<commit_before>window.Prometheus = (function(){

var URL;
var LOCATOR;
var ANONS; //TO-DO: add boolean to config to toggle tracking anonymous users

var Prometheus = function(config){

	//TO-DO: write check to see if '/prometheus' is at the end of url
	URL = config.url || config || "NO_URL_EXCEPTION";
	LOCATOR = config.locator || true;

	if(LOCATOR){
		getGeoIP(updateCoords);
	}

	var prometheus = {

		trackUser: function(uid){
			if(uid){
				sessionStorage.setItem('prometheus_user', uid);
			}
		},

		getUID: function(){
			var track = "ANONYMOUS_USER";
			if(this.isTrackingUser()){
				track = sessionStorage.getItem('prometheus_user');
			}
			return track;
		},

		save: function(dataObj, metaProps){
			var uid = this.getUID();
			var eventData = dataObj || {type: "SAVED_VISIT"};
			var meta = metaProps || 'all';
			var visitsRoute = createRoute('/users/' + uid + '/visits');
			visitsRoute.push({
				meta: this.get(meta),
				visit: eventData
			});
		},

		error: function(errorInfo){
			var dataObj = {
				type: "ERROR",
				message: errorInfo.message,
				url: errorInfo.url,
				line: errorInfo.line
			};
			this.save(dataObj);
		},

		logon: function(uid, userData, metaProps){
			if(uid){
				this.trackUser(uid);
				if(userData){
					var profileRoute = createRoute('/users/' + uid + '/profile');
					profileRoute.set(userData);
				}
				this.save({type: "USER_LOGON"}, metaProps);
			}
		},

		isTrackingUser: function(){
			var response = false;
			var trackedUID = sessionStorage.getItem('prometheus_user');
			if(trackedUID){
				response = true;
			}
			return response;
		},

		//TO-DO: function to change URL of firebase reference

		get: function(request){
			var response = {};
			if(Array.isArray(request) && request.length > 0){
				if(request.includes('all')){
					response = getData('all');
				}
				else{
					for(var d = 0; d < request.length; d++){
						var prop = request[d];
						response[prop] = getData(prop);
					}
				}
			}
			else if(request){
				response = getData(request);
			}
			else{
				response = "BAD_REQUEST_EXCEPTION"
			}
			return response;
		},

		deliver: function(featureID, callback, fallback){
			var uid = this.getUID();
			var featureRoute = createRoute('/features/' + featureID + '/access/');
			featureRoute.once('value', function(snapshot){
				var allowed = snapshot.val();
				var executed = false;
				for(var i in allowed){
					if(uid === allowed[i]){
						callback();
						executed = true;
						break;
					}
				}
				if(!executed && fallback){
					fallback();
				}
			});
		},

		toString: function(){
			console.log(config);
			return 'Bringing Firebase to humanity!';
		}

	}

		//Track Errors
	window.onerror = function(msg, url, line){
		prometheus.error({
			message: msg,
			url: url,
			line: line
		});
	}

	return prometheus;

}

/*--------------------------------------------*/
/*---> FIREBASE HANDLING <--------------------*/
/*--------------------------------------------*/

function createRoute(endpoint){
	var route;
	if(URL && URL !== "NO_URL_EXCEPTION"){
		//TO-DO: check that endpoint has leading slash
		route = new Firebase(URL + endpoint);
	}
	else{
		throw new Error(URL, 'prometheus.js');
	}
	return route;
}

/*--------------------------------------------*/
/*---> META DATA RETRIEVAL <------------------*/
/*--------------------------------------------*/

var GEOLOCATION = {
	latitude: 0,
	longitude: 0,
	isValid: false
};

function getGeoIP(callback){
	var x = new XMLHttpRequest();
	x.open('GET', 'https://geoip.nekudo.com/api/', false);
	x.send();
	var res = x.responseText;
	var geoip = JSON.parse(res);
	if(callback){
		callback(geoip);
	}
}

function updateCoords(position){
	GEOLOCATION.latitude = position.location.latitude;
	GEOLOCATION.longitude = position.location.longitude;
	GEOLOCATION.city = position.city;
	GEOLOCATION.country = position.country.name;
	GEOLOCATION.ip = position.ip
	GEOLOCATION.isValid = true;
}

function getLocationData(){
	var response = "NO_GEOLOCATION_EXCEPTION";
	if(GEOLOCATION.isValid){
		response = {
			latitude: GEOLOCATION.latitude,
			longitude: GEOLOCATION.longitude,
			city: GEOLOCATION.city,
			country: GEOLOCATION.country,
			ip: GEOLOCATION.ip
		}
	}
	return response;
}

function getDateTimeData(){
	return {
		timestamp: Date.now(),
		timezoneOffset: new Date().getTimezoneOffset()
	}
}

/*
 * S/O: http://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser
 */
function getBrowserData(){
	var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
	if(/trident/i.test(M[1])){
		tem=/\brv[ :]+(\d+)/g.exec(ua) || []; 
		return {name:'IE',version:(tem[1]||'')};
		}
	if(M[1]==='Chrome'){
		tem=ua.match(/\bOPR\/(\d+)/)
		if(tem!=null)   {return {name:'Opera', version:tem[1]};}
		}
	M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
	if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);}
	return {
		name: M[0],
		version: M[1]
	}
}

function getPageData(){
	return {
		url: location.href
	}
}

function getData(dataType){
	var response;
	switch(dataType){
		case 'location':
			response = getLocationData();
			break;
		case 'datetime':
			response = getDateTimeData();
			break;
		case 'browser':
			response = getBrowserData();
			break;
		case 'page':
			response = getPageData();
			break;
		case 'all':
			response = {
				location: getLocationData(),
				datetime: getDateTimeData(),
				browser: getBrowserData(),
				page: getPageData()
			}
			break;
		default:
			response = "BAD_REQUEST_EXCEPTION";
	}
	return response;
}

