@hey-api/openapi-ts 0.89.1 → 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 +27 -24
  2. package/dist/clients/angular/client.ts +4 -0
  3. package/dist/clients/axios/client.ts +5 -1
  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-Duuay7XM.d.cts → config-DT26kmcq.d.cts} +2493 -1614
  10. package/dist/{config-DsA-xawl.d.mts → config-Dis5Gu6e.d.mts} +2492 -1613
  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-T7IO6Tfr.cjs → src-CHy94xdb.cjs} +5 -4
  30. package/dist/src-CHy94xdb.cjs.map +1 -0
  31. package/dist/{src-DwGvCacY.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-C6rgbKAs.mjs +0 -13
  35. package/dist/openApi-C6rgbKAs.mjs.map +0 -1
  36. package/dist/openApi-DbVAMWYK.cjs +0 -13
  37. package/dist/openApi-DbVAMWYK.cjs.map +0 -1
  38. package/dist/src-DwGvCacY.mjs.map +0 -1
  39. package/dist/src-T7IO6Tfr.cjs.map +0 -1
@@ -0,0 +1,14 @@
1
+
2
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@hey-api/codegen-core`),u=require(`ansi-colors`);u=c(u);let d=require(`node:fs`);d=c(d);let f=require(`node:path`);f=c(f);let p=require(`node:url`),m=require(`typescript`);m=c(m);let ee=require(`node:os`),h=require(`semver`);h=c(h);let te=require(`@hey-api/json-schema-ref-parser`);const ne=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),re=f.default.dirname(ne),ie=()=>{let e=re;for(;e!==f.default.dirname(e);){let t=d.default.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=f.default.join(e,t[0]);return JSON.parse(d.default.readFileSync(n,{encoding:`utf8`}))}e=f.default.dirname(e)}},ae=()=>{let e=ie(),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},oe=e=>{if(e===null)return null;if(e){let t=f.default.isAbsolute(e)?e:f.default.resolve(re,e);return d.default.existsSync(t)?t:null}let t=re;for(;t!==f.default.dirname(t);){let e=d.default.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return f.default.join(t,e[0]);t=f.default.dirname(t)}return null},se=e=>{if(!e)return null;let t=m.default.readConfigFile(e,m.default.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return m.default.parseJsonConfigFileContent(t.config,m.default.sys,f.default.dirname(e))},ce=e=>{d.default.existsSync(e)||d.default.mkdirSync(e,{recursive:!0})};var le=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},ue=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},de=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},fe=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 pe=(e,t)=>{if(e instanceof le||e instanceof ue)return;e instanceof de&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=f.default.resolve(process.cwd(),t);ce(r);let i=f.default.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof fe&&(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`),d.default.writeFileSync(i,a),i},me=async e=>{let t=ae();if(!t.bugs.url)return;e instanceof de&&(e=e.originalError.error);let n=``;e instanceof fe&&(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)},he=({error:e,logPath:t})=>{if(e instanceof ue&&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=u.default.gray(`[Job ${e+1}] `),r=n.length,i=u.default.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=u.default.red(r);console.error(`${t}${i}${u.default.white(e.message)}`)})}}else{let t=u.default.gray(`[root] `);e instanceof de&&(t=u.default.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=u.default.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=u.default.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=u.default.gray(`[root] `);console.error(`${e}${u.default.cyan(`📄 Crash log saved to:`)} ${u.default.gray(t)}`)}},ge=async({error:e,isInteractive:t})=>!t||e instanceof le||e instanceof ue?!1:new Promise(e=>{let t=u.default.gray(`[root] `);console.log(`${t}${u.default.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),_e=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,ve=`https://get.heyapi.dev`,ye=(e,t,n)=>`${ve}/${e}/${t}${n?`?${n}`:``}`,be=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(_e);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}},xe=e=>{let t=be(e);return{path:ye(t.organization,t.project,t.queryParams),registry:`hey-api`}},Se=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,Ce=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,we=`readme`,Te=e=>{let t=e.match(Se);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${we}:@organization/project#uuid" or "${we}:uuid", received: ${we}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Ee=e=>{let t=Te(e.slice(`${we}:`.length));return{...t,path:Ce(t.uuid),registry:`readme`}},De=/^(@[\w-]+)\/([\w.-]+)$/,Oe=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,ke=`scalar`,Ae=e=>{let t=e.match(De);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${ke}:@organization/project", received: ${ke}:${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}},je=e=>{let t=Ae(e.slice(`${ke}:`.length));return{...t,path:Oe(t.organization,t.project),registry:`scalar`}},Me=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Ee(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,je(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(ve)){e.path=e.path.slice(23),Object.assign(e,xe(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,xe(e));return}},Ne={enabled:!1,interval:1e3,timeout:6e4},Pe=e=>{let t={...Ne};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},Fe=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Ne};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:ve,...r},t.watch!==void 0&&(t.watch=Pe(t))):t={...t,path:r},typeof t.path==`string`&&Me(t),e.watch!==void 0&&t.watch.enabled===Ne.enabled&&t.watch.interval===Ne.interval&&t.watch.timeout===Ne.timeout&&(t.watch=Pe({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Ie=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Le=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Re=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Le(n.logs,r.logs)),i},ze=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Be=(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=Be(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Be(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Be(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Be(r,e(n))}break;case`object`:if(ze(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Be(r,i(n,e))}else r=Be(r,n);break}return r},Ve=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=se(oe(t.tsConfigPath)),t.importFileExtension===void 0&&(t.tsConfig?.options.moduleResolution===m.default.ModuleResolutionKind.NodeNext||t.tsConfig?.options.moduleResolution===m.default.ModuleResolutionKind.Node16)&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},He=e=>{let t=e?f.default.dirname(e):process.cwd();for(;t!==f.default.dirname(t);){let e=f.default.join(t,`package.json`);if(d.default.existsSync(e))try{let t=JSON.parse(d.default.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=f.default.dirname(t);if(n===t)break;t=n}return{}},Ue=[`after`,`before`,`cursor`,`offset`,`page`,`start`],We=e=>g({defaultValue:{hooks:{},pagination:{keywords:Ue},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}),_=e=>t=>({...e,config:{...e.config,...t}}),v={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};function Ge(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 y={byTags:e=>t=>{let n=t.tags&&t.tags.length>0?t.tags:[e.fallback],r=(e.path??b.id())(t);return n.map(e=>[e,...r])},flat:e=>t=>{let n=(e?.path??b.id())(t);return[[n[n.length-1]]]},single:e=>t=>{let n=(e.path??b.id())(t);return[[e.root,...n]]}},b={fromOperationId:e=>t=>{let n=e?.fallback??b.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 Ke(e){return e.config.httpRequests.nesting===`id`?b.id():e.config.httpRequests.nesting===`operationId`?b.fromOperationId({delimiters:e.config.httpRequests.nestingDelimiters,fallback:b.id()}):e.config.httpRequests.nesting}function qe(e){if(e.config.httpRequests.strategy===`flat`)return y.flat({path:t=>[Ke(e)(t).join(`.`)]});if(e.config.httpRequests.strategy===`single`){let t=e.config.httpRequests.containerName;return y.single({path:Ke(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.httpRequests.strategy===`byTags`?y.byTags({fallback:e.config.httpRequests.strategyDefaultTag,path:Ke(e)}):e.config.httpRequests.strategy}function Je(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 Ye(e){return e.config.httpResources.nesting===`id`?b.id():e.config.httpResources.nesting===`operationId`?b.fromOperationId({delimiters:e.config.httpResources.nestingDelimiters,fallback:b.id()}):e.config.httpResources.nesting}function Xe(e){if(e.config.httpResources.strategy===`flat`)return y.flat({path:t=>[Ye(e)(t).join(`.`)]});if(e.config.httpResources.strategy===`single`){let t=e.config.httpResources.containerName;return y.single({path:Ye(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.httpResources.strategy===`byTags`?y.byTags({fallback:e.config.httpResources.strategyDefaultTag,path:Ye(e)}):e.config.httpResources.strategy}const Ze=e=>{let t=x(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},x=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},Qe=({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]},$e=e=>{for(let t in e)if(e[t].required)return!0;return!1},et=e=>e?!!($e(e.cookie)||$e(e.header)||$e(e.path)||$e(e.query)):!1,tt=({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:Qe({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:Qe({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:Qe({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:Qe({context:e,parameter:r})}}}},S=({detectFormat:e=!0,schema:t})=>{if(!t.items)return t;let n=[],r=[];for(let i of t.items){if(!i.type&&i.items||t.type===`tuple`){n.push(i);continue}if(!i.type||i.type===`boolean`||i.type===`integer`||i.type===`null`||i.type===`number`||i.type===`string`||i.type===`unknown`||i.type===`void`){let t=i.const===void 0?``:`const-${i.const}`,a=i.format!==void 0&&e?`format-${i.format}`:``,o=[i.minLength===void 0?``:`minLength-${i.minLength}`,i.maxLength===void 0?``:`maxLength-${i.maxLength}`,i.minimum===void 0?``:`minimum-${i.minimum}`,i.maximum===void 0?``:`maximum-${i.maximum}`,i.exclusiveMinimum===void 0?``:`exclusiveMinimum-${i.exclusiveMinimum}`,i.exclusiveMaximum===void 0?``:`exclusiveMaximum-${i.exclusiveMaximum}`,i.minItems===void 0?``:`minItems-${i.minItems}`,i.maxItems===void 0?``:`maxItems-${i.maxItems}`,i.pattern===void 0?``:`pattern-${i.pattern}`].join(``),s=`${i.$ref??``}${i.type??``}${t}${a}${o}`;r.includes(s)||(r.push(s),n.push(i));continue}n.push(i)}let i={...t};if(i.items=n,i.items.length<=1&&i.type!==`array`&&i.type!==`enum`&&i.type!==`tuple`){let e=i.items[0];delete i.logicalOperator,delete i.items,i={...i,...e}}return i.type===`unknown`?{}:i},C=({items:e,logicalOperator:t=`or`,mutateSchemaOneItem:n=!1,schema:r})=>e.length?r.type===`tuple`?(r.items=e,r):e.length===1?n?(r={...r,...e[0]},r):(r.items=e,r):(r.items=e,r.logicalOperator=t,r):r,nt=e=>!!(et(e.parameters)||e.body?.required),w=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,rt=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return tt({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}:tt({context:e,parameters:t.parameters})},it=({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`}},at=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(it({statusCode:t})){case`1XX`:case`3XX`:break;case`2XX`:r.properties[t]=a.schema;break;case`4XX`:case`5XX`:n.properties[t]=a.schema;break;case`default`:i=a;break}}if(i){let e=!1;Object.keys(r.properties).length||(r.properties.default=i.schema,e=!0);let t=(i.schema.description??``).toLocaleLowerCase(),a=(i.schema.$ref??``).toLocaleLowerCase();[`success`].some(e=>t.includes(e)||a.includes(e))&&(r.properties.default=i.schema,e=!0),[`error`,`problem`].some(e=>t.includes(e)||a.includes(e))&&(n.properties.default=i.schema,e=!0),e||(n.properties.default=i.schema)}let a=Object.keys(n.properties);if(a.length){n.required=a,t.errors=n;let e=C({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.error=e)}let o=Object.keys(r.properties);if(o.length){r.required=o,t.responses=r;let e=C({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t};var T=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=(0,l.ref)(e),(0,l.isSymbol)(e)&&e.setNode(this)},toString:()=>this._name?this.$name(this._name):``}}nameSanitizer;language=`typescript`;parent;root=!1;scope=`value`;structuralChildren;structuralParents;symbol;toAst(){}"~brand"=l.nodeBrand;$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`?m.default.factory.createIdentifier(e):e}$name(e){let t=(0,l.fromRef)(e);if((0,l.isSymbol)(t))try{return t.finalName}catch{return t.name}return String(t)}$node(e){if(e!==void 0)return(0,l.isRef)(e)&&(e=(0,l.fromRef)(e)),(0,l.isSymbol)(e)?this.$maybeId(e.finalName):typeof e==`string`?this.$maybeId(e):e instanceof Array?e.map(e=>((0,l.isRef)(e)&&(e=(0,l.fromRef)(e)),this.unwrap(e))):this.unwrap(e)}$type(e,t){if(e!==void 0){if((0,l.isRef)(e)&&(e=(0,l.fromRef)(e)),(0,l.isSymbol)(e))return m.default.factory.createTypeReferenceNode(e.finalName,t);if(typeof e==`string`)return m.default.factory.createTypeReferenceNode(e,t);if(typeof e==`boolean`){let t=e?m.default.factory.createTrue():m.default.factory.createFalse();return m.default.factory.createLiteralTypeNode(t)}return typeof e==`number`?m.default.factory.createLiteralTypeNode(m.default.factory.createNumericLiteral(e)):e instanceof Array?e.map(e=>this.$type(e,t)):this.unwrap(e)}}_name;unwrap(e){return(0,l.isNode)(e)?e.toAst():e}},ot=class extends T{};const st=T;var ct=class extends st{"~dsl"=`IdTsDsl`;constructor(e){super(),this.name.set(e)}analyze(e){super.analyze(e)}toAst(){return m.default.factory.createIdentifier(this.name.toString())}},lt=class extends T{"~dsl"=`NewlineTsDsl`;analyze(e){super.analyze(e)}toAst(){return this.$node(new ct(`
3
+ `))}};function ut(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((0,l.ref)(e)),this}args(...e){return this._args.push(...e.filter(e=>e!==void 0).map(e=>(0,l.ref)(e))),this}$args(){return this.$node(this._args).map(e=>this.$node(e))}}return t}const dt=T;var ft=class extends dt{"~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=m.default.SyntaxKind.MinusToken,this}not(){return this._op=m.default.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 m.default.factory.createPrefixUnaryExpression(this._op,this.$node(this._expr))}};function E(e){let t,n=((...n)=>{if(!t)throw Error(`${e} factory not registered`);return t(...n)});return n.set=e=>{t=e},n}const D={as:E(`as`),attr:E(`attr`),await:E(`await`),call:E(`call`),new:E(`new`),return:E(`return`),type:{expr:E(`type.expr`),idx:E(`type.idx`),operator:E(`type.operator`),query:E(`type.query`)},typeofExpr:E(`typeofExpr`)};function O(e){class t extends e{analyze(e){super.analyze(e)}as(...e){return D.as(this,...e)}}return t}const pt=O(T);var k=class extends pt{"~dsl"=`LiteralTsDsl`;value;constructor(e){super(),this.value=e}analyze(e){super.analyze(e)}toAst(){if(typeof this.value==`boolean`)return this.value?m.default.factory.createTrue():m.default.factory.createFalse();if(typeof this.value==`number`){let e=m.default.factory.createNumericLiteral(Math.abs(this.value));return this.value<0?this.$node(new ft(e).neg()):e}if(typeof this.value==`string`)return m.default.factory.createStringLiteral(this.value,!0);if(typeof this.value==`bigint`)return m.default.factory.createBigIntLiteral(this.value.toString());if(this.value===null)return m.default.factory.createNull();throw Error(`Unsupported literal: ${String(this.value)}`)}};const mt=/^[^$_\p{ID_Start}]+/u,ht=/^-?\d+(\.\d+)?$/,gt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,A={illegalStartCharacters:mt,number:ht,typeScriptIdentifier:gt},_t=[`document`,`history`,`location`,`navigator`,`window`],vt=[`console`,`Array`,`Date`,`Error`,`Function`,`JSON`,`Map`,`Math`,`Object`,`Promise`,`RegExp`,`Set`,`WeakMap`,`WeakSet`],yt=`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(`.`),bt=[`global`,`process`,`Buffer`],xt=[`any`,`as`,`bigint`,`boolean`,`namespace`,`never`,`null`,`number`,`string`,`symbol`,`type`,`undefined`,`unknown`,`void`],St={browserGlobals:_t,javaScriptGlobals:vt,javaScriptKeywords:yt,nodeGlobals:bt,typeScriptKeywords:xt};var Ct=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 wt=new Ct([...St.browserGlobals,...St.javaScriptGlobals,...St.javaScriptKeywords,...St.nodeGlobals,...St.typeScriptKeywords]),Tt=new Ct([...St.javaScriptKeywords,...St.typeScriptKeywords]),Et={runtime:wt,type:Tt},Dt=e=>(A.number.lastIndex=0,A.number.test(e)?e.startsWith(`-`)?`'${e}'`:e:(A.typeScriptIdentifier.lastIndex=0,A.typeScriptIdentifier.test(e)?e:`'${e}'`)),Ot=e=>(A.typeScriptIdentifier.lastIndex=0,A.typeScriptIdentifier.test(e)?new ct(e):new k(e)),kt=e=>(A.number.lastIndex=0,A.number.test(e)?e.startsWith(`-`)?new k(e):new k(Number(e)):(A.typeScriptIdentifier.lastIndex=0,A.typeScriptIdentifier.test(e)?new ct(e):new k(e))),At=(e,t)=>{let n=``,r,i=e[0];for(A.illegalStartCharacters.lastIndex=0,A.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||`_`},jt=e=>At(e,Et.runtime),Mt=e=>At(e,Et.type),Nt=ut(T);var Pt=class extends Nt{"~dsl"=`DecoratorTsDsl`;nameSanitizer=jt;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 m.default.factory.createDecorator(t.length?m.default.factory.createCallExpression(e,void 0,t):e)}};function Ft(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 Pt(e,...t)),this}$decorators(){return this.$node(this.decorators)}}return t}function It(e){let t;return e.forEach((e,n)=>{t=n===0?e:t.attr(e.name)}),t}function Lt(e){let t=Ht([...zt(e,new Set)]);return t.length===0?[e.clone()]:t.map(e=>e.clone())}function Rt(e){return e.scope??`value`}function zt(e,t){if(t.has(e)||(t.add(e),Vt(e)))return[];if(e.structuralParents)for(let[n]of e.structuralParents){if(Rt(n)!==Rt(e))continue;let r=zt(n,t);if(r.length>0)return[...r,e]}return e.root?[e]:[]}function Bt(e){return e[`~dsl`]===`FieldTsDsl`||e[`~dsl`]===`GetterTsDsl`||e[`~dsl`]===`MethodTsDsl`}function Vt(e){return e[`~dsl`]===`FuncTsDsl`||e[`~dsl`]===`TemplateTsDsl`}function Ht(e){let t=[];return e.forEach((e,n)=>{(n===0||Bt(e))&&t.push(e)}),t}function Ut(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&&Bt(t)&&t.hasModifier(`static`)?I(n.name):I.new(n.name).args()}return I(n.name)}return n})}var Wt=class{access(e,t){let n=(0,l.isSymbol)(e)?e.node:e;if(!n)throw Error(`Symbol ${e.name} is not resolved to a node.`);return It(Ut(Lt(n),t))}example(e,t,n){if(n)return gi.astToString(n);if(!t)throw Error(`Example options are required.`);let r=Lt(e);t.importName&&r[0].name.set(t.importName);let i=I(r[0].name.toString()),a=Ut(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?[I.const(s).assign(o),It([I(s),...a.slice(1)]).call(...c)]:[It([o,...a.slice(1)]).call(...c)];let u=i.name.toString();return gi.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})}},Gt=class extends T{"~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 Wt,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=>m.default.factory.createJSDocText(`${e}\n`)),i=m.default.factory.createJSDocComment(m.default.factory.createNodeArray(r),void 0),a=m.default.createPrinter().printNode(m.default.EmitHint.Unspecified,i,e.getSourceFile?.()??m.default.createSourceFile(``,``,m.default.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.MultiLineCommentTrivia,a,!0),e}toAst(){return this.$node(new ct(``))}};function j(e){class t extends e{_doc;analyze(e){super.analyze(e)}doc(e,t){return this._doc=new Gt(e,t),this}$docs(e){return this._doc?this._doc.apply(e):e}}return t}function Kt(e){switch(e){case`abstract`:return m.default.SyntaxKind.AbstractKeyword;case`async`:return m.default.SyntaxKind.AsyncKeyword;case`const`:return m.default.SyntaxKind.ConstKeyword;case`declare`:return m.default.SyntaxKind.DeclareKeyword;case`default`:return m.default.SyntaxKind.DefaultKeyword;case`export`:return m.default.SyntaxKind.ExportKeyword;case`override`:return m.default.SyntaxKind.OverrideKeyword;case`private`:return m.default.SyntaxKind.PrivateKeyword;case`protected`:return m.default.SyntaxKind.ProtectedKeyword;case`public`:return m.default.SyntaxKind.PublicKeyword;case`readonly`:return m.default.SyntaxKind.ReadonlyKeyword;case`static`:return m.default.SyntaxKind.StaticKeyword}}function M(e){class t extends e{modifiers=[];analyze(e){super.analyze(e)}hasModifier(e){let t=Kt(e);return!!this.modifiers.find(e=>e.kind===t)}_m(e,t){if(t){let t=Kt(e);this.modifiers.push(m.default.factory.createModifier(t))}return this}}return t}function qt(e){let t=M(e);class n extends t{abstract(e){let t=arguments.length===0?!0:!!e;return this._m(`abstract`,t)}}return n}function Jt(e){let t=M(e);class n extends t{async(e){let t=arguments.length===0?!0:!!e;return this._m(`async`,t)}}return n}function Yt(e){let t=M(e);class n extends t{const(e){let t=arguments.length===0?!0:!!e;return this._m(`const`,t)}}return n}function Xt(e){let t=M(e);class n extends t{default(e){let t=arguments.length===0?!0:!!e;return this._m(`default`,t)}}return n}function Zt(e){let t=M(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=M(e);class n extends t{private(e){let t=arguments.length===0?!0:!!e;return this._m(`private`,t)}}return n}function $t(e){let t=M(e);class n extends t{protected(e){let t=arguments.length===0?!0:!!e;return this._m(`protected`,t)}}return n}function en(e){let t=M(e);class n extends t{public(e){let t=arguments.length===0?!0:!!e;return this._m(`public`,t)}}return n}function tn(e){let t=M(e);class n extends t{readonly(e){let t=arguments.length===0?!0:!!e;return this._m(`readonly`,t)}}return n}function nn(e){let t=M(e);class n extends t{static(e){let t=arguments.length===0?!0:!!e;return this._m(`static`,t)}}return n}const rn=T;var an=class extends rn{"~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=(0,l.ref)(e),this}extends(e){return this.constraint=(0,l.ref)(e),this}toAst(){if(!this.name.toString())throw Error(`Missing type name`);return m.default.factory.createTypeParameterDeclaration(void 0,this.$node(this.name),this.$type(this.constraint),this.$type(this.defaultValue))}};function on(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 an(...e);return this._generics.push(t),this}generics(...e){for(let t of e)(typeof t==`string`||typeof t==`number`||(0,l.isSymbol)(t)||(0,l.isRef)(t))&&(t=new an(t)),this._generics.push(t);return this}$generics(){return this.$node(this._generics)}}return t}function sn(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 cn(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 N=class extends T{"~dsl"=`TokenTsDsl`;_kind;kind(e){return this._kind=e,this}minus(){return this.kind(m.default.SyntaxKind.MinusToken)}optional(){return this.kind(m.default.SyntaxKind.QuestionToken)}plus(){return this.kind(m.default.SyntaxKind.PlusToken)}questionDot(){return this.kind(m.default.SyntaxKind.QuestionDotToken)}readonly(){return this.kind(m.default.SyntaxKind.ReadonlyKeyword)}spread(){return this.kind(m.default.SyntaxKind.DotDotDotToken)}toAst(){if(!this._kind)throw Error("Token missing `.kind(kind)`");return m.default.factory.createToken(this._kind)}};function ln(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((0,l.ref)(e)),this}generics(...e){return this._generics.push(...e.map(e=>(0,l.ref)(e))),this}$generics(){return this.$type(this._generics)}}return t}function un(e){class t extends e{analyze(e){super.analyze(e)}idx(...e){return D.type.idx(this,...e)}keyof(){return D.type.operator().keyof(this)}readonly(){return D.type.operator().readonly(this)}returnType(...e){return D.type.expr(`ReturnType`).generic(D.type.query(this,...e))}typeofExpr(...e){return D.typeofExpr(this,...e)}typeofType(...e){return D.type.query(this,...e)}unique(){return D.type.operator().unique(this)}}return t}const dn=un(T);var fn=class extends dn{"~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(0,l.isRef)(e)?this._base=e:this._base=e?(0,l.ref)(e):void 0,this}right(e){return this._right=(0,l.ref)(e),this}toAst(){if(!this._base)throw Error(`TypeAttrTsDsl: missing base for qualified name`);let e=this.$node(this._base);if(!m.default.isEntityName(e))throw Error(`TypeAttrTsDsl: base must be an EntityName`);return m.default.factory.createQualifiedName(e,this.$node(this._right))}};const pn=ln(un(T));var mn=class extends pn{"~dsl"=`TypeExprTsDsl`;scope=`type`;_exprInput;constructor(e,t){super(),typeof e==`function`?e(this):(this._exprInput=e?(0,l.ref)(e):void 0,t?.(this))}analyze(e){super.analyze(e),e.analyze(this._exprInput)}attr(e){return this._exprInput=(0,l.isNode)(e)?(0,l.ref)(e.base(this._exprInput)):(0,l.ref)(new fn(this._exprInput,e)),this}toAst(){if(!this._exprInput)throw Error(`TypeExpr must have an expression`);return m.default.factory.createTypeReferenceNode(this.$type(this._exprInput),this.$generics())}};D.type.expr.set((...e)=>new mn(...e));const hn=Ft(j(sn(Qt($t(en(tn(nn(cn(T)))))))));var gn=class extends hn{"~dsl"=`FieldTsDsl`;nameSanitizer=Dt;_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 ot?e:new mn(e),this}toAst(){let e=m.default.factory.createPropertyDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this._optional?this.$node(new N().optional()):void 0,this.$type(this._type),this.$value());return this.$docs(e)}};const _n=T;var vn=class extends _n{"~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 m.default.isStatement(e)?e:m.default.factory.createExpressionStatement(e)}};function yn(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 vn(e)))}}return t}const bn=T;var xn=class extends bn{"~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?m.default.factory.createBindingElement(void 0,void 0,e,void 0):m.default.factory.createBindingElement(void 0,e,t,void 0)),t=this.createSpread();return t&&e.push(t),m.default.factory.createObjectBindingPattern(e)}if(this.pattern.kind===`array`){let e=this.pattern.values.map(e=>m.default.factory.createBindingElement(void 0,void 0,e,void 0)),t=this.createSpread();return t&&e.push(t),m.default.factory.createArrayBindingPattern(e)}throw Error(`PatternTsDsl requires object() or array() pattern`)}createSpread(){return this._spread?m.default.factory.createBindingElement(this.$node(new N().spread()),void 0,this.$node(new ct(this._spread))):void 0}};function Sn(e){class t extends e{pattern;analyze(e){super.analyze(e),e.analyze(this.pattern)}array(...e){return(this.pattern??=new xn).array(...e),this}object(...e){return(this.pattern??=new xn).object(...e),this}spread(e){return(this.pattern??=new xn).spread(e),this}$pattern(){if(this.pattern)return this.$node(this.pattern)}}return t}const Cn=Ft(sn(Sn(cn(T))));var wn=class extends Cn{"~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 ot?e:new mn(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 m.default.factory.createParameterDeclaration(this.$decorators(),void 0,e,this._optional?this.$node(new N().optional()):void 0,this.$type(this._type),this.$value())}};function Tn(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 wn(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 En(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 Dn=yn(En(T));var P=class extends Dn{"~dsl"=`BlockTsDsl`;constructor(...e){super(),this.do(...e)}analyze(e){super.analyze(e)}toAst(){let e=this.$do();return m.default.factory.createBlock(e,this.$multiline(e.length))}};const On=Ft(yn(j(Tn(Qt($t(en(T)))))));var kn=class extends On{"~dsl"=`InitTsDsl`;constructor(e){super(),e?.(this)}analyze(e){e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=m.default.factory.createConstructorDeclaration([...this.$decorators(),...this.modifiers],this.$params(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};function An(e){class t extends e{_returns;analyze(e){super.analyze(e),e.analyze(this._returns)}returns(e){return this._returns=e instanceof ot?e:new mn(e),this}$returns(){return this.$type(this._returns)}}return t}const jn=qt(Jt(Ft(yn(j(sn(Tn(Qt($t(en(nn(on(An(T)))))))))))));var Mn=class extends jn{"~dsl"=`MethodTsDsl`;nameSanitizer=Dt;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=m.default.factory.createMethodDeclaration([...this.$decorators(),...this.modifiers],void 0,this.$node(this.name),this._optional?this.$node(new N().optional()):void 0,this.$generics(),this.$params(),this.$returns(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};const Nn=qt(Ft(Xt(j(Zt(on(T))))));var Pn=class extends Nn{"~dsl"=`ClassTsDsl`;nameSanitizer=jt;baseClass;body=[];constructor(e){super(),this.name.set(e),(0,l.isSymbol)(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?(0,l.ref)(e):void 0,this}field(e,t){let n=new gn(e,t);return this.body.push(n),this}init(e){let t=typeof e==`function`?new kn(e):e||new kn;return this.body.push(t),this}method(e,t){let n=new Mn(e,t);return this.body.push(n),this}newline(){return this.body.push(new lt),this}toAst(){let e=this.$node(this.body),t=m.default.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?[m.default.factory.createHeritageClause(m.default.SyntaxKind.ExtendsKeyword,[m.default.factory.createExpressionWithTypeArguments(e,void 0)])]:[]}};const Fn=j(T);var In=class extends Fn{"~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=m.default.factory.createEnumMember(this.$node(Ot(this.name.toString())),this.$node(this._value));return this.$docs(e)}};const Ln=Yt(j(Zt(T)));var Rn=class extends Ln{"~dsl"=`EnumTsDsl`;nameSanitizer=jt;_members=[];constructor(e,t){super(),this.name.set(e),(0,l.isSymbol)(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 In(e,t);return this._members.push(n),this}members(...e){return this._members.push(...e),this}toAst(){let e=m.default.factory.createEnumDeclaration(this.modifiers,this.$node(this.name),this.$node(this._members));return this.$docs(e)}};const zn=qt(O(Jt(Ft(yn(j(Tn(Qt($t(en(nn(on(An(T)))))))))))));var Bn=class extends zn{"~dsl"=`FuncTsDsl`;nameSanitizer=jt;mode;constructor(e,t){super(),typeof e==`function`?(this.mode=`arrow`,e(this)):e&&(this.mode=`decl`,this.name.set(e),(0,l.isSymbol)(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 P(...this._do).pretty());if(this.mode===`decl`){if(!this.name.toString())throw Error(`Function declaration requires a name`);let t=m.default.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=m.default.factory.createFunctionExpression(this.modifiers,void 0,this.$node(this.name),this.$generics(),this.$params(),this.$returns(),e);return this.$docs(t)}let t=m.default.factory.createArrowFunction(this.modifiers,this.$generics(),this.$params(),this.$returns(),void 0,e.statements.length===1&&m.default.isReturnStatement(e.statements[0])&&e.statements[0].expression?e.statements[0].expression:e);return this.$docs(t)}};const Vn=Bn,Hn=qt(Jt(Ft(yn(j(Tn(Qt($t(en(nn(An(T)))))))))));var Un=class extends Hn{"~dsl"=`GetterTsDsl`;nameSanitizer=Dt;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=m.default.factory.createGetAccessorDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$params(),this.$returns(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};const Wn=qt(Jt(Ft(yn(j(Tn(Qt($t(en(nn(T))))))))));var Gn=class extends Wn{"~dsl"=`SetterTsDsl`;nameSanitizer=Dt;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=m.default.factory.createSetAccessorDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$params(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};const Kn=O(En(T));var qn=class extends Kn{"~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 k(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`?m.default.factory.createSpreadElement(t):t});return m.default.factory.createArrayLiteralExpression(e,this.$multiline(this._elements.length))}};function Jn(e){class t extends e{analyze(e){super.analyze(e)}attr(...e){return D.attr(this,...e)}await(){return D.await(this)}call(...e){return D.call(this,...e)}return(){return D.return(this)}}return t}const Yn=O(Jn(T));var Xn=class extends Yn{"~dsl"=`AsTsDsl`;expr;type;constructor(e,t){super(),this.expr=(0,l.ref)(e),this.type=(0,l.ref)(t)}analyze(e){super.analyze(e),e.analyze(this.expr),e.analyze(this.type)}toAst(){return m.default.factory.createAsExpression(this.$node(this.expr),this.$type(this.type))}};D.as.set((...e)=>new Xn(...e));const Zn=O(Jn(T));var F=class extends Zn{"~dsl"=`BinaryTsDsl`;_base;_expr;_op;constructor(e,t,n){super(),this._base=(0,l.ref)(e),this._op=t,n&&(this._expr=(0,l.ref)(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 m.default.factory.createBinaryExpression(t,n,e)}opAndExpr(e,t){return this._expr=(0,l.ref)(t),this._op=e,this}opToToken(e){let t={"!=":m.default.SyntaxKind.ExclamationEqualsToken,"!==":m.default.SyntaxKind.ExclamationEqualsEqualsToken,"&&":m.default.SyntaxKind.AmpersandAmpersandToken,"*":m.default.SyntaxKind.AsteriskToken,"+":m.default.SyntaxKind.PlusToken,"-":m.default.SyntaxKind.MinusToken,"/":m.default.SyntaxKind.SlashToken,"<":m.default.SyntaxKind.LessThanToken,"<=":m.default.SyntaxKind.LessThanEqualsToken,"=":m.default.SyntaxKind.EqualsToken,"==":m.default.SyntaxKind.EqualsEqualsToken,"===":m.default.SyntaxKind.EqualsEqualsEqualsToken,">":m.default.SyntaxKind.GreaterThanToken,">=":m.default.SyntaxKind.GreaterThanEqualsToken,"??":m.default.SyntaxKind.QuestionQuestionToken,"??=":m.default.SyntaxKind.QuestionQuestionEqualsToken,"||":m.default.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}};function Qn(e){class t extends e{analyze(e){super.analyze(e)}and(e){return new F(this).and(e)}assign(e){return new F(this,`=`,e)}coalesce(e){return new F(this).coalesce(e)}div(e){return new F(this).div(e)}eq(e){return new F(this).eq(e)}gt(e){return new F(this).gt(e)}gte(e){return new F(this).gte(e)}looseEq(e){return new F(this).looseEq(e)}looseNeq(e){return new F(this).looseNeq(e)}lt(e){return new F(this).lt(e)}lte(e){return new F(this).lte(e)}minus(e){return new F(this).minus(e)}neq(e){return new F(this).neq(e)}nullishAssign(e){return new F(this).nullishAssign(e)}or(e){return new F(this).or(e)}plus(e){return new F(this).plus(e)}times(e){return new F(this).times(e)}}return t}const $n=O(Jn(Qn(sn(T))));var er=class extends $n{"~dsl"=`AttrTsDsl`;left;constructor(e,t){super(),this.left=(0,l.ref)(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);A.typeScriptIdentifier.lastIndex=0;let t=(0,l.fromRef)(this.name);if(!A.typeScriptIdentifier.test(this.name.toString())){let n=(0,l.isSymbol)(t)?t.finalName:t;return typeof n==`string`&&(n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith(`"`)&&n.endsWith(`"`))&&(n=n.slice(1,-1)),this._optional?m.default.factory.createElementAccessChain(e,this.$node(new N().questionDot()),this.$node(new k(n))):m.default.factory.createElementAccessExpression(e,this.$node(new k(n)))}return this._optional?m.default.factory.createPropertyAccessChain(e,this.$node(new N().questionDot()),this.$node(this.name)):m.default.factory.createPropertyAccessExpression(e,this.$node(this.name))}};D.attr.set((...e)=>new er(...e));const tr=Jn(T);var nr=class extends tr{"~dsl"=`AwaitTsDsl`;_awaitExpr;constructor(e){super(),this._awaitExpr=(0,l.ref)(e)}analyze(e){super.analyze(e),e.analyze(this._awaitExpr)}toAst(){return m.default.factory.createAwaitExpression(this.$node(this._awaitExpr))}};D.await.set((...e)=>new nr(...e));const rr=ut(O(Jn(ln(T))));var ir=class extends rr{"~dsl"=`CallTsDsl`;_callExpr;constructor(e,...t){super(),this._callExpr=(0,l.ref)(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this._callExpr)}toAst(){return m.default.factory.createCallExpression(this.$node(this._callExpr),this.$generics(),this.$args())}};D.call.set((...e)=>new ir(...e));const ar=O(Jn(Qn(un(T))));var or=class extends ar{"~dsl"=`ExprTsDsl`;_exprInput;constructor(e){super(),this._exprInput=(0,l.ref)(e),typeof e==`string`||(0,l.isSymbol)(e)?this.name.set(e):(0,l.isNode)(e)&&this.name.set(e.name)}analyze(e){super.analyze(e),e.analyze(this._exprInput)}toAst(){return this.$node(this._exprInput)}},sr=class extends T{"~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 Wt,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)m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.SingleLineCommentTrivia,` ${t}`,!1);return e}toAst(){return this.$node(new ct(``))}};function cr(e){class t extends e{_hint;analyze(e){super.analyze(e)}hint(e,t){return this._hint=new sr(e,t),this}$hint(e){return this._hint?this._hint.apply(e):e}}return t}const lr=j(T);var ur=class extends lr{"~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=(0,l.ref)(e),this}toAst(){this.$validate();let e=this.$node(this._value);if(this.meta.kind===`spread`){if(m.default.isStatement(e))throw Error(`Invalid spread: object spread must be an expression, not a statement.`);let t=m.default.factory.createSpreadAssignment(e);return this.$docs(t)}if(this.meta.kind===`getter`){let t=new Un(this.meta.name).do(e),n=this.$node(t);return this.$docs(n)}if(this.meta.kind===`setter`){let t=new Gn(this.meta.name).do(e),n=this.$node(t);return this.$docs(n)}if(m.default.isIdentifier(e)&&e.text===this.meta.name){let e=m.default.factory.createShorthandPropertyAssignment(this.meta.name);return this.$docs(e)}if(m.default.isStatement(e))throw Error(`Invalid property: object property value must be an expression, not a statement.`);let t=m.default.factory.createPropertyAssignment(this.meta.kind===`computed`?m.default.factory.createComputedPropertyName(this.$node(new ct(this.meta.name))):this.$node(kt(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 dr=O(Jn(cr(En(T))));var fr=class extends dr{"~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 ur({kind:`computed`,name:e}).value(t)),this}getter(e,t){return this._props.push(new ur({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 ur({kind:`prop`,name:e}).value(t)),this}props(...e){return this._props.push(...e),this}setter(e,t){return this._props.push(new ur({kind:`setter`,name:e}).value(t)),this}spread(e){return this._props.push(new ur({kind:`spread`}).value(e)),this}toAst(){let e=m.default.factory.createObjectLiteralExpression(this.$node(this._props),this.$multiline(this._props.length));return this.$hint(e)}};const pr=(e,t)=>{if((0,l.isNode)(e))return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`||typeof e==`bigint`)return new k(e);if(e instanceof Array){let n=new qn(...e.map(e=>pr(e,t)));return t?.layout===`pretty`&&n.pretty(),n}if(typeof e==`object`){let n=new fr;for(let[r,i]of Object.entries(e)){let e=pr(i,t);n.prop(r,e)}return t?.layout===`pretty`&&n.pretty(),n}throw Error(`$.fromValue(): Unsupported input type ${String(e)}`)},mr=ut(O(Jn(ln(T))));var hr=class extends mr{"~dsl"=`NewTsDsl`;_newExpr;constructor(e,...t){super(),this._newExpr=(0,l.ref)(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this._newExpr)}toAst(){return m.default.factory.createNewExpression(this.$node(this._newExpr),this.$generics(),this.$args())}};D.new.set((...e)=>new hr(...e));const gr=T;var _r=class extends gr{"~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 m.default.factory.createRegularExpressionLiteral(e)}};const vr=T;var yr=class extends vr{"~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((0,l.ref)(e)),this}toAst(){let e=this.$node(this.parts.map(e=>{let t=(0,l.fromRef)(e);return(0,l.isSymbol)(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 m.default.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return m.default.factory.createTemplateExpression(m.default.factory.createTemplateHead(t[0]),[m.default.factory.createTemplateSpan(t[1],m.default.factory.createTemplateTail(``))]);let n=m.default.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(m.default.factory.createTemplateSpan(e,i?m.default.factory.createTemplateTail(n):m.default.factory.createTemplateMiddle(n)))}return m.default.factory.createTemplateExpression(n,r)}};const br=T;var xr=class extends br{"~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 m.default.factory.createConditionalExpression(this.$node(this._condition),void 0,this.$node(this._then),void 0,this.$node(this._else))}};const Sr=Qn(T);var Cr=class extends Sr{"~dsl"=`TypeOfExprTsDsl`;_expr;constructor(e){super(),this._expr=e}analyze(e){super.analyze(e),e.analyze(this._expr)}toAst(){return m.default.factory.createTypeOfExpression(this.$node(this._expr))}};D.typeofExpr.set((...e)=>new Cr(...e));var wr=class extends T{"~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 Wt,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&&m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.MultiLineCommentTrivia,`\n${n.join(`
4
+ `)}\n`,!0),e}toAst(){return this.$node(new ct(``))}};const Tr=yn(T);var Er=class extends Tr{"~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 m.default.factory.createIfStatement(this.$node(this._condition),this.$node(new P(...this._do).pretty()),this._else?this.$node(new P(...this._else).pretty()):void 0)}};const Dr=T;var Or=class extends Dr{"~dsl"=`ReturnTsDsl`;_returnExpr;constructor(e){super(),e&&(this._returnExpr=(0,l.ref)(e))}analyze(e){super.analyze(e),e.analyze(this._returnExpr)}toAst(){return m.default.factory.createReturnStatement(this.$node(this._returnExpr))}};D.return.set((...e)=>new Or(...e));const kr=T;var Ar=class extends kr{"~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 k(e)):e);if(this.useNew)return m.default.factory.createThrowStatement(m.default.factory.createNewExpression(e,void 0,t));let n=t.length?[m.default.factory.createCallExpression(e,void 0,t)]:[e];return m.default.factory.createThrowStatement(n[0])}};const jr=T;var Mr=class extends jr{"~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 m.default.factory.createTryStatement(this.$node(new P(...this._try).pretty()),m.default.factory.createCatchClause(e?m.default.factory.createVariableDeclaration(e):void 0,this.$node(new P(...this._catch??[]).pretty())),this._finally?this.$node(new P(...this._finally).pretty()):void 0)}};const Nr=Xt(j(Zt(cr(Sn(cn(T))))));var Pr=class extends Nr{"~dsl"=`VarTsDsl`;nameSanitizer=jt;kind=m.default.NodeFlags.None;_type;constructor(e){super(),e&&this.name.set(e),(0,l.isSymbol)(e)&&e.setKind(`var`)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}const(){return this.kind=m.default.NodeFlags.Const,this}let(){return this.kind=m.default.NodeFlags.Let,this}type(e){return this._type=e instanceof ot?e:new mn(e),this}var(){return this.kind=m.default.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=m.default.factory.createVariableStatement(this.modifiers,m.default.factory.createVariableDeclarationList([m.default.factory.createVariableDeclaration(e,void 0,this.$type(this._type),this.$value())],this.kind));return this.$docs(this.$hint(t))}};const Fr=j(Zt(on(T)));var Ir=class extends Fr{"~dsl"=`TypeAliasTsDsl`;nameSanitizer=Mt;scope=`type`;value;constructor(e,t){super(),this.name.set(e),(0,l.isSymbol)(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=m.default.factory.createTypeAliasDeclaration(this.modifiers,this.$node(this.name),this.$generics(),this.$type(this.value));return this.$docs(e)}};const Lr=T;var Rr=class extends Lr{"~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=>(0,l.ref)(e))),this}toAst(){let e=[];for(let t of this._types){let n=this.$type(t);m.default.isIntersectionTypeNode(n)?e.push(...n.types):e.push(n)}return m.default.factory.createIntersectionTypeNode(e)}};const zr=T;var Br=class extends zr{"~dsl"=`TypeLiteralTsDsl`;scope=`type`;value;constructor(e){super(),this.value=e}analyze(e){super.analyze(e)}toAst(){return m.default.factory.createLiteralTypeNode(this.$node(new k(this.value)))}};const Vr=j(tn(T));var Hr=class extends Vr{"~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=m.default.factory.createIndexSignature(this.modifiers,[m.default.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 Ur=j(sn(tn(T)));var Wr=class extends Ur{"~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=(0,l.ref)(e),this}toAst(){let e=this.name.toString();if(!this._type||!e)throw Error(`Type not specified for property '${e}'`);let t=m.default.factory.createPropertySignature(this.modifiers,this.$node(kt(e)),this._optional?this.$node(new N().optional()):void 0,this.$type(this._type));return this.$docs(t)}};const Gr=T;var Kr=class extends Gr{"~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 Hr(e,t);return this.props.push(n),this}get isEmpty(){return!this.props.length}prop(e,t){let n=new Wr(e,t);return this.props.push(n),this}toAst(){return m.default.factory.createTypeLiteralNode(this.$node(this.props))}};const qr=T;var Jr=class extends qr{"~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 m.default.factory.createTupleTypeNode(this._elements.map(e=>this.$type(e)))}};const Yr=e=>{if((0,l.isNode)(e))return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return new Br(e);if(e instanceof Array)return new Jr(...e.map(e=>Yr(e)));if(typeof e==`object`){let t=new Kr;for(let[n,r]of Object.entries(e)){let e=Yr(r);t.prop(n,t=>t.type(e))}return t}throw Error(`$.type.fromValue(): Unsupported input type ${String(e)}`)},Xr=j(Tn(on(An(T))));var Zr=class extends Xr{"~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=m.default.factory.createFunctionTypeNode(this.$generics(),this.$params(),e);return this.$docs(t)}};const Qr=un(T);var $r=class extends Qr{"~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 m.default.factory.createIndexedAccessTypeNode(this.$type(this._base),this.$type(this._index))}};D.type.idx.set((...e)=>new $r(...e));const ei=T;var ti=class extends ei{"~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 N().minus(),this}optional(){return this.questionToken=new N().optional(),this}readonly(){return this.readonlyToken=new N().readonly(),this}required(){return this.questionToken=new N().minus(),this}type(e){return this._type=e,this}toAst(){return this.$validate(),m.default.factory.createMappedTypeNode(this.$node(this.readonlyToken),m.default.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 ni=T;var ri=class extends ni{"~dsl"=`TypeOperatorTsDsl`;scope=`type`;_op;_type;analyze(e){super.analyze(e),e.analyze(this._type)}keyof(e){return this.operator(m.default.SyntaxKind.KeyOfKeyword),this.type(e),this}operator(e){return this._op=e,this}readonly(e){return this.operator(m.default.SyntaxKind.ReadonlyKeyword),this.type(e),this}type(e){return this._type=e,this}unique(e){return this.operator(m.default.SyntaxKind.UniqueKeyword),this.type(e),this}toAst(){return this.$validate(),m.default.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}};D.type.operator.set((...e)=>new ri(...e));const ii=T;var ai=class extends ii{"~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=>(0,l.ref)(e))),this}toAst(){let e=[];for(let t of this._types){let n=this.$type(t);m.default.isUnionTypeNode(n)?e.push(...n.types):e.push(n)}return m.default.factory.createUnionTypeNode(e)}};const oi=un(T);var si=class extends oi{"~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 m.default.factory.createTypeQueryNode(e)}};D.type.query.set((...e)=>new si(...e));const ci=T;var li=class extends ci{"~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 m.default.factory.createTemplateLiteralType(m.default.factory.createTemplateHead(t[0]),[]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return m.default.factory.createTemplateLiteralType(m.default.factory.createTemplateHead(t[0]),[m.default.factory.createTemplateLiteralTypeSpan(t[1],m.default.factory.createTemplateTail(``))]);let n=m.default.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(m.default.factory.createTemplateLiteralTypeSpan(e,i?m.default.factory.createTemplateTail(n):m.default.factory.createTemplateMiddle(n)))}return m.default.factory.createTemplateLiteralType(n,r)}},ui=class extends T{"~dsl"=`LazyTsDsl`;_thunk;constructor(e){super(),this._thunk=e}analyze(e){super.analyze(e),e.analyze(this.toResult())}toResult(){return this._thunk(new Wt)}toAst(){return this.toResult().toAst()}};const di=m.default.createPrinter({newLine:m.default.NewLineKind.LineFeed,removeComments:!1}),fi=m.default.createSourceFile(``,``,m.default.ScriptTarget.ESNext,!1,m.default.ScriptKind.TS);function pi(e){let t=di.printNode(m.default.EmitHint.Unspecified,e,fi);try{return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}catch{return t}}const mi=({file:e,fromFile:t,preferFileExtension:n,root:r})=>{let i=e.finalPath.split(f.default.sep).join(`/`),a=t.finalPath.split(f.default.sep).join(`/`);if(t.external&&!f.default.isAbsolute(a))return[0,0,a];if(!a.startsWith(r.split(f.default.sep).join(`/`)))return[1,0,a];let o=f.default.relative(f.default.dirname(i),f.default.dirname(a)).split(f.default.sep).join(`/`),s;return o.startsWith(`..`)?(a=`${o}/${t.name}${t.extension??``}`,s=o.split(f.default.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 hi(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 gi=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 hi(t.header))n+=`${e}\n`;let r=``;for(let n of t.imports??[]){r&&(r+=`
5
+ `);for(let t of n)r+=`${pi(e.toImportAst(t))}\n`}n=`${n}${n&&r?`
6
+ `:``}${r}`;let i=``;for(let e of t.nodes??[])i&&(i+=`
7
+ `),i+=`${pi(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+=`${pi(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=>m.default.factory.createExportSpecifier(e.isTypeOnly,e.sourceName===e.exportedName?void 0:I.id(e.sourceName).toAst(),I.id(e.exportedName).toAst())),r=e.namespaceExport?m.default.factory.createNamespaceExport(I.id(e.namespaceExport).toAst()):(!e.canExportAll||!t?.preferExportAll)&&n.length?m.default.factory.createNamedExports(n):void 0;return m.default.factory.createExportDeclaration(void 0,e.isTypeOnly,r,I.literal(e.modulePath).toAst())}static toImportAst(e){let t=e.imports.map(e=>m.default.factory.createImportSpecifier(e.isTypeOnly,e.sourceName===e.localName?void 0:I.id(e.sourceName).toAst(),I.id(e.localName).toAst())),n=m.default.factory.createImportClause(e.isTypeOnly,e.kind===`default`?I.id(e.localName??``).toAst():void 0,e.kind===`namespace`?m.default.factory.createNamespaceImport(I.id(e.localName??``).toAst()):t.length>0?m.default.factory.createNamedImports(t):void 0);return m.default.factory.createImportDeclaration(void 0,n,I.literal(e.modulePath).toAst())}getExports(e){let t=new Map;for(let n of e.file.exports){let r=mi({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=mi({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 _i={array:(...e)=>new qn(...e),as:(...e)=>new Xn(...e),attr:(...e)=>new er(...e),await:(...e)=>new nr(...e),binary:(...e)=>new F(...e),block:(...e)=>new P(...e),call:(...e)=>new ir(...e),class:(...e)=>new Pn(...e),const:(...e)=>new Pr(...e).const(),decorator:(...e)=>new Pt(...e),doc:(...e)=>new Gt(...e),enum:(...e)=>new Rn(...e),expr:(...e)=>new or(...e),field:(...e)=>new gn(...e),fromValue:(...e)=>pr(...e),func:((e,t)=>e===void 0?new Vn:typeof e!=`string`||t===void 0?new Vn(e):new Vn(e,t)),getter:(...e)=>new Un(...e),hint:(...e)=>new sr(...e),id:(...e)=>new ct(...e),if:(...e)=>new Er(...e),init:(...e)=>new kn(...e),lazy:(...e)=>new ui(...e),let:(...e)=>new Pr(...e).let(),literal:(...e)=>new k(...e),member:(...e)=>new In(...e),method:(...e)=>new Mn(...e),neg:(...e)=>new ft(...e).neg(),new:(...e)=>new hr(...e),newline:(...e)=>new lt(...e),not:(...e)=>new ft(...e).not(),note:(...e)=>new wr(...e),object:(...e)=>new fr(...e),param:(...e)=>new wn(...e),pattern:(...e)=>new xn(...e),prefix:(...e)=>new ft(...e),prop:(...e)=>new ur(...e),regexp:(...e)=>new _r(...e),return:(...e)=>new Or(...e),setter:(...e)=>new Gn(...e),stmt:(...e)=>new vn(...e),template:(...e)=>new yr(...e),ternary:(...e)=>new xr(...e),throw:(...e)=>new Ar(...e),token:(...e)=>new N(...e),try:(...e)=>new Mr(...e),type:Object.assign((...e)=>new mn(...e),{alias:(...e)=>new Ir(...e),and:(...e)=>new Rr(...e),attr:(...e)=>new fn(...e),expr:(...e)=>new mn(...e),fromValue:(...e)=>Yr(...e),func:(...e)=>new Zr(...e),idx:(...e)=>new $r(...e),literal:(...e)=>new Br(...e),mapped:(...e)=>new ti(...e),object:(...e)=>new Kr(...e),operator:(...e)=>new ri(...e),or:(...e)=>new ai(...e),param:(...e)=>new an(...e),query:(...e)=>new si(...e),template:(...e)=>new li(...e),tuple:(...e)=>new Jr(...e)}),typeofExpr:(...e)=>new Cr(...e),var:(...e)=>new Pr(...e)},I=Object.assign((...e)=>new or(...e),_i),vi=/[\p{Lu}]/u,yi=/[\p{Ll}]/u,bi=/([\p{Alpha}\p{N}_]|$)/u,xi=/[_.$+:\- `\\[\](){}\\/]+/,Si=RegExp(`^${xi.source}`),Ci=RegExp(`${xi.source}${bi.source}`,`gu`),wi=RegExp(`\\d+${bi.source}`,`gu`),Ti=(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(xi.lastIndex=0;l&&xi.test(l);)c+=1,l=e[c];let u=c!==t+1;if(yi.lastIndex=0,vi.lastIndex=0,vi.test(s)&&(n||l&&!u&&l!==`s`&&yi.test(l)))e=`${e.slice(0,t)}${o}${e.slice(t)}`,t++,i=r,n=!1,r=!0;else if(r&&i&&yi.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},L=(e,t,n={})=>{let r=n.stripLeadingSeparators??!0,i=e.trim();return!i.length||!t||t===`preserve`?i:i.length===1?(xi.lastIndex=0,xi.test(i)?``:t===`PascalCase`||t===`SCREAMING_SNAKE_CASE`?i.toLocaleUpperCase():i.toLocaleLowerCase()):(i!==i.toLocaleLowerCase()&&(i=Ti(i,t)),(r||i[0]!==e[0])&&(i=i.replace(Si,``)),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(Ci,(e,t,n)=>n===0&&!r?e:`_${t}`),i[i.length-1]===`_`&&(i=i.slice(0,i.length-1))):(Ci.lastIndex=0,wi.lastIndex=0,i=i.replaceAll(wi,(e,t,n)=>[`_`,`-`,`.`].includes(i.charAt(n+e.length))?e:e.toLocaleUpperCase()),i=i.replaceAll(Ci,(t,n,i)=>i===0&&!r&&t[0]&&e.startsWith(t[0])?t:n.toLocaleUpperCase())),i)};function R(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 L(n,r)}const Ei=({plugin:e,sdkSymbol:t,symbol:n})=>{let r=e.symbol(`defaultKey`),i=e.symbol(`instances`);return I.class(n).generic(`T`).field(r,e=>e.private().readonly().assign(I.literal(`default`))).newline().field(i,e=>e.private().readonly().type(I.type(`Map`).generics(`string`,`T`)).assign(I.new(`Map`))).newline().method(`get`,e=>e.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(I.const(`instance`).assign(I(`this`).attr(i).attr(`get`).call(I(`key`).coalesce(I(`this`).attr(r)))),I.if(I.not(`instance`)).do(I.throw(`Error`).message(I.template(`No SDK client found. Create one with "new `).add(t).add(`()" to fix this error.`))),I.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(I(`this`).attr(i).attr(`set`).call(I(`key`).coalesce(I(`this`).attr(r)),`value`)))},Di=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return I.class(t).field(`client`,e=>e.protected().type(i)).newline().init(e=>e.param(`args`,e=>e.optional(r).type(I.type.object().prop(`client`,e=>e.optional(r).type(i)))).do(I(`this`).attr(`client`).assign(I(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n)))))},Oi=`TComposable`,ki=`DefaultT`,Ai=`ResT`,ji=({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}},Mi=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=ji({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},Ni=/~1/g,Pi=/~0/g,z=e=>{let t=Ii(e),n=t[t.length-1];return decodeURI(n)},Fi=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),Ii=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(Ni,`/`).replace(Pi,`~`)):[]},Li=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},Ri=e=>{let t=e.map(Fi).join(`/`);return`#`+(t?`/${t}`:``)},zi=({$ref:e,spec:t})=>{let n=Ii(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},Bi=({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(L(z(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=L(z(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}},Vi=({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})},Hi=({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})},Ui=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=x(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 I.type(o).generic(Oi).generic(e?a??`unknown`:`never`).generic(r??`unknown`).generic(ki)}return r?I.type(o).generic(e?a??`unknown`:`never`).generic(r):I.type(o).$if(!e||a,t=>t.generic(e?a:`never`))},Wi=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=x(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=Bi({operation:t,plugin:n}),a=I.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:(0,l.refs)({path:[]})})))}r.argNames.push(`parameters`);for(let t of e.fields)r.fields.push(t);r.parameters.push(I.param(`parameters`,e=>e.required(t).type(a)))}}return r.parameters.push(I.param(`options`,r=>r.required(e).type(Ui({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})))),r},Gi=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`}},Ki=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=x(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=I.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`,I.literal(null));break;case`url-search-params`:{let e=r.referenceSymbol({category:`external`,resource:`client.urlSearchParamsBodySerializer`});c.spread(e);break}}let l=I.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,I.object().prop(`array`,I.object().$if(t.explode===!1,e=>e.prop(`explode`,I.literal(t.explode))).$if(t.style!==`form`,e=>e.prop(`style`,I.literal(t.style))))):t.schema.type===`object`&&(t.style!==`deepObject`||!t.explode)&&l.prop(t.name,I.object().prop(`object`,I.object().$if(t.explode===!1,e=>e.prop(`explode`,I.literal(t.explode))).$if(t.style!==`deepObject`,e=>e.prop(`style`,I.literal(t.style)))))}l.hasProps()&&c.prop(`querySerializer`,I.object().prop(`parameters`,l));let u=Vi({operation:n,plugin:r}),d=Hi({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`,I(t))}}let f=!1,p;for(let e in n.responses){let t=n.responses[e];!p&&i.name===`@hey-api/client-axios`&&it({statusCode:e})===`2XX`&&(p=Gi(t.mediaType),p&&c.prop(`responseType`,I.literal(p))),t.mediaType===`text/event-stream`&&(f=!0)}d&&c.prop(`responseValidator`,d.arrow()),r.config.responseStyle===`data`&&c.prop(`responseStyle`,I.literal(r.config.responseStyle));let m=Mi({context:r.context,operation:n,plugin:r});m.length&&c.prop(`security`,I.fromValue(m)),c.prop(`url`,I.literal(n.path)),c.spread(`options`);let ee=[],h=t.argNames.length;if(h){let e=[],n=[];for(let n of t.argNames)e.push(I(n));for(let e of t.fields){let t=I.object();`in`in e&&t.prop(`in`,I.literal(e.in)),`key`in e&&(e.key&&t.prop(`key`,I.literal(e.key)),e.map&&t.prop(`map`,I.literal(e.map))),n.push(t)}let i=r.referenceSymbol({category:`external`,resource:`client.buildClientParams`});ee.push(I.const(`params`).assign(I(i).call(I.array(...e),I.array(I.object().prop(`args`,I.array(...n)))))),c.spread(`params`)}if(n.body){let t=n.parameters?.header?.[`content-type`];if(!t?.required){let r=I.object().pretty().prop(t?.name??`Content-Type`,I.literal(n.body.type===`form-data`?null:n.body.mediaType)).spread(I(`options`).attr(`headers`).required(e));h&&r.spread(I(`params`).attr(`headers`)),c.prop(`headers`,r)}}let te=r.config.client?r.getSymbol({category:`client`}):void 0,ne,re=I(`options`).attr(`client`).required(e);ne=Ji(r)?re.coalesce(I(`this`).attr(`client`)):te?re.coalesce(te):re;let ie=f?ne.attr(`sse`):ne;return ie=ie.attr(n.method),ee.push(I.return(ie.call(c).$if(a,e=>e.generic(Oi).generic(I.type.or(o??`unknown`,ki)).generic(s??`unknown`).generic(ki),e=>e.generic(o??`unknown`).generic(s??`unknown`).generic(`ThrowOnError`)).$if(r.config.responseStyle===`data`,e=>e.generic(I.type.literal(r.config.responseStyle))))),ee},qi=globalThis.Symbol(`@hey-api/sdk`);function Ji(e){let t=e.config.operations;return t.container===`class`&&t.methods===`instance`&&t.strategy!==`flat`}function Yi(e){let{node:t,operation:n}=e;return t.$if(ia(n),(e,t)=>e.doc(t))}function Xi(e){return{category:`utility`,resource:`class`,resourceId:e.getPath().join(`.`),tool:`sdk`}}function Zi(e,t){let{operation:n,path:r,tags:i}=t.data,a=t.location[t.location.length-1];return e.symbol(R(a,e.config.operations.methodName),{meta:{category:`sdk`,path:r,resource:`operation`,resourceId:n.id,tags:i,tool:`sdk`}})}function Qi(e,t){let n=t.referenceSymbol(Xi(e)),r=L(n.name,t.config.operations.methodName.casing??`camelCase`),i=t.symbol(r);if(Ji(t)){let e=t.symbol(`_${r}`);return[I.field(e,e=>e.private().optional().type(n)),I.getter(i,t=>t.returns(n).do(I(`this`).attr(e).nullishAssign(I.new(n).args(I.object().prop(`client`,I(`this`).attr(`client`)))).return()))]}return t.isSymbolRegistered(n.id)?[I.field(i,e=>e.static().assign(I(n)))]:[I.getter(i,e=>e.public().static().do(I.return(n)))]}function $i(e){let t=x(e.context.config).name===`@hey-api/client-angular`;return{define:n=>{let r=e.symbol(R(n.name,n.isRoot?e.config.operations.containerName:e.config.operations.segmentName),{meta:Xi(n)}),i=I.class(r).export().$if(Ji(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`),I.object().prop(`providedIn`,I.literal(`root`)))),a=[];return n.isRoot&&Ji(e)&&ea({dependencies:a,node:i,plugin:e,symbol:r}),{dependencies:a,node:i}}}}function ea(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(Di({plugin:r,symbol:a}));let o=r.symbol(`HeyApiRegistry`,{meta:{category:`utility`,resource:`class`,resourceId:`HeyApiRegistry`,tool:`sdk`}});t.push(Ei({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 I(e.name).attr(c).attr(`get`).call()},n.do(I.field(c,e=>e.public().static().readonly().assign(I.new(o).generic(i))),I.newline(),I.init(e=>e.param(`args`,e=>e.required(s).type(I.type.object().prop(`client`,e=>e.required(s).type(r.external(`client.Client`))).prop(`key`,e=>e.optional().type(`string`)))).do(I(`super`).call(`args`),I(i).attr(c).attr(`set`).call(`this`,I(`args`).attr(`key`).required(s)))))}function ta(e){let{node:t,operation:n,plugin:r}=e,i=x(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=aa({context:r.context,operation:n}),s=Wi({isRequiredOptions:o,operation:n,plugin:r}),c=Ki({isRequiredOptions:o,opParameters:s,operation:n,plugin:r});return t.$if(a,e=>e.generic(Oi,e=>e.extends(r.external(`client.Composable`)).default(I.type.literal(`$fetch`))).generic(ki,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 na(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(qi)){let{operation:e}=r.data,i=I.const(Zi(t,r)).export().assign(ta({node:I.func(),operation:e,plugin:t}));i=Yi({node:i,operation:e}),n.push(i)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=x(t.context.config).name===`@hey-api/client-angular`,i=e.shell.define(e),a=i.node,o=0;for(let n of e.itemsFrom(qi)){let{operation:e}=n.data;a[`~dsl`]===`VarTsDsl`||((o>0||a.hasBody)&&a.newline(),a.do(ta({node:I.method(Zi(t,n),n=>Yi({node:n,operation:e}).public().static(!r&&!Ji(t))),operation:e,plugin:t}))),o+=1}for(let n of e.children.values())a[`~dsl`]===`VarTsDsl`||(a.hasBody&&a.newline(),a.do(...Qi(n,t)));return n.push(a),{dependencies:i.dependencies,nodes:n}}const ra=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>ee.EOL+t.trim()),ia=e=>{let t=[];return e.summary&&t.push(ra(e.summary)),e.description&&(t.length&&t.push(``),t.push(ra(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},aa=({context:e,operation:t})=>{let n=x(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];if(r){if(!r.config.client&&!Ji(r))return!0;if(r.config.paramsStructure===`flat`)return!1}return n||nt(t)},oa=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},sa=globalThis.Symbol(`@angular/common`);function ca(e){let{node:t,operation:n}=e;return t.$if(ia(n),(e,t)=>e.doc(t))}function la(e){return{category:`utility`,resource:`operation`,resourceId:e.id,role:`request`,tool:`angular`}}function ua(e){return{category:`utility`,resource:`shell`,resourceId:e.getPath().join(`.`),role:`request`,tool:`angular`}}function da(e){return{category:`utility`,resource:`operation`,resourceId:e.id,role:`resource`,tool:`angular`}}function fa(e){return{category:`utility`,resource:`shell`,resourceId:e.getPath().join(`.`),role:`resource`,tool:`angular`}}function pa(e,t){let{operation:n}=t.data,r=t.location[t.location.length-1];return e.symbol(R(r,e.config.httpRequests.methodName),{meta:la(n)})}function ma(e,t){let{operation:n}=t.data,r=t.location[t.location.length-1];return e.symbol(R(r,e.config.httpResources.methodName),{meta:da(n)})}function ha(e,t){let n=t.referenceSymbol(ua(e)),r=L(n.name,`camelCase`),i=t.symbol(r),a=t.symbol(`_${r}`);return[I.field(a,e=>e.private().optional().type(n)),I.getter(i,e=>e.returns(n).do(I(`this`).attr(a).nullishAssign(I.new(n).args()).return()))]}function ga(e,t){let n=t.referenceSymbol(fa(e)),r=L(n.name,`camelCase`),i=t.symbol(r),a=t.symbol(`_${r}`);return[I.field(a,e=>e.private().optional().type(n)),I.getter(i,e=>e.returns(n).do(I(`this`).attr(a).nullishAssign(I.new(n).args()).return()))]}function _a(e){let t=x(e.context.config).name===`@hey-api/client-angular`,n=e.external(`@angular/core.Injectable`);return{define:r=>{let i=e.symbol(R(r.name,r.isRoot?e.config.httpRequests.containerName:e.config.httpRequests.segmentName),{meta:ua(r)});return{dependencies:[],node:I.class(i).export().$if(t&&r.isRoot,e=>e.decorator(n,I.object().prop(`providedIn`,I.literal(`root`))))}}}}function va(e){let t=x(e.context.config).name===`@hey-api/client-angular`,n=e.external(`@angular/core.Injectable`);return{define:r=>{let i=e.symbol(R(r.name,r.isRoot?e.config.httpResources.containerName:e.config.httpResources.segmentName),{meta:fa(r)});return{dependencies:[],node:I.class(i).export().$if(t&&r.isRoot,e=>e.decorator(n,I.object().prop(`providedIn`,I.literal(`root`))))}}}}function ya(e){let{node:t,operation:n,plugin:r}=e,i=aa({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(I.type(s).generic(c??`unknown`).generic(`ThrowOnError`))).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).returns(I.type(a).generic(`unknown`)).do(I.return(I(`options`).attr(`client`).optional().$if(o,(e,t)=>e.coalesce(t)).attr(`requestOptions`).call(I.object().prop(`responseStyle`,I.literal(`data`)).prop(`method`,I.literal(n.method.toUpperCase())).prop(`url`,I.literal(n.path)).spread(`options`))))}function ba(e){let{node:t,operation:n,plugin:r}=e,i=aa({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(I.type.func().returns(I.type.or(I.type(s).generic(c??`unknown`).generic(`ThrowOnError`),I.type(`undefined`))))).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).do(I.return(I(a).call(I.func().do(I.const(`opts`).assign(I.ternary(`options`).do(I(`options`).call()).otherwise(I.id(`undefined`))),I.return(I.ternary(`opts`).do(I.lazy(e=>e.access(r.referenceSymbol(la(n)),{transform:(e,t)=>t===0?e[`~dsl`]===`ClassTsDsl`?I(o).call(I(e.name)):I(e.name):e}).call(`opts`))).otherwise(I.id(`undefined`))))).generic(l??`unknown`)))}function xa(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(sa)){let{operation:e}=r.data,i=I.const(pa(t,r)).export().assign(ya({node:I.func(),operation:e,plugin:t}));i=ca({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(sa)){let{operation:e}=n.data;(a>0||i.hasBody)&&i.newline(),i.do(ya({node:I.method(pa(t,n),t=>ca({node:t,operation:e}).public()),operation:e,plugin:t})),a+=1}for(let n of e.children.values())i.hasBody&&i.newline(),i.do(...ha(n,t));return n.push(i),{dependencies:r.dependencies,nodes:n}}function Sa(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(sa)){let{operation:e}=r.data,i=I.const(ma(t,r)).export().assign(ba({node:I.func(),operation:e,plugin:t}));i=ca({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(sa)){let{operation:e}=n.data;(a>0||i.hasBody)&&i.newline(),i.do(ba({node:I.method(ma(t,n),t=>ca({node:t,operation:e}).public()),operation:e,plugin:t})),a+=1}for(let n of e.children.values())i.hasBody&&i.newline(),i.do(...ga(n,t));return n.push(i),{dependencies:r.dependencies,nodes:n}}const Ca=({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 l.StructureModel,n=new l.StructureModel;if(e.config.httpRequests.enabled){let n=_a(e),r=qe(e);e.forEach(`operation`,({operation:e})=>{t.insert({data:{operation:e},locations:r(e).map(e=>({path:e,shell:n})),source:sa})},{order:`declarations`})}if(e.config.httpResources.enabled){let t=va(e),r=Xe(e);e.forEach(`operation`,({operation:e})=>{n.insert({data:{operation:e},locations:r(e).map(e=>({path:e,shell:t})),source:sa})},{order:`declarations`})}let r=[],i=[];for(let n of t.walk()){let{dependencies:t,nodes:a}=xa(n,e);r.push(...t??[]),i.push(...a)}for(let t of n.walk()){let{dependencies:n,nodes:a}=Sa(t,e);r.push(...n??[]),i.push(...a)}let a=new Map;for(let e of r)e.symbol&&a.set(e.symbol.id,e);for(let t of a.values())e.node(t);for(let t of i)e.node(t)},wa={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:Ca,name:`@angular/common`,resolveConfig:(e,t)=>{e.config.httpRequests=Ge(e.config,t),e.config.httpResources=Je(e.config,t)}},Ta=_(wa),Ea={baseUrl:!0,bundle:!0,exportFromIndex:!1},Da={dependencies:[`@hey-api/typescript`],tags:[`client`]},Oa=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),ka=f.default.dirname(Oa),Aa=e=>{let t=x(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return f.default.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},ja=(e,t)=>{if(d.default.statSync(e).isDirectory()){d.default.existsSync(t)||d.default.mkdirSync(t,{recursive:!0});let n=d.default.readdirSync(e);for(let r of n)ja(f.default.join(e,r),f.default.join(t,r))}else{let n=d.default.readFileSync(e);d.default.writeFileSync(t,n)}},Ma=({filePath:e,project:t,renamed:n})=>{let r=f.default.extname(e),i=f.default.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=f.default.dirname(e);d.default.renameSync(e,f.default.resolve(t,`${a}${r}`)),n.set(i,a)}},Na=({filePath:e,meta:t,renamed:n})=>{let r=d.default.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=f.default.extname(r),o=f.default.basename(r,a),s=f.default.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}`,d.default.writeFileSync(e,r,`utf8`)},Pa=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=f.default.resolve(t,`core`);ce(a),ja(f.default.resolve(ka,`clients`,`core`),a);let o=f.default.resolve(t,`client`);ce(o);let s=n.name.slice(16);if(ja(f.default.resolve(ka,`clients`,s),o),r){let e=d.default.readdirSync(a);for(let t of e)Ma({filePath:f.default.resolve(a,t),project:r,renamed:i});let t=d.default.readdirSync(o);for(let e of t)Ma({filePath:f.default.resolve(o,e),project:r,renamed:i})}let c=d.default.readdirSync(a);for(let t of c)Na({filePath:f.default.resolve(a,t),meta:e,renamed:i});let l=d.default.readdirSync(o);for(let t of l)Na({filePath:f.default.resolve(o,t),meta:e,renamed:i});return i}let a=f.default.isAbsolute(n.name)?f.default.dirname(n.name):void 0;if(a){let e=f.default.resolve(t,`client`);ce(e),ja(a,e);return}let o=f.default.normalize(require.resolve(n.name)).split(f.default.sep),s=o.slice(0,o.indexOf(`dist`)+1).join(f.default.sep),c=[o[o.length-1],`index.d.mts`,`index.d.cts`],l=f.default.resolve(t,`client`);ce(l);for(let e of c)d.default.copyFileSync(f.default.resolve(s,e),f.default.resolve(l,e))},Fa=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Ia=e=>{let t={host:``,path:``,port:``,protocol:``};Fa.lastIndex=0;let n=e.match(Fa);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}},La=({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},Ra=({plugin:e})=>{let t=Aa(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=I.object(),c=La({plugin:e});if(c){let t=Ia(c);if(t.protocol&&t.host&&!c.includes(`{`))s.prop(Ze(e.context.config),I.literal(c));else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.prop(Ze(e.context.config),I.literal(t))}}`throwOnError`in e.config&&e.config.throwOnError&&s.prop(`throwOnError`,I.literal(!0));let l=[I(r).call(s.hasProps()?s:void 0).generic(i)],u=e.symbol(`client`,{meta:{category:`client`}}),d=I.const(u).export().assign(I(n).$if(o,(e,t)=>e.call(I(t).call(...l)),e=>e.call(...l)));e.node(d)},za=({plugin:e})=>{let t=Aa(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=I.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(I.type.func().param(`override`,e=>e.optional().type(I.type(r).generic(I.type.and(i,`T`)))).returns(I.type(r).generic(I.type.and(I.type(`Required`).generic(i),`T`))));e.node(o)},Ba=({plugin:e})=>{za({plugin:e}),Ra({plugin:e})},Va={...Da,config:{...Ea,throwOnError:!1},handler:Ba,name:`@hey-api/client-angular`},Ha=_(Va),Ua={...Da,config:{...Ea,throwOnError:!1},handler:Ba,name:`@hey-api/client-axios`},Wa=_(Ua),Ga={...Da,config:{...Ea,throwOnError:!1},handler:Ba,name:`@hey-api/client-fetch`},Ka=_(Ga),qa={...Da,config:{...Ea,throwOnError:!1},handler:Ba,name:`@hey-api/client-ky`},Ja=_(qa),Ya={...Da,config:{...Ea,throwOnError:!1},handler:Ba,name:`@hey-api/client-next`},Xa=_(Ya),Za={...Da,config:Ea,handler:Ba,name:`@hey-api/client-nuxt`},Qa=_(Za),$a={...Da,config:{...Ea,throwOnError:!1},handler:Ba,name:`@hey-api/client-ofetch`},eo=_($a),to=(...e)=>h.satisfies(...e),no=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=h.parse(n);if(e)return e;let t=h.minVersion(n);if(t)return t;if(e=h.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?to(i,n,r):!1}}),ro=({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)},io=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>io({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(ro({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=io({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>io({context:e,plugin:t,schema:n})),r.items&&=io({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]=io({context:e,plugin:t,schema:i}))}return r},ao=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>ao({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(ro({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=ao({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>ao({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>ao({context:e,plugin:t,schema:n})),r.items&&=ao({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>ao({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]=ao({context:e,plugin:t,schema:i}))}return r},oo=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>oo({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(ro({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=oo({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>oo({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>oo({context:e,plugin:t,schema:n})),r.items&&=oo({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>oo({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>oo({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]=oo({context:e,plugin:t,schema:i}))}return r},so=({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},co=({context:e,plugin:t})=>{if(e.spec.definitions)for(let n in e.spec.definitions){let r=e.spec.definitions[n],i=t.symbol(so({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=io({context:e,plugin:t,schema:r}),o=I.const(i).export().assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},lo=({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(so({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=ao({context:e,plugin:t,schema:r}),o=I.const(i).export().assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},uo=({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(so({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=oo({context:e,plugin:t,schema:r}),o=I.const(i).export().assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},fo=({plugin:e})=>{if(`swagger`in e.context.spec){co({context:e.context,plugin:e});return}if(to(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){lo({context:e.context,plugin:e});return}if(to(e.context.spec.openapi,`>=3.1.0`)){uo({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},po={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:fo,name:`@hey-api/schemas`},mo=_(po);function ho(e,t){e.asClass!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`asClass`,replacement:[`operations: { strategy: "byTags" }`,`operations: { strategy: "single" }`]}),e.classNameBuilder!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`classNameBuilder`,replacement:`operations: { containerName: "..." }`}),e.classStructure!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`classStructure`,replacement:[`operations: { nesting: "operationId" }`,`operations: { nesting: "id" }`]}),e.instance!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`instance`,replacement:`operations: { strategy: "single", containerName: "${e.instance||`Name`}", methods: "instance" }`}),e.methodNameBuilder!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`methodNameBuilder`,replacement:`operations: { methodName: "..." }`}),e.operationId!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`operationId`,replacement:[`operations: { nesting: "operationId" }`,`operations: { nesting: "id" }`]});let n=_o(e);return go(e.operations,n,t)}function go(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 _o(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 vo(e){return e.config.operations.nesting===`id`?b.id():e.config.operations.nesting===`operationId`?b.fromOperationId({delimiters:e.config.operations.nestingDelimiters,fallback:b.id()}):e.config.operations.nesting}function yo(e){if(e.config.operations.strategy===`flat`)return y.flat({path:t=>[vo(e)(t).join(`.`)]});if(e.config.operations.strategy===`single`){let t=e.config.operations.containerName;return y.single({path:vo(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.operations.strategy===`byTags`?y.byTags({fallback:e.config.operations.strategyDefaultTag,path:vo(e)}):e.config.operations.strategy}const bo=({plugin:e})=>{let t=Aa(e.context.config),n=x(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=I.type.alias(s).export().$if(r,t=>t.generic(`TComposable`,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`})).default(I.type.literal(`$fetch`))).generic(`TData`,e=>e.extends(i).default(i)).generic(Ai,e=>e.default(`unknown`)).generic(ki,e=>e.default(`undefined`)),e=>e.generic(`TData`,e=>e.extends(i).default(i)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(`boolean`))).type(I.type.and(I.type(o).$if(r,e=>e.generic(`TComposable`).generic(`TData`).generic(Ai).generic(ki),e=>e.generic(`TData`).generic(`ThrowOnError`)),I.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&&!Ji(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(I.type(`Record`).generics(`string`,`unknown`)))));e.node(c)},xo=({plugin:e})=>{let t=Aa(e.context.config),n=x(e.context.config),r=n.name===`@hey-api/client-angular`,i=n.name===`@hey-api/client-nuxt`;e.symbol(`formDataBodySerializer`,{external:t,meta:{category:`external`,resource:`client.formDataBodySerializer`,tool:n.name}}),e.symbol(`urlSearchParamsBodySerializer`,{external:t,meta:{category:`external`,resource:`client.urlSearchParamsBodySerializer`,tool:n.name}}),e.symbol(`buildClientParams`,{external:t,meta:{category:`external`,resource:`client.buildClientParams`,tool:n.name}}),i&&e.symbol(`Composable`,{external:t,kind:`type`,meta:{category:`external`,resource:`client.Composable`,tool:n.name}}),r&&e.symbol(`Injectable`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`}}),bo({plugin:e});let a=new l.StructureModel,o=$i(e),s=yo(e);e.forEach(`operation`,e=>{a.insert({data:{operation:e.operation,path:e._path,tags:e.tags},locations:s(e.operation).map(e=>({path:e,shell:o})),source:qi})},{order:`declarations`});let c=[],u=[];for(let t of a.walk()){let{dependencies:n,nodes:r}=na(t,e);c.push(...n??[]),u.push(...r)}let d=new Map;for(let e of c)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)},So=e=>xo(e),Co={config:{auth:!0,client:!0,exportFromIndex:!0,paramsStructure:`grouped`,responseStyle:`fields`,transformer:!1,validator:!1,response:`body`},dependencies:[`@hey-api/typescript`],handler:So,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=ho(e.config,t)}},wo=_(Co),To=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:I(`BigInt`).call(I.expr(e).attr(`toString`).call());if(n){if(typeof e==`string`)return[n];if(e)return[I.expr(e).assign(n)]}},Eo=({dataExpression:e,schema:t})=>{if(!(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))){if(typeof e==`string`)return[I.new(`Date`).arg(e)];if(e)return[I.expr(e).assign(I.new(`Date`).arg(e))]}},Do=`data`,Oo=new Set,ko=e=>e[`~dsl`]===`ReturnTsDsl`,Ao=({plugin:e,schema:t})=>{let n=jo({dataExpression:I(Do),plugin:e,schema:t});if(n.length){let e=n[n.length-1];ko(e)||n.push(I.return(Do))}return n},jo=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r={category:`transform`,resource:`definition`,resourceId:n.$ref},i=t.getSymbol(r)??t.symbol(R(z(n.$ref),{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`}),{meta:r});if(!i.node&&!Oo.has(i.id)){Oo.add(i.id);try{let e=Ao({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=I.const(i).assign(I.func().param(Do,e=>e.type(`any`)).do(...e));t.node(n)}}finally{Oo.delete(i.id)}}if(i.node||Oo.has(i.id)){let n=I(t.referenceSymbol(r)).call(e);if(e)return typeof e==`string`&&e===`item`?[I.return(n)]:[typeof e==`string`?n:I(e).assign(n)]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?jo({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=>ko(e))||i.push(I.return(`item`)),[I(e).assign(I(e).attr(`map`).call(I.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=I(e||Do).attr(a),c=jo({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(I.if(s).do(...c))}return r}if(n.items){if(n.items.length===1)return jo({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=jo({dataExpression:e||`item`,plugin:t,schema:i});n.length&&(e?r=r.concat(n):r.push(I.if(`item`).do(...n),I.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[]},Mo=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=at(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${w(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`});if(!r)return;let i=Ao({plugin:e,schema:n});if(!i.length)return;let a=e.symbol(R(t.id,{case:`camelCase`,name:`{{name}}ResponseTransformer`}),{meta:{category:`transform`,resource:`operation`,resourceId:t.id,role:`response`}}),o=I.const(a).export().assign(I.func().async().param(Do,e=>e.type(`any`)).returns(I.type(`Promise`).generic(r)).do(...i));e.node(o)},{order:`declarations`})},No={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:Mo,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Eo]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,To])},tags:[`transformer`]},Po=_(No),Fo=({server:e})=>{let t=Ia(e.url);return t.protocol&&t.host?I.type.literal(e.url):I.type.template().add(t.protocol||I.type(`string`)).add(`://`).add(t.host||I.type(`string`)).add(t.port?`:${t.port}`:``).add(t.path||``)},Io=({nodeIndex:e,plugin:t,servers:n})=>{let r=x(t.context.config),i=n.map(e=>Fo({server:e}));n.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(I.type.and(I.type(`string`),I.type.object())):i.push(I.type(`string`));let a=t.symbol(R(`ClientOptions`,{case:t.config.case}),{meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`}}),o=I.type.alias(a).export().type(I.type.object().prop(Ze(t.context.config),e=>e.type(I.type.or(...i))));t.node(o,e)},B=e=>{let t=[];return e.title&&t.push(ra(e.title)),e.description&&(t.length&&t.push(``),t.push(ra(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Lo=({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=L(a,e.config.enums.case,{stripLeadingSeparators:!1}),A.number.lastIndex=0,A.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}},Ro=({plugin:e,schema:t,state:n,type:r})=>{let i=Ri((0,l.fromRef)(n.path));if(t.type===`enum`&&e.config.enums.enabled){let r=Lo({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&r.typeofItems.includes(`object`)&&(r.obj=r.obj.filter(e=>e.schema.const!==null));let a=e.symbol(R(z(i),e.config.definitions),{meta:{category:`utility`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.const(a).export().$if(B(t),(e,t)=>e.doc(t)).assign(I.object(...r.obj.map(e=>I.prop({kind:`prop`,name:e.key}).$if(B(e.schema),(e,t)=>e.doc(t)).value(I.fromValue(e.schema.const)))).as(`const`));e.node(o);let s=e.symbol(R(z(i),e.config.definitions),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),c=I.type.alias(s).export().$if(B(t),(e,t)=>e.doc(t)).type(I.type(s).idx(I.type(s).typeofType().keyof()).typeofType());e.node(c);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let a=e.symbol(R(z(i),e.config.definitions),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.enum(a).export().$if(B(t),(e,t)=>e.doc(t)).const(e.config.enums.mode===`typescript-const`).members(...r.obj.map(e=>I.member(e.key).$if(B(e.schema),(e,t)=>e.doc(t)).value(I.fromValue(e.schema.const))));e.node(o);return}}let a=e.symbol(R(z(i),e.config.definitions),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().$if(B(t),(e,t)=>e.doc(t)).type(r);e.node(o)},zo=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=S({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Bo=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=zo({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=zo({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=zo({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.symbol(R(e.id,t.config.requests),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`data`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().type(V({plugin:t,schema:r,state:n}));t.node(o)},Vo=({operation:e,plugin:t,state:n})=>{Bo({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=at(e);if(i){let a=t.symbol(R(e.id,t.config.errors),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`errors`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().type(V({plugin:t,schema:i,state:n}));if(t.node(o),r){let r=t.symbol(R(e.id,{case:t.config.errors.case,name:t.config.errors.error}),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`error`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),i=I.type.alias(r).export().type(I.type(a).idx(I.type(a).keyof()));t.node(i)}}if(o){let r=t.symbol(R(e.id,t.config.responses),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`responses`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),i=I.type.alias(r).export().type(V({plugin:t,schema:o,state:n}));if(t.node(i),a){let i=t.symbol(R(e.id,{case:t.config.responses.case,name:t.config.responses.response}),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`response`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),a=I.type.alias(i).export().type(I.type(r).idx(I.type(r).keyof()));t.node(a)}}},Ho=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.symbol(R(e.id,{case:t.config.webhooks.case,name:t.config.webhooks.payload}),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`webhook`,resourceId:e.id,role:`data`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().$if(B(e.body.schema),(e,t)=>e.doc(t)).type(V({plugin:t,schema:e.body.schema,state:n}));t.node(o),r.properties.body={symbolRef:a},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.symbol(R(e.id,t.config.webhooks),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`webhook`,resourceId:e.id,role:`data`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().type(V({plugin:t,schema:r,state:n}));return t.node(o),a},Uo=({operation:e,plugin:t,state:n})=>Ho({operation:e,plugin:t,state:n}),Wo=({plugin:e,schema:t,state:n})=>{if(!t.items)return I.type(`Array`).generic(I.type(e.config.topType));t=S({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=V({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});r.push(a)}),r.length===1?I.type(`Array`).generic(r[0]):t.logicalOperator===`and`?I.type(`Array`).generic(I.type.and(...r)):I.type(`Array`).generic(I.type.or(...r))},Go=({schema:e})=>e.const===void 0?I.type(`boolean`):I.type.literal(e.const),Ko=({plugin:e,schema:t,state:n})=>V({plugin:e,schema:{...t,type:void 0},state:n}),qo=e=>I.type(`never`),Jo=e=>I.type.literal(null),Yo=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?I.type(`bigint`):I.type(`number`):I.type.literal(t.const),Xo=({plugin:e,schema:t,state:n})=>{let r=I.type.object(),i=t.required??[],a=[],o=!1;for(let s in t.properties){let c=t.properties[s],u=V({plugin:e,schema:c,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`properties`,s])}}),d=i.includes(s);r.prop(s,e=>e.$if(B(c),(e,t)=>e.doc(t)).readonly(c.accessScope===`read`).required(d).type(u)),a.push(c),d||(o=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];a.unshift(n)}let s=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,c=t.additionalProperties,u=c!==!1&&c?c:void 0;if(s||u&&(u.type!==`never`||!a.length)){let i=u;i&&i.type!==`never`?a.unshift(i):!s&&!a.length&&i&&i.type===`never`&&(a=[i]),o&&a.push({type:`undefined`});let c=a.length===1?V({plugin:e,schema:a[0],state:n}):V({plugin:e,schema:{items:a,logicalOperator:`or`},state:n});if(t.propertyNames?.$ref)return I.type.mapped(`key`).key(V({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n})).optional().type(c);r.idxSig(`key`,e=>e.key(`string`).type(c))}return r},Zo=({plugin:e,schema:t})=>{if(t.const!==void 0)return I.type.literal(t.const);if(t.format){if(t.format===`binary`)return I.type.or(I.type(`Blob`),I.type(`File`));if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return I.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=I.type.alias(n).export().generic(`T`,e=>e.extends(`string`)).type(I.type.template().add(I.type(`T`)).add(`_`).add(I.type(`string`)));e.node(r)}let n=e.referenceSymbol(t),a=e.symbol(L(`${r}_id`,e.config.case),{meta:i}),o=I.type.alias(a).export().type(I.type(n).generic(I.type.literal(r)));e.node(o)}let a=e.referenceSymbol(i);return I.type(a)}}return I.type(`string`)},Qo=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(e=>I.type.fromValue(e)):t.items&&t.items.forEach((t,i)=>{let a=V({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});r.push(a)}),I.type.tuple(...r)},$o=e=>I.type(`undefined`),es=({plugin:e})=>I.type(e.config.topType),ts=e=>I.type(`void`),ns=({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 Wo({...t,schema:e});case`boolean`:return Go({...t,schema:e});case`enum`:return Ko({...t,schema:e});case`integer`:case`number`:return Yo({...t,schema:e});case`never`:return qo({...t,schema:e});case`null`:return Jo({...t,schema:e});case`object`:return Xo({...t,schema:e});case`string`:return Zo({...t,schema:e});case`tuple`:return Qo({...t,schema:e});case`undefined`:return $o({...t,schema:e});case`unknown`:return es({...t,schema:e});case`void`:return ts({...t,schema:e})}},V=({plugin:e,schema:t,state:n})=>{if(t.symbolRef){let e=I.type(t.symbolRef);if(t.omit&&t.omit.length>0){let n=t.omit.length===1?I.type.literal(t.omit[0]):I.type.or(...t.omit.map(e=>I.type.literal(e)));return I.type(`Omit`).generics(e,n)}return e}if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref}),r=I.type(n);if(t.omit&&t.omit.length>0){let e=t.omit.length===1?I.type.literal(t.omit[0]):I.type.or(...t.omit.map(e=>I.type.literal(e)));return I.type(`Omit`).generics(r,e)}return r}if(t.type)return ns({plugin:e,schema:t,state:n});if(t.items){if(t=S({detectFormat:!1,schema:t}),t.items){let r=t.items.map(t=>V({plugin:e,schema:t,state:n}));return t.logicalOperator===`and`?I.type.and(...r):I.type.or(...r)}return V({plugin:e,schema:t,state:n})}return ns({plugin:e,schema:{type:`unknown`},state:n})},rs=({plugin:e,schema:t,state:n})=>{Ro({plugin:e,schema:t,state:n,type:V({plugin:e,schema:t,state:n})})},is=({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=(0,l.refs)({path:t._path,tags:t.tags});switch(t.type){case`operation`:Vo({operation:t.operation,plugin:e,state:n});break;case`parameter`:rs({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:rs({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:rs({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(Uo({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),Io({nodeIndex:t,plugin:e,servers:r}),i.length>0){let t=e.symbol(R(`Webhooks`,{case:e.config.case}),{meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`}}),r=I.type.alias(t).export().type(I.type.or(...i));e.node(r,n)}};var as=class{schemaToType(e){return V(e)}};const os=e=>is(e),ss={api:new as,config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:os,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})}},cs=_(ss),ls=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.fromValue(i)},us=({operation:e,plugin:t})=>Ui({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),ds=({operation:e,plugin:t})=>{let n=x(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 I.type(e).generic(r)}return I.type(r)},fs=({operation:e,plugin:t})=>{let n=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`});return I.type(n??`unknown`)},ps=({isNuxtClient:e,operation:t,plugin:n})=>{let r=us({operation:t,plugin:n});return e?I.type(`Omit`).generic(r).generic(`composable`):r},ms=({operation:e,plugin:t})=>{let n=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),r=x(t.context.config).name===`@hey-api/client-nuxt`,i=ps({isNuxtClient:r,operation:e,plugin:t}),a=t.symbol(`options`),o=t.symbol(`vars`),s=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().pretty().spread(a).spread(o).prop(`throwOnError`,I.literal(!0))).await()),c=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?c.push(I.return(s)):c.push(I.const().object(`data`).assign(s),I.return(`data`));let l=I.object().pretty().prop(`mutation`,I.func().async().param(o,e=>e.$if(r,e=>e.type(I.type(`Partial`).generic(i)))).do(...c)).$if(ls(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t)),u=t.symbol(R(e.id,t.config.mutationOptions)),d=I.const(u).export().$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I.func().param(a,e=>e.optional().type(I.type(`Partial`).generic(i))).returns(I.type(n).generic(fs({operation:e,plugin:t})).generic(i).generic(ds({operation:e,plugin:t}))).do(I.return(l)));t.node(d)},hs=`TOptions`,gs=({plugin:e})=>{let t=e.symbol(R(`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=I.type(n).generic(hs).idx(0),a=Ze(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=Aa(e.context.config),l=e.symbol(`serializeQueryKeyValue`,{external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`}}),u=I.const(t).assign(I.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(hs)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).returns(I.type.tuple(i)).generic(hs,e=>e.extends(o)).do(I.const(`params`).type(i).assign(I.object().prop(`_id`,`id`).prop(a,I(`options`).attr(a).optional().or(I(`options`).attr(`client`).optional().$if(s,(e,t)=>e.coalesce(t)).attr(`getConfig`).call().attr(a))).as(i)),I.if(`tags`).do(I(`params`).attr(`tags`).assign(I(`tags`).as(`unknown`).as(r))),I.if(I(`options`).attr(`body`).optional().neq(I.id(`undefined`))).do(I.const(`normalizedBody`).assign(I(l).call(I(`options`).attr(`body`))),I.if(I(`normalizedBody`).neq(I.id(`undefined`))).do(I(`params`).attr(`body`).assign(`normalizedBody`))),I.if(I(`options`).attr(`path`).optional()).do(I(`params`).attr(`path`).assign(I(`options`).attr(`path`))),I.if(I(`options`).attr(`query`).optional().neq(I.id(`undefined`))).do(I.const(`normalizedQuery`).assign(I(l).call(I(`options`).attr(`query`))),I.if(I(`normalizedQuery`).neq(I.id(`undefined`))).do(I(`params`).attr(`query`).assign(`normalizedQuery`))),I.return(I.array(I(`params`)))));e.node(u)},_s=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;return r.tags&&t.tags&&t.tags.length>0&&(i=I.array(...t.tags.map(e=>I.literal(e)))),I(n.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:n.name})).call(I.literal(e),`options`,i)},vs=({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=I.type.alias(r).export().generic(hs,e=>e.extends(I.type(n))).type(I.type.tuple(I.type.and(I.type(`Pick<${hs}, 'path'>`),I.type.object().prop(`_id`,e=>e.type(`string`)).prop(Ze(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)},ys=({operation:e,plugin:t,symbol:n})=>{let r=x(t.context.config).name===`@hey-api/client-nuxt`;return I.const(n).export().assign(I.func().param(`options`,n=>n.required(nt(e)).type(ps({isNuxtClient:r,operation:e,plugin:t}))).do(_s({id:e.id,operation:e,plugin:t}).return()))},bs=`options`,xs=`context`,Ss=({operation:e,plugin:t})=>{if(oa({operation:e}))return;let n=aa({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(vs({plugin:t}),gs({plugin:t}));let r;if(t.config.queryKeys.enabled){let n=t.symbol(R(e.id,t.config.queryKeys)),i=ys({operation:e,plugin:t,symbol:n});t.node(i),r=I(n).call(bs)}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),i;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(i=I.array(...e.tags.map(e=>I.literal(e)))),r=I(n).call(I.literal(e.id),bs,i)}let i=ps({isNuxtClient:x(t.context.config).name===`@hey-api/client-nuxt`,operation:e,plugin:t}),a=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(bs).spread(xs).prop(`throwOnError`,I.literal(!0))).await()),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(I.return(a)):o.push(I.const().object(`data`).assign(a),I.return(`data`));let s=I.object().pretty().prop(`key`,r).prop(`query`,I.func().async().param(xs).do(...o)).$if(ls(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),c=t.symbol(R(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=I.const(c).export().$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I(l).call(I.func().param(bs,e=>e.required(n).type(i)).do(I.return(s))));t.node(u)},Cs=({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&&Ss({operation:t,plugin:e}),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&ms({operation:t,plugin:e})},{order:`declarations`})},ws=e=>Cs(e),Ts={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:ws,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=_(Ts),Ds=({operation:e,plugin:t})=>Ui({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Os=({operation:e,plugin:t})=>{let n=x(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 I.type(e).generic(r)}return I.type(r)},ks=({operation:e,plugin:t})=>{let n=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`});return I.type(n??`unknown`)},As=`TOptions`,js=({plugin:e})=>{let t=e.symbol(R(`createQueryKey`,{case:e.config.case}),{meta:{category:`utility`,resource:`createQueryKey`,tool:e.name}}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=Ze(e.context.config),i=e.getSymbol({category:`client`}),a=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=I.type(n).generic(As).idx(0),s=I.const(t).assign(I.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(As)).param(`infinite`,e=>e.optional().type(`boolean`)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).generic(As,e=>e.extends(a)).returns(I.type.tuple(o)).do(I.const(`params`).type(o).assign(I.object().prop(`_id`,`id`).prop(r,I(`options`).attr(r).optional().or(I(`options`).attr(`client`).optional().$if(i,(e,t)=>e.coalesce(t)).attr(`getConfig`).call().attr(r))).as(o)),I.if(`infinite`).do(I(`params`).attr(`_infinite`).assign(`infinite`)),I.if(`tags`).do(I(`params`).attr(`tags`).assign(`tags`)),I.if(I(`options`).attr(`body`).optional()).do(I(`params`).attr(`body`).assign(I(`options`).attr(`body`))),I.if(I(`options`).attr(`headers`).optional()).do(I(`params`).attr(`headers`).assign(I(`options`).attr(`headers`))),I.if(I(`options`).attr(`path`).optional()).do(I(`params`).attr(`path`).assign(I(`options`).attr(`path`))),I.if(I(`options`).attr(`query`).optional()).do(I(`params`).attr(`query`).assign(I(`options`).attr(`query`))),I.return(I.array().element(I(`params`)))));e.node(s)},Ms=({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=I.array().elements(...n.tags)),I(r.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:r.name})).call(I.literal(e),`options`,t||a?I.literal(!!t):void 0,a)},Ns=({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=I.type.alias(n).export().generic(As,e=>e.extends(t)).type(I.type.tuple(I.type.and(I.type(`Pick<${As}, '${Ze(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`),I.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)},Ps=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Ds({operation:t,plugin:n});return I.const(r).export().assign(I.func().param(`options`,e=>e.required(nt(t)).type(a)).$if(e&&i,(e,t)=>e.returns(t)).do(Ms({id:t.id,isInfinite:e,operation:t,plugin:n}).return()))},Fs=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.fromValue(i)},Is=({plugin:e})=>{let t=e.symbol(R(`createInfiniteParams`,{case:e.config.case}),{meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name}}),n=I.const(t).assign(I.func().generic(`K`,e=>e.extends(I.type(`Pick`).generics(I.type(`QueryKey`).generic(`Options`).idx(0),I.type.or(I.type.literal(`body`),I.type.literal(`headers`),I.type.literal(`path`),I.type.literal(`query`))))).param(`queryKey`,e=>e.type(`QueryKey<Options>`)).param(`page`,e=>e.type(`K`)).do(I.const(`params`).assign(I.object().spread(I(`queryKey`).attr(0))),I.if(I(`page`).attr(`body`)).do(I(`params`).attr(`body`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`body`).as(`any`)).spread(I(`page`).attr(`body`).as(`any`)))),I.if(I(`page`).attr(`headers`)).do(I(`params`).attr(`headers`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`headers`)).spread(I(`page`).attr(`headers`)))),I.if(I(`page`).attr(`path`)).do(I(`params`).attr(`path`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`path`).as(`any`)).spread(I(`page`).attr(`path`).as(`any`)))),I.if(I(`page`).attr(`query`)).do(I(`params`).attr(`query`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`query`).as(`any`)).spread(I(`page`).attr(`query`).as(`any`)))),I.return(I(`params`).as(`unknown`).as(I(`page`).typeofType()))));e.node(n)},Ls=({operation:e,plugin:t})=>{let n=rt({context:t.context,operation:e});if(!n)return;let r=aa({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Ns({plugin:t}),js({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||Is({plugin:t});let i=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),a=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),o=Ds({operation:e,plugin:t}),s=ks({operation:e,plugin:t}),c=t.referenceSymbol({category:`type`,resource:`QueryKey`,tool:t.name}),u=I.type(c).generic(o),d=I.type(`Pick`).generics(u.idx(0),I.type.or(I.type.literal(`body`),I.type.literal(`headers`),I.type.literal(`path`),I.type.literal(`query`))),f=t.getPluginOrThrow(`@hey-api/typescript`),p=f.api.schemaToType({plugin:f,schema:n.schema,state:{path:(0,l.ref)([])}}),m=t.symbol(R(e.id,t.config.infiniteQueryKeys)),ee=Ps({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.node(ee);let h=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(`options`).spread(`params`).prop(`signal`,I(`signal`)).prop(`throwOnError`,I.literal(!0))).await()),te=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),ne=[I.const(`page`).type(d).hint(`@ts-ignore`).assign(I.ternary(I(`pageParam`).typeofExpr().eq(I.literal(`object`))).do(`pageParam`).otherwise(I.object().pretty().prop(n.in,I.object().pretty().prop(n.name,I(`pageParam`))))),I.const(`params`).assign(I(te).call(`queryKey`,`page`))];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?ne.push(I.return(h)):ne.push(I.const().object(`data`).assign(h),I.return(`data`));let re=t.symbol(R(e.id,t.config.infiniteQueryOptions)),ie=I.const(re).export().$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.required(r).type(o)).do(I.return(I(i).call(I.object().pretty().hint(`@ts-ignore`).prop(`queryFn`,I.func().async().param(e=>e.object(`pageParam`,`queryKey`,`signal`)).do(...ne)).prop(`queryKey`,I(m).call(`options`)).$if(Fs(t,e,`infiniteQueryOptions`),(e,t)=>e.prop(`meta`,t))).generics(s,Os({operation:e,plugin:t}),I.type(a).generic(s),u,I.type.or(p,d)))));t.node(ie)},Rs=({operation:e,plugin:t})=>{let n=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),r=Ds({operation:e,plugin:t}),i=I.type(n).generic(ks({operation:e,plugin:t})).generic(Os({operation:e,plugin:t})).generic(r),a=`fnOptions`,o=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(`options`).spread(a).prop(`throwOnError`,I.literal(!0))).await()),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(I.return(o)):s.push(I.const().object(`data`).assign(o),I.return(`data`));let c=`mutationOptions`,l=t.symbol(R(e.id,t.config.mutationOptions)),u=I.const(l).export().$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.optional().type(I.type(`Partial`).generic(r))).returns(i).do(I.const(c).type(i).assign(I.object().pretty().prop(`mutationFn`,I.func().async().param(a).do(...s)).$if(Fs(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t))),I(c).return()));t.node(u)},zs=`options`,Bs=({operation:e,plugin:t})=>{if(oa({operation:e}))return;let n=aa({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Ns({plugin:t}),js({plugin:t}));let r=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),i=t.symbol(R(e.id,t.config.queryKeys)),a=Ps({isInfinite:!1,operation:e,plugin:t,symbol:i});t.node(a);let o=ks({operation:e,plugin:t}),s=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(zs).spread(I(`queryKey`).attr(0)).prop(`signal`,I(`signal`)).prop(`throwOnError`,I.literal(!0))).await()),c=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?c.push(I.return(s)):c.push(I.const().object(`data`).assign(s),I.return(`data`));let l=I.object().pretty().prop(`queryFn`,I.func().async().param(e=>e.object(`queryKey`,`signal`)).do(...c)).prop(`queryKey`,I(i).call(zs)).$if(Fs(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),u=t.symbol(R(e.id,t.config.queryOptions),{meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}}),d=I.const(u).export(t.config.queryOptions.exported).$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I.func().param(zs,r=>r.required(n).type(Ds({operation:e,plugin:t}))).do(I(r).call(l).generics(o,Os({operation:e,plugin:t}),o,I(i).returnType()).return()));t.node(d)},Vs=`options`,Hs=({operation:e,plugin:t})=>{if(oa({operation:e})||!(`useQuery`in t.config))return;let n=t.symbol(R(e.id,t.config.useQuery)),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=aa({context:t.context,operation:e}),a=Ds({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=I.const(n).export().$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I.func().param(Vs,e=>e.required(i).type(a)).do(I(r).call(I(o).call(Vs)).return()));t.node(s)},Us=({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&&Bs({operation:t,plugin:e}),e.config.infiniteQueryOptions.enabled&&Ls({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&&Rs({operation:t,plugin:e})},{order:`declarations`})},Ws=e=>Us(e),Gs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Ws,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})}},Ks=_(Gs),qs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Ws,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))}},Js=_(qs),Ys={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Ws,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=_(Ys),Zs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Ws,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})}},Qs=_(Zs),$s={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Ws,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})}},ec=_($s),tc=({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 I.func().async().param(r).do(I(n).attr(`parseAsync`).call(r).await().return())},nc=({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 I.func().async().param(r).do(I(n).attr(`parseAsync`).call(r).await().return())};var rc=class{createRequestValidator(e){return tc(e)}createResponseValidator(e){return nc(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`}},ic=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=I.const(r).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).assign(I(a).call(e.def?I.literal(e.def):e.expression));if(t.node(o),i){let e=I.type.alias(i).export().type(I.type(r).attr(H.type.infer).typeofType());t.node(e)}},ac=e=>{let t={};return t.def=H.primitives.null,t},oc=({plugin:e,schema:t,state:n})=>{let r={},i=I.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),u=lc({optional:!c,plugin:e,schema:s,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`properties`,o])}});u.hasLazyExpression&&(r.hasLazyExpression=!0),i.prop(c?o:`${o}?`,u.expression)}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=lc({plugin:e,schema:t.additionalProperties,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`additionalProperties`])}});return r.expression=I(`TODO`).attr(`record`).call(I(`TODO`).attr(`string`).call(),i.expression),i.hasLazyExpression&&(r.hasLazyExpression=!0),r}return r.expression=i,r.hasLazyExpression?{...r,typeName:`TODO`}:r},sc=({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},cc=({schema:e,...t})=>{switch(e.type){case`null`:return ac({...t,schema:e});case`object`:return oc({...t,schema:e});case`string`:return sc({...t,schema:e})}return{def:``,expression:I(t.plugin.referenceSymbol({category:`external`,resource:`arktype.type`})).call(I.object().prop(`name`,I.literal(`string`)).prop(`platform`,I.literal(`'android' | 'ios'`)).prop(`versions?`,I.literal(`(number | string)[]`))),hasLazyExpression:!1}},lc=({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=I(a);r.expression=e}else{let e=I(`TODO`).attr(`TODO`).call(I.func().returns(`any`).do(I.return(a)));r.expression=e,r.hasLazyExpression=!0,n.hasLazyExpression[`~ref`]=!0}}else if(t.type){let i=cc({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=S({schema:t}),t.items||(r=lc({plugin:e,schema:t,state:n}));else{let t=cc({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}if(!r.expression){let t=cc({plugin:e,schema:{type:`unknown`},state:n});r.expression=t.expression}return r},uc=({plugin:e,schema:t,state:n})=>{let r=Ri((0,l.fromRef)(n.path)),i=lc({plugin:e,schema:t,state:n}),a=z(r);ic({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`arktype`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tool:`arktype`,variant:`infer`}}):void 0})},dc=({plugin:e})=>{e.symbol(`type`,{external:`arktype`,meta:{category:`external`,resource:`arktype.type`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:uc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:uc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:uc({plugin:e,schema:t.schema,state:n});break}})},fc=e=>dc(e),pc={api:new rc,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:fc,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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},mc=_(pc),hc=({operation:e,plugin:t})=>{let n=I.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(I.type(r).idx(I.type.literal(`body`)))),e.parameters&&(e.parameters.header&&n.prop(`Headers`,t=>t.required($e(e.parameters.header)).type(I.type(r).idx(I.type.literal(`headers`)))),e.parameters.path&&n.prop(`Params`,t=>t.required($e(e.parameters.path)).type(I.type(r).idx(I.type.literal(`path`)))),e.parameters.query&&n.prop(`Querystring`,t=>t.required($e(e.parameters.query)).type(I.type(r).idx(I.type.literal(`query`))))));let{errors:i,responses:a}=at(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=I.type(`Omit`,e=>e.generics(I.type(s),I.type.literal(`default`)))):o=I.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=I.type(`Omit`,e=>e.generics(I.type(l),I.type.literal(`default`)))):c=I.type(l))}let u=[o,c].filter(e=>e!==void 0);if(u.length&&n.prop(`Reply`,e=>e.type(I.type.and(...u))),n.isEmpty)return;let d=t.referenceSymbol({category:`type`,resource:`route-handler`,tool:`fastify`});return{name:e.id,type:I.type(d,e=>e.generic(n))}},gc=({plugin:e})=>{e.symbol(`RouteHandler`,{external:`fastify`,kind:`type`,meta:{category:`type`,resource:`route-handler`,tool:`fastify`}});let t=e.symbol(`RouteHandlers`),n=I.type.object();e.forEach(`operation`,({operation:t})=>{let r=hc({operation:t,plugin:e});r&&n.prop(r.name,e=>e.type(r.type))},{order:`declarations`});let r=I.type.alias(t).export().type(n);e.node(r)},_c={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:gc,name:`fastify`},vc=_(_c),yc=({operation:e,plugin:t})=>{if(oa({operation:e}))return;let n=t.referenceSymbol({category:`external`,resource:`swr`}),r=t.symbol(R(e.id,t.config.useSwr)),i=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().prop(`throwOnError`,I.literal(!0))).await()),a=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?a.push(I.return(i)):a.push(I.const().object(`data`).assign(i),I.return(`data`));let o=I.const(r).export().$if(t.config.comments&&ia(e),(e,t)=>e.doc(t)).assign(I.func().do(I(n).call(I.literal(e.path),I.func().async().do(...a)).return()));t.node(o)},bc=({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&&yc({operation:t,plugin:e})},{order:`declarations`})},xc=e=>bc(e),Sc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:xc,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))}},Cc=_(Sc),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]:I(t.external(`valibot.v`)).attr(U.methods.pipe).call(...e):e,wc=(e,t)=>(t instanceof Array?e.push(...t):e.push(t),e),Tc={push:wc,toNode:W},Ec=e=>{let{schema:t,v:n}=e.symbols;return I(n).attr(U.async.parseAsync).call(t,`data`).await().return()},Dc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`valibot`});if(!n)return;let r={$:I,operation:e,pipes:{...Tc,current:[]},plugin:t,symbols:{schema:n,v:t.external(`valibot.v`)}},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,Ec];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Oc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`valibot`});if(!n)return;let r={$:I,operation:e,pipes:{...Tc,current:[]},plugin:t,symbols:{schema:n,v:t.external(`valibot.v`)}},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,Ec];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var kc=class{createRequestValidator(e){return Dc(e)}createResponseValidator(e){return Oc(e)}};const Ac=e=>e===`int64`||e===`uint64`,jc=(e,t)=>Ac(t)?typeof e==`string`?(e.endsWith(`n`)&&(e=e.slice(0,-1)),I(`BigInt`).call(I.fromValue(e))):typeof e==`number`?I(`BigInt`).call(I.fromValue(e)):I.fromValue(e):I.fromValue(e),Mc=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=I.const(i).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).$if(r.hasLazyExpression[`~ref`],t=>t.type(I.type(a).attr(e.typeName||U.types.GenericSchema))).assign(W(e.pipes,t));t.node(o)},Nc=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Mc({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,state:r,symbol:n.symbol(R(t.id,n.config.requests),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`operation`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`valibot`}})})}if(n.config.responses.enabled&&t.responses){let{response:i}=at(t);if(i){let a=[...(0,l.fromRef)(r.path),`responses`];Mc({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.symbol(R(t.id,n.config.responses),{meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:(0,l.fromRef)(r.tags),tool:`valibot`}})})}}},Pc=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Mc({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,state:r,symbol:n.symbol(R(t.id,n.config.webhooks),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`valibot`}})})}},Fc=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.unknown).call(),Ic=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol({category:`external`,resource:`valibot.v`}),a=I(i).attr(U.schemas.array);if(t.items){t=S({schema:t});let i=t.items.map((t,i)=>{let a=ml({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),W(a.pipes,e)});if(i.length===1){let e=a.call(...i);r.pipes.push(e)}else{t.logicalOperator;let i=a.call(Fc({plugin:e,schema:{type:`unknown`},state:n}));r.pipes.push(i)}}else{let t=a.call(Fc({plugin:e,schema:{type:`unknown`},state:n}));r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=I(i).attr(U.actions.length).call(I.fromValue(t.minItems));r.pipes.push(e)}else{if(t.minItems!==void 0){let e=I(i).attr(U.actions.minLength).call(I.fromValue(t.minItems));r.pipes.push(e)}if(t.maxItems!==void 0){let e=I(i).attr(U.actions.maxLength).call(I.fromValue(t.maxItems));r.pipes.push(e)}}return r},Lc=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?(n.push(I(r).attr(U.schemas.literal).call(I.literal(t.const))),W(n,e)):(n.push(I(r).attr(U.schemas.boolean).call()),W(n,e))},Rc=({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(I.literal(e.const)):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Fc({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=I(a).attr(U.schemas.picklist).call(I.array(...r));return i&&(o=I(a).attr(U.schemas.nullable).call(o)),o},zc=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.never).call(),Bc=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.null).call(),Vc=(e,t)=>({maxError:`Invalid value: Expected ${e} to be <= ${t[1]}`,minError:`Invalid value: Expected ${e} to be >= ${t[0]}`}),Hc={int16:[-32768,32767],int32:[-2147483648,2147483647],int64:[`-9223372036854775808`,`9223372036854775807`],int8:[-128,127],uint16:[0,65535],uint32:[0,4294967295],uint64:[`0`,`18446744073709551615`],uint8:[0,255]},Uc=e=>{if(!e)return;let t=Hc[e];if(!t)return;let n=Vc(e,t);return{maxValue:t[1],minValue:t[0],...n}};function Wc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return[I(r).attr(U.schemas.union).call(I.array(I(r).attr(U.schemas.number).call(),I(r).attr(U.schemas.string).call(),I(r).attr(U.schemas.bigInt).call())),I(r).attr(U.actions.transform).call(I.func().param(`x`).do(I(`BigInt`).call(`x`).return()))];let i=[];return i.push(I(r).attr(U.schemas.number).call()),t.type===`integer`&&i.push(I(r).attr(U.actions.integer).call()),i}function Gc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.const!==void 0)return I(r).attr(U.schemas.literal).call(e.utils.maybeBigInt(t.const,t.format))}function Kc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.exclusiveMaximum!==void 0)return I(r).attr(U.actions.ltValue).call(e.utils.maybeBigInt(t.exclusiveMaximum,t.format));if(t.maximum!==void 0)return I(r).attr(U.actions.maxValue).call(e.utils.maybeBigInt(t.maximum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(U.actions.maxValue).call(e.utils.maybeBigInt(i.maxValue,t.format),I.literal(i.maxError))}function qc(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.exclusiveMinimum!==void 0)return I(r).attr(U.actions.gtValue).call(e.utils.maybeBigInt(t.exclusiveMinimum,t.format));if(t.minimum!==void 0)return I(r).attr(U.actions.minValue).call(e.utils.maybeBigInt(t.minimum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(U.actions.minValue).call(e.utils.maybeBigInt(i.minValue,t.format),I.literal(i.minError))}function Jc(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 Yc=({plugin:e,schema:t})=>{let n={$:I,nodes:{base:Wc,const:Gc,max:Kc,min:qc},pipes:{...Tc,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)},utils:{getIntegerLimit:Uc,maybeBigInt:jc,shouldCoerceToBigInt:Ac}},r=e.config[`~resolvers`]?.number,i=r?.(n)??Jc(n);return n.pipes.toNode(i,e)};function Xc(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||!n.additionalProperties.type)return;if(n.additionalProperties.type===`never`)return null;let r=ml({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),Tc.toNode(r.pipes,t)}function Zc(e){let{nodes:t,symbols:n}=e,{v:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i===null?I(r).attr(U.schemas.strictObject).call(a):i?a.isEmpty?I(r).attr(U.schemas.record).call(I(r).attr(U.schemas.string).call(),i):I(r).attr(U.schemas.objectWithRest).call(a,i):I(r).attr(U.schemas.object).call(a)}function Qc(e){return e.nodes.base(e)}function $c(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=ml({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.prop(i,Tc.toNode(o.pipes,t))}return r}const el=({plugin:e,schema:t,state:n})=>{let r={$:I,nodes:{additionalProperties:Xc,base:Zc,shape:$c},pipes:{...Tc,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)},utils:{ast:{},state:n}},i=e.config[`~resolvers`]?.object,a=i?.(r)??Qc(r);return r.utils.ast.pipes=[r.pipes.toNode(a,e)],r.utils.ast};function tl(e){let{v:t}=e.symbols;return I(t).attr(U.schemas.string).call()}function nl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(typeof t.const==`string`)return I(r).attr(U.schemas.literal).call(I.literal(t.const))}function rl(e){let{schema:t,symbols:n}=e,{v:r}=n;switch(t.format){case`date`:return I(r).attr(U.actions.isoDate).call();case`date-time`:return I(r).attr(U.actions.isoTimestamp).call();case`email`:return I(r).attr(U.actions.email).call();case`ipv4`:case`ipv6`:return I(r).attr(U.actions.ip).call();case`time`:return I(r).attr(U.actions.isoTimeSecond).call();case`uri`:return I(r).attr(U.actions.url).call();case`uuid`:return I(r).attr(U.actions.uuid).call()}}function il(e){let{schema:t,symbols:n}=e,{v:r}=n;if(!(t.minLength===void 0||t.minLength!==t.maxLength))return I(r).attr(U.actions.length).call(I.literal(t.minLength))}function al(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.maxLength!==void 0)return I(r).attr(U.actions.maxLength).call(I.literal(t.maxLength))}function ol(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.minLength!==void 0)return I(r).attr(U.actions.minLength).call(I.literal(t.minLength))}function sl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.pattern)return I(r).attr(U.actions.regex).call(I.regexp(t.pattern))}function cl(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 ll=({plugin:e,schema:t})=>{let n={$:I,nodes:{base:tl,const:nl,format:rl,length:il,maxLength:al,minLength:ol,pattern:sl},pipes:{...Tc,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)}},r=e.config[`~resolvers`]?.string,i=r?.(n)??cl(n);return n.pipes.toNode(i,e)},ul=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I(i).attr(U.schemas.literal).call(I.fromValue(e)));return r.pipes=[I(i).attr(U.schemas.tuple).call(I.array(...e))],r}if(t.items){let a=t.items.map((t,i)=>{let a=ml({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),W(a.pipes,e)});return r.pipes=[I(i).attr(U.schemas.tuple).call(I.array(...a))],r}return{pipes:[Fc({plugin:e,schema:{type:`unknown`},state:n})]}},dl=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.undefined).call(),fl=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.void).call(),pl=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:W(Ic({...t,schema:e}).pipes,t.plugin)};case`boolean`:return{expression:Lc({...t,schema:e})};case`enum`:return{expression:Rc({...t,schema:e})};case`integer`:case`number`:return{expression:Yc({...t,schema:e})};case`never`:return{expression:zc({...t,schema:e})};case`null`:return{expression:Bc({...t,schema:e})};case`object`:return{expression:W(el({...t,schema:e}).pipes,t.plugin)};case`string`:return{expression:Ac(e.format)?Yc({...t,schema:{...e,type:`number`}}):ll({...t,schema:e})};case`tuple`:return{expression:W(ul({...t,schema:e}).pipes,t.plugin)};case`undefined`:return{expression:dl({...t,schema:e})};case`unknown`:return{expression:Fc({...t,schema:e})};case`void`:return{expression:fl({...t,schema:e})}}},ml=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol({category:`external`,resource:`valibot.v`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`valibot`},o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=I(o);i.pipes.push(e)}else{let e=I(a).attr(U.schemas.lazy).call(I.func().do(I(o).return()));i.pipes.push(e),r.hasLazyExpression[`~ref`]=!0}}else if(n.type){let e=pl({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=I(a).attr(U.actions.metadata).call(I.object().prop(`description`,I.literal(n.description)));i.pipes.push(e)}}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>W(ml({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}).pipes,t));if(n.logicalOperator===`and`){let t=I(a).attr(U.schemas.intersect).call(I.array(...e));i.pipes.push(t)}else{let t=I(a).attr(U.schemas.union).call(I.array(...e));i.pipes.push(t)}}else{let e=ml({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=pl({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=I(a).attr(U.actions.readonly).call();i.pipes.push(e)}n.default===void 0?e&&(i.pipes=[I(a).attr(U.schemas.optional).call(W(i.pipes,t))]):i.pipes=[I(a).attr(U.schemas.optional).call(W(i.pipes,t),n.type===`integer`||n.type===`number`?jc(n.default,n.format):I.fromValue(n.default))]}return i},hl=({plugin:e,schema:t,state:n})=>{let r=Ri((0,l.fromRef)(n.path)),i=ml({plugin:e,schema:t,state:n}),a=z(r);Mc({ast:i,plugin:e,schema:t,state:n,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`valibot`}})})},gl=({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=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Nc({getAst:(n,r)=>ml({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:hl({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:hl({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:hl({plugin:e,schema:t.schema,state:n});break;case`webhook`:Pc({getAst:(n,r)=>ml({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},_l=e=>gl(e),vl={api:new kc,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:_l,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`]},yl=_(vl),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`},bl=e=>{let{schema:t}=e.symbols;return I(t).attr(G.parseAsync).call(`data`).await().return()},xl=({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={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,bl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Sl=({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={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,bl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Cl=e=>{let{schema:t}=e.symbols;return I(t).attr(G.parseAsync).call(`data`).await().return()},wl=({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={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,Cl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Tl=({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={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,Cl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},El=e=>{let{schema:t}=e.symbols;return I(t).attr(G.parseAsync).call(`data`).await().return()},Dl=({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={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,El];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Ol=({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={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,El];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var kl=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return wl(e);case`mini`:return xl(e);case 4:default:return Dl(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Tl(e);case`mini`:return Sl(e);case 4:default:return Ol(e)}}};const Al=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=I.const(r).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).$if(e.typeName,(e,t)=>e.type(I.type(a).attr(t))).assign(e.expression);if(t.node(o),i){let e=I.type.alias(i).export().type(I.type(a).attr(G.infer).generic(I(r).typeofType()));t.node(e)}},jl=({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`}},Ml=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Al({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,symbol:n.symbol(R(t.id,n.config.requests),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`operation`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`}}),typeInferSymbol:n.config.requests.types.infer.enabled?n.symbol(R(t.id,n.config.requests.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(r.path),resource:`operation`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`,variant:`infer`}}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=at(t);if(i){let a=[...(0,l.fromRef)(r.path),`responses`];Al({ast:e(i,a),plugin:n,schema:i,symbol:n.symbol(R(t.id,n.config.responses),{meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:(0,l.fromRef)(r.tags),tool:`zod`}}),typeInferSymbol:n.config.responses.types.infer.enabled?n.symbol(R(t.id,n.config.responses.types.infer),{meta:{category:`type`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:(0,l.fromRef)(r.tags),tool:`zod`,variant:`infer`}}):void 0})}}},Nl=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Al({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,symbol:n.symbol(R(t.id,n.config.webhooks),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`}}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.symbol(R(t.id,n.config.webhooks.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(r.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`,variant:`infer`}}):void 0})}},Pl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.unknown).call(),n},Fl=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=I(r).attr(G.array);if(!t.items)i.expression=a.call(Pl({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=S({schema:t});let o=t.items.map((t,r)=>{let a=uu({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=a.call(...o);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I(r).attr(G.intersection).call(...o);else{n=o[0];for(let e=1;e<o.length;e++)n=I(r).attr(G.intersection).call(n,o[e])}i.expression=a.call(n)}else i.expression=I(r).attr(G.array).call(I(r).attr(G.union).call(I.array(...o)))}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(I(r).attr(G.length).call(I.fromValue(t.minItems))):(t.minItems!==void 0&&o.push(I(r).attr(G.minLength).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&o.push(I(r).attr(G.maxLength).call(I.fromValue(t.maxItems)))),o.length>0&&(i.expression=i.expression.attr(G.check).call(...o)),i},Il=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=I(i).attr(G.literal).call(I.literal(t.const)),n.expression=r,n):(r=I(i).attr(G.boolean).call(),n.expression=r,n)},Ll=({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=I.literal(e.const);a.push(t),o.push(I(r).attr(G.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.literal(e.const);o.push(I(r).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.literal(e.const);o.push(I(r).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=I(r).attr(G.enum).call(I.array(...a)):o.length===1?i.expression=o[0]:i.expression=I(r).attr(G.union).call(I.array(...o)),s&&(i.expression=I(r).attr(G.nullable).call(i.expression)),i):Pl({plugin:e,schema:{type:`unknown`},state:n})},Rl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.never).call(),n},zl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.null).call(),n};function Bl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return I(r).attr(G.coerce).attr(G.bigint).call();let i=I(r).attr(G.number).call();return t.type===`integer`&&(i=I(r).attr(G.int).call()),i}function Vl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return I(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function Hl(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.exclusiveMaximum!==void 0)return I(r).attr(G.lt).call(e.utils.maybeBigInt(t.exclusiveMaximum,t.format));if(t.maximum!==void 0)return I(r).attr(G.lte).call(e.utils.maybeBigInt(t.maximum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(G.maximum).call(e.utils.maybeBigInt(i.maxValue,t.format),I.object().prop(`error`,I.literal(i.maxError)))}function Ul(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.exclusiveMinimum!==void 0)return I(r).attr(G.gt).call(e.utils.maybeBigInt(t.exclusiveMinimum,t.format));if(t.minimum!==void 0)return I(r).attr(G.gte).call(e.utils.maybeBigInt(t.minimum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(G.minimum).call(e.utils.maybeBigInt(i.minValue,t.format),I.object().prop(`error`,I.literal(i.minError)))}function Wl(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 Gl=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{base:Bl,const:Vl,max:Hl,min:Ul},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:Uc,maybeBigInt:jc,shouldCoerceToBigInt:Ac,state:n}},o=e.config[`~resolvers`]?.number;return r.expression=o?.(a)??Wl(a),r};function Kl(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let r=uu({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.expression}function ql(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?I(r).attr(G.record).call(I(r).attr(G.string).call(),i):I(r).attr(G.object).call(a)}function Jl(e){return e.nodes.base(e)}function Yl(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=uu({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression?(e.utils.ast.hasLazyExpression=!0,r.getter(i,o.expression.return())):r.prop(i,o.expression)}return r}const Xl=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{additionalProperties:Kl,base:ql,shape:Yl},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??Jl(a),r};function Zl(e){let{z:t}=e.symbols;return I(t).attr(G.string).call()}function Ql(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return I(r).attr(G.literal).call(I.literal(t.const))}function $l(e){let{plugin:t,schema:n,symbols:r}=e,{z:i}=r;switch(n.format){case`date`:return I(i).attr(G.iso).attr(G.date).call();case`date-time`:{let e=I.object().$if(t.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,I.literal(!0)));return I(i).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return I(i).attr(G.email).call();case`ipv4`:return I(i).attr(G.ipv4).call();case`ipv6`:return I(i).attr(G.ipv6).call();case`time`:return I(i).attr(G.iso).attr(G.time).call();case`uri`:return I(i).attr(G.url).call();case`uuid`:return I(i).attr(G.uuid).call()}}function eu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(!(t.minLength===void 0||t.minLength!==t.maxLength))return I(r).attr(G.length).call(I.literal(t.minLength))}function tu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.maxLength!==void 0)return I(r).attr(G.maxLength).call(I.literal(t.maxLength))}function nu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.minLength!==void 0)return I(r).attr(G.minLength).call(I.literal(t.minLength))}function ru(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.pattern)return I(r).attr(G.regex).call(I.regexp(t.pattern))}function iu(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 au=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:I,chain:{current:I(n)},nodes:{base:Zl,const:Ql,format:$l,length:eu,maxLength:tu,minLength:nu,pattern:ru},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return{expression:i?.(r)??iu(r)}},ou=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I(r).attr(G.literal).call(I.fromValue(e)));return i.expression=I(r).attr(G.tuple).call(I.array(...e)),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=uu({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=I(r).attr(G.tuple).call(I.array(...a)),i},su=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.undefined).call(),n},cu=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.void).call(),n},lu=({schema:e,...t})=>{switch(e.type){case`array`:return Fl({...t,schema:e});case`boolean`:return Il({...t,schema:e});case`enum`:return Ll({...t,schema:e});case`integer`:case`number`:return Gl({...t,schema:e});case`never`:return Rl({...t,schema:e});case`null`:return zl({...t,schema:e});case`object`:return Xl({...t,schema:e});case`string`:return Ac(e.format)?Gl({...t,schema:{...e,type:`number`}}):au({...t,schema:e});case`tuple`:return ou({...t,schema:e});case`undefined`:return su({...t,schema:e});case`unknown`:return Pl({...t,schema:e});case`void`:return cu({...t,schema:e})}},uu=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I(o):(i.expression=I(a).attr(G.lazy).call(I.func().returns(`any`).do(I(o).return())),i.hasLazyExpression=!0,r.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=lu({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=i.expression.attr(G.register).call(I(a).attr(G.globalRegistry),I.object().pretty().prop(`description`,I.literal(n.description))))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>uu({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a).attr(G.intersection).call(...e.map(e=>e.expression)):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I(a).attr(G.intersection).call(i.expression,e.hasLazyExpression?I(a).attr(G.lazy).call(I.func().do(e.expression.return())):e.expression)}))}else i.expression=I(a).attr(G.union).call(I.array().pretty().elements(...e.map(e=>e.expression)))}else i=uu({plugin:t,schema:n,state:r});else{let e=lu({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression}return i.expression&&(n.accessScope===`read`&&(i.expression=I(a).attr(G.readonly).call(i.expression)),e&&(i.expression=I(a).attr(G.optional).call(i.expression),i.typeName=G.ZodMiniOptional),n.default!==void 0&&(i.expression=I(a).attr(G._default).call(i.expression,n.type===`integer`||n.type===`number`?jc(n.default,n.format):I.fromValue(n.default)))),i},du=({plugin:e,schema:t,state:n})=>{let r=Ri((0,l.fromRef)(n.path)),i=uu({plugin:e,schema:t,state:n}),a=z(r);Al({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`,variant:`infer`}}):void 0})},fu=({plugin:e})=>{e.symbol(`z`,{external:jl({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Ml({getAst:(n,r)=>uu({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:du({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:du({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:du({plugin:e,schema:t.schema,state:n});break;case`webhook`:Nl({getAst:(n,r)=>uu({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},pu=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.unknown).call(),mu=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=I(r).attr(G.array),a,o=!1;if(!t.items)a=i.call(pu({plugin:e,schema:{type:`unknown`},state:n}));else{t=S({schema:t});let s=t.items.map((t,r)=>{let i=Uu({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=i.call(...s);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I(r).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])}a=i.call(n)}else a=I(r).attr(G.array).call(I(r).attr(G.union).call(I.array(...s)))}return t.minItems===t.maxItems&&t.minItems!==void 0?a=a.attr(G.length).call(I.fromValue(t.minItems)):(t.minItems!==void 0&&(a=a.attr(G.min).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&(a=a.attr(G.max).call(I.fromValue(t.maxItems)))),{expression:a,hasLazyExpression:o}},hu=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n=I(r).attr(G.literal).call(I.literal(t.const)),n):(n=I(r).attr(G.boolean).call(),n)},gu=({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=I.literal(e.const);i.push(t),a.push(I(r).attr(G.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=I.literal(e.const);a.push(I(r).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=I.literal(e.const);a.push(I(r).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return pu({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?I(r).attr(G.enum).call(I.array(...i)):a.length===1?a[0]:I(r).attr(G.union).call(I.array(...a)),o&&(c=c.attr(G.nullable).call()),c},_u=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.never).call(),vu=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.null).call();function yu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return I(r).attr(G.coerce).attr(G.bigint).call();let i=I(r).attr(G.number).call();return t.type===`integer`&&(i=i.attr(G.int).call()),i}function bu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return I(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function xu(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),I.object().prop(`message`,I.literal(r.maxError)))}function Su(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),I.object().prop(`message`,I.literal(r.minError)))}function Cu(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 wu=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{base:yu,const:bu,max:xu,min:Su},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:Uc,maybeBigInt:jc,shouldCoerceToBigInt:Ac,state:n}},o=e.config[`~resolvers`]?.number;return o?.(a)??Cu(a)};function Tu(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let r=Uu({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.expression}function Eu(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?I(r).attr(G.record).call(i):I(r).attr(G.object).call(a)}function Du(e){return e.nodes.base(e)}function Ou(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=Uu({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.prop(i,o.expression)}return r}const ku=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{additionalProperties:Tu,base:Eu,shape:Ou},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??Du(a),{...r,anyType:`AnyZodObject`}};function Au(e){let{z:t}=e.symbols;return I(t).attr(G.string).call()}function ju(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return I(r).attr(G.literal).call(I.literal(t.const))}function Mu(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=I.object().$if(n.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(n.config.dates.local,e=>e.prop(`local`,I.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 Nu(e){let{chain:t,schema:n}=e;if(!(n.minLength===void 0||n.minLength!==n.maxLength))return t.current.attr(G.length).call(I.literal(n.minLength))}function Pu(e){let{chain:t,schema:n}=e;if(n.maxLength!==void 0)return t.current.attr(G.max).call(I.literal(n.maxLength))}function Fu(e){let{chain:t,schema:n}=e;if(n.minLength!==void 0)return t.current.attr(G.min).call(I.literal(n.minLength))}function Iu(e){let{chain:t,schema:n}=e;if(n.pattern)return t.current.attr(G.regex).call(I.regexp(n.pattern))}function Lu(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 Ru=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:I,chain:{current:I(n)},nodes:{base:Au,const:ju,format:Mu,length:Nu,maxLength:Pu,minLength:Fu,pattern:Iu},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return i?.(r)??Lu(r)},zu=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I(r).attr(G.literal).call(I.fromValue(e)));return{expression:I(r).attr(G.tuple).call(I.array(...e)),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Uu({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:I(r).attr(G.tuple).call(I.array(...a)),hasLazyExpression:i}},Bu=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.undefined).call(),Vu=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.void).call(),Hu=({schema:e,...t})=>{switch(e.type){case`array`:return mu({...t,schema:e});case`boolean`:return{expression:hu({...t,schema:e})};case`enum`:return{expression:gu({...t,schema:e})};case`integer`:case`number`:return{expression:wu({...t,schema:e})};case`never`:return{expression:_u({...t,schema:e})};case`null`:return{expression:vu({...t,schema:e})};case`object`:return ku({...t,schema:e});case`string`:return{expression:Ac(e.format)?wu({...t,schema:{...e,type:`number`}}):Ru({...t,schema:e})};case`tuple`:return zu({...t,schema:e});case`undefined`:return{expression:Bu({...t,schema:e})};case`unknown`:return{expression:pu({...t,schema:e})};case`void`:return{expression:Vu({...t,schema:e})}}},Uu=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I(o):(i.expression=I(a).attr(G.lazy).call(I.func().do(I(o).return())),i.hasLazyExpression=!0,r.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=Hu({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=i.expression.attr(G.describe).call(I.literal(n.description)))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Uu({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a).attr(G.intersection).call(...e):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=i.expression.attr(G.and).call(e)}))}else i.expression=I(a).attr(G.union).call(I.array().pretty().elements(...e))}else i=Uu({plugin:t,schema:n,state:r});else{let e=Hu({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}return i.expression&&(n.accessScope===`read`&&(i.expression=i.expression.attr(G.readonly).call()),e&&(i.expression=i.expression.attr(G.optional).call()),n.default!==void 0&&(i.expression=i.expression.attr(G.default).call(n.type===`integer`||n.type===`number`?jc(n.default,n.format):I.fromValue(n.default)))),r.hasLazyExpression[`~ref`]?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},Wu=({plugin:e,schema:t,state:n})=>{let r=Ri((0,l.fromRef)(n.path)),i=Uu({plugin:e,schema:t,state:n}),a=z(r);Al({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`,variant:`infer`}}):void 0})},Gu=({plugin:e})=>{e.symbol(`z`,{external:jl({plugin:e}),meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Ml({getAst:(n,r)=>Uu({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Wu({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Wu({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Wu({plugin:e,schema:t.schema,state:n});break;case`webhook`:Nl({getAst:(n,r)=>Uu({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Ku=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.unknown).call(),t},qu=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=I(i).attr(G.array);if(!t.items)r.expression=a.call(Ku({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=S({schema:t});let o=t.items.map((t,i)=>{let a=Sd({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=a.call(...o);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I(i).attr(G.intersection).call(...o);else{n=o[0];for(let e=1;e<o.length;e++)n=n.attr(G.and).call(o[e])}r.expression=a.call(n)}else r.expression=I(i).attr(G.array).call(I(i).attr(G.union).call(I.array(...o)))}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=r.expression.attr(G.length).call(I.fromValue(t.minItems)):(t.minItems!==void 0&&(r.expression=r.expression.attr(G.min).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&(r.expression=r.expression.attr(G.max).call(I.fromValue(t.maxItems)))),r},Ju=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=I(i).attr(G.literal).call(I.literal(t.const)),n.expression=r,n):(r=I(i).attr(G.boolean).call(),n.expression=r,n)},Yu=({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=I.literal(e.const);a.push(t),o.push(I(i).attr(G.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.literal(e.const);o.push(I(i).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.literal(e.const);o.push(I(i).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=I(i).attr(G.enum).call(I.array(...a)):o.length===1?r.expression=o[0]:r.expression=I(i).attr(G.union).call(I.array(...o)),s&&(r.expression=I(i).attr(G.nullable).call(r.expression)),r):Ku({plugin:e,schema:{type:`unknown`},state:n})},Xu=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.never).call(),t},Zu=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.null).call(),t};function Qu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return I(r).attr(G.coerce).attr(G.bigint).call();let i=I(r).attr(G.number).call();return t.type===`integer`&&(i=I(r).attr(G.int).call()),i}function $u(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return I(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function ed(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),I.object().prop(`error`,I.literal(r.maxError)))}function td(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),I.object().prop(`error`,I.literal(r.minError)))}function nd(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 rd=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{base:Qu,const:$u,max:ed,min:td},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:Uc,maybeBigInt:jc,shouldCoerceToBigInt:Ac,state:n}},o=e.config[`~resolvers`]?.number;return r.expression=o?.(a)??nd(a),r};function id(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let r=Sd({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.expression}function ad(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?I(r).attr(G.record).call(I(r).attr(G.string).call(),i):I(r).attr(G.object).call(a)}function od(e){return e.nodes.base(e)}function sd(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=Sd({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression?(e.utils.ast.hasLazyExpression=!0,r.getter(i,o.expression.return())):r.prop(i,o.expression)}return r}const cd=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{additionalProperties:id,base:ad,shape:sd},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??od(a),r};function ld(e){let{z:t}=e.symbols;return I(t).attr(G.string).call()}function ud(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return I(r).attr(G.literal).call(I.literal(t.const))}function dd(e){let{plugin:t,schema:n,symbols:r}=e,{z:i}=r;switch(n.format){case`date`:return I(i).attr(G.iso).attr(G.date).call();case`date-time`:{let e=I.object().$if(t.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,I.literal(!0)));return I(i).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return I(i).attr(G.email).call();case`ipv4`:return I(i).attr(G.ipv4).call();case`ipv6`:return I(i).attr(G.ipv6).call();case`time`:return I(i).attr(G.iso).attr(G.time).call();case`uri`:return I(i).attr(G.url).call();case`uuid`:return I(i).attr(G.uuid).call()}}function fd(e){let{chain:t,schema:n}=e;if(!(n.minLength===void 0||n.minLength!==n.maxLength))return t.current.attr(G.length).call(I.literal(n.minLength))}function pd(e){let{chain:t,schema:n}=e;if(n.maxLength!==void 0)return t.current.attr(G.max).call(I.literal(n.maxLength))}function md(e){let{chain:t,schema:n}=e;if(n.minLength!==void 0)return t.current.attr(G.min).call(I.literal(n.minLength))}function hd(e){let{chain:t,schema:n}=e;if(n.pattern)return t.current.attr(G.regex).call(I.regexp(n.pattern))}function gd(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 _d=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:I,chain:{current:I(n)},nodes:{base:ld,const:ud,format:dd,length:fd,maxLength:pd,minLength:md,pattern:hd},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return{expression:i?.(r)??gd(r)}},vd=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I(i).attr(G.literal).call(I.fromValue(e)));return r.expression=I(i).attr(G.tuple).call(I.array(...e)),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=Sd({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=I(i).attr(G.tuple).call(I.array(...a)),r},yd=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.undefined).call(),t},bd=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.void).call(),t},xd=({schema:e,...t})=>{switch(e.type){case`array`:return qu({...t,schema:e});case`boolean`:return Ju({...t,schema:e});case`enum`:return Yu({...t,schema:e});case`integer`:case`number`:return rd({...t,schema:e});case`never`:return Xu({...t,schema:e});case`null`:return Zu({...t,schema:e});case`object`:return cd({...t,schema:e});case`string`:return Ac(e.format)?rd({...t,schema:{...e,type:`number`}}):_d({...t,schema:e});case`tuple`:return vd({...t,schema:e});case`undefined`:return yd({...t,schema:e});case`unknown`:return Ku({...t,schema:e});case`void`:return bd({...t,schema:e})}},Sd=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I(o):(i.expression=I(a).attr(G.lazy).call(I.func().returns(`any`).do(I(o).return())),i.hasLazyExpression=!0,r.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=xd({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=i.expression.attr(G.register).call(I(a).attr(G.globalRegistry),I.object().pretty().prop(`description`,I.literal(n.description))))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Sd({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a).attr(G.intersection).call(...e.map(e=>e.expression)):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=i.expression.attr(G.and).call(e.hasLazyExpression?I(a).attr(G.lazy).call(I.func().do(e.expression.return())):e.expression)}))}else i.expression=I(a).attr(G.union).call(I.array().pretty().elements(...e.map(e=>e.expression)))}else i=Sd({plugin:t,schema:n,state:r});else{let e=xd({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression}return i.expression&&(n.accessScope===`read`&&(i.expression=i.expression.attr(G.readonly).call()),e&&(i.expression=I(a).attr(G.optional).call(i.expression),i.typeName=G.ZodOptional),n.default!==void 0&&(i.expression=i.expression.attr(G.default).call(n.type===`integer`||n.type===`number`?jc(n.default,n.format):I.fromValue(n.default)))),i},Cd=({plugin:e,schema:t,state:n})=>{let r=Ri((0,l.fromRef)(n.path)),i=Sd({plugin:e,schema:t,state:n}),a=z(r);Al({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`,variant:`infer`}}):void 0})},wd=({plugin:e})=>{e.symbol(`z`,{external:jl({plugin:e}),meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Ml({getAst:(n,r)=>Sd({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Cd({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Cd({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Cd({plugin:e,schema:t.schema,state:n});break;case`webhook`:Nl({getAst:(n,r)=>Sd({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Td=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Gu(e);case`mini`:return fu(e);case 4:default:return wd(e)}},Ed={api:new kl,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Td,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(`🔌 ${u.default.yellow(`Warning:`)} Installed ${u.default.cyan(`zod`)} ${u.default.cyan(`v${n.version}`)} does not support compatibility version ${u.default.yellow(String(e))}, using ${u.default.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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Dd=_(Ed),Od={"@angular/common":wa,"@hey-api/client-angular":Va,"@hey-api/client-axios":Ua,"@hey-api/client-fetch":Ga,"@hey-api/client-ky":qa,"@hey-api/client-next":Ya,"@hey-api/client-nuxt":Za,"@hey-api/client-ofetch":$a,"@hey-api/schemas":po,"@hey-api/sdk":Co,"@hey-api/transformers":No,"@hey-api/typescript":ss,"@pinia/colada":Ts,"@tanstack/angular-query-experimental":Gs,"@tanstack/react-query":qs,"@tanstack/solid-query":Ys,"@tanstack/svelte-query":Zs,"@tanstack/vue-query":$s,arktype:pc,fastify:_c,swr:Sc,valibot:vl,zod:Ed},kd=[`@hey-api/typescript`,`@hey-api/sdk`],Ad=({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=Od[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:no(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Od[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Od[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}},jd=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),Md=({dependencies:e,userConfig:t})=>{let n={},r=kd;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&jd(t.plugins[0])?[...kd,...t.plugins]:t.plugins),Ad({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})},Nd=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Pd=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=He(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Re(e,i)):[Re(s,i)];for(let e of l){let t=Fe(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${u.default.yellow(`Warning:`)} You provided ${u.default.cyan(String(r))} ${u.default.cyan(r===1?`input`:`inputs`)} and ${u.default.yellow(String(i))} ${u.default.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let 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=Ie(e),n=Fe(e),i=Ve(e),o=We(e),s=[];n.length||s.push(new le(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||s.push(new le(`missing output - where should we generate your output?`)),i.path=f.default.resolve(process.cwd(),i.path);let c;try{c=Md({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??Nd(),logs:t,output:i,parser:o,pluginOrder:c.pluginOrder,plugins:c.plugins},d=a.length;if(t.level===`debug`){let e=u.default.gray(`[Job ${d+1}] `);console.warn(`${e}${u.default.cyan(`config:`)}`,l)}a.push({config:l,errors:s,jobIndex:d})}return o.timeEnd(),{dependencies:r,results:a}},Fd=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),Id=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Ld=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Rd=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},zd=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Ld(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Id(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Bd({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Bd=({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)}`},Vd=({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=Rd(r),s=Object.entries(i).map(([t,i])=>Bd({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Hd=({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=zd({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Vd({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Bd({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Ud=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Wd=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Ud(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},Gd=Hd({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Kd=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,te.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,te.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Wd(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(0,te.sendRequest)({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 qd=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 Jd=(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))},Yd=(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 qd(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))},Xd=(e,t,n)=>n?.order===`topological`?Yd(e,t,n):Jd(e,t,n),Zd=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],Qd=(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}},$d=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],ef=(()=>{let e={};for(let t=0;t<$d.length;t++){let n=$d[t];n&&(e[n]=t)}for(let t of Zd)e[t]===void 0&&(e[t]=$d.length);return e})(),tf=10,nf=e=>{let t=Qd(e);return t.matched?ef[t.kind]??10:10},rf=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},af=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var of=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:nf,matchPointerToGroup:Qd,order:`topological`,preferGroups:$d};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:Zd);Xd(this.context.graph,(e,n)=>{let r=Qd(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:Ii(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:f.default.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 fe({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 rf(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,af];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}},sf=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:t,logger:n,spec:r}){this.config=e,this.gen=new l.Project({defaultFileName:`index`,fileName:t=>{let n=R(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 gi({header:e.output.header,preferExportAll:e.output.preferExportAll,preferFileExtension:e.output.importFileExtension||void 0,resolveModuleName:e.output.resolveModuleName})],root:e.output.path}),this.logger=n,this.package=no(t),this.spec=r}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 of({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 zi({$ref:e,spec:this.ir})}resolveRef(e){return zi({$ref:e,spec:this.spec})}};const cf=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],lf=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),uf=({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`)?L(lf(n),c):L(`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`,c),t>1&&(o=`${o}${t}`),a.ids.has(o)?uf({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,w({method:r,path:i})),o)},df=`/`,K=(e,t=``)=>`${e}/${t}`,q=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},ff=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)}},pf=({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 cf){if(!i[t])continue;let a=w({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))},mf=({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 cf){if(!r[t])continue;let i=w({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))}},hf=({spec:e,...t})=>{`swagger`in e?pf({...t,spec:e}):mf({...t,spec:e})},gf=(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);hf({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},_f=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,vf=({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}},yf=({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}},bf=({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}},xf=({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}},Sf=({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}},Cf=({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}}}},wf=({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}}}},Tf=({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}}}},Ef=({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}}}},Df=({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)},Of=({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}},kf=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Sf({filters:e,resourceMetadata:n}),{parameters:a}=yf({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=bf({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=xf({filters:e,resourceMetadata:n,schemas:i});Ef({filters:e,resourceMetadata:n,schemas:i}),Cf({filters:e,parameters:a,resourceMetadata:n}),wf({filters:e,requestBodies:o,resourceMetadata:n}),Tf({filters:e,resourceMetadata:n,responses:s});let{operations:c}=vf({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Of({operations:c,resourceMetadata:n});Df({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Af=(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=Ii(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=ff(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(K(e,i))}}return n};for(let[t,n]of e.nodes){let e=Ii(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&&cf.includes(e[2])){let a=e[e.length-1],o=w({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}},jf=e=>JSON.parse(JSON.stringify(e)),Mf=[[`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`]],Nf=e=>{if(Pf(e))return e.components.schemas;if(Ff(e))return e.definitions},Pf=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,Ff=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,If=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Lf=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;If(t,i)||n&&If(n,i);)i=`${e}${r}`,r+=1;return i},Rf=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,zf=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},Bf=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})},Vf=({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||Mf.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)=>Vf({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Vf({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Hf=({spec:e})=>{let t=Nf(e);if(!t)return;let n=zf(e),r={};for(let[e,i]of Object.entries(t))Bf(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,jf(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=Ii(e),r=n[n.length-1];r&&delete t[r]}},Uf=({config:e,spec:t})=>{let n=Nf(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Bf(t);n&&(r[n]=e)}let i=[];Vf({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Rf(e.path)){let t=Bf(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]=Lf({base:R(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=zf(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}`})}},Wf=({config:e,spec:t})=>{if(e.mode===`inline`){Hf({spec:t});return}if(e.mode===`root`){Uf({config:e,spec:t});return}},Gf=({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||Mf.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)=>Gf({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Gf({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Kf=({spec:e})=>{Gf({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)}}})},qf=(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(!qf(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(!qf(r[e],i[e]))return!1;return!0};var Jf=qf;const Yf=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))}},Xf=({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=Xf({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=Xf({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}},Zf=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&&Qf(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 Mf){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&&Qf(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&Qf(a,t)&&n(a.parentPointer,t)}}},Qf=(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},$f=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`])))}},ep=(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=Ri(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=Li(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);$f(r.nodes),Zf(r),Yf(r.nodes);for(let e of r.nodes.keys()){let t=Xf({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}},tp=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),np=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`}},rp=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Pf(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(Ff(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},ip=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Pf(t)?Object.assign(t.components.schemas,n.schemas):Ff(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},ap=(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,!Mf.some(([e])=>e in t)))return!0}for(let[r,i]of Mf){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||ap(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||ap(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||ap(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||ap(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||ap(e,a,n))&&delete t[r]}if(t.type===`object`&&!Mf.some(([e])=>e in t))return!0}return!1},op=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=Nf(n);for(let e of Object.keys(r.mapping)){let n=Ii(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()},sp=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=zf(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=Ii(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=jf(r.node);ap(t,c,`writeOnly`);let u=R(i,e.responses),d=u===i?u:Lf({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=jf(r.node);ap(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`))})&&Jf(c,p)&&Jf(c,r.node))continue;let ee=R(i,e.requests),h=ee===i&&ee!==d?ee:Lf({base:ee,components:a});a.add(h),o.schemas[h]=p;let te=`${s}${h}`;o.mapping[n]={read:f,write:te},o.reverseMapping[f]=n,o.reverseMapping[te]=n}return i.timeEnd(),o},cp=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=zf(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(Rf(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=np(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(tp.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()},lp=({config:e,logger:t,spec:n})=>{let{graph:r}=ep(n,t),i=rp(n,t),a=sp({config:e,graph:r,logger:t,spec:n});ip({logger:t,spec:n,split:a}),cp({logger:t,spec:n,split:a}),op({logger:t,originalSchemas:i,spec:n,split:a})},up=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&Wf({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Kf({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&lp({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},dp=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),fp=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:dp(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),pp=e=>{let t=fp(e.path),n=e.severity===`error`?u.default.bold.red:u.default.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>u.default.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${u.default.cyan(t)}: ${r}`},mp=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,hp=({context:e,result:t})=>{for(let n of t.issues)mp({context:e,issue:n})&&console.log(pp(n));t.valid||process.exit(1)},gp=({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 cf){if(!r[e])continue;let i=K(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},_p=/^(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,vp=/^application\/(.*\+)?json(;.*)?$/i,yp=/^multipart\/form-data(;.*)?$/i,bp=/^text\/[a-z0-9.+-]+(;.*)?$/i,xp=/^application\/x-www-form-urlencoded(;.*)?$/i,Sp=/^application\/octet-stream(;.*)?$/i,Cp=({mediaType:e})=>(_p.lastIndex=0,_p.test(e)),wp=({mediaType:e})=>{if(vp.lastIndex=0,vp.test(e))return`json`;if(yp.lastIndex=0,yp.test(e))return`form-data`;if(bp.lastIndex=0,bp.test(e))return`text`;if(xp.lastIndex=0,xp.test(e))return`url-search-params`;if(Sp.lastIndex=0,Sp.test(e))return`octet-stream`},Tp=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Cp({mediaType:t})?{...n,format:`binary`}:n:Cp({mediaType:t})?{format:`binary`,type:`string`}:void 0},Ep=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:wp({mediaType:r})});return n};function Dp(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Op=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[z(e)]:r},kp=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Ap=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},jp=({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`)},Mp=({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=C({items:i,schema:t}),t},Np=({irSchema:e={}})=>(e.type=`boolean`,e),Pp=({irSchema:e={},schema:t})=>(e.type=t.type,e),Fp=({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},Ip=({irSchema:e={}})=>(e.type=`string`,e),Lp=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},Rp=({schema:e})=>{let t={};return Ap({irSchema:t,schema:e}),Lp({source:e,target:t}),t},zp=({context:e,schema:t,state:n})=>{let r=Rp({schema:t}),i=[],a=kp({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=Op(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=Wp({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(kp({schema:a})===`object`){let i=Wp({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t[`x-nullable`]){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Bp=({context:e,schema:t,state:n})=>{let r=Rp({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=Wp({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=C({items:i,schema:r}),r},Vp=({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},Hp=({context:e,irSchema:t,schema:n,state:r})=>{t||=Rp({schema:n});let i={};return jp({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[Wp({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Up=({context:e,schema:t,state:n})=>{let r=Rp({schema:t});jp({irSchema:r,schema:t});let i=kp({schema:t});return i?t[`x-nullable`]?Hp({context:e,irSchema:r,schema:{...t,type:i},state:n}):Wp({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Wp=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Rp({schema:n}),jp({irSchema:t,schema:n})),n.type){case`array`:return Mp({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Np({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Pp({context:e,irSchema:t,schema:n,state:r});case`object`:return Fp({context:e,irSchema:t,schema:n,state:r});case`string`:return Ip({context:e,irSchema:t,schema:n,state:r});default:return Gp({context:e,irSchema:t,schema:n})}},Gp=({irSchema:e,schema:t})=>(e||=Rp({schema:t}),e.type=`unknown`,jp({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?Vp({context:e,schema:t,state:n}):t.enum?Bp({context:e,schema:t,state:n}):t.allOf?zp({context:e,schema:t,state:n}):t.type||t.properties?Up({context:e,schema:t,state:n}):Gp({context:e,schema:t})),Kp=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[z(e)]=X({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},qp=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Jp=({context:e,name:t,schema:n})=>{if(Dp(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?Jp({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):Jp({context:e,name:t,schema:r})}if(`in`in n)return n.in?Jp({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(Dp(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&qp(kp({schema:e})))return t}for(let r of n.allOf??[]){let n=Jp({context:e,name:t,schema:r});if(n)return n}return!1},Yp=({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)},Xp=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:uf({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Yp({irOperation:a,operation:n}),Lp({source:n,target:a}),a},Zp=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Xp({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=Ep({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=Jp({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=Ep({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,...Tp({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},Qp=({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]=Zp({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},$p=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},em=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},tm=({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()]=nm({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},nm=({$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=Jp({context:t,name:n.name,schema:i}),o=em(n.in),s={allowReserved:!1,explode:$p(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),Lp({source:n,target:s}),s},rm=({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=Ia(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})))},im=(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 cf){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},am=e=>{if(e.config.parser.validate_EXPERIMENTAL&&hp({context:e,result:im(e.spec,e.logger)}),_f(e.config.parser.filters)){let t=gf(e.config.parser.filters,e.spec,e.logger),{graph:n}=ep(e.spec,e.logger),{resourceMetadata:r}=Af(n,e.logger);gp({...kf({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}up({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];Kp({$ref:n,context:e,schema:r})}for(let r in rm({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:tm({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=Y({source:tm({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});Qp({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=Y({source:tm({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});Qp({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=Y({source:tm({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});Qp({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=Y({source:tm({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});Qp({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=Y({source:tm({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});Qp({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=Y({source:tm({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});Qp({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=Y({source:tm({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});Qp({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},om=({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 cf){if(!r[e])continue;let i=K(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},sm=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Cp({mediaType:t})?{...n,format:`binary`}:n:Cp({mediaType:t})?{format:`binary`,type:`string`}:void 0},cm=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:wp({mediaType:n})});return t},lm=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},um=({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,um({context:e,discriminators:t,schema:n})}return t},dm=({discriminator:e,schemaRef:t})=>{let n=[];for(let[r,i]of Object.entries(e.mapping||{}))i===t&&n.push(r);return n},fm=({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)},pm=({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`)},mm=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=Z({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!n.items.nullable?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},hm=({irSchema:e={}})=>(e.type=`boolean`,e),gm=({irSchema:e={},schema:t})=>(e.type=t.type,e),_m=({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},vm=({irSchema:e={}})=>(e.type=`string`,e),ym=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},bm=({schema:e})=>{let t={};return fm({irSchema:t,schema:e}),ym({source:e,target:t}),t},xm=({context:e,schema:t,state:n})=>{let r=bm({schema:t}),i=[],a=lm({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=um({context:e,schema:t});for(let{discriminator:i,oneOf:a}of r){if(c.has(i.propertyName))continue;let o=Op(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=dm({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=Om({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(lm({schema:a})===`object`){let i=Om({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t.nullable){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Sm=({context:e,schema:t,state:n})=>{let r=bm({schema:t}),i=[],a=lm({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=Op(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(t.nullable&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Om({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Cm=({context:e,schema:t,state:n})=>{let r=bm({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=Om({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=C({items:i,schema:r}),r},wm=({context:e,schema:t,state:n})=>{let r=bm({schema:t}),i=[],a=lm({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=Op(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(t.nullable&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Om({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Tm=({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},Em=({context:e,irSchema:t,schema:n,state:r})=>{t||=bm({schema:n});let i={};return pm({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[Om({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Dm=({context:e,schema:t,state:n})=>{let r=bm({schema:t});pm({irSchema:r,schema:t});let i=lm({schema:t});return i?t.nullable?Em({context:e,irSchema:r,schema:{...t,type:i},state:n}):Om({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Om=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=bm({schema:n}),pm({irSchema:t,schema:n})),n.type){case`array`:return mm({context:e,irSchema:t,schema:n,state:r});case`boolean`:return hm({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return gm({context:e,irSchema:t,schema:n,state:r});case`object`:return _m({context:e,irSchema:t,schema:n,state:r});case`string`:return vm({context:e,irSchema:t,schema:n,state:r});default:return km({context:e,irSchema:t,schema:n})}},km=({irSchema:e,schema:t})=>(e||=bm({schema:t}),e.type=`unknown`,pm({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?Tm({context:e,schema:t,state:n}):t.enum?Cm({context:e,schema:t,state:n}):t.allOf?xm({context:e,schema:t,state:n}):t.anyOf?Sm({context:e,schema:t,state:n}):t.oneOf?wm({context:e,schema:t,state:n}):t.type||t.properties?Dm({context:e,schema:t,state:n}):km({context:e,schema:t})),Am=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[z(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},jm=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Mm=({context:e,name:t,schema:n})=>{if(Dp(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=cm({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Mm({context:e,name:t,schema:n}):!1}return Mm({context:e,name:t,schema:r})}for(let t in n.properties)if(Dp(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&jm(lm({schema:e})))return t}for(let r of n.allOf??[]){let n=Mm({context:e,name:t,schema:r});if(n)return n}return!1},Nm=({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)},Pm=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:uf({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Nm({irOperation:a,operation:n}),ym({source:n,target:a}),a},Fm=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Pm({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=cm({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Mm({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=cm({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,...sm({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},Im=({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]=Fm({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Lm=e=>{switch(e){case`query`:return!1;default:return}},Rm=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},zm=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Bm=({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()]=Vm({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Vm=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=cm({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=Mm({context:t,name:n.name,schema:i}),o=n.style||zm(n.in),s=n.explode===void 0?Rm(o):n.explode,c={allowReserved:n.allowReserved===void 0?Lm(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),ym({source:n,target:c}),c},Hm=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[z(e)]=Vm({$ref:e,context:t,parameter:n})},Um=({$ref:e,context:t,requestBody:n})=>{let r=cm({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},Wm=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[z(e)]=Um({$ref:e,context:t,requestBody:n})},Gm=({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=Ia(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Km=(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 cf){let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},qm=e=>{if(e.config.parser.validate_EXPERIMENTAL&&hp({context:e,result:Km(e.spec,e.logger)}),_f(e.config.parser.filters)){let t=gf(e.config.parser.filters,e.spec,e.logger),{graph:n}=ep(e.spec,e.logger),{resourceMetadata:r}=Af(n,e.logger);om({...kf({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}up({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];Hm({$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];Wm({$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];Am({$ref:n,context:e,schema:r})}}for(let r in Gm({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:Bm({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Im({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:Bm({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Im({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:Bm({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Im({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:Bm({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Im({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:Bm({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Im({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:Bm({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Im({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:Bm({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Im({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:Bm({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Im({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:Bm({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Jm=({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 cf){if(!r[e])continue;let i=K(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Ym=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&Cp({mediaType:t})?{...n,format:`binary`}:n:Cp({mediaType:t})?{format:`binary`,type:`string`}:void 0},Xm=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:wp({mediaType:n})});return t},Zm=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],Qm=({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,Qm({context:e,discriminators:t,schema:n})}return t},$m=({discriminator:e,schemaRef:t})=>{let n=[];for(let[r,i]of Object.entries(e.mapping||{}))i===t&&n.push(r);return n},eh=({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)},th=({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`)},nh=({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&&!Zm({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},rh=({irSchema:e={}})=>(e.type=`boolean`,e),ih=({irSchema:e={}})=>(e.type=`null`,e),ah=({irSchema:e={},schema:t})=>(e.type=t.type,e),oh=({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},sh=({irSchema:e={}})=>(e.type=`string`,e),ch=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},lh=({schema:e})=>{let t={};return eh({irSchema:t,schema:e}),ch({source:e,target:t}),t},uh=({context:e,schema:t,state:n})=>{let r=lh({schema:t});th({irSchema:r,schema:t});let i=[],a=Zm({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=Qm({context:e,schema:t});for(let{discriminator:i,oneOf:a}of r){if(c.has(i.propertyName))continue;let o=Op(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=$m({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=hh({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(Zm({schema:a}).includes(`object`)){let i=hh({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),a.includes(`null`)){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`}}return r},dh=({context:e,schema:t,state:n})=>{let r=lh({schema:t});th({irSchema:r,schema:t});let i=[],a=Zm({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=Op(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=hh({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},fh=({context:e,schema:t,state:n})=>{let r=lh({schema:t});r.type=`enum`;let i=[],a=Zm({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=hh({context:e,schema:{const:o,description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:c},state:n});i.push(l)}return r=C({items:i,schema:r}),r},ph=({context:e,schema:t,state:n})=>{let r=lh({schema:t});th({irSchema:r,schema:t});let i=[],a=Zm({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=Op(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=hh({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},mh=({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=lh({schema:t});th({irSchema:r,schema:t});let i={};if(i.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,Q({context:e,schema:r,state:n}),n.$ref=i}let a=[];return a.push(i),t.type&&typeof t.type!=`string`&&t.type.includes(`null`)&&a.push({type:`null`}),r=C({items:a,mutateSchemaOneItem:!0,schema:r}),r},hh=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=lh({schema:n}),th({irSchema:t,schema:n})),n.type){case`array`:return nh({context:e,irSchema:t,schema:n,state:r});case`boolean`:return rh({context:e,irSchema:t,schema:n});case`integer`:case`number`:return ah({context:e,irSchema:t,schema:n});case`null`:return ih({context:e,irSchema:t,schema:n});case`object`:return oh({context:e,irSchema:t,schema:n,state:r});case`string`:return sh({context:e,irSchema:t,schema:n});default:return vh({context:e,irSchema:t,schema:n})}},gh=({context:e,irSchema:t,schema:n,state:r})=>{t||=lh({schema:n});let i={};th({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=hh({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=C({items:a,schema:t}),t},_h=({context:e,schema:t,state:n})=>{let r=lh({schema:t});th({irSchema:r,schema:t});let i=Zm({schema:t});return i.length===1?hh({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):gh({context:e,irSchema:r,schema:{...t,type:i},state:n})},vh=({irSchema:e,schema:t})=>(e||=lh({schema:t}),e.type=`unknown`,th({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?mh({context:e,schema:t,state:n}):t.enum?fh({context:e,schema:t,state:n}):t.allOf?uh({context:e,schema:t,state:n}):t.anyOf?dh({context:e,schema:t,state:n}):t.oneOf?ph({context:e,schema:t,state:n}):t.type||t.properties?_h({context:e,schema:t,state:n}):vh({context:e,schema:t})),yh=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[z(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},bh=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),xh=({context:e,name:t,schema:n})=>{if(Dp(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=Xm({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?xh({context:e,name:t,schema:n}):!1}return xh({context:e,name:t,schema:r})}for(let t in n.properties)if(Dp(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=Zm({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&bh(Zm({schema:n[0]})))return t}if(bh(n))return t}}for(let r of n.allOf??[]){let n=xh({context:e,name:t,schema:r});if(n)return n}return!1},Sh=({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)},Ch=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:uf({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Sh({irOperation:a,operation:n}),ch({source:n,target:a}),a},wh=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Ch({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=Xm({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=xh({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=Xm({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,...Ym({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},Th=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:wh({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),Eh=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Th({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Dh=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Th({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},Oh=e=>{switch(e){case`query`:return!1;default:return}},kh=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Ah=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()]=jh({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},jh=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Xm({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=xh({context:t,name:n.name,schema:i}),o=n.style||Ah(n.in),s=n.explode===void 0?kh(o):n.explode,c={allowReserved:n.allowReserved===void 0?Oh(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),ch({source:n,target:c}),c},Mh=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[z(e)]=jh({$ref:e,context:t,parameter:n})},Nh=({$ref:e,context:t,requestBody:n})=>{let r=Xm({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},Ph=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[z(e)]=Nh({$ref:e,context:t,requestBody:n})},Fh=({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=Ia(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Ih=(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 cf){let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Lh=({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&&Dh({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Dh({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Dh({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Dh({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Dh({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Dh({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Dh({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Dh({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Rh=e=>{if(e.config.parser.validate_EXPERIMENTAL&&hp({context:e,result:Ih(e.spec,e.logger)}),_f(e.config.parser.filters)){let t=gf(e.config.parser.filters,e.spec,e.logger),{graph:n}=ep(e.spec,e.logger),{resourceMetadata:r}=Af(n,e.logger);Jm({...kf({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}up({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];Mh({$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];Ph({$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];yh({$ref:n,context:e,schema:r})}}for(let r in Fh({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&&Eh({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Eh({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Eh({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Eh({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Eh({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Eh({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Eh({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Eh({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}Lh({context:e,securitySchemesMap:n})},zh=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new sf({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return am(i),i;if(to(i.spec.openapi,`>=3.0.0 <3.1.0`))return qm(i),i;if(to(i.spec.openapi,`>=3.1.0`))return Rh(i),i;throw Error(`Unsupported OpenAPI specification`)};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return kd}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Ea}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return gi}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Pd}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Da}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return ep}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Ba}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Kd}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Pa}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return zh}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return b}});
14
+ //# sourceMappingURL=openApi-CcUF29dR.cjs.map