"use strict";var a=b(require("handlebars"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function b(a){return a&&a.__esModule?a:{default:a}}var c=a["default"].compile("const { Kafka } = require('kafkajs');\n{{#if schema.isAvro}}\nconst avro = require('avro-js');\n{{/if}}\n{{#if securityDetails.MUTUAL_TLS}}\nconst fs = require('fs');\n{{else}}\n  {{#if securityDetails.SSL}}\nconst fs = require('fs');\n  {{/if}}\n{{/if}}\n\nconst kafka = new Kafka({\n  {{#if operationBindings.clientId}}\n  clientId: '{{{operationBindings.clientId}}}',\n  {{else}}\n  {{#if enforced}}\n  clientId: '<Client Id>',\n  {{/if}}\n  {{/if}}\n  brokers: [{{{bootstrapServers}}}],\n  {{#if securityDetails.MUTUAL_TLS}}\n  ssl: {\n    key: fs.readFileSync('<path to client key>', 'utf-8'),\n    ca: fs.readFileSync('<path to cluster CA>', 'utf-8'),\n    cert: fs.readFileSync('<path to client cert>', 'utf-8')\n  },\n  {{else}}\n   {{#if securityDetails.SSL}}\n  ssl: {\n    ca: fs.readFileSync('<path to cluster CA>', 'utf-8')\n  },\n    {{/if}}\n  {{/if}}\n  {{#if securityDetails.SASL}}\nsasl: {\n    mechanism: '{{securityDetails.saslMechanism}}',\n    username: '{{securityDetails.saslUsername}}',\n    password: '<SASL_password>'\n  }\n  {{/if}}\n});\n\nconst topic = '{{{channel}}}';\nconst consumer = kafka.consumer({ groupId: {{#if applicationDetails.groupId}}'{{{applicationDetails.groupId}}}'{{else}}'<Group Id>'{{/if}} });\n{{#if schema.isAvro}}\nconst payloadType = avro.parse('{{schema.fileName}}');\n{{/if}}\n\nconst startConsumer = async () => {\n  await consumer.connect();\n  await consumer.subscribe({ topic });\n \n  await consumer.run({\n    eachMessage: async ({ topic, partition, message }) => {\n      console.log({\n        topic,\n        partition,\n        offset: message.offset,\n        key: message.key,\n        {{#if schema.isAvro}}\n          {{#if encodingType.JSONEncoded}}\n        value: payloadType.fromString(message.value)\n          {{else}}\n        value: payloadType.fromBuffer(message.value)\n          {{/if}}\n        {{else}}\n        value: message.value.toString()\n        {{/if}}\n      })\n    },\n  })\n}\n \nstartConsumer().catch(console.error)");exports["default"]=c;