(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Spooky = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i').attr('id', this.styleId).text("\n #" + this.wrapperId + " {\n position: relative;\n }\n #" + this.wrapperId + " > #" + this.containerId + "::before {\n content: \" \";\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n background: linear-gradient(\n rgba(" + screenDoorRgb.toString() + ", 0) 50%,\n rgba(" + screenDoorRgb.toString() + ", " + screenDoorOpacity + ") 50%\n ), linear-gradient(\n 90deg,\n rgba(255, 0, 0, 0.06),\n rgba(0, 255, 0, 0.02),\n rgba(0, 0, 255, 0.06)\n );\n z-index: 2;\n background-size: 100% " + screenDoorSize + "px, 3px 100%;\n pointer-events: none;\n }\n " + this.makeFlickerFrames() + "\n #" + this.wrapperId + " > #" + this.containerId + "::after {\n content: \" \";\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n background: rgba(18, 16, 16, 0.1);\n opacity: 0;\n z-index: 2;\n pointer-events: none;\n animation: flicker_" + this.styleId + " 0.15s infinite;\n }\n " + this.makeSeparationFrames() + "\n #" + this.wrapperId + " > #" + this.containerId + " {\n animation: separation_" + this.styleId + " 1.6s infinite;\n }\n ").appendTo($('body'));
}
CRT.prototype.makeFlickerFrames = function () {
var css = "@keyframes flicker_" + this.styleId + " {";
for (var i = 0; i <= 20; i++) {
css += " " + i * 5 + "% { opacity: " + Math.random() + "; }";
}
css += ' }';
return css;
};
CRT.prototype.makeSeparationFrames = function () {
var rgb = new Util_1.rgbColor(this.separationColor);
var css = "@keyframes separation_" + this.styleId + " {";
for (var i = 0; i <= 20; i++) {
css += " " + i * 5 + "% { text-shadow: " + Math.random() * this.separationDistance + "px 0 " + this.separationBlur + "px rgba(" + rgb.toString() + ", " + this.separationOpacity + "), -" + Math.random() * this.separationDistance + "px 0 " + this.separationBlur + "px rgba(" + rgb.toString() + ", " + this.separationOpacity * 0.5 + "), 0 0 3px; }";
}
css += ' }';
return css;
};
CRT.prototype.execute = function () {
if (!$("#" + this.wrapperId).length) {
$("#" + this.containerId).wrap($('
').attr('id', this.wrapperId));
}
};
CRT.prototype.stop = function () {
if ($("#" + this.wrapperId).length) {
$("#" + this.containerId).unwrap("#" + this.wrapperId);
}
};
return CRT;
}());
exports.CRT = CRT;
},{"./Util":3,"jquery":5,"uuid":7}],2:[function(require,module,exports){
"use strict";
// credit: https://codepen.io/zadvorsky/pen/PwyoMm
Object.defineProperty(exports, "__esModule", { value: true });
var $ = require("jquery");
var FilmGrain = /** @class */ (function () {
function FilmGrain(options) {
var _a, _b;
this.targetStep = 0;
this.viewWidth = 0;
this.viewHeight = 0;
this.frame = 0;
this.active = false;
this.patternSize = (options === null || options === void 0 ? void 0 : options.patternSize) || 64;
this.grainScaleX = ((_a = options === null || options === void 0 ? void 0 : options.grainScale) === null || _a === void 0 ? void 0 : _a.x) || 3;
this.grainScaleY = ((_b = options === null || options === void 0 ? void 0 : options.grainScale) === null || _b === void 0 ? void 0 : _b.y) || 1;
this.refreshInterval = (options === null || options === void 0 ? void 0 : options.refreshInterval) || 4;
this.alpha = this.targetAlpha = (options === null || options === void 0 ? void 0 : options.alpha) == null ? 25 : options.alpha;
this.canvasId = options === null || options === void 0 ? void 0 : options.canvasId;
this.patternPixelDataLength = this.patternSize * this.patternSize * 4;
}
FilmGrain.prototype.initCanvas = function (canvasId) {
if (!this.canvasId) {
// create full-screne canvas
this.canvas = $('')
.css({
position: 'fixed',
top: '0',
left: '0',
width: '100%',
height: '100%',
pointerEvents: 'none',
})
.click(function () { return false; });
$('html').css({
position: 'relative',
width: '100%',
height: '100%',
}).append(this.canvas);
}
else {
// use provided canvas
this.canvas = $("#" + this.canvasId);
}
this.viewWidth = this.canvas[0].width = this.canvas[0].clientWidth;
this.viewHeight = this.canvas[0].height = this.canvas[0].clientHeight;
this.context = this.canvas[0].getContext('2d');
this.context.scale(this.grainScaleX, this.grainScaleY);
};
FilmGrain.prototype.initGrain = function () {
this.patternCanvas = document.createElement('canvas');
this.patternCanvas.width = this.patternSize;
this.patternCanvas.height = this.patternSize;
this.patternContext = this.patternCanvas.getContext('2d');
this.patternData = this.patternContext.createImageData(this.patternSize, this.patternSize);
};
FilmGrain.prototype.update = function () {
// handle alpha animations
if (Math.abs(this.targetAlpha - this.alpha) > this.targetStep) {
if (this.targetAlpha < this.alpha) {
this.alpha -= this.targetStep;
}
else {
this.alpha += this.targetStep;
}
}
else if (this.alpha !== this.targetAlpha) {
this.alpha = this.targetAlpha;
}
// put a random shade of gray into every pixel of the pattern
if (this.patternData && this.patternContext) {
for (var i = 0; i < this.patternPixelDataLength; i += 4) {
var value = (Math.random() * 255) | 0;
this.patternData.data[i] = value;
this.patternData.data[i + 1] = value;
this.patternData.data[i + 2] = value;
this.patternData.data[i + 3] = this.alpha;
}
this.patternContext.putImageData(this.patternData, 0, 0);
}
};
FilmGrain.prototype.draw = function () {
if (this.context && this.patternCanvas) {
this.context.clearRect(0, 0, this.viewWidth, this.viewHeight);
this.context.fillStyle = this.context.createPattern(this.patternCanvas, 'repeat');
this.context.fillRect(0, 0, this.viewWidth, this.viewHeight);
}
};
FilmGrain.prototype.loop = function () {
var _this = this;
if (this.active) {
if (++(this.frame) % this.refreshInterval === 0) {
this.update();
this.draw();
}
requestAnimationFrame(function () { return _this.loop(); });
}
};
FilmGrain.prototype.execute = function () {
var _this = this;
if (!this.active) {
this.active = true;
this.initCanvas();
this.initGrain();
requestAnimationFrame(function () { return _this.loop(); });
}
};
FilmGrain.prototype.setAlpha = function (alpha, step) {
if (step === void 0) { step = 5; }
this.targetAlpha = alpha;
this.targetStep = step;
};
FilmGrain.prototype.stop = function () {
this.active = false;
if (!this.canvasId && this.canvas) {
// if we created the original canvas, just remove it
this.canvas.remove();
}
else {
if (this.context) {
// otherwise clear it out
this.context.clearRect(0, 0, this.viewWidth, this.viewHeight);
}
}
};
return FilmGrain;
}());
exports.FilmGrain = FilmGrain;
},{"jquery":5}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rgbColor = /** @class */ (function () {
function rgbColor(hex) {
this.r = 0;
this.g = 0;
this.b = 0;
var regex = hex.length > 4
? /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i
: /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
var repeat = hex.length > 4 ? 1 : 2;
var result = regex.exec(hex);
if (result) {
this.r = parseInt(result[1].repeat(repeat), 16);
this.g = parseInt(result[2].repeat(repeat), 16);
this.b = parseInt(result[3].repeat(repeat), 16);
}
}
rgbColor.prototype.toString = function () {
return this.r + ", " + this.g + ", " + this.b;
};
return rgbColor;
}());
exports.rgbColor = rgbColor;
},{}],4:[function(require,module,exports){
"use strict";
module.exports = {
CRT: require('./CRT.js').CRT,
FilmGrain: require('./FilmGrain.js').FilmGrain,
};
},{"./CRT.js":1,"./FilmGrain.js":2}],5:[function(require,module,exports){
/*!
* jQuery JavaScript Library v3.5.1
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2020-05-04T22:49Z
*/
( function( global, factory ) {
"use strict";
if ( typeof module === "object" && typeof module.exports === "object" ) {
// For CommonJS and CommonJS-like environments where a proper `window`
// is present, execute the factory and get jQuery.
// For environments that do not have a `window` with a `document`
// (such as Node.js), expose a factory as module.exports.
// This accentuates the need for the creation of a real `window`.
// e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info.
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
throw new Error( "jQuery requires a window with a document" );
}
return factory( w );
};
} else {
factory( global );
}
// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
// enough that all such attempts are guarded in a try block.
"use strict";
var arr = [];
var getProto = Object.getPrototypeOf;
var slice = arr.slice;
var flat = arr.flat ? function( array ) {
return arr.flat.call( array );
} : function( array ) {
return arr.concat.apply( [], array );
};
var push = arr.push;
var indexOf = arr.indexOf;
var class2type = {};
var toString = class2type.toString;
var hasOwn = class2type.hasOwnProperty;
var fnToString = hasOwn.toString;
var ObjectFunctionString = fnToString.call( Object );
var support = {};
var isFunction = function isFunction( obj ) {
// Support: Chrome <=57, Firefox <=52
// In some browsers, typeof returns "function" for HTML