(()=>{function e(e,a,i,t,n,l){a.availableKpi=function(){return i.getCompatibleKpi(a.kpis,a.dp||{})},a.isKpiAvailable=function(){return a.dp._kpiId&&d(a.dp._kpiId)},a.saveToLibrary=function(t){a.isopen=!1;var e=!!t._kpiId;t._kpiId&&!d(t._kpiId)&&(e=!1,delete t._kpiId);i.saveDataPointToLibrary(t,e).then(function(e){_.isEmpty(e.data)||(t._kpiId=e.data.id),n.success(l("Saved to library.")),a.listKpi()})},a.updateDataPointWithKpi=function(e,t){a.isopen=!1,i.updateDataPointWithKpi(e,t)},a.chartTypes=t.renderTypes,a.lineTypes=t.lineTypes,a.axisTypes=t.axisTypes,a.dpDebounce=300,a.getLinkedKpiLabel=function(){{var e;if(a.dp._kpiId)return e=_.find(a.availableKpi(),{id:a.dp._kpiId}),_.get(e,"c8y_Kpi.label","")}return},a.setRangesFieldsAsTouched=_.once(function(){_.forEach(o,function(e){return _.get(a.singleDpForm,e).$setTouched()})}),a.isCollapsed=!1,a.collapse=function(){a.isCollapsed=!a.isCollapsed,a.defaultDatapoint||i.listForObject(a.dp.__target).then(p)},a.localIsEqualToTargetDp=function(){return i.equals(a.defaultDatapoint,a.dp)},a.localIsEqualToTargetDpValue=function(e){var t=_.get(a.defaultDatapoint,e),e=_.get(a.dp,e);return i.equals(t,e)},a.defaultDatapoint=void 0,a.save=function(){a.dp&&!a.dontSave&&i.save(a.dp.__target,a.dp).then(p)},a.onRangeFieldChange=function(){r(),a.setRangesFieldsAsTouched()};var o=["min","max","yellowRangeMin","yellowRangeMax","redRangeMin","redRangeMax"];function p(e){a.defaultDatapoint=e[a.dp._id]}function d(e){return _.some(a.availableKpi(),{id:e})}function r(){var e=a.singleDpForm;u(e.min,e.max),u(e.yellowRangeMin,e.yellowRangeMax),u(e.redRangeMin,e.redRangeMax)}function u(e,t){var a,i,n;e&&t&&(a="range-ends-must-not-be-equal",i=s(e),n=s(t),e.$setValidity(a,e=!(null!==i&&null!==n)||i!==n),t.$setValidity(a,e))}function s(e){e=e.$modelValue;return _.isNumber(e)||_.isString(e)&&!_.isEmpty(e)?_.toNumber(e):null}e(r)}e.$inject=["$timeout","$scope","c8yDataPointSvc","c8yChart","c8yAlert","gettext"],angular.module("c8y.cockpit.dataPointExplorer").controller("c8yDataPointItemCtrl",e)})();