(()=>{function e(e,t,u,a){var s=this;function r(){e.requestTemplateForm.$setPristine(),e.requestTemplateForm.$setUntouched()}function l(){e.requestTemplateForm.msgId.$validate()}function n(){return s.requestTemplate&&s.requestTemplate.api&&s.requestTemplate.method}function o(){return s.requestTemplate&&u.doesRequestTemplateRequireByIdOrByExternalId(s.requestTemplate)}function m(){return s.requestTemplate&&u.doesRequestTemplateRequireExternalId(s.requestTemplate)}_.assign(s,{validation:a.validation,methods:u.Methods.values(),apis:u.APIs.values(),types:u.typesForUI(),getMethodsForAPI:u.getMethodsForAPI,setupRequestTemplateDefaults:u.setupRequestTemplateDefaults,addCustomValue:u.addRequestTemplateCustomValue,removeCustomValue:u.removeRequestTemplateCustomValue,$onChanges:function(e){e.requestTemplate&&e.requestTemplate.currentValue&&(e=e.requestTemplate.currentValue,s.originalMsgId=e.msgId,s.requestTemplate=_.cloneDeep(e),s.originalMsgId||u.setupRequestTemplateDefaults(s.requestTemplate),t(r),t(l))},apiAndMethodSelected:n,shouldShowByIdOrByExternalId:o,shouldShowExternalId:m,noRequiredApiValues:function(){return n()&&!o()&&!m()&&0===s.requestTemplate.mandatoryValues.length},onCustomValueDataTypeChanged:function(e){e.value=null},save:function(){s.onSave({requestTemplate:s.requestTemplate})},remove:function(){s.onRemove({requestTemplate:s.requestTemplate})},cancel:function(){s.onCancel()},getPreviews:function(e){return e?u.getRequestTemplatePreview(e).csv:""}})}e.$inject=["$scope","$timeout","c8ySmartRestTemplates","c8yConfig"],angular.module("c8y.smartRestEditor").component("c8ySmartRestRequestEditor",{bindings:{template:"<",requestTemplate:"<",onSave:"&",onRemove:"&",onCancel:"&"},templateUrl:":::PLUGIN_PATH:::/requestEditor/requestEditor.html",controller:e,controllerAs:"vm"})})();