"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var a=require("./../../utils/ProtocolTypes.js"),b=require("lodash"),c=require("./../../utils/common.js");function d(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function e(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?d(Object(b),!0).forEach(function(c){f(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):d(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function f(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function g(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function h(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function i(a,b,c){return b&&h(a.prototype,b),c&&h(a,c),a}var j=function(){function d(a,b,c,e,f){g(this,d),this.apiHandler=a,this.channelName=b,this.selectedCredentials=c,this.translate=e,this.isUserLoggedIn=f,this.DEFAULT_AVRO_DESERIALIZER_TYPE="byte",this.DEFAULT_ASYNC_API_DESERIALIZER_TYPE="byte"}return i(d,[{key:"getBootstrapServers",value:function getBootstrapServers(){throw new Error("getBootstrapServers is not implemented")}},{key:"getSchemaInformation",value:function getSchemaInformation(){var a=this.apiHandler.getFirstSchema(this.channelName),b=a.type,d=this.apiHandler.isAvroSchema(b);return{isAvro:d,fileName:(0,c.generateFileName)(this.channelName,d?"avsc":"json")}}},{key:"getKeyDeserializer",value:function getKeyDeserializer(){return""}},{key:"getEncodingType",value:function getEncodingType(){var a=this.apiHandler.getFirstSchema(this.channelName),b=a.encodingType;return{JSONEncoded:"application/json"===b}}},{key:"getApplicationDetails",value:function getApplicationDetails(){var a={};return this.apiHandler.isEnforced()&&(a.groupId=1),a}},{key:"getEnforcedType",value:function getEnforcedType(){return this.apiHandler.isEnforced()}},{key:"getOperationBindings",value:function getOperationBindings(){var a={},c=this.apiHandler.getSubscribeBindings(this.channelName);return c&&(0,b.get)(c,["kafka","clientId"])&&(a.clientId=this.getSingleGroupClientId(c.kafka.clientId)),!this.isUserLoggedIn||a.clientId&&this.getApplicationDetails().groupId||(a.comment=this.translate("contact_api_owner")),a}},{key:"getSingleGroupClientId",value:function getSingleGroupClientId(a){return a["enum"]&&1<a["enum"].length?null:a["enum"]&&1===a["enum"].length?a["enum"][0]:a["const"]?a["const"]:null}},{key:"sasl_ssl",value:function sasl_ssl(){throw new Error("sasl_ssl is not implemented")}},{key:"sasl_plain",value:function sasl_plain(){throw new Error("sasl_plain is not implemented")}},{key:"ssl",value:function ssl(){throw new Error("ssl is not implemented")}},{key:"ssl_mutualtls",value:function ssl_mutualtls(){throw new Error("ssl_mutualtls is not implemented")}},{key:"plaintext",value:function plaintext(){throw new Error("plaintext is not implemented")}},{key:"sasl_sha_256",value:function sasl_sha_256(){throw new Error("sasl_sha_256 is not implemented")}},{key:"sasl_sha_512",value:function sasl_sha_512(){throw new Error("sasl_sha_512 is not implemented")}},{key:"sasl_ssl_sha_256",value:function sasl_ssl_sha_256(){throw new Error("sasl_ssl_sha_256 is not implemented")}},{key:"sasl_ssl_sha_512",value:function sasl_ssl_sha_512(){throw new Error("sasl_ssl_sha_512 is not implemented")}},{key:"getSecurityDetails",value:function getSecurityDetails(){var b,c=this.apiHandler.getFirstSecurityType(),d=c.type,f=this.apiHandler.getFirstProtocol();if(f===a.ProtocolTypes.kafkaSecure)switch(d){case"plain":case"userPassword":b=this.sasl_ssl();break;case"X509":b=this.ssl_mutualtls();break;case"scramSha256":b=this.sasl_ssl_sha_256();break;case"scramSha512":b=this.sasl_ssl_sha_512();break;case"gssapi":default:b=this.ssl();}else if(f===a.ProtocolTypes.kafka)switch(d){case"plain":case"userPassword":b=this.sasl_plain();break;case"X509":b=this.ssl_mutualtls();break;case"scramSha256":b=this.sasl_sha_256();break;case"scramSha512":b=this.sasl_sha_512();break;case"gssapi":default:b=this.plaintext();}return e(e({},b),{},{truststoreWarning:this.translate("truststore_warning"),saslUsername:this.selectedCredentials.credential})}}]),d}();exports["default"]=j;