text: (function(){var K={"function":true,object:true};function L(a){return(a&&a.Object===Object)?a:null}var C=parseFloat,Q=parseInt;var M=(K[typeof exports]&&exports&&!exports.nodeType)?exports:undefined;var y=(K[typeof module]&&module&&!module.nodeType)?module:undefined;var J=(y&&y.exports===M)?M:undefined;var G=L(M&&y&&typeof global=="object"&&global);var V=L(K[typeof self]&&self);var R=L(K[typeof window]&&window);var F=L(K[typeof this]&&this);var D=G||((R!==(F&&F.window))&&R)||V||F||Function("return this")();if(!("gc" in window)){window.gc=function(){}}if(!HTMLCanvasElement.prototype.toBlob){Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(b,e,c){var a=atob(this.toDataURL(e,c).split(",")[1]),d=a.length,g=new Uint8Array(d);for(var f=0;f<d;f++){g[f]=a.charCodeAt(f)}b(new Blob([g],{type:e||"image/png"}))}})}(function(){if("performance" in window==false){window.performance={}}Date.now=(Date.now||function(){return new Date().getTime()});if("now" in window.performance==false){var a=Date.now();if(performance.timing&&performance.timing.navigationStart){a=performance.timing.navigationStart}window.performance.now=function b(){return Date.now()-a}}})();function B(a){return String("0000000"+a).slice(-7)}var T=window.Date.now();function E(){function a(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()}function I(a){var b={};this.settings=a;this.on=function(d,c){b[d]=c};this.emit=function(d){var c=b[d];if(c){c.apply(null,Array.prototype.slice.call(arguments,1))}};this.filename=a.name||E();this.extension="";this.mimeType=""}I.prototype.start=function(){};I.prototype.stop=function(){};I.prototype.add=function(){};I.prototype.save=function(){};I.prototype.dispose=function(){};I.prototype.safeToProceed=function(){return true};I.prototype.step=function(){console.log("Step not set!")};function P(a){I.call(this,a);this.extension=".tar";this.mimeType="application/x-tar";this.fileExtension="";this.tape=null;this.count=0}P.prototype=Object.create(I.prototype);P.prototype.start=function(){this.dispose()};P.prototype.add=function(a){var b=new FileReader();b.onload=function(){this.tape.append(B(this.count)+this.fileExtension,new Uint8Array(b.result));this.count++;this.step()}.bind(this);b.readAsArrayBuffer(a)};P.prototype.save=function(a){a(this.tape.save())};P.prototype.dispose=function(){this.tape=new Tar();this.count=0};function H(a){P.call(this,a);this.type="image/png";this.fileExtension=".png"}H.prototype=Object.create(P.prototype);H.prototype.add=function(a){a.toBlob(function(b){P.prototype.add.call(this,b)}.bind(this),this.type)};function A(a){P.call(this,a);this.type="image/jpeg";this.fileExtension=".jpg";this.quality=(a.quality/100)||0.8}A.prototype=Object.create(P.prototype);A.prototype.add=function(a){a.toBlob(function(b){P.prototype.add.call(this,b)}.bind(this),this.type,this.quality)};function N(a){var b=document.createElement("canvas");if(b.toDataURL("image/webp").substr(5,10)!=="image/webp"){console.log("WebP not supported - try another export format")}I.call(this,a);a.quality=(a.quality/100)||0.8;this.extension=".webm";this.mimeType="video/webm";this.baseFilename=this.filename;this.frames=[];this.part=1}N.prototype=Object.create(I.prototype);N.prototype.start=function(a){this.dispose()};N.prototype.add=function(a){this.frames.push(a.toDataURL("image/webp",this.quality));if(this.settings.autoSaveTime>0&&(this.frames.length/this.settings.framerate)>=this.settings.autoSaveTime){this.save(function(b){this.filename=this.baseFilename+"-part-"+B(this.part);download(b,this.filename+this.extension,this.mimeType);this.dispose();this.part++;this.filename=this.baseFilename+"-part-"+B(this.part);this.step()}.bind(this))}else{this.step()}};N.prototype.save=function(a){if(!this.frames.length){return}var b=Whammy.fromImageArray(this.frames,this.settings.framerate);var c=new Blob([b],{type:"octet/stream"});a(c)};N.prototype.dispose=function(a){this.frames=[]};function O(a){I.call(this,a);a.quality=(a.quality/100)||0.8;this.encoder=new FFMpegServer.Video(a);this.encoder.on("process",function(){this.emit("process")}.bind(this));this.encoder.on("finished",function(b,d){var c=this.callback;if(c){this.callback=undefined;c(b,d)}}.bind(this));this.encoder.on("progress",function(b){if(this.settings.onProgress){this.settings.onProgress(b)}}.bind(this));this.encoder.on("error",function(b){alert(JSON.stringify(b,null,2))}.bind(this))}O.prototype=Object.create(I.prototype);O.prototype.start=function(){this.encoder.start(this.settings)};O.prototype.add=function(a){this.encoder.add(a)};O.prototype.save=function(a){this.callback=a;this.encoder.end()};O.prototype.safeToProceed=function(){return this.encoder.safeToProceed()};function S(a){I.call(this,a);this.framerate=this.settings.framerate;this.type="video/webm";this.extension=".webm";this.stream=null;this.mediaRecorder=null;this.chunks=[]}S.prototype=Object.create(I.prototype);S.prototype.add=function(a){if(!this.stream){this.stream=a.captureStream(this.framerate);
  this.mediaRecorder=new MediaRecorder(this.stream);this.mediaRecorder.start();this.mediaRecorder.ondataavailable=function(b){this.chunks.push(b.data)}.bind(this)}this.step()};S.prototype.save=function(a){this.mediaRecorder.onstop=function(b){var c=new Blob(this.chunks,{type:"video/webm"});this.chunks=[];a(c)}.bind(this);this.mediaRecorder.stop()};function z(a){I.call(this,a);a.quality=31-((a.quality*30/100)||10);a.workers=a.workers||4;this.extension=".gif";this.mimeType="image/gif";this.canvas=document.createElement("canvas");this.ctx=this.canvas.getContext("2d");this.sizeSet=false;this.encoder=new GIF({workers:a.workers,quality:a.quality,workerScript:a.workersPath+"gif.worker.js"});this.encoder.on("progress",function(b){if(this.settings.onProgress){this.settings.onProgress(b)}}.bind(this));this.encoder.on("finished",function(b){var c=this.callback;if(c){this.callback=undefined;c(b)}}.bind(this))}z.prototype=Object.create(I.prototype);z.prototype.add=function(a){if(!this.sizeSet){this.encoder.setOption("width",a.width);this.encoder.setOption("height",a.height);this.sizeSet=true}this.canvas.width=a.width;this.canvas.height=a.height;this.ctx.drawImage(a,0,0);this.encoder.addFrame(this.ctx,{copy:true,delay:this.settings.step});this.step()};z.prototype.save=function(a){this.callback=a;this.encoder.render()};function U(l){var o=l||{},m=new Date(),f,e,aq,at,h,ay,aD,aG,n=[],aO=[],av=0,q=0,aw=null,aC=[],au=false,a={};o.framerate=o.framerate||60;o.motionBlurFrames=2*(o.motionBlurFrames||1);f=o.verbose||false;e=o.display||false;o.step=1000/o.framerate;o.timeLimit=o.timeLimit||0;o.frameLimit=o.frameLimit||0;o.startTime=o.startTime||0;var j=document.createElement("div");j.style.position="absolute";j.style.left=j.style.top=0;j.style.backgroundColor="black";j.style.fontFamily="monospace";j.style.fontSize="11px";j.style.padding="5px";j.style.color="red";j.style.zIndex=100000;if(o.display){document.body.appendChild(j)}var s=document.createElement("canvas");var ar=s.getContext("2d");var w;var ao;aI("Step is set to "+o.step+"ms");var an={gif:z,webm:N,ffmpegserver:O,png:H,jpg:A,"webm-mediarecorder":S};var aA=an[o.format];if(!aA){throw"Error: Incorrect or missing format: Valid formats are "+Object.keys(an).join(", ")}aG=new aA(o);aG.step=aD;aG.on("process",t);aG.on("progress",c);if("performance" in window==false){window.performance={}}Date.now=(Date.now||function(){return new Date().getTime()});if("now" in window.performance==false){var aK=Date.now();if(performance.timing&&performance.timing.navigationStart){aK=performance.timing.navigationStart}window.performance.now=function ax(){return Date.now()-aK}}var aM=window.setTimeout,x=window.setInterval,ap=window.clearTimeout,i=window.requestAnimationFrame,b=window.Date.now,aE=window.performance.now,aF=window.Date.prototype.getTime;var aB=[];function u(){aI("Capturer start");at=window.Date.now();aq=at+o.startTime;ay=window.performance.now();h=ay+o.startTime;window.Date.prototype.getTime=function(){return aq};window.Date.now=function(){return aq};window.setTimeout=function(Y,Z){var aa={callback:Y,time:Z,triggerTime:aq+Z};n.push(aa);aI("Timeout set to "+aa.time);return aa};window.clearTimeout=function(Y){for(var Z=0;Z<n.length;Z++){if(n[Z]==Y){n.splice(Z,1);aI("Timeout cleared");continue}}};window.setInterval=function(Y,Z){var aa={callback:Y,time:Z,triggerTime:aq+Z};aO.push(aa);aI("Interval set to "+aa.time);return aa};window.clearInterval=function(Y){aI("clear Interval");return null};window.requestAnimationFrame=function(Y){aC.push(Y)};window.performance.now=function(){return h};function W(){if(!this._hooked){this._hooked=true;this._hookedTime=this.currentTime||0;this.pause();aB.push(this)}return this._hookedTime+o.startTime}try{Object.defineProperty(HTMLVideoElement.prototype,"currentTime",{get:W});Object.defineProperty(HTMLAudioElement.prototype,"currentTime",{get:W})}catch(X){aI(X)}}function aJ(){u();aG.start();au=true}function r(){au=false;aG.stop();az()}function aP(W,X){aM(W,0,X)}function aD(){aP(t)}function az(){aI("Capturer stop");window.setTimeout=aM;window.setInterval=x;window.clearTimeout=ap;window.requestAnimationFrame=i;window.Date.prototype.getTime=aF;window.Date.now=b;window.performance.now=aE}function d(){var X=av/o.framerate;if((o.frameLimit&&av>=o.frameLimit)||(o.timeLimit&&X>=o.timeLimit)){r();k()}var W=new Date(null);W.setSeconds(X);if(o.motionBlurFrames>2){j.textContent="CCapture "+o.format+" | "+av+" frames ("+q+" inter) | "+W.toISOString().substr(11,8)}else{j.textContent="CCapture "+o.format+" | "+av+" frames | "+W.toISOString().substr(11,8)}if(o.onProcess){o.onProcess(av)}}function aL(W){if(s.width!==W.width||s.height!==W.height){s.width=W.width;s.height=W.height;w=new Uint16Array(s.height*s.width*4);ar.fillStyle="#0";ar.fillRect(0,0,s.width,s.height)}}function g(X){ar.drawImage(X,0,0);ao=ar.getImageData(0,0,s.width,s.height);for(var W=0;W<w.length;W+=4){w[W]+=ao.data[W];w[W+1]+=ao.data[W+1];w[W+2]+=ao.data[W+2]}q++}function aN(){var X=ao.data;for(var W=0;W<w.length;
  W+=4){X[W]=w[W]*2/o.motionBlurFrames;X[W+1]=w[W+1]*2/o.motionBlurFrames;X[W+2]=w[W+2]*2/o.motionBlurFrames}ar.putImageData(ao,0,0);aG.add(s);av++;q=0;aI("Full MB Frame! "+av+" "+aq);for(var W=0;W<w.length;W+=4){w[W]=0;w[W+1]=0;w[W+2]=0}gc()}function p(Y){if(o.format==="webm"){var X=document.createElement("canvas");var W=X.getContext("2d");X.width=Y.width;X.height=Y.height;W.fillStyle=o.bakckgroundColor;W.fillRect(0,0,Y.width,Y.height);W.drawImage(Y,0,0)}if(au){if(o.motionBlurFrames>2){aL(X);g(X);if(q>=0.5*o.motionBlurFrames){aN()}else{aD()}}else{aG.add(X);av++;aI("Full Frame! "+av)}}}function t(){var X=1000/o.framerate;var Y=(av+q/o.motionBlurFrames)*X;aq=at+Y;h=ay+Y;aB.forEach(function(Z){Z._hookedTime=Y/1000});d();aI("Frame: "+av+" "+q);for(var W=0;W<n.length;W++){if(aq>=n[W].triggerTime){aP(n[W].callback);n.splice(W,1);continue}}for(var W=0;W<aO.length;W++){if(aq>=aO[W].triggerTime){aP(aO[W].callback);aO[W].triggerTime+=aO[W].time;continue}}aC.forEach(function(Z){aP(Z,aq-T)});aC=[]}function k(W){if(!W){W=function(X){download(X,aG.filename+aG.extension,aG.mimeType);return false}}aG.save(W)}function aI(W){if(f){console.log(W)}}function aH(X,W){a[X]=W}function v(X){var W=a[X];if(W){W.apply(null,Array.prototype.slice.call(arguments,1))}}function c(W){v("progress",W)}return{start:aJ,capture:p,stop:r,save:k,on:aH}}(R||V||{}).CCapture=U;if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define(function(){return U})}else{if(M&&y){if(J){(y.exports=U).CCapture=U}M.CCapture=U}else{D.CCapture=U}}}());