@hey-api/openapi-ts 0.89.2 → 0.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +14 -13
  2. package/dist/clients/angular/client.ts +4 -0
  3. package/dist/clients/axios/client.ts +4 -0
  4. package/dist/clients/fetch/client.ts +4 -0
  5. package/dist/clients/ky/client.ts +4 -0
  6. package/dist/clients/next/client.ts +4 -0
  7. package/dist/clients/nuxt/client.ts +5 -0
  8. package/dist/clients/nuxt/types.ts +15 -9
  9. package/dist/{config-CREHWzRd.d.cts → config-DT26kmcq.d.cts} +2481 -1607
  10. package/dist/{config-Baq-Kb-6.d.mts → config-Dis5Gu6e.d.mts} +2488 -1614
  11. package/dist/index.cjs +2 -1
  12. package/dist/index.d.cts +49 -32
  13. package/dist/index.d.mts +22 -5
  14. package/dist/index.mjs +2 -1
  15. package/dist/internal.cjs +2 -1
  16. package/dist/internal.d.cts +2 -1
  17. package/dist/internal.d.mts +2 -1
  18. package/dist/internal.mjs +2 -1
  19. package/dist/openApi-BU6F2oHy.mjs +14 -0
  20. package/dist/openApi-BU6F2oHy.mjs.map +1 -0
  21. package/dist/openApi-CcUF29dR.cjs +14 -0
  22. package/dist/openApi-CcUF29dR.cjs.map +1 -0
  23. package/dist/run.cjs +3 -1
  24. package/dist/run.cjs.map +1 -1
  25. package/dist/run.d.cts +1 -0
  26. package/dist/run.d.mts +1 -0
  27. package/dist/run.mjs +3 -1
  28. package/dist/run.mjs.map +1 -1
  29. package/dist/{src-CnDKH9rV.cjs → src-CHy94xdb.cjs} +5 -4
  30. package/dist/src-CHy94xdb.cjs.map +1 -0
  31. package/dist/{src-novPNOHw.mjs → src-DnaJOx9H.mjs} +5 -4
  32. package/dist/src-DnaJOx9H.mjs.map +1 -0
  33. package/package.json +6 -6
  34. package/dist/openApi-DV_SToAE.cjs +0 -13
  35. package/dist/openApi-DV_SToAE.cjs.map +0 -1
  36. package/dist/openApi-Dz9FsU_q.mjs +0 -13
  37. package/dist/openApi-Dz9FsU_q.mjs.map +0 -1
  38. package/dist/src-CnDKH9rV.cjs.map +0 -1
  39. package/dist/src-novPNOHw.mjs.map +0 -1
@@ -0,0 +1,14 @@
1
+
2
+ import{createRequire as e}from"node:module";import{Project as t,StructureModel as n,fromRef as r,isNode as i,isRef as a,isSymbol as o,log as s,nodeBrand as c,ref as l,refs as u}from"@hey-api/codegen-core";import d from"ansi-colors";import f from"node:fs";import p from"node:path";import{fileURLToPath as m}from"node:url";import h from"typescript";import{EOL as ee}from"node:os";import*as te from"semver";import{getResolvedInput as ne,sendRequest as re}from"@hey-api/json-schema-ref-parser";var ie=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ae=e(import.meta.url);const oe=m(import.meta.url),se=p.dirname(oe),ce=()=>{let e=se;for(;e!==p.dirname(e);){let t=f.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=p.join(e,t[0]);return JSON.parse(f.readFileSync(n,{encoding:`utf8`}))}e=p.dirname(e)}},le=()=>{let e=ce(),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},ue=e=>{if(e===null)return null;if(e){let t=p.isAbsolute(e)?e:p.resolve(se,e);return f.existsSync(t)?t:null}let t=se;for(;t!==p.dirname(t);){let e=f.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return p.join(t,e[0]);t=p.dirname(t)}return null},de=e=>{if(!e)return null;let t=h.readConfigFile(e,h.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return h.parseJsonConfigFileContent(t.config,h.sys,p.dirname(e))},fe=e=>{f.existsSync(e)||f.mkdirSync(e,{recursive:!0})};var pe=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},me=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},he=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},ge=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 _e=(e,t)=>{if(e instanceof pe||e instanceof me)return;e instanceof he&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=p.resolve(process.cwd(),t);fe(r);let i=p.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof ge&&(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 o=e instanceof Error?e.message:String(e),s=e instanceof Error?e.stack:void 0;return a+=`Error: ${o}\n`,s&&(a+=`Stack:\n${s}\n`),f.writeFileSync(i,a),i},ve=async e=>{let t=le();if(!t.bugs.url)return;e instanceof he&&(e=e.originalError.error);let n=``;e instanceof ge&&(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)},ye=({error:e,logPath:t})=>{if(e instanceof me&&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=d.gray(`[Job ${e+1}] `),r=n.length,i=d.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=d.red(r);console.error(`${t}${i}${d.white(e.message)}`)})}}else{let t=d.gray(`[root] `);e instanceof he&&(t=d.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=d.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=d.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=d.gray(`[root] `);console.error(`${e}${d.cyan(`📄 Crash log saved to:`)} ${d.gray(t)}`)}},be=async({error:e,isInteractive:t})=>!t||e instanceof pe||e instanceof me?!1:new Promise(e=>{let t=d.gray(`[root] `);console.log(`${t}${d.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),xe=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,Se=`https://get.heyapi.dev`,Ce=(e,t,n)=>`${Se}/${e}/${t}${n?`?${n}`:``}`,we=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(xe);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}},Te=e=>{let t=we(e);return{path:Ce(t.organization,t.project,t.queryParams),registry:`hey-api`}},Ee=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,De=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,Oe=`readme`,ke=e=>{let t=e.match(Ee);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${Oe}:@organization/project#uuid" or "${Oe}:uuid", received: ${Oe}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Ae=e=>{let t=ke(e.slice(`${Oe}:`.length));return{...t,path:De(t.uuid),registry:`readme`}},je=/^(@[\w-]+)\/([\w.-]+)$/,Me=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Ne=`scalar`,Pe=e=>{let t=e.match(je);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${Ne}:@organization/project", received: ${Ne}:${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}},Fe=e=>{let t=Pe(e.slice(`${Ne}:`.length));return{...t,path:Me(t.organization,t.project),registry:`scalar`}},Ie=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Ae(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,Fe(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(Se)){e.path=e.path.slice(23),Object.assign(e,Te(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,Te(e));return}},Le={enabled:!1,interval:1e3,timeout:6e4},Re=e=>{let t={...Le};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},ze=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Le};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:Se,...r},t.watch!==void 0&&(t.watch=Re(t))):t={...t,path:r},typeof t.path==`string`&&Ie(t),e.watch!==void 0&&t.watch.enabled===Le.enabled&&t.watch.interval===Le.interval&&t.watch.timeout===Le.timeout&&(t.watch=Re({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Be=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Ve=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},He=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Ve(n.logs,r.logs)),i},Ue=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,We=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},g=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=We(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=We(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=We(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=We(r,e(n))}break;case`object`:if(Ue(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=We(r,i(n,e))}else r=We(r,n);break}return r},Ge=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=g({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,header:`// This file is auto-generated by @hey-api/openapi-ts`,indexFile:!0,lint:null,path:``,preferExportAll:!1},mappers:{object:(e,t)=>({...e,fileName:g({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=de(ue(t.tsConfigPath)),t.importFileExtension===void 0&&(t.tsConfig?.options.moduleResolution===h.ModuleResolutionKind.NodeNext||t.tsConfig?.options.moduleResolution===h.ModuleResolutionKind.Node16)&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Ke=e=>{let t=e?p.dirname(e):process.cwd();for(;t!==p.dirname(t);){let e=p.join(t,`package.json`);if(f.existsSync(e))try{let t=JSON.parse(f.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=p.dirname(t);if(n===t)break;t=n}return{}},qe=[`after`,`before`,`cursor`,`offset`,`page`,`start`],Je=e=>g({defaultValue:{hooks:{},pagination:{keywords:qe},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:g({defaultValue:{...t.pagination},value:e.pagination}),transforms:g({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:g({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:g({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:g({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:g({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}),Ye=e=>t=>({...e,config:{...e.config,...t}}),_={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};function Xe(e,t){let n=e.httpRequests;typeof n==`string`||typeof n==`function`?n={strategy:n}:(typeof n==`boolean`||!n)&&(n={enabled:!!n});let r=n.strategy??`flat`;return t.valueToObject({defaultValue:{container:`class`,enabled:!0,methods:`instance`,nesting:`operationId`,nestingDelimiters:/[./]/,strategy:r,strategyDefaultTag:`default`},mappers:{object(e){return e.containerName=t.valueToObject({defaultValue:r===`single`?{casing:`PascalCase`,name:`HttpRequests`}:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.containerName}),e.methodName=t.valueToObject({defaultValue:r===`flat`?{casing:`camelCase`,name:`{{name}}Request`}:{casing:`camelCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.methodName}),e.segmentName=t.valueToObject({defaultValue:{casing:`PascalCase`,name:`{{name}}Requests`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.segmentName}),e}},value:n})}const v={byTags:e=>t=>{let n=t.tags&&t.tags.length>0?t.tags:[e.fallback],r=(e.path??y.id())(t);return n.map(e=>[e,...r])},flat:e=>t=>{let n=(e?.path??y.id())(t);return[[n[n.length-1]]]},single:e=>t=>{let n=(e.path??y.id())(t);return[[e.root,...n]]}},y={fromOperationId:e=>t=>{let n=e?.fallback??y.id();if(!t.operationId)return n(t);let r=e?.delimiters??/[./]/,i=t.operationId.split(r).filter(Boolean);return i.length===0?n(t):i},fromPath:e=>t=>{let n=e?.delimiters??/[./]/,r=t.path.split(n).filter(Boolean);switch(e?.methodPosition){case`prefix`:r.unshift(t.method.toLowerCase());break;case`suffix`:r.push(t.method.toLowerCase());break;default:break}return r},id:()=>e=>[e.id]};function Ze(e){return e.config.httpRequests.nesting===`id`?y.id():e.config.httpRequests.nesting===`operationId`?y.fromOperationId({delimiters:e.config.httpRequests.nestingDelimiters,fallback:y.id()}):e.config.httpRequests.nesting}function Qe(e){if(e.config.httpRequests.strategy===`flat`)return v.flat({path:t=>[Ze(e)(t).join(`.`)]});if(e.config.httpRequests.strategy===`single`){let t=e.config.httpRequests.containerName;return v.single({path:Ze(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.httpRequests.strategy===`byTags`?v.byTags({fallback:e.config.httpRequests.strategyDefaultTag,path:Ze(e)}):e.config.httpRequests.strategy}function $e(e,t){let n=e.httpResources;typeof n==`string`||typeof n==`function`?n={strategy:n}:(typeof n==`boolean`||!n)&&(n={enabled:!!n});let r=n.strategy??`flat`;return t.valueToObject({defaultValue:{container:`class`,enabled:!0,methods:`instance`,nesting:`operationId`,nestingDelimiters:/[./]/,strategy:r,strategyDefaultTag:`default`},mappers:{object(e){return e.containerName=t.valueToObject({defaultValue:r===`single`?{casing:`PascalCase`,name:`HttpResources`}:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.containerName}),e.methodName=t.valueToObject({defaultValue:r===`flat`?{casing:`camelCase`,name:`{{name}}Resource`}:{casing:`camelCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.methodName}),e.segmentName=t.valueToObject({defaultValue:{casing:`PascalCase`,name:`{{name}}Resources`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.segmentName}),e}},value:n})}function et(e){return e.config.httpResources.nesting===`id`?y.id():e.config.httpResources.nesting===`operationId`?y.fromOperationId({delimiters:e.config.httpResources.nestingDelimiters,fallback:y.id()}):e.config.httpResources.nesting}function tt(e){if(e.config.httpResources.strategy===`flat`)return v.flat({path:t=>[et(e)(t).join(`.`)]});if(e.config.httpResources.strategy===`single`){let t=e.config.httpResources.containerName;return v.single({path:et(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.httpResources.strategy===`byTags`?v.byTags({fallback:e.config.httpResources.strategyDefaultTag,path:et(e)}):e.config.httpResources.strategy}const nt=e=>{let t=b(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},b=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},rt=({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]},it=e=>{for(let t in e)if(e[t].required)return!0;return!1},at=e=>e?!!(it(e.cookie)||it(e.header)||it(e.path)||it(e.query)):!1,ot=({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:rt({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:rt({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:rt({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:rt({context:e,parameter:r})}}}},x=({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},S=({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,st=e=>!!(at(e.parameters)||e.body?.required),C=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,ct=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return ot({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}:ot({context:e,parameters:t.parameters})},lt=({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`}},ut=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(lt({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=S({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=x({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=S({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=x({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t};var w=class{analyze(e){}clone(){let e=Object.create(Object.getPrototypeOf(this));return Object.assign(e,this),e}exported;file;get name(){return{...this._name,set:e=>{this._name=l(e),o(e)&&e.setNode(this)},toString:()=>this._name?this.$name(this._name):``}}nameSanitizer;language=`typescript`;parent;root=!1;scope=`value`;structuralChildren;structuralParents;symbol;toAst(){}"~brand"=c;$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}$maybeId(e){return typeof e==`string`?h.factory.createIdentifier(e):e}$name(e){let t=r(e);if(o(t))try{return t.finalName}catch{return t.name}return String(t)}$node(e){if(e!==void 0)return a(e)&&(e=r(e)),o(e)?this.$maybeId(e.finalName):typeof e==`string`?this.$maybeId(e):e instanceof Array?e.map(e=>(a(e)&&(e=r(e)),this.unwrap(e))):this.unwrap(e)}$type(e,t){if(e!==void 0){if(a(e)&&(e=r(e)),o(e))return h.factory.createTypeReferenceNode(e.finalName,t);if(typeof e==`string`)return h.factory.createTypeReferenceNode(e,t);if(typeof e==`boolean`){let t=e?h.factory.createTrue():h.factory.createFalse();return h.factory.createLiteralTypeNode(t)}return typeof e==`number`?h.factory.createLiteralTypeNode(h.factory.createNumericLiteral(e)):e instanceof Array?e.map(e=>this.$type(e,t)):this.unwrap(e)}}_name;unwrap(e){return i(e)?e.toAst():e}},dt=class extends w{};const ft=w;var pt=class extends ft{"~dsl"=`IdTsDsl`;constructor(e){super(),this.name.set(e)}analyze(e){super.analyze(e)}toAst(){return h.factory.createIdentifier(this.name.toString())}},mt=class extends w{"~dsl"=`NewlineTsDsl`;analyze(e){super.analyze(e)}toAst(){return this.$node(new pt(`
3
+ `))}};function ht(e){class t extends e{_args=[];analyze(e){super.analyze(e);for(let t of this._args)e.analyze(t)}arg(e){return e!==void 0&&this._args.push(l(e)),this}args(...e){return this._args.push(...e.filter(e=>e!==void 0).map(e=>l(e))),this}$args(){return this.$node(this._args).map(e=>this.$node(e))}}return t}const gt=w;var _t=class extends gt{"~dsl"=`PrefixTsDsl`;_expr;_op;constructor(e,t){super(),this._expr=e,this._op=t}analyze(e){super.analyze(e),e.analyze(this._expr)}expr(e){return this._expr=e,this}neg(){return this._op=h.SyntaxKind.MinusToken,this}not(){return this._op=h.SyntaxKind.ExclamationToken,this}op(e){return this._op=e,this}toAst(){if(!this._expr)throw Error(`Missing expression for prefix unary expression`);if(!this._op)throw Error(`Missing operator for prefix unary expression`);return h.factory.createPrefixUnaryExpression(this._op,this.$node(this._expr))}};function T(e){let t,n=((...n)=>{if(!t)throw Error(`${e} factory not registered`);return t(...n)});return n.set=e=>{t=e},n}const E={as:T(`as`),attr:T(`attr`),await:T(`await`),call:T(`call`),new:T(`new`),return:T(`return`),type:{expr:T(`type.expr`),idx:T(`type.idx`),operator:T(`type.operator`),query:T(`type.query`)},typeofExpr:T(`typeofExpr`)};function D(e){class t extends e{analyze(e){super.analyze(e)}as(...e){return E.as(this,...e)}}return t}const vt=D(w);var O=class extends vt{"~dsl"=`LiteralTsDsl`;value;constructor(e){super(),this.value=e}analyze(e){super.analyze(e)}toAst(){if(typeof this.value==`boolean`)return this.value?h.factory.createTrue():h.factory.createFalse();if(typeof this.value==`number`){let e=h.factory.createNumericLiteral(Math.abs(this.value));return this.value<0?this.$node(new _t(e).neg()):e}if(typeof this.value==`string`)return h.factory.createStringLiteral(this.value,!0);if(typeof this.value==`bigint`)return h.factory.createBigIntLiteral(this.value.toString());if(this.value===null)return h.factory.createNull();throw Error(`Unsupported literal: ${String(this.value)}`)}};const k={illegalStartCharacters:/^[^$_\p{ID_Start}]+/u,number:/^-?\d+(\.\d+)?$/,typeScriptIdentifier:/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u},yt={browserGlobals:[`document`,`history`,`location`,`navigator`,`window`],javaScriptGlobals:[`console`,`Array`,`Date`,`Error`,`Function`,`JSON`,`Map`,`Math`,`Object`,`Promise`,`RegExp`,`Set`,`WeakMap`,`WeakSet`],javaScriptKeywords:`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`.split(`.`),nodeGlobals:[`global`,`process`,`Buffer`],typeScriptKeywords:[`any`,`as`,`bigint`,`boolean`,`namespace`,`never`,`null`,`number`,`string`,`symbol`,`type`,`undefined`,`unknown`,`void`]};var bt=class{_array;_set;constructor(e){this._array=e,this._set=new Set(e)}get"~values"(){return this._set}set(e){let t=typeof e==`function`?e(this._array):e;this._array=t,this._set=new Set(t)}};const xt={runtime:new bt([...yt.browserGlobals,...yt.javaScriptGlobals,...yt.javaScriptKeywords,...yt.nodeGlobals,...yt.typeScriptKeywords]),type:new bt([...yt.javaScriptKeywords,...yt.typeScriptKeywords])},St=e=>(k.number.lastIndex=0,k.number.test(e)?e.startsWith(`-`)?`'${e}'`:e:(k.typeScriptIdentifier.lastIndex=0,k.typeScriptIdentifier.test(e)?e:`'${e}'`)),Ct=e=>(k.typeScriptIdentifier.lastIndex=0,k.typeScriptIdentifier.test(e)?new pt(e):new O(e)),wt=e=>(k.number.lastIndex=0,k.number.test(e)?e.startsWith(`-`)?new O(e):new O(Number(e)):(k.typeScriptIdentifier.lastIndex=0,k.typeScriptIdentifier.test(e)?new pt(e):new O(e))),Tt=(e,t)=>{let n=``,r,i=e[0];for(k.illegalStartCharacters.lastIndex=0,k.illegalStartCharacters.test(i)?(n+=`_`,r=0):(n+=i,r=1);r<e.length;){let t=e[r];n+=/^[\u200c\u200d\p{ID_Continue}]$/u.test(t)?t:`_`,r+=1}return t[`~values`].has(n)&&(n=`${n}_`),n||`_`},Et=e=>Tt(e,xt.runtime),Dt=e=>Tt(e,xt.type),Ot=ht(w);var kt=class extends Ot{"~dsl"=`DecoratorTsDsl`;nameSanitizer=Et;constructor(e,...t){super(),this.name.set(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this.name)}toAst(){let e=this.$node(this.name),t=this.$args();return h.factory.createDecorator(t.length?h.factory.createCallExpression(e,void 0,t):e)}};function At(e){class t extends e{decorators=[];analyze(e){super.analyze(e);for(let t of this.decorators)e.analyze(t)}decorator(e,...t){return this.decorators.push(new kt(e,...t)),this}$decorators(){return this.$node(this.decorators)}}return t}function jt(e){let t;return e.forEach((e,n)=>{t=n===0?e:t.attr(e.name)}),t}function Mt(e){let t=Lt([...Pt(e,new Set)]);return t.length===0?[e.clone()]:t.map(e=>e.clone())}function Nt(e){return e.scope??`value`}function Pt(e,t){if(t.has(e)||(t.add(e),It(e)))return[];if(e.structuralParents)for(let[n]of e.structuralParents){if(Nt(n)!==Nt(e))continue;let r=Pt(n,t);if(r.length>0)return[...r,e]}return e.root?[e]:[]}function Ft(e){return e[`~dsl`]===`FieldTsDsl`||e[`~dsl`]===`GetterTsDsl`||e[`~dsl`]===`MethodTsDsl`}function It(e){return e[`~dsl`]===`FuncTsDsl`||e[`~dsl`]===`TemplateTsDsl`}function Lt(e){let t=[];return e.forEach((e,n)=>{(n===0||Ft(e))&&t.push(e)}),t}function Rt(e,t={}){return e.map((n,r)=>{let i=t.transform?.(n,r,e);if(i)return i;let a=n.toAccessNode?.(n,t,{chain:e,index:r,isLeaf:r===e.length-1,isRoot:r===0,length:e.length});if(a)return a;if(r===0){if(n[`~dsl`]===`ClassTsDsl`){let t=e[r+1];return t&&Ft(t)&&t.hasModifier(`static`)?F(n.name):F.new(n.name).args()}return F(n.name)}return n})}var zt=class{access(e,t){let n=o(e)?e.node:e;if(!n)throw Error(`Symbol ${e.name} is not resolved to a node.`);return jt(Rt(Mt(n),t))}example(e,t,n){if(n)return ui.astToString(n);if(!t)throw Error(`Example options are required.`);let r=Mt(e);t.importName&&r[0].name.set(t.importName);let i=F(r[0].name.toString()),a=Rt(r,{context:`example`}),o=t.importSetup?typeof t.importSetup==`function`?t.importSetup(i):t.importSetup:a[0],s=t.setupName,c=t.payload instanceof Array?t.payload:t.payload?[t.payload]:[],l=[];l=s?[F.const(s).assign(o),jt([F(s),...a.slice(1)]).call(...c)]:[jt([o,...a.slice(1)]).call(...c)];let u=i.name.toString();return ui.astToString({imports:[[{imports:!t.importKind||t.importKind===`named`?[{isTypeOnly:!1,localName:u,sourceName:u}]:[],isTypeOnly:!1,kind:t.importKind??`named`,localName:t.importKind===`named`?void 0:u,modulePath:t.moduleName}]],nodes:l,trailingNewline:!1})}},Bt=class extends w{"~dsl"=`DocTsDsl`;_lines=[];constructor(e,t){super(),e&&this.add(e),t?.(this)}analyze(e){super.analyze(e)}add(e){return this._lines.push(e),this}apply(e){let t=new zt,n=this._lines.reduce((e,n)=>{typeof n==`function`&&(n=n(t));for(let t of typeof n==`string`?[n]:n)(t||t===``)&&e.push(t);return e},[]);if(!n.length)return e;let r=n.map(e=>h.factory.createJSDocText(`${e}\n`)),i=h.factory.createJSDocComment(h.factory.createNodeArray(r),void 0),a=h.createPrinter().printNode(h.EmitHint.Unspecified,i,e.getSourceFile?.()??h.createSourceFile(``,``,h.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return h.addSyntheticLeadingComment(e,h.SyntaxKind.MultiLineCommentTrivia,a,!0),e}toAst(){return this.$node(new pt(``))}};function A(e){class t extends e{_doc;analyze(e){super.analyze(e)}doc(e,t){return this._doc=new Bt(e,t),this}$docs(e){return this._doc?this._doc.apply(e):e}}return t}function Vt(e){switch(e){case`abstract`:return h.SyntaxKind.AbstractKeyword;case`async`:return h.SyntaxKind.AsyncKeyword;case`const`:return h.SyntaxKind.ConstKeyword;case`declare`:return h.SyntaxKind.DeclareKeyword;case`default`:return h.SyntaxKind.DefaultKeyword;case`export`:return h.SyntaxKind.ExportKeyword;case`override`:return h.SyntaxKind.OverrideKeyword;case`private`:return h.SyntaxKind.PrivateKeyword;case`protected`:return h.SyntaxKind.ProtectedKeyword;case`public`:return h.SyntaxKind.PublicKeyword;case`readonly`:return h.SyntaxKind.ReadonlyKeyword;case`static`:return h.SyntaxKind.StaticKeyword}}function j(e){class t extends e{modifiers=[];analyze(e){super.analyze(e)}hasModifier(e){let t=Vt(e);return!!this.modifiers.find(e=>e.kind===t)}_m(e,t){if(t){let t=Vt(e);this.modifiers.push(h.factory.createModifier(t))}return this}}return t}function Ht(e){let t=j(e);class n extends t{abstract(e){let t=arguments.length===0?!0:!!e;return this._m(`abstract`,t)}}return n}function Ut(e){let t=j(e);class n extends t{async(e){let t=arguments.length===0?!0:!!e;return this._m(`async`,t)}}return n}function Wt(e){let t=j(e);class n extends t{const(e){let t=arguments.length===0?!0:!!e;return this._m(`const`,t)}}return n}function Gt(e){let t=j(e);class n extends t{default(e){let t=arguments.length===0?!0:!!e;return this._m(`default`,t)}}return n}function Kt(e){let t=j(e);class n extends t{export(e){let t=arguments.length===0?!0:!!e;return this.exported=t,this.symbol&&this.symbol.setExported(t),this._m(`export`,t)}}return n}function qt(e){let t=j(e);class n extends t{private(e){let t=arguments.length===0?!0:!!e;return this._m(`private`,t)}}return n}function Jt(e){let t=j(e);class n extends t{protected(e){let t=arguments.length===0?!0:!!e;return this._m(`protected`,t)}}return n}function Yt(e){let t=j(e);class n extends t{public(e){let t=arguments.length===0?!0:!!e;return this._m(`public`,t)}}return n}function Xt(e){let t=j(e);class n extends t{readonly(e){let t=arguments.length===0?!0:!!e;return this._m(`readonly`,t)}}return n}function Zt(e){let t=j(e);class n extends t{static(e){let t=arguments.length===0?!0:!!e;return this._m(`static`,t)}}return n}const Qt=w;var $t=class extends Qt{"~dsl"=`TypeParamTsDsl`;scope=`type`;constraint;defaultValue;constructor(e,t){super(),e&&this.name.set(e),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this.constraint),e.analyze(this.defaultValue)}default(e){return this.defaultValue=l(e),this}extends(e){return this.constraint=l(e),this}toAst(){if(!this.name.toString())throw Error(`Missing type name`);return h.factory.createTypeParameterDeclaration(void 0,this.$node(this.name),this.$type(this.constraint),this.$type(this.defaultValue))}};function en(e){class t extends e{_generics=[];analyze(e){super.analyze(e);for(let t of this._generics)e.analyze(t)}generic(...e){let t=new $t(...e);return this._generics.push(t),this}generics(...e){for(let t of e)(typeof t==`string`||typeof t==`number`||o(t)||a(t))&&(t=new $t(t)),this._generics.push(t);return this}$generics(){return this.$node(this._generics)}}return t}function tn(e){class t extends e{_optional;analyze(e){super.analyze(e)}optional(e){return this._optional=arguments.length===0?!0:!!e,this}required(e){return this._optional=arguments.length===0?!1:!e,this}}return t}function nn(e){class t extends e{value;analyze(e){super.analyze(e),e.analyze(this.value)}assign(e){return this.value=e,this}$value(){return this.$node(this.value)}}return t}var M=class extends w{"~dsl"=`TokenTsDsl`;_kind;kind(e){return this._kind=e,this}minus(){return this.kind(h.SyntaxKind.MinusToken)}optional(){return this.kind(h.SyntaxKind.QuestionToken)}plus(){return this.kind(h.SyntaxKind.PlusToken)}questionDot(){return this.kind(h.SyntaxKind.QuestionDotToken)}readonly(){return this.kind(h.SyntaxKind.ReadonlyKeyword)}spread(){return this.kind(h.SyntaxKind.DotDotDotToken)}toAst(){if(!this._kind)throw Error("Token missing `.kind(kind)`");return h.factory.createToken(this._kind)}};function rn(e){class t extends e{_generics=[];analyze(e){super.analyze(e);for(let t of this._generics)e.analyze(t)}generic(e){return this._generics.push(l(e)),this}generics(...e){return this._generics.push(...e.map(e=>l(e))),this}$generics(){return this.$type(this._generics)}}return t}function an(e){class t extends e{analyze(e){super.analyze(e)}idx(...e){return E.type.idx(this,...e)}keyof(){return E.type.operator().keyof(this)}readonly(){return E.type.operator().readonly(this)}returnType(...e){return E.type.expr(`ReturnType`).generic(E.type.query(this,...e))}typeofExpr(...e){return E.typeofExpr(this,...e)}typeofType(...e){return E.type.query(this,...e)}unique(){return E.type.operator().unique(this)}}return t}const on=an(w);var sn=class extends on{"~dsl"=`TypeAttrTsDsl`;scope=`type`;_base;_right;constructor(e,t){super(),t?(this.base(e),this.right(t)):(this.base(),this.right(e))}analyze(e){super.analyze(e),e.analyze(this._base),e.analyze(this._right)}base(e){return a(e)?this._base=e:this._base=e?l(e):void 0,this}right(e){return this._right=l(e),this}toAst(){if(!this._base)throw Error(`TypeAttrTsDsl: missing base for qualified name`);let e=this.$node(this._base);if(!h.isEntityName(e))throw Error(`TypeAttrTsDsl: base must be an EntityName`);return h.factory.createQualifiedName(e,this.$node(this._right))}};const cn=rn(an(w));var ln=class extends cn{"~dsl"=`TypeExprTsDsl`;scope=`type`;_exprInput;constructor(e,t){super(),typeof e==`function`?e(this):(this._exprInput=e?l(e):void 0,t?.(this))}analyze(e){super.analyze(e),e.analyze(this._exprInput)}attr(e){return this._exprInput=i(e)?l(e.base(this._exprInput)):l(new sn(this._exprInput,e)),this}toAst(){if(!this._exprInput)throw Error(`TypeExpr must have an expression`);return h.factory.createTypeReferenceNode(this.$type(this._exprInput),this.$generics())}};E.type.expr.set((...e)=>new ln(...e));const un=At(A(tn(qt(Jt(Yt(Xt(Zt(nn(w)))))))));var dn=class extends un{"~dsl"=`FieldTsDsl`;nameSanitizer=St;_type;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}type(e){return this._type=e instanceof dt?e:new ln(e),this}toAst(){let e=h.factory.createPropertyDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this._optional?this.$node(new M().optional()):void 0,this.$type(this._type),this.$value());return this.$docs(e)}};const fn=w;var pn=class extends fn{"~dsl"=`StmtTsDsl`;_inner;constructor(e){super(),this._inner=e}analyze(e){super.analyze(e),e.analyze(this._inner)}toAst(){let e=this.$node(this._inner);return h.isStatement(e)?e:h.factory.createExpressionStatement(e)}};function mn(e){class t extends e{_do=[];analyze(e){super.analyze(e),e.pushScope();try{for(let t of this._do)e.analyze(t)}finally{e.popScope()}}do(...e){return this._do.push(...e),this}$do(){return this.$node(this._do.map(e=>new pn(e)))}}return t}const hn=w;var gn=class extends hn{"~dsl"=`PatternTsDsl`;pattern;_spread;analyze(e){super.analyze(e)}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}toAst(){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?h.factory.createBindingElement(void 0,void 0,e,void 0):h.factory.createBindingElement(void 0,e,t,void 0)),t=this.createSpread();return t&&e.push(t),h.factory.createObjectBindingPattern(e)}if(this.pattern.kind===`array`){let e=this.pattern.values.map(e=>h.factory.createBindingElement(void 0,void 0,e,void 0)),t=this.createSpread();return t&&e.push(t),h.factory.createArrayBindingPattern(e)}throw Error(`PatternTsDsl requires object() or array() pattern`)}createSpread(){return this._spread?h.factory.createBindingElement(this.$node(new M().spread()),void 0,this.$node(new pt(this._spread))):void 0}};function _n(e){class t extends e{pattern;analyze(e){super.analyze(e),e.analyze(this.pattern)}array(...e){return(this.pattern??=new gn).array(...e),this}object(...e){return(this.pattern??=new gn).object(...e),this}spread(e){return(this.pattern??=new gn).spread(e),this}$pattern(){if(this.pattern)return this.$node(this.pattern)}}return t}const vn=At(tn(_n(nn(w))));var yn=class extends vn{"~dsl"=`ParamTsDsl`;_type;constructor(e,t){super(),typeof e==`function`?e(this):(this.name.set(e),t?.(this))}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}type(e){return this._type=e instanceof dt?e:new ln(e),this}toAst(){let e=this.$pattern()||this.name.toString();if(!e)throw Error(`Param must have either a name or a destructuring pattern`);return h.factory.createParameterDeclaration(this.$decorators(),void 0,e,this._optional?this.$node(new M().optional()):void 0,this.$type(this._type),this.$value())}};function bn(e){class t extends e{_params=[];analyze(e){super.analyze(e);for(let t of this._params)e.analyze(t)}param(e,t){let n=new yn(e,t);return this._params.push(n),this}params(...e){return this._params.push(...e),this}$params(){return this.$node(this._params)}}return t}function xn(e){class t extends e{static DEFAULT_THRESHOLD=3;layout;analyze(e){super.analyze(e)}auto(e=t.DEFAULT_THRESHOLD){return this.layout=e,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}$multiline(e){return this.layout===void 0&&(this.layout=t.DEFAULT_THRESHOLD),e===0?!1:typeof this.layout==`number`?e>=this.layout:this.layout}}return t}const Sn=mn(xn(w));var N=class extends Sn{"~dsl"=`BlockTsDsl`;constructor(...e){super(),this.do(...e)}analyze(e){super.analyze(e)}toAst(){let e=this.$do();return h.factory.createBlock(e,this.$multiline(e.length))}};const Cn=At(mn(A(bn(qt(Jt(Yt(w)))))));var wn=class extends Cn{"~dsl"=`InitTsDsl`;constructor(e){super(),e?.(this)}analyze(e){e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=h.factory.createConstructorDeclaration([...this.$decorators(),...this.modifiers],this.$params(),this.$node(new N(...this._do).pretty()));return this.$docs(e)}};function Tn(e){class t extends e{_returns;analyze(e){super.analyze(e),e.analyze(this._returns)}returns(e){return this._returns=e instanceof dt?e:new ln(e),this}$returns(){return this.$type(this._returns)}}return t}const En=Ht(Ut(At(mn(A(tn(bn(qt(Jt(Yt(Zt(en(Tn(w)))))))))))));var Dn=class extends En{"~dsl"=`MethodTsDsl`;nameSanitizer=St;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){e.analyze(this.name),e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=h.factory.createMethodDeclaration([...this.$decorators(),...this.modifiers],void 0,this.$node(this.name),this._optional?this.$node(new M().optional()):void 0,this.$generics(),this.$params(),this.$returns(),this.$node(new N(...this._do).pretty()));return this.$docs(e)}};const On=Ht(At(Gt(A(Kt(en(w))))));var kn=class extends On{"~dsl"=`ClassTsDsl`;nameSanitizer=Et;baseClass;body=[];constructor(e){super(),this.name.set(e),o(e)&&e.setKind(`class`)}analyze(e){super.analyze(e),e.analyze(this.baseClass),e.analyze(this.name),e.pushScope();try{for(let t of this.body)e.analyze(t)}finally{e.popScope()}}get hasBody(){return this.body.length>0}do(...e){return this.body.push(...e),this}extends(e){return this.baseClass=e?l(e):void 0,this}field(e,t){let n=new dn(e,t);return this.body.push(n),this}init(e){let t=typeof e==`function`?new wn(e):e||new wn;return this.body.push(t),this}method(e,t){let n=new Dn(e,t);return this.body.push(n),this}newline(){return this.body.push(new mt),this}toAst(){let e=this.$node(this.body),t=h.factory.createClassDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$generics(),this._heritage(),e);return this.$docs(t)}_heritage(){let e=this.$node(this.baseClass);return e?[h.factory.createHeritageClause(h.SyntaxKind.ExtendsKeyword,[h.factory.createExpressionWithTypeArguments(e,void 0)])]:[]}};const An=A(w);var jn=class extends An{"~dsl"=`EnumMemberTsDsl`;_value;constructor(e,t){super(),this.name.set(e),typeof t==`function`?t(this):this.value(t)}analyze(e){super.analyze(e),e.analyze(this._value)}value(e){return this._value=e,this}toAst(){let e=h.factory.createEnumMember(this.$node(Ct(this.name.toString())),this.$node(this._value));return this.$docs(e)}};const Mn=Wt(A(Kt(w)));var Nn=class extends Mn{"~dsl"=`EnumTsDsl`;nameSanitizer=Et;_members=[];constructor(e,t){super(),this.name.set(e),o(e)&&e.setKind(`enum`),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.pushScope();try{for(let t of this._members)e.analyze(t)}finally{e.popScope()}}member(e,t){let n=new jn(e,t);return this._members.push(n),this}members(...e){return this._members.push(...e),this}toAst(){let e=h.factory.createEnumDeclaration(this.modifiers,this.$node(this.name),this.$node(this._members));return this.$docs(e)}};const Pn=Ht(D(Ut(At(mn(A(bn(qt(Jt(Yt(Zt(en(Tn(w))))))))))))),Fn=class extends Pn{"~dsl"=`FuncTsDsl`;nameSanitizer=Et;mode;constructor(e,t){super(),typeof e==`function`?(this.mode=`arrow`,e(this)):e&&(this.mode=`decl`,this.name.set(e),o(e)&&e.setKind(`function`),t?.(this))}analyze(e){e.pushScope();try{super.analyze(e),e.analyze(this.name)}finally{e.popScope()}}arrow(){return this.mode=`arrow`,this}decl(){return this.mode=`decl`,this}expr(){return this.mode=`expr`,this}toAst(){let e=this.$node(new N(...this._do).pretty());if(this.mode===`decl`){if(!this.name.toString())throw Error(`Function declaration requires a name`);let t=h.factory.createFunctionDeclaration([...this.$decorators(),...this.modifiers],void 0,this.$node(this.name),this.$generics(),this.$params(),this.$returns(),e);return this.$docs(t)}if(this.mode===`expr`){let t=h.factory.createFunctionExpression(this.modifiers,void 0,this.$node(this.name),this.$generics(),this.$params(),this.$returns(),e);return this.$docs(t)}let t=h.factory.createArrowFunction(this.modifiers,this.$generics(),this.$params(),this.$returns(),void 0,e.statements.length===1&&h.isReturnStatement(e.statements[0])&&e.statements[0].expression?e.statements[0].expression:e);return this.$docs(t)}},In=Ht(Ut(At(mn(A(bn(qt(Jt(Yt(Zt(Tn(w)))))))))));var Ln=class extends In{"~dsl"=`GetterTsDsl`;nameSanitizer=St;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){e.analyze(this.name),e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=h.factory.createGetAccessorDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$params(),this.$returns(),this.$node(new N(...this._do).pretty()));return this.$docs(e)}};const Rn=Ht(Ut(At(mn(A(bn(qt(Jt(Yt(Zt(w))))))))));var zn=class extends Rn{"~dsl"=`SetterTsDsl`;nameSanitizer=St;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){e.analyze(this.name),e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=h.factory.createSetAccessorDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$params(),this.$node(new N(...this._do).pretty()));return this.$docs(e)}};const Bn=D(xn(w));var Vn=class extends Bn{"~dsl"=`ArrayTsDsl`;_elements=[];constructor(...e){super(),this.elements(...e)}analyze(e){super.analyze(e);for(let t of this._elements)e.analyze(t.expr)}element(e){let t=typeof e==`string`||typeof e==`number`||typeof e==`boolean`?new O(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}toAst(){let e=this._elements.map(e=>{let t=this.$node(e.expr);return e.kind===`spread`?h.factory.createSpreadElement(t):t});return h.factory.createArrayLiteralExpression(e,this.$multiline(this._elements.length))}};function Hn(e){class t extends e{analyze(e){super.analyze(e)}attr(...e){return E.attr(this,...e)}await(){return E.await(this)}call(...e){return E.call(this,...e)}return(){return E.return(this)}}return t}const Un=D(Hn(w));var Wn=class extends Un{"~dsl"=`AsTsDsl`;expr;type;constructor(e,t){super(),this.expr=l(e),this.type=l(t)}analyze(e){super.analyze(e),e.analyze(this.expr),e.analyze(this.type)}toAst(){return h.factory.createAsExpression(this.$node(this.expr),this.$type(this.type))}};E.as.set((...e)=>new Wn(...e));const Gn=D(Hn(w));var P=class extends Gn{"~dsl"=`BinaryTsDsl`;_base;_expr;_op;constructor(e,t,n){super(),this._base=l(e),this._op=t,n&&(this._expr=l(n))}analyze(e){super.analyze(e),e.analyze(this._base),e.analyze(this._expr)}and(e){return this.opAndExpr(`&&`,e)}assign(e){return this.opAndExpr(`=`,e)}coalesce(e){return this.opAndExpr(`??`,e)}div(e){return this.opAndExpr(`/`,e)}eq(e){return this.opAndExpr(`===`,e)}gt(e){return this.opAndExpr(`>`,e)}gte(e){return this.opAndExpr(`>=`,e)}looseEq(e){return this.opAndExpr(`==`,e)}looseNeq(e){return this.opAndExpr(`!=`,e)}lt(e){return this.opAndExpr(`<`,e)}lte(e){return this.opAndExpr(`<=`,e)}minus(e){return this.opAndExpr(`-`,e)}neq(e){return this.opAndExpr(`!==`,e)}nullishAssign(e){return this.opAndExpr(`??=`,e)}or(e){return this.opAndExpr(`||`,e)}plus(e){return this.opAndExpr(`+`,e)}times(e){return this.opAndExpr(`*`,e)}toAst(){if(!this._op)throw Error(`BinaryTsDsl: missing operator`);let e=this.$node(this._expr);if(!e)throw Error(`BinaryTsDsl: missing right-hand expression`);let t=this.$node(this._base),n=typeof this._op==`string`?this.opToToken(this._op):this._op;return h.factory.createBinaryExpression(t,n,e)}opAndExpr(e,t){return this._expr=l(t),this._op=e,this}opToToken(e){let t={"!=":h.SyntaxKind.ExclamationEqualsToken,"!==":h.SyntaxKind.ExclamationEqualsEqualsToken,"&&":h.SyntaxKind.AmpersandAmpersandToken,"*":h.SyntaxKind.AsteriskToken,"+":h.SyntaxKind.PlusToken,"-":h.SyntaxKind.MinusToken,"/":h.SyntaxKind.SlashToken,"<":h.SyntaxKind.LessThanToken,"<=":h.SyntaxKind.LessThanEqualsToken,"=":h.SyntaxKind.EqualsToken,"==":h.SyntaxKind.EqualsEqualsToken,"===":h.SyntaxKind.EqualsEqualsEqualsToken,">":h.SyntaxKind.GreaterThanToken,">=":h.SyntaxKind.GreaterThanEqualsToken,"??":h.SyntaxKind.QuestionQuestionToken,"??=":h.SyntaxKind.QuestionQuestionEqualsToken,"||":h.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}};function Kn(e){class t extends e{analyze(e){super.analyze(e)}and(e){return new P(this).and(e)}assign(e){return new P(this,`=`,e)}coalesce(e){return new P(this).coalesce(e)}div(e){return new P(this).div(e)}eq(e){return new P(this).eq(e)}gt(e){return new P(this).gt(e)}gte(e){return new P(this).gte(e)}looseEq(e){return new P(this).looseEq(e)}looseNeq(e){return new P(this).looseNeq(e)}lt(e){return new P(this).lt(e)}lte(e){return new P(this).lte(e)}minus(e){return new P(this).minus(e)}neq(e){return new P(this).neq(e)}nullishAssign(e){return new P(this).nullishAssign(e)}or(e){return new P(this).or(e)}plus(e){return new P(this).plus(e)}times(e){return new P(this).times(e)}}return t}const qn=D(Hn(Kn(tn(w))));var Jn=class extends qn{"~dsl"=`AttrTsDsl`;left;constructor(e,t){super(),this.left=l(e),this.name.set(t)}analyze(e){super.analyze(e),e.analyze(this.left),e.analyze(this.name)}toAst(){let e=this.$node(this.left);k.typeScriptIdentifier.lastIndex=0;let t=r(this.name);if(!k.typeScriptIdentifier.test(this.name.toString())){let n=o(t)?t.finalName:t;return typeof n==`string`&&(n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith(`"`)&&n.endsWith(`"`))&&(n=n.slice(1,-1)),this._optional?h.factory.createElementAccessChain(e,this.$node(new M().questionDot()),this.$node(new O(n))):h.factory.createElementAccessExpression(e,this.$node(new O(n)))}return this._optional?h.factory.createPropertyAccessChain(e,this.$node(new M().questionDot()),this.$node(this.name)):h.factory.createPropertyAccessExpression(e,this.$node(this.name))}};E.attr.set((...e)=>new Jn(...e));const Yn=Hn(w);var Xn=class extends Yn{"~dsl"=`AwaitTsDsl`;_awaitExpr;constructor(e){super(),this._awaitExpr=l(e)}analyze(e){super.analyze(e),e.analyze(this._awaitExpr)}toAst(){return h.factory.createAwaitExpression(this.$node(this._awaitExpr))}};E.await.set((...e)=>new Xn(...e));const Zn=ht(D(Hn(rn(w))));var Qn=class extends Zn{"~dsl"=`CallTsDsl`;_callExpr;constructor(e,...t){super(),this._callExpr=l(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this._callExpr)}toAst(){return h.factory.createCallExpression(this.$node(this._callExpr),this.$generics(),this.$args())}};E.call.set((...e)=>new Qn(...e));const $n=D(Hn(Kn(an(w))));var er=class extends $n{"~dsl"=`ExprTsDsl`;_exprInput;constructor(e){super(),this._exprInput=l(e),typeof e==`string`||o(e)?this.name.set(e):i(e)&&this.name.set(e.name)}analyze(e){super.analyze(e),e.analyze(this._exprInput)}toAst(){return this.$node(this._exprInput)}},tr=class extends w{"~dsl"=`HintTsDsl`;_lines=[];constructor(e,t){super(),e&&this.add(e),t?.(this)}analyze(e){super.analyze(e)}add(e){return this._lines.push(e),this}apply(e){let t=new zt,n=this._lines.reduce((e,n)=>{typeof n==`function`&&(n=n(t));for(let t of typeof n==`string`?[n]:n)(t||t===``)&&e.push(t);return e},[]);if(!n.length)return e;for(let t of n)h.addSyntheticLeadingComment(e,h.SyntaxKind.SingleLineCommentTrivia,` ${t}`,!1);return e}toAst(){return this.$node(new pt(``))}};function nr(e){class t extends e{_hint;analyze(e){super.analyze(e)}hint(e,t){return this._hint=new tr(e,t),this}$hint(e){return this._hint?this._hint.apply(e):e}}return t}const rr=A(w);var ir=class extends rr{"~dsl"=`ObjectPropTsDsl`;_value;meta;constructor(e){super(),this.meta=e}analyze(e){super.analyze(e),e.analyze(this._value)}get isValid(){return this.missingRequiredCalls().length===0}value(e){return typeof e==`function`?e(this):this._value=l(e),this}toAst(){this.$validate();let e=this.$node(this._value);if(this.meta.kind===`spread`){if(h.isStatement(e))throw Error(`Invalid spread: object spread must be an expression, not a statement.`);let t=h.factory.createSpreadAssignment(e);return this.$docs(t)}if(this.meta.kind===`getter`){let t=new Ln(this.meta.name).do(e),n=this.$node(t);return this.$docs(n)}if(this.meta.kind===`setter`){let t=new zn(this.meta.name).do(e),n=this.$node(t);return this.$docs(n)}if(h.isIdentifier(e)&&e.text===this.meta.name){let e=h.factory.createShorthandPropertyAssignment(this.meta.name);return this.$docs(e)}if(h.isStatement(e))throw Error(`Invalid property: object property value must be an expression, not a statement.`);let t=h.factory.createPropertyAssignment(this.meta.kind===`computed`?h.factory.createComputedPropertyName(this.$node(new pt(this.meta.name))):this.$node(wt(this.meta.name)),e);return this.$docs(t)}$validate(){let e=this.missingRequiredCalls();if(e.length!==0)throw Error(`Object property${this.meta.name?` "${this.meta.name}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._value||e.push(`.value()`),e}};const ar=D(Hn(nr(xn(w))));var or=class extends ar{"~dsl"=`ObjectTsDsl`;_props=[];constructor(...e){super(),this.props(...e)}analyze(e){super.analyze(e);for(let t of this._props)e.analyze(t)}computed(e,t){return this._props.push(new ir({kind:`computed`,name:e}).value(t)),this}getter(e,t){return this._props.push(new ir({kind:`getter`,name:e}).value(t)),this}hasProps(){return this._props.length>0}get isEmpty(){return this._props.length===0}prop(e,t){return this._props.push(new ir({kind:`prop`,name:e}).value(t)),this}props(...e){return this._props.push(...e),this}setter(e,t){return this._props.push(new ir({kind:`setter`,name:e}).value(t)),this}spread(e){return this._props.push(new ir({kind:`spread`}).value(e)),this}toAst(){let e=h.factory.createObjectLiteralExpression(this.$node(this._props),this.$multiline(this._props.length));return this.$hint(e)}};const sr=(e,t)=>{if(i(e))return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`||typeof e==`bigint`)return new O(e);if(e instanceof Array){let n=new Vn(...e.map(e=>sr(e,t)));return t?.layout===`pretty`&&n.pretty(),n}if(typeof e==`object`){let n=new or;for(let[r,i]of Object.entries(e)){let e=sr(i,t);n.prop(r,e)}return t?.layout===`pretty`&&n.pretty(),n}throw Error(`$.fromValue(): Unsupported input type ${String(e)}`)},cr=ht(D(Hn(rn(w))));var lr=class extends cr{"~dsl"=`NewTsDsl`;_newExpr;constructor(e,...t){super(),this._newExpr=l(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this._newExpr)}toAst(){return h.factory.createNewExpression(this.$node(this._newExpr),this.$generics(),this.$args())}};E.new.set((...e)=>new lr(...e));const ur=w;var dr=class extends ur{"~dsl"=`RegExpTsDsl`;pattern;flags;constructor(e,t){super(),this.pattern=e,this.flags=t}analyze(e){super.analyze(e)}toAst(){let e=`/${(this.pattern.startsWith(`/`)&&this.pattern.endsWith(`/`)?this.pattern.slice(1,-1):this.pattern).replace(/(?<!\\)\//g,`\\/`)}/${this.flags??``}`;return h.factory.createRegularExpressionLiteral(e)}};const fr=w;var pr=class extends fr{"~dsl"=`TemplateTsDsl`;parts=[];constructor(e){super(),e!==void 0&&this.add(e)}analyze(e){super.analyze(e);for(let t of this.parts)e.analyze(t)}add(e){return this.parts.push(l(e)),this}toAst(){let e=this.$node(this.parts.map(e=>{let t=r(e);return o(t)?t.finalName:t})),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 typeof r==`number`?t.push(String(r)):t.push(r)}if((t.length===0||typeof t[0]!=`string`)&&t.unshift(``),t.length===1&&typeof t[0]==`string`)return h.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return h.factory.createTemplateExpression(h.factory.createTemplateHead(t[0]),[h.factory.createTemplateSpan(t[1],h.factory.createTemplateTail(``))]);let n=h.factory.createTemplateHead(t.shift()),i=[];for(;t.length;){let e=t.shift(),n=typeof t[0]==`string`?t.shift():``,r=t.length===0;i.push(h.factory.createTemplateSpan(e,r?h.factory.createTemplateTail(n):h.factory.createTemplateMiddle(n)))}return h.factory.createTemplateExpression(n,i)}};const mr=w;var hr=class extends mr{"~dsl"=`TernaryTsDsl`;_condition;_then;_else;constructor(e){super(),e&&this.condition(e)}analyze(e){super.analyze(e),e.analyze(this._condition),e.analyze(this._then),e.analyze(this._else)}condition(e){return this._condition=e,this}do(e){return this._then=e,this}otherwise(e){return this._else=e,this}toAst(){if(!this._condition)throw Error(`Missing condition in ternary`);if(!this._then)throw Error(`Missing then expression in ternary`);if(!this._else)throw Error(`Missing else expression in ternary`);return h.factory.createConditionalExpression(this.$node(this._condition),void 0,this.$node(this._then),void 0,this.$node(this._else))}};const gr=Kn(w);var _r=class extends gr{"~dsl"=`TypeOfExprTsDsl`;_expr;constructor(e){super(),this._expr=e}analyze(e){super.analyze(e),e.analyze(this._expr)}toAst(){return h.factory.createTypeOfExpression(this.$node(this._expr))}};E.typeofExpr.set((...e)=>new _r(...e));var vr=class extends w{"~dsl"=`NoteTsDsl`;_lines=[];constructor(e,t){super(),e&&this.add(e),t?.(this)}analyze(e){super.analyze(e)}add(e){return this._lines.push(e),this}apply(e){let t=new zt,n=this._lines.reduce((e,n)=>{typeof n==`function`&&(n=n(t));for(let t of typeof n==`string`?[n]:n)(t||t===``)&&e.push(t);return e},[]);return n.length&&h.addSyntheticLeadingComment(e,h.SyntaxKind.MultiLineCommentTrivia,`\n${n.join(`
4
+ `)}\n`,!0),e}toAst(){return this.$node(new pt(``))}};const yr=mn(w);var br=class extends yr{"~dsl"=`IfTsDsl`;_condition;_else;constructor(e){super(),e&&this.condition(e)}analyze(e){if(super.analyze(e),e.analyze(this._condition),this._else){e.pushScope();try{for(let t of this._else)e.analyze(t)}finally{e.popScope()}}}condition(e){return this._condition=e,this}otherwise(...e){return this._else=e,this}toAst(){if(!this._condition)throw Error(`Missing condition in if`);if(!this._do)throw Error(`Missing then block in if`);return h.factory.createIfStatement(this.$node(this._condition),this.$node(new N(...this._do).pretty()),this._else?this.$node(new N(...this._else).pretty()):void 0)}};const xr=w;var Sr=class extends xr{"~dsl"=`ReturnTsDsl`;_returnExpr;constructor(e){super(),e&&(this._returnExpr=l(e))}analyze(e){super.analyze(e),e.analyze(this._returnExpr)}toAst(){return h.factory.createReturnStatement(this.$node(this._returnExpr))}};E.return.set((...e)=>new Sr(...e));const Cr=w;var wr=class extends Cr{"~dsl"=`ThrowTsDsl`;error;msg;useNew;constructor(e,t=!0){super(),this.error=e,this.useNew=t}analyze(e){super.analyze(e),e.analyze(this.error),e.analyze(this.msg)}message(e){return this.msg=e,this}toAst(){let e=this.$node(this.error),t=this.$node(this.msg?[this.msg]:[]).map(e=>typeof e==`string`?this.$node(new O(e)):e);if(this.useNew)return h.factory.createThrowStatement(h.factory.createNewExpression(e,void 0,t));let n=t.length?[h.factory.createCallExpression(e,void 0,t)]:[e];return h.factory.createThrowStatement(n[0])}};const Tr=w;var Er=class extends Tr{"~dsl"=`TryTsDsl`;_catch;_catchArg;_finally;_try;constructor(...e){super(),this.try(...e)}analyze(e){if(super.analyze(e),this._try){e.pushScope();try{for(let t of this._try)e.analyze(t)}finally{e.popScope()}}if(this._catch||this._catchArg){e.pushScope();try{if(e.analyze(this._catchArg),this._catch)for(let t of this._catch)e.analyze(t)}finally{e.popScope()}}if(this._finally){e.pushScope();try{for(let t of this._finally)e.analyze(t)}finally{e.popScope()}}}catch(...e){return this._catch=e,this}catchArg(e){return this._catchArg=e,this}finally(...e){return this._finally=e,this}try(...e){return this._try=e,this}toAst(){if(!this._try?.length)throw Error(`Missing try block`);let e=this._catchArg?this.$node(this._catchArg):void 0;return h.factory.createTryStatement(this.$node(new N(...this._try).pretty()),h.factory.createCatchClause(e?h.factory.createVariableDeclaration(e):void 0,this.$node(new N(...this._catch??[]).pretty())),this._finally?this.$node(new N(...this._finally).pretty()):void 0)}};const Dr=Gt(A(Kt(nr(_n(nn(w))))));var Or=class extends Dr{"~dsl"=`VarTsDsl`;nameSanitizer=Et;kind=h.NodeFlags.None;_type;constructor(e){super(),e&&this.name.set(e),o(e)&&e.setKind(`var`)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}const(){return this.kind=h.NodeFlags.Const,this}let(){return this.kind=h.NodeFlags.Let,this}type(e){return this._type=e instanceof dt?e:new ln(e),this}var(){return this.kind=h.NodeFlags.None,this}toAst(){let e=this.$pattern()??this.$node(this.name);if(!e)throw Error(`Var must have either a name or a destructuring pattern`);let t=h.factory.createVariableStatement(this.modifiers,h.factory.createVariableDeclarationList([h.factory.createVariableDeclaration(e,void 0,this.$type(this._type),this.$value())],this.kind));return this.$docs(this.$hint(t))}};const kr=A(Kt(en(w)));var Ar=class extends kr{"~dsl"=`TypeAliasTsDsl`;nameSanitizer=Dt;scope=`type`;value;constructor(e,t){super(),this.name.set(e),o(e)&&e.setKind(`type`),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this.value)}type(e){return this.value=e,this}toAst(){if(!this.value)throw Error(`Type alias '${this.name.toString()}' is missing a type definition`);let e=h.factory.createTypeAliasDeclaration(this.modifiers,this.$node(this.name),this.$generics(),this.$type(this.value));return this.$docs(e)}};const jr=w;var Mr=class extends jr{"~dsl"=`TypeAndTsDsl`;scope=`type`;_types=[];constructor(...e){super(),this.types(...e)}analyze(e){super.analyze(e);for(let t of this._types)e.analyze(t)}types(...e){return this._types.push(...e.map(e=>l(e))),this}toAst(){let e=[];for(let t of this._types){let n=this.$type(t);h.isIntersectionTypeNode(n)?e.push(...n.types):e.push(n)}return h.factory.createIntersectionTypeNode(e)}};const Nr=w;var Pr=class extends Nr{"~dsl"=`TypeLiteralTsDsl`;scope=`type`;value;constructor(e){super(),this.value=e}analyze(e){super.analyze(e)}toAst(){return h.factory.createLiteralTypeNode(this.$node(new O(this.value)))}};const Fr=A(Xt(w));var Ir=class extends Fr{"~dsl"=`TypeIdxSigTsDsl`;scope=`type`;_key;_type;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){super.analyze(e),e.analyze(this._key),e.analyze(this._type)}get isValid(){return this.missingRequiredCalls().length===0}key(e){return this._key=e,this}type(e){return this._type=e,this}toAst(){this.$validate();let e=h.factory.createIndexSignature(this.modifiers,[h.factory.createParameterDeclaration(void 0,void 0,this.$node(this.name),void 0,this.$type(this._key))],this.$type(this._type));return this.$docs(e)}$validate(){let e=this.missingRequiredCalls();if(e.length===0)return;let t=this.name.toString();throw Error(`Index signature${t?` "${t}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._key||e.push(`.key()`),this._type||e.push(`.​type()`),e}};const Lr=A(tn(Xt(w)));var Rr=class extends Lr{"~dsl"=`TypePropTsDsl`;scope=`type`;_type;constructor(e,t){super(),this.name.set(e),t(this)}analyze(e){super.analyze(e),e.analyze(this._type)}type(e){return this._type=l(e),this}toAst(){let e=this.name.toString();if(!this._type||!e)throw Error(`Type not specified for property '${e}'`);let t=h.factory.createPropertySignature(this.modifiers,this.$node(wt(e)),this._optional?this.$node(new M().optional()):void 0,this.$type(this._type));return this.$docs(t)}};const zr=w;var Br=class extends zr{"~dsl"=`TypeObjectTsDsl`;scope=`type`;props=[];analyze(e){super.analyze(e);for(let t of this.props)e.analyze(t)}hasProps(){return this.props.length>0}idxSig(e,t){let n=new Ir(e,t);return this.props.push(n),this}get isEmpty(){return!this.props.length}prop(e,t){let n=new Rr(e,t);return this.props.push(n),this}toAst(){return h.factory.createTypeLiteralNode(this.$node(this.props))}};const Vr=w;var Hr=class extends Vr{"~dsl"=`TypeTupleTsDsl`;scope=`type`;_elements=[];constructor(...e){super(),this.elements(...e)}analyze(e){super.analyze(e);for(let t of this._elements)e.analyze(t)}elements(...e){return this._elements.push(...e),this}toAst(){return h.factory.createTupleTypeNode(this._elements.map(e=>this.$type(e)))}};const Ur=e=>{if(i(e))return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return new Pr(e);if(e instanceof Array)return new Hr(...e.map(e=>Ur(e)));if(typeof e==`object`){let t=new Br;for(let[n,r]of Object.entries(e)){let e=Ur(r);t.prop(n,t=>t.type(e))}return t}throw Error(`$.type.fromValue(): Unsupported input type ${String(e)}`)},Wr=A(bn(en(Tn(w))));var Gr=class extends Wr{"~dsl"=`TypeFuncTsDsl`;scope=`type`;analyze(e){super.analyze(e)}toAst(){let e=this.$returns();if(e===void 0)throw Error(`Missing return type in function type DSL`);let t=h.factory.createFunctionTypeNode(this.$generics(),this.$params(),e);return this.$docs(t)}};const Kr=an(w);var qr=class extends Kr{"~dsl"=`TypeIdxTsDsl`;scope=`type`;_base;_index;constructor(e,t){super(),this.base(e),this.index(t)}analyze(e){super.analyze(e),e.analyze(this._base),e.analyze(this._index)}base(e){return this._base=e,this}index(e){return this._index=e,this}toAst(){return h.factory.createIndexedAccessTypeNode(this.$type(this._base),this.$type(this._index))}};E.type.idx.set((...e)=>new qr(...e));const Jr=w;var Yr=class extends Jr{"~dsl"=`TypeMappedTsDsl`;scope=`type`;questionToken;readonlyToken;_key;_type;constructor(e){super(),e&&this.name.set(e)}analyze(e){super.analyze(e),e.analyze(this.questionToken),e.analyze(this.readonlyToken),e.analyze(this._key),e.analyze(this._type)}get isValid(){return this.missingRequiredCalls().length===0}key(e){return this._key=e,this}mutable(){return this.readonlyToken=new M().minus(),this}optional(){return this.questionToken=new M().optional(),this}readonly(){return this.readonlyToken=new M().readonly(),this}required(){return this.questionToken=new M().minus(),this}type(e){return this._type=e,this}toAst(){return this.$validate(),h.factory.createMappedTypeNode(this.$node(this.readonlyToken),h.factory.createTypeParameterDeclaration(void 0,this.$node(this.name),this.$type(this._key),void 0),void 0,this.$node(this.questionToken),this.$type(this._type),void 0)}$validate(){let e=this.missingRequiredCalls();if(e.length===0)return;let t=this.name.toString();throw Error(`Mapped type${t?` "${t}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._key||e.push(`.key()`),this._type||e.push(`.​type()`),e}};const Xr=w;var Zr=class extends Xr{"~dsl"=`TypeOperatorTsDsl`;scope=`type`;_op;_type;analyze(e){super.analyze(e),e.analyze(this._type)}keyof(e){return this.operator(h.SyntaxKind.KeyOfKeyword),this.type(e),this}operator(e){return this._op=e,this}readonly(e){return this.operator(h.SyntaxKind.ReadonlyKeyword),this.type(e),this}type(e){return this._type=e,this}unique(e){return this.operator(h.SyntaxKind.UniqueKeyword),this.type(e),this}toAst(){return this.$validate(),h.factory.createTypeOperatorNode(this._op,this.$type(this._type))}$validate(){let e=this.missingRequiredCalls();if(e.length!==0)throw Error(`Type operator missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._op||e.push(`.operator()`),this._type||e.push(`.​type()`),e}};E.type.operator.set((...e)=>new Zr(...e));const Qr=w;var $r=class extends Qr{"~dsl"=`TypeOrTsDsl`;scope=`type`;_types=[];constructor(...e){super(),this.types(...e)}analyze(e){super.analyze(e);for(let t of this._types)e.analyze(t)}types(...e){return this._types.push(...e.map(e=>l(e))),this}toAst(){let e=[];for(let t of this._types){let n=this.$type(t);h.isUnionTypeNode(n)?e.push(...n.types):e.push(n)}return h.factory.createUnionTypeNode(e)}};const ei=an(w);var ti=class extends ei{"~dsl"=`TypeQueryTsDsl`;scope=`type`;_expr;constructor(e){super(),this._expr=e}analyze(e){super.analyze(e),e.analyze(this._expr)}toAst(){let e=this.$node(this._expr);return h.factory.createTypeQueryNode(e)}};E.type.query.set((...e)=>new ti(...e));const ni=w;var ri=class extends ni{"~dsl"=`TypeTemplateTsDsl`;scope=`type`;parts=[];constructor(e){super(),e!==void 0&&this.add(e)}analyze(e){super.analyze(e);for(let t of this.parts)e.analyze(t)}add(e){return this.parts.push(e),this}toAst(){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 h.factory.createTemplateLiteralType(h.factory.createTemplateHead(t[0]),[]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return h.factory.createTemplateLiteralType(h.factory.createTemplateHead(t[0]),[h.factory.createTemplateLiteralTypeSpan(t[1],h.factory.createTemplateTail(``))]);let n=h.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(h.factory.createTemplateLiteralTypeSpan(e,i?h.factory.createTemplateTail(n):h.factory.createTemplateMiddle(n)))}return h.factory.createTemplateLiteralType(n,r)}},ii=class extends w{"~dsl"=`LazyTsDsl`;_thunk;constructor(e){super(),this._thunk=e}analyze(e){super.analyze(e),e.analyze(this.toResult())}toResult(){return this._thunk(new zt)}toAst(){return this.toResult().toAst()}};const ai=h.createPrinter({newLine:h.NewLineKind.LineFeed,removeComments:!1}),oi=h.createSourceFile(``,``,h.ScriptTarget.ESNext,!1,h.ScriptKind.TS);function si(e){let t=ai.printNode(h.EmitHint.Unspecified,e,oi);try{return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}catch{return t}}const ci=({file:e,fromFile:t,preferFileExtension:n,root:r})=>{let i=e.finalPath.split(p.sep).join(`/`),a=t.finalPath.split(p.sep).join(`/`);if(t.external&&!p.isAbsolute(a))return[0,0,a];if(!a.startsWith(r.split(p.sep).join(`/`)))return[1,0,a];let o=p.relative(p.dirname(i),p.dirname(a)).split(p.sep).join(`/`),s;return o.startsWith(`..`)?(a=`${o}/${t.name}${t.extension??``}`,s=o.split(p.sep).filter(e=>e===`..`).length):(a=`./${o?`${o}/`:``}${t.name}${t.extension??``}`,s=0),a.endsWith(`.ts`)&&(a=a.slice(0,-3)),n?a+=n:a.endsWith(`/index`)&&(a=a.slice(0,-6)),[2,s,a]};function li(e){if(!e)return[];let t=[];if(typeof e==`string`)return t.push(...e.split(/\r?\n/)),t;for(let n of e)t.push(...n.split(/\r?\n/));return t}var ui=class e{_header;_preferExportAll;_preferFileExtension;_resolveModuleName;constructor(e={}){this._header=e.header,this._preferExportAll=e.preferExportAll??!1,this._preferFileExtension=e.preferFileExtension??``,this._resolveModuleName=e.resolveModuleName}render(t){let n=typeof this._header==`function`?this._header(t):this._header;return e.astToString({exports:this.getExports(t),exportsOptions:{preferExportAll:this._preferExportAll},header:n,imports:this.getImports(t),nodes:t.file.nodes})}supports(e){return e.file.language===`typescript`}static astToString(t){let n=``;for(let e of li(t.header))n+=`${e}\n`;let r=``;for(let n of t.imports??[]){r&&(r+=`
5
+ `);for(let t of n)r+=`${si(e.toImportAst(t))}\n`}n=`${n}${n&&r?`
6
+ `:``}${r}`;let i=``;for(let e of t.nodes??[])i&&(i+=`
7
+ `),i+=`${si(e.toAst())}\n`;n=`${n}${n&&i?`
8
+ `:``}${i}`;let a=``;for(let n of t.exports??[]){(!a&&i||a)&&(a+=`
9
+ `);for(let r of n)a+=`${si(e.toExportAst(r,t.exportsOptions))}\n`}return n=`${n}${n&&a?`
10
+ `:``}${a}`,t.trailingNewline===!1&&n.endsWith(`
11
+ `)&&(n=n.slice(0,-1)),n}static toExportAst(e,t){let n=e.exports.map(e=>h.factory.createExportSpecifier(e.isTypeOnly,e.sourceName===e.exportedName?void 0:F.id(e.sourceName).toAst(),F.id(e.exportedName).toAst())),r=e.namespaceExport?h.factory.createNamespaceExport(F.id(e.namespaceExport).toAst()):(!e.canExportAll||!t?.preferExportAll)&&n.length?h.factory.createNamedExports(n):void 0;return h.factory.createExportDeclaration(void 0,e.isTypeOnly,r,F.literal(e.modulePath).toAst())}static toImportAst(e){let t=e.imports.map(e=>h.factory.createImportSpecifier(e.isTypeOnly,e.sourceName===e.localName?void 0:F.id(e.sourceName).toAst(),F.id(e.localName).toAst())),n=h.factory.createImportClause(e.isTypeOnly,e.kind===`default`?F.id(e.localName??``).toAst():void 0,e.kind===`namespace`?h.factory.createNamespaceImport(F.id(e.localName??``).toAst()):t.length>0?h.factory.createNamedImports(t):void 0);return h.factory.createImportDeclaration(void 0,n,F.literal(e.modulePath).toAst())}getExports(e){let t=new Map;for(let n of e.file.exports){let r=ci({file:e.file,fromFile:n.from,preferFileExtension:this._preferFileExtension,root:e.project.root}),i=this._resolveModuleName?.(r[2])??r[2],[a]=r;t.has(a)||t.set(a,new Map);let o=t.get(a);o.has(i)||o.set(i,{group:{canExportAll:n.canExportAll,exports:n.exports,isTypeOnly:n.isTypeOnly,modulePath:i,namespaceExport:n.namespaceExport},sortKey:r})}return Array.from(t.entries()).sort((e,t)=>e[0]-t[0]).map(([,e])=>{let t=Array.from(e.values());return t.sort((e,t)=>{let n=e.sortKey[1]-t.sortKey[1];return n===0?e.group.modulePath.localeCompare(t.group.modulePath):n}),t.map(e=>{let t=e.group;if(t.namespaceExport)t.exports=[];else{if(!t.exports.find(e=>!e.isTypeOnly)){t.isTypeOnly=!0;for(let e of t.exports)e.isTypeOnly=!1}t.exports.sort((e,t)=>e.exportedName.localeCompare(t.exportedName))}return t})})}getImports(e){let t=new Map;for(let n of e.file.imports){let r=ci({file:e.file,fromFile:n.from,preferFileExtension:this._preferFileExtension,root:e.project.root}),i=this._resolveModuleName?.(r[2])??r[2],[a]=r;t.has(a)||t.set(a,new Map);let o=t.get(a);o.has(i)||o.set(i,{group:{imports:[],isTypeOnly:!1,kind:n.kind,modulePath:i},sortKey:r});let s=o.get(i).group;n.kind===`named`?s.imports.push(...n.imports):(s.isTypeOnly=n.isTypeOnly,s.kind=n.kind,s.localName=n.localName)}return Array.from(t.entries()).sort((e,t)=>e[0]-t[0]).map(([,e])=>{let t=Array.from(e.values());return t.sort((e,t)=>{let n=e.sortKey[1]-t.sortKey[1];return n===0?e.group.modulePath.localeCompare(t.group.modulePath):n}),t.map(e=>{let t=e.group;if(t.kind===`namespace`)t.imports=[];else{if(!t.imports.find(e=>!e.isTypeOnly)){t.isTypeOnly=!0;for(let e of t.imports)e.isTypeOnly=!1}t.imports.sort((e,t)=>e.localName.localeCompare(t.localName))}return t})})}};const di={array:(...e)=>new Vn(...e),as:(...e)=>new Wn(...e),attr:(...e)=>new Jn(...e),await:(...e)=>new Xn(...e),binary:(...e)=>new P(...e),block:(...e)=>new N(...e),call:(...e)=>new Qn(...e),class:(...e)=>new kn(...e),const:(...e)=>new Or(...e).const(),decorator:(...e)=>new kt(...e),doc:(...e)=>new Bt(...e),enum:(...e)=>new Nn(...e),expr:(...e)=>new er(...e),field:(...e)=>new dn(...e),fromValue:(...e)=>sr(...e),func:((e,t)=>e===void 0?new Fn:typeof e!=`string`||t===void 0?new Fn(e):new Fn(e,t)),getter:(...e)=>new Ln(...e),hint:(...e)=>new tr(...e),id:(...e)=>new pt(...e),if:(...e)=>new br(...e),init:(...e)=>new wn(...e),lazy:(...e)=>new ii(...e),let:(...e)=>new Or(...e).let(),literal:(...e)=>new O(...e),member:(...e)=>new jn(...e),method:(...e)=>new Dn(...e),neg:(...e)=>new _t(...e).neg(),new:(...e)=>new lr(...e),newline:(...e)=>new mt(...e),not:(...e)=>new _t(...e).not(),note:(...e)=>new vr(...e),object:(...e)=>new or(...e),param:(...e)=>new yn(...e),pattern:(...e)=>new gn(...e),prefix:(...e)=>new _t(...e),prop:(...e)=>new ir(...e),regexp:(...e)=>new dr(...e),return:(...e)=>new Sr(...e),setter:(...e)=>new zn(...e),stmt:(...e)=>new pn(...e),template:(...e)=>new pr(...e),ternary:(...e)=>new hr(...e),throw:(...e)=>new wr(...e),token:(...e)=>new M(...e),try:(...e)=>new Er(...e),type:Object.assign((...e)=>new ln(...e),{alias:(...e)=>new Ar(...e),and:(...e)=>new Mr(...e),attr:(...e)=>new sn(...e),expr:(...e)=>new ln(...e),fromValue:(...e)=>Ur(...e),func:(...e)=>new Gr(...e),idx:(...e)=>new qr(...e),literal:(...e)=>new Pr(...e),mapped:(...e)=>new Yr(...e),object:(...e)=>new Br(...e),operator:(...e)=>new Zr(...e),or:(...e)=>new $r(...e),param:(...e)=>new $t(...e),query:(...e)=>new ti(...e),template:(...e)=>new ri(...e),tuple:(...e)=>new Hr(...e)}),typeofExpr:(...e)=>new _r(...e),var:(...e)=>new Or(...e)},F=Object.assign((...e)=>new er(...e),di),fi=/[\p{Lu}]/u,pi=/[\p{Ll}]/u,mi=/([\p{Alpha}\p{N}_]|$)/u,hi=/[_.$+:\- `\\[\](){}\\/]+/,gi=RegExp(`^${hi.source}`),_i=RegExp(`${hi.source}${mi.source}`,`gu`),vi=RegExp(`\\d+${mi.source}`,`gu`),yi=(e,t)=>{let n=!1,r=!1,i=!1,a=!1,o=t===`snake_case`||t===`SCREAMING_SNAKE_CASE`?`_`:`-`;for(let t=0;t<e.length;t++){let s=e[t];a=t>2?e[t-3]===o:!0;let c=t+1,l=e[c];for(hi.lastIndex=0;l&&hi.test(l);)c+=1,l=e[c];let u=c!==t+1;if(pi.lastIndex=0,fi.lastIndex=0,fi.test(s)&&(n||l&&!u&&l!==`s`&&pi.test(l)))e=`${e.slice(0,t)}${o}${e.slice(t)}`,t++,i=r,n=!1,r=!0;else if(r&&i&&pi.test(s)&&!a&&!(s===`s`&&(!l||l.toLocaleLowerCase()!==l)))e=`${e.slice(0,t-1)}${o}${e.slice(t-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 e},I=(e,t,n={})=>{let r=n.stripLeadingSeparators??!0,i=e.trim();return!i.length||!t||t===`preserve`?i:i.length===1?(hi.lastIndex=0,hi.test(i)?``:t===`PascalCase`||t===`SCREAMING_SNAKE_CASE`?i.toLocaleUpperCase():i.toLocaleLowerCase()):(i!==i.toLocaleLowerCase()&&(i=yi(i,t)),(r||i[0]!==e[0])&&(i=i.replace(gi,``)),i=t===`SCREAMING_SNAKE_CASE`?i.toLocaleUpperCase():i.toLocaleLowerCase(),t===`PascalCase`&&(i=`${i.charAt(0).toLocaleUpperCase()}${i.slice(1)}`),t===`snake_case`||t===`SCREAMING_SNAKE_CASE`?(i=i.replaceAll(_i,(e,t,n)=>n===0&&!r?e:`_${t}`),i[i.length-1]===`_`&&(i=i.slice(0,i.length-1))):(_i.lastIndex=0,vi.lastIndex=0,i=i.replaceAll(vi,(e,t,n)=>[`_`,`-`,`.`].includes(i.charAt(n+e.length))?e:e.toLocaleUpperCase()),i=i.replaceAll(_i,(t,n,i)=>i===0&&!r&&t[0]&&e.startsWith(t[0])?t:n.toLocaleUpperCase())),i)};function L(e,t){let n=e,r=t.casing??t.case;if(t.name)if(typeof t.name==`function`)n=t.name(n);else{let e=!r||r===`preserve`?``:`-`;n=t.name.replace(`{{name}}`,`${e}${n}${e}`)}return I(n,r)}const bi=({plugin:e,sdkSymbol:t,symbol:n})=>{let r=e.symbol(`defaultKey`),i=e.symbol(`instances`);return F.class(n).generic(`T`).field(r,e=>e.private().readonly().assign(F.literal(`default`))).newline().field(i,e=>e.private().readonly().type(F.type(`Map`).generics(`string`,`T`)).assign(F.new(`Map`))).newline().method(`get`,e=>e.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(F.const(`instance`).assign(F(`this`).attr(i).attr(`get`).call(F(`key`).coalesce(F(`this`).attr(r)))),F.if(F.not(`instance`)).do(F.throw(`Error`).message(F.template(`No SDK client found. Create one with "new `).add(t).add(`()" to fix this error.`))),F.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(F(`this`).attr(i).attr(`set`).call(F(`key`).coalesce(F(`this`).attr(r)),`value`)))},xi=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return F.class(t).field(`client`,e=>e.protected().type(i)).newline().init(e=>e.param(`args`,e=>e.optional(r).type(F.type.object().prop(`client`,e=>e.optional(r).type(i)))).do(F(`this`).attr(`client`).assign(F(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n)))))},Si=`TComposable`,Ci=`DefaultT`,wi=`ResT`,Ti=({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}},Ei=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=Ti({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},Di=/~1/g,Oi=/~0/g,R=e=>{let t=Ai(e),n=t[t.length-1];return decodeURI(n)},ki=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),Ai=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(Di,`/`).replace(Oi,`~`)):[]},ji=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},Mi=e=>{let t=e.map(ki).join(`/`);return`#`+(t?`/${t}`:``)},Ni=({$ref:e,spec:t})=>{let n=Ai(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},Pi=({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(I(R(e.body.schema.$ref),`camelCase`),`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=I(R(e.body.schema.$ref),`camelCase`),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}},Fi=({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})},Ii=({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})},Li=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=b(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`});return F.type(o).generic(Si).generic(e?a??`unknown`:`never`).generic(r??`unknown`).generic(Ci)}return r?F.type(o).generic(e?a??`unknown`:`never`).generic(r):F.type(o).$if(!e||a,t=>t.generic(e?a:`never`))},Ri=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=b(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=Pi({operation:t,plugin:n}),a=F.type.object();if(e){let t=!1;for(let n in e.parameters){let r=e.parameters[n];r.isRequired&&(t=!0),a.prop(r.name,e=>e.required(r.isRequired).type(i.api.schemaToType({plugin:i,schema:r.schema,state:u({path:[]})})))}r.argNames.push(`parameters`);for(let t of e.fields)r.fields.push(t);r.parameters.push(F.param(`parameters`,e=>e.required(t).type(a)))}}return r.parameters.push(F.param(`options`,r=>r.required(e).type(Li({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})))),r},zi=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`}},Bi=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=b(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`response`:`responses`}),s=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`error`:`errors`}),c=F.object();if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol({category:`external`,resource:`client.formDataBodySerializer`});c.spread(e);break}case`json`:break;case`text`:case`octet-stream`:c.prop(`bodySerializer`,F.literal(null));break;case`url-search-params`:{let e=r.referenceSymbol({category:`external`,resource:`client.urlSearchParamsBodySerializer`});c.spread(e);break}}let l=F.object();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.prop(t.name,F.object().prop(`array`,F.object().$if(t.explode===!1,e=>e.prop(`explode`,F.literal(t.explode))).$if(t.style!==`form`,e=>e.prop(`style`,F.literal(t.style))))):t.schema.type===`object`&&(t.style!==`deepObject`||!t.explode)&&l.prop(t.name,F.object().prop(`object`,F.object().$if(t.explode===!1,e=>e.prop(`explode`,F.literal(t.explode))).$if(t.style!==`deepObject`,e=>e.prop(`style`,F.literal(t.style)))))}l.hasProps()&&c.prop(`querySerializer`,F.object().prop(`parameters`,l));let u=Fi({operation:n,plugin:r}),d=Ii({operation:n,plugin:r});if(u&&c.prop(`requestValidator`,u.arrow()),r.config.transformer){let e={category:`transform`,resource:`operation`,resourceId:n.id,role:`response`};if(r.isSymbolRegistered(e)){let t=r.referenceSymbol(e);c.prop(`responseTransformer`,F(t))}}let f=!1,p;for(let e in n.responses){let t=n.responses[e];!p&&i.name===`@hey-api/client-axios`&&lt({statusCode:e})===`2XX`&&(p=zi(t.mediaType),p&&c.prop(`responseType`,F.literal(p))),t.mediaType===`text/event-stream`&&(f=!0)}d&&c.prop(`responseValidator`,d.arrow()),r.config.responseStyle===`data`&&c.prop(`responseStyle`,F.literal(r.config.responseStyle));let m=Ei({context:r.context,operation:n,plugin:r});m.length&&c.prop(`security`,F.fromValue(m)),c.prop(`url`,F.literal(n.path)),c.spread(`options`);let h=[],ee=t.argNames.length;if(ee){let e=[],n=[];for(let n of t.argNames)e.push(F(n));for(let e of t.fields){let t=F.object();`in`in e&&t.prop(`in`,F.literal(e.in)),`key`in e&&(e.key&&t.prop(`key`,F.literal(e.key)),e.map&&t.prop(`map`,F.literal(e.map))),n.push(t)}let i=r.referenceSymbol({category:`external`,resource:`client.buildClientParams`});h.push(F.const(`params`).assign(F(i).call(F.array(...e),F.array(F.object().prop(`args`,F.array(...n)))))),c.spread(`params`)}if(n.body){let t=n.parameters?.header?.[`content-type`];if(!t?.required){let r=F.object().pretty().prop(t?.name??`Content-Type`,F.literal(n.body.type===`form-data`?null:n.body.mediaType)).spread(F(`options`).attr(`headers`).required(e));ee&&r.spread(F(`params`).attr(`headers`)),c.prop(`headers`,r)}}let te=r.config.client?r.getSymbol({category:`client`}):void 0,ne,re=F(`options`).attr(`client`).required(e);ne=Hi(r)?re.coalesce(F(`this`).attr(`client`)):te?re.coalesce(te):re;let ie=f?ne.attr(`sse`):ne;return ie=ie.attr(n.method),h.push(F.return(ie.call(c).$if(a,e=>e.generic(Si).generic(F.type.or(o??`unknown`,Ci)).generic(s??`unknown`).generic(Ci),e=>e.generic(o??`unknown`).generic(s??`unknown`).generic(`ThrowOnError`)).$if(r.config.responseStyle===`data`,e=>e.generic(F.type.literal(r.config.responseStyle))))),h},Vi=globalThis.Symbol(`@hey-api/sdk`);function Hi(e){let t=e.config.operations;return t.container===`class`&&t.methods===`instance`&&t.strategy!==`flat`}function Ui(e){let{node:t,operation:n}=e;return t.$if(z(n),(e,t)=>e.doc(t))}function Wi(e){return{category:`utility`,resource:`class`,resourceId:e.getPath().join(`.`),tool:`sdk`}}function Gi(e,t){let{operation:n,path:r,tags:i}=t.data,a=t.location[t.location.length-1];return e.symbol(L(a,e.config.operations.methodName),{meta:{category:`sdk`,path:r,resource:`operation`,resourceId:n.id,tags:i,tool:`sdk`}})}function Ki(e,t){let n=t.referenceSymbol(Wi(e)),r=I(n.name,t.config.operations.methodName.casing??`camelCase`),i=t.symbol(r);if(Hi(t)){let e=t.symbol(`_${r}`);return[F.field(e,e=>e.private().optional().type(n)),F.getter(i,t=>t.returns(n).do(F(`this`).attr(e).nullishAssign(F.new(n).args(F.object().prop(`client`,F(`this`).attr(`client`)))).return()))]}return t.isSymbolRegistered(n.id)?[F.field(i,e=>e.static().assign(F(n)))]:[F.getter(i,e=>e.public().static().do(F.return(n)))]}function qi(e){let t=b(e.context.config).name===`@hey-api/client-angular`;return{define:n=>{let r=e.symbol(L(n.name,n.isRoot?e.config.operations.containerName:e.config.operations.segmentName),{meta:Wi(n)}),i=F.class(r).export().$if(Hi(e),t=>t.extends(e.referenceSymbol({category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`}))).$if(t&&n.isRoot,t=>t.decorator(e.external(`@angular/core.Injectable`),F.object().prop(`providedIn`,F.literal(`root`)))),a=[];return n.isRoot&&Hi(e)&&Ji({dependencies:a,node:i,plugin:e,symbol:r}),{dependencies:a,node:i}}}}function Ji(e){let{dependencies:t,node:n,plugin:r,symbol:i}=e,a=r.symbol(`HeyApiClient`,{meta:{category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`}});t.push(xi({plugin:r,symbol:a}));let o=r.symbol(`HeyApiRegistry`,{meta:{category:`utility`,resource:`class`,resourceId:`HeyApiRegistry`,tool:`sdk`}});t.push(bi({plugin:r,sdkSymbol:i,symbol:o}));let s=!r.config.client||!r.getSymbol({category:`client`}),c=r.symbol(`__registry`);n.toAccessNode=(e,t)=>{if(!t.context)return F(e.name).attr(c).attr(`get`).call()},n.do(F.field(c,e=>e.public().static().readonly().assign(F.new(o).generic(i))),F.newline(),F.init(e=>e.param(`args`,e=>e.required(s).type(F.type.object().prop(`client`,e=>e.required(s).type(r.external(`client.Client`))).prop(`key`,e=>e.optional().type(`string`)))).do(F(`super`).call(`args`),F(i).attr(c).attr(`set`).call(`this`,F(`args`).attr(`key`).required(s)))))}function Yi(e){let{node:t,operation:n,plugin:r}=e,i=b(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=Qi({context:r.context,operation:n}),s=Ri({isRequiredOptions:o,operation:n,plugin:r}),c=Bi({isRequiredOptions:o,opParameters:s,operation:n,plugin:r});return t.$if(a,e=>e.generic(Si,e=>e.extends(r.external(`client.Composable`)).default(F.type.literal(`$fetch`))).generic(Ci,e=>e.$if(r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`response`}),(e,t)=>e.extends(t).default(t),e=>e.default(`undefined`))),e=>e.generic(`ThrowOnError`,e=>e.extends(`boolean`).default((`throwOnError`in i.config?i.config.throwOnError:!1)??!1))).params(...s.parameters).do(...c)}function Xi(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(Vi)){let{operation:e}=r.data,i=F.const(Gi(t,r)).export().assign(Yi({node:F.func(),operation:e,plugin:t}));i=Ui({node:i,operation:e}),n.push(i)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=b(t.context.config).name===`@hey-api/client-angular`,i=e.shell.define(e),a=i.node,o=0;for(let n of e.itemsFrom(Vi)){let{operation:e}=n.data;a[`~dsl`]===`VarTsDsl`||((o>0||a.hasBody)&&a.newline(),a.do(Yi({node:F.method(Gi(t,n),n=>Ui({node:n,operation:e}).public().static(!r&&!Hi(t))),operation:e,plugin:t}))),o+=1}for(let n of e.children.values())a[`~dsl`]===`VarTsDsl`||(a.hasBody&&a.newline(),a.do(...Ki(n,t)));return n.push(a),{dependencies:i.dependencies,nodes:n}}const Zi=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>ee+t.trim()),z=e=>{let t=[];return e.summary&&t.push(Zi(e.summary)),e.description&&(t.length&&t.push(``),t.push(Zi(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Qi=({context:e,operation:t})=>{let n=b(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];if(r){if(!r.config.client&&!Hi(r))return!0;if(r.config.paramsStructure===`flat`)return!1}return n||st(t)},$i=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},ea=globalThis.Symbol(`@angular/common`);function ta(e){let{node:t,operation:n}=e;return t.$if(z(n),(e,t)=>e.doc(t))}function na(e){return{category:`utility`,resource:`operation`,resourceId:e.id,role:`request`,tool:`angular`}}function ra(e){return{category:`utility`,resource:`shell`,resourceId:e.getPath().join(`.`),role:`request`,tool:`angular`}}function ia(e){return{category:`utility`,resource:`operation`,resourceId:e.id,role:`resource`,tool:`angular`}}function aa(e){return{category:`utility`,resource:`shell`,resourceId:e.getPath().join(`.`),role:`resource`,tool:`angular`}}function oa(e,t){let{operation:n}=t.data,r=t.location[t.location.length-1];return e.symbol(L(r,e.config.httpRequests.methodName),{meta:na(n)})}function sa(e,t){let{operation:n}=t.data,r=t.location[t.location.length-1];return e.symbol(L(r,e.config.httpResources.methodName),{meta:ia(n)})}function ca(e,t){let n=t.referenceSymbol(ra(e)),r=I(n.name,`camelCase`),i=t.symbol(r),a=t.symbol(`_${r}`);return[F.field(a,e=>e.private().optional().type(n)),F.getter(i,e=>e.returns(n).do(F(`this`).attr(a).nullishAssign(F.new(n).args()).return()))]}function la(e,t){let n=t.referenceSymbol(aa(e)),r=I(n.name,`camelCase`),i=t.symbol(r),a=t.symbol(`_${r}`);return[F.field(a,e=>e.private().optional().type(n)),F.getter(i,e=>e.returns(n).do(F(`this`).attr(a).nullishAssign(F.new(n).args()).return()))]}function ua(e){let t=b(e.context.config).name===`@hey-api/client-angular`,n=e.external(`@angular/core.Injectable`);return{define:r=>{let i=e.symbol(L(r.name,r.isRoot?e.config.httpRequests.containerName:e.config.httpRequests.segmentName),{meta:ra(r)});return{dependencies:[],node:F.class(i).export().$if(t&&r.isRoot,e=>e.decorator(n,F.object().prop(`providedIn`,F.literal(`root`))))}}}}function da(e){let t=b(e.context.config).name===`@hey-api/client-angular`,n=e.external(`@angular/core.Injectable`);return{define:r=>{let i=e.symbol(L(r.name,r.isRoot?e.config.httpResources.containerName:e.config.httpResources.segmentName),{meta:aa(r)});return{dependencies:[],node:F.class(i).export().$if(t&&r.isRoot,e=>e.decorator(n,F.object().prop(`providedIn`,F.literal(`root`))))}}}}function fa(e){let{node:t,operation:n,plugin:r}=e,i=Qi({context:r.context,operation:n}),a=r.external(`@angular/common/http.HttpRequest`),o=r.getSymbol({category:`client`}),s=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),c=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`});return t.param(`options`,e=>e.required(i).type(F.type(s).generic(c??`unknown`).generic(`ThrowOnError`))).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).returns(F.type(a).generic(`unknown`)).do(F.return(F(`options`).attr(`client`).optional().$if(o,(e,t)=>e.coalesce(t)).attr(`requestOptions`).call(F.object().prop(`responseStyle`,F.literal(`data`)).prop(`method`,F.literal(n.method.toUpperCase())).prop(`url`,F.literal(n.path)).spread(`options`))))}function pa(e){let{node:t,operation:n,plugin:r}=e,i=Qi({context:r.context,operation:n}),a=r.external(`@angular/common/http.httpResource`),o=r.external(`@angular/core.inject`),s=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),c=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`}),l=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`response`});return t.param(`options`,e=>e.required(i).type(F.type.func().returns(F.type.or(F.type(s).generic(c??`unknown`).generic(`ThrowOnError`),F.type(`undefined`))))).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).do(F.return(F(a).call(F.func().do(F.const(`opts`).assign(F.ternary(`options`).do(F(`options`).call()).otherwise(F.id(`undefined`))),F.return(F.ternary(`opts`).do(F.lazy(e=>e.access(r.referenceSymbol(na(n)),{transform:(e,t)=>t===0?e[`~dsl`]===`ClassTsDsl`?F(o).call(F(e.name)):F(e.name):e}).call(`opts`))).otherwise(F.id(`undefined`))))).generic(l??`unknown`)))}function ma(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(ea)){let{operation:e}=r.data,i=F.const(oa(t,r)).export().assign(fa({node:F.func(),operation:e,plugin:t}));i=ta({node:i,operation:e}),n.push(i)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=e.shell.define(e),i=r.node,a=0;for(let n of e.itemsFrom(ea)){let{operation:e}=n.data;(a>0||i.hasBody)&&i.newline(),i.do(fa({node:F.method(oa(t,n),t=>ta({node:t,operation:e}).public()),operation:e,plugin:t})),a+=1}for(let n of e.children.values())i.hasBody&&i.newline(),i.do(...ca(n,t));return n.push(i),{dependencies:r.dependencies,nodes:n}}function ha(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(ea)){let{operation:e}=r.data,i=F.const(sa(t,r)).export().assign(pa({node:F.func(),operation:e,plugin:t}));i=ta({node:i,operation:e}),n.push(i)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=e.shell.define(e),i=r.node,a=0;for(let n of e.itemsFrom(ea)){let{operation:e}=n.data;(a>0||i.hasBody)&&i.newline(),i.do(pa({node:F.method(sa(t,n),t=>ta({node:t,operation:e}).public()),operation:e,plugin:t})),a+=1}for(let n of e.children.values())i.hasBody&&i.newline(),i.do(...la(n,t));return n.push(i),{dependencies:r.dependencies,nodes:n}}const ga={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:({plugin:e})=>{e.symbol(`HttpRequest`,{external:`@angular/common/http`,kind:`type`,meta:{category:`external`,resource:`@angular/common/http.HttpRequest`}}),e.symbol(`inject`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.inject`}}),e.symbol(`Injectable`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`}}),e.symbol(`httpResource`,{external:`@angular/common/http`,meta:{category:`external`,resource:`@angular/common/http.httpResource`}});let t=new n,r=new n;if(e.config.httpRequests.enabled){let n=ua(e),r=Qe(e);e.forEach(`operation`,({operation:e})=>{t.insert({data:{operation:e},locations:r(e).map(e=>({path:e,shell:n})),source:ea})},{order:`declarations`})}if(e.config.httpResources.enabled){let t=da(e),n=tt(e);e.forEach(`operation`,({operation:e})=>{r.insert({data:{operation:e},locations:n(e).map(e=>({path:e,shell:t})),source:ea})},{order:`declarations`})}let i=[],a=[];for(let n of t.walk()){let{dependencies:t,nodes:r}=ma(n,e);i.push(...t??[]),a.push(...r)}for(let t of r.walk()){let{dependencies:n,nodes:r}=ha(t,e);i.push(...n??[]),a.push(...r)}let o=new Map;for(let e of i)e.symbol&&o.set(e.symbol.id,e);for(let t of o.values())e.node(t);for(let t of a)e.node(t)},name:`@angular/common`,resolveConfig:(e,t)=>{e.config.httpRequests=Xe(e.config,t),e.config.httpResources=$e(e.config,t)}},_a={baseUrl:!0,bundle:!0,exportFromIndex:!1},va={dependencies:[`@hey-api/typescript`],tags:[`client`]},ya=m(import.meta.url),ba=p.dirname(ya),xa=e=>{let t=b(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return p.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},Sa=(e,t)=>{if(f.statSync(e).isDirectory()){f.existsSync(t)||f.mkdirSync(t,{recursive:!0});let n=f.readdirSync(e);for(let r of n)Sa(p.join(e,r),p.join(t,r))}else{let n=f.readFileSync(e);f.writeFileSync(t,n)}},Ca=({filePath:e,project:t,renamed:n})=>{let r=p.extname(e),i=p.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=p.dirname(e);f.renameSync(e,p.resolve(t,`${a}${r}`)),n.set(i,a)}},wa=({filePath:e,meta:t,renamed:n})=>{let r=f.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=p.extname(r),o=p.basename(r,a),s=p.dirname(r),c=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[s,c].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
12
+
13
+ ${r}`,f.writeFileSync(e,r,`utf8`)},Ta=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=p.resolve(t,`core`);fe(a),Sa(p.resolve(ba,`clients`,`core`),a);let o=p.resolve(t,`client`);fe(o);let s=n.name.slice(16);if(Sa(p.resolve(ba,`clients`,s),o),r){let e=f.readdirSync(a);for(let t of e)Ca({filePath:p.resolve(a,t),project:r,renamed:i});let t=f.readdirSync(o);for(let e of t)Ca({filePath:p.resolve(o,e),project:r,renamed:i})}let c=f.readdirSync(a);for(let t of c)wa({filePath:p.resolve(a,t),meta:e,renamed:i});let l=f.readdirSync(o);for(let t of l)wa({filePath:p.resolve(o,t),meta:e,renamed:i});return i}let a=p.isAbsolute(n.name)?p.dirname(n.name):void 0;if(a){let e=p.resolve(t,`client`);fe(e),Sa(a,e);return}let o=p.normalize(ae.resolve(n.name)).split(p.sep),s=o.slice(0,o.indexOf(`dist`)+1).join(p.sep),c=[o[o.length-1],`index.d.mts`,`index.d.cts`],l=p.resolve(t,`client`);fe(l);for(let e of c)f.copyFileSync(p.resolve(s,e),p.resolve(l,e))},Ea=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Da=e=>{let t={host:``,path:``,port:``,protocol:``};Ea.lastIndex=0;let n=e.match(Ea);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}},Oa=({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},ka=({plugin:e})=>{let t=xa(e.context.config),n=e.symbol(`createClient`,{external:t}),r=e.symbol(`createConfig`,{external:t}),i=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),{runtimeConfigPath:a}=e.config,o=a?e.symbol(`createClientConfig`,{external:a}):void 0,s=F.object(),c=Oa({plugin:e});if(c){let t=Da(c);if(t.protocol&&t.host&&!c.includes(`{`))s.prop(nt(e.context.config),F.literal(c));else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.prop(nt(e.context.config),F.literal(t))}}`throwOnError`in e.config&&e.config.throwOnError&&s.prop(`throwOnError`,F.literal(!0));let l=[F(r).call(s.hasProps()?s:void 0).generic(i)],u=e.symbol(`client`,{meta:{category:`client`}}),d=F.const(u).export().assign(F(n).$if(o,(e,t)=>e.call(F(t).call(...l)),e=>e.call(...l)));e.node(d)},Aa=({plugin:e})=>{let t=xa(e.context.config),n=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),r=e.symbol(`Config`,{external:t,kind:`type`}),i=e.symbol(`ClientOptions`,{external:t,kind:`type`}),a=e.symbol(`CreateClientConfig`),o=F.type.alias(a).export().doc(["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.`]).generic(`T`,e=>e.extends(i).default(n)).type(F.type.func().param(`override`,e=>e.optional().type(F.type(r).generic(F.type.and(i,`T`)))).returns(F.type(r).generic(F.type.and(F.type(`Required`).generic(i),`T`))));e.node(o)},ja=({plugin:e})=>{Aa({plugin:e}),ka({plugin:e})},Ma={...va,config:{..._a,throwOnError:!1},handler:ja,name:`@hey-api/client-angular`},Na={...va,config:{..._a,throwOnError:!1},handler:ja,name:`@hey-api/client-axios`},Pa={...va,config:{..._a,throwOnError:!1},handler:ja,name:`@hey-api/client-fetch`},Fa={...va,config:{..._a,throwOnError:!1},handler:ja,name:`@hey-api/client-ky`},Ia={...va,config:{..._a,throwOnError:!1},handler:ja,name:`@hey-api/client-next`},La={...va,config:_a,handler:ja,name:`@hey-api/client-nuxt`},Ra={...va,config:{..._a,throwOnError:!1},handler:ja,name:`@hey-api/client-ofetch`},za=(...e)=>te.satisfies(...e),Ba=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=te.parse(n);if(e)return e;let t=te.minVersion(n);if(t)return t;if(e=te.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?za(i,n,r):!1}}),Va=({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)},Ha=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Ha({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(Va({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Ha({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Ha({context:e,plugin:t,schema:n})),r.items&&=Ha({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]=Ha({context:e,plugin:t,schema:i}))}return r},Ua=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Ua({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(Va({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Ua({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Ua({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Ua({context:e,plugin:t,schema:n})),r.items&&=Ua({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Ua({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]=Ua({context:e,plugin:t,schema:i}))}return r},Wa=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Wa({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(Va({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Wa({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Wa({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Wa({context:e,plugin:t,schema:n})),r.items&&=Wa({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Wa({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>Wa({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]=Wa({context:e,plugin:t,schema:i}))}return r},Ga=({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`,r},Ka=({context:e,plugin:t})=>{if(e.spec.definitions)for(let n in e.spec.definitions){let r=e.spec.definitions[n],i=t.symbol(Ga({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=Ha({context:e,plugin:t,schema:r}),o=F.const(i).export().assign(F(F.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},qa=({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.symbol(Ga({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=Ua({context:e,plugin:t,schema:r}),o=F.const(i).export().assign(F(F.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},Ja=({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.symbol(Ga({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=Wa({context:e,plugin:t,schema:r}),o=F.const(i).export().assign(F(F.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},Ya={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:({plugin:e})=>{if(`swagger`in e.context.spec){Ka({context:e.context,plugin:e});return}if(za(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){qa({context:e.context,plugin:e});return}if(za(e.context.spec.openapi,`>=3.1.0`)){Ja({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},name:`@hey-api/schemas`};function Xa(e,t){e.asClass!==void 0&&s.warnDeprecated({context:`@hey-api/sdk`,field:`asClass`,replacement:[`operations: { strategy: "byTags" }`,`operations: { strategy: "single" }`]}),e.classNameBuilder!==void 0&&s.warnDeprecated({context:`@hey-api/sdk`,field:`classNameBuilder`,replacement:`operations: { containerName: "..." }`}),e.classStructure!==void 0&&s.warnDeprecated({context:`@hey-api/sdk`,field:`classStructure`,replacement:[`operations: { nesting: "operationId" }`,`operations: { nesting: "id" }`]}),e.instance!==void 0&&s.warnDeprecated({context:`@hey-api/sdk`,field:`instance`,replacement:`operations: { strategy: "single", containerName: "${e.instance||`Name`}", methods: "instance" }`}),e.methodNameBuilder!==void 0&&s.warnDeprecated({context:`@hey-api/sdk`,field:`methodNameBuilder`,replacement:`operations: { methodName: "..." }`}),e.operationId!==void 0&&s.warnDeprecated({context:`@hey-api/sdk`,field:`operationId`,replacement:[`operations: { nesting: "operationId" }`,`operations: { nesting: "id" }`]});let n=Qa(e);return Za(e.operations,n,t)}function Za(e,t,n){(!e||typeof e==`string`||typeof e==`function`)&&(e={strategy:e});let r=t.strategy??e.strategy??`flat`,i=r===`single`?`instance`:`static`;return n.valueToObject({defaultValue:{container:`class`,methods:i,nesting:`operationId`,nestingDelimiters:/[./]/,strategy:r,strategyDefaultTag:`default`},mappers:{object(e){return e.containerName=n.valueToObject({defaultValue:r===`single`?{casing:`PascalCase`,name:`Sdk`}:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.containerName}),e.methodName=n.valueToObject({defaultValue:{casing:`camelCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.methodName}),e.segmentName=n.valueToObject({defaultValue:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.segmentName}),e}},value:{...t,...e}})}function Qa(e){let t;e.instance?t=`single`:e.asClass?t=`byTags`:(e.instance===!1||e.asClass===!1)&&(t=`flat`);let n,r;if(e.instance){let t=typeof e.instance==`string`?e.instance:`Sdk`;r={casing:`PascalCase`},e.classNameBuilder&&(r.name=e.classNameBuilder,t=typeof e.classNameBuilder==`string`?e.classNameBuilder.replace(`{{name}}`,t):e.classNameBuilder(t)),n={casing:`PascalCase`,name:t}}else e.classNameBuilder?(n={casing:`PascalCase`,name:e.classNameBuilder},r={...n}):e.asClass&&(n={casing:`PascalCase`},r={...n});let i;e.instance?i=`instance`:e.asClass&&(i=`static`);let a;e.classStructure===`off`||e.operationId===!1?a=`id`:e.classStructure===`auto`&&(a=`operationId`);let o;return e.methodNameBuilder&&(o={casing:`camelCase`,name:e.methodNameBuilder}),{containerName:n,methodName:o,methods:i,nesting:a,segmentName:r,strategy:t}}function $a(e){return e.config.operations.nesting===`id`?y.id():e.config.operations.nesting===`operationId`?y.fromOperationId({delimiters:e.config.operations.nestingDelimiters,fallback:y.id()}):e.config.operations.nesting}function eo(e){if(e.config.operations.strategy===`flat`)return v.flat({path:t=>[$a(e)(t).join(`.`)]});if(e.config.operations.strategy===`single`){let t=e.config.operations.containerName;return v.single({path:$a(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.operations.strategy===`byTags`?v.byTags({fallback:e.config.operations.strategyDefaultTag,path:$a(e)}):e.config.operations.strategy}const to=({plugin:e})=>{let t=xa(e.context.config),n=b(e.context.config),r=n.name===`@hey-api/client-nuxt`,i=e.symbol(`TDataShape`,{external:t,kind:`type`}),a=e.symbol(`Client`,{external:t,kind:`type`,meta:{category:`external`,resource:`client.Client`,tool:n.name}}),o=e.symbol(`Options`,{external:t,kind:`type`}),s=e.symbol(`Options`,{meta:{category:`type`,resource:`client-options`,tool:`sdk`}}),c=F.type.alias(s).export().$if(r,t=>t.generic(`TComposable`,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`})).default(F.type.literal(`$fetch`))).generic(`TData`,e=>e.extends(i).default(i)).generic(wi,e=>e.default(`unknown`)).generic(Ci,e=>e.default(`undefined`)),e=>e.generic(`TData`,e=>e.extends(i).default(i)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(`boolean`))).type(F.type.and(F.type(o).$if(r,e=>e.generic(`TComposable`).generic(`TData`).generic(wi).generic(Ci),e=>e.generic(`TData`).generic(`ThrowOnError`)),F.type.object().prop(`client`,t=>t.doc(["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.`]).required(!e.config.client&&!Hi(e)).type(a)).prop(`meta`,e=>e.doc(["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.`]).optional().type(F.type(`Record`).generics(`string`,`unknown`)))));e.node(c)},no=({plugin:e})=>{let t=xa(e.context.config),r=b(e.context.config),i=r.name===`@hey-api/client-angular`,a=r.name===`@hey-api/client-nuxt`;e.symbol(`formDataBodySerializer`,{external:t,meta:{category:`external`,resource:`client.formDataBodySerializer`,tool:r.name}}),e.symbol(`urlSearchParamsBodySerializer`,{external:t,meta:{category:`external`,resource:`client.urlSearchParamsBodySerializer`,tool:r.name}}),e.symbol(`buildClientParams`,{external:t,meta:{category:`external`,resource:`client.buildClientParams`,tool:r.name}}),a&&e.symbol(`Composable`,{external:t,kind:`type`,meta:{category:`external`,resource:`client.Composable`,tool:r.name}}),i&&e.symbol(`Injectable`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`}}),to({plugin:e});let o=new n,s=qi(e),c=eo(e);e.forEach(`operation`,e=>{o.insert({data:{operation:e.operation,path:e._path,tags:e.tags},locations:c(e.operation).map(e=>({path:e,shell:s})),source:Vi})},{order:`declarations`});let l=[],u=[];for(let t of o.walk()){let{dependencies:n,nodes:r}=Xi(t,e);l.push(...n??[]),u.push(...r)}let d=new Map;for(let e of l)e.symbol&&d.set(e.symbol.id,e);for(let t of d.values())e.node(t);for(let t of u)e.node(t)},ro={config:{auth:!0,client:!0,exportFromIndex:!0,paramsStructure:`grouped`,responseStyle:`fields`,transformer:!1,validator:!1,response:`body`},dependencies:[`@hey-api/typescript`],handler:e=>no(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.operations=Xa(e.config,t)}},io=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:F(`BigInt`).call(F.expr(e).attr(`toString`).call());if(n){if(typeof e==`string`)return[n];if(e)return[F.expr(e).assign(n)]}},ao=({dataExpression:e,schema:t})=>{if(!(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))){if(typeof e==`string`)return[F.new(`Date`).arg(e)];if(e)return[F.expr(e).assign(F.new(`Date`).arg(e))]}},oo=`data`,so=new Set,co=e=>e[`~dsl`]===`ReturnTsDsl`,lo=({plugin:e,schema:t})=>{let n=uo({dataExpression:F(oo),plugin:e,schema:t});if(n.length){let e=n[n.length-1];co(e)||n.push(F.return(oo))}return n},uo=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r={category:`transform`,resource:`definition`,resourceId:n.$ref},i=t.getSymbol(r)??t.symbol(L(R(n.$ref),{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`}),{meta:r});if(!i.node&&!so.has(i.id)){so.add(i.id);try{let e=lo({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=F.const(i).assign(F.func().param(oo,e=>e.type(`any`)).do(...e));t.node(n)}}finally{so.delete(i.id)}}if(i.node||so.has(i.id)){let n=F(t.referenceSymbol(r)).call(e);if(e)return typeof e==`string`&&e===`item`?[F.return(n)]:[typeof e==`string`?n:F(e).assign(n)]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?uo({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=r;return i.some(e=>co(e))||i.push(F.return(`item`)),[F(e).assign(F(e).attr(`map`).call(F.func().param(`item`,e=>e.type(`any`)).do(...i)))]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=F(e||oo).attr(a),c=uo({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(F.if(s).do(...c))}return r}if(n.items){if(n.items.length===1)return uo({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=uo({dataExpression:e||`item`,plugin:t,schema:i});n.length&&(e?r=r.concat(n):r.push(F.if(`item`).do(...n),F.return(`item`)))}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[]},fo={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ut(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${C(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=lo({plugin:e,schema:n});if(!i.length)return;let a=e.symbol(L(t.id,{case:`camelCase`,name:`{{name}}ResponseTransformer`}),{meta:{category:`transform`,resource:`operation`,resourceId:t.id,role:`response`}}),o=F.const(a).export().assign(F.func().async().param(oo,e=>e.type(`any`)).returns(F.type(`Promise`).generic(r)).do(...i));e.node(o)},{order:`declarations`})},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,ao]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,io])},tags:[`transformer`]},po=({server:e})=>{let t=Da(e.url);return t.protocol&&t.host?F.type.literal(e.url):F.type.template().add(t.protocol||F.type(`string`)).add(`://`).add(t.host||F.type(`string`)).add(t.port?`:${t.port}`:``).add(t.path||``)},mo=({nodeIndex:e,plugin:t,servers:n})=>{let r=b(t.context.config),i=n.map(e=>po({server:e}));n.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(F.type.and(F.type(`string`),F.type.object())):i.push(F.type(`string`));let a=t.symbol(L(`ClientOptions`,{case:t.config.case}),{meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`}}),o=F.type.alias(a).export().type(F.type.object().prop(nt(t.context.config),e=>e.type(F.type.or(...i))));t.node(o,e)},B=e=>{let t=[];return e.title&&t.push(Zi(e.title)),e.description&&(t.length&&t.push(``),t.push(Zi(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},ho=({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=I(a,e.config.enums.case,{stripLeadingSeparators:!1}),k.number.lastIndex=0,k.number.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{key:a,schema:t}}),typeofItems:n}},go=({plugin:e,schema:t,state:n,type:i})=>{let a=Mi(r(n.path));if(t.type===`enum`&&e.config.enums.enabled){let i=ho({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&i.typeofItems.includes(`object`)&&(i.obj=i.obj.filter(e=>e.schema.const!==null));let o=e.symbol(L(R(a),e.config.definitions),{meta:{category:`utility`,path:r(n.path),resource:`definition`,resourceId:a,tags:r(n.tags),tool:`typescript`}}),s=F.const(o).export().$if(B(t),(e,t)=>e.doc(t)).assign(F.object(...i.obj.map(e=>F.prop({kind:`prop`,name:e.key}).$if(B(e.schema),(e,t)=>e.doc(t)).value(F.fromValue(e.schema.const)))).as(`const`));e.node(s);let c=e.symbol(L(R(a),e.config.definitions),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:a,tags:r(n.tags),tool:`typescript`}}),l=F.type.alias(c).export().$if(B(t),(e,t)=>e.doc(t)).type(F.type(c).idx(F.type(c).typeofType().keyof()).typeofType());e.node(l);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!i.typeofItems.some(e=>e!==`number`&&e!==`string`)){let o=e.symbol(L(R(a),e.config.definitions),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:a,tags:r(n.tags),tool:`typescript`}}),s=F.enum(o).export().$if(B(t),(e,t)=>e.doc(t)).const(e.config.enums.mode===`typescript-const`).members(...i.obj.map(e=>F.member(e.key).$if(B(e.schema),(e,t)=>e.doc(t)).value(F.fromValue(e.schema.const))));e.node(s);return}}let o=e.symbol(L(R(a),e.config.definitions),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:a,tags:r(n.tags),tool:`typescript`}}),s=F.type.alias(o).export().$if(B(t),(e,t)=>e.doc(t)).type(i);e.node(s)},_o=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=x({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},vo=({operation:e,plugin:t,state:n})=>{let i={type:`object`},a=[];i.properties||={},e.body?(i.properties.body=e.body.schema,e.body.required&&a.push(`body`)):i.properties.body={type:`never`},e.parameters?.header&&(i.properties.headers=_o({parameters:e.parameters.header}),i.properties.headers.required&&a.push(`headers`)),e.parameters?.path?(i.properties.path=_o({parameters:e.parameters.path}),i.properties.path.required&&a.push(`path`)):i.properties.path={type:`never`},e.parameters?.query?(i.properties.query=_o({parameters:e.parameters.query}),i.properties.query.required&&a.push(`query`)):i.properties.query={type:`never`},i.properties.url={const:e.path,type:`string`},a.push(`url`),i.required=a;let o=t.symbol(L(e.id,t.config.requests),{meta:{category:`type`,path:r(n.path),resource:`operation`,resourceId:e.id,role:`data`,tags:r(n.tags),tool:`typescript`}}),s=F.type.alias(o).export().type(V({plugin:t,schema:i,state:n}));t.node(s)},yo=({operation:e,plugin:t,state:n})=>{vo({operation:e,plugin:t,state:n});let{error:i,errors:a,response:o,responses:s}=ut(e);if(a){let o=t.symbol(L(e.id,t.config.errors),{meta:{category:`type`,path:r(n.path),resource:`operation`,resourceId:e.id,role:`errors`,tags:r(n.tags),tool:`typescript`}}),s=F.type.alias(o).export().type(V({plugin:t,schema:a,state:n}));if(t.node(s),i){let i=t.symbol(L(e.id,{case:t.config.errors.case,name:t.config.errors.error}),{meta:{category:`type`,path:r(n.path),resource:`operation`,resourceId:e.id,role:`error`,tags:r(n.tags),tool:`typescript`}}),a=F.type.alias(i).export().type(F.type(o).idx(F.type(o).keyof()));t.node(a)}}if(s){let i=t.symbol(L(e.id,t.config.responses),{meta:{category:`type`,path:r(n.path),resource:`operation`,resourceId:e.id,role:`responses`,tags:r(n.tags),tool:`typescript`}}),a=F.type.alias(i).export().type(V({plugin:t,schema:s,state:n}));if(t.node(a),o){let a=t.symbol(L(e.id,{case:t.config.responses.case,name:t.config.responses.response}),{meta:{category:`type`,path:r(n.path),resource:`operation`,resourceId:e.id,role:`response`,tags:r(n.tags),tool:`typescript`}}),o=F.type.alias(a).export().type(F.type(i).idx(F.type(i).keyof()));t.node(o)}}},bo=({operation:e,plugin:t,state:n})=>{let i={type:`object`},a=[];if(i.properties||={},e.body){let o=t.symbol(L(e.id,{case:t.config.webhooks.case,name:t.config.webhooks.payload}),{meta:{category:`type`,path:r(n.path),resource:`webhook`,resourceId:e.id,role:`data`,tags:r(n.tags),tool:`typescript`}}),s=F.type.alias(o).export().$if(B(e.body.schema),(e,t)=>e.doc(t)).type(V({plugin:t,schema:e.body.schema,state:n}));t.node(s),i.properties.body={symbolRef:o},a.push(`body`)}else i.properties.body={type:`never`};i.properties.key={const:e.path,type:`string`},a.push(`key`),i.properties.path={type:`never`},i.properties.query={type:`never`},i.required=a;let o=t.symbol(L(e.id,t.config.webhooks),{meta:{category:`type`,path:r(n.path),resource:`webhook`,resourceId:e.id,role:`data`,tags:r(n.tags),tool:`typescript`}}),s=F.type.alias(o).export().type(V({plugin:t,schema:i,state:n}));return t.node(s),o},xo=({operation:e,plugin:t,state:n})=>bo({operation:e,plugin:t,state:n}),So=({plugin:e,schema:t,state:n})=>{if(!t.items)return F.type(`Array`).generic(F.type(e.config.topType));t=x({detectFormat:!0,schema:t});let i=[];return t.items&&t.items.forEach((t,a)=>{let o=V({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,a])}});i.push(o)}),i.length===1?F.type(`Array`).generic(i[0]):t.logicalOperator===`and`?F.type(`Array`).generic(F.type.and(...i)):F.type(`Array`).generic(F.type.or(...i))},Co=({schema:e})=>e.const===void 0?F.type(`boolean`):F.type.literal(e.const),wo=({plugin:e,schema:t,state:n})=>V({plugin:e,schema:{...t,type:void 0},state:n}),To=e=>F.type(`never`),Eo=e=>F.type.literal(null),Do=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?F.type(`bigint`):F.type(`number`):F.type.literal(t.const),Oo=({plugin:e,schema:t,state:n})=>{let i=F.type.object(),a=t.required??[],o=[],s=!1;for(let c in t.properties){let u=t.properties[c],d=V({plugin:e,schema:u,state:{...n,path:l([...r(n.path),`properties`,c])}}),f=a.includes(c);i.prop(c,e=>e.$if(B(u),(e,t)=>e.doc(t)).readonly(u.accessScope===`read`).required(f).type(d)),o.push(u),f||(s=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let c=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(c||d&&(d.type!==`never`||!o.length)){let r=d;r&&r.type!==`never`?o.unshift(r):!c&&!o.length&&r&&r.type===`never`&&(o=[r]),s&&o.push({type:`undefined`});let a=o.length===1?V({plugin:e,schema:o[0],state:n}):V({plugin:e,schema:{items:o,logicalOperator:`or`},state:n});if(t.propertyNames?.$ref)return F.type.mapped(`key`).key(V({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n})).optional().type(a);i.idxSig(`key`,e=>e.key(`string`).type(a))}return i},ko=({plugin:e,schema:t})=>{if(t.const!==void 0)return F.type.literal(t.const);if(t.format){if(t.format===`binary`)return F.type.or(F.type(`Blob`),F.type(`File`));if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return F.type(`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.symbol(`TypeID`,{meta:t}),r=F.type.alias(n).export().generic(`T`,e=>e.extends(`string`)).type(F.type.template().add(F.type(`T`)).add(`_`).add(F.type(`string`)));e.node(r)}let n=e.referenceSymbol(t),a=e.symbol(I(`${r}_id`,e.config.case),{meta:i}),o=F.type.alias(a).export().type(F.type(n).generic(F.type.literal(r)));e.node(o)}let a=e.referenceSymbol(i);return F.type(a)}}return F.type(`string`)},Ao=({plugin:e,schema:t,state:n})=>{let i=[];return t.const&&Array.isArray(t.const)?i=t.const.map(e=>F.type.fromValue(e)):t.items&&t.items.forEach((t,a)=>{let o=V({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,a])}});i.push(o)}),F.type.tuple(...i)},jo=e=>F.type(`undefined`),Mo=({plugin:e})=>F.type(e.config.topType),No=e=>F.type(`void`),Po=({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 So({...t,schema:e});case`boolean`:return Co({...t,schema:e});case`enum`:return wo({...t,schema:e});case`integer`:case`number`:return Do({...t,schema:e});case`never`:return To({...t,schema:e});case`null`:return Eo({...t,schema:e});case`object`:return Oo({...t,schema:e});case`string`:return ko({...t,schema:e});case`tuple`:return Ao({...t,schema:e});case`undefined`:return jo({...t,schema:e});case`unknown`:return Mo({...t,schema:e});case`void`:return No({...t,schema:e})}},V=({plugin:e,schema:t,state:n})=>{if(t.symbolRef){let e=F.type(t.symbolRef);if(t.omit&&t.omit.length>0){let n=t.omit.length===1?F.type.literal(t.omit[0]):F.type.or(...t.omit.map(e=>F.type.literal(e)));return F.type(`Omit`).generics(e,n)}return e}if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref}),r=F.type(n);if(t.omit&&t.omit.length>0){let e=t.omit.length===1?F.type.literal(t.omit[0]):F.type.or(...t.omit.map(e=>F.type.literal(e)));return F.type(`Omit`).generics(r,e)}return r}if(t.type)return Po({plugin:e,schema:t,state:n});if(t.items){if(t=x({detectFormat:!1,schema:t}),t.items){let r=t.items.map(t=>V({plugin:e,schema:t,state:n}));return t.logicalOperator===`and`?F.type.and(...r):F.type.or(...r)}return V({plugin:e,schema:t,state:n})}return Po({plugin:e,schema:{type:`unknown`},state:n})},Fo=({plugin:e,schema:t,state:n})=>{go({plugin:e,schema:t,state:n,type:V({plugin:e,schema:t,state:n})})},Io=({plugin:e})=>{let t=e.node(null),n=e.node(null),r=[],i=[];if(e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=u({path:t._path,tags:t.tags});switch(t.type){case`operation`:yo({operation:t.operation,plugin:e,state:n});break;case`parameter`:Fo({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Fo({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Fo({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(xo({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),mo({nodeIndex:t,plugin:e,servers:r}),i.length>0){let t=e.symbol(L(`Webhooks`,{case:e.config.case}),{meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`}}),r=F.type.alias(t).export().type(F.type.or(...i));e.node(r,n)}},Lo={api:new class{schemaToType(e){return V(e)}},config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:e=>Io(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})}},Ro=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return F.fromValue(i)},zo=({operation:e,plugin:t})=>Li({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Bo=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})||`Error`;if(n.name===`@hey-api/client-axios`){let e=t.referenceSymbol({category:`external`,resource:`axios.AxiosError`});return F.type(e).generic(r)}return F.type(r)},Vo=({operation:e,plugin:t})=>{let n=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`});return F.type(n??`unknown`)},Ho=({isNuxtClient:e,operation:t,plugin:n})=>{let r=zo({operation:t,plugin:n});return e?F.type(`Omit`).generic(r).generic(`composable`):r},Uo=({operation:e,plugin:t})=>{let n=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),r=b(t.context.config).name===`@hey-api/client-nuxt`,i=Ho({isNuxtClient:r,operation:e,plugin:t}),a=t.symbol(`options`),o=t.symbol(`vars`),s=F.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(F.object().pretty().spread(a).spread(o).prop(`throwOnError`,F.literal(!0))).await()),c=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?c.push(F.return(s)):c.push(F.const().object(`data`).assign(s),F.return(`data`));let l=F.object().pretty().prop(`mutation`,F.func().async().param(o,e=>e.$if(r,e=>e.type(F.type(`Partial`).generic(i)))).do(...c)).$if(Ro(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t)),u=t.symbol(L(e.id,t.config.mutationOptions)),d=F.const(u).export().$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F.func().param(a,e=>e.optional().type(F.type(`Partial`).generic(i))).returns(F.type(n).generic(Vo({operation:e,plugin:t})).generic(i).generic(Bo({operation:e,plugin:t}))).do(F.return(l)));t.node(d)},Wo=`TOptions`,Go=({plugin:e})=>{let t=e.symbol(L(`createQueryKey`,{case:e.config.case}),{meta:{category:`utility`,resource:`createQueryKey`,tool:e.name}}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),i=F.type(n).generic(Wo).idx(0),a=nt(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=xa(e.context.config),l=e.symbol(`serializeQueryKeyValue`,{external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`}}),u=F.const(t).assign(F.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(Wo)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).returns(F.type.tuple(i)).generic(Wo,e=>e.extends(o)).do(F.const(`params`).type(i).assign(F.object().prop(`_id`,`id`).prop(a,F(`options`).attr(a).optional().or(F(`options`).attr(`client`).optional().$if(s,(e,t)=>e.coalesce(t)).attr(`getConfig`).call().attr(a))).as(i)),F.if(`tags`).do(F(`params`).attr(`tags`).assign(F(`tags`).as(`unknown`).as(r))),F.if(F(`options`).attr(`body`).optional().neq(F.id(`undefined`))).do(F.const(`normalizedBody`).assign(F(l).call(F(`options`).attr(`body`))),F.if(F(`normalizedBody`).neq(F.id(`undefined`))).do(F(`params`).attr(`body`).assign(`normalizedBody`))),F.if(F(`options`).attr(`path`).optional()).do(F(`params`).attr(`path`).assign(F(`options`).attr(`path`))),F.if(F(`options`).attr(`query`).optional().neq(F.id(`undefined`))).do(F.const(`normalizedQuery`).assign(F(l).call(F(`options`).attr(`query`))),F.if(F(`normalizedQuery`).neq(F.id(`undefined`))).do(F(`params`).attr(`query`).assign(`normalizedQuery`))),F.return(F.array(F(`params`)))));e.node(u)},Ko=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;return r.tags&&t.tags&&t.tags.length>0&&(i=F.array(...t.tags.map(e=>F.literal(e)))),F(n.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:n.name})).call(F.literal(e),`options`,i)},qo=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),n=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),r=e.symbol(`QueryKey`,{meta:{category:`type`,resource:`QueryKey`,tool:e.name}}),i=F.type.alias(r).export().generic(Wo,e=>e.extends(F.type(n))).type(F.type.tuple(F.type.and(F.type(`Pick<${Wo}, 'path'>`),F.type.object().prop(`_id`,e=>e.type(`string`)).prop(nt(e.context.config),e=>e.optional().type(t)).prop(`body`,e=>e.optional().type(t)).prop(`query`,e=>e.optional().type(t)).prop(`tags`,e=>e.optional().type(t)))));e.node(i)},Jo=({operation:e,plugin:t,symbol:n})=>{let r=b(t.context.config).name===`@hey-api/client-nuxt`;return F.const(n).export().assign(F.func().param(`options`,n=>n.required(st(e)).type(Ho({isNuxtClient:r,operation:e,plugin:t}))).do(Ko({id:e.id,operation:e,plugin:t}).return()))},Yo=`options`,Xo=`context`,Zo=({operation:e,plugin:t})=>{if($i({operation:e}))return;let n=Qi({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(qo({plugin:t}),Go({plugin:t}));let r;if(t.config.queryKeys.enabled){let n=t.symbol(L(e.id,t.config.queryKeys)),i=Jo({operation:e,plugin:t,symbol:n});t.node(i),r=F(n).call(Yo)}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),i;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(i=F.array(...e.tags.map(e=>F.literal(e)))),r=F(n).call(F.literal(e.id),Yo,i)}let i=Ho({isNuxtClient:b(t.context.config).name===`@hey-api/client-nuxt`,operation:e,plugin:t}),a=F.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(F.object().spread(Yo).spread(Xo).prop(`throwOnError`,F.literal(!0))).await()),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(F.return(a)):o.push(F.const().object(`data`).assign(a),F.return(`data`));let s=F.object().pretty().prop(`key`,r).prop(`query`,F.func().async().param(Xo).do(...o)).$if(Ro(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),c=t.symbol(L(e.id,t.config.queryOptions),{meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}}),l=t.referenceSymbol({category:`external`,resource:`${t.name}.defineQueryOptions`}),u=F.const(c).export().$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F(l).call(F.func().param(Yo,e=>e.required(n).type(i)).do(F.return(s))));t.node(u)},Qo=({plugin:e})=>{e.symbol(`defineQueryOptions`,{external:e.name,meta:{category:`external`,resource:`${e.name}.defineQueryOptions`}}),e.symbol(`UseMutationOptions`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseMutationOptions`}}),e.symbol(`UseQueryOptions`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseQueryOptions`}}),e.symbol(`_JSONValue`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}._JSONValue`}}),e.symbol(`AxiosError`,{external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`}}),e.forEach(`operation`,({operation:t})=>{e.hooks.operation.isQuery(t)&&e.config.queryOptions.enabled&&Zo({operation:t,plugin:e}),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Uo({operation:t,plugin:e})},{order:`declarations`})},$o={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:e=>Qo(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})}},es=({operation:e,plugin:t})=>Li({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),ts=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})||t.referenceSymbol({category:`external`,resource:`${t.name}.DefaultError`});if(n.name===`@hey-api/client-axios`){let e=t.referenceSymbol({category:`external`,resource:`axios.AxiosError`});return F.type(e).generic(r)}return F.type(r)},ns=({operation:e,plugin:t})=>{let n=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`});return F.type(n??`unknown`)},rs=`TOptions`,is=({plugin:e})=>{let t=e.symbol(L(`createQueryKey`,{case:e.config.case}),{meta:{category:`utility`,resource:`createQueryKey`,tool:e.name}}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=nt(e.context.config),i=e.getSymbol({category:`client`}),a=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=F.type(n).generic(rs).idx(0),s=F.const(t).assign(F.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(rs)).param(`infinite`,e=>e.optional().type(`boolean`)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).generic(rs,e=>e.extends(a)).returns(F.type.tuple(o)).do(F.const(`params`).type(o).assign(F.object().prop(`_id`,`id`).prop(r,F(`options`).attr(r).optional().or(F(`options`).attr(`client`).optional().$if(i,(e,t)=>e.coalesce(t)).attr(`getConfig`).call().attr(r))).as(o)),F.if(`infinite`).do(F(`params`).attr(`_infinite`).assign(`infinite`)),F.if(`tags`).do(F(`params`).attr(`tags`).assign(`tags`)),F.if(F(`options`).attr(`body`).optional()).do(F(`params`).attr(`body`).assign(F(`options`).attr(`body`))),F.if(F(`options`).attr(`headers`).optional()).do(F(`params`).attr(`headers`).assign(F(`options`).attr(`headers`))),F.if(F(`options`).attr(`path`).optional()).do(F(`params`).attr(`path`).assign(F(`options`).attr(`path`))),F.if(F(`options`).attr(`query`).optional()).do(F(`params`).attr(`query`).assign(F(`options`).attr(`query`))),F.return(F.array().element(F(`params`)))));e.node(s)},as=({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=F.array().elements(...n.tags)),F(r.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:r.name})).call(F.literal(e),`options`,t||a?F.literal(!!t):void 0,a)},os=({plugin:e})=>{let t=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),n=e.symbol(`QueryKey`,{meta:{category:`type`,resource:`QueryKey`,tool:e.name}}),r=F.type.alias(n).export().generic(rs,e=>e.extends(t)).type(F.type.tuple(F.type.and(F.type(`Pick<${rs}, '${nt(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`),F.type.object().prop(`_id`,e=>e.type(`string`)).prop(`_infinite`,e=>e.optional().type(`boolean`)).prop(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)))));e.node(r)},ss=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=es({operation:t,plugin:n});return F.const(r).export().assign(F.func().param(`options`,e=>e.required(st(t)).type(a)).$if(e&&i,(e,t)=>e.returns(t)).do(as({id:t.id,isInfinite:e,operation:t,plugin:n}).return()))},cs=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return F.fromValue(i)},ls=({plugin:e})=>{let t=e.symbol(L(`createInfiniteParams`,{case:e.config.case}),{meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name}}),n=F.const(t).assign(F.func().generic(`K`,e=>e.extends(F.type(`Pick`).generics(F.type(`QueryKey`).generic(`Options`).idx(0),F.type.or(F.type.literal(`body`),F.type.literal(`headers`),F.type.literal(`path`),F.type.literal(`query`))))).param(`queryKey`,e=>e.type(`QueryKey<Options>`)).param(`page`,e=>e.type(`K`)).do(F.const(`params`).assign(F.object().spread(F(`queryKey`).attr(0))),F.if(F(`page`).attr(`body`)).do(F(`params`).attr(`body`).assign(F.object().pretty().spread(F(`queryKey`).attr(0).attr(`body`).as(`any`)).spread(F(`page`).attr(`body`).as(`any`)))),F.if(F(`page`).attr(`headers`)).do(F(`params`).attr(`headers`).assign(F.object().pretty().spread(F(`queryKey`).attr(0).attr(`headers`)).spread(F(`page`).attr(`headers`)))),F.if(F(`page`).attr(`path`)).do(F(`params`).attr(`path`).assign(F.object().pretty().spread(F(`queryKey`).attr(0).attr(`path`).as(`any`)).spread(F(`page`).attr(`path`).as(`any`)))),F.if(F(`page`).attr(`query`)).do(F(`params`).attr(`query`).assign(F.object().pretty().spread(F(`queryKey`).attr(0).attr(`query`).as(`any`)).spread(F(`page`).attr(`query`).as(`any`)))),F.return(F(`params`).as(`unknown`).as(F(`page`).typeofType()))));e.node(n)},us=({operation:e,plugin:t})=>{let n=ct({context:t.context,operation:e});if(!n)return;let r=Qi({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(os({plugin:t}),is({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||ls({plugin:t});let i=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),a=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),o=es({operation:e,plugin:t}),s=ns({operation:e,plugin:t}),c=t.referenceSymbol({category:`type`,resource:`QueryKey`,tool:t.name}),u=F.type(c).generic(o),d=F.type(`Pick`).generics(u.idx(0),F.type.or(F.type.literal(`body`),F.type.literal(`headers`),F.type.literal(`path`),F.type.literal(`query`))),f=t.getPluginOrThrow(`@hey-api/typescript`),p=f.api.schemaToType({plugin:f,schema:n.schema,state:{path:l([])}}),m=t.symbol(L(e.id,t.config.infiniteQueryKeys)),h=ss({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.node(h);let ee=F.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(F.object().spread(`options`).spread(`params`).prop(`signal`,F(`signal`)).prop(`throwOnError`,F.literal(!0))).await()),te=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),ne=[F.const(`page`).type(d).hint(`@ts-ignore`).assign(F.ternary(F(`pageParam`).typeofExpr().eq(F.literal(`object`))).do(`pageParam`).otherwise(F.object().pretty().prop(n.in,F.object().pretty().prop(n.name,F(`pageParam`))))),F.const(`params`).assign(F(te).call(`queryKey`,`page`))];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?ne.push(F.return(ee)):ne.push(F.const().object(`data`).assign(ee),F.return(`data`));let re=t.symbol(L(e.id,t.config.infiniteQueryOptions)),ie=F.const(re).export().$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F.func().param(`options`,e=>e.required(r).type(o)).do(F.return(F(i).call(F.object().pretty().hint(`@ts-ignore`).prop(`queryFn`,F.func().async().param(e=>e.object(`pageParam`,`queryKey`,`signal`)).do(...ne)).prop(`queryKey`,F(m).call(`options`)).$if(cs(t,e,`infiniteQueryOptions`),(e,t)=>e.prop(`meta`,t))).generics(s,ts({operation:e,plugin:t}),F.type(a).generic(s),u,F.type.or(p,d)))));t.node(ie)},ds=({operation:e,plugin:t})=>{let n=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),r=es({operation:e,plugin:t}),i=F.type(n).generic(ns({operation:e,plugin:t})).generic(ts({operation:e,plugin:t})).generic(r),a=`fnOptions`,o=F.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(F.object().spread(`options`).spread(a).prop(`throwOnError`,F.literal(!0))).await()),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(F.return(o)):s.push(F.const().object(`data`).assign(o),F.return(`data`));let c=`mutationOptions`,l=t.symbol(L(e.id,t.config.mutationOptions)),u=F.const(l).export().$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F.func().param(`options`,e=>e.optional().type(F.type(`Partial`).generic(r))).returns(i).do(F.const(c).type(i).assign(F.object().pretty().prop(`mutationFn`,F.func().async().param(a).do(...s)).$if(cs(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t))),F(c).return()));t.node(u)},fs=`options`,ps=({operation:e,plugin:t})=>{if($i({operation:e}))return;let n=Qi({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(os({plugin:t}),is({plugin:t}));let r=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),i=t.symbol(L(e.id,t.config.queryKeys)),a=ss({isInfinite:!1,operation:e,plugin:t,symbol:i});t.node(a);let o=ns({operation:e,plugin:t}),s=F.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(F.object().spread(fs).spread(F(`queryKey`).attr(0)).prop(`signal`,F(`signal`)).prop(`throwOnError`,F.literal(!0))).await()),c=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?c.push(F.return(s)):c.push(F.const().object(`data`).assign(s),F.return(`data`));let l=F.object().pretty().prop(`queryFn`,F.func().async().param(e=>e.object(`queryKey`,`signal`)).do(...c)).prop(`queryKey`,F(i).call(fs)).$if(cs(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),u=t.symbol(L(e.id,t.config.queryOptions),{meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}}),d=F.const(u).export(t.config.queryOptions.exported).$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F.func().param(fs,r=>r.required(n).type(es({operation:e,plugin:t}))).do(F(r).call(l).generics(o,ts({operation:e,plugin:t}),o,F(i).returnType()).return()));t.node(d)},ms=`options`,hs=({operation:e,plugin:t})=>{if($i({operation:e})||!(`useQuery`in t.config))return;let n=t.symbol(L(e.id,t.config.useQuery)),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=Qi({context:t.context,operation:e}),a=es({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=F.const(n).export().$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F.func().param(ms,e=>e.required(i).type(a)).do(F(r).call(F(o).call(ms)).return()));t.node(s)},gs=({plugin:e})=>{e.symbol(`DefaultError`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.DefaultError`}}),e.symbol(`InfiniteData`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.InfiniteData`}});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.symbol(t,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.MutationOptions`}}),e.symbol(`infiniteQueryOptions`,{external:e.name,meta:{category:`external`,resource:`${e.name}.infiniteQueryOptions`}}),e.symbol(`queryOptions`,{external:e.name,meta:{category:`external`,resource:`${e.name}.queryOptions`}}),e.symbol(`useQuery`,{external:e.name,meta:{category:`external`,resource:`${e.name}.useQuery`}}),e.symbol(`AxiosError`,{external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`}}),e.forEach(`operation`,({operation:t})=>{e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&ps({operation:t,plugin:e}),e.config.infiniteQueryOptions.enabled&&us({operation:t,plugin:e}),`useQuery`in e.config&&e.config.useQuery.enabled&&hs({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&ds({operation:t,plugin:e})},{order:`declarations`})},_s=e=>gs(e),vs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:_s,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})}},ys={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:_s,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))}},bs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:_s,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})}},xs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:_s,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})}},Ss={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:_s,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})}},Cs=({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 F.func().async().param(r).do(F(n).attr(`parseAsync`).call(r).await().return())},ws=({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 F.func().async().param(r).do(F(n).attr(`parseAsync`).call(r).await().return())};var Ts=class{createRequestValidator(e){return Cs(e)}createResponseValidator(e){return ws(e)}};const H={keywords:{false:`false`,true:`true`},number:{Infinity:`Infinity`,NaN:`NaN`,NegativeInfinity:`NegativeInfinity`,epoch:`epoch`,integer:`integer`,safe:`safe`},primitives:{bigint:`bigint`,boolean:`boolean`,keywords:`keywords`,null:`null`,number:`number`,string:`string`,symbol:`symbol`,undefined:`undefined`,unit:`unit`},string:{NFC:`NFC`,NFD:`NFD`,NFKC:`NFKC`,NFKD:`NFKD`,alpha:`alpha`,alphanumeric:`alphanumeric`,base64:`base64`,capitalize:`capitalize`,creditCard:`creditCard`,date:`date`,digits:`digits`,email:`email`,epoch:`epoch`,hex:`hex`,integer:`integer`,ip:`ip`,iso:`iso`,json:`json`,lower:`lower`,normalize:`normalize`,numeric:`numeric`,parse:`parse`,preformatted:`preformatted`,regex:`regex`,semver:`semver`,trim:`trim`,upper:`upper`,url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:`$`,allows:`allows`,and:`and`,array:`array`,as:`as`,assert:`assert`,brand:`brand`,configure:`configure`,default:`default`,describe:`describe`,description:`description`,equals:`equals`,exclude:`exclude`,expression:`expression`,extends:`extends`,extract:`extract`,filter:`filter`,from:`from`,ifEquals:`ifEquals`,ifExtends:`ifExtends`,infer:`infer`,inferIn:`inferIn`,intersect:`intersect`,json:`json`,meta:`meta`,narrow:`narrow`,onDeepUndeclaredKey:`onDeepUndeclaredKey`,onUndeclaredKey:`onUndeclaredKey`,optional:`optional`,or:`or`,overlaps:`overlaps`,pipe:`pipe`,select:`select`,to:`to`,toJsonSchema:`toJsonSchema`}},Es=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=F.const(r).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).assign(F(a).call(e.def?F.literal(e.def):e.expression));if(t.node(o),i){let e=F.type.alias(i).export().type(F.type(r).attr(H.type.infer).typeofType());t.node(e)}},Ds=e=>{let t={};return t.def=H.primitives.null,t},Os=({plugin:e,schema:t,state:n})=>{let i={},a=F.object().pretty(),o=t.required??[];for(let s in t.properties){let c=t.properties[s],u=o.includes(s),d=js({optional:!u,plugin:e,schema:c,state:{...n,path:l([...r(n.path),`properties`,s])}});d.hasLazyExpression&&(i.hasLazyExpression=!0),a.prop(u?s:`${s}?`,d.expression)}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=js({plugin:e,schema:t.additionalProperties,state:{...n,path:l([...r(n.path),`additionalProperties`])}});return i.expression=F(`TODO`).attr(`record`).call(F(`TODO`).attr(`string`).call(),a.expression),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=a,i.hasLazyExpression?{...i,typeName:`TODO`}:i},ks=({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},As=({schema:e,...t})=>{switch(e.type){case`null`:return Ds({...t,schema:e});case`object`:return Os({...t,schema:e});case`string`:return ks({...t,schema:e})}return{def:``,expression:F(t.plugin.referenceSymbol({category:`external`,resource:`arktype.type`})).call(F.object().prop(`name`,F.literal(`string`)).prop(`platform`,F.literal(`'android' | 'ios'`)).prop(`versions?`,F.literal(`(number | string)[]`))),hasLazyExpression:!1}},js=({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);if(e.isSymbolRegistered(i)){let e=F(a);r.expression=e}else{let e=F(`TODO`).attr(`TODO`).call(F.func().returns(`any`).do(F.return(a)));r.expression=e,r.hasLazyExpression=!0,n.hasLazyExpression[`~ref`]=!0}}else if(t.type){let i=As({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=x({schema:t}),t.items||(r=js({plugin:e,schema:t,state:n}));else{let t=As({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}if(!r.expression){let t=As({plugin:e,schema:{type:`unknown`},state:n});r.expression=t.expression}return r},Ms=({plugin:e,schema:t,state:n})=>{let i=Mi(r(n.path)),a=js({plugin:e,schema:t,state:n}),o=R(i);Es({ast:a,plugin:e,schema:t,symbol:e.symbol(L(o,e.config.definitions),{meta:{category:`schema`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`arktype`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(L(o,e.config.definitions.types.infer),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:i,tool:`arktype`,variant:`infer`}}):void 0})},Ns=({plugin:e})=>{e.symbol(`type`,{external:`arktype`,meta:{category:`external`,resource:`arktype.type`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=u({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:Ms({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Ms({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Ms({plugin:e,schema:t.schema,state:n});break}})},Ps={api:new Ts,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Ns(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:_,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:{..._,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:_,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:{..._,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:_,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:{..._,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:_,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:{..._,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:_,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Fs=({operation:e,plugin:t})=>{let n=F.type.object(),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`data`,tool:`typescript`});r&&(e.body&&n.prop(`Body`,t=>t.required(e.body.required).type(F.type(r).idx(F.type.literal(`body`)))),e.parameters&&(e.parameters.header&&n.prop(`Headers`,t=>t.required(it(e.parameters.header)).type(F.type(r).idx(F.type.literal(`headers`)))),e.parameters.path&&n.prop(`Params`,t=>t.required(it(e.parameters.path)).type(F.type(r).idx(F.type.literal(`path`)))),e.parameters.query&&n.prop(`Querystring`,t=>t.required(it(e.parameters.query)).type(F.type(r).idx(F.type.literal(`query`))))));let{errors:i,responses:a}=ut(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);e.length&&(e.includes(`default`)?e.length>1&&(o=F.type(`Omit`,e=>e.generics(F.type(s),F.type.literal(`default`)))):o=F.type(s))}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);e.length&&(e.includes(`default`)?e.length>1&&(c=F.type(`Omit`,e=>e.generics(F.type(l),F.type.literal(`default`)))):c=F.type(l))}let u=[o,c].filter(e=>e!==void 0);if(u.length&&n.prop(`Reply`,e=>e.type(F.type.and(...u))),n.isEmpty)return;let d=t.referenceSymbol({category:`type`,resource:`route-handler`,tool:`fastify`});return{name:e.id,type:F.type(d,e=>e.generic(n))}},Is={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.symbol(`RouteHandler`,{external:`fastify`,kind:`type`,meta:{category:`type`,resource:`route-handler`,tool:`fastify`}});let t=e.symbol(`RouteHandlers`),n=F.type.object();e.forEach(`operation`,({operation:t})=>{let r=Fs({operation:t,plugin:e});r&&n.prop(r.name,e=>e.type(r.type))},{order:`declarations`});let r=F.type.alias(t).export().type(n);e.node(r)},name:`fastify`},Ls=({operation:e,plugin:t})=>{if($i({operation:e}))return;let n=t.referenceSymbol({category:`external`,resource:`swr`}),r=t.symbol(L(e.id,t.config.useSwr)),i=F.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(F.object().prop(`throwOnError`,F.literal(!0))).await()),a=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?a.push(F.return(i)):a.push(F.const().object(`data`).assign(i),F.return(`data`));let o=F.const(r).export().$if(t.config.comments&&z(e),(e,t)=>e.doc(t)).assign(F.func().do(F(n).call(F.literal(e.path),F.func().async().do(...a)).return()));t.node(o)},Rs=({plugin:e})=>{e.symbol(`useSWR`,{external:`swr`,importKind:`default`,kind:`function`,meta:{category:`external`,resource:`swr`}}),e.forEach(`operation`,({operation:t})=>{e.hooks.operation.isQuery(t)&&e.config.useSwr.enabled&&Ls({operation:t,plugin:e})},{order:`declarations`})},zs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:e=>Rs(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:`args`,base64:`base64`,bic:`bic`,brand:`brand`,bytes:`bytes`,check:`check`,checkItems:`checkItems`,creditCard:`creditCard`,cuid2:`cuid2`,decimal:`decimal`,description:`description`,digits:`digits`,email:`email`,emoji:`emoji`,empty:`empty`,endsWith:`endsWith`,entries:`entries`,everyItem:`everyItem`,excludes:`excludes`,filterItems:`filterItems`,findItem:`findItem`,finite:`finite`,flavor:`flavor`,graphemes:`graphemes`,gtValue:`gtValue`,hash:`hash`,hexColor:`hexColor`,hexadecimal:`hexadecimal`,imei:`imei`,includes:`includes`,integer:`integer`,ip:`ip`,ipv4:`ipv4`,ipv6:`ipv6`,isoDate:`isoDate`,isoDateTime:`isoDateTime`,isoTime:`isoTime`,isoTimeSecond:`isoTimeSecond`,isoTimestamp:`isoTimestamp`,isoWeek:`isoWeek`,length:`length`,ltValue:`ltValue`,mac:`mac`,mac48:`mac48`,mac64:`mac64`,mapItems:`mapItems`,maxBytes:`maxBytes`,maxEntries:`maxEntries`,maxGraphemes:`maxGraphemes`,maxLength:`maxLength`,maxSize:`maxSize`,maxValue:`maxValue`,maxWords:`maxWords`,metadata:`metadata`,mimeType:`mimeType`,minBytes:`minBytes`,minEntries:`minEntries`,minGraphemes:`minGraphemes`,minLength:`minLength`,minSize:`minSize`,minValue:`minValue`,minWords:`minWords`,multipleOf:`multipleOf`,nanoid:`nanoid`,nonEmpty:`nonEmpty`,normalize:`normalize`,notBytes:`notBytes`,notEntries:`notEntries`,notGraphemes:`notGraphemes`,notLength:`notLength`,notSize:`notSize`,notValue:`notValue`,notValues:`notValues`,notWords:`notWords`,octal:`octal`,parseJson:`parseJson`,partialCheck:`partialCheck`,rawCheck:`rawCheck`,rawTransform:`rawTransform`,readonly:`readonly`,reduceItems:`reduceItems`,regex:`regex`,returns:`returns`,rfcEmail:`rfcEmail`,safeInteger:`safeInteger`,size:`size`,slug:`slug`,someItem:`someItem`,sortItems:`sortItems`,startsWith:`startsWith`,stringifyJson:`stringifyJson`,title:`title`,toLowerCase:`toLowerCase`,toMaxValue:`toMaxValue`,toMinValue:`toMinValue`,toUpperCase:`toUpperCase`,transform:`transform`,trim:`trim`,trimEnd:`trimEnd`,trimStart:`trimStart`,ulid:`ulid`,url:`url`,uuid:`uuid`,value:`value`,values:`values`,words:`words`},async:{argsAsync:`argsAsync`,arrayAsync:`arrayAsync`,awaitAsync:`awaitAsync`,checkAsync:`checkAsync`,checkItemsAsync:`checkItemsAsync`,customAsync:`customAsync`,exactOptionalAsync:`exactOptionalAsync`,fallbackAsync:`fallbackAsync`,forwardAsync:`forwardAsync`,getDefaultsAsync:`getDefaultsAsync`,getFallbacksAsync:`getFallbacksAsync`,intersectAsync:`intersectAsync`,lazyAsync:`lazyAsync`,looseObjectAsync:`looseObjectAsync`,looseTupleAsync:`looseTupleAsync`,mapAsync:`mapAsync`,nonNullableAsync:`nonNullableAsync`,nonNullishAsync:`nonNullishAsync`,nonOptionalAsync:`nonOptionalAsync`,nullableAsync:`nullableAsync`,nullishAsync:`nullishAsync`,objectAsync:`objectAsync`,objectWithRestAsync:`objectWithRestAsync`,optionalAsync:`optionalAsync`,parseAsync:`parseAsync`,parserAsync:`parserAsync`,partialAsync:`partialAsync`,partialCheckAsync:`partialCheckAsync`,pipeAsync:`pipeAsync`,rawCheckAsync:`rawCheckAsync`,rawTransformAsync:`rawTransformAsync`,recordAsync:`recordAsync`,requiredAsync:`requiredAsync`,returnsAsync:`returnsAsync`,safeParseAsync:`safeParseAsync`,safeParserAsync:`safeParserAsync`,setAsync:`setAsync`,strictObjectAsync:`strictObjectAsync`,strictTupleAsync:`strictTupleAsync`,transformAsync:`transformAsync`,tupleAsync:`tupleAsync`,tupleWithRestAsync:`tupleWithRestAsync`,undefinedableAsync:`undefinedableAsync`,unionAsync:`unionAsync`,variantAsync:`variantAsync`},methods:{assert:`assert`,config:`config`,fallback:`fallback`,flatten:`flatten`,forward:`forward`,getDefault:`getDefault`,getDefaults:`getDefaults`,getDescription:`getDescription`,getFallback:`getFallback`,getFallbacks:`getFallbacks`,getMetadata:`getMetadata`,getTitle:`getTitle`,is:`is`,keyof:`keyof`,message:`message`,omit:`omit`,parse:`parse`,parser:`parser`,partial:`partial`,pick:`pick`,pipe:`pipe`,required:`required`,safeParse:`safeParse`,safeParser:`safeParser`,summarize:`summarize`,unwrap:`unwrap`},schemas:{any:`any`,array:`array`,bigInt:`bigint`,blob:`blob`,boolean:`boolean`,custom:`custom`,date:`date`,enum:`enum`,exactOptional:`exactOptional`,file:`file`,function:`function`,instance:`instance`,intersect:`intersect`,lazy:`lazy`,literal:`literal`,looseObject:`looseObject`,looseTuple:`looseTuple`,map:`map`,nan:`nan`,never:`never`,nonNullable:`nonNullable`,nonNullish:`nonNullish`,nonOptional:`nonOptional`,null:`null`,nullable:`nullable`,nullish:`nullish`,number:`number`,object:`object`,objectWithRest:`objectWithRest`,optional:`optional`,picklist:`picklist`,promise:`promise`,record:`record`,set:`set`,strictObject:`strictObject`,strictTuple:`strictTuple`,string:`string`,symbol:`symbol`,tuple:`tuple`,tupleWithRest:`tupleWithRest`,undefined:`undefined`,undefinedable:`undefinedable`,union:`union`,unknown:`unknown`,variant:`variant`,void:`void`},storages:{},types:{GenericSchema:`GenericSchema`},utils:{}},W=(e,t)=>e instanceof Array?e.length===1?e[0]:F(t.external(`valibot.v`)).attr(U.methods.pipe).call(...e):e,Bs={push:(e,t)=>(t instanceof Array?e.push(...t):e.push(t),e),toNode:W},Vs=e=>{let{schema:t,v:n}=e.symbols;return F(n).attr(U.async.parseAsync).call(t,`data`).await().return()},Hs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`valibot`});if(!n)return;let r={$:F,operation:e,pipes:{...Bs,current:[]},plugin:t,symbols:{schema:n,v:t.external(`valibot.v`)}},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,Vs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Us=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`valibot`});if(!n)return;let r={$:F,operation:e,pipes:{...Bs,current:[]},plugin:t,symbols:{schema:n,v:t.external(`valibot.v`)}},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,Vs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var Ws=class{createRequestValidator(e){return Hs(e)}createResponseValidator(e){return Us(e)}};const Gs=e=>e===`int64`||e===`uint64`,Ks=(e,t)=>Gs(t)?typeof e==`string`?(e.endsWith(`n`)&&(e=e.slice(0,-1)),F(`BigInt`).call(F.fromValue(e))):typeof e==`number`?F(`BigInt`).call(F.fromValue(e)):F.fromValue(e):F.fromValue(e),qs=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=F.const(i).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).$if(r.hasLazyExpression[`~ref`],t=>t.type(F.type(a).attr(e.typeName||U.types.GenericSchema))).assign(W(e.pipes,t));t.node(o)},Js=({getAst:e,operation:t,plugin:n,state:i})=>{if(n.config.requests.enabled){let a=new Set,o={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 i=t.parameters.header[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`headers`))}Object.keys(e).length&&(o.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let i=t.parameters.path[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`path`))}Object.keys(e).length&&(o.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let i=t.parameters.query[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`query`))}Object.keys(e).length&&(o.properties.query={properties:e,required:n,type:`object`})}}t.body&&(o.properties.body=t.body.schema,t.body.required&&a.add(`body`)),o.required=[...a],qs({ast:e(o,r(i.path)),plugin:n,schema:o,state:i,symbol:n.symbol(L(t.id,n.config.requests),{meta:{category:`schema`,path:r(i.path),resource:`operation`,resourceId:t.id,role:`data`,tags:r(i.tags),tool:`valibot`}})})}if(n.config.responses.enabled&&t.responses){let{response:a}=ut(t);if(a){let o=[...r(i.path),`responses`];qs({ast:e(a,o),plugin:n,schema:a,state:i,symbol:n.symbol(L(t.id,n.config.responses),{meta:{category:`schema`,path:o,resource:`operation`,resourceId:t.id,role:`responses`,tags:r(i.tags),tool:`valibot`}})})}}},Ys=({getAst:e,operation:t,plugin:n,state:i})=>{if(n.config.webhooks.enabled){let a=new Set,o={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 i=t.parameters.header[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`headers`))}Object.keys(e).length&&(o.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let i=t.parameters.path[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`path`))}Object.keys(e).length&&(o.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let i=t.parameters.query[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`query`))}Object.keys(e).length&&(o.properties.query={properties:e,required:n,type:`object`})}}t.body&&(o.properties.body=t.body.schema,t.body.required&&a.add(`body`)),o.required=[...a],qs({ast:e(o,r(i.path)),plugin:n,schema:o,state:i,symbol:n.symbol(L(t.id,n.config.webhooks),{meta:{category:`schema`,path:r(i.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:r(i.tags),tool:`valibot`}})})}},Xs=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.unknown).call(),Zs=({plugin:e,schema:t,state:n})=>{let i={pipes:[]},a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=F(a).attr(U.schemas.array);if(t.items){t=x({schema:t});let a=t.items.map((t,a)=>{let o=kc({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,a])}});return o.hasLazyExpression&&(i.hasLazyExpression=!0),W(o.pipes,e)});if(a.length===1){let e=o.call(...a);i.pipes.push(e)}else{t.logicalOperator;let r=o.call(Xs({plugin:e,schema:{type:`unknown`},state:n}));i.pipes.push(r)}}else{let t=o.call(Xs({plugin:e,schema:{type:`unknown`},state:n}));i.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=F(a).attr(U.actions.length).call(F.fromValue(t.minItems));i.pipes.push(e)}else{if(t.minItems!==void 0){let e=F(a).attr(U.actions.minLength).call(F.fromValue(t.minItems));i.pipes.push(e)}if(t.maxItems!==void 0){let e=F(a).attr(U.actions.maxLength).call(F.fromValue(t.maxItems));i.pipes.push(e)}}return i},Qs=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?(n.push(F(r).attr(U.schemas.literal).call(F.literal(t.const))),W(n,e)):(n.push(F(r).attr(U.schemas.boolean).call()),W(n,e))},$s=({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(F.literal(e.const)):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Xs({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=F(a).attr(U.schemas.picklist).call(F.array(...r));return i&&(o=F(a).attr(U.schemas.nullable).call(o)),o},ec=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.never).call(),tc=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.null).call(),nc=(e,t)=>({maxError:`Invalid value: Expected ${e} to be <= ${t[1]}`,minError:`Invalid value: Expected ${e} to be >= ${t[0]}`}),rc={int16:[-32768,32767],int32:[-2147483648,2147483647],int64:[`-9223372036854775808`,`9223372036854775807`],int8:[-128,127],uint16:[0,65535],uint32:[0,4294967295],uint64:[`0`,`18446744073709551615`],uint8:[0,255]},ic=e=>{if(!e)return;let t=rc[e];if(!t)return;let n=nc(e,t);return{maxValue:t[1],minValue:t[0],...n}};function ac(e){let{schema:t,symbols:n}=e,{v:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return[F(r).attr(U.schemas.union).call(F.array(F(r).attr(U.schemas.number).call(),F(r).attr(U.schemas.string).call(),F(r).attr(U.schemas.bigInt).call())),F(r).attr(U.actions.transform).call(F.func().param(`x`).do(F(`BigInt`).call(`x`).return()))];let i=[];return i.push(F(r).attr(U.schemas.number).call()),t.type===`integer`&&i.push(F(r).attr(U.actions.integer).call()),i}function oc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.const!==void 0)return F(r).attr(U.schemas.literal).call(e.utils.maybeBigInt(t.const,t.format))}function sc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.exclusiveMaximum!==void 0)return F(r).attr(U.actions.ltValue).call(e.utils.maybeBigInt(t.exclusiveMaximum,t.format));if(t.maximum!==void 0)return F(r).attr(U.actions.maxValue).call(e.utils.maybeBigInt(t.maximum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return F(r).attr(U.actions.maxValue).call(e.utils.maybeBigInt(i.maxValue,t.format),F.literal(i.maxError))}function cc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.exclusiveMinimum!==void 0)return F(r).attr(U.actions.gtValue).call(e.utils.maybeBigInt(t.exclusiveMinimum,t.format));if(t.minimum!==void 0)return F(r).attr(U.actions.minValue).call(e.utils.maybeBigInt(t.minimum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return F(r).attr(U.actions.minValue).call(e.utils.maybeBigInt(i.minValue,t.format),F.literal(i.minError))}function lc(e){let t=e.nodes.const(e);if(t)return e.pipes.push(e.pipes.current,t);let n=e.nodes.base(e);n&&e.pipes.push(e.pipes.current,n);let r=e.nodes.min(e);r&&e.pipes.push(e.pipes.current,r);let i=e.nodes.max(e);return i&&e.pipes.push(e.pipes.current,i),e.pipes.current}const uc=({plugin:e,schema:t})=>{let n={$:F,nodes:{base:ac,const:oc,max:sc,min:cc},pipes:{...Bs,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)},utils:{getIntegerLimit:ic,maybeBigInt:Ks,shouldCoerceToBigInt:Gs}},r=e.config[`~resolvers`]?.number,i=r?.(n)??lc(n);return n.pipes.toNode(i,e)};function dc(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||!n.additionalProperties.type)return;if(n.additionalProperties.type===`never`)return null;let i=kc({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:l([...r(e.utils.state.path),`additionalProperties`])}});return i.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),Bs.toNode(i.pipes,t)}function fc(e){let{nodes:t,symbols:n}=e,{v:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i===null?F(r).attr(U.schemas.strictObject).call(a):i?a.isEmpty?F(r).attr(U.schemas.record).call(F(r).attr(U.schemas.string).call(),i):F(r).attr(U.schemas.objectWithRest).call(a,i):F(r).attr(U.schemas.object).call(a)}function pc(e){return e.nodes.base(e)}function mc(e){let{plugin:t,schema:n}=e,i=F.object().pretty();for(let a in n.properties){let o=n.properties[a],s=kc({optional:!n.required?.includes(a),plugin:t,schema:o,state:{...e.utils.state,path:l([...r(e.utils.state.path),`properties`,a])}});s.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),i.prop(a,Bs.toNode(s.pipes,t))}return i}const hc=({plugin:e,schema:t,state:n})=>{let r={$:F,nodes:{additionalProperties:dc,base:fc,shape:mc},pipes:{...Bs,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)},utils:{ast:{},state:n}},i=e.config[`~resolvers`]?.object,a=i?.(r)??pc(r);return r.utils.ast.pipes=[r.pipes.toNode(a,e)],r.utils.ast};function gc(e){let{v:t}=e.symbols;return F(t).attr(U.schemas.string).call()}function _c(e){let{schema:t,symbols:n}=e,{v:r}=n;if(typeof t.const==`string`)return F(r).attr(U.schemas.literal).call(F.literal(t.const))}function vc(e){let{schema:t,symbols:n}=e,{v:r}=n;switch(t.format){case`date`:return F(r).attr(U.actions.isoDate).call();case`date-time`:return F(r).attr(U.actions.isoTimestamp).call();case`email`:return F(r).attr(U.actions.email).call();case`ipv4`:case`ipv6`:return F(r).attr(U.actions.ip).call();case`time`:return F(r).attr(U.actions.isoTimeSecond).call();case`uri`:return F(r).attr(U.actions.url).call();case`uuid`:return F(r).attr(U.actions.uuid).call()}}function yc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(!(t.minLength===void 0||t.minLength!==t.maxLength))return F(r).attr(U.actions.length).call(F.literal(t.minLength))}function bc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.maxLength!==void 0)return F(r).attr(U.actions.maxLength).call(F.literal(t.maxLength))}function xc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.minLength!==void 0)return F(r).attr(U.actions.minLength).call(F.literal(t.minLength))}function Sc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.pattern)return F(r).attr(U.actions.regex).call(F.regexp(t.pattern))}function Cc(e){let t=e.nodes.const(e);if(t)return e.pipes.push(e.pipes.current,t);let n=e.nodes.base(e);n&&e.pipes.push(e.pipes.current,n);let r=e.nodes.format(e);r&&e.pipes.push(e.pipes.current,r);let i=e.nodes.length(e);if(i)e.pipes.push(e.pipes.current,i);else{let t=e.nodes.minLength(e);t&&e.pipes.push(e.pipes.current,t);let n=e.nodes.maxLength(e);n&&e.pipes.push(e.pipes.current,n)}let a=e.nodes.pattern(e);return a&&e.pipes.push(e.pipes.current,a),e.pipes.current}const wc=({plugin:e,schema:t})=>{let n={$:F,nodes:{base:gc,const:_c,format:vc,length:yc,maxLength:bc,minLength:xc,pattern:Sc},pipes:{...Bs,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)}},r=e.config[`~resolvers`]?.string,i=r?.(n)??Cc(n);return n.pipes.toNode(i,e)},Tc=({plugin:e,schema:t,state:n})=>{let i={},a=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F(a).attr(U.schemas.literal).call(F.fromValue(e)));return i.pipes=[F(a).attr(U.schemas.tuple).call(F.array(...e))],i}if(t.items){let o=t.items.map((t,a)=>{let o=kc({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,a])}});return o.hasLazyExpression&&(i.hasLazyExpression=!0),W(o.pipes,e)});return i.pipes=[F(a).attr(U.schemas.tuple).call(F.array(...o))],i}return{pipes:[Xs({plugin:e,schema:{type:`unknown`},state:n})]}},Ec=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.undefined).call(),Dc=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.void).call(),Oc=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:W(Zs({...t,schema:e}).pipes,t.plugin)};case`boolean`:return{expression:Qs({...t,schema:e})};case`enum`:return{expression:$s({...t,schema:e})};case`integer`:case`number`:return{expression:uc({...t,schema:e})};case`never`:return{expression:ec({...t,schema:e})};case`null`:return{expression:tc({...t,schema:e})};case`object`:return{expression:W(hc({...t,schema:e}).pipes,t.plugin)};case`string`:return{expression:Gs(e.format)?uc({...t,schema:{...e,type:`number`}}):wc({...t,schema:e})};case`tuple`:return{expression:W(Tc({...t,schema:e}).pipes,t.plugin)};case`undefined`:return{expression:Ec({...t,schema:e})};case`unknown`:return{expression:Xs({...t,schema:e})};case`void`:return{expression:Dc({...t,schema:e})}}},kc=({optional:e,plugin:t,schema:n,state:i})=>{let a={pipes:[]},o=t.referenceSymbol({category:`external`,resource:`valibot.v`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`valibot`},r=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=F(r);a.pipes.push(e)}else{let e=F(o).attr(U.schemas.lazy).call(F.func().do(F(r).return()));a.pipes.push(e),i.hasLazyExpression[`~ref`]=!0}}else if(n.type){let e=Oc({plugin:t,schema:n,state:i});if(a.typeName=e.anyType,a.pipes.push(e.expression),t.config.metadata&&n.description){let e=F(o).attr(U.actions.metadata).call(F.object().prop(`description`,F.literal(n.description)));a.pipes.push(e)}}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>W(kc({plugin:t,schema:e,state:{...i,path:l([...r(i.path),`items`,n])}}).pipes,t));if(n.logicalOperator===`and`){let t=F(o).attr(U.schemas.intersect).call(F.array(...e));a.pipes.push(t)}else{let t=F(o).attr(U.schemas.union).call(F.array(...e));a.pipes.push(t)}}else{let e=kc({plugin:t,schema:n,state:i});a.pipes.push(...e.pipes)}else{let e=Oc({plugin:t,schema:{type:`unknown`},state:i});a.typeName=e.anyType,a.pipes.push(e.expression)}if(a.pipes.length){if(n.accessScope===`read`){let e=F(o).attr(U.actions.readonly).call();a.pipes.push(e)}n.default===void 0?e&&(a.pipes=[F(o).attr(U.schemas.optional).call(W(a.pipes,t))]):a.pipes=[F(o).attr(U.schemas.optional).call(W(a.pipes,t),n.type===`integer`||n.type===`number`?Ks(n.default,n.format):F.fromValue(n.default))]}return a},Ac=({plugin:e,schema:t,state:n})=>{let i=Mi(r(n.path)),a=kc({plugin:e,schema:t,state:n}),o=R(i);qs({ast:a,plugin:e,schema:t,state:n,symbol:e.symbol(L(o,e.config.definitions),{meta:{category:`schema`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`valibot`}})})},jc=({plugin:e})=>{e.symbol(`v`,{external:`valibot`,importKind:`namespace`,meta:{category:`external`,resource:`valibot.v`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=u({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Js({getAst:(n,r)=>kc({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Ac({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Ac({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Ac({plugin:e,schema:t.schema,state:n});break;case`webhook`:Ys({getAst:(n,r)=>kc({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Mc={api:new Ws,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>jc(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:`ZodMiniOptional`,ZodOptional:`ZodOptional`,_default:`_default`,and:`and`,array:`array`,bigint:`bigint`,boolean:`boolean`,check:`check`,coerce:`coerce`,date:`date`,datetime:`datetime`,default:`default`,describe:`describe`,email:`email`,enum:`enum`,globalRegistry:`globalRegistry`,gt:`gt`,gte:`gte`,infer:`infer`,int:`int`,intersection:`intersection`,ip:`ip`,ipv4:`ipv4`,ipv6:`ipv6`,iso:`iso`,lazy:`lazy`,length:`length`,literal:`literal`,lt:`lt`,lte:`lte`,max:`max`,maxLength:`maxLength`,maximum:`maximum`,min:`min`,minLength:`minLength`,minimum:`minimum`,never:`never`,null:`null`,nullable:`nullable`,number:`number`,object:`object`,optional:`optional`,parseAsync:`parseAsync`,readonly:`readonly`,record:`record`,regex:`regex`,register:`register`,string:`string`,time:`time`,tuple:`tuple`,undefined:`undefined`,union:`union`,unknown:`unknown`,url:`url`,uuid:`uuid`,void:`void`},Nc=e=>{let{schema:t}=e.symbols;return F(t).attr(G.parseAsync).call(`data`).await().return()},Pc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:F,chain:{current:F(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,Nc];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Fc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:F,chain:{current:F(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,Nc];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Ic=e=>{let{schema:t}=e.symbols;return F(t).attr(G.parseAsync).call(`data`).await().return()},Lc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:F,chain:{current:F(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,Ic];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Rc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:F,chain:{current:F(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,Ic];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}},zc=e=>{let{schema:t}=e.symbols;return F(t).attr(G.parseAsync).call(`data`).await().return()},Bc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:F,chain:{current:F(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,zc];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Vc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:F,chain:{current:F(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,zc];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return F.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var Hc=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Lc(e);case`mini`:return Pc(e);case 4:default:return Bc(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Rc(e);case`mini`:return Fc(e);case 4:default:return Vc(e)}}};const Uc=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=F.const(r).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).$if(e.typeName,(e,t)=>e.type(F.type(a).attr(t))).assign(e.expression);if(t.node(o),i){let e=F.type.alias(i).export().type(F.type(a).attr(G.infer).generic(F(r).typeofType()));t.node(e)}},Wc=({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`}},Gc=({getAst:e,operation:t,plugin:n,state:i})=>{if(n.config.requests.enabled){let a=new Set,o={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 i=t.parameters.header[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`headers`))}Object.keys(e).length&&(o.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let i=t.parameters.path[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`path`))}Object.keys(e).length&&(o.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let i=t.parameters.query[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`query`))}Object.keys(e).length&&(o.properties.query={properties:e,required:n,type:`object`})}}t.body&&(o.properties.body=t.body.schema,t.body.required&&a.add(`body`)),o.required=[...a],Uc({ast:e(o,r(i.path)),plugin:n,schema:o,symbol:n.symbol(L(t.id,n.config.requests),{meta:{category:`schema`,path:r(i.path),resource:`operation`,resourceId:t.id,role:`data`,tags:r(i.tags),tool:`zod`}}),typeInferSymbol:n.config.requests.types.infer.enabled?n.symbol(L(t.id,n.config.requests.types.infer),{meta:{category:`type`,path:r(i.path),resource:`operation`,resourceId:t.id,role:`data`,tags:r(i.tags),tool:`zod`,variant:`infer`}}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:a}=ut(t);if(a){let o=[...r(i.path),`responses`];Uc({ast:e(a,o),plugin:n,schema:a,symbol:n.symbol(L(t.id,n.config.responses),{meta:{category:`schema`,path:o,resource:`operation`,resourceId:t.id,role:`responses`,tags:r(i.tags),tool:`zod`}}),typeInferSymbol:n.config.responses.types.infer.enabled?n.symbol(L(t.id,n.config.responses.types.infer),{meta:{category:`type`,path:o,resource:`operation`,resourceId:t.id,role:`responses`,tags:r(i.tags),tool:`zod`,variant:`infer`}}):void 0})}}},Kc=({getAst:e,operation:t,plugin:n,state:i})=>{if(n.config.webhooks.enabled){let a=new Set,o={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 i=t.parameters.header[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`headers`))}Object.keys(e).length&&(o.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let i=t.parameters.path[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`path`))}Object.keys(e).length&&(o.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let i=t.parameters.query[r];e[i.name]=i.schema,i.required&&(n.push(i.name),a.add(`query`))}Object.keys(e).length&&(o.properties.query={properties:e,required:n,type:`object`})}}t.body&&(o.properties.body=t.body.schema,t.body.required&&a.add(`body`)),o.required=[...a],Uc({ast:e(o,r(i.path)),plugin:n,schema:o,symbol:n.symbol(L(t.id,n.config.webhooks),{meta:{category:`schema`,path:r(i.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:r(i.tags),tool:`zod`}}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.symbol(L(t.id,n.config.webhooks.types.infer),{meta:{category:`type`,path:r(i.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:r(i.tags),tool:`zod`,variant:`infer`}}):void 0})}},qc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F(t).attr(G.unknown).call(),n},Jc=({plugin:e,schema:t,state:n})=>{let i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a={},o=F(i).attr(G.array);if(!t.items)a.expression=o.call(qc({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=x({schema:t});let s=t.items.map((t,i)=>{let o=Cl({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,i])}});return o.hasLazyExpression&&(a.hasLazyExpression=!0),o.expression});if(s.length===1)a.expression=o.call(...s);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=F(i).attr(G.intersection).call(...s);else{n=s[0];for(let e=1;e<s.length;e++)n=F(i).attr(G.intersection).call(n,s[e])}a.expression=o.call(n)}else a.expression=F(i).attr(G.array).call(F(i).attr(G.union).call(F.array(...s)))}let s=[];return t.minItems===t.maxItems&&t.minItems!==void 0?s.push(F(i).attr(G.length).call(F.fromValue(t.minItems))):(t.minItems!==void 0&&s.push(F(i).attr(G.minLength).call(F.fromValue(t.minItems))),t.maxItems!==void 0&&s.push(F(i).attr(G.maxLength).call(F.fromValue(t.maxItems)))),s.length>0&&(a.expression=a.expression.attr(G.check).call(...s)),a},Yc=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=F(i).attr(G.literal).call(F.literal(t.const)),n.expression=r,n):(r=F(i).attr(G.boolean).call(),n.expression=r,n)},Xc=({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=F.literal(e.const);a.push(t),o.push(F(r).attr(G.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=F.literal(e.const);o.push(F(r).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=F.literal(e.const);o.push(F(r).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=F(r).attr(G.enum).call(F.array(...a)):o.length===1?i.expression=o[0]:i.expression=F(r).attr(G.union).call(F.array(...o)),s&&(i.expression=F(r).attr(G.nullable).call(i.expression)),i):qc({plugin:e,schema:{type:`unknown`},state:n})},Zc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F(t).attr(G.never).call(),n},Qc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F(t).attr(G.null).call(),n};function $c(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return F(r).attr(G.coerce).attr(G.bigint).call();let i=F(r).attr(G.number).call();return t.type===`integer`&&(i=F(r).attr(G.int).call()),i}function el(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return F(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function tl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.exclusiveMaximum!==void 0)return F(r).attr(G.lt).call(e.utils.maybeBigInt(t.exclusiveMaximum,t.format));if(t.maximum!==void 0)return F(r).attr(G.lte).call(e.utils.maybeBigInt(t.maximum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return F(r).attr(G.maximum).call(e.utils.maybeBigInt(i.maxValue,t.format),F.object().prop(`error`,F.literal(i.maxError)))}function nl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.exclusiveMinimum!==void 0)return F(r).attr(G.gt).call(e.utils.maybeBigInt(t.exclusiveMinimum,t.format));if(t.minimum!==void 0)return F(r).attr(G.gte).call(e.utils.maybeBigInt(t.minimum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return F(r).attr(G.minimum).call(e.utils.maybeBigInt(i.minValue,t.format),F.object().prop(`error`,F.literal(i.minError)))}function rl(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=[],i=e.nodes.min(e);i&&r.push(i);let a=e.nodes.max(e);return a&&r.push(a),r.length>0&&(e.chain.current=e.chain.current.attr(G.check).call(...r)),e.chain.current}const il=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:F,chain:{current:F(i)},nodes:{base:$c,const:el,max:tl,min:nl},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:ic,maybeBigInt:Ks,shouldCoerceToBigInt:Gs,state:n}},o=e.config[`~resolvers`]?.number;return r.expression=o?.(a)??rl(a),r};function al(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let i=Cl({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:l([...r(e.utils.state.path),`additionalProperties`])}});return i.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),i.expression}function ol(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?F(r).attr(G.record).call(F(r).attr(G.string).call(),i):F(r).attr(G.object).call(a)}function sl(e){return e.nodes.base(e)}function cl(e){let{plugin:t,schema:n}=e,i=F.object().pretty();for(let a in n.properties){let o=n.properties[a],s=Cl({optional:!n.required?.includes(a),plugin:t,schema:o,state:{...e.utils.state,path:l([...r(e.utils.state.path),`properties`,a])}});s.hasLazyExpression?(e.utils.ast.hasLazyExpression=!0,i.getter(a,s.expression.return())):i.prop(a,s.expression)}return i}const ll=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:F,chain:{current:F(i)},nodes:{additionalProperties:al,base:ol,shape:cl},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??sl(a),r};function ul(e){let{z:t}=e.symbols;return F(t).attr(G.string).call()}function dl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return F(r).attr(G.literal).call(F.literal(t.const))}function fl(e){let{plugin:t,schema:n,symbols:r}=e,{z:i}=r;switch(n.format){case`date`:return F(i).attr(G.iso).attr(G.date).call();case`date-time`:{let e=F.object().$if(t.config.dates.offset,e=>e.prop(`offset`,F.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,F.literal(!0)));return F(i).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return F(i).attr(G.email).call();case`ipv4`:return F(i).attr(G.ipv4).call();case`ipv6`:return F(i).attr(G.ipv6).call();case`time`:return F(i).attr(G.iso).attr(G.time).call();case`uri`:return F(i).attr(G.url).call();case`uuid`:return F(i).attr(G.uuid).call()}}function pl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(!(t.minLength===void 0||t.minLength!==t.maxLength))return F(r).attr(G.length).call(F.literal(t.minLength))}function ml(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.maxLength!==void 0)return F(r).attr(G.maxLength).call(F.literal(t.maxLength))}function hl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.minLength!==void 0)return F(r).attr(G.minLength).call(F.literal(t.minLength))}function gl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.pattern)return F(r).attr(G.regex).call(F.regexp(t.pattern))}function _l(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.format(e);r&&(e.chain.current=r);let i=[],a=e.nodes.length(e);if(a)i.push(a);else{let t=e.nodes.minLength(e);t&&i.push(t);let n=e.nodes.maxLength(e);n&&i.push(n)}let o=e.nodes.pattern(e);return o&&i.push(o),i.length>0&&(e.chain.current=e.chain.current.attr(G.check).call(...i)),e.chain.current}const vl=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:F,chain:{current:F(n)},nodes:{base:ul,const:dl,format:fl,length:pl,maxLength:ml,minLength:hl,pattern:gl},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return{expression:i?.(r)??_l(r)}},yl=({plugin:e,schema:t,state:n})=>{let i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F(i).attr(G.literal).call(F.fromValue(e)));return a.expression=F(i).attr(G.tuple).call(F.array(...e)),a}let o=[];return t.items&&t.items.forEach((t,i)=>{let s=Cl({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,i])}});o.push(s.expression),s.hasLazyExpression&&(a.hasLazyExpression=!0)}),a.expression=F(i).attr(G.tuple).call(F.array(...o)),a},bl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F(t).attr(G.undefined).call(),n},xl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=F(t).attr(G.void).call(),n},Sl=({schema:e,...t})=>{switch(e.type){case`array`:return Jc({...t,schema:e});case`boolean`:return Yc({...t,schema:e});case`enum`:return Xc({...t,schema:e});case`integer`:case`number`:return il({...t,schema:e});case`never`:return Zc({...t,schema:e});case`null`:return Qc({...t,schema:e});case`object`:return ll({...t,schema:e});case`string`:return Gs(e.format)?il({...t,schema:{...e,type:`number`}}):vl({...t,schema:e});case`tuple`:return yl({...t,schema:e});case`undefined`:return bl({...t,schema:e});case`unknown`:return qc({...t,schema:e});case`void`:return xl({...t,schema:e})}},Cl=({optional:e,plugin:t,schema:n,state:i})=>{let a={},o=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},r=t.referenceSymbol(e);t.isSymbolRegistered(e)?a.expression=F(r):(a.expression=F(o).attr(G.lazy).call(F.func().returns(`any`).do(F(r).return())),a.hasLazyExpression=!0,i.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=Sl({plugin:t,schema:n,state:i});a.expression=e.expression,a.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(a.expression=a.expression.attr(G.register).call(F(o).attr(G.globalRegistry),F.object().pretty().prop(`description`,F.literal(n.description))))}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>Cl({plugin:t,schema:e,state:{...i,path:l([...r(i.path),`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?a.expression=F(o).attr(G.intersection).call(...e.map(e=>e.expression)):(a.expression=e[0].expression,e.slice(1).forEach(e=>{a.expression=F(o).attr(G.intersection).call(a.expression,e.hasLazyExpression?F(o).attr(G.lazy).call(F.func().do(e.expression.return())):e.expression)}))}else a.expression=F(o).attr(G.union).call(F.array().pretty().elements(...e.map(e=>e.expression)))}else a=Cl({plugin:t,schema:n,state:i});else{let e=Sl({plugin:t,schema:{type:`unknown`},state:i});a.expression=e.expression}return a.expression&&(n.accessScope===`read`&&(a.expression=F(o).attr(G.readonly).call(a.expression)),e&&(a.expression=F(o).attr(G.optional).call(a.expression),a.typeName=G.ZodMiniOptional),n.default!==void 0&&(a.expression=F(o).attr(G._default).call(a.expression,n.type===`integer`||n.type===`number`?Ks(n.default,n.format):F.fromValue(n.default)))),a},wl=({plugin:e,schema:t,state:n})=>{let i=Mi(r(n.path)),a=Cl({plugin:e,schema:t,state:n}),o=R(i);Uc({ast:a,plugin:e,schema:t,symbol:e.symbol(L(o,e.config.definitions),{meta:{category:`schema`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(L(o,e.config.definitions.types.infer),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`zod`,variant:`infer`}}):void 0})},Tl=({plugin:e})=>{e.symbol(`z`,{external:Wc({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=u({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Gc({getAst:(n,r)=>Cl({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:wl({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:wl({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:wl({plugin:e,schema:t.schema,state:n});break;case`webhook`:Kc({getAst:(n,r)=>Cl({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},El=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.unknown).call(),Dl=({plugin:e,schema:t,state:n})=>{let i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=F(i).attr(G.array),o,s=!1;if(!t.items)o=a.call(El({plugin:e,schema:{type:`unknown`},state:n}));else{t=x({schema:t});let c=t.items.map((t,i)=>{let a=nu({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,i])}});return a.hasLazyExpression&&(s=!0),a.expression});if(c.length===1)o=a.call(...c);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=F(i).attr(G.intersection).call(...c);else{n=c[0];for(let e=1;e<c.length;e++)n=n.attr(G.and).call(c[e])}o=a.call(n)}else o=F(i).attr(G.array).call(F(i).attr(G.union).call(F.array(...c)))}return t.minItems===t.maxItems&&t.minItems!==void 0?o=o.attr(G.length).call(F.fromValue(t.minItems)):(t.minItems!==void 0&&(o=o.attr(G.min).call(F.fromValue(t.minItems))),t.maxItems!==void 0&&(o=o.attr(G.max).call(F.fromValue(t.maxItems)))),{expression:o,hasLazyExpression:s}},Ol=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n=F(r).attr(G.literal).call(F.literal(t.const)),n):(n=F(r).attr(G.boolean).call(),n)},kl=({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=F.literal(e.const);i.push(t),a.push(F(r).attr(G.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=F.literal(e.const);a.push(F(r).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=F.literal(e.const);a.push(F(r).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return El({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?F(r).attr(G.enum).call(F.array(...i)):a.length===1?a[0]:F(r).attr(G.union).call(F.array(...a)),o&&(c=c.attr(G.nullable).call()),c},Al=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.never).call(),jl=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.null).call();function Ml(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return F(r).attr(G.coerce).attr(G.bigint).call();let i=F(r).attr(G.number).call();return t.type===`integer`&&(i=i.attr(G.int).call()),i}function Nl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return F(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function Pl(e){let{chain:t,schema:n}=e;if(n.exclusiveMaximum!==void 0)return t.current.attr(G.lt).call(e.utils.maybeBigInt(n.exclusiveMaximum,n.format));if(n.maximum!==void 0)return t.current.attr(G.lte).call(e.utils.maybeBigInt(n.maximum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.max).call(e.utils.maybeBigInt(r.maxValue,n.format),F.object().prop(`message`,F.literal(r.maxError)))}function Fl(e){let{chain:t,schema:n}=e;if(n.exclusiveMinimum!==void 0)return t.current.attr(G.gt).call(e.utils.maybeBigInt(n.exclusiveMinimum,n.format));if(n.minimum!==void 0)return t.current.attr(G.gte).call(e.utils.maybeBigInt(n.minimum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.min).call(e.utils.maybeBigInt(r.minValue,n.format),F.object().prop(`message`,F.literal(r.minError)))}function Il(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.min(e);r&&(e.chain.current=r);let i=e.nodes.max(e);return i&&(e.chain.current=i),e.chain.current}const Ll=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:F,chain:{current:F(i)},nodes:{base:Ml,const:Nl,max:Pl,min:Fl},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:ic,maybeBigInt:Ks,shouldCoerceToBigInt:Gs,state:n}},o=e.config[`~resolvers`]?.number;return o?.(a)??Il(a)};function Rl(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let i=nu({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:l([...r(e.utils.state.path),`additionalProperties`])}});return i.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),i.expression}function zl(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?F(r).attr(G.record).call(i):F(r).attr(G.object).call(a)}function Bl(e){return e.nodes.base(e)}function Vl(e){let{plugin:t,schema:n}=e,i=F.object().pretty();for(let a in n.properties){let o=n.properties[a],s=nu({optional:!n.required?.includes(a),plugin:t,schema:o,state:{...e.utils.state,path:l([...r(e.utils.state.path),`properties`,a])}});s.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),i.prop(a,s.expression)}return i}const Hl=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:F,chain:{current:F(i)},nodes:{additionalProperties:Rl,base:zl,shape:Vl},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??Bl(a),{...r,anyType:`AnyZodObject`}};function Ul(e){let{z:t}=e.symbols;return F(t).attr(G.string).call()}function Wl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return F(r).attr(G.literal).call(F.literal(t.const))}function Gl(e){let{chain:t,plugin:n,schema:r}=e;switch(r.format){case`date`:return t.current.attr(G.date).call();case`date-time`:{let e=F.object().$if(n.config.dates.offset,e=>e.prop(`offset`,F.literal(!0))).$if(n.config.dates.local,e=>e.prop(`local`,F.literal(!0)));return t.current.attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return t.current.attr(G.email).call();case`ipv4`:case`ipv6`:return t.current.attr(G.ip).call();case`time`:return t.current.attr(G.time).call();case`uri`:return t.current.attr(G.url).call();case`uuid`:return t.current.attr(G.uuid).call()}}function Kl(e){let{chain:t,schema:n}=e;if(!(n.minLength===void 0||n.minLength!==n.maxLength))return t.current.attr(G.length).call(F.literal(n.minLength))}function ql(e){let{chain:t,schema:n}=e;if(n.maxLength!==void 0)return t.current.attr(G.max).call(F.literal(n.maxLength))}function Jl(e){let{chain:t,schema:n}=e;if(n.minLength!==void 0)return t.current.attr(G.min).call(F.literal(n.minLength))}function Yl(e){let{chain:t,schema:n}=e;if(n.pattern)return t.current.attr(G.regex).call(F.regexp(n.pattern))}function Xl(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.format(e);r&&(e.chain.current=r);let i=e.nodes.length(e);if(i)e.chain.current=i;else{let t=e.nodes.minLength(e);t&&(e.chain.current=t);let n=e.nodes.maxLength(e);n&&(e.chain.current=n)}let a=e.nodes.pattern(e);return a&&(e.chain.current=a),e.chain.current}const Zl=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:F,chain:{current:F(n)},nodes:{base:Ul,const:Wl,format:Gl,length:Kl,maxLength:ql,minLength:Jl,pattern:Yl},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return i?.(r)??Xl(r)},Ql=({plugin:e,schema:t,state:n})=>{let i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F(i).attr(G.literal).call(F.fromValue(e)));return{expression:F(i).attr(G.tuple).call(F.array(...e)),hasLazyExpression:a}}let o=[];return t.items&&t.items.forEach((t,i)=>{let s=nu({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,i])}});o.push(s.expression),s.hasLazyExpression&&(a=!0)}),{expression:F(i).attr(G.tuple).call(F.array(...o)),hasLazyExpression:a}},$l=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.undefined).call(),eu=({plugin:e})=>F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.void).call(),tu=({schema:e,...t})=>{switch(e.type){case`array`:return Dl({...t,schema:e});case`boolean`:return{expression:Ol({...t,schema:e})};case`enum`:return{expression:kl({...t,schema:e})};case`integer`:case`number`:return{expression:Ll({...t,schema:e})};case`never`:return{expression:Al({...t,schema:e})};case`null`:return{expression:jl({...t,schema:e})};case`object`:return Hl({...t,schema:e});case`string`:return{expression:Gs(e.format)?Ll({...t,schema:{...e,type:`number`}}):Zl({...t,schema:e})};case`tuple`:return Ql({...t,schema:e});case`undefined`:return{expression:$l({...t,schema:e})};case`unknown`:return{expression:El({...t,schema:e})};case`void`:return{expression:eu({...t,schema:e})}}},nu=({optional:e,plugin:t,schema:n,state:i})=>{let a={},o=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},r=t.referenceSymbol(e);t.isSymbolRegistered(e)?a.expression=F(r):(a.expression=F(o).attr(G.lazy).call(F.func().do(F(r).return())),a.hasLazyExpression=!0,i.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=tu({plugin:t,schema:n,state:i});a.expression=e.expression,a.typeName=e.anyType,t.config.metadata&&n.description&&(a.expression=a.expression.attr(G.describe).call(F.literal(n.description)))}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>nu({plugin:t,schema:e,state:{...i,path:l([...r(i.path),`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?a.expression=F(o).attr(G.intersection).call(...e):(a.expression=e[0],e.slice(1).forEach(e=>{a.expression=a.expression.attr(G.and).call(e)}))}else a.expression=F(o).attr(G.union).call(F.array().pretty().elements(...e))}else a=nu({plugin:t,schema:n,state:i});else{let e=tu({plugin:t,schema:{type:`unknown`},state:i});a.expression=e.expression,a.typeName=e.anyType}return a.expression&&(n.accessScope===`read`&&(a.expression=a.expression.attr(G.readonly).call()),e&&(a.expression=a.expression.attr(G.optional).call()),n.default!==void 0&&(a.expression=a.expression.attr(G.default).call(n.type===`integer`||n.type===`number`?Ks(n.default,n.format):F.fromValue(n.default)))),i.hasLazyExpression[`~ref`]?a.typeName||=`ZodTypeAny`:a.typeName&&=void 0,a},ru=({plugin:e,schema:t,state:n})=>{let i=Mi(r(n.path)),a=nu({plugin:e,schema:t,state:n}),o=R(i);Uc({ast:a,plugin:e,schema:t,symbol:e.symbol(L(o,e.config.definitions),{meta:{category:`schema`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(L(o,e.config.definitions.types.infer),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`zod`,variant:`infer`}}):void 0})},iu=({plugin:e})=>{e.symbol(`z`,{external:Wc({plugin:e}),meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=u({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Gc({getAst:(n,r)=>nu({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:ru({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:ru({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:ru({plugin:e,schema:t.schema,state:n});break;case`webhook`:Kc({getAst:(n,r)=>nu({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},au=({plugin:e})=>{let t={};return t.expression=F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.unknown).call(),t},ou=({plugin:e,schema:t,state:n})=>{let i={},a=e.referenceSymbol({category:`external`,resource:`zod.z`}),o=F(a).attr(G.array);if(!t.items)i.expression=o.call(au({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=x({schema:t});let s=t.items.map((t,a)=>{let o=Fu({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,a])}});return o.hasLazyExpression&&(i.hasLazyExpression=!0),o.expression});if(s.length===1)i.expression=o.call(...s);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=F(a).attr(G.intersection).call(...s);else{n=s[0];for(let e=1;e<s.length;e++)n=n.attr(G.and).call(s[e])}i.expression=o.call(n)}else i.expression=F(a).attr(G.array).call(F(a).attr(G.union).call(F.array(...s)))}return t.minItems===t.maxItems&&t.minItems!==void 0?i.expression=i.expression.attr(G.length).call(F.fromValue(t.minItems)):(t.minItems!==void 0&&(i.expression=i.expression.attr(G.min).call(F.fromValue(t.minItems))),t.maxItems!==void 0&&(i.expression=i.expression.attr(G.max).call(F.fromValue(t.maxItems)))),i},su=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=F(i).attr(G.literal).call(F.literal(t.const)),n.expression=r,n):(r=F(i).attr(G.boolean).call(),n.expression=r,n)},cu=({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=F.literal(e.const);a.push(t),o.push(F(i).attr(G.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=F.literal(e.const);o.push(F(i).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=F.literal(e.const);o.push(F(i).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=F(i).attr(G.enum).call(F.array(...a)):o.length===1?r.expression=o[0]:r.expression=F(i).attr(G.union).call(F.array(...o)),s&&(r.expression=F(i).attr(G.nullable).call(r.expression)),r):au({plugin:e,schema:{type:`unknown`},state:n})},lu=({plugin:e})=>{let t={};return t.expression=F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.never).call(),t},uu=({plugin:e})=>{let t={};return t.expression=F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.null).call(),t};function du(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return F(r).attr(G.coerce).attr(G.bigint).call();let i=F(r).attr(G.number).call();return t.type===`integer`&&(i=F(r).attr(G.int).call()),i}function fu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return F(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function pu(e){let{chain:t,schema:n}=e;if(n.exclusiveMaximum!==void 0)return t.current.attr(G.lt).call(e.utils.maybeBigInt(n.exclusiveMaximum,n.format));if(n.maximum!==void 0)return t.current.attr(G.lte).call(e.utils.maybeBigInt(n.maximum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.max).call(e.utils.maybeBigInt(r.maxValue,n.format),F.object().prop(`error`,F.literal(r.maxError)))}function mu(e){let{chain:t,schema:n}=e;if(n.exclusiveMinimum!==void 0)return t.current.attr(G.gt).call(e.utils.maybeBigInt(n.exclusiveMinimum,n.format));if(n.minimum!==void 0)return t.current.attr(G.gte).call(e.utils.maybeBigInt(n.minimum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.min).call(e.utils.maybeBigInt(r.minValue,n.format),F.object().prop(`error`,F.literal(r.minError)))}function hu(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.min(e);r&&(e.chain.current=r);let i=e.nodes.max(e);return i&&(e.chain.current=i),e.chain.current}const gu=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:F,chain:{current:F(i)},nodes:{base:du,const:fu,max:pu,min:mu},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:ic,maybeBigInt:Ks,shouldCoerceToBigInt:Gs,state:n}},o=e.config[`~resolvers`]?.number;return r.expression=o?.(a)??hu(a),r};function _u(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let i=Fu({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:l([...r(e.utils.state.path),`additionalProperties`])}});return i.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),i.expression}function vu(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?F(r).attr(G.record).call(F(r).attr(G.string).call(),i):F(r).attr(G.object).call(a)}function yu(e){return e.nodes.base(e)}function bu(e){let{plugin:t,schema:n}=e,i=F.object().pretty();for(let a in n.properties){let o=n.properties[a],s=Fu({optional:!n.required?.includes(a),plugin:t,schema:o,state:{...e.utils.state,path:l([...r(e.utils.state.path),`properties`,a])}});s.hasLazyExpression?(e.utils.ast.hasLazyExpression=!0,i.getter(a,s.expression.return())):i.prop(a,s.expression)}return i}const xu=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:F,chain:{current:F(i)},nodes:{additionalProperties:_u,base:vu,shape:bu},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??yu(a),r};function Su(e){let{z:t}=e.symbols;return F(t).attr(G.string).call()}function Cu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return F(r).attr(G.literal).call(F.literal(t.const))}function wu(e){let{plugin:t,schema:n,symbols:r}=e,{z:i}=r;switch(n.format){case`date`:return F(i).attr(G.iso).attr(G.date).call();case`date-time`:{let e=F.object().$if(t.config.dates.offset,e=>e.prop(`offset`,F.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,F.literal(!0)));return F(i).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return F(i).attr(G.email).call();case`ipv4`:return F(i).attr(G.ipv4).call();case`ipv6`:return F(i).attr(G.ipv6).call();case`time`:return F(i).attr(G.iso).attr(G.time).call();case`uri`:return F(i).attr(G.url).call();case`uuid`:return F(i).attr(G.uuid).call()}}function Tu(e){let{chain:t,schema:n}=e;if(!(n.minLength===void 0||n.minLength!==n.maxLength))return t.current.attr(G.length).call(F.literal(n.minLength))}function Eu(e){let{chain:t,schema:n}=e;if(n.maxLength!==void 0)return t.current.attr(G.max).call(F.literal(n.maxLength))}function Du(e){let{chain:t,schema:n}=e;if(n.minLength!==void 0)return t.current.attr(G.min).call(F.literal(n.minLength))}function Ou(e){let{chain:t,schema:n}=e;if(n.pattern)return t.current.attr(G.regex).call(F.regexp(n.pattern))}function ku(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.format(e);r&&(e.chain.current=r);let i=e.nodes.length(e);if(i)e.chain.current=i;else{let t=e.nodes.minLength(e);t&&(e.chain.current=t);let n=e.nodes.maxLength(e);n&&(e.chain.current=n)}let a=e.nodes.pattern(e);return a&&(e.chain.current=a),e.chain.current}const Au=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:F,chain:{current:F(n)},nodes:{base:Su,const:Cu,format:wu,length:Tu,maxLength:Eu,minLength:Du,pattern:Ou},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return{expression:i?.(r)??ku(r)}},ju=({plugin:e,schema:t,state:n})=>{let i={},a=e.referenceSymbol({category:`external`,resource:`zod.z`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F(a).attr(G.literal).call(F.fromValue(e)));return i.expression=F(a).attr(G.tuple).call(F.array(...e)),i}let o=[];return t.items&&t.items.forEach((t,a)=>{let s=Fu({plugin:e,schema:t,state:{...n,path:l([...r(n.path),`items`,a])}});o.push(s.expression),s.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=F(a).attr(G.tuple).call(F.array(...o)),i},Mu=({plugin:e})=>{let t={};return t.expression=F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.undefined).call(),t},Nu=({plugin:e})=>{let t={};return t.expression=F(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.void).call(),t},Pu=({schema:e,...t})=>{switch(e.type){case`array`:return ou({...t,schema:e});case`boolean`:return su({...t,schema:e});case`enum`:return cu({...t,schema:e});case`integer`:case`number`:return gu({...t,schema:e});case`never`:return lu({...t,schema:e});case`null`:return uu({...t,schema:e});case`object`:return xu({...t,schema:e});case`string`:return Gs(e.format)?gu({...t,schema:{...e,type:`number`}}):Au({...t,schema:e});case`tuple`:return ju({...t,schema:e});case`undefined`:return Mu({...t,schema:e});case`unknown`:return au({...t,schema:e});case`void`:return Nu({...t,schema:e})}},Fu=({optional:e,plugin:t,schema:n,state:i})=>{let a={},o=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},r=t.referenceSymbol(e);t.isSymbolRegistered(e)?a.expression=F(r):(a.expression=F(o).attr(G.lazy).call(F.func().returns(`any`).do(F(r).return())),a.hasLazyExpression=!0,i.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=Pu({plugin:t,schema:n,state:i});a.expression=e.expression,a.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(a.expression=a.expression.attr(G.register).call(F(o).attr(G.globalRegistry),F.object().pretty().prop(`description`,F.literal(n.description))))}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>Fu({plugin:t,schema:e,state:{...i,path:l([...r(i.path),`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?a.expression=F(o).attr(G.intersection).call(...e.map(e=>e.expression)):(a.expression=e[0].expression,e.slice(1).forEach(e=>{a.expression=a.expression.attr(G.and).call(e.hasLazyExpression?F(o).attr(G.lazy).call(F.func().do(e.expression.return())):e.expression)}))}else a.expression=F(o).attr(G.union).call(F.array().pretty().elements(...e.map(e=>e.expression)))}else a=Fu({plugin:t,schema:n,state:i});else{let e=Pu({plugin:t,schema:{type:`unknown`},state:i});a.expression=e.expression}return a.expression&&(n.accessScope===`read`&&(a.expression=a.expression.attr(G.readonly).call()),e&&(a.expression=F(o).attr(G.optional).call(a.expression),a.typeName=G.ZodOptional),n.default!==void 0&&(a.expression=a.expression.attr(G.default).call(n.type===`integer`||n.type===`number`?Ks(n.default,n.format):F.fromValue(n.default)))),a},Iu=({plugin:e,schema:t,state:n})=>{let i=Mi(r(n.path)),a=Fu({plugin:e,schema:t,state:n}),o=R(i);Uc({ast:a,plugin:e,schema:t,symbol:e.symbol(L(o,e.config.definitions),{meta:{category:`schema`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(L(o,e.config.definitions.types.infer),{meta:{category:`type`,path:r(n.path),resource:`definition`,resourceId:i,tags:r(n.tags),tool:`zod`,variant:`infer`}}):void 0})},Lu=({plugin:e})=>{e.symbol(`z`,{external:Wc({plugin:e}),meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=u({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Gc({getAst:(n,r)=>Fu({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Iu({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Iu({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Iu({plugin:e,schema:t.schema,state:n});break;case`webhook`:Kc({getAst:(n,r)=>Fu({plugin:e,schema:n,state:u({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Ru={api:new Hc,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return iu(e);case`mini`:return Tl(e);case 4:default:return Lu(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(`🔌 ${d.yellow(`Warning:`)} Installed ${d.cyan(`zod`)} ${d.cyan(`v${n.version}`)} does not support compatibility version ${d.yellow(String(e))}, using ${d.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:_,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:{..._,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:_,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:{..._,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:_,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:{..._,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:_,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:{..._,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:_,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},zu={"@angular/common":ga,"@hey-api/client-angular":Ma,"@hey-api/client-axios":Na,"@hey-api/client-fetch":Pa,"@hey-api/client-ky":Fa,"@hey-api/client-next":Ia,"@hey-api/client-nuxt":La,"@hey-api/client-ofetch":Ra,"@hey-api/schemas":Ya,"@hey-api/sdk":ro,"@hey-api/transformers":fo,"@hey-api/typescript":Lo,"@pinia/colada":$o,"@tanstack/angular-query-experimental":vs,"@tanstack/react-query":ys,"@tanstack/solid-query":bs,"@tanstack/svelte-query":xs,"@tanstack/vue-query":Ss,arktype:Ps,fastify:Is,swr:zs,valibot:Mc,zod:Ru},Bu=[`@hey-api/typescript`,`@hey-api/sdk`],Vu=({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=zu[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:Ba(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=zu[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=zu[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:g};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}},Hu=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),Uu=({dependencies:e,userConfig:t})=>{let n={},r=Bu;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Hu(t.plugins[0])?[...Bu,...t.plugins]:t.plugins),Vu({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})},Wu=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Gu=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 a=e.timeEvent(`c12`),{loadConfig:o}=await import(`c12`),{config:s,configFile:c}=await o({configFile:t,name:`openapi-ts`});a.timeEnd(),Object.keys(r).length||(r=Ke(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>He(e,i)):[He(s,i)];for(let e of l){let t=ze(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${d.yellow(`Warning:`)} You provided ${d.cyan(String(r))} ${d.cyan(r===1?`input`:`inputs`)} and ${d.yellow(String(i))} ${d.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 a=[],o=e.timeEvent(`build`);for(let e of n){let t=Be(e),n=ze(e),i=Ge(e),o=Je(e),s=[];n.length||s.push(new pe(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||s.push(new pe(`missing output - where should we generate your output?`)),i.path=p.resolve(process.cwd(),i.path);let c;try{c=Uu({dependencies:r,userConfig:e})}catch(e){s.push(e),c={pluginOrder:[],plugins:{}}}let l={configFile:e.configFile??``,dryRun:e.dryRun??!1,input:n,interactive:e.interactive??Wu(),logs:t,output:i,parser:o,pluginOrder:c.pluginOrder,plugins:c.plugins},u=a.length;if(t.level===`debug`){let e=d.gray(`[Job ${u+1}] `);console.warn(`${e}${d.cyan(`config:`)}`,l)}a.push({config:l,errors:s,jobIndex:u})}return o.timeEnd(),{dependencies:r,results:a}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Ku=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},qu=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Ju=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Yu=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(qu(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Ku(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Xu({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Xu=({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)}`},Zu=({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=Ju(r),s=Object.entries(i).map(([t,i])=>Xu({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Qu=({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=Yu({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Zu({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Xu({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},$u=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},ed=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?$u(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};Qu({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const td=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=ne({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await re({fetchOptions:{method:`HEAD`,...e,headers:ed(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 re({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}};var nd=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 rd=(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))},id=(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 nd(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))},ad=(e,t,n)=>n?.order===`topological`?id(e,t,n):rd(e,t,n),od=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],sd=(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}},cd=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],ld=(()=>{let e={};for(let t=0;t<cd.length;t++){let n=cd[t];n&&(e[n]=t)}for(let t of od)e[t]===void 0&&(e[t]=cd.length);return e})(),ud=e=>{let t=sd(e);return t.matched?ld[t.kind]??10:10},dd=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},fd=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var pd=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}external(e,t){return this.gen.symbols.reference({...t,category:`external`,resource:e})}forEach(...e){if(!this.context.graph)throw Error(`No graph available in context`);let t,n,r={getPointerPriority:ud,matchPointerToGroup:sd,order:`topological`,preferGroups:cd};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:od);ad(this.context.graph,(e,n)=>{let r=sd(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:Ai(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)}node(e,t){for(let t of this.eventHooks[`node:set:before`])t({node:e,plugin:this});let n=t===void 0?this.gen.nodes.add(e):this.gen.nodes.update(t,e);for(let t of this.eventHooks[`node:set:after`])t({node:e,plugin:this});return n}querySymbol(e){return this.gen.symbols.query(e)[0]}referenceSymbol(e){return this.gen.symbols.reference(e)}registerSymbol(e){return this.symbol(e.name,e)}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})}symbol(e,t){let n={...t,exportFrom:t?.exportFrom??(!t?.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?[`index`]:void 0),getFilePath:t?.getFilePath??this.getSymbolFilePath.bind(this),meta:{pluginName:p.isAbsolute(this.name)?`custom`:this.name,...t?.meta},name:e};for(let e of this.eventHooks[`symbol:register:before`])e({plugin:this,symbol:n});let r=this.gen.symbols.register(n);for(let e of this.eventHooks[`symbol:register:after`])e({plugin:this,symbol:r});return r}symbolOnce(e,t){let n={...t?.meta};return t?.external&&(n.category=`external`,n.resource=t.external),this.querySymbol(n)||this.symbol(e,{...t,meta:n})}buildEventHooks(){let e={"node:set:after":[],"node:set:before":[],"plugin:handler:after":[],"plugin:handler:before":[],"symbol:register:after":[],"symbol:register: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 ge({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 dd(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,fd];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}},md=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=L(t,e.output.fileName),{suffix:r}=e.output.fileName;return r?n===`index`||n.endsWith(r)?n:`${n}${r}`:n},nameConflictResolvers:e.output.nameConflictResolver?{typescript:e.output.nameConflictResolver}:void 0,renderers:[new ui({header:e.output.header,preferExportAll:e.output.preferExportAll,preferFileExtension:e.output.importFileExtension||void 0,resolveModuleName:e.output.resolveModuleName})],root:e.output.path}),this.logger=r,this.package=Ba(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 pd({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 Ni({$ref:e,spec:this.ir})}resolveRef(e){return Ni({$ref:e,spec:this.spec})}};const hd=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],gd=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),_d=({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.operations&&typeof e.config.plugins[`@hey-api/sdk`].config.operations!=`function`&&typeof e.config.plugins[`@hey-api/sdk`].config.operations==`object`&&e.config.plugins[`@hey-api/sdk`].config.operations.nesting===`operationId`)?I(gd(n),c):I(`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`,c),t>1&&(o=`${o}${t}`),a.ids.has(o)?_d({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,C({method:r,path:i})),o)},K=(e,t=``)=>`${e}/${t}`,q=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},vd=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},J=(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(K(e,i));return{regexps:r,set:new Set(n)}},yd=({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 hd){if(!i[t])continue;let a=C({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(K(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(K(`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(K(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(K(`schema`,e))},bd=({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 hd){if(!r[t])continue;let i=C({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(K(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(K(`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(K(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(K(`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(K(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(K(`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(K(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(K(`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(K(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(K(`schema`,e))}},xd=({spec:e,...t})=>{`swagger`in e?yd({...t,spec:e}):bd({...t,spec:e})},Sd=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=J(`operation`,e?.operations?.exclude),a=J(`operation`,e?.operations?.include),o=J(`parameter`,e?.parameters?.exclude),s=J(`parameter`,e?.parameters?.include),c=J(`body`,e?.requestBodies?.exclude),l=J(`body`,e?.requestBodies?.include),u=J(`response`,e?.responses?.exclude),d=J(`response`,e?.responses?.include),f=J(`schema`,e?.schemas?.exclude),p=J(`schema`,e?.schemas?.include);xd({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},Cd=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,wd=({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}=q(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}},Td=({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}=q(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}},Ed=({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}=q(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}},Dd=({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}=q(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}},Od=({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}=q(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},kd=({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}}}},Ad=({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}}}},jd=({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}}}},Md=({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}}}},Nd=({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)},Pd=({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}=q(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}},Fd=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Od({filters:e,resourceMetadata:n}),{parameters:a}=Td({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Ed({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Dd({filters:e,resourceMetadata:n,schemas:i});Md({filters:e,resourceMetadata:n,schemas:i}),kd({filters:e,parameters:a,resourceMetadata:n}),Ad({filters:e,requestBodies:o,resourceMetadata:n}),jd({filters:e,resourceMetadata:n,responses:s});let{operations:c}=wd({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Pd({operations:c,resourceMetadata:n});Nd({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Id=(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=Ai(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=vd(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(K(e,i))}}return n};for(let[t,n]of e.nodes){let e=Ai(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(K(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(K(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(K(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(K(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&hd.includes(e[2])){let a=e[e.length-1],o=C({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(K(`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(K(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},Ld=e=>JSON.parse(JSON.stringify(e)),Rd=[[`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`]],zd=e=>{if(Bd(e))return e.components.schemas;if(Vd(e))return e.definitions},Bd=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,Vd=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Hd=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Ud=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Hd(t,i)||n&&Hd(n,i);)i=`${e}${r}`,r+=1;return i},Wd=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,Gd=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},Kd=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})},qd=({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||Rd.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)=>qd({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):qd({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Jd=({spec:e})=>{let t=zd(e);if(!t)return;let n=Gd(e),r={};for(let[e,i]of Object.entries(t))Kd(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,Ld(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=Ai(e),r=n[n.length-1];r&&delete t[r]}},Yd=({config:e,spec:t})=>{let n=zd(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Kd(t);n&&(r[n]=e)}let i=[];qd({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Wd(e.path)){let t=Kd(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]=Ud({base:L(typeof s==`object`&&s&&`title`in s&&typeof s.title==`string`?s.title:String(t),e),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=Gd(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}`})}},Xd=({config:e,spec:t})=>{if(e.mode===`inline`){Jd({spec:t});return}if(e.mode===`root`){Yd({config:e,spec:t});return}},Zd=({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||Rd.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)=>Zd({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Zd({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Qd=({spec:e})=>{Zd({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)}}})},$d=(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(!$d(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(!$d(r[e],i[e]))return!1;return!0};var ef=$d;const tf=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))}},nf=({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=nf({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=nf({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}},rf=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&&af(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 Rd){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&&af(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&af(a,t)&&n(a.parentPointer,t)}}},af=(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},of=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`])))}},sf=(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=Mi(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=ji(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);of(r.nodes),rf(r),tf(r.nodes);for(let e of r.nodes.keys()){let t=nf({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}},cf=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),lf=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`}},uf=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Bd(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(Vd(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},df=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Bd(t)?Object.assign(t.components.schemas,n.schemas):Vd(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},ff=(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,!Rd.some(([e])=>e in t)))return!0}for(let[r,i]of Rd){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||ff(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||ff(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||ff(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||ff(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||ff(e,a,n))&&delete t[r]}if(t.type===`object`&&!Rd.some(([e])=>e in t))return!0}return!1},pf=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=zd(n);for(let e of Object.keys(r.mapping)){let n=Ai(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()},mf=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=Gd(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=Ai(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=Ld(r.node);ff(t,c,`writeOnly`);let u=L(i,e.responses),d=u===i?u:Ud({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Ld(r.node);ff(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`))})&&ef(c,p)&&ef(c,r.node))continue;let h=L(i,e.requests),ee=h===i&&h!==d?h:Ud({base:h,components:a});a.add(ee),o.schemas[ee]=p;let te=`${s}${ee}`;o.mapping[n]={read:f,write:te},o.reverseMapping[f]=n,o.reverseMapping[te]=n}return i.timeEnd(),o},hf=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=Gd(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(Wd(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=lf(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(cf.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()},gf=({config:e,logger:t,spec:n})=>{let{graph:r}=sf(n,t),i=uf(n,t),a=mf({config:e,graph:r,logger:t,spec:n});df({logger:t,spec:n,split:a}),hf({logger:t,spec:n,split:a}),pf({logger:t,originalSchemas:i,spec:n,split:a})},_f=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&Xd({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Qd({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&gf({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},Y=({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},vf=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),yf=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:vf(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),bf=e=>{let t=yf(e.path),n=e.severity===`error`?d.bold.red:d.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>d.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${d.cyan(t)}: ${r}`},xf=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,Sf=({context:e,result:t})=>{for(let n of t.issues)xf({context:e,issue:n})&&console.log(bf(n));t.valid||process.exit(1)},Cf=({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(K(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=q(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 hd){if(!r[e])continue;let i=K(`operation`,C({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},wf=/^(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,Tf=/^application\/(.*\+)?json(;.*)?$/i,Ef=/^multipart\/form-data(;.*)?$/i,Df=/^text\/[a-z0-9.+-]+(;.*)?$/i,Of=/^application\/x-www-form-urlencoded(;.*)?$/i,kf=/^application\/octet-stream(;.*)?$/i,Af=({mediaType:e})=>(wf.lastIndex=0,wf.test(e)),jf=({mediaType:e})=>{if(Tf.lastIndex=0,Tf.test(e))return`json`;if(Ef.lastIndex=0,Ef.test(e))return`form-data`;if(Df.lastIndex=0,Df.test(e))return`text`;if(Of.lastIndex=0,Of.test(e))return`url-search-params`;if(kf.lastIndex=0,kf.test(e))return`octet-stream`},Mf=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Af({mediaType:t})?{...n,format:`binary`}:n:Af({mediaType:t})?{format:`binary`,type:`string`}:void 0},Nf=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:jf({mediaType:r})});return n};function Pf(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Ff=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[R(e)]:r},If=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Lf=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Rf=({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`)},zf=({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=X({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=S({items:i,schema:t}),t},Bf=({irSchema:e={}})=>(e.type=`boolean`,e),Vf=({irSchema:e={},schema:t})=>(e.type=t.type,e),Hf=({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]=X({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=X({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Uf=({irSchema:e={}})=>(e.type=`string`,e),Wf=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},Gf=({schema:e})=>{let t={};return Lf({irSchema:t,schema:e}),Wf({source:e,target:t}),t},Kf=({context:e,schema:t,state:n})=>{let r=Gf({schema:t}),i=[],a=If({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=X({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=Ff(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=Zf({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(If({schema:a})===`object`){let i=Zf({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=S({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},qf=({context:e,schema:t,state:n})=>{let r=Gf({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=Zf({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=S({items:i,schema:r}),r},Jf=({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=X({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,X({context:e,schema:r,state:n}),n.$ref=i}return r},Yf=({context:e,irSchema:t,schema:n,state:r})=>{t||=Gf({schema:n});let i={};return Rf({irSchema:i,schema:n}),i.default===null&&delete i.default,t=S({items:[Zf({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Xf=({context:e,schema:t,state:n})=>{let r=Gf({schema:t});Rf({irSchema:r,schema:t});let i=If({schema:t});return i?t[`x-nullable`]?Yf({context:e,irSchema:r,schema:{...t,type:i},state:n}):Zf({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Zf=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Gf({schema:n}),Rf({irSchema:t,schema:n})),n.type){case`array`:return zf({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Bf({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Vf({context:e,irSchema:t,schema:n,state:r});case`object`:return Hf({context:e,irSchema:t,schema:n,state:r});case`string`:return Uf({context:e,irSchema:t,schema:n,state:r});default:return Qf({context:e,irSchema:t,schema:n})}},Qf=({irSchema:e,schema:t})=>(e||=Gf({schema:t}),e.type=`unknown`,Rf({irSchema:e,schema:t}),e),X=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Jf({context:e,schema:t,state:n}):t.enum?qf({context:e,schema:t,state:n}):t.allOf?Kf({context:e,schema:t,state:n}):t.type||t.properties?Xf({context:e,schema:t,state:n}):Qf({context:e,schema:t})),$f=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[R(e)]=X({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},ep=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,tp=({context:e,name:t,schema:n})=>{if(Pf(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?tp({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):tp({context:e,name:t,schema:r})}if(`in`in n)return n.in?tp({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(Pf(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&ep(If({schema:e})))return t}for(let r of n.allOf??[]){let n=tp({context:e,name:t,schema:r});if(n)return n}return!1},np=({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)},rp=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:_d({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),np({irOperation:a,operation:n}),Wf({source:n,target:a}),a},ip=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=rp({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=Nf({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=tp({context:e,name:``,schema:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema}}),n=X({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=Nf({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:X({context:e,schema:{description:i.description,...Mf({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},ap=({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]=ip({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},op=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},sp=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},cp=({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()]=lp({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},lp=({$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=tp({context:t,name:n.name,schema:i}),o=sp(n.in),s={allowReserved:!1,explode:op(n.collectionFormat),location:n.in,name:n.name,schema:X({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),Wf({source:n,target:s}),s},up=({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=Da(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})))},dp=(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 hd){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=C({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`)}},fp=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Sf({context:e,result:dp(e.spec,e.logger)}),Cd(e.config.parser.filters)){let t=Sd(e.config.parser.filters,e.spec,e.logger),{graph:n}=sf(e.spec,e.logger),{resourceMetadata:r}=Id(n,e.logger);Cf({...Fd({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}_f({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];$f({$ref:n,context:e,schema:r})}for(let r in up({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:cp({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=Y({source:cp({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});ap({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=Y({source:cp({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});ap({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=Y({source:cp({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});ap({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=Y({source:cp({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});ap({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=Y({source:cp({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});ap({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=Y({source:cp({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});ap({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=Y({source:cp({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});ap({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},pp=({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(K(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=q(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(K(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=q(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(K(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=q(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(K(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=q(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 hd){if(!r[e])continue;let i=K(`operation`,C({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},mp=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Af({mediaType:t})?{...n,format:`binary`}:n:Af({mediaType:t})?{format:`binary`,type:`string`}:void 0},hp=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:jf({mediaType:n})});return t},gp=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},_p=({context:e,discriminators:t=[],schema:n})=>{if(n.discriminator&&t.push({discriminator:n.discriminator,oneOf:n.oneOf}),n.allOf)for(let r of n.allOf){let n;n=`$ref`in r?e.resolveRef(r.$ref):r,_p({context:e,discriminators:t,schema:n})}return t},vp=({discriminator:e,schemaRef:t})=>{let n=[];for(let[r,i]of Object.entries(e.mapping||{}))i===t&&n.push(r);return n},yp=({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)},bp=({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`)},xp=({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=S({items:i,schema:t}),t},Sp=({irSchema:e={}})=>(e.type=`boolean`,e),Cp=({irSchema:e={},schema:t})=>(e.type=t.type,e),wp=({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},Tp=({irSchema:e={}})=>(e.type=`string`,e),Ep=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},Dp=({schema:e})=>{let t={};return yp({irSchema:t,schema:e}),Ep({source:e,target:t}),t},Op=({context:e,schema:t,state:n})=>{let r=Dp({schema:t}),i=[],a=gp({schema:t}),o=t.allOf,s=[],c=new Set;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(n.$ref){let r=_p({context:e,schema:t});for(let{discriminator:i,oneOf:a}of r){if(c.has(i.propertyName))continue;let o=Ff(n.$ref,i.mapping,a?()=>a.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(o.length>0){let n=r.some(n=>n.discriminator.propertyName===i.propertyName&&(t.required?.includes(n.discriminator.propertyName)||t.allOf&&t.allOf.some(t=>(`$ref`in t?e.resolveRef(t.$ref):t).required?.includes(n.discriminator.propertyName))));s.push({discriminator:i,isRequired:n,values:o}),c.add(i.propertyName)}}}}}for(let{discriminator:t,isRequired:r,values:a}of s){let o=vp({discriminator:t,schemaRef:n.$ref}),s=(o.length>0?o:a).map(e=>({const:e,type:`string`})),c=s.length>1?{items:s,logicalOperator:`or`}:s[0];for(let n of i)(n.$ref||n.symbolRef)&&(()=>{if(!n.$ref)return!1;try{let r=e.resolveRef(n.$ref);return r.properties?.[t.propertyName]!==void 0||r.allOf&&r.allOf.some(n=>(`$ref`in n?e.resolveRef(n.$ref):n).properties?.[t.propertyName]!==void 0)}catch{return!1}})()&&(n.omit?n.omit.includes(t.propertyName)||(n.omit=[...n.omit,t.propertyName]):n.omit=[t.propertyName]);let l;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.type===`object`||t.properties){l=t;break}}if(l)l.properties||={},l.properties[t.propertyName]=c,r&&(l.required||=[],l.required.includes(t.propertyName)||(l.required=[...l.required,t.propertyName]));else{let e={properties:{[t.propertyName]:c},type:`object`};r&&(e.required=[t.propertyName]),i.push(e)}}if(a===`object`){let r=Fp({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(gp({schema:a})===`object`){let i=Fp({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=S({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},kp=({context:e,schema:t,state:n})=>{let r=Dp({schema:t}),i=[],a=gp({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=Ff(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Fp({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Ap=({context:e,schema:t,state:n})=>{let r=Dp({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=Fp({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=S({items:i,schema:r}),r},jp=({context:e,schema:t,state:n})=>{let r=Dp({schema:t}),i=[],a=gp({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=Ff(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Fp({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Mp=({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},Np=({context:e,irSchema:t,schema:n,state:r})=>{t||=Dp({schema:n});let i={};return bp({irSchema:i,schema:n}),i.default===null&&delete i.default,t=S({items:[Fp({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Pp=({context:e,schema:t,state:n})=>{let r=Dp({schema:t});bp({irSchema:r,schema:t});let i=gp({schema:t});return i?t.nullable?Np({context:e,irSchema:r,schema:{...t,type:i},state:n}):Fp({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Fp=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Dp({schema:n}),bp({irSchema:t,schema:n})),n.type){case`array`:return xp({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Sp({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Cp({context:e,irSchema:t,schema:n,state:r});case`object`:return wp({context:e,irSchema:t,schema:n,state:r});case`string`:return Tp({context:e,irSchema:t,schema:n,state:r});default:return Ip({context:e,irSchema:t,schema:n})}},Ip=({irSchema:e,schema:t})=>(e||=Dp({schema:t}),e.type=`unknown`,bp({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?Mp({context:e,schema:t,state:n}):t.enum?Ap({context:e,schema:t,state:n}):t.allOf?Op({context:e,schema:t,state:n}):t.anyOf?kp({context:e,schema:t,state:n}):t.oneOf?jp({context:e,schema:t,state:n}):t.type||t.properties?Pp({context:e,schema:t,state:n}):Ip({context:e,schema:t})),Lp=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[R(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Rp=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,zp=({context:e,name:t,schema:n})=>{if(Pf(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=hp({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?zp({context:e,name:t,schema:n}):!1}return zp({context:e,name:t,schema:r})}for(let t in n.properties)if(Pf(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Rp(gp({schema:e})))return t}for(let r of n.allOf??[]){let n=zp({context:e,name:t,schema:r});if(n)return n}return!1},Bp=({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)},Vp=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:_d({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Bp({irOperation:a,operation:n}),Ep({source:n,target:a}),a},Hp=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Vp({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=hp({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=zp({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){if(t.startsWith(`x-`))continue;o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=hp({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,...mp({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},Up=({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]=Hp({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Wp=e=>{switch(e){case`query`:return!1;default:return}},Gp=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Kp=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},qp=({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()]=Jp({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Jp=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=hp({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=zp({context:t,name:n.name,schema:i}),o=n.style||Kp(n.in),s=n.explode===void 0?Gp(o):n.explode,c={allowReserved:n.allowReserved===void 0?Wp(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),Ep({source:n,target:c}),c},Yp=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[R(e)]=Jp({$ref:e,context:t,parameter:n})},Xp=({$ref:e,context:t,requestBody:n})=>{let r=hp({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},Zp=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[R(e)]=Xp({$ref:e,context:t,requestBody:n})},Qp=({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=Da(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},$p=(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 hd){let a=n[t];if(!a)continue;let o=C({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`)}},em=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Sf({context:e,result:$p(e.spec,e.logger)}),Cd(e.config.parser.filters)){let t=Sd(e.config.parser.filters,e.spec,e.logger),{graph:n}=sf(e.spec,e.logger),{resourceMetadata:r}=Id(n,e.logger);pp({...Fd({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}_f({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];Yp({$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];Zp({$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];Lp({$ref:n,context:e,schema:r})}}for(let r in Qp({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={context:e,operation:{description:a.description,parameters:qp({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Up({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:qp({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Up({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:qp({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Up({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:qp({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Up({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:qp({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Up({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:qp({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Up({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:qp({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Up({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:qp({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Up({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:qp({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},tm=({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(K(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=q(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(K(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=q(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(K(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=q(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(K(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=q(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 hd){if(!r[e])continue;let i=K(`operation`,C({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},nm=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&Af({mediaType:t})?{...n,format:`binary`}:n:Af({mediaType:t})?{format:`binary`,type:`string`}:void 0},rm=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:jf({mediaType:n})});return t},im=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],am=({context:e,discriminators:t=[],schema:n})=>{if(n.discriminator&&t.push({discriminator:n.discriminator,oneOf:n.oneOf}),n.allOf)for(let r of n.allOf){let n;n=r.$ref?e.resolveRef(r.$ref):r,am({context:e,discriminators:t,schema:n})}return t},om=({discriminator:e,schemaRef:t})=>{let n=[];for(let[r,i]of Object.entries(e.mapping||{}))i===t&&n.push(r);return n},sm=({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)},cm=({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`)},lm=({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&&!im({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=S({items:i,schema:t}),t},um=({irSchema:e={}})=>(e.type=`boolean`,e),dm=({irSchema:e={}})=>(e.type=`null`,e),fm=({irSchema:e={},schema:t})=>(e.type=t.type,e),pm=({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},mm=({irSchema:e={}})=>(e.type=`string`,e),hm=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},gm=({schema:e})=>{let t={};return sm({irSchema:t,schema:e}),hm({source:e,target:t}),t},_m=({context:e,schema:t,state:n})=>{let r=gm({schema:t});cm({irSchema:r,schema:t});let i=[],a=im({schema:t}),o=t.allOf,s=[],c=new Set;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(n.$ref){let r=am({context:e,schema:t});for(let{discriminator:i,oneOf:a}of r){if(c.has(i.propertyName))continue;let o=Ff(n.$ref,i.mapping,a?()=>a.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(o.length>0){let n=r.some(n=>n.discriminator.propertyName===i.propertyName&&(t.required?.includes(n.discriminator.propertyName)||t.allOf&&t.allOf.some(t=>(t.$ref?e.resolveRef(t.$ref):t).required?.includes(n.discriminator.propertyName))));s.push({discriminator:i,isRequired:n,values:o}),c.add(i.propertyName)}}}}}for(let{discriminator:t,isRequired:r,values:a}of s){let o=om({discriminator:t,schemaRef:n.$ref}),s=(o.length>0?o:a).map(e=>({const:e,type:`string`})),c=s.length>1?{items:s,logicalOperator:`or`}:s[0];for(let n of i)(n.$ref||n.symbolRef)&&(()=>{if(!n.$ref)return!1;try{let r=e.resolveRef(n.$ref);return r.properties?.[t.propertyName]!==void 0||r.allOf&&r.allOf.some(n=>(n.$ref?e.resolveRef(n.$ref):n).properties?.[t.propertyName]!==void 0)}catch{return!1}})()&&(n.omit?n.omit.includes(t.propertyName)||(n.omit=[...n.omit,t.propertyName]):n.omit=[t.propertyName]);let l;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.type===`object`||t.properties){l=t;break}}if(l)l.properties||={},l.properties[t.propertyName]=c,r&&(l.required||=[],l.required.includes(t.propertyName)||(l.required=[...l.required,t.propertyName]));else{let e={properties:{[t.propertyName]:c},type:`object`};r&&(e.required=[t.propertyName]),i.push(e)}}if(a.includes(`object`)){let r=Sm({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(im({schema:a}).includes(`object`)){let i=Sm({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=S({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},vm=({context:e,schema:t,state:n})=>{let r=gm({schema:t});cm({irSchema:r,schema:t});let i=[],a=im({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=Ff(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Sm({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},ym=({context:e,schema:t,state:n})=>{let r=gm({schema:t});r.type=`enum`;let i=[],a=im({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=Sm({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=S({items:i,schema:r}),r},bm=({context:e,schema:t,state:n})=>{let r=gm({schema:t});cm({irSchema:r,schema:t});let i=[],a=im({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=Ff(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Sm({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},xm=({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=gm({schema:t});cm({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=S({items:a,mutateSchemaOneItem:!0,schema:r}),r},Sm=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=gm({schema:n}),cm({irSchema:t,schema:n})),n.type){case`array`:return lm({context:e,irSchema:t,schema:n,state:r});case`boolean`:return um({context:e,irSchema:t,schema:n});case`integer`:case`number`:return fm({context:e,irSchema:t,schema:n});case`null`:return dm({context:e,irSchema:t,schema:n});case`object`:return pm({context:e,irSchema:t,schema:n,state:r});case`string`:return mm({context:e,irSchema:t,schema:n});default:return Tm({context:e,irSchema:t,schema:n})}},Cm=({context:e,irSchema:t,schema:n,state:r})=>{t||=gm({schema:n});let i={};cm({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=Sm({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=S({items:a,schema:t}),t},wm=({context:e,schema:t,state:n})=>{let r=gm({schema:t});cm({irSchema:r,schema:t});let i=im({schema:t});return i.length===1?Sm({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):Cm({context:e,irSchema:r,schema:{...t,type:i},state:n})},Tm=({irSchema:e,schema:t})=>(e||=gm({schema:t}),e.type=`unknown`,cm({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?xm({context:e,schema:t,state:n}):t.enum?ym({context:e,schema:t,state:n}):t.allOf?_m({context:e,schema:t,state:n}):t.anyOf?vm({context:e,schema:t,state:n}):t.oneOf?bm({context:e,schema:t,state:n}):t.type||t.properties?wm({context:e,schema:t,state:n}):Tm({context:e,schema:t})),Em=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[R(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Dm=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),Om=({context:e,name:t,schema:n})=>{if(Pf(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=rm({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Om({context:e,name:t,schema:n}):!1}return Om({context:e,name:t,schema:r})}for(let t in n.properties)if(Pf(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=im({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&Dm(im({schema:n[0]})))return t}if(Dm(n))return t}}for(let r of n.allOf??[]){let n=Om({context:e,name:t,schema:r});if(n)return n}return!1},km=({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)},Am=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:_d({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),km({irOperation:a,operation:n}),hm({source:n,target:a}),a},jm=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Am({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=rm({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Om({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){if(t.startsWith(`x-`))continue;o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=rm({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,...nm({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},Mm=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:jm({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),Nm=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Mm({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Pm=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Mm({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},Fm=e=>{switch(e){case`query`:return!1;default:return}},Im=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Lm=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()]=Rm({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Rm=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=rm({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=Om({context:t,name:n.name,schema:i}),o=n.style||Lm(n.in),s=n.explode===void 0?Im(o):n.explode,c={allowReserved:n.allowReserved===void 0?Fm(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),hm({source:n,target:c}),c},zm=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[R(e)]=Rm({$ref:e,context:t,parameter:n})},Bm=({$ref:e,context:t,requestBody:n})=>{let r=rm({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},Vm=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[R(e)]=Bm({$ref:e,context:t,requestBody:n})},Hm=({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=Da(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Um=(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 hd){let a=n[t];if(!a)continue;let o=C({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`)}},Wm=({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&&Pm({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Pm({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Pm({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Pm({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Pm({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Pm({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Pm({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Pm({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Gm=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Sf({context:e,result:Um(e.spec,e.logger)}),Cd(e.config.parser.filters)){let t=Sd(e.config.parser.filters,e.spec,e.logger),{graph:n}=sf(e.spec,e.logger),{resourceMetadata:r}=Id(n,e.logger);tm({...Fd({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}_f({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];zm({$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];Vm({$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];Em({$ref:n,context:e,schema:r})}}for(let r in Hm({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={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&&Nm({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Nm({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Nm({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Nm({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Nm({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Nm({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Nm({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Nm({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}Wm({context:e,securitySchemesMap:n})},Km=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new md({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return fp(i),i;if(za(i.spec.openapi,`>=3.0.0 <3.1.0`))return em(i),i;if(za(i.spec.openapi,`>=3.1.0`))return Gm(i),i;throw Error(`Unsupported OpenAPI specification`)};export{be as A,Be as C,_e as D,he as E,ie as M,ae as N,ve as O,qe as S,me as T,w as _,Bu as a,v as b,_a as c,F as d,ui as f,k as g,yt as h,Gu as i,le as j,ye as k,va as l,xt as m,sf as n,ja as o,zt as p,td as r,Ta as s,Km as t,I as u,b as v,pe as w,Ye as x,y};
14
+ //# sourceMappingURL=openApi-BU6F2oHy.mjs.map