{"version":3,"file":"operations.cjs","sources":["../../../../../src/querybuilder/shared/rendering/operations.ts"],"sourcesContent":["import { PromVisualQueryOperationCategory } from '../../types';\nimport { type PrometheusVisualQuery, type QueryBuilderOperation, type QueryBuilderOperationDef } from '../types';\n\n/**\n * Renders operations\n */\nexport function renderOperations(\n  queryString: string,\n  operations: QueryBuilderOperation[],\n  operationsRegistry: Map<string, QueryBuilderOperationDef>\n): string {\n  for (const operation of operations) {\n    const def = operationsRegistry.get(operation.id);\n    if (!def) {\n      throw new Error(`Could not find operation ${operation.id} in the registry`);\n    }\n    queryString = def.renderer(operation, def, queryString);\n  }\n\n  return queryString;\n}\n\n/**\n * Checks if query has binary operation\n */\nexport function hasBinaryOp(\n  query: PrometheusVisualQuery,\n  operationsRegistry: Map<string, QueryBuilderOperationDef>\n): boolean {\n  return (\n    query.operations.find((op) => {\n      const def = operationsRegistry.get(op.id);\n      return def?.category === PromVisualQueryOperationCategory.BinaryOps;\n    }) !== undefined\n  );\n}\n"],"names":["PromVisualQueryOperationCategory"],"mappings":";;;;;;;AAMO,SAAS,gBAAA,CACd,WAAA,EACA,UAAA,EACA,kBAAA,EACQ;AACR,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,MAAM,GAAA,GAAM,kBAAA,CAAmB,GAAA,CAAI,SAAA,CAAU,EAAE,CAAA;AAC/C,IAAA,IAAI,CAAC,GAAA,EAAK;AACR,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,yBAAA,EAA4B,SAAA,CAAU,EAAE,CAAA,gBAAA,CAAkB,CAAA;AAAA,IAC5E;AACA,IAAA,WAAA,GAAc,GAAA,CAAI,QAAA,CAAS,SAAA,EAAW,GAAA,EAAK,WAAW,CAAA;AAAA,EACxD;AAEA,EAAA,OAAO,WAAA;AACT;AAKO,SAAS,WAAA,CACd,OACA,kBAAA,EACS;AACT,EAAA,OACE,KAAA,CAAM,UAAA,CAAW,IAAA,CAAK,CAAC,EAAA,KAAO;AAC5B,IAAA,MAAM,GAAA,GAAM,kBAAA,CAAmB,GAAA,CAAI,EAAA,CAAG,EAAE,CAAA;AACxC,IAAA,OAAA,CAAO,GAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,GAAA,CAAK,cAAaA,sCAAA,CAAiC,SAAA;AAAA,EAC5D,CAAC,CAAA,KAAM,KAAA,CAAA;AAEX;;;;;"}