"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("from kafka import KafkaConsumer\n{{#if schema.isAvro }}\nimport avro.schema\n  {{#if encodingType.JSONEncoded}}\nimport json\nimport avro_json_serializer\n  {{else}}\nimport avro.io\nimport io\n  {{/if}}\n{{/if}}\n\n{{#if schema.isAvro }}\nschema = avro.schema.parse(open('{{schema.fileName}}').read())\n  {{#if encodingType.JSONEncoded }}\nserializer = avro_json_serializer.AvroJsonSerializer(schema)\n  {{else}}\nreader = avro.io.DatumReader(schema)\n  {{/if}}\n{{/if}}\n\nconsumer = KafkaConsumer('{{channel}}',\n                         bootstrap_servers=[{{{bootstrapServers}}}],\n                         security_protocol='{{securityDetails.securityProtocol}}',\n                         {{#if securityDetails.MUTUAL_TLS}}\n                         ssl_certfile='<path to client cert>',\n                         ssl_keyfile='<path to client key>',\n                         ssl_password='<ssl key password>',\n                         ssl_cafile='<path to cluster ca>',\n                         {{else}}\n                           {{#if securityDetails.SSL}}\n                         ssl_cafile='<path to cluster ca>',\n                           {{/if}}\n                         {{/if}}\n                         {{#if securityDetails.SASL}}\n                         sasl_mechanism='{{securityDetails.saslMechanism}}',\n                         sasl_plain_username='{{securityDetails.saslUsername}}',\n                         sasl_plain_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 \nfor msg in consumer:\n    {{#if schema.isAvro}}\n      {{#if encodingType.JSONEncoded}}\n    decodedMessageValue = serializer.to_json(json.loads(msg.value.decode('utf-8')))\n      {{else}}\n    bytes_reader = io.BytesIO(msg.value)\n    decoder = avro.io.BinaryDecoder(bytes_reader)\n    decodedMessageValue = reader.read(decoder)\n      {{/if}}\n    {{/if}}\n    message = {\n      \"topic\": msg.topic,\n      \"partition\": msg.partition,\n      \"offset\": msg.offset,\n      \"key\": msg.key,\n      {{#if schema.isAvro}}\n      \"value\": decodedMessageValue\n      {{else}}\n      \"value\": msg.value\n      {{/if}}\n    }\n    print(message)");exports["default"]=c;