{"version":3,"file":"builders.cjs","names":[],"sources":["../../../src/codegen/builders.ts"],"sourcesContent":["import { AST_NODE_TYPES, type TSESTree } from \"@typescript-eslint/types\";\n\nimport { asNode } from \"./ast.js\";\n\nexport function id(name: string): TSESTree.Identifier {\n  return asNode<TSESTree.Identifier>({\n    type: AST_NODE_TYPES.Identifier,\n    name,\n    decorators: [],\n    optional: false,\n    typeAnnotation: undefined,\n  });\n}\n\nexport function str(value: string): TSESTree.StringLiteral {\n  return asNode<TSESTree.StringLiteral>({\n    type: AST_NODE_TYPES.Literal,\n    value,\n    raw: JSON.stringify(value),\n  });\n}\n\nexport function tsLiteralType(value: string): TSESTree.TSLiteralType {\n  return asNode<TSESTree.TSLiteralType>({\n    type: AST_NODE_TYPES.TSLiteralType,\n    literal: str(value),\n  });\n}\n\nexport function tsTypeReference(name: string): TSESTree.TSTypeReference {\n  return asNode<TSESTree.TSTypeReference>({\n    type: AST_NODE_TYPES.TSTypeReference,\n    typeName: id(name),\n    typeArguments: undefined,\n  });\n}\n\nexport function tsIndexedAccessType(\n  objectType: TSESTree.TypeNode,\n  indexType: TSESTree.TypeNode,\n): TSESTree.TSIndexedAccessType {\n  return asNode<TSESTree.TSIndexedAccessType>({\n    type: AST_NODE_TYPES.TSIndexedAccessType,\n    objectType,\n    indexType,\n  });\n}\n\nexport function tsUnionType(members: TSESTree.TypeNode[]): TSESTree.TypeNode {\n  if (members.length === 0) {\n    return asNode<TSESTree.TSNeverKeyword>({ type: AST_NODE_TYPES.TSNeverKeyword });\n  }\n  if (members.length === 1) {\n    return members[0]!;\n  }\n  return asNode<TSESTree.TSUnionType>({\n    type: AST_NODE_TYPES.TSUnionType,\n    types: members,\n  });\n}\n\nexport function tsTypeAnnotation(type: TSESTree.TypeNode): TSESTree.TSTypeAnnotation {\n  return asNode<TSESTree.TSTypeAnnotation>({\n    type: AST_NODE_TYPES.TSTypeAnnotation,\n    typeAnnotation: type,\n  });\n}\n\nexport function tsPropertySignature(\n  key: TSESTree.PropertyNameNonComputed,\n  type: TSESTree.TypeNode,\n): TSESTree.TSPropertySignatureNonComputedName {\n  return asNode<TSESTree.TSPropertySignatureNonComputedName>({\n    type: AST_NODE_TYPES.TSPropertySignature,\n    computed: false,\n    key,\n    optional: false,\n    readonly: false,\n    static: false,\n    accessibility: undefined,\n    typeAnnotation: tsTypeAnnotation(type),\n  });\n}\n\nexport function tsTypeLiteral(members: TSESTree.TypeElement[]): TSESTree.TSTypeLiteral {\n  return asNode<TSESTree.TSTypeLiteral>({\n    type: AST_NODE_TYPES.TSTypeLiteral,\n    members,\n  });\n}\n\nexport function tsTypeAlias(\n  name: string,\n  type: TSESTree.TypeNode,\n): TSESTree.TSTypeAliasDeclaration {\n  return asNode<TSESTree.TSTypeAliasDeclaration>({\n    type: AST_NODE_TYPES.TSTypeAliasDeclaration,\n    declare: false,\n    id: id(name),\n    typeParameters: undefined,\n    typeAnnotation: type,\n  });\n}\n\nexport function tsTypeQuery(name: string): TSESTree.TSTypeQuery {\n  return asNode<TSESTree.TSTypeQuery>({\n    type: AST_NODE_TYPES.TSTypeQuery,\n    exprName: id(name),\n    typeArguments: undefined,\n  });\n}\n\nexport function tsNullKeyword(): TSESTree.TSNullKeyword {\n  return asNode<TSESTree.TSNullKeyword>({ type: AST_NODE_TYPES.TSNullKeyword });\n}\n\nexport function tsTupleType(elements: TSESTree.TypeNode[]): TSESTree.TSTupleType {\n  return asNode<TSESTree.TSTupleType>({\n    type: AST_NODE_TYPES.TSTupleType,\n    elementTypes: elements,\n  });\n}\n\nexport function tsConditionalType(\n  checkType: TSESTree.TypeNode,\n  extendsType: TSESTree.TypeNode,\n  trueType: TSESTree.TypeNode,\n  falseType: TSESTree.TypeNode,\n): TSESTree.TSConditionalType {\n  return asNode<TSESTree.TSConditionalType>({\n    type: AST_NODE_TYPES.TSConditionalType,\n    checkType,\n    extendsType,\n    trueType,\n    falseType,\n  });\n}\n\nexport function tsInferType(typeParameterName: string): TSESTree.TSInferType {\n  return asNode<TSESTree.TSInferType>({\n    type: AST_NODE_TYPES.TSInferType,\n    typeParameter: asNode<TSESTree.TSTypeParameter>({\n      type: AST_NODE_TYPES.TSTypeParameter,\n      name: id(typeParameterName),\n      in: false,\n      out: false,\n      const: false,\n      default: undefined,\n      constraint: undefined,\n    }),\n  });\n}\n\nexport function objectProperty(\n  key: TSESTree.PropertyNameNonComputed,\n  value: TSESTree.Expression,\n): TSESTree.PropertyNonComputedName {\n  return asNode<TSESTree.PropertyNonComputedName>({\n    type: AST_NODE_TYPES.Property,\n    key,\n    value,\n    kind: \"init\",\n    method: false,\n    shorthand: false,\n    computed: false,\n    optional: false,\n  });\n}\n\nexport function objectExpression(\n  properties: TSESTree.PropertyNonComputedName[],\n): TSESTree.ObjectExpression {\n  return asNode<TSESTree.ObjectExpression>({\n    type: AST_NODE_TYPES.ObjectExpression,\n    properties,\n  });\n}\n\nexport function arrayExpression(elements: TSESTree.Expression[]): TSESTree.ArrayExpression {\n  return asNode<TSESTree.ArrayExpression>({\n    type: AST_NODE_TYPES.ArrayExpression,\n    elements,\n  });\n}\n\nexport function importDeclaration(\n  local: string,\n  imported: string,\n  source: string,\n  importKind: \"type\" | \"value\" = \"value\",\n): TSESTree.ImportDeclaration {\n  return asNode<TSESTree.ImportDeclaration>({\n    type: AST_NODE_TYPES.ImportDeclaration,\n    specifiers: [\n      asNode<TSESTree.ImportSpecifier>({\n        type: AST_NODE_TYPES.ImportSpecifier,\n        imported: id(imported),\n        local: id(local),\n        importKind: \"value\",\n      }),\n    ],\n    source: str(source),\n    importKind,\n    assertions: [],\n    attributes: [],\n    phase: null,\n  });\n}\n\nexport function importDefaultDeclaration(\n  local: string,\n  source: string,\n  importKind: \"type\" | \"value\" = \"value\",\n): TSESTree.ImportDeclaration {\n  return asNode<TSESTree.ImportDeclaration>({\n    type: AST_NODE_TYPES.ImportDeclaration,\n    specifiers: [\n      asNode<TSESTree.ImportDefaultSpecifier>({\n        type: AST_NODE_TYPES.ImportDefaultSpecifier,\n        local: id(local),\n      }),\n    ],\n    source: str(source),\n    importKind,\n    assertions: [],\n    attributes: [],\n    phase: null,\n  });\n}\n\nexport function exportConst(\n  name: string,\n  init: TSESTree.Expression,\n): TSESTree.ExportNamedDeclarationWithoutSourceWithSingle {\n  return asNode<TSESTree.ExportNamedDeclarationWithoutSourceWithSingle>({\n    type: AST_NODE_TYPES.ExportNamedDeclaration,\n    declaration: asNode<TSESTree.ConstDeclaration>({\n      type: AST_NODE_TYPES.VariableDeclaration,\n      kind: \"const\",\n      declare: false,\n      declarations: [\n        asNode<TSESTree.VariableDeclaratorMaybeInit>({\n          type: AST_NODE_TYPES.VariableDeclarator,\n          id: id(name),\n          init,\n          definite: false,\n        }),\n      ],\n    }),\n    specifiers: [],\n    exportKind: \"value\",\n    source: null,\n    assertions: [],\n    attributes: [],\n  });\n}\n\nexport function exportTypeAlias(\n  name: string,\n  type: TSESTree.TypeNode,\n): TSESTree.ExportNamedDeclarationWithoutSourceWithSingle {\n  return asNode<TSESTree.ExportNamedDeclarationWithoutSourceWithSingle>({\n    type: AST_NODE_TYPES.ExportNamedDeclaration,\n    declaration: tsTypeAlias(name, type),\n    specifiers: [],\n    exportKind: \"type\",\n    source: null,\n    assertions: [],\n    attributes: [],\n  });\n}\n\nexport function tsAsConst(expression: TSESTree.Expression): TSESTree.TSAsExpression {\n  return asNode<TSESTree.TSAsExpression>({\n    type: AST_NODE_TYPES.TSAsExpression,\n    expression,\n    typeAnnotation: tsTypeReference(\"const\"),\n  });\n}\n"],"mappings":";;;AAIA,SAAgB,GAAG,MAAmC;CACpD,OAAO,YAAA,OAA4B;EACjC,MAAM,yBAAA,eAAe;EACrB;EACA,YAAY,CAAC;EACb,UAAU;EACV,gBAAgB,KAAA;CAClB,CAAC;AACH;AAEA,SAAgB,IAAI,OAAuC;CACzD,OAAO,YAAA,OAA+B;EACpC,MAAM,yBAAA,eAAe;EACrB;EACA,KAAK,KAAK,UAAU,KAAK;CAC3B,CAAC;AACH;AAEA,SAAgB,cAAc,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