return Prometheus;

}());<commit_msg>Take screenshots with Prometheus Tracking<commit_after>window.Prometheus = (function(){

//HTML2CANVAS
(function(t,e,n,r,o,i){function a(t,e,n,r,o){return g(t,t,n,r,e,t.defaultView.pageXOffset,t.defaultView.pageYOffset).then(function(i){L("Document cloned");var a=Yt+o,c="["+a+"='"+o+"']";t.querySelector(c).removeAttribute(a);var h=i.contentWindow,u=h.document.querySelector(c),l="function"==typeof e.onclone?Promise.resolve(e.onclone(h.document)):Promise.resolve(!0);return l.then(function(){return s(u,i,e,n,r)})})}function s(t,n,r,o,i){var a=n.contentWindow,s=new _t(a.document),d=new P(r,s),p=V(t),f="view"===r.type?o:u(a.document),g="view"===r.type?i:l(a.document),m=new r.renderer(f,g,d,r,e),y=new U(t,m,s,d,r);return y.ready.then(function(){L("Finished rendering");var e;return e="view"===r.type?h(m.canvas,{width:m.canvas.width,height:m.canvas.height,top:0,left:0,x:0,y:0}):t===a.document.body||t===a.document.documentElement||null!=r.canvas?m.canvas:h(m.canvas,{width:null!=r.width?r.width:p.width,height:null!=r.height?r.height:p.height,top:p.top,left:p.left,x:a.pageXOffset,y:a.pageYOffset}),c(n,r),e})}function c(t,e){e.removeContainer&&(t.parentNode.removeChild(t),L("Cleaned up container"))}function h(t,n){var r=e.createElement("canvas"),o=Math.min(t.width-1,Math.max(0,n.left)),i=Math.min(t.width,Math.max(1,n.left+n.width)),a=Math.min(t.height-1,Math.max(0,n.top)),s=Math.min(t.height,Math.max(1,n.top+n.height));return r.width=n.width,r.height=n.height,L("Cropping canvas at:","left:",n.left,"top:",n.top,"width:",i-o,"height:",s-a),L("Resulting crop with width",n.width,"and height",n.height," with x",o,"and y",a),r.getContext("2d").drawImage(t,o,a,i-o,s-a,n.x,n.y,i-o,s-a),r}function u(t){return Math.max(Math.max(t.body.scrollWidth,t.documentElement.scrollWidth),Math.max(t.body.offsetWidth,t.documentElement.offsetWidth),Math.max(t.body.clientWidth,t.documentElement.clientWidth))}function l(t){return Math.max(Math.max(t.body.scrollHeight,t.documentElement.scrollHeight),Math.max(t.body.offsetHeight,t.documentElement.offsetHeight),Math.max(t.body.clientHeight,t.documentElement.clientHeight))}function d(){return"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}function p(){return e.documentMode&&e.documentMode<=9}function f(t,n){for(var r=3===t.nodeType?e.createTextNode(t.nodeValue):t.cloneNode(!1),o=t.firstChild;o;)(n===!0||1!==o.nodeType||"SCRIPT"!==o.nodeName)&&r.appendChild(f(o,n)),o=o.nextSibling;return r}function g(t,e,n,r,o,i,a){w(t);var s=p()?f(t.documentElement,o.javascriptEnabled):t.documentElement.cloneNode(!0),c=e.createElement("iframe");return c.className="html2canvas-container",c.style.visibility="hidden",c.style.position="fixed",c.style.left="-10000px",c.style.top="0px",c.style.border="0",c.width=n,c.height=r,c.scrolling="no",e.body.appendChild(c),new Promise(function(e){var n=c.contentWindow.document;m(t.documentElement,s,"textarea"),m(t.documentElement,s,"select"),c.contentWindow.onload=c.onload=function(){var r=setInterval(function(){n.body.childNodes.length>0&&(x(t,n),clearInterval(r),"view"===o.type&&c.contentWindow.scrollTo(i,a),e(c))},50)},n.open(),n.write("<!DOCTYPE html><html></html>"),y(t,i,a),n.replaceChild(o.javascriptEnabled===!0?n.adoptNode(s):E(n.adoptNode(s)),n.documentElement),n.close()})}function m(t,e,n){for(var r=t.getElementsByTagName(n),o=e.getElementsByTagName(n),i=r.length,a=0;i>a;a++)o[a].value=r[a].value}function y(t,e,n){!t.defaultView||e===t.defaultView.pageXOffset&&n===t.defaultView.pageYOffset||t.defaultView.scrollTo(e,n)}function v(e,n,r,o,i,a){return new Ot(e,n,t.document).then(b(e)).then(function(t){return g(t,r,o,i,a,0,0)})}function b(t){return function(n){var r,o=new DOMParser;try{r=o.parseFromString(n,"text/html")}catch(i){L("DOMParser not supported, falling back to createHTMLDocument"),r=e.implementation.createHTMLDocument("");try{r.open(),r.write(n),r.close()}catch(a){L("createHTMLDocument write not supported, falling back to document.body.innerHTML"),r.body.innerHTML=n}}var s=r.querySelector("base");if(!s||!s.href.host){var c=r.createElement("base");c.href=t,r.head.insertBefore(c,r.head.firstChild)}return r}}function w(t){[].slice.call(t.querySelectorAll("canvas"),0).forEach(function(t){t.setAttribute(Gt,"canvas-"+Qt++)})}function x(t,e){[].slice.call(t.querySelectorAll("["+Gt+"]"),0).forEach(function(t){try{var n=e.querySelector("["+Gt+'="'+t.getAttribute(Gt)+'"]');n&&(n.width=t.width,n.height=t.height,n.getContext("2d").putImageData(t.getContext("2d").getImageData(0,0,t.width,t.height),0,0))}catch(r){L("Unable to copy canvas content from",t,r)}t.removeAttribute(Gt)})}function E(t){return[].slice.call(t.childNodes,0).filter(T).forEach(function(e){"SCRIPT"===e.tagName?t.removeChild(e):E(e)}),t}function T(t){return t.nodeType===Node.ELEMENT_NODE}function k(t){var n=e.createElement("a");return n.href=t,n.href=n.href,n}function C(t){this.r=0,this.g=0,this.b=0,this.a=null;this.fromArray(t)||this.namedColor(t)||this.rgb(t)||this.rgba(t)||this.hex6(t)||this.hex3(t)}function S(t){if(this.src=t,L("DummyImageContainer for",t),!this.promise||!this.image){L("Initiating DummyImageContainer"),S.prototype.image=new Image;var e=this.image;S.prototype.promise=new Promise(function(t,n){e.onload=t,e.onerror=n,e.src=d(),e.complete===!0&&t(e)})}}function I(t,n){var r,o,i=e.createElement("div"),a=e.createElement("img"),s=e.createElement("span"),c="Hidden Text";i.style.visibility="hidden",i.style.fontFamily=t,i.style.fontSize=n,i.style.margin=0,i.style.padding=0,e.body.appendChild(i),a.src=d(),a.width=1,a.height=1,a.style.margin=0,a.style.padding=0,a.style.verticalAlign="baseline",s.style.fontFamily=t,s.style.fontSize=n,s.style.margin=0,s.style.padding=0,s.appendChild(e.createTextNode(c)),i.appendChild(s),i.appendChild(a),r=a.offsetTop-s.offsetTop+1,i.removeChild(s),i.appendChild(e.createTextNode(c)),i.style.lineHeight="normal",a.style.verticalAlign="super",o=a.offsetTop-i.offsetTop+1,e.body.removeChild(i),this.baseline=r,this.lineWidth=1,this.middle=o}function O(){this.data={}}function R(t,e,n){this.image=null,this.src=t;var r=this,o=V(t);this.promise=(e?new Promise(function(e){"about:blank"===t.contentWindow.document.URL||null==t.contentWindow.document.documentElement?t.contentWindow.onload=t.onload=function(){e(t)}:e(t)}):this.proxyLoad(n.proxy,o,n)).then(function(t){return html2canvas(t.contentWindow.document.documentElement,{type:"view",width:t.width,height:t.height,proxy:n.proxy,javascriptEnabled:n.javascriptEnabled,removeContainer:n.removeContainer,allowTaint:n.allowTaint,imageTimeout:n.imageTimeout/2})}).then(function(t){return r.image=t})}function A(t){this.src=t.value,this.colorStops=[],this.type=null,this.x0=.5,this.y0=.5,this.x1=.5,this.y1=.5,this.promise=Promise.resolve(!0)}function M(t,e){this.src=t,this.image=new Image;var n=this;this.tainted=null,this.promise=new Promise(function(r,o){n.image.onload=r,n.image.onerror=o,e&&(n.image.crossOrigin="anonymous"),n.image.src=t,n.image.complete===!0&&r(n.image)})}function P(e,n){this.link=null,this.options=e,this.support=n,this.origin=this.getOrigin(t.location.href)}function N(t){A.apply(this,arguments),this.type=this.TYPES.LINEAR;var e=null===t.args[0].match(this.stepRegExp);e?t.args[0].split(" ").reverse().forEach(function(t){switch(t){case"left":this.x0=0,this.x1=1;break;case"top":this.y0=0,this.y1=1;break;case"right":this.x0=1,this.x1=0;break;case"bottom":this.y0=1,this.y1=0;break;case"to":var e=this.y0,n=this.x0;this.y0=this.y1,this.x0=this.x1,this.x1=n,this.y1=e}},this):(this.y0=0,this.y1=1),this.colorStops=t.args.slice(e?1:0).map(function(t){var e=t.match(this.stepRegExp);return{color:new C(e[1]),stop:"%"===e[3]?e[2]/100:null}},this),null===this.colorStops[0].stop&&(this.colorStops[0].stop=0),null===this.colorStops[this.colorStops.length-1].stop&&(this.colorStops[this.colorStops.length-1].stop=1),this.colorStops.forEach(function(t,e){null===t.stop&&this.colorStops.slice(e).some(function(n,r){return null!==n.stop?(t.stop=(n.stop-this.colorStops[e-1].stop)/(r+1)+this.colorStops[e-1].stop,!0):!1},this)},this)}function L(){t.html2canvas.logging&&t.console&&t.console.log&&Function.prototype.bind.call(t.console.log,t.console).apply(t.console,[Date.now()-t.html2canvas.start+"ms","html2canvas:"].concat([].slice.call(arguments,0)))}function D(t,e){this.node=t,this.parent=e,this.stack=null,this.bounds=null,this.borders=null,this.clip=[],this.backgroundClip=[],this.offsetBounds=null,this.visible=null,this.computedStyles=null,this.colors={},this.styles={},this.backgroundImages=null,this.transformData=null,this.transformMatrix=null,this.isPseudoElement=!1,this.opacity=null}function B(t){var e=t.options[t.selectedIndex||0];return e?e.text||"":""}function _(t){return t&&"matrix"===t[1]?t[2].split(",").map(function(t){return parseFloat(t.trim())}):void 0}function F(t){return-1!==t.toString().indexOf("%")}function j(t){var e,n,r,o,i,a,s,c=" \r\n	",h=[],u=0,l=0,d=function(){e&&('"'===n.substr(0,1)&&(n=n.substr(1,n.length-2)),n&&s.push(n),"-"===e.substr(0,1)&&(o=e.indexOf("-",1)+1)>0&&(r=e.substr(0,o),e=e.substr(o)),h.push({prefix:r,method:e.toLowerCase(),value:i,args:s,image:null})),s=[],e=r=n=i=""};return s=[],e=r=n=i="",t.split("").forEach(function(t){if(!(0===u&&c.indexOf(t)>-1)){switch(t){case'"':a?a===t&&(a=null):a=t;break;case"(":if(a)break;if(0===u)return u=1,void(i+=t);l++;break;case")":if(a)break;if(1===u){if(0===l)return u=0,i+=t,void d();l--}break;case",":if(a)break;if(0===u)return void d();if(1===u&&0===l&&!e.match(/^url$/i))return s.push(n),n="",void(i+=t)}i+=t,0===u?e+=t:n+=t}}),d(),h}function W(t){return t.replace("px","")}function H(t){return parseFloat(t)}function V(t){if(t.getBoundingClientRect){var e=t.getBoundingClientRect(),n=null==t.offsetWidth?e.width:t.offsetWidth;return{top:e.top,bottom:e.bottom||e.top+e.height,right:e.left+n,left:e.left,width:n,height:null==t.offsetHeight?e.height:t.offsetHeight}}return{}}function z(t){var e=t.offsetParent?z(t.offsetParent):{top:0,left:0};return{top:t.offsetTop+e.top,bottom:t.offsetTop+t.offsetHeight+e.top,right:t.offsetLeft+e.left+t.offsetWidth,left:t.offsetLeft+e.left,width:t.offsetWidth,height:t.offsetHeight}}function U(t,e,n,r,o){L("Starting NodeParser"),this.renderer=e,this.options=o,this.range=null,this.support=n,this.renderQueue=[],this.stack=new Bt(!0,1,t.ownerDocument,null);var i=new D(t,null);if(o.background&&e.rectangle(0,0,e.width,e.height,new C(o.background)),t===t.ownerDocument.documentElement){var a=new D(i.color("backgroundColor").isTransparent()?t.ownerDocument.body:t.ownerDocument.documentElement,null);e.rectangle(0,0,e.width,e.height,a.color("backgroundColor"))}i.visibile=i.isElementVisible(),this.createPseudoHideStyles(t.ownerDocument),this.disableAnimations(t.ownerDocument),this.nodes=Tt([i].concat(this.getChildren(i)).filter(function(t){return t.visible=t.isElementVisible()}).map(this.getPseudoElements,this)),this.fontMetrics=new O,L("Fetched nodes, total:",this.nodes.length),L("Calculate overflow clips"),this.calculateOverflowClips(),L("Start fetching images"),this.images=r.fetch(this.nodes.filter(ft)),this.ready=this.images.ready.then(bt(function(){return L("Images loaded, starting parsing"),L("Creating stacking contexts"),this.createStackingContexts(),L("Sorting stacking contexts"),this.sortStackingContexts(this.stack),this.parse(this.stack),L("Render queue created with "+this.renderQueue.length+" items"),new Promise(bt(function(t){o.async?"function"==typeof o.async?o.async.call(this,this.renderQueue,t):this.renderQueue.length>0?(this.renderIndex=0,this.asyncRenderer(this.renderQueue,t)):t():(this.renderQueue.forEach(this.paint,this),t())},this))},this))}function q(t){return t.parent&&t.parent.clip.length}function X(t){return t.replace(/(\-[a-z])/g,function(t){return t.toUpperCase().replace("-","")})}function Y(){}function G(t,e,n,r){return t.map(function(o,i){if(o.width>0){var a=e.left,s=e.top,c=e.width,h=e.height-t[2].width;switch(i){case 0:h=t[0].width,o.args=K({c1:[a,s],c2:[a+c,s],c3:[a+c-t[1].width,s+h],c4:[a+t[3].width,s+h]},r[0],r[1],n.topLeftOuter,n.topLeftInner,n.topRightOuter,n.topRightInner);break;case 1:a=e.left+e.width-t[1].width,c=t[1].width,o.args=K({c1:[a+c,s],c2:[a+c,s+h+t[2].width],c3:[a,s+h],c4:[a,s+t[0].width]},r[1],r[2],n.topRightOuter,n.topRightInner,n.bottomRightOuter,n.bottomRightInner);break;case 2:s=s+e.height-t[2].width,h=t[2].width,o.args=K({c1:[a+c,s+h],c2:[a,s+h],c3:[a+t[3].width,s],c4:[a+c-t[3].width,s]},r[2],r[3],n.bottomRightOuter,n.bottomRightInner,n.bottomLeftOuter,n.bottomLeftInner);break;case 3:c=t[3].width,o.args=K({c1:[a,s+h+t[2].width],c2:[a,s],c3:[a+c,s+t[0].width],c4:[a+c,s+h]},r[3],r[0],n.bottomLeftOuter,n.bottomLeftInner,n.topLeftOuter,n.topLeftInner)}}return o})}function Q(t,e,n,r){var o=4*((Math.sqrt(2)-1)/3),i=n*o,a=r*o,s=t+n,c=e+r;return{topLeft:J({x:t,y:c},{x:t,y:c-a},{x:s-i,y:e},{x:s,y:e}),topRight:J({x:t,y:e},{x:t+i,y:e},{x:s,y:c-a},{x:s,y:c}),bottomRight:J({x:s,y:e},{x:s,y:e+a},{x:t+i,y:c},{x:t,y:c}),bottomLeft:J({x:s,y:c},{x:s-i,y:c},{x:t,y:e+a},{x:t,y:e})}}function $(t,e,n){var r=t.left,o=t.top,i=t.width,a=t.height,s=e[0][0],c=e[0][1],h=e[1][0],u=e[1][1],l=e[2][0],d=e[2][1],p=e[3][0],f=e[3][1],g=i-h,m=a-d,y=i-l,v=a-f;return{topLeftOuter:Q(r,o,s,c).topLeft.subdivide(.5),topLeftInner:Q(r+n[3].width,o+n[0].width,Math.max(0,s-n[3].width),Math.max(0,c-n[0].width)).topLeft.subdivide(.5),topRightOuter:Q(r+g,o,h,u).topRight.subdivide(.5),topRightInner:Q(r+Math.min(g,i+n[3].width),o+n[0].width,g>i+n[3].width?0:h-n[3].width,u-n[0].width).topRight.subdivide(.5),bottomRightOuter:Q(r+y,o+m,l,d).bottomRight.subdivide(.5),bottomRightInner:Q(r+Math.min(y,i-n[3].width),o+Math.min(m,a+n[0].width),Math.max(0,l-n[1].width),d-n[2].width).bottomRight.subdivide(.5),bottomLeftOuter:Q(r,o+v,p,f).bottomLeft.subdivide(.5),bottomLeftInner:Q(r+n[3].width,o+v,Math.max(0,p-n[3].width),f-n[2].width).bottomLeft.subdivide(.5)}}function J(t,e,n,r){var o=function(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}};return{start:t,startControl:e,endControl:n,end:r,subdivide:function(i){var a=o(t,e,i),s=o(e,n,i),c=o(n,r,i),h=o(a,s,i),u=o(s,c,i),l=o(h,u,i);return[J(t,a,h,l),J(l,u,c,r)]},curveTo:function(t){t.push(["bezierCurve",e.x,e.y,n.x,n.y,r.x,r.y])},curveToReversed:function(r){r.push(["bezierCurve",n.x,n.y,e.x,e.y,t.x,t.y])}}}function K(t,e,n,r,o,i,a){var s=[];return e[0]>0||e[1]>0?(s.push(["line",r[1].start.x,r[1].start.y]),r[1].curveTo(s)):s.push(["line",t.c1[0],t.c1[1]]),n[0]>0||n[1]>0?(s.push(["line",i[0].start.x,i[0].start.y]),i[0].curveTo(s),s.push(["line",a[0].end.x,a[0].end.y]),a[0].curveToReversed(s)):(s.push(["line",t.c2[0],t.c2[1]]),s.push(["line",t.c3[0],t.c3[1]])),e[0]>0||e[1]>0?(s.push(["line",o[1].end.x,o[1].end.y]),o[1].curveToReversed(s)):s.push(["line",t.c4[0],t.c4[1]]),s}function Z(t,e,n,r,o,i,a){e[0]>0||e[1]>0?(t.push(["line",r[0].start.x,r[0].start.y]),r[0].curveTo(t),r[1].curveTo(t)):t.push(["line",i,a]),(n[0]>0||n[1]>0)&&t.push(["line",o[0].start.x,o[0].start.y])}function tt(t){return t.cssInt("zIndex")<0}function et(t){return t.cssInt("zIndex")>0}function nt(t){return 0===t.cssInt("zIndex")}function rt(t){return-1!==["inline","inline-block","inline-table"].indexOf(t.css("display"))}function ot(t){return t instanceof Bt}function it(t){return t.node.data.trim().length>0}function at(t){return/^(normal|none|0px)$/.test(t.parent.css("letterSpacing"))}function st(t){return["TopLeft","TopRight","BottomRight","BottomLeft"].map(function(e){var n=t.css("border"+e+"Radius"),r=n.split(" ");return r.length<=1&&(r[1]=r[0]),r.map(wt)})}function ct(t){return t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE}function ht(t){var e=t.css("position"),n=-1!==["absolute","relative","fixed"].indexOf(e)?t.css("zIndex"):"auto";return"auto"!==n}function ut(t){return"static"!==t.css("position")}function lt(t){return"none"!==t.css("float")}function dt(t){return-1!==["inline-block","inline-table"].indexOf(t.css("display"))}function pt(t){var e=this;return function(){return!t.apply(e,arguments)}}function ft(t){return t.node.nodeType===Node.ELEMENT_NODE}function gt(t){return t.isPseudoElement===!0}function mt(t){return t.node.nodeType===Node.TEXT_NODE}function yt(t){return function(e,n){return e.cssInt("zIndex")+t.indexOf(e)/t.length-(n.cssInt("zIndex")+t.indexOf(n)/t.length)}}function vt(t){return t.getOpacity()<1}function bt(t,e){return function(){return t.apply(e,arguments)}}function wt(t){return parseInt(t,10)}function xt(t){return t.width}function Et(t){return t.node.nodeType!==Node.ELEMENT_NODE||-1===["SCRIPT","HEAD","TITLE","OBJECT","BR","OPTION"].indexOf(t.node.nodeName)}function Tt(t){return[].concat.apply([],t)}function kt(t){var e=t.substr(0,1);return e===t.substr(t.length-1)&&e.match(/'|"/)?t.substr(1,t.length-2):t}function Ct(e){for(var n,r=[],o=0,i=!1;e.length;)St(e[o])===i?(n=e.splice(0,o),n.length&&r.push(t.html2canvas.punycode.ucs2.encode(n)),i=!i,o=0):o++,o>=e.length&&(n=e.splice(0,o),n.length&&r.push(t.html2canvas.punycode.ucs2.encode(n)));return r}function St(t){return-1!==[32,13,10,9,45].indexOf(t)}function It(t){return/[^\u0000-\u00ff]/.test(t)}function Ot(t,e,n){if(!e)return Promise.reject("No proxy configured");var r=Mt(oe),o=Pt(e,t,r);return oe?Ut(o):At(n,o,r).then(function(t){return jt(t.content)})}function Rt(t,e,n){var r=Mt(ie),o=Pt(e,t,r);return ie?Promise.resolve(o):At(n,o,r).then(function(t){return"data:"+t.type+";base64,"+t.content})}function At(e,n,r){return new Promise(function(o,i){var a=e.createElement("script"),s=function(){delete t.html2canvas.proxy[r],e.body.removeChild(a)};t.html2canvas.proxy[r]=function(t){s(),o(t)},a.src=n,a.onerror=function(t){s(),i(t)},e.body.appendChild(a)})}function Mt(t){return t?"":"html2canvas_"+Date.now()+"_"+ ++re+"_"+Math.round(1e5*Math.random())}function Pt(t,e,n){return t+"?url="+encodeURIComponent(e)+(n.length?"&callback=html2canvas.proxy."+n:"")}function Nt(t,n){var r=(e.createElement("script"),e.createElement("a"));r.href=t,t=r.href,this.src=t,this.image=new Image;var o=this;this.promise=new Promise(function(r,i){o.image.crossOrigin="Anonymous",o.image.onload=r,o.image.onerror=i,new Rt(t,n,e).then(function(t){o.image.src=t})["catch"](i)})}function Lt(t,e,n){D.call(this,t,e),this.isPseudoElement=!0,this.before=":before"===n}function Dt(t,e,n,r,o){this.width=t,this.height=e,this.images=n,this.options=r,this.document=o}function Bt(t,e,n,r){D.call(this,n,r),this.ownStacking=t,this.contexts=[],this.children=[],this.opacity=(this.parent?this.parent.stack.opacity:1)*e}function _t(t){this.rangeBounds=this.testRangeBounds(t),this.cors=this.testCORS(),this.svg=this.testSVG()}function Ft(t){this.src=t,this.image=null;var e=this;this.promise=this.hasFabric().then(function(){return e.isInline(t)?Promise.resolve(e.inlineFormatting(t)):Ut(t)}).then(function(t){return new Promise(function(n){html2canvas.fabric.loadSVGFromString(t,e.createCanvas.call(e,n))})})}function jt(t){var e,n,r,o,i,a,s,c,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=t.length,l="";for(e=0;u>e;e+=4)n=h.indexOf(t[e]),r=h.indexOf(t[e+1]),o=h.indexOf(t[e+2]),i=h.indexOf(t[e+3]),a=n<<2|r>>4,s=(15&r)<<4|o>>2,c=(3&o)<<6|i,l+=64===o?String.fromCharCode(a):64===i||-1===i?String.fromCharCode(a,s):String.fromCharCode(a,s,c);return l}function Wt(t,e){this.src=t,this.image=null;var n=this;this.promise=e?new Promise(function(e,r){n.image=new Image,n.image.onload=e,n.image.onerror=r,n.image.src="data:image/svg+xml,"+(new XMLSerializer).serializeToString(t),n.image.complete===!0&&e(n.image)}):this.hasFabric().then(function(){return new Promise(function(e){html2canvas.fabric.parseSVGDocument(t,n.createCanvas.call(n,e))})})}function Ht(t,e){D.call(this,t,e)}function Vt(t,e,n){return t.length>0?e+n.toUpperCase():void 0}function zt(t){A.apply(this,arguments),this.type="linear"===t.args[0]?this.TYPES.LINEAR:this.TYPES.RADIAL}function Ut(t){return new Promise(function(e,n){var r=new XMLHttpRequest;r.open("GET",t),r.onload=function(){200===r.status?e(r.responseText):n(new Error(r.statusText))},r.onerror=function(){n(new Error("Network Error"))},r.send()})}function qt(t,e){Dt.apply(this,arguments),this.canvas=this.options.canvas||this.document.createElement("canvas"),this.options.canvas||(this.canvas.width=t,this.canvas.height=e),this.ctx=this.canvas.getContext("2d"),this.taintCtx=this.document.createElement("canvas").getContext("2d"),this.ctx.textBaseline="bottom",this.variables={},L("Initialized CanvasRenderer with size",t,"x",e)}function Xt(t){return t.length>0}if(function(){function n(t,e){M[O]=t,M[O+1]=e,O+=2,2===O&&S()}function i(t){return"function"==typeof t}function a(){return function(){process.nextTick(u)}}function s(){var t=0,n=new A(u),r=e.createTextNode("");return n.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function c(){var t=new MessageChannel;return t.port1.onmessage=u,function(){t.port2.postMessage(0)}}function h(){return function(){setTimeout(u,1)}}function u(){for(var t=0;O>t;t+=2)(0,M[t])(M[t+1]),M[t]=void 0,M[t+1]=void 0;O=0}function l(){}function d(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function p(t,e,r){n(function(t){var n=!1,o=d(r,e,function(r){n||(n=!0,e!==r?g(t,r):y(t,r))},function(e){n||(n=!0,v(t,e))});!n&&o&&(n=!0,v(t,o))},t)}function f(t,e){1===e.a?y(t,e.b):2===t.a?v(t,e.b):b(e,void 0,function(e){g(t,e)},function(e){v(t,e)})}function g(t,e){if(t===e)v(t,new TypeError("You cannot resolve a promise with itself"));else if("function"==typeof e||"object"==typeof e&&null!==e)if(e.constructor===t.constructor)f(t,e);else{var n;try{n=e.then}catch(r){P.error=r,n=P}n===P?v(t,P.error):void 0===n?y(t,e):i(n)?p(t,e,n):y(t,e)}else y(t,e)}function m(t){t.f&&t.f(t.b),w(t)}function y(t,e){void 0===t.a&&(t.b=e,t.a=1,0!==t.e.length&&n(w,t))}function v(t,e){void 0===t.a&&(t.a=2,t.b=e,n(m,t))}function b(t,e,r,o){var i=t.e,a=i.length;t.f=null,i[a]=e,i[a+1]=r,i[a+2]=o,0===a&&t.a&&n(w,t)}function w(t){var e=t.e,n=t.a;if(0!==e.length){for(var r,o,i=t.b,a=0;a<e.length;a+=3)r=e[a],o=e[a+n],r?E(n,r,o,i):o(i);t.e.length=0}}function x(){this.error=null}function E(t,e,n,r){var o,a,s,c,h=i(n);if(h){try{o=n(r)}catch(u){N.error=u,o=N}if(o===N?(c=!0,a=o.error,o=null):s=!0,e===o)return void v(e,new TypeError("A promises callback cannot return that same promise."))}else o=r,s=!0;void 0===e.a&&(h&&s?g(e,o):c?v(e,a):1===t?y(e,o):2===t&&v(e,o))}function T(t,e){try{e(function(e){g(t,e)},function(e){v(t,e)})}catch(n){v(t,n)}}function k(t,e,n,r){this.n=t,this.c=new t(l,r),this.i=n,this.o(e)?(this.m=e,this.d=this.length=e.length,this.l(),0===this.length?y(this.c,this.b):(this.length=this.length||0,this.k(),0===this.d&&y(this.c,this.b))):v(this.c,this.p())}function C(t){if(L++,this.b=this.a=void 0,this.e=[],l!==t){if(!i(t))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof C))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");T(this,t)}}var S,I=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},O=0,R="undefined"!=typeof t?t:{},A=R.MutationObserver||R.WebKitMutationObserver,R="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,M=Array(1e3);S="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?a():A?s():R?c():h();var P=new x,N=new x;k.prototype.o=function(t){return I(t)},k.prototype.p=function(){return Error("Array Methods must be provided an Array")},k.prototype.l=function(){this.b=Array(this.length)},k.prototype.k=function(){for(var t=this.length,e=this.c,n=this.m,r=0;void 0===e.a&&t>r;r++)this.j(n[r],r)},k.prototype.j=function(t,e){var n=this.n;"object"==typeof t&&null!==t?t.constructor===n&&void 0!==t.a?(t.f=null,this.g(t.a,e,t.b)):this.q(n.resolve(t),e):(this.d--,this.b[e]=this.h(t))},k.prototype.g=function(t,e,n){var r=this.c;void 0===r.a&&(this.d--,this.i&&2===t?v(r,n):this.b[e]=this.h(n)),0===this.d&&y(r,this.b)},k.prototype.h=function(t){return t},k.prototype.q=function(t,e){var n=this;b(t,void 0,function(t){n.g(1,e,t)},function(t){n.g(2,e,t)})};var L=0;C.all=function(t,e){return new k(this,t,!0,e).c},C.race=function(t,e){function n(t){g(o,t)}function r(t){v(o,t)}var o=new this(l,e);if(!I(t))return v(o,new TypeError("You must pass an array to race.")),o;for(var i=t.length,a=0;void 0===o.a&&i>a;a++)b(this.resolve(t[a]),void 0,n,r);return o},C.resolve=function(t,e){if(t&&"object"==typeof t&&t.constructor===this)return t;var n=new this(l,e);return g(n,t),n},C.reject=function(t,e){var n=new this(l,e);return v(n,t),n},C.prototype={constructor:C,then:function(t,e){var r=this.a;if(1===r&&!t||2===r&&!e)return this;var o=new this.constructor(l),i=this.b;if(r){var a=arguments[r-1];n(function(){E(r,o,a,i)})}else b(this,o,t,e);return o},"catch":function(t){return this.then(null,t)}};var D={Promise:C,polyfill:function(){var e;e="undefined"!=typeof r?r:"undefined"!=typeof t&&t.document?t:self,"Promise"in e&&"resolve"in e.Promise&&"reject"in e.Promise&&"all"in e.Promise&&"race"in e.Promise&&function(){var t;return new e.Promise(function(e){t=e}),i(t)}()||(e.Promise=C)}};"function"==typeof o&&o.amd?o(function(){return D}):"undefined"!=typeof module&&module.exports?module.exports=D:"undefined"!=typeof this&&(this.ES6Promise=D)}.call(t),t&&t.ES6Promise.polyfill(),"undefined"==typeof e||"function"!=typeof Object.create||"function"!=typeof e.createElement("canvas").getContext)return void((t||module.exports).html2canvas=function(){return Promise.reject("No canvas support")});!function(t){function e(t){throw RangeError(N[t])}function i(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}function a(t,e){var n=t.split("@"),r="";n.length>1&&(r=n[0]+"@",t=n[1]);var o=t.split(P),a=i(o,e).join(".");return r+a}function s(t){for(var e,n,r=[],o=0,i=t.length;i>o;)e=t.charCodeAt(o++),e>=55296&&56319>=e&&i>o?(n=t.charCodeAt(o++),56320==(64512&n)?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),o--)):r.push(e);return r}function c(t){return i(t,function(t){var e="";return t>65535&&(t-=65536,e+=B(t>>>10&1023|55296),t=56320|1023&t),e+=B(t)}).join("")}function h(t){return 10>t-48?t-22:26>t-65?t-65:26>t-97?t-97:E}function u(t,e){return t+22+75*(26>t)-((0!=e)<<5)}function l(t,e,n){var r=0;for(t=n?D(t/S):t>>1,t+=D(t/e);t>L*k>>1;r+=E)t=D(t/L);return D(r+(L+1)*t/(t+C))}function d(t){var n,r,o,i,a,s,u,d,p,f,g=[],m=t.length,y=0,v=O,b=I;for(r=t.lastIndexOf(R),0>r&&(r=0),o=0;r>o;++o)t.charCodeAt(o)>=128&&e("not-basic"),g.push(t.charCodeAt(o));for(i=r>0?r+1:0;m>i;){for(a=y,s=1,u=E;i>=m&&e("invalid-input"),d=h(t.charCodeAt(i++)),(d>=E||d>D((x-y)/s))&&e("overflow"),y+=d*s,p=b>=u?T:u>=b+k?k:u-b,!(p>d);u+=E)f=E-p,s>D(x/f)&&e("overflow"),s*=f;n=g.length+1,b=l(y-a,n,0==a),D(y/n)>x-v&&e("overflow"),v+=D(y/n),y%=n,g.splice(y++,0,v)}return c(g)}function p(t){var n,r,o,i,a,c,h,d,p,f,g,m,y,v,b,w=[];for(t=s(t),m=t.length,n=O,r=0,a=I,c=0;m>c;++c)g=t[c],128>g&&w.push(B(g));for(o=i=w.length,i&&w.push(R);m>o;){for(h=x,c=0;m>c;++c)g=t[c],g>=n&&h>g&&(h=g);for(y=o+1,h-n>D((x-r)/y)&&e("overflow"),r+=(h-n)*y,n=h,c=0;m>c;++c)if(g=t[c],n>g&&++r>x&&e("overflow"),g==n){for(d=r,p=E;f=a>=p?T:p>=a+k?k:p-a,!(f>d);p+=E)b=d-f,v=E-f,w.push(B(u(f+b%v,0))),d=D(b/v);w.push(B(u(d,0))),a=l(r,y,o==i),r=0,++o}++r,++n}return w.join("")}function f(t){return a(t,function(t){return A.test(t)?d(t.slice(4).toLowerCase()):t})}function g(t){return a(t,function(t){return M.test(t)?"xn--"+p(t):t})}var m="object"==typeof n&&n&&!n.nodeType&&n,y="object"==typeof module&&module&&!module.nodeType&&module,v="object"==typeof r&&r;(v.global===v||v.window===v||v.self===v)&&(t=v);var b,w,x=2147483647,E=36,T=1,k=26,C=38,S=700,I=72,O=128,R="-",A=/^xn--/,M=/[^\x20-\x7E]/,P=/[\x2E\u3002\uFF0E\uFF61]/g,N={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},L=E-T,D=Math.floor,B=String.fromCharCode;if(b={version:"1.3.1",ucs2:{decode:s,encode:c},decode:d,encode:p,toASCII:g,toUnicode:f},"function"==typeof o&&"object"==typeof o.amd&&o.amd)o("punycode",function(){return b});else if(m&&y)if(module.exports==m)y.exports=b;else for(w in b)b.hasOwnProperty(w)&&(m[w]=b[w]);else t.punycode=b}(this);var Yt="data-html2canvas-node",Gt="data-html2canvas-canvas-clone",Qt=0,$t=0;t.html2canvas=function(n,r){var o=$t++;if(r=r||{},r.logging&&(t.html2canvas.logging=!0,t.html2canvas.start=Date.now()),r.async="undefined"==typeof r.async?!0:r.async,r.allowTaint="undefined"==typeof r.allowTaint?!1:r.allowTaint,r.removeContainer="undefined"==typeof r.removeContainer?!0:r.removeContainer,r.javascriptEnabled="undefined"==typeof r.javascriptEnabled?!1:r.javascriptEnabled,r.imageTimeout="undefined"==typeof r.imageTimeout?1e4:r.imageTimeout,r.renderer="function"==typeof r.renderer?r.renderer:qt,r.strict=!!r.strict,"string"==typeof n){if("string"!=typeof r.proxy)return Promise.reject("Proxy must be used when rendering url");var c=null!=r.width?r.width:t.innerWidth,h=null!=r.height?r.height:t.innerHeight;return v(k(n),r.proxy,e,c,h,r).then(function(t){return s(t.contentWindow.document.documentElement,t,r,c,h)})}var u=(n===i?[e.documentElement]:n.length?n:[n])[0];return u.setAttribute(Yt+o,o),a(u.ownerDocument,r,u.ownerDocument.defaultView.innerWidth,u.ownerDocument.defaultView.innerHeight,o).then(function(t){return"function"==typeof r.onrendered&&(L("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas"),r.onrendered(t)),t})},t.html2canvas.punycode=this.punycode,t.html2canvas.proxy={},C.prototype.darken=function(t){var e=1-t;return new C([Math.round(this.r*e),Math.round(this.g*e),Math.round(this.b*e),this.a])},C.prototype.isTransparent=function(){return 0===this.a},C.prototype.isBlack=function(){return 0===this.r&&0===this.g&&0===this.b},C.prototype.fromArray=function(t){return Array.isArray(t)&&(this.r=Math.min(t[0],255),this.g=Math.min(t[1],255),this.b=Math.min(t[2],255),t.length>3&&(this.a=t[3])),Array.isArray(t)};var Jt=/^#([a-f0-9]{3})$/i;C.prototype.hex3=function(t){var e=null;return null!==(e=t.match(Jt))&&(this.r=parseInt(e[1][0]+e[1][0],16),this.g=parseInt(e[1][1]+e[1][1],16),this.b=parseInt(e[1][2]+e[1][2],16)),null!==e};var Kt=/^#([a-f0-9]{6})$/i;C.prototype.hex6=function(t){var e=null;return null!==(e=t.match(Kt))&&(this.r=parseInt(e[1].substring(0,2),16),this.g=parseInt(e[1].substring(2,4),16),this.b=parseInt(e[1].substring(4,6),16)),null!==e};var Zt=/^rgb\((\d{1,3}) *, *(\d{1,3}) *, *(\d{1,3})\)$/;C.prototype.rgb=function(t){var e=null;return null!==(e=t.match(Zt))&&(this.r=Number(e[1]),this.g=Number(e[2]),this.b=Number(e[3])),null!==e};var te=/^rgba\((\d{1,3}) *, *(\d{1,3}) *, *(\d{1,3}) *, *(\d+\.?\d*)\)$/;C.prototype.rgba=function(t){var e=null;return null!==(e=t.match(te))&&(this.r=Number(e[1]),this.g=Number(e[2]),this.b=Number(e[3]),this.a=Number(e[4])),null!==e},C.prototype.toString=function(){return null!==this.a&&1!==this.a?"rgba("+[this.r,this.g,this.b,this.a].join(",")+")":"rgb("+[this.r,this.g,this.b].join(",")+")"},C.prototype.namedColor=function(t){var e=ee[t.toLowerCase()];if(e)this.r=e[0],this.g=e[1],this.b=e[2];else if("transparent"===t.toLowerCase())return this.r=this.g=this.b=this.a=0,!0;return!!e},C.prototype.isColor=!0;var ee={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],
darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};O.prototype.getMetrics=function(t,e){return this.data[t+"-"+e]===i&&(this.data[t+"-"+e]=new I(t,e)),this.data[t+"-"+e]},R.prototype.proxyLoad=function(t,e,n){var r=this.src;return v(r.src,t,r.ownerDocument,e.width,e.height,n)},A.prototype.TYPES={LINEAR:1,RADIAL:2},P.prototype.findImages=function(t){var e=[];return t.reduce(function(t,e){switch(e.node.nodeName){case"IMG":return t.concat([{args:[e.node.src],method:"url"}]);case"svg":case"IFRAME":return t.concat([{args:[e.node],method:e.node.nodeName}])}return t},[]).forEach(this.addImage(e,this.loadImage),this),e},P.prototype.findBackgroundImage=function(t,e){return e.parseBackgroundImages().filter(this.hasImageBackground).forEach(this.addImage(t,this.loadImage),this),t},P.prototype.addImage=function(t,e){return function(n){n.args.forEach(function(r){this.imageExists(t,r)||(t.splice(0,0,e.call(this,n)),L("Added image #"+t.length,"string"==typeof r?r.substring(0,100):r))},this)}},P.prototype.hasImageBackground=function(t){return"none"!==t.method},P.prototype.loadImage=function(t){if("url"===t.method){var e=t.args[0];return!this.isSVG(e)||this.support.svg||this.options.allowTaint?e.match(/data:image\/.*;base64,/i)?new M(e.replace(/url\(['"]{0,}|['"]{0,}\)$/gi,""),!1):this.isSameOrigin(e)||this.options.allowTaint===!0||this.isSVG(e)?new M(e,!1):this.support.cors&&!this.options.allowTaint&&this.options.useCORS?new M(e,!0):this.options.proxy?new Nt(e,this.options.proxy):new S(e):new Ft(e)}return"linear-gradient"===t.method?new N(t):"gradient"===t.method?new zt(t):"svg"===t.method?new Wt(t.args[0],this.support.svg):"IFRAME"===t.method?new R(t.args[0],this.isSameOrigin(t.args[0].src),this.options):new S(t)},P.prototype.isSVG=function(t){return"svg"===t.substring(t.length-3).toLowerCase()||Ft.prototype.isInline(t)},P.prototype.imageExists=function(t,e){return t.some(function(t){return t.src===e})},P.prototype.isSameOrigin=function(t){return this.getOrigin(t)===this.origin},P.prototype.getOrigin=function(t){var n=this.link||(this.link=e.createElement("a"));return n.href=t,n.href=n.href,n.protocol+n.hostname+n.port},P.prototype.getPromise=function(t){return this.timeout(t,this.options.imageTimeout)["catch"](function(){var e=new S(t.src);return e.promise.then(function(e){t.image=e})})},P.prototype.get=function(t){var e=null;return this.images.some(function(n){return(e=n).src===t})?e:null},P.prototype.fetch=function(t){return this.images=t.reduce(bt(this.findBackgroundImage,this),this.findImages(t)),this.images.forEach(function(t,e){t.promise.then(function(){L("Succesfully loaded image #"+(e+1),t)},function(n){L("Failed loading image #"+(e+1),t,n)})}),this.ready=Promise.all(this.images.map(this.getPromise,this)),L("Finished searching images"),this},P.prototype.timeout=function(t,e){var n,r=Promise.race([t.promise,new Promise(function(r,o){n=setTimeout(function(){L("Timed out loading image",t),o(t)},e)})]).then(function(t){return clearTimeout(n),t});return r["catch"](function(){clearTimeout(n)}),r},N.prototype=Object.create(A.prototype),N.prototype.stepRegExp=/((?:rgb|rgba)\(\d{1,3},\s\d{1,3},\s\d{1,3}(?:,\s[0-9\.]+)?\))\s*(\d{1,3})?(%|px)?/,D.prototype.cloneTo=function(t){t.visible=this.visible,t.borders=this.borders,t.bounds=this.bounds,t.clip=this.clip,t.backgroundClip=this.backgroundClip,t.computedStyles=this.computedStyles,t.styles=this.styles,t.backgroundImages=this.backgroundImages,t.opacity=this.opacity},D.prototype.getOpacity=function(){return null===this.opacity?this.opacity=this.cssFloat("opacity"):this.opacity},D.prototype.assignStack=function(t){this.stack=t,t.children.push(this)},D.prototype.isElementVisible=function(){return this.node.nodeType===Node.TEXT_NODE?this.parent.visible:"none"!==this.css("display")&&"hidden"!==this.css("visibility")&&!this.node.hasAttribute("data-html2canvas-ignore")&&("INPUT"!==this.node.nodeName||"hidden"!==this.node.getAttribute("type"))},D.prototype.css=function(t){return this.computedStyles||(this.computedStyles=this.isPseudoElement?this.parent.computedStyle(this.before?":before":":after"):this.computedStyle(null)),this.styles[t]||(this.styles[t]=this.computedStyles[t])},D.prototype.prefixedCss=function(t){var e=["webkit","moz","ms","o"],n=this.css(t);return n===i&&e.some(function(e){return n=this.css(e+t.substr(0,1).toUpperCase()+t.substr(1)),n!==i},this),n===i?null:n},D.prototype.computedStyle=function(t){return this.node.ownerDocument.defaultView.getComputedStyle(this.node,t)},D.prototype.cssInt=function(t){var e=parseInt(this.css(t),10);return isNaN(e)?0:e},D.prototype.color=function(t){return this.colors[t]||(this.colors[t]=new C(this.css(t)))},D.prototype.cssFloat=function(t){var e=parseFloat(this.css(t));return isNaN(e)?0:e},D.prototype.fontWeight=function(){var t=this.css("fontWeight");switch(parseInt(t,10)){case 401:t="bold";break;case 400:t="normal"}return t},D.prototype.parseClip=function(){var t=this.css("clip").match(this.CLIP);return t?{top:parseInt(t[1],10),right:parseInt(t[2],10),bottom:parseInt(t[3],10),left:parseInt(t[4],10)}:null},D.prototype.parseBackgroundImages=function(){return this.backgroundImages||(this.backgroundImages=j(this.css("backgroundImage")))},D.prototype.cssList=function(t,e){var n=(this.css(t)||"").split(",");return n=n[e||0]||n[0]||"auto",n=n.trim().split(" "),1===n.length&&(n=[n[0],n[0]]),n},D.prototype.parseBackgroundSize=function(t,e,n){var r,o,i=this.cssList("backgroundSize",n);if(F(i[0]))r=t.width*parseFloat(i[0])/100;else{if(/contain|cover/.test(i[0])){var a=t.width/t.height,s=e.width/e.height;return s>a^"contain"===i[0]?{width:t.height*s,height:t.height}:{width:t.width,height:t.width/s}}r=parseInt(i[0],10)}return o="auto"===i[0]&&"auto"===i[1]?e.height:"auto"===i[1]?r/e.width*e.height:F(i[1])?t.height*parseFloat(i[1])/100:parseInt(i[1],10),"auto"===i[0]&&(r=o/e.height*e.width),{width:r,height:o}},D.prototype.parseBackgroundPosition=function(t,e,n,r){var o,i,a=this.cssList("backgroundPosition",n);return o=F(a[0])?(t.width-(r||e).width)*(parseFloat(a[0])/100):parseInt(a[0],10),i="auto"===a[1]?o/e.width*e.height:F(a[1])?(t.height-(r||e).height)*parseFloat(a[1])/100:parseInt(a[1],10),"auto"===a[0]&&(o=i/e.height*e.width),{left:o,top:i}},D.prototype.parseBackgroundRepeat=function(t){return this.cssList("backgroundRepeat",t)[0]},D.prototype.parseTextShadows=function(){var t=this.css("textShadow"),e=[];if(t&&"none"!==t)for(var n=t.match(this.TEXT_SHADOW_PROPERTY),r=0;n&&r<n.length;r++){var o=n[r].match(this.TEXT_SHADOW_VALUES);e.push({color:new C(o[0]),offsetX:o[1]?parseFloat(o[1].replace("px","")):0,offsetY:o[2]?parseFloat(o[2].replace("px","")):0,blur:o[3]?o[3].replace("px",""):0})}return e},D.prototype.parseTransform=function(){if(!this.transformData)if(this.hasTransform()){var t=this.parseBounds(),e=this.prefixedCss("transformOrigin").split(" ").map(W).map(H);e[0]+=t.left,e[1]+=t.top,this.transformData={origin:e,matrix:this.parseTransformMatrix()}}else this.transformData={origin:[0,0],matrix:[1,0,0,1,0,0]};return this.transformData},D.prototype.parseTransformMatrix=function(){if(!this.transformMatrix){var t=this.prefixedCss("transform"),e=t?_(t.match(this.MATRIX_PROPERTY)):null;this.transformMatrix=e?e:[1,0,0,1,0,0]}return this.transformMatrix},D.prototype.parseBounds=function(){return this.bounds||(this.bounds=this.hasTransform()?z(this.node):V(this.node))},D.prototype.hasTransform=function(){return"1,0,0,1,0,0"!==this.parseTransformMatrix().join(",")||this.parent&&this.parent.hasTransform()},D.prototype.getValue=function(){var t=this.node.value||"";return"SELECT"===this.node.tagName?t=B(this.node):"password"===this.node.type&&(t=Array(t.length+1).join("•")),0===t.length?this.node.placeholder||"":t},D.prototype.MATRIX_PROPERTY=/(matrix)\((.+)\)/,D.prototype.TEXT_SHADOW_PROPERTY=/((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g,D.prototype.TEXT_SHADOW_VALUES=/(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g,D.prototype.CLIP=/^rect\((\d+)px,? (\d+)px,? (\d+)px,? (\d+)px\)$/,U.prototype.calculateOverflowClips=function(){this.nodes.forEach(function(t){if(ft(t)){gt(t)&&t.appendToDOM(),t.borders=this.parseBorders(t);var e="hidden"===t.css("overflow")?[t.borders.clip]:[],n=t.parseClip();n&&-1!==["absolute","fixed"].indexOf(t.css("position"))&&e.push([["rect",t.bounds.left+n.left,t.bounds.top+n.top,n.right-n.left,n.bottom-n.top]]),t.clip=q(t)?t.parent.clip.concat(e):e,t.backgroundClip="hidden"!==t.css("overflow")?t.clip.concat([t.borders.clip]):t.clip,gt(t)&&t.cleanDOM()}else mt(t)&&(t.clip=q(t)?t.parent.clip:[]);gt(t)||(t.bounds=null)},this)},U.prototype.asyncRenderer=function(t,e,n){n=n||Date.now(),this.paint(t[this.renderIndex++]),t.length===this.renderIndex?e():n+20>Date.now()?this.asyncRenderer(t,e,n):setTimeout(bt(function(){this.asyncRenderer(t,e)},this),0)},U.prototype.createPseudoHideStyles=function(t){this.createStyles(t,"."+Lt.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE+':before { content: "" !important; display: none !important; }.'+Lt.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER+':after { content: "" !important; display: none !important; }')},U.prototype.disableAnimations=function(t){this.createStyles(t,"* { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; animation: none !important; -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; transition: none !important;}")},U.prototype.createStyles=function(t,e){var n=t.createElement("style");n.innerHTML=e,t.body.appendChild(n)},U.prototype.getPseudoElements=function(t){var e=[[t]];if(t.node.nodeType===Node.ELEMENT_NODE){var n=this.getPseudoElement(t,":before"),r=this.getPseudoElement(t,":after");n&&e.push(n),r&&e.push(r)}return Tt(e)},U.prototype.getPseudoElement=function(t,n){var r=t.computedStyle(n);if(!r||!r.content||"none"===r.content||"-moz-alt-content"===r.content||"none"===r.display)return null;for(var o=kt(r.content),i="url"===o.substr(0,3),a=e.createElement(i?"img":"html2canvaspseudoelement"),s=new Lt(a,t,n),c=r.length-1;c>=0;c--){var h=X(r.item(c));a.style[h]=r[h]}if(a.className=Lt.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE+" "+Lt.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER,i)return a.src=j(o)[0].args[0],[s];var u=e.createTextNode(o);return a.appendChild(u),[s,new Ht(u,s)]},U.prototype.getChildren=function(t){return Tt([].filter.call(t.node.childNodes,ct).map(function(e){var n=[e.nodeType===Node.TEXT_NODE?new Ht(e,t):new D(e,t)].filter(Et);return e.nodeType===Node.ELEMENT_NODE&&n.length&&"TEXTAREA"!==e.tagName?n[0].isElementVisible()?n.concat(this.getChildren(n[0])):[]:n},this))},U.prototype.newStackingContext=function(t,e){var n=new Bt(e,t.getOpacity(),t.node,t.parent);t.cloneTo(n);var r=e?n.getParentStack(this):n.parent.stack;r.contexts.push(n),t.stack=n},U.prototype.createStackingContexts=function(){this.nodes.forEach(function(t){ft(t)&&(this.isRootElement(t)||vt(t)||ht(t)||this.isBodyWithTransparentRoot(t)||t.hasTransform())?this.newStackingContext(t,!0):ft(t)&&(ut(t)&&nt(t)||dt(t)||lt(t))?this.newStackingContext(t,!1):t.assignStack(t.parent.stack)},this)},U.prototype.isBodyWithTransparentRoot=function(t){return"BODY"===t.node.nodeName&&t.parent.color("backgroundColor").isTransparent()},U.prototype.isRootElement=function(t){return null===t.parent},U.prototype.sortStackingContexts=function(t){t.contexts.sort(yt(t.contexts.slice(0))),t.contexts.forEach(this.sortStackingContexts,this)},U.prototype.parseTextBounds=function(t){return function(e,n,r){if("none"!==t.parent.css("textDecoration").substr(0,4)||0!==e.trim().length){if(this.support.rangeBounds&&!t.parent.hasTransform()){var o=r.slice(0,n).join("").length;return this.getRangeBounds(t.node,o,e.length)}if(t.node&&"string"==typeof t.node.data){var i=t.node.splitText(e.length),a=this.getWrapperBounds(t.node,t.parent.hasTransform());return t.node=i,a}}else(!this.support.rangeBounds||t.parent.hasTransform())&&(t.node=t.node.splitText(e.length));return{}}},U.prototype.getWrapperBounds=function(t,e){var n=t.ownerDocument.createElement("html2canvaswrapper"),r=t.parentNode,o=t.cloneNode(!0);n.appendChild(t.cloneNode(!0)),r.replaceChild(n,t);var i=e?z(n):V(n);return r.replaceChild(o,n),i},U.prototype.getRangeBounds=function(t,e,n){var r=this.range||(this.range=t.ownerDocument.createRange());return r.setStart(t,e),r.setEnd(t,e+n),r.getBoundingClientRect()},U.prototype.parse=function(t){var e=t.contexts.filter(tt),n=t.children.filter(ft),r=n.filter(pt(lt)),o=r.filter(pt(ut)).filter(pt(rt)),i=n.filter(pt(ut)).filter(lt),a=r.filter(pt(ut)).filter(rt),s=t.contexts.concat(r.filter(ut)).filter(nt),c=t.children.filter(mt).filter(it),h=t.contexts.filter(et);e.concat(o).concat(i).concat(a).concat(s).concat(c).concat(h).forEach(function(t){this.renderQueue.push(t),ot(t)&&(this.parse(t),this.renderQueue.push(new Y))},this)},U.prototype.paint=function(t){try{t instanceof Y?this.renderer.ctx.restore():mt(t)?(gt(t.parent)&&t.parent.appendToDOM(),this.paintText(t),gt(t.parent)&&t.parent.cleanDOM()):this.paintNode(t)}catch(e){if(L(e),this.options.strict)throw e}},U.prototype.paintNode=function(t){ot(t)&&(this.renderer.setOpacity(t.opacity),this.renderer.ctx.save(),t.hasTransform()&&this.renderer.setTransform(t.parseTransform())),"INPUT"===t.node.nodeName&&"checkbox"===t.node.type?this.paintCheckbox(t):"INPUT"===t.node.nodeName&&"radio"===t.node.type?this.paintRadio(t):this.paintElement(t)},U.prototype.paintElement=function(t){var e=t.parseBounds();this.renderer.clip(t.backgroundClip,function(){this.renderer.renderBackground(t,e,t.borders.borders.map(xt))},this),this.renderer.clip(t.clip,function(){this.renderer.renderBorders(t.borders.borders)},this),this.renderer.clip(t.backgroundClip,function(){switch(t.node.nodeName){case"svg":case"IFRAME":var n=this.images.get(t.node);n?this.renderer.renderImage(t,e,t.borders,n):L("Error loading <"+t.node.nodeName+">",t.node);break;case"IMG":var r=this.images.get(t.node.src);r?this.renderer.renderImage(t,e,t.borders,r):L("Error loading <img>",t.node.src);break;case"CANVAS":this.renderer.renderImage(t,e,t.borders,{image:t.node});break;case"SELECT":case"INPUT":case"TEXTAREA":this.paintFormValue(t)}},this)},U.prototype.paintCheckbox=function(t){var e=t.parseBounds(),n=Math.min(e.width,e.height),r={width:n-1,height:n-1,top:e.top,left:e.left},o=[3,3],i=[o,o,o,o],a=[1,1,1,1].map(function(t){return{color:new C("#A5A5A5"),width:t}}),s=$(r,i,a);this.renderer.clip(t.backgroundClip,function(){this.renderer.rectangle(r.left+1,r.top+1,r.width-2,r.height-2,new C("#DEDEDE")),this.renderer.renderBorders(G(a,r,s,i)),t.node.checked&&(this.renderer.font(new C("#424242"),"normal","normal","bold",n-3+"px","arial"),this.renderer.text("✔",r.left+n/6,r.top+n-1))},this)},U.prototype.paintRadio=function(t){var e=t.parseBounds(),n=Math.min(e.width,e.height)-2;this.renderer.clip(t.backgroundClip,function(){this.renderer.circleStroke(e.left+1,e.top+1,n,new C("#DEDEDE"),1,new C("#A5A5A5")),t.node.checked&&this.renderer.circle(Math.ceil(e.left+n/4)+1,Math.ceil(e.top+n/4)+1,Math.floor(n/2),new C("#424242"))},this)},U.prototype.paintFormValue=function(t){var e=t.getValue();if(e.length>0){var n=t.node.ownerDocument,r=n.createElement("html2canvaswrapper"),o=["lineHeight","textAlign","fontFamily","fontWeight","fontSize","color","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","borderLeftStyle","borderTopStyle","borderLeftWidth","borderTopWidth","boxSizing","whiteSpace","wordWrap"];o.forEach(function(e){try{r.style[e]=t.css(e)}catch(n){L("html2canvas: Parse: Exception caught in renderFormValue: "+n.message)}});var i=t.parseBounds();r.style.position="fixed",r.style.left=i.left+"px",r.style.top=i.top+"px",r.textContent=e,n.body.appendChild(r),this.paintText(new Ht(r.firstChild,t)),n.body.removeChild(r)}},U.prototype.paintText=function(e){e.applyTextTransform();var n=t.html2canvas.punycode.ucs2.decode(e.node.data),r=this.options.letterRendering&&!at(e)||It(e.node.data)?n.map(function(e){return t.html2canvas.punycode.ucs2.encode([e])}):Ct(n),o=e.parent.fontWeight(),i=e.parent.css("fontSize"),a=e.parent.css("fontFamily"),s=e.parent.parseTextShadows();this.renderer.font(e.parent.color("color"),e.parent.css("fontStyle"),e.parent.css("fontVariant"),o,i,a),s.length?this.renderer.fontShadow(s[0].color,s[0].offsetX,s[0].offsetY,s[0].blur):this.renderer.clearShadow(),this.renderer.clip(e.parent.clip,function(){r.map(this.parseTextBounds(e),this).forEach(function(t,n){t&&(this.renderer.text(r[n],t.left,t.bottom),this.renderTextDecoration(e.parent,t,this.fontMetrics.getMetrics(a,i)))},this)},this)},U.prototype.renderTextDecoration=function(t,e,n){switch(t.css("textDecoration").split(" ")[0]){case"underline":this.renderer.rectangle(e.left,Math.round(e.top+n.baseline+n.lineWidth),e.width,1,t.color("color"));break;case"overline":this.renderer.rectangle(e.left,Math.round(e.top),e.width,1,t.color("color"));break;case"line-through":this.renderer.rectangle(e.left,Math.ceil(e.top+n.middle+n.lineWidth),e.width,1,t.color("color"))}};var ne={inset:[["darken",.6],["darken",.1],["darken",.1],["darken",.6]]};U.prototype.parseBorders=function(t){var e=t.parseBounds(),n=st(t),r=["Top","Right","Bottom","Left"].map(function(e,n){var r=t.css("border"+e+"Style"),o=t.color("border"+e+"Color");"inset"===r&&o.isBlack()&&(o=new C([255,255,255,o.a]));var i=ne[r]?ne[r][n]:null;return{width:t.cssInt("border"+e+"Width"),color:i?o[i[0]](i[1]):o,args:null}}),o=$(e,n,r);return{clip:this.parseBackgroundClip(t,o,r,n,e),borders:G(r,e,o,n)}},U.prototype.parseBackgroundClip=function(t,e,n,r,o){var i=t.css("backgroundClip"),a=[];switch(i){case"content-box":case"padding-box":Z(a,r[0],r[1],e.topLeftInner,e.topRightInner,o.left+n[3].width,o.top+n[0].width),Z(a,r[1],r[2],e.topRightInner,e.bottomRightInner,o.left+o.width-n[1].width,o.top+n[0].width),Z(a,r[2],r[3],e.bottomRightInner,e.bottomLeftInner,o.left+o.width-n[1].width,o.top+o.height-n[2].width),Z(a,r[3],r[0],e.bottomLeftInner,e.topLeftInner,o.left+n[3].width,o.top+o.height-n[2].width);break;default:Z(a,r[0],r[1],e.topLeftOuter,e.topRightOuter,o.left,o.top),Z(a,r[1],r[2],e.topRightOuter,e.bottomRightOuter,o.left+o.width,o.top),Z(a,r[2],r[3],e.bottomRightOuter,e.bottomLeftOuter,o.left+o.width,o.top+o.height),Z(a,r[3],r[0],e.bottomLeftOuter,e.topLeftOuter,o.left,o.top+o.height)}return a};var re=0,oe="withCredentials"in new XMLHttpRequest,ie="crossOrigin"in new Image;Lt.prototype.cloneTo=function(t){Lt.prototype.cloneTo.call(this,t),t.isPseudoElement=!0,t.before=this.before},Lt.prototype=Object.create(D.prototype),Lt.prototype.appendToDOM=function(){this.before?this.parent.node.insertBefore(this.node,this.parent.node.firstChild):this.parent.node.appendChild(this.node),this.parent.node.className+=" "+this.getHideClass()},Lt.prototype.cleanDOM=function(){this.node.parentNode.removeChild(this.node),this.parent.node.className=this.parent.node.className.replace(this.getHideClass(),"")},Lt.prototype.getHideClass=function(){return this["PSEUDO_HIDE_ELEMENT_CLASS_"+(this.before?"BEFORE":"AFTER")]},Lt.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE="___html2canvas___pseudoelement_before",Lt.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER="___html2canvas___pseudoelement_after",Dt.prototype.renderImage=function(t,e,n,r){var o=t.cssInt("paddingLeft"),i=t.cssInt("paddingTop"),a=t.cssInt("paddingRight"),s=t.cssInt("paddingBottom"),c=n.borders,h=e.width-(c[1].width+c[3].width+o+a),u=e.height-(c[0].width+c[2].width+i+s);this.drawImage(r,0,0,r.image.width||h,r.image.height||u,e.left+o+c[3].width,e.top+i+c[0].width,h,u)},Dt.prototype.renderBackground=function(t,e,n){e.height>0&&e.width>0&&(this.renderBackgroundColor(t,e),this.renderBackgroundImage(t,e,n))},Dt.prototype.renderBackgroundColor=function(t,e){var n=t.color("backgroundColor");n.isTransparent()||this.rectangle(e.left,e.top,e.width,e.height,n)},Dt.prototype.renderBorders=function(t){t.forEach(this.renderBorder,this)},Dt.prototype.renderBorder=function(t){t.color.isTransparent()||null===t.args||this.drawShape(t.args,t.color)},Dt.prototype.renderBackgroundImage=function(t,e,n){var r=t.parseBackgroundImages();r.reverse().forEach(function(r,o,i){switch(r.method){case"url":var a=this.images.get(r.args[0]);a?this.renderBackgroundRepeating(t,e,a,i.length-(o+1),n):L("Error loading background-image",r.args[0]);break;case"linear-gradient":case"gradient":var s=this.images.get(r.value);s?this.renderBackgroundGradient(s,e,n):L("Error loading background-image",r.args[0]);break;case"none":break;default:L("Unknown background-image type",r.args[0])}},this)},Dt.prototype.renderBackgroundRepeating=function(t,e,n,r,o){var i=t.parseBackgroundSize(e,n.image,r),a=t.parseBackgroundPosition(e,n.image,r,i),s=t.parseBackgroundRepeat(r);switch(s){case"repeat-x":case"repeat no-repeat":this.backgroundRepeatShape(n,a,i,e,e.left+o[3],e.top+a.top+o[0],99999,i.height,o);break;case"repeat-y":case"no-repeat repeat":this.backgroundRepeatShape(n,a,i,e,e.left+a.left+o[3],e.top+o[0],i.width,99999,o);break;case"no-repeat":this.backgroundRepeatShape(n,a,i,e,e.left+a.left+o[3],e.top+a.top+o[0],i.width,i.height,o);break;default:this.renderBackgroundRepeat(n,a,i,{top:e.top,left:e.left},o[3],o[0])}},Bt.prototype=Object.create(D.prototype),Bt.prototype.getParentStack=function(t){var e=this.parent?this.parent.stack:null;return e?e.ownStacking?e:e.getParentStack(t):t.stack},_t.prototype.testRangeBounds=function(t){var e,n,r,o,i=!1;return t.createRange&&(e=t.createRange(),e.getBoundingClientRect&&(n=t.createElement("boundtest"),n.style.height="123px",n.style.display="block",t.body.appendChild(n),e.selectNode(n),r=e.getBoundingClientRect(),o=r.height,123===o&&(i=!0),t.body.removeChild(n))),i},_t.prototype.testCORS=function(){return"undefined"!=typeof(new Image).crossOrigin},_t.prototype.testSVG=function(){var t=new Image,n=e.createElement("canvas"),r=n.getContext("2d");t.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{r.drawImage(t,0,0),n.toDataURL()}catch(o){return!1}return!0},Ft.prototype.hasFabric=function(){return html2canvas.fabric?Promise.resolve():Promise.reject(new Error("html2canvas.svg.js is not loaded, cannot render svg"))},Ft.prototype.inlineFormatting=function(t){return/^data:image\/svg\+xml;base64,/.test(t)?this.decode64(this.removeContentType(t)):this.removeContentType(t)},Ft.prototype.removeContentType=function(t){return t.replace(/^data:image\/svg\+xml(;base64)?,/,"")},Ft.prototype.isInline=function(t){return/^data:image\/svg\+xml/i.test(t)},Ft.prototype.createCanvas=function(t){var e=this;return function(n,r){var o=new html2canvas.fabric.StaticCanvas("c");e.image=o.lowerCanvasEl,o.setWidth(r.width).setHeight(r.height).add(html2canvas.fabric.util.groupSVGElements(n,r)).renderAll(),t(o.lowerCanvasEl)}},Ft.prototype.decode64=function(e){return"function"==typeof t.atob?t.atob(e):jt(e)},Wt.prototype=Object.create(Ft.prototype),Ht.prototype=Object.create(D.prototype),Ht.prototype.applyTextTransform=function(){this.node.data=this.transform(this.parent.css("textTransform"))},Ht.prototype.transform=function(t){var e=this.node.data;switch(t){case"lowercase":return e.toLowerCase();case"capitalize":return e.replace(/(^|\s|:|-|\(|\))([a-z])/g,Vt);case"uppercase":return e.toUpperCase();default:return e}},zt.prototype=Object.create(A.prototype),qt.prototype=Object.create(Dt.prototype),qt.prototype.setFillStyle=function(t){return this.ctx.fillStyle="object"==typeof t&&t.isColor?t.toString():t,this.ctx},qt.prototype.rectangle=function(t,e,n,r,o){this.setFillStyle(o).fillRect(t,e,n,r)},qt.prototype.circle=function(t,e,n,r){this.setFillStyle(r),this.ctx.beginPath(),this.ctx.arc(t+n/2,e+n/2,n/2,0,2*Math.PI,!0),this.ctx.closePath(),this.ctx.fill()},qt.prototype.circleStroke=function(t,e,n,r,o,i){this.circle(t,e,n,r),this.ctx.strokeStyle=i.toString(),this.ctx.stroke()},qt.prototype.drawShape=function(t,e){this.shape(t),this.setFillStyle(e).fill()},qt.prototype.taints=function(t){if(null===t.tainted){this.taintCtx.drawImage(t.image,0,0);try{this.taintCtx.getImageData(0,0,1,1),t.tainted=!1}catch(n){this.taintCtx=e.createElement("canvas").getContext("2d"),t.tainted=!0}}return t.tainted},qt.prototype.drawImage=function(t,e,n,r,o,i,a,s,c){(!this.taints(t)||this.options.allowTaint)&&this.ctx.drawImage(t.image,e,n,r,o,i,a,s,c)},qt.prototype.clip=function(t,e,n){this.ctx.save(),t.filter(Xt).forEach(function(t){this.shape(t).clip()},this),e.call(n),this.ctx.restore()},qt.prototype.shape=function(t){return this.ctx.beginPath(),t.forEach(function(t,e){"rect"===t[0]?this.ctx.rect.apply(this.ctx,t.slice(1)):this.ctx[0===e?"moveTo":t[0]+"To"].apply(this.ctx,t.slice(1))},this),this.ctx.closePath(),this.ctx},qt.prototype.font=function(t,e,n,r,o,i){this.setFillStyle(t).font=[e,n,r,o,i].join(" ").split(",")[0]},qt.prototype.fontShadow=function(t,e,n,r){this.setVariable("shadowColor",t.toString()).setVariable("shadowOffsetY",e).setVariable("shadowOffsetX",n).setVariable("shadowBlur",r)},qt.prototype.clearShadow=function(){this.setVariable("shadowColor","rgba(0,0,0,0)")},qt.prototype.setOpacity=function(t){this.ctx.globalAlpha=t},qt.prototype.setTransform=function(t){this.ctx.translate(t.origin[0],t.origin[1]),this.ctx.transform.apply(this.ctx,t.matrix),this.ctx.translate(-t.origin[0],-t.origin[1])},qt.prototype.setVariable=function(t,e){return this.variables[t]!==e&&(this.variables[t]=this.ctx[t]=e),this},qt.prototype.text=function(t,e,n){this.ctx.fillText(t,e,n)},qt.prototype.backgroundRepeatShape=function(t,e,n,r,o,i,a,s,c){var h=[["line",Math.round(o),Math.round(i)],["line",Math.round(o+a),Math.round(i)],["line",Math.round(o+a),Math.round(s+i)],["line",Math.round(o),Math.round(s+i)]];this.clip([h],function(){this.renderBackgroundRepeat(t,e,n,r,c[3],c[0])},this)},qt.prototype.renderBackgroundRepeat=function(t,e,n,r,o,i){var a=Math.round(r.left+e.left+o),s=Math.round(r.top+e.top+i);this.setFillStyle(this.ctx.createPattern(this.resizeImage(t,n),"repeat")),this.ctx.translate(a,s),this.ctx.fill(),this.ctx.translate(-a,-s)},qt.prototype.renderBackgroundGradient=function(t,e){if(t instanceof N){var n=this.ctx.createLinearGradient(e.left+e.width*t.x0,e.top+e.height*t.y0,e.left+e.width*t.x1,e.top+e.height*t.y1);t.colorStops.forEach(function(t){n.addColorStop(t.stop,t.color.toString())}),this.rectangle(e.left,e.top,e.width,e.height,n)}},qt.prototype.resizeImage=function(t,n){var r=t.image;if(r.width===n.width&&r.height===n.height)return r;var o,i=e.createElement("canvas");return i.width=n.width,i.height=n.height,o=i.getContext("2d"),o.drawImage(r,0,0,r.width,r.height,0,0,n.width,n.height),i}}).call({},"undefined"!=typeof window?window:void 0,"undefined"!=typeof document?document:void 0);

var URL;
var LOCATOR;
var ANONS; //TO-DO: add boolean to config to toggle tracking anonymous users

var Prometheus = function(config){

	//TO-DO: write check to see if '/prometheus' is at the end of url
	URL = config.url || config || "NO_URL_EXCEPTION";
	LOCATOR = config.locator || true;

	if(LOCATOR){
		getGeoIP(updateCoords);
	}

	var prometheus = {

		trackUser: function(uid){
			if(uid){
				sessionStorage.setItem('prometheus_user', uid);
			}
		},

		getUID: function(){
			var track = "ANONYMOUS_USER";
			if(this.isTrackingUser()){
				track = sessionStorage.getItem('prometheus_user');
			}
			return track;
		},

		save: function(dataObj, metaProps){
			var uid = this.getUID();
			var eventData = dataObj || {type: "SAVED_VISIT"};
			var meta = metaProps || 'all';
			var visitsRoute = createRoute('/users/' + uid + '/visits');
			visitsRoute.push({
				meta: this.get(meta),
				visit: eventData
			});
		},

		error: function(errorInfo){
			var dataObj = {
				type: "ERROR",
				message: errorInfo.message,
				url: errorInfo.url,
				line: errorInfo.line
			};
			this.save(dataObj);
		},

		logon: function(uid, userData, metaProps){
			if(uid){
				this.trackUser(uid);
				if(userData){
					var profileRoute = createRoute('/users/' + uid + '/profile');
					profileRoute.set(userData);
				}
				this.save({type: "USER_LOGON"}, metaProps);
			}
		},

		capture: function(dataObj){
			var dataObj = dataObj || {type: 'SCREEN_CAPTURE'};
			var _this = this;
			html2canvas(window.parent.document.body, {
				onrendered: function(canvas){
					canvas.style.display = 'none';
					document.body.appendChild(canvas);
					var data = canvas.toDataURL('image/png');
					//document.body.innerHTML += '<img src="' + data + '">';
					dataObj.img = data;
					_this.save(dataObj);
				}
			});
		},

		isTrackingUser: function(){
			var response = false;
			var trackedUID = sessionStorage.getItem('prometheus_user');
			if(trackedUID){
				response = true;
			}
			return response;
		},

		//TO-DO: function to change URL of firebase reference

		get: function(request){
			var response = {};
			if(Array.isArray(request) && request.length > 0){
				if(request.includes('all')){
					response = getData('all');
				}
				else{
					for(var d = 0; d < request.length; d++){
						var prop = request[d];
						response[prop] = getData(prop);
					}
				}
			}
			else if(request){
				response = getData(request);
			}
			else{
				response = "BAD_REQUEST_EXCEPTION"
			}
			return response;
		},

		deliver: function(featureID, callback, fallback){
			var uid = this.getUID();
			var featureRoute = createRoute('/features/' + featureID + '/access/');
			featureRoute.once('value', function(snapshot){
				var allowed = snapshot.val();
				var executed = false;
				for(var i in allowed){
					if(uid === allowed[i]){
						callback();
						executed = true;
						break;
					}
				}
				if(!executed && fallback){
					fallback();
				}
			});
		},

		toString: function(){
			console.log(config);
			return 'Bringing Firebase to humanity!';
		}

	}

		//Track Errors
	window.onerror = function(msg, url, line){
		prometheus.error({
			message: msg,
			url: url,
			line: line
		});
	}

	return prometheus;

}

/*--------------------------------------------*/
/*---> FIREBASE HANDLING <--------------------*/
/*--------------------------------------------*/

function createRoute(endpoint){
	var route;
	if(URL && URL !== "NO_URL_EXCEPTION"){
		//TO-DO: check that endpoint has leading slash
		route = new Firebase(URL + endpoint);
	}
	else{
		throw new Error(URL, 'prometheus.js');
	}
	return route;
}

/*--------------------------------------------*/
/*---> META DATA RETRIEVAL <------------------*/
/*--------------------------------------------*/

var GEOLOCATION = {
	latitude: 0,
	longitude: 0,
	isValid: false
};

function getGeoIP(callback){
	var x = new XMLHttpRequest();
	x.open('GET', 'https://geoip.nekudo.com/api/', false);
	x.send();
	var res = x.responseText;
	var geoip = JSON.parse(res);
	if(callback){
		callback(geoip);
	}
}

function updateCoords(position){
	GEOLOCATION.latitude = position.location.latitude;
	GEOLOCATION.longitude = position.location.longitude;
	GEOLOCATION.city = position.city;
	GEOLOCATION.country = position.country.name;
	GEOLOCATION.ip = position.ip
	GEOLOCATION.isValid = true;
}

function getLocationData(){
	var response = "NO_GEOLOCATION_EXCEPTION";
	if(GEOLOCATION.isValid){
		response = {
			latitude: GEOLOCATION.latitude,
			longitude: GEOLOCATION.longitude,
			city: GEOLOCATION.city,
			country: GEOLOCATION.country,
			ip: GEOLOCATION.ip
		}
	}
	return response;
}

function getDateTimeData(){
	return {
		timestamp: Date.now(),
		timezoneOffset: new Date().getTimezoneOffset()
	}
}

/*
 * S/O: http://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser
 */
function getBrowserData(){
	var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
	if(/trident/i.test(M[1])){
		tem=/\brv[ :]+(\d+)/g.exec(ua) || []; 
		return {name:'IE',version:(tem[1]||'')};
		}
	if(M[1]==='Chrome'){
		tem=ua.match(/\bOPR\/(\d+)/)
		if(tem!=null)   {return {name:'Opera', version:tem[1]};}
		}
	M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
	if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);}
	return {
		name: M[0],
		version: M[1]
	}
}

function getPageData(){
	return {
		url: location.href
	}
}

function getData(dataType){
	var response;
	switch(dataType){
		case 'location':
			response = getLocationData();
			break;
		case 'datetime':
			response = getDateTimeData();
			break;
		case 'browser':
			response = getBrowserData();
			break;
		case 'page':
			response = getPageData();
			break;
		case 'all':
			response = {
				location: getLocationData(),
				datetime: getDateTimeData(),
				browser: getBrowserData(),
				page: getPageData()
			}
			break;
		default:
			response = "BAD_REQUEST_EXCEPTION";
	}
	return response;
}

return Prometheus;

}());
{'fraction_non_alphanumeric': 0.2592475887768523, 'fraction_numerical': 0.032304910127137224, 'mean_word_length': 9.42459297343616, 'pattern_counts': {'":': 51, '<': 33, '<?xml version=': 0, '>': 99, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5952833', 'n_tokens_mistral': 31954, 'n_tokens_neox': 30016, 'n_words': 1750}