"use strict";function hookBeforeAndAfter(e,t){return __awaiter(this,void 0,void 0,function(){var r,o,n,a,i,s,c,l,u;return __generator(this,function(f){switch(f.label){case 0:if(r=e.method,o=e.params,n=+new Date,a=n+"_"+Math.floor(1e3*Math.random()),this.devConfig.onBeforeInvokeAPI)try{this.devConfig.onBeforeInvokeAPI({invokeId:a,method:r,params:o,startTime:n})}catch(e){log_1.formatLog(log_1.diagnosticMessageMap.call_api_on_before_error,e.toString())}c=!0,f.label=1;case 1:return f.trys.push([1,3,,4]),[4,t()];case 2:return i=f.sent(),[3,4];case 3:return l=f.sent(),s=l,c=!1,[3,4];case 4:if(u=c?i:s,this.devConfig.onAfterInvokeAPI)try{this.devConfig.onAfterInvokeAPI({invokeId:a,method:r,params:o,payload:u,startTime:n,duration:+new Date-n,isSuccess:c})}catch(e){log_1.formatLog(log_1.diagnosticMessageMap.call_api_on_after_error,e.toString())}return[2,c?Promise.resolve(u):Promise.reject(u)]}})})}var __awaiter=this&&this.__awaiter||function(e,t,r,o){function n(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,a){function i(e){try{c(o.next(e))}catch(e){a(e)}}function s(e){try{c(o.throw(e))}catch(e){a(e)}}function c(e){e.done?r(e.value):n(e.value).then(i,s)}c((o=o.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){function r(e){return function(t){return o([e,t])}}function o(r){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,a&&(i=2&r[0]?a.return:r[0]?a.throw||((i=a.return)&&i.call(a),0):a.next)&&!(i=i.call(a,r[1])).done)return i;switch(a=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return c.label++,{value:r[1],done:!1};case 5:c.label++,a=r[1],r=[0];continue;case 7:r=c.ops.pop(),c.trys.pop();continue;default:if(i=c.trys,!(i=i.length>0&&i[i.length-1])&&(6===r[0]||2===r[0])){c=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){c.label=r[1];break}if(6===r[0]&&c.label<i[1]){c.label=i[1],i=r;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(r);break}i[2]&&c.ops.pop(),c.trys.pop();continue}r=t.call(e,c)}catch(e){r=[6,e],a=0}finally{n=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}var n,a,i,s,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s};Object.defineProperty(exports,"__esModule",{value:!0}),exports.hookBeforeAndAfter=void 0;var log_1=require("../../log");exports.hookBeforeAndAfter=hookBeforeAndAfter;