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CAAO,EAAW,GAC/B,OAAO,EACJ,MAAM,MACN,KAAK,GAAS,IAAI,OAAO,GAAM,IAC/B,KAAK,KACV,CAEO,yBAAO,CACZ,EACA,EAAgC,IAAI,gBAAA,YAEpC,OAAO,EAAK,SAAS,EACvB,EAhHF,QAAA","file":"/npm/ifc-expressions@2.3.0/dist/cjs/IfcExpression.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ifc-expressions@2.3.0/dist/cjs/IfcExpression.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import {\n  CharStream,\n  CommonTokenStream,\n  ErrorListener,\n  ParserRuleContext,\n  ParseTreeWalker,\n  Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n  ExprEvalError,\n  ExprEvalResult,\n  isExprEvalError,\n  isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\nimport { IfcDurationValue } from \"./value/IfcDurationValue\";\nimport { IfcDateValue } from \"./value/IfcDateValue.js\";\nimport { IfcDateTimeValue } from \"./value/IfcDateTimeValue.js\";\nimport { IfcTimeValue } from \"./value/IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./value/IfcTimeStampValue.js\";\nimport { ArrayType } from \"./type/ArrayType.js\";\nimport { ExprType } from \"./type/ExprType.js\";\nimport { SimpleType } from \"./type/SimpleType.js\";\nimport { TupleType } from \"./type/TupleType.js\";\nimport { TypeDisjunction } from \"./type/TypeDisjunction.js\";\nimport { Types } from \"./type/Types.js\";\n\nexport {\n  IfcElementAccessor,\n  IfcExpressionContext,\n  Value,\n  StringValue,\n  BooleanValue,\n  LogicalValue,\n  NumericValue,\n  ExpressionValue,\n  ReferenceValue,\n  IfcDateValue,\n  IfcDateTimeValue,\n  IfcTimeValue,\n  IfcDurationValue,\n  IfcTimeStampValue,\n  IfcPropertySetAccessor,\n  IfcPropertyAccessor,\n  IfcRootObjectAccessor,\n  IfcTypeObjectAccessor,\n  NamedObjectAccessor,\n  ObjectAccessor,\n  Expr,\n  ExprCompiler,\n  ExprKind,\n  IfcExpressionEvaluationException,\n  IfcExpressionErrorListener,\n  IfcExpressionVisitor,\n  isPresent,\n  isNullish,\n  ExprEvalResult,\n  ExprEvalError,\n  isExprEvalError,\n  isExprEvalSuccess,\n  ExprToTextInputLinker,\n  ExprFacade,\n  ArrayType,\n  ExprType,\n  SimpleType,\n  TupleType,\n  TypeDisjunction,\n  Types,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n  private readonly _input: string;\n  private readonly _typeManager: TypeManager;\n  private readonly _parseTree: ParserRuleContext;\n\n  constructor(input: string, typeManager: TypeManager, exprContext) {\n    this._typeManager = typeManager;\n    this._parseTree = exprContext;\n    this._input = input;\n  }\n\n  get typeManager(): TypeManager {\n    return this._typeManager;\n  }\n\n  get parseTree(): ParserRuleContext {\n    return this._parseTree;\n  }\n\n  get input(): string {\n    return this._input;\n  }\n}\n\nexport class IfcExpression {\n  /**\n   * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n   * @param input\n   * @param errorListener\n   * @return the parse result, which can subequently be compiled into an Expr using compile().\n   */\n  public static parse(\n    input: string,\n    errorListener?: ErrorListener<Token | number>\n  ): IfcExpressionParseResult {\n    const chars = new CharStream(input); // replace this with a FileStream as required\n    const lexer = new IfcExpressionLexer(chars);\n    const tokens = new CommonTokenStream(lexer);\n    const parser = new IfcExpressionParser(tokens);\n    lexer.removeErrorListeners();\n    parser.removeErrorListeners();\n    const myErrorListener = new IfcExpressionErrorListener();\n    if (isPresent(errorListener)) {\n      lexer.addErrorListener(errorListener);\n      parser.addErrorListener(errorListener);\n    }\n    lexer.addErrorListener(myErrorListener);\n    parser.addErrorListener(myErrorListener);\n    let expr;\n    expr = parser.expr();\n    const validationListener = new IfcExpressionValidationListener();\n    if (!myErrorListener.isErrorOccurred()) {\n      const walker = new ParseTreeWalker();\n      try {\n        walker.walk(validationListener, expr);\n      } catch (e) {\n        if (e instanceof ValidationException) {\n          if (errorListener instanceof IfcExpressionErrorListener) {\n            errorListener.validationException(e);\n          }\n          myErrorListener.validationException(e);\n        }\n      }\n    }\n    return new IfcExpressionParseResult(\n      input,\n      validationListener.getTypeManager(),\n      expr\n    );\n  }\n\n  /**\n   * Compiles the specified parseResult into an Expr.\n   * @param parseResult\n   * @return the Expression (Expr), which can be evaluated to obtain its result.\n   */\n  public static compile(\n    parseResult: IfcExpressionParseResult\n  ): ExprFacade<ExpressionValue> {\n    const compiler = new ExprCompiler(parseResult.typeManager);\n    const expr = compiler.visit(parseResult.parseTree);\n    ExprToTextInputLinker.linkTextToExpressions(\n      parseResult.input,\n      expr,\n      compiler.getExprManager()\n    );\n    return new ExprFacade(expr);\n  }\n\n  /**\n   * Evaluates the specified input expression and returns the evaluation result. The parse\n   * and compile steps are done internally.\n   *\n   * @param expression: the input expression\n   * @param context: the context required for accessing the IFC model\n   * @return the result (or an error object).\n   */\n  public static evaluate(\n    expression: string,\n    context: IfcExpressionContext = new NopContext()\n  ): ExprEvalResult<ExpressionValue> {\n    const errorListener = new IfcExpressionErrorListener();\n    const parseResult = IfcExpression.parse(expression, errorListener);\n    if (errorListener.isErrorOccurred()) {\n      return mapException(errorListener.getException());\n    }\n    const compiledExpression = this.compile(parseResult);\n    return compiledExpression.evaluate(context);\n  }\n\n  public static formatError(input: string, error: ExprEvalError) {\n    const lines = [\"** Error **\"];\n    if (!isNullish(error[\"textSpan\"])) {\n      const span: TextSpan = error[\"textSpan\"];\n      const underlined = span.underline(input, \"^\");\n      const startString = \"Input: \";\n      const indented = this.indent(underlined, startString.length);\n      const replaced = startString + indented.substr(startString.length);\n      replaced.split(\"\\n\").forEach((line) => lines.push(line));\n    }\n    lines.push(\"Problem: \" + error.message);\n    return lines.join(\"\\n\");\n  }\n\n  private static indent(s: string, by: number) {\n    return s\n      .split(\"\\n\")\n      .map((line) => \" \".repeat(by) + line)\n      .join(\"\\n\");\n  }\n\n  public static evaluateExpression(\n    expr: ExprFacade<ExpressionValue>,\n    context: IfcExpressionContext = new NopContext()\n  ) {\n    return expr.evaluate(context);\n  }\n}\n"]}