stackdriver-errors-js
Version:
Experimental client-side JavaScript library to report errors to Stackdriver Error Reporting
3 lines (2 loc) • 32.1 kB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).StackdriverErrorReporter=e()}}(function(){function e(n){var t;return function(e){return t||n(t={exports:{},parent:e},t.exports),t.exports}}var t=e(function(t,r){!function(e,n){"use strict";"object"==typeof r?t.exports=n(o({}),a({})):e.StackTraceGPS=n(e.SourceMap||e.sourceMap,e.StackFrame)}(this,function(o,u){"use strict";function n(r){return new Promise(function(e,n){var t=new XMLHttpRequest;t.open("get",r),t.onerror=n,t.onreadystatechange=function(){4===t.readyState&&(200<=t.status&&t.status<300||"file://"===r.substr(0,7)&&t.responseText?e(t.responseText):n(new Error("HTTP status: "+t.status+" retrieving "+r)))},t.send()})}function t(e){if("undefined"!=typeof window&&window.atob)return window.atob(e);throw new Error("You must supply a polyfill for window.atob in this environment")}function r(e){if("object"!=typeof e)throw new TypeError("Given StackFrame is not an object");if("string"!=typeof e.fileName)throw new TypeError("Given file name is not a String");if("number"!=typeof e.lineNumber||e.lineNumber%1!=0||e.lineNumber<1)throw new TypeError("Given line number must be a positive integer");if("number"!=typeof e.columnNumber||e.columnNumber%1!=0||e.columnNumber<0)throw new TypeError("Given column number must be a non-negative integer");return!0}return function e(c){if(!(this instanceof e))return new e(c);c=c||{},this.sourceCache=c.sourceCache||{},this.sourceMapConsumerCache=c.sourceMapConsumerCache||{},this.ajax=c.ajax||n,this._atob=c.atob||t,this._get=function(u){return new Promise(function(e,n){var t="data:"===u.substr(0,5);if(this.sourceCache[u])e(this.sourceCache[u]);else if(c.offline&&!t)n(new Error("Cannot make network requests in offline mode"));else if(t){var r=u.match(/^data:application\/json;([\w=:"-]+;)*base64,/);if(r){var o=r[0].length,i=u.substr(o),a=this._atob(i);e(this.sourceCache[u]=a)}else n(new Error("The encoding of the inline sourcemap is not supported"))}else{var s=this.ajax(u,{method:"get"});(this.sourceCache[u]=s).then(e,n)}}.bind(this))},this._getSourceMapConsumer=function(t,r){return new Promise(function(e){if(this.sourceMapConsumerCache[t])e(this.sourceMapConsumerCache[t]);else{var n=new Promise(function(n,e){return this._get(t).then(function(e){"string"==typeof e&&(e=function(e){if("undefined"!=typeof JSON&&JSON.parse)return JSON.parse(e);throw new Error("You must supply a polyfill for JSON.parse in this environment")}(e.replace(/^\)\]\}'/,""))),void 0===e.sourceRoot&&(e.sourceRoot=r),n(new o.SourceMapConsumer(e))},e)}.bind(this));e(this.sourceMapConsumerCache[t]=n)}}.bind(this))},this.pinpoint=function(n){return new Promise(function(t,e){this.getMappedLocation(n).then(function(e){function n(){t(e)}this.findFunctionName(e).then(t,n).catch(n)}.bind(this),e)}.bind(this))},this.findFunctionName=function(i){return new Promise(function(o,e){r(i),this._get(i.fileName).then(function(e){var n=i.lineNumber,t=i.columnNumber,r=function(e,n){for(var t=[/['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*function\b/,/function\s+([^('"`]*?)\s*\(([^)]*)\)/,/['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*(?:eval|new Function)\b/,/\b(?!(?:if|for|switch|while|with|catch)\b)(?:(?:static)\s+)?(\S+)\s*\(.*?\)\s*\{/,/['"]?([$_A-Za-z][$_A-Za-z0-9]*)['"]?\s*[:=]\s*\(.*?\)\s*=>/],r=e.split("\n"),o="",i=Math.min(n,20),a=0;a<i;++a){var s=r[n-a-1],u=s.indexOf("//");if(0<=u&&(s=s.substr(0,u)),s){o=s+o;for(var c=t.length,l=0;l<c;l++){var f=t[l].exec(o);if(f&&f[1])return f[1]}}}}(e,n);o(r?new u({functionName:r,args:i.args,fileName:i.fileName,lineNumber:n,columnNumber:t}):i)},e).catch(e)}.bind(this))},this.getMappedLocation=function(s){return new Promise(function(o,e){!function(){if("function"!=typeof Object.defineProperty||"function"!=typeof Object.create)throw new Error("Unable to consume source maps in older browsers")}(),r(s);var i=this.sourceCache,a=s.fileName;this._get(a).then(function(e){var n=function(e){for(var n,t,r=/\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm;t=r.exec(e);)n=t[1];if(n)return n;throw new Error("sourceMappingURL not found")}(e),t="data:"===n.substr(0,5),r=a.substring(0,a.lastIndexOf("/")+1);return"/"===n[0]||t||/^https?:\/\/|^\/\//i.test(n)||(n=r+n),this._getSourceMapConsumer(n,r).then(function(e){return function(o,i,a){return new Promise(function(e,n){var t=i.originalPositionFor({line:o.lineNumber,column:o.columnNumber});if(t.source){var r=i.sourceContentFor(t.source);r&&(a[t.source]=r),e(new u({functionName:t.name||o.functionName,args:o.args,fileName:t.source,lineNumber:t.line,columnNumber:t.column}))}else n(new Error("Could not get original source for given stackframe and source map"))})}(s,e,i).then(o).catch(function(){o(s)})})}.bind(this),e).catch(e)}.bind(this))}}})}),o=e(function(e,n){var f=d.ArraySet,y=O.quickSort;function a(e){var n=e;return"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,""))),null!=n.sections?new t(n):new p(n)}function p(e){var n=e;"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,"")));var t=b.getArg(n,"version"),r=b.getArg(n,"sources"),o=b.getArg(n,"names",[]),i=b.getArg(n,"sourceRoot",null),a=b.getArg(n,"sourcesContent",null),s=b.getArg(n,"mappings"),u=b.getArg(n,"file",null);if(t!=this._version)throw new Error("Unsupported version: "+t);r=r.map(String).map(b.normalize).map(function(e){return i&&b.isAbsolute(i)&&b.isAbsolute(e)?b.relative(i,e):e}),this._names=f.fromArray(o.map(String),!0),this._sources=f.fromArray(r,!0),this.sourceRoot=i,this.sourcesContent=a,this._mappings=s,this.file=u}function w(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}function t(e){var n=e;"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,"")));var t=b.getArg(n,"version"),r=b.getArg(n,"sections");if(t!=this._version)throw new Error("Unsupported version: "+t);this._sources=new f,this._names=new f;var o={line:-1,column:0};this._sections=r.map(function(e){if(e.url)throw new Error("Support for url field in sections not implemented.");var n=b.getArg(e,"offset"),t=b.getArg(n,"line"),r=b.getArg(n,"column");if(t<o.line||t===o.line&&r<o.column)throw new Error("Section offsets must be ordered and non-overlapping.");return o=n,{generatedOffset:{generatedLine:t+1,generatedColumn:r+1},consumer:new a(b.getArg(e,"map"))}})}a.fromSourceMap=function(e){return p.fromSourceMap(e)},a.prototype._version=3,a.prototype.__generatedMappings=null,Object.defineProperty(a.prototype,"_generatedMappings",{get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),a.prototype.__originalMappings=null,Object.defineProperty(a.prototype,"_originalMappings",{get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),a.prototype._charIsMappingSeparator=function(e,n){var t=e.charAt(n);return";"===t||","===t},a.prototype._parseMappings=function(e,n){throw new Error("Subclasses must implement _parseMappings")},a.GENERATED_ORDER=1,a.ORIGINAL_ORDER=2,a.GREATEST_LOWER_BOUND=1,a.LEAST_UPPER_BOUND=2,a.prototype.eachMapping=function(e,n,t){var r,o=n||null;switch(t||a.GENERATED_ORDER){case a.GENERATED_ORDER:r=this._generatedMappings;break;case a.ORIGINAL_ORDER:r=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var i=this.sourceRoot;r.map(function(e){var n=null===e.source?null:this._sources.at(e.source);return null!=n&&null!=i&&(n=b.join(i,n)),{source:n,generatedLine:e.generatedLine,generatedColumn:e.generatedColumn,originalLine:e.originalLine,originalColumn:e.originalColumn,name:null===e.name?null:this._names.at(e.name)}},this).forEach(e,o)},a.prototype.allGeneratedPositionsFor=function(e){var n=b.getArg(e,"line"),t={source:b.getArg(e,"source"),originalLine:n,originalColumn:b.getArg(e,"column",0)};if(null!=this.sourceRoot&&(t.source=b.relative(this.sourceRoot,t.source)),!this._sources.has(t.source))return[];t.source=this._sources.indexOf(t.source);var r=[],o=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",b.compareByOriginalPositions,m.LEAST_UPPER_BOUND);if(0<=o){var i=this._originalMappings[o];if(void 0===e.column)for(var a=i.originalLine;i&&i.originalLine===a;)r.push({line:b.getArg(i,"generatedLine",null),column:b.getArg(i,"generatedColumn",null),lastColumn:b.getArg(i,"lastGeneratedColumn",null)}),i=this._originalMappings[++o];else for(var s=i.originalColumn;i&&i.originalLine===n&&i.originalColumn==s;)r.push({line:b.getArg(i,"generatedLine",null),column:b.getArg(i,"generatedColumn",null),lastColumn:b.getArg(i,"lastGeneratedColumn",null)}),i=this._originalMappings[++o]}return r},n.SourceMapConsumer=a,(p.prototype=Object.create(a.prototype)).consumer=a,p.fromSourceMap=function(e){var n=Object.create(p.prototype),t=n._names=f.fromArray(e._names.toArray(),!0),r=n._sources=f.fromArray(e._sources.toArray(),!0);n.sourceRoot=e._sourceRoot,n.sourcesContent=e._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=e._file;for(var o=e._mappings.toArray().slice(),i=n.__generatedMappings=[],a=n.__originalMappings=[],s=0,u=o.length;s<u;s++){var c=o[s],l=new w;l.generatedLine=c.generatedLine,l.generatedColumn=c.generatedColumn,c.source&&(l.source=r.indexOf(c.source),l.originalLine=c.originalLine,l.originalColumn=c.originalColumn,c.name&&(l.name=t.indexOf(c.name)),a.push(l)),i.push(l)}return y(n.__originalMappings,b.compareByOriginalPositions),n},p.prototype._version=3,Object.defineProperty(p.prototype,"sources",{get:function(){return this._sources.toArray().map(function(e){return null!=this.sourceRoot?b.join(this.sourceRoot,e):e},this)}}),p.prototype._parseMappings=function(e,n){for(var t,r,o,i,a,s=1,u=0,c=0,l=0,f=0,p=0,g=e.length,h=0,m={},d={},v=[],_=[];h<g;)if(";"===e.charAt(h))s++,h++,u=0;else if(","===e.charAt(h))h++;else{for((t=new w).generatedLine=s,i=h;i<g&&!this._charIsMappingSeparator(e,i);i++);if(o=m[r=e.slice(h,i)])h+=r.length;else{for(o=[];h<i;)C.decode(e,h,d),a=d.value,h=d.rest,o.push(a);if(2===o.length)throw new Error("Found a source, but no line and column");if(3===o.length)throw new Error("Found a source and line, but no column");m[r]=o}t.generatedColumn=u+o[0],u=t.generatedColumn,1<o.length&&(t.source=f+o[1],f+=o[1],t.originalLine=c+o[2],c=t.originalLine,t.originalLine+=1,t.originalColumn=l+o[3],l=t.originalColumn,4<o.length&&(t.name=p+o[4],p+=o[4])),_.push(t),"number"==typeof t.originalLine&&v.push(t)}y(_,b.compareByGeneratedPositionsDeflated),this.__generatedMappings=_,y(v,b.compareByOriginalPositions),this.__originalMappings=v},p.prototype._findMapping=function(e,n,t,r,o,i){if(e[t]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[t]);if(e[r]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[r]);return m.search(e,n,o,i)},p.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var n=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var t=this._generatedMappings[e+1];if(n.generatedLine===t.generatedLine){n.lastGeneratedColumn=t.generatedColumn-1;continue}}n.lastGeneratedColumn=1/0}},p.prototype.originalPositionFor=function(e){var n={generatedLine:b.getArg(e,"line"),generatedColumn:b.getArg(e,"column")},t=this._findMapping(n,this._generatedMappings,"generatedLine","generatedColumn",b.compareByGeneratedPositionsDeflated,b.getArg(e,"bias",a.GREATEST_LOWER_BOUND));if(0<=t){var r=this._generatedMappings[t];if(r.generatedLine===n.generatedLine){var o=b.getArg(r,"source",null);null!==o&&(o=this._sources.at(o),null!=this.sourceRoot&&(o=b.join(this.sourceRoot,o)));var i=b.getArg(r,"name",null);return null!==i&&(i=this._names.at(i)),{source:o,line:b.getArg(r,"originalLine",null),column:b.getArg(r,"originalColumn",null),name:i}}}return{source:null,line:null,column:null,name:null}},p.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&(this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return null==e}))},p.prototype.sourceContentFor=function(e,n){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=b.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var t;if(null!=this.sourceRoot&&(t=b.urlParse(this.sourceRoot))){var r=e.replace(/^file:\/\//,"");if("file"==t.scheme&&this._sources.has(r))return this.sourcesContent[this._sources.indexOf(r)];if((!t.path||"/"==t.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}if(n)return null;throw new Error('"'+e+'" is not in the SourceMap.')},p.prototype.generatedPositionFor=function(e){var n=b.getArg(e,"source");if(null!=this.sourceRoot&&(n=b.relative(this.sourceRoot,n)),!this._sources.has(n))return{line:null,column:null,lastColumn:null};var t={source:n=this._sources.indexOf(n),originalLine:b.getArg(e,"line"),originalColumn:b.getArg(e,"column")},r=this._findMapping(t,this._originalMappings,"originalLine","originalColumn",b.compareByOriginalPositions,b.getArg(e,"bias",a.GREATEST_LOWER_BOUND));if(0<=r){var o=this._originalMappings[r];if(o.source===t.source)return{line:b.getArg(o,"generatedLine",null),column:b.getArg(o,"generatedColumn",null),lastColumn:b.getArg(o,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},n.BasicSourceMapConsumer=p,(t.prototype=Object.create(a.prototype)).constructor=a,t.prototype._version=3,Object.defineProperty(t.prototype,"sources",{get:function(){for(var e=[],n=0;n<this._sections.length;n++)for(var t=0;t<this._sections[n].consumer.sources.length;t++)e.push(this._sections[n].consumer.sources[t]);return e}}),t.prototype.originalPositionFor=function(e){var n={generatedLine:b.getArg(e,"line"),generatedColumn:b.getArg(e,"column")},t=m.search(n,this._sections,function(e,n){var t=e.generatedLine-n.generatedOffset.generatedLine;return t||e.generatedColumn-n.generatedOffset.generatedColumn}),r=this._sections[t];return r?r.consumer.originalPositionFor({line:n.generatedLine-(r.generatedOffset.generatedLine-1),column:n.generatedColumn-(r.generatedOffset.generatedLine===n.generatedLine?r.generatedOffset.generatedColumn-1:0),bias:e.bias}):{source:null,line:null,column:null,name:null}},t.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(e){return e.consumer.hasContentsOfAllSources()})},t.prototype.sourceContentFor=function(e,n){for(var t=0;t<this._sections.length;t++){var r=this._sections[t].consumer.sourceContentFor(e,!0);if(r)return r}if(n)return null;throw new Error('"'+e+'" is not in the SourceMap.')},t.prototype.generatedPositionFor=function(e){for(var n=0;n<this._sections.length;n++){var t=this._sections[n];if(-1!==t.consumer.sources.indexOf(b.getArg(e,"source"))){var r=t.consumer.generatedPositionFor(e);if(r)return{line:r.line+(t.generatedOffset.generatedLine-1),column:r.column+(t.generatedOffset.generatedLine===r.line?t.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},t.prototype._parseMappings=function(e,n){this.__generatedMappings=[],this.__originalMappings=[];for(var t=0;t<this._sections.length;t++)for(var r=this._sections[t],o=r.consumer._generatedMappings,i=0;i<o.length;i++){var a=o[i],s=r.consumer._sources.at(a.source);null!==r.consumer.sourceRoot&&(s=b.join(r.consumer.sourceRoot,s)),this._sources.add(s),s=this._sources.indexOf(s);var u=r.consumer._names.at(a.name);this._names.add(u),u=this._names.indexOf(u);var c={source:s,generatedLine:a.generatedLine+(r.generatedOffset.generatedLine-1),generatedColumn:a.generatedColumn+(r.generatedOffset.generatedLine===a.generatedLine?r.generatedOffset.generatedColumn-1:0),originalLine:a.originalLine,originalColumn:a.originalColumn,name:u};this.__generatedMappings.push(c),"number"==typeof c.originalLine&&this.__originalMappings.push(c)}y(this.__generatedMappings,b.compareByGeneratedPositionsDeflated),y(this.__originalMappings,b.compareByOriginalPositions)},n.IndexedSourceMapConsumer=t}),r=e(function(t,r){!function(e,n){"use strict";"object"==typeof r?t.exports=n(a({})):e.StackGenerator=n(e.StackFrame)}(this,function(a){return{backtrace:function(e){var n=[],t=10;"object"==typeof e&&"number"==typeof e.maxStackSize&&(t=e.maxStackSize);for(var r=arguments.callee;r&&n.length<t&&r.arguments;){for(var o=new Array(r.arguments.length),i=0;i<o.length;++i)o[i]=r.arguments[i];/function(?:\s+([\w$]+))+\s*\(/.test(r.toString())?n.push(new a({functionName:RegExp.$1||void 0,args:o})):n.push(new a({args:o}));try{r=r.caller}catch(e){break}}return n}}})}),i=e(function(t,r){!function(e,n){"use strict";"object"==typeof r?t.exports=n(a({})):e.ErrorStackParser=n(e.StackFrame)}(this,function(s){"use strict";var n=/(^|@)\S+:\d+/,t=/^\s*at .*(\S+:\d+|\(native\))/m,r=/^(eval@)?(\[native code])?$/;return{parse:function(e){if(void 0!==e.stacktrace||void 0!==e["opera#sourceloc"])return this.parseOpera(e);if(e.stack&&e.stack.match(t))return this.parseV8OrIE(e);if(e.stack)return this.parseFFOrSafari(e);throw new Error("Cannot parse given Error object")},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];var n=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));return[n[1],n[2]||void 0,n[3]||void 0]},parseV8OrIE:function(e){return e.stack.split("\n").filter(function(e){return!!e.match(t)},this).map(function(e){-1<e.indexOf("(eval ")&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var n=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),t=n.match(/ (\((.+):(\d+):(\d+)\)$)/),r=(n=t?n.replace(t[0],""):n).split(/\s+/).slice(1),o=this.extractLocation(t?t[1]:r.pop()),i=r.join(" ")||void 0,a=-1<["eval","<anonymous>"].indexOf(o[0])?void 0:o[0];return new s({functionName:i,fileName:a,lineNumber:o[1],columnNumber:o[2],source:e})},this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter(function(e){return!e.match(r)},this).map(function(e){if(-1<e.indexOf(" > eval")&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return new s({functionName:e});var n=/((.*".+"[^@]*)?[^@]*)(?:@)/,t=e.match(n),r=t&&t[1]?t[1]:void 0,o=this.extractLocation(e.replace(n,""));return new s({functionName:r,fileName:o[0],lineNumber:o[1],columnNumber:o[2],source:e})},this)},parseOpera:function(e){return!e.stacktrace||-1<e.message.indexOf("\n")&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var n=/Line (\d+).*script (?:in )?(\S+)/i,t=e.message.split("\n"),r=[],o=2,i=t.length;o<i;o+=2){var a=n.exec(t[o]);a&&r.push(new s({fileName:a[2],lineNumber:a[1],source:t[o]}))}return r},parseOpera10:function(e){for(var n=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,t=e.stacktrace.split("\n"),r=[],o=0,i=t.length;o<i;o+=2){var a=n.exec(t[o]);a&&r.push(new s({functionName:a[3]||void 0,fileName:a[2],lineNumber:a[1],source:t[o]}))}return r},parseOpera11:function(e){return e.stack.split("\n").filter(function(e){return!!e.match(n)&&!e.match(/^Error created at/)},this).map(function(e){var n,t=e.split("@"),r=this.extractLocation(t.pop()),o=t.shift()||"",i=o.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;o.match(/\(([^)]*)\)/)&&(n=o.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var a=void 0===n||"[arguments not available]"===n?void 0:n.split(",");return new s({functionName:i,args:a,fileName:r[0],lineNumber:r[1],columnNumber:r[2],source:e})},this)}}})}),a=e(function(t,r){!function(e,n){"use strict";"object"==typeof r?t.exports=n():e.StackFrame=n()}(this,function(){"use strict";function t(e){return e.charAt(0).toUpperCase()+e.substring(1)}function e(e){return function(){return this[e]}}var n=["isConstructor","isEval","isNative","isToplevel"],r=["columnNumber","lineNumber"],o=["fileName","functionName","source"],i=n.concat(r,o,["args"],["evalOrigin"]);function l(e){if(e)for(var n=0;n<i.length;n++)void 0!==e[i[n]]&&this["set"+t(i[n])](e[i[n]])}l.prototype={getArgs:function(){return this.args},setArgs:function(e){if("[object Array]"!==Object.prototype.toString.call(e))throw new TypeError("Args must be an Array");this.args=e},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(e){if(e instanceof l)this.evalOrigin=e;else{if(!(e instanceof Object))throw new TypeError("Eval Origin must be an Object or StackFrame");this.evalOrigin=new l(e)}},toString:function(){var e=this.getFileName()||"",n=this.getLineNumber()||"",t=this.getColumnNumber()||"",r=this.getFunctionName()||"";return this.getIsEval()?e?"[eval] ("+e+":"+n+":"+t+")":"[eval]:"+n+":"+t:r?r+" ("+e+":"+n+":"+t+")":e+":"+n+":"+t}},l.fromString=function(e){var n=e.indexOf("("),t=e.lastIndexOf(")"),r=e.substring(0,n),o=e.substring(n+1,t).split(","),i=e.substring(t+1);if(0===i.indexOf("@"))var a=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(i,""),s=a[1],u=a[2],c=a[3];return new l({functionName:r,args:o||void 0,fileName:s,lineNumber:u||void 0,columnNumber:c||void 0})};for(var a=0;a<n.length;a++)l.prototype["get"+t(n[a])]=e(n[a]),l.prototype["set"+t(n[a])]=function(n){return function(e){this[n]=Boolean(e)}}(n[a]);for(var s=0;s<r.length;s++)l.prototype["get"+t(r[s])]=e(r[s]),l.prototype["set"+t(r[s])]=function(t){return function(e){if(n=e,isNaN(parseFloat(n))||!isFinite(n))throw new TypeError(t+" must be a Number");var n;this[t]=Number(e)}}(r[s]);for(var u=0;u<o.length;u++)l.prototype["get"+t(o[u])]=e(o[u]),l.prototype["set"+t(o[u])]=function(n){return function(e){this[n]=String(e)}}(o[u]);return l})}),b={};b.getArg=function(e,n,t){if(n in e)return e[n];if(3===arguments.length)return t;throw new Error('"'+n+'" is a required argument.')};var s=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,u=/^data:.+\,.+$/;function c(e){var n=e.match(s);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function l(e){var n="";return e.scheme&&(n+=e.scheme+":"),n+="//",e.auth&&(n+=e.auth+"@"),e.host&&(n+=e.host),e.port&&(n+=":"+e.port),e.path&&(n+=e.path),n}function f(e){var n=e,t=c(e);if(t){if(!t.path)return e;n=t.path}for(var r,o=b.isAbsolute(n),i=n.split(/\/+/),a=0,s=i.length-1;0<=s;s--)"."===(r=i[s])?i.splice(s,1):".."===r?a++:0<a&&(""===r?(i.splice(s+1,a),a=0):(i.splice(s,2),a--));return""===(n=i.join("/"))&&(n=o?"/":"."),t?(t.path=n,l(t)):n}b.urlParse=c,b.urlGenerate=l,b.normalize=f,b.join=function(e,n){""===e&&(e="."),""===n&&(n=".");var t=c(n),r=c(e);if(r&&(e=r.path||"/"),t&&!t.scheme)return r&&(t.scheme=r.scheme),l(t);if(t||n.match(u))return n;if(r&&!r.host&&!r.path)return r.host=n,l(r);var o="/"===n.charAt(0)?n:f(e.replace(/\/+$/,"")+"/"+n);return r?(r.path=o,l(r)):o},b.isAbsolute=function(e){return"/"===e.charAt(0)||!!e.match(s)},b.relative=function(e,n){""===e&&(e="."),e=e.replace(/\/$/,"");for(var t=0;0!==n.indexOf(e+"/");){var r=e.lastIndexOf("/");if(r<0)return n;if((e=e.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return n;++t}return Array(t+1).join("../")+n.substr(e.length+1)};var n=!("__proto__"in Object.create(null));function p(e){return e}function g(e){if(!e)return!1;var n=e.length;if(n<9)return!1;if(95!==e.charCodeAt(n-1)||95!==e.charCodeAt(n-2)||111!==e.charCodeAt(n-3)||116!==e.charCodeAt(n-4)||111!==e.charCodeAt(n-5)||114!==e.charCodeAt(n-6)||112!==e.charCodeAt(n-7)||95!==e.charCodeAt(n-8)||95!==e.charCodeAt(n-9))return!1;for(var t=n-10;0<=t;t--)if(36!==e.charCodeAt(t))return!1;return!0}function h(e,n){return e===n?0:n<e?1:-1}b.toSetString=n?p:function(e){return g(e)?"$"+e:e},b.fromSetString=n?p:function(e){return g(e)?e.slice(1):e},b.compareByOriginalPositions=function(e,n,t){var r=e.source-n.source;return 0!==r?r:0!==(r=e.originalLine-n.originalLine)?r:0!==(r=e.originalColumn-n.originalColumn)||t?r:0!==(r=e.generatedColumn-n.generatedColumn)?r:0!==(r=e.generatedLine-n.generatedLine)?r:e.name-n.name},b.compareByGeneratedPositionsDeflated=function(e,n,t){var r=e.generatedLine-n.generatedLine;return 0!==r?r:0!==(r=e.generatedColumn-n.generatedColumn)||t?r:0!==(r=e.source-n.source)?r:0!==(r=e.originalLine-n.originalLine)?r:0!==(r=e.originalColumn-n.originalColumn)?r:e.name-n.name},b.compareByGeneratedPositionsInflated=function(e,n){var t=e.generatedLine-n.generatedLine;return 0!==t?t:0!==(t=e.generatedColumn-n.generatedColumn)?t:0!==(t=h(e.source,n.source))?t:0!==(t=e.originalLine-n.originalLine)?t:0!==(t=e.originalColumn-n.originalColumn)?t:h(e.name,n.name)};var m={};m.GREATEST_LOWER_BOUND=1,m.LEAST_UPPER_BOUND=2,m.search=function(e,n,t,r){if(0===n.length)return-1;var o=function e(n,t,r,o,i,a){var s=Math.floor((t-n)/2)+n,u=i(r,o[s],!0);return 0===u?s:0<u?1<t-s?e(s,t,r,o,i,a):a==m.LEAST_UPPER_BOUND?t<o.length?t:-1:s:1<s-n?e(n,s,r,o,i,a):a==m.LEAST_UPPER_BOUND?s:n<0?-1:n}(-1,n.length,e,n,t,r||m.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;0<=o-1&&0===t(n[o],n[o-1],!0);)--o;return o};var d={},v=Object.prototype.hasOwnProperty;function _(){this._array=[],this._set=Object.create(null)}_.fromArray=function(e,n){for(var t=new _,r=0,o=e.length;r<o;r++)t.add(e[r],n);return t},_.prototype.size=function(){return Object.getOwnPropertyNames(this._set).length},_.prototype.add=function(e,n){var t=b.toSetString(e),r=v.call(this._set,t),o=this._array.length;r&&!n||this._array.push(e),r||(this._set[t]=o)},_.prototype.has=function(e){var n=b.toSetString(e);return v.call(this._set,n)},_.prototype.indexOf=function(e){var n=b.toSetString(e);if(v.call(this._set,n))return this._set[n];throw new Error('"'+e+'" is not in the set.')},_.prototype.at=function(e){if(0<=e&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},_.prototype.toArray=function(){return this._array.slice()},d.ArraySet=_;var y={},w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");y.encode=function(e){if(0<=e&&e<w.length)return w[e];throw new TypeError("Must be between 0 and 63: "+e)},y.decode=function(e){return 65<=e&&e<=90?e-65:97<=e&&e<=122?e-97+26:48<=e&&e<=57?e-48+52:43==e?62:47==e?63:-1};var C={};C.encode=function(e){for(var n,t="",r=function(e){return e<0?1+(-e<<1):0+(e<<1)}(e);n=31&r,0<(r>>>=5)&&(n|=32),t+=y.encode(n),0<r;);return t},C.decode=function(e,n,t){var r,o,i=e.length,a=0,s=0;do{if(i<=n)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(o=y.decode(e.charCodeAt(n++))))throw new Error("Invalid base64 digit: "+e.charAt(n-1));r=!!(32&o),a+=(o&=31)<<s,s+=5}while(r);t.value=function(e){var n=e>>1;return 1==(1&e)?-n:n}(a),t.rest=n};var O={};function A(e,n,t){var r=e[n];e[n]=e[t],e[t]=r}function E(e,n,t,r){if(t<r){var o=t-1;A(e,function(e,n){return Math.round(e+Math.random()*(n-e))}(t,r),r);for(var i=e[r],a=t;a<r;a++)n(e[a],i)<=0&&A(e,o+=1,a);A(e,o+1,a);var s=o+1;E(e,n,t,s-1),E(e,n,s+1,r)}}O.quickSort=function(e,n){E(e,n,0,e.length-1)};var S={};!function(e,n){"use strict";"object"==typeof S?S=n(i({}),r({}),t({})):e.StackTrace=n(e.ErrorStackParser,e.StackGenerator,e.StackTraceGPS)}(this,function(i,t,e){function r(){try{throw new Error}catch(e){return e}}var a={filter:function(e){return-1===(e.functionName||"").indexOf("StackTrace$$")&&-1===(e.functionName||"").indexOf("ErrorStackParser$$")&&-1===(e.functionName||"").indexOf("StackTraceGPS$$")&&-1===(e.functionName||"").indexOf("StackGenerator$$")},sourceCache:{}};function s(e,n){var t={};return[e,n].forEach(function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}),t}function u(e){return e.stack||e["opera#sourceloc"]}function c(e,n){return"function"==typeof n?e.filter(n):e}return{get:function(e){var n=r();return u(n)?this.fromError(n,e):this.generateArtificially(e)},getSync:function(e){e=s(a,e);var n=r();return c(u(n)?i.parse(n):t.backtrace(e),e.filter)},fromError:function(t,r){r=s(a,r);var o=new e(r);return new Promise(function(e){var n=c(i.parse(t),r.filter);e(Promise.all(n.map(function(t){return new Promise(function(e){function n(){e(t)}o.pinpoint(t).then(e,n).catch(n)})})))}.bind(this))},generateArtificially:function(e){e=s(a,e);var n=t.backtrace(e);return"function"==typeof e.filter&&(n=n.filter(e.filter)),Promise.resolve(n)},instrument:function(e,n,t,r){if("function"!=typeof e)throw new Error("Cannot instrument non-function object");if("function"==typeof e.__stacktraceOriginalFn)return e;var o=function(){try{return this.get().then(n,t).catch(t),e.apply(r||this,arguments)}catch(e){throw u(e)&&this.fromError(e).then(n,t).catch(t),e}}.bind(this);return o.__stacktraceOriginalFn=e,o},deinstrument:function(e){if("function"!=typeof e)throw new Error("Cannot de-instrument non-function object");return"function"==typeof e.__stacktraceOriginalFn?e.__stacktraceOriginalFn:e},report:function(a,s,u,c){return new Promise(function(e,n){var t=new XMLHttpRequest;if(t.onerror=n,t.onreadystatechange=function(){4===t.readyState&&(200<=t.status&&t.status<400?e(t.responseText):n(new Error("POST to "+s+" failed with status: "+t.status)))},t.open("post",s),t.setRequestHeader("Content-Type","application/json"),c&&"object"==typeof c.headers){var r=c.headers;for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&t.setRequestHeader(o,r[o])}var i={stack:a};null!=u&&(i.message=u),t.send(JSON.stringify(i))})}}});function N(){}return N.prototype.start=function(e){if(!e.key&&!e.targetUrl&&!e.customReportingFunction)throw new Error("Cannot initialize: No API key, target url or custom reporting function provided.");if(!e.projectId&&!e.targetUrl&&!e.customReportingFunction)throw new Error("Cannot initialize: No project ID, target url or custom reporting function provided.");this.customReportingFunction=e.customReportingFunction,this.apiKey=e.key,this.projectId=e.projectId,this.targetUrl=e.targetUrl,this.context=e.context||{},this.serviceContext={service:e.service||"web"},e.version&&(this.serviceContext.version=e.version),this.reportUncaughtExceptions=!1!==e.reportUncaughtExceptions,this.reportUnhandledPromiseRejections=!1!==e.reportUnhandledPromiseRejections,this.disabled=!!e.disabled,function(i){function a(){}if(i.reportUncaughtExceptions){var s=window.onerror||a;window.onerror=function(e,n,t,r,o){return o&&i.report(o).catch(a),s(e,n,t,r,o),!0}}if(i.reportUnhandledPromiseRejections){var n=window.onunhandledrejection||a;window.onunhandledrejection=function(e){return e&&i.report(e.reason).catch(a),n(e.reason),!0}}}(this)},N.prototype.report=function(n,e){if(this.disabled)return Promise.resolve(null);if(!n)return Promise.reject(new Error("no error to report"));e=e||{};var t={};t.serviceContext=this.serviceContext,t.context=this.context,t.context.httpRequest={userAgent:window.navigator.userAgent,url:window.location.href};var r=0;if("string"==typeof n||n instanceof String){try{throw new Error(n)}catch(e){n=e}r=e.skipLocalFrames||1}var o=this.targetUrl||"https://clouderrorreporting.googleapis.com/v1beta1/projects/"+this.projectId+"/events:report?key="+this.apiKey,i=this.customReportingFunction;return function(r,o){return S.fromError(r).then(function(e){for(var n=[r.toString()],t=o;t<e.length;t++)n.push([" at ",e[t].getFunctionName()||"<anonymous>"," (",e[t].getFileName(),":",e[t].getLineNumber(),":",e[t].getColumnNumber(),")"].join(""));return n.join("\n")},function(e){return["Error extracting stack trace: ",e,"\n",r.toString(),"\n"," (",r.file,":",r.line,":",r.column,")"].join("")})}(n,r).then(function(e){return t.message=e,i?i(t):function(e,r){var o=new XMLHttpRequest;return o.open("POST",e,!0),o.setRequestHeader("Content-Type","application/json; charset=UTF-8"),new Promise(function(n,t){o.onreadystatechange=function(){if(4===o.readyState){var e=o.status;if(200<=e&&e<300)n({message:r.message});else if(429===e)t({message:"quota or rate limiting error on stackdriver report",name:"Http429FakeError"});else{t(new Error((e?e+" http response":"network error")+" on stackdriver report"))}}},o.send(JSON.stringify(r))})}(o,t)})},N.prototype.setUser=function(e){this.context.user=e},N});
//# sourceMappingURL=maps/stackdriver-errors-concat.min.js.map