(()=>{function e(e,n,t,o,r,c,a,i,u,s){var l,m=this;_.assign(m,{$onInit:function(){e.all(_.transform(r.APIS.values(),function(e,n){var t="".concat(n.name,"S"),t=_.get(c.ENTITIES[t],"staticSchemaPath");t&&(e[n.value]=c.another(t).list())},{})).then(function(e){l=e})},$onChanges:function(e){e.inputDuplicateId&&m.inputDuplicateId?(e=>{r.getConnectorDuplicate(e).then(r.convertToViewModel).then(function(e){m.connector=e})})(m.inputDuplicateId):e.inputId&&m.inputId?(e=>{"new"===e?(m.connector=r.getConnectorStub(),t.find("#connectorName").eq(0).focus()):r.getConnector(e).then(r.convertToViewModel).then(function(e){m.connector=e})})(m.inputId):e.inputConnector&&m.inputConnector&&(e=>{m.connector=r.convertToViewModel(e)})(m.inputConnector)},addFilter:function(){m.connector.filters.push({isOpen:!0,selectedGroupOrDevice:null,apis:{alarm:!0,event:!0,measurement:!0,managedObject:!0,operation:!0},fragmentsToFilter:[{fragment:""}],fragmentsToCopy:[{fragment:""}],copyAllFragments:!1,typeFilter:""}),m.connectorForm.$setDirty()},removeFilter:function(e){_.remove(m.connector.filters,e),m.connectorForm.$setDirty()},addFragment:function(e,n){e[n].push({fragment:""}),m.connectorForm.$setDirty()},removeFragment:function(e,n,t){1===e[n].length?_.set(e[n][0],"fragment",""):_.remove(e[n],t);m.connectorForm.$setDirty()},getSuggestedFragments:function(e){return _(e.apis).map(function(e,n){return e?_.get(l,n,[]):[]}).flatten().reject("computed").map(function(e){return e.keyPath.join(".")}).uniq().orderBy([function(e){return e.toLowerCase()}],["asc"]).value()},saveName:function(e){e=n.onSaveName?m.onSaveName({connector:m.connector,name:e}):((e,n)=>r.updateConnectorName(e,n).then(function(){o.hasId(e)&&a.success(i("Connector name updated."))}))(m.connector,e);return e},canSave:function(){return m.connectorForm.$dirty&&m.connectorForm.$valid&&_.get(m,"connector.filters")&&1<=m.connector.filters.length&&_.every(m.connector.filters,function(e){return _.some(e.apis)})},save:function(){var e=r.convertToBackendModel(m.connector);e=n.onSave?m.onSave({connector:e,connectorForm:m.connectorForm}):(e=>r.saveConnector(e).then(r.navigateToDetails).then(function(){a.success(i("Connector saved.")),m.connectorForm.$setPristine()}))(e);return e},remove:function(){var e=r.convertToBackendModel(m.connector);e=n.onRemove?m.onRemove({connector:e}):(e=>u({title:i("Delete connector"),body:s.getString('You are about to delete connector "{{name}}". Do you want to proceed?',{name:e.name}),status:"danger",labels:{ok:i("Delete")}}).then(function(){return r.deleteConnector(e.id).then(r.navigateToList).then(function(){a.success(i("Connector deleted."))})}))(e);return e},cancel:function(){var e;n.onCancel?e=m.onCancel():r.navigateToList();return e},getFilterFragmentsSummary:r.getFilterFragmentsSummary,apis:r.APIS.values()})}e.$inject=["$q","$attrs","$element","c8yBase","dataBrokerConnectorsSvc","c8yPropertiesLibrary","c8yAlert","gettext","c8yModal","gettextCatalog"],angular.module("c8y.dataBroker").component("c8yDataBrokerConnectorEditor",{bindings:{inputDuplicateId:"<duplicateId",inputId:"<id",inputConnector:"<connector",onSave:"&",onSaveName:"&",onRemove:"&",onCancel:"&"},templateUrl:":::PLUGIN_PATH:::/connectors/connectorEditor.html",controller:e,controllerAs:"vm"})})();