function JL(n){if(!n)return JL.__;Array.prototype.reduce||(Array.prototype.reduce=function(n,t){for(var r=t,i=0;i<this.length;i++)r=n(r,this[i],i,this);return r});var t="";return("."+n).split(".").reduce(function(n,i){return t=t?t+("."+i):i,i=n["__"+t],void 0===i&&(JL.Logger.prototype=n,i=new JL.Logger(t),n["__"+t]=i),i},JL.__)}var $jscomp=$jscomp||{},__extends,define;$jscomp.scope={};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(n,t,i){n!=Array.prototype&&n!=Object.prototype&&(n[t]=i.value)};$jscomp.getGlobal=function(n){return"undefined"!=typeof window&&window===n?n:"undefined"!=typeof global&&null!=global?global:n};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(n,t,i,r){if(t){for(i=$jscomp.global,n=n.split("."),r=0;r<n.length-1;r++){var u=n[r];u in i||(i[u]={});i=i[u]}n=n[n.length-1];r=i[n];t=t(r);t!=r&&null!=t&&$jscomp.defineProperty(i,n,{configurable:!0,writable:!0,value:t})}};$jscomp.polyfill("Object.setPrototypeOf",function(n){return n?n:"object"!=typeof"".__proto__?null:function(n,t){if(n.__proto__=t,n.__proto__!==t)throw new TypeError(n+" is not extensible");return n}},"es6","es5");__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){function t(n,t,i){void 0!==t[n]&&(null===t[n]?delete i[n]:i[n]=t[n])}function u(t){if(null!=n.enabled&&!n.enabled)return!1;try{if(t.userAgentRegex&&!new RegExp(t.userAgentRegex).test(navigator.userAgent))return!1}catch(i){}try{if(t.ipRegex&&n.clientIP&&!new RegExp(t.ipRegex).test(n.clientIP))return!1}catch(i){}return!0}function s(n,t){try{if(n.disallow&&new RegExp(n.disallow).test(t))return!1}catch(i){}return!0}function h(n){return"function"==typeof n?n instanceof RegExp?n.toString():n():n}function c(t){t=h(t);switch(typeof t){case"string":return new r(t,null,t);case"number":var i=t.toString();return new r(i,null,i);case"boolean":return i=t.toString(),new r(i,null,i);case"undefined":return new r("undefined",null,"undefined");case"object":return t instanceof RegExp||t instanceof String||t instanceof Number||t instanceof Boolean?(i=t.toString(),new r(i,null,i)):(i="function"==typeof n.serialize?n.serialize.call(this,t):JSON.stringify(t),new r("",t,i));default:return new r("unknown",null,"unknown")}}function l(t,i,r){return n.entryId++,new o(t,i,r,n._getTime(),n.entryId)}function a(n){n.id&&(clearTimeout(n.id),n.id=null)}function v(n,t,i){var r=this;n.id||(n.id=setTimeout(function(){i.call(r)},t))}var r,i,o,f,e;n.requestId="";n.entryId=0;n._createXMLHttpRequest=function(){return new XMLHttpRequest};n._getTime=function(){return(new Date).getTime()};n._console=console;n._appenderNames=[];r=function(){return function(n,t,i){this.msg=n;this.meta=t;this.finalString=i}}();n.setOptions=function(n){return t("enabled",n,this),t("maxMessages",n,this),t("defaultAjaxUrl",n,this),t("clientIP",n,this),t("requestId",n,this),t("defaultBeforeSend",n,this),t("serialize",n,this),this};n.getAllLevel=function(){return-2147483648};n.getTraceLevel=function(){return 1e3};n.getDebugLevel=function(){return 2e3};n.getInfoLevel=function(){return 3e3};n.getWarnLevel=function(){return 4e3};n.getErrorLevel=function(){return 5e3};n.getFatalLevel=function(){return 6e3};n.getOffLevel=function(){return 2147483647};i=function(){return function(n,t){this.inner=t;this.name="JL.Exception";this.message=c(n).finalString}}();n.Exception=i;i.prototype=Error();o=function(){return function(n,t,i,r,u){this.l=n;this.m=t;this.n=i;this.t=r;this.u=u}}();n.LogItem=o;i=function(){function i(t,i){if(this.appenderName=t,this.sendLogItems=i,this.level=n.getTraceLevel(),this.sendWithBufferLevel=2147483647,this.storeInBufferLevel=-2147483648,this.bufferSize=0,this.batchSize=1,this.maxBatchSize=20,this.batchTimeout=2147483647,this.sendTimeout=5e3,this.buffer=[],this.batchBuffer=[],this.batchTimeoutTimer={id:null},this.sendTimeoutTimer={id:null},this.nbrLogItemsBeingSent=this.nbrLogItemsSkipped=0,void 0==t)throw"Trying to create an appender without a name or with an empty name";if(-1!=n._appenderNames.indexOf(t)){if(!t)throw"Trying to create an appender without a name or with an empty name";throw"Multiple appenders use the same name "+t;}n._appenderNames.push(t)}return i.prototype.addLogItemsToBuffer=function(t){if(this.batchBuffer.length>=this.maxBatchSize)this.nbrLogItemsSkipped+=t.length;else{if(null!=n.maxMessages){if(1>n.maxMessages)return;n.maxMessages-=t.length}this.batchBuffer=this.batchBuffer.concat(t);var i=this;v(this.batchTimeoutTimer,this.batchTimeout,function(){i.sendBatch.call(i)})}},i.prototype.batchBufferHasOverdueMessages=function(){for(var t=0;t<this.batchBuffer.length;t++)if(n._getTime()-this.batchBuffer[t].t>this.batchTimeout)return!0;return!1},i.prototype.batchBufferHasStrandedMessage=function(){return null!=n.maxMessages&&1>n.maxMessages&&0<this.batchBuffer.length},i.prototype.sendBatchIfComplete=function(){(this.batchBuffer.length>=this.batchSize||this.batchBufferHasOverdueMessages()||this.batchBufferHasStrandedMessage())&&this.sendBatch()},i.prototype.onSendingEnded=function(){a(this.sendTimeoutTimer);this.nbrLogItemsBeingSent=0;this.sendBatchIfComplete()},i.prototype.setOptions=function(i){if(t("level",i,this),t("ipRegex",i,this),t("userAgentRegex",i,this),t("disallow",i,this),t("sendWithBufferLevel",i,this),t("storeInBufferLevel",i,this),t("bufferSize",i,this),t("batchSize",i,this),t("maxBatchSize",i,this),t("batchTimeout",i,this),t("sendTimeout",i,this),this.bufferSize<this.buffer.length&&(this.buffer.length=this.bufferSize),this.maxBatchSize<this.batchSize)throw new n.Exception({message:"maxBatchSize cannot be smaller than batchSize",maxBatchSize:this.maxBatchSize,batchSize:this.batchSize});return this},i.prototype.log=function(n,t,i,r,f,e,o){!u(this)||!s(this,e)||f<this.storeInBufferLevel||(n=l(f,e,o),f<this.level?0<this.bufferSize&&(this.buffer.push(n),this.buffer.length>this.bufferSize&&this.buffer.shift()):(this.addLogItemsToBuffer([n]),f>=this.sendWithBufferLevel&&this.buffer.length&&(this.addLogItemsToBuffer(this.buffer),this.buffer.length=0),this.sendBatchIfComplete()))},i.prototype.sendBatch=function(){if(!(0<this.nbrLogItemsBeingSent)&&(a(this.batchTimeoutTimer),0!=this.batchBuffer.length)){this.nbrLogItemsBeingSent=this.batchBuffer.length;var n=this;v(this.sendTimeoutTimer,this.sendTimeout,function(){n.onSendingEnded.call(n)});this.sendLogItems(this.batchBuffer,function(){n.batchBuffer.splice(0,n.nbrLogItemsBeingSent);0<n.nbrLogItemsSkipped&&(n.batchBuffer.push(l(4e3,"Lost "+n.nbrLogItemsSkipped+" messages. Either connection with the server was down or logging was disabled via the enabled option. Reduce lost messages by increasing the ajaxAppender option maxBatchSize.",n.appenderName)),n.nbrLogItemsSkipped=0);n.onSendingEnded.call(n)})}},i}();n.Appender=i;f=function(i){function r(n){return i.call(this,n,r.prototype.sendLogItemsAjax)||this}return __extends(r,i),r.prototype.setOptions=function(n){return t("url",n,this),t("beforeSend",n,this),i.prototype.setOptions.call(this,n),this},r.prototype.sendLogItemsAjax=function(t,i){var r,f,e,o;try{u(this)&&(this.xhr&&0!=this.xhr.readyState&&4!=this.xhr.readyState&&this.xhr.abort(),this.xhr=n._createXMLHttpRequest(),r="/jsnlog.logger",null!=n.defaultAjaxUrl&&(r=n.defaultAjaxUrl),this.url&&(r=this.url),this.xhr.open("POST",r),this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("JSNLog-RequestId",n.requestId),f=this,this.xhr.onreadystatechange=function(){4==f.xhr.readyState&&200<=f.xhr.status&&300>f.xhr.status&&i()},e={r:n.requestId,lg:t},"function"==typeof this.beforeSend?this.beforeSend.call(this,this.xhr,e):"function"==typeof n.defaultBeforeSend&&n.defaultBeforeSend.call(this,this.xhr,e),o=JSON.stringify(e),this.xhr.send(o))}catch(s){}},r}(i);n.AjaxAppender=f;e=function(t){function i(n){return t.call(this,n,i.prototype.sendLogItemsConsole)||this}return __extends(i,t),i.prototype.clog=function(t){n._console.log(t)},i.prototype.cerror=function(t){n._console.error?n._console.error(t):this.clog(t)},i.prototype.cwarn=function(t){n._console.warn?n._console.warn(t):this.clog(t)},i.prototype.cinfo=function(t){n._console.info?n._console.info(t):this.clog(t)},i.prototype.cdebug=function(t){n._console.debug?n._console.debug(t):this.cinfo(t)},i.prototype.sendLogItemsConsole=function(t,i){var e,r,f;try{if(!u(this)||!n._console)return;for(e=0;e<t.length;++e)r=t[e],f=r.n+": "+r.m,"undefined"==typeof window&&(f=new Date(r.t)+" | "+f),r.l<=n.getDebugLevel()?this.cdebug(f):r.l<=n.getInfoLevel()?this.cinfo(f):r.l<=n.getWarnLevel()?this.cwarn(f):this.cerror(f)}catch(o){}i()},i}(i);n.ConsoleAppender=e;i=function(){function n(n){this.loggerName=n;this.seenRegexes=[]}return n.prototype.setOptions=function(n){return t("level",n,this),t("userAgentRegex",n,this),t("disallow",n,this),t("ipRegex",n,this),t("appenders",n,this),t("onceOnly",n,this),this.seenRegexes=[],this},n.prototype.buildExceptionObject=function(n){var t={};return n.stack?t.stack=n.stack:t.e=n,n.message&&(t.message=n.message),n.name&&(t.name=n.name),n.data&&(t.data=n.data),n.inner&&(t.inner=this.buildExceptionObject(n.inner)),t},n.prototype.log=function(n,t,i){var r=0;if(!this.appenders)return this;if(n>=this.level&&u(this)&&(i?(r=this.buildExceptionObject(i),r.logData=h(t)):r=t,t=c(r),s(this,t.finalString))){if(this.onceOnly)for(r=this.onceOnly.length-1;0<=r;){if(new RegExp(this.onceOnly[r]).test(t.finalString)){if(this.seenRegexes[r])return this;this.seenRegexes[r]=!0}r--}for(t.meta=t.meta||{},r=this.appenders.length-1;0<=r;)this.appenders[r].log(1e3>=n?"trace":2e3>=n?"debug":3e3>=n?"info":4e3>=n?"warn":5e3>=n?"error":"fatal",t.msg,t.meta,function(){},n,t.finalString,this.loggerName),r--}return this},n.prototype.trace=function(n){return this.log(1e3,n)},n.prototype.debug=function(n){return this.log(2e3,n)},n.prototype.info=function(n){return this.log(3e3,n)},n.prototype.warn=function(n){return this.log(4e3,n)},n.prototype.error=function(n){return this.log(5e3,n)},n.prototype.fatal=function(n){return this.log(6e3,n)},n.prototype.fatalException=function(n,t){return this.log(6e3,n,t)},n}();n.Logger=i;n.createAjaxAppender=function(n){return new f(n)};n.createConsoleAppender=function(n){return new e(n)};i="undefined"!=typeof window?new f(""):new e("");n.__=new n.Logger("");n.__.setOptions({level:n.getDebugLevel(),appenders:[i]})}(JL||(JL={}));"undefined"!=typeof exports&&(exports.__esModule=!0,exports.JL=JL);"function"==typeof define&&define.amd&&define("jsnlog",[],function(){return JL});"function"==typeof __jsnlog_configure&&__jsnlog_configure(JL);"undefined"==typeof window||window.onerror||(window.onerror=function(n,t,i,r,u){return JL("onerrorLogger").fatalException({msg:"Uncaught Exception",errorMsg:n?n.message||n:"",url:t,"line number":i,column:r},u),!1});"undefined"==typeof window||window.onunhandledrejection||(window.onunhandledrejection=function(n){JL("onerrorLogger").fatalException({msg:"unhandledrejection",errorMsg:n.reason?n.reason.message:n.message||null},n.reason)})