var __extends=this.__extends||function(c,d){function n(){this.constructor=c}for(var e in d)d.hasOwnProperty(e)&&(c[e]=d[e]);n.prototype=d.prototype;c.prototype=new n}; function JL(c){if(!c)return JL.__;Array.prototype.reduce||(Array.prototype.reduce=function(c,d){for(var l=d,h=0;hc.maxMessages)return!1;try{if(a.userAgentRegex&&!RegExp(a.userAgentRegex).test(navigator.userAgent))return!1}catch(b){}try{if(a.ipRegex&&c.clientIP&&!RegExp(a.ipRegex).test(c.clientIP))return!1}catch(k){}return!0}function e(a,b){try{if(a.disallow&&RegExp(a.disallow).test(b))return!1}catch(k){}return!0}function l(a){return"function"==typeof a?a instanceof RegExp?a.toString():a():a}function h(a){a=l(a);switch(typeof a){case "string":return new m(a,null,a);case "number":return a=a.toString(),new m(a,null,a);case "boolean":return a=a.toString(),new m(a,null,a);case "undefined":return new m("undefined",null,"undefined");case "object":return a instanceof RegExp||a instanceof String||a instanceof Number||a instanceof Boolean?(a=a.toString(),new m(a,null,a)):new m(null,a,JSON.stringify(a));default:return new m("unknown",null,"unknown")}}c.enabled;c.maxMessages; c.defaultAjaxUrl;c.clientIP;c.requestId="";var m=function(){return function(a,b,k){this.msg=a;this.meta=b;this.finalString=k}}();c.setOptions=function(a){d("enabled",a,this);d("maxMessages",a,this);d("defaultAjaxUrl",a,this);d("clientIP",a,this);d("requestId",a,this);return this};c.getAllLevel=function(){return-2147483648};c.getTraceLevel=function(){return 1E3};c.getDebugLevel=function(){return 2E3};c.getInfoLevel=function(){return 3E3};c.getWarnLevel=function(){return 4E3};c.getErrorLevel=function(){return 5E3}; c.getFatalLevel=function(){return 6E3};c.getOffLevel=function(){return 2147483647};var g=function(){return function(a,b){this.inner=b;this.name="JL.Exception";this.message=h(a).finalString}}();c.Exception=g;g.prototype=Error();var r=function(){return function(a,b,k,c){this.l=a;this.m=b;this.n=k;this.t=c}}();c.LogItem=r;g=function(){function a(b,a){this.appenderName=b;this.sendLogItems=a;this.level=c.getTraceLevel();this.sendWithBufferLevel=2147483647;this.storeInBufferLevel=-2147483648;this.bufferSize= 0;this.batchSize=1;this.buffer=[];this.batchBuffer=[]}a.prototype.setOptions=function(b){d("level",b,this);d("ipRegex",b,this);d("userAgentRegex",b,this);d("disallow",b,this);d("sendWithBufferLevel",b,this);d("storeInBufferLevel",b,this);d("bufferSize",b,this);d("batchSize",b,this);this.bufferSizethis.bufferSize&&this.buffer.shift()):(f=this.batchSize&&this.sendBatch()))};a.prototype.sendBatch=function(){0==this.batchBuffer.length||null!=c.maxMessages&&1>c.maxMessages||(null!=c.maxMessages&&(c.maxMessages-=this.batchBuffer.length),this.sendLogItems(this.batchBuffer), this.batchBuffer.length=0)};return a}();c.Appender=g;var p=function(a){function b(c){a.call(this,c,b.prototype.sendLogItemsAjax)}__extends(b,a);b.prototype.setOptions=function(b){d("url",b,this);a.prototype.setOptions.call(this,b);return this};b.prototype.sendLogItemsAjax=function(b){try{var a="/jsnlog.logger";null!=c.defaultAjaxUrl&&(a=c.defaultAjaxUrl);this.url&&(a=this.url);var d=JSON.stringify({r:c.requestId,lg:b}),f=new XMLHttpRequest;f.open("POST",a);f.setRequestHeader("Content-Type","application/json"); f.setRequestHeader("JSNLog-RequestId",c.requestId);f.send(d)}catch(e){}};return b}(g);c.AjaxAppender=p;var q=function(a){function b(c){a.call(this,c,b.prototype.sendLogItemsConsole)}__extends(b,a);b.prototype.clog=function(b){console.log(b)};b.prototype.cerror=function(b){console.error?console.error(b):this.clog(b)};b.prototype.cwarn=function(b){console.warn?console.warn(b):this.clog(b)};b.prototype.cinfo=function(b){console.info?console.info(b):this.clog(b)};b.prototype.cdebug=function(b){console.debug? console.debug(b):this.cinfo(b)};b.prototype.sendLogItemsConsole=function(b){try{if(console){var a;for(a=0;a=this.level&&n(this)&&(c?(d=this.buildExceptionObject(c),d.logData=l(a)): d=a,a=h(d),e(this,a.finalString))){if(this.onceOnly)for(d=this.onceOnly.length-1;0<=d;){if(RegExp(this.onceOnly[d]).test(a.finalString)){if(this.seenRegexes[d])return this;this.seenRegexes[d]=!0}d--}a.meta=a.meta||{};a.meta.loggerName=this.loggerName;for(d=this.appenders.length-1;0<=d;)this.appenders[d].log(1E3>=b?"trace":2E3>=b?"debug":3E3>=b?"info":4E3>=b?"warn":5E3>=b?"error":"fatal",a.msg,a.meta,function(){},b,a.finalString,this.loggerName),d--}return this};a.prototype.trace=function(a){return this.log(1E3, a)};a.prototype.debug=function(a){return this.log(2E3,a)};a.prototype.info=function(a){return this.log(3E3,a)};a.prototype.warn=function(a){return this.log(4E3,a)};a.prototype.error=function(a){return this.log(5E3,a)};a.prototype.fatal=function(a){return this.log(6E3,a)};a.prototype.fatalException=function(a,c){return this.log(6E3,a,c)};return a}();c.Logger=g;c.createAjaxAppender=function(a){return new p(a)};c.createConsoleAppender=function(a){return new q(a)};g=new p("");"undefined"===typeof window&& (g=new q(""));c.__=new c.Logger("");c.__.setOptions({level:c.getDebugLevel(),appenders:[g]})})(JL||(JL={}));var exports;"undefined"!==typeof exports&&(exports.JL=JL);var define;"function"==typeof define&&define.amd&&define("jsnlog",[],function(){return JL});"function"==typeof __jsnlog_configure&&__jsnlog_configure(JL);