"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('node-rdkafka');\n{{#if schema.isAvro}}\nconst avro = require('avro-js');\n{{/if}}\n\nlet driver_options = {\n  'metadata.broker.list': [{{{bootstrapServers}}}],\n  'security.protocol': '{{securityDetails.securityProtocol}}',\n  {{#if securityDetails.MUTUAL_TLS}}\n  'ssl.certificate.location': '<path to client cert>',\n  'ssl.key.location': '<path to client key>',\n  'ssl.key.password': '<ssl key password>',\n  'ssl.ca.location': '<path to cluster ca>',\n  {{else}}\n    {{#if securityDetails.SSL}}\n  'ssl.ca.location': '<path to cluster ca>',\n    {{/if}}\n  {{/if}}\n  {{#if securityDetails.SASL }}\n  'sasl.mechanism': '{{securityDetails.saslMechanism}}',\n  'sasl.username': '{{securityDetails.saslUsername}}',\n  'sasl.password': '<SASL_password>',\n  {{/if}}\n  {{#if operationBindings.clientId}}\n  'client.id': '{{{operationBindings.clientId}}}',\n  {{else}}\n  {{#if enforced}}\n  'client.id': '<Client Id>',\n  {{/if}}\n  {{/if}}\n  'group.id': {{#if applicationDetails.groupId}}'{{{applicationDetails.groupId}}}'{{else}}'<Group Id>'{{/if}}\n};\n\nlet topic_options = {}\n\nlet consumer = new kafka.KafkaConsumer(driver_options, topic_options);\n{{#if schema.isAvro}}\nconst payloadType = avro.parse('{{schema.fileName}}');\n{{/if}}\n\nconsumer.connect(null, function(err) {\n  if (err !== null) {\n    console.log(\"ERROR: \" + err);\n  }\n});\n\nconsumer.on('ready', function(arg) {\n  consumer.subscribe([\"{{channel}}\"]);\n  consumer.consume();\n});\n\nconsumer.on('data', function(data) {\n  const { value, topic, partition, key, offset } = data\n  console.log({\n    topic,\n    partition,\n    offset,\n    key,\n    {{#if schema.isAvro}}\n      {{#if encodingType.JSONEncoded}}\n    value: payloadType.fromString(value)\n      {{else}}\n    value: payloadType.fromBuffer(value)\n    {{/if}}\n    {{else}}\n    value: value.toString()\n    {{/if}}\n  })\n});\n\nconsumer.on('disconnect', function() {\n  console.log('consumer disconnected')\n});\n");exports["default"]=c;