@loaders.gl/video 4.3.3 → 4.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.min.js CHANGED
@@ -4,6 +4,6 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var Re=Object.create;var de=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Be=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Me(e))!Le.call(t,i)&&i!==n&&de(t,i,{get:()=>e[i],enumerable:!(o=Ue(e,i))||o.enumerable});return t},fe=(t,e,n)=>(ce(t,e,"default"),n&&ce(n,e,"default")),Ge=(t,e,n)=>(n=t!=null?Re(Ve(t)):{},ce(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),Pe=t=>ce(de({},"__esModule",{value:!0}),t);var ye=He((rt,we)=>{we.exports=globalThis.loaders});var se={};Be(se,{GIFBuilder:()=>K,VideoLoader:()=>Ce});fe(se,Ge(ye(),1));async function he(t){let e=new Blob([t]),n=document.createElement("video");return n.src=URL.createObjectURL(e),n}var _e="4.3.2",Ce={dataType:null,batchType:null,name:"Video",id:"video",module:"video",version:_e,extensions:["mp4"],mimeTypes:["video/mp4"],options:{video:{}},parse:he};function Se(t,e){if(!t)throw new Error(e)}var D=globalThis.document||{},r={URL:globalThis.URL||globalThis.webkitURL||globalThis.mozURL||globalThis.msURL,getUserMedia:function(){if(!globalThis.navigator)return globalThis.navigator;let t=globalThis.navigator.getUserMedia||globalThis.navigator.webkitGetUserMedia||globalThis.navigator.mozGetUserMedia||globalThis.navigator.msGetUserMedia;return t&&t.bind(globalThis.navigator)}(),requestAnimFrame:globalThis.requestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.mozRequestAnimationFrame||globalThis.oRequestAnimationFrame||globalThis.msRequestAnimationFrame,requestTimeout:function(e,n){if(e=e||r.noop,n=n||0,!r.requestAnimFrame)return setTimeout(e,n);let o=new Date().getTime(),i=new Object,s=r.requestAnimFrame,a=function l(){new Date().getTime()-o>=n?e.call():i.value=s(l)};return i.value=s(a),i},Blob:globalThis.Blob||globalThis.BlobBuilder||globalThis.WebKitBlobBuilder||globalThis.MozBlobBuilder||globalThis.MSBlobBuilder,btoa:function(){let t=globalThis.btoa||function(e){let n="",o=0,i=e.length,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a,l,c,u,x,k,m;for(;o<i;)a=e.charCodeAt(o++),l=e.charCodeAt(o++),c=e.charCodeAt(o++),u=a>>2,x=(a&3)<<4|l>>4,k=(l&15)<<2|c>>6,m=c&63,isNaN(l)?k=m=64:isNaN(c)&&(m=64),n=n+s.charAt(u)+s.charAt(x)+s.charAt(k)+s.charAt(m);return n};return t?t.bind(globalThis):r.noop}(),isObject:function(e){return e&&Object.prototype.toString.call(e)==="[object Object]"},isEmptyObject:function(e){return r.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&typeof e=="function"},isElement:function(e){return e&&e.nodeType===1},isString:function(e){return typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"},isSupported:{canvas:function(){let e=D.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return globalThis.Worker},blob:function(){return r.Blob},Uint8Array:function(){return globalThis.Uint8Array},Uint32Array:function(){return globalThis.Uint32Array},videoCodecs:function(){let t=D.createElement("video"),e={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{t&&t.canPlayType&&(e.mp4=t.canPlayType('video/mp4; codecs="mp4v.20.8"')!=="",e.h264=(t.canPlayType('video/mp4; codecs="avc1.42E01E"')||t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'))!=="",e.ogv=t.canPlayType('video/ogg; codecs="theora"')!=="",e.ogg=t.canPlayType('video/ogg; codecs="theora"')!=="",e.webm=t.canPlayType('video/webm; codecs="vp8, vorbis"')!==-1)}catch{}return e}()},noop:function(){},each:function(e,n){let o,i;if(r.isArray(e))for(o=-1,i=e.length;++o<i&&n(o,e[o])!==!1;);else if(r.isObject(e)){for(o in e)if(e.hasOwnProperty(o)&&n(o,e[o])===!1)break}},normalizeOptions:function(e,n){if(!r.isObject(e)||!r.isObject(n)||!Object.keys)return;let o={};return r.each(e,function(i,s){o[i]=e[i]}),r.each(n,function(i,s){let a=n[i];r.isObject(a)&&e[i]?o[i]=r.normalizeOptions(e[i],a):o[i]=a}),o},setCSSAttr:function(e,n,o){r.isElement(e)&&(r.isString(n)&&r.isString(o)?e.style[n]=o:r.isObject(n)&&r.each(n,function(i,s){e.style[i]=s}))},removeElement:function(e){r.isElement(e)&&e.parentNode&&e.parentNode.removeChild(e)},createWebWorker:function(e){if(!r.isString(e))return{};try{let n=new r.Blob([e],{type:"text/javascript"}),o=r.URL.createObjectURL(n),i=new Worker(o);return{objectUrl:o,worker:i}}catch(n){return`${n}`}},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1,e.length)},getFontSize:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!D.body||e.resizeFont===!1)return e.fontSize;let n=e.text,o=e.gifWidth,i=parseInt(e.fontSize,10),s=parseInt(e.minFontSize,10),a=D.createElement("div"),l=D.createElement("span");for(a.setAttribute("width",o),a.appendChild(l),l.innerHTML=n,l.style.fontSize=`${i}px`,l.style.textIndent="-9999px",l.style.visibility="hidden",D.body.appendChild(l);l.offsetWidth>o&&i>=s;)l.style.fontSize=`${--i}px`;return D.body.removeChild(l),`${i}px`},webWorkerError:!1},je=Object.freeze({default:r}),q={validate:function(e){e=r.isObject(e)?e:{};let n={};return r.each(q.validators,function(o,i){let s=i.errorCode;if(!e[s]&&!i.condition)return n=i,n.error=!0,!1}),delete n.condition,n},isValid:function(e){return q.validate(e).error!==!0},validators:[{condition:r.isFunction(r.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:r.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:r.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:r.isFunction(r.URL),errorCode:"globalThis.URL",errorMsg:"The globalThis.URL API is not supported in your browser"},{condition:r.isSupported.blob(),errorCode:"globalThis.Blob",errorMsg:"The globalThis.Blob File API is not supported in your browser"},{condition:r.isSupported.Uint8Array(),errorCode:"globalThis.Uint8Array",errorMsg:"The globalThis.Uint8Array function constructor is not supported in your browser"},{condition:r.isSupported.Uint32Array(),errorCode:"globalThis.Uint32Array",errorMsg:"The globalThis.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}},De=Object.freeze({default:q}),Fe=function(){},be={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:Fe,completeCallback:Fe,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},Ne=Object.freeze({default:be});function $e(){return q.isValid()}function We(){return q.isValid()}function qe(){let t={getUserMedia:!0};return q.isValid(t)}function Xe(t){let e=!1;if(r.isArray(t)&&t.length){if(r.each(t,function(n,o){r.isSupported.videoCodecs[o]&&(e=!0)}),!e)return!1}else if(r.isString(t)&&t.length&&!r.isSupported.videoCodecs[t])return!1;return q.isValid({getUserMedia:!0})}function Ee(){let U,G,j,X,S,P=[],Q=[],Z=[],ee=[];function me(g,p,W){let h,b;for(G=g,j=p,X=W,S=new Array(256),h=0;h<256;h++)S[h]=new Array(4),b=S[h],b[0]=b[1]=b[2]=(h<<4+8)/256|0,Z[h]=65536/256|0,Q[h]=0}function ue(){let g=[],p=new Array(256);for(let h=0;h<256;h++)p[S[h][3]]=h;let W=0;for(let h=0;h<256;h++){let b=p[h];g[W++]=S[b][0],g[W++]=S[b][1],g[W++]=S[b][2]}return g}function te(){let g,p,W,h,b,d,f,F;for(f=0,F=0,g=0;g<256;g++){for(b=S[g],W=g,h=b[1],p=g+1;p<256;p++)d=S[p],d[1]<h&&(W=p,h=d[1]);if(d=S[W],g!=W&&(p=d[0],d[0]=b[0],b[0]=p,p=d[1],d[1]=b[1],b[1]=p,p=d[2],d[2]=b[2],b[2]=p,p=d[3],d[3]=b[3],b[3]=p),h!=f){for(P[f]=F+g>>1,p=f+1;p<h;p++)P[p]=g;f=h,F=g}}for(P[f]=F+255>>1,p=f+1;p<256;p++)P[p]=255}function ie(){let g,p,W,h,b,d,f,F,T,O,$,A,_,xe;for(j<1509&&(X=1),U=30+(X-1)/3,A=G,_=0,xe=j,$=j/(3*X),O=$/100|0,F=1024,d=2048,f=d>>6,f<=1&&(f=0),g=0;g<f;g++)ee[g]=F*((f*f-g*g)*256/(f*f));for(j<1509?T=3:j%499!==0?T=3*499:j%491!==0?T=3*491:j%487!==0?T=3*487:T=3*503,g=0;g<$;)if(W=(A[_+0]&255)<<4,h=(A[_+1]&255)<<4,b=(A[_+2]&255)<<4,p=le(W,h,b),ae(F,p,W,h,b),f!==0&&re(f,p,W,h,b),_+=T,_>=xe&&(_-=j),g++,O===0&&(O=1),g%O===0)for(F-=F/U,d-=d/30,f=d>>6,f<=1&&(f=0),p=0;p<f;p++)ee[p]=F*((f*f-p*p)*256/(f*f))}function ne(g,p,W){let h,b,d,f,F,T,O;for(F=1e3,O=-1,h=P[p],b=h-1;h<256||b>=0;)h<256&&(T=S[h],d=T[1]-p,d>=F?h=256:(h++,d<0&&(d=-d),f=T[0]-g,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3])))),b>=0&&(T=S[b],d=p-T[1],d>=F?b=-1:(b--,d<0&&(d=-d),f=T[0]-g,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3]))));return O}function oe(){return ie(),ge(),te(),ue()}function ge(){let g,p;for(g=0;g<256;g++)S[g][0]>>=4,S[g][1]>>=4,S[g][2]>>=4,S[g][3]=g}function re(g,p,W,h,b){let d,f,F,T,O,$,A;for(F=p-g,F<-1&&(F=-1),T=p+g,T>256&&(T=256),d=p+1,f=p-1,$=1;d<T||f>F;){if(O=ee[$++],d<T){A=S[d++];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}if(f>F){A=S[f--];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}}}function ae(g,p,W,h,b){let d=S[p],f=g/1024;d[0]-=f*(d[0]-W)|0,d[1]-=f*(d[1]-h)|0,d[2]-=f*(d[2]-b)|0}function le(g,p,W){let h,b,d,f,F,T,O,$,A,_;for($=~(1<<31),A=$,T=-1,O=T,h=0;h<256;h++)_=S[h],b=_[0]-g,b<0&&(b=-b),d=_[1]-p,d<0&&(d=-d),b+=d,d=_[2]-W,d<0&&(d=-d),b+=d,b<$&&($=b,T=h),f=b-(Q[h]>>16-4),f<A&&(A=f,O=h),F=Z[h]>>10,Z[h]-=F,Q[h]+=F<<10;return Z[T]+=64,Q[T]-=65536,O}me.apply(this,arguments);let J={};return J.map=ne,J.process=oe,J}function ke(){let t=this;try{globalThis.onmessage=function(n){let o=n.data||{},i;o.gifshot&&(i=e.run(o),postMessage(i))}}catch{}var e={dataToRGB:function(o,i,s){let a=i*s*4,l=0,c=[];for(;l<a;)c.push(o[l++]),c.push(o[l++]),c.push(o[l++]),l++;return c},componentizedPaletteToArray:function(o){o=o||[];let i=[];for(let s=0;s<o.length;s+=3){let a=o[s],l=o[s+1],c=o[s+2];i.push(a<<16|l<<8|c)}return i},processFrameWithQuantizer:function(o,i,s,a){let l=this.dataToRGB(o,i,s),c=new Ee(l,l.length,a),u=c.process(),x=new Uint32Array(this.componentizedPaletteToArray(u)),k=i*s,m=new Uint8Array(k),v=0;for(let w=0;w<k;w++){let E=l[v++],y=l[v++],C=l[v++];m[w]=c.map(E,y,C)}return{pixels:m,palette:x}},run:function(o){o=o||{};let i=o,s=i.height,a=i.palette,l=i.sampleInterval,c=i.width,u=o.data;return this.processFrameWithQuantizer(u,c,s,l)}};return e}function Ye(t,e,n,o){let i=0;o=o===void 0?{}:o;let s=o.loop===void 0?null:o.loop,a=o.palette===void 0?null:o.palette;if(e<=0||n<=0||e>65535||n>65535)throw"Width/Height invalid.";function l(m){let v=m.length;if(v<2||v>256||v&v-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return v}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;let c=0,u=0;if(t[i++]=e&255,t[i++]=e>>8&255,t[i++]=n&255,t[i++]=n>>8&255,t[i++]=(a!==null?128:0)|c,t[i++]=u,t[i++]=0,s!==null){if(s<0||s>65535)throw"Loop count invalid.";t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=s&255,t[i++]=s>>8&255,t[i++]=0}let x=!1;this.addFrame=function(m,v,w,E,y,C){if(x===!0&&(--i,x=!1),C=C===void 0?{}:C,m<0||v<0||m>65535||v>65535)throw"x/y invalid.";if(w<=0||E<=0||w>65535||E>65535)throw"Width/Height invalid.";if(y.length<w*E)throw"Not enough pixels for the frame size.";let z=!0,I=C.palette;if(I==null&&(z=!1,I=a),I==null)throw"Must supply either a local or global palette.";let M=l(I),V=0;for(;M>>=1;)++V;M=1<<V;let R=C.delay===void 0?0:C.delay,U=C.disposal===void 0?0:C.disposal;if(U<0||U>3)throw"Disposal out of range.";let Y=!1,L=0;if(C.transparent!==void 0&&C.transparent!==null&&(Y=!0,L=C.transparent,L<0||L>=M))throw"Transparent color index.";if((U!==0||Y||R!==0)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=U<<2|(Y===!0?1:0),t[i++]=R&255,t[i++]=R>>8&255,t[i++]=L,t[i++]=0),t[i++]=44,t[i++]=m&255,t[i++]=m>>8&255,t[i++]=v&255,t[i++]=v>>8&255,t[i++]=w&255,t[i++]=w>>8&255,t[i++]=E&255,t[i++]=E>>8&255,t[i++]=z===!0?128|V-1:0,z===!0)for(let H=0,N=I.length;H<N;++H){let G=I[H];t[i++]=G>>16&255,t[i++]=G>>8&255,t[i++]=G&255}i=k(t,i,V<2?2:V,y)},this.end=function(){return x===!1&&(t[i++]=59,x=!0),i};function k(m,v,w,E){m[v++]=w;let y=v++,C=1<<w,z=C-1,I=C+1,M=I+1,V=w+1,R=0,U=0;function Y(G){for(;R>=G;)m[v++]=U&255,U>>=8,R-=8,v===y+256&&(m[y]=255,y=v++)}function L(G){U|=G<<R,R+=V,Y(8)}let H=E[0]&z,N={};L(C);for(let G=1,j=E.length;G<j;++G){let X=E[G]&z,S=H<<8|X,P=N[S];if(P===void 0){for(U|=H<<R,R+=V;R>=8;)m[v++]=U&255,U>>=8,R-=8,v===y+256&&(m[y]=255,y=v++);M===4096?(L(C),M=I+1,V=w+1,N={}):(M>=1<<V&&++V,N[S]=M++),H=X}else H=P}return L(H),L(I),Y(1),y+1===v?m[y]=0:(m[y]=v-y-1,m[v++]=0),v}}var Te=function(){},ve=function(e){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=Te,this.onRenderProgressCallback=Te,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=e,this.initializeWebWorkers(e)};ve.prototype={workerMethods:ke(),initializeWebWorkers:function(e){let n=this,o=`${Ee.toString()}(${ke.toString()}());`,i,s,a,l,c=-1,u="";for(l=e.numWorkers;++c<l;)i=r.createWebWorker(o),r.isObject(i)?(s=i.objectUrl,a=i.worker,n.workers.push({worker:a,objectUrl:s}),n.availableWorkers.push(a)):(u=i,r.webWorkerError=Boolean(i));this.workerError=u,this.canvas=D.createElement("canvas"),this.canvas.width=e.gifWidth,this.canvas.height=e.gifHeight,this.ctx=this.canvas.getContext("2d"),this.frames=[]},getWorker:function(){return this.availableWorkers.pop()},freeWorker:function(e){this.availableWorkers.push(e)},byteMap:function(){let t=[];for(let e=0;e<256;e++)t[e]=String.fromCharCode(e);return t}(),bufferToString:function(e){let n=e.length,o="",i=-1;for(;++i<n;)o+=this.byteMap[e[i]];return o},onFrameFinished:function(e){let n=this,o=n.frames,i=n.options,s=Boolean((i.images||[]).length),a=o.every(function(l){return!l.beingProcessed&&l.done});n.numRenderedFrames++,s&&e(n.numRenderedFrames/o.length),n.onRenderProgressCallback(n.numRenderedFrames*.75/o.length),a?n.generatingGIF||n.generateGIF(o,n.onRenderCompleteCallback):r.requestTimeout(function(){n.processNextFrame()},1)},processFrame:function(e){let n=this,o=this.options,i=this.options,s=i.progressCallback,a=i.sampleInterval,l=this.frames,c,u,x=function(){let v=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).data;delete c.data,c.pixels=Array.prototype.slice.call(v.pixels),c.palette=Array.prototype.slice.call(v.palette),c.done=!0,c.beingProcessed=!1,n.freeWorker(u),n.onFrameFinished(s)};if(c=l[e],c.beingProcessed||c.done){this.onFrameFinished();return}c.sampleInterval=a,c.beingProcessed=!0,c.gifshot=!0,u=this.getWorker(),u?(u.onmessage=x,u.postMessage(c)):x({data:n.workerMethods.run(c)})},startRendering:function(e){this.onRenderCompleteCallback=e;for(let n=0;n<this.options.numWorkers&&n<this.frames.length;n++)this.processFrame(n)},processNextFrame:function(){let e=-1;for(let n=0;n<this.frames.length;n++){let o=this.frames[n];if(!o.done&&!o.beingProcessed){e=n;break}}e>=0&&this.processFrame(e)},generateGIF:function(e,n){let o=[],i={loop:this.repeat},s=this.options,a=s.interval,l=s.frameDuration,c=s.images,u=Boolean(c.length),x=s.gifHeight,k=s.gifWidth,m=new Ye(o,k,x,i),v=this.onRenderProgressCallback,w=u?a*100:0,E,y;this.generatingGIF=!0,r.each(e,function(C,z){let I=z.palette;v(.75+.25*z.position*1/e.length);for(let M=0;M<l;M++)m.addFrame(0,0,k,x,z.pixels,{palette:I,delay:w})}),m.end(),v(1),this.frames=[],this.generatingGIF=!1,r.isFunction(n)&&(E=this.bufferToString(o),y=`data:image/gif;base64,${r.btoa(E)}`,n(y))},setRepeat:function(e){this.repeat=e},addFrame:function(e,n){n=r.isObject(n)?n:{};let o=this,i=o.ctx,s=o.options,a=s.gifWidth,l=s.gifHeight,c=r.getFontSize(n),u=n,x=u.filter,k=u.fontColor,m=u.fontFamily,v=u.fontWeight,w=u.gifHeight,E=u.gifWidth,y=u.text,C=u.textAlign,z=u.textBaseline,I=n.textXCoordinate?n.textXCoordinate:C==="left"?1:C==="right"?a:a/2,M=n.textYCoordinate?n.textYCoordinate:z==="top"?1:z==="center"?l/2:l,V=`${v} ${c} ${m}`,R;try{i.filter=x,i.drawImage(e,0,0,a,l),y&&(i.font=V,i.fillStyle=k,i.textAlign=C,i.textBaseline=z,i.fillText(y,I,M)),R=i.getImageData(0,0,a,l),o.addFrameImageData(R)}catch(U){return`${U}`}},addFrameImageData:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=this.frames,o=e.data;this.frames.push({data:o,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:n.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(e){let n=this,o=function(s){n.destroyWorkers(),r.requestTimeout(function(){e(s)},0)};n.startRendering(o)},destroyWorkers:function(){if(this.workerError)return;let e=this.workers;r.each(e,function(n,o){let i=o.worker,s=o.objectUrl;i.terminate(),r.URL.revokeObjectURL(s)})}};function Qe(t,e){t.getBase64GIF(function(n){e({error:!1,errorCode:"",errorMsg:"",image:n})})}function Ke(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=this,n=t.callback,o=t.images,i=t.options,s=t.imagesLength,a={getUserMedia:!0,"globalThis.URL":!0},l=q.validate(a),c=[],u=0,x,k;if(l.error)return n(l);k=new ve(i),r.each(o,function(v,w){let E=w;r.isElement(E)?(i.crossOrigin&&(E.crossOrigin=i.crossOrigin),c[v]=E,u+=1,u===s&&m()):r.isString(E)&&(x=new Image,i.crossOrigin&&(x.crossOrigin=i.crossOrigin),function(y){w.text&&(y.text=w.text),y.onerror=function(C){let z;if(--s,s===0)return z={},z.error="None of the requested images was capable of being retrieved",n(z)},y.onload=function(C){w.text?c[v]={img:y,text:y.text}:c[v]=y,u+=1,u===s&&m(),r.removeElement(y)},y.src=E}(x),r.setCSSAttr(x,{position:"fixed",opacity:"0"}),D.body.appendChild(x))});function m(){r.each(c,function(v,w){w&&(w.text?k.addFrame(w.img,i,w.text):k.addFrame(w,i))}),Qe(k,n)}}var Ze=function(){},pe={getGIF:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1];n=r.isFunction(n)?n:Ze;let o=D.createElement("canvas"),i,s=e.images,a=Boolean(s.length),l=e.cameraStream,c=e.crop,u=e.filter,x=e.fontColor,k=e.fontFamily,m=e.fontWeight,v=e.keepCameraOn,w=e.numWorkers,E=e.progressCallback,y=e.saveRenderingContexts,C=e.savedRenderingContexts,z=e.text,I=e.textAlign,M=e.textBaseline,V=e.videoElement,R=e.videoHeight,U=e.videoWidth,Y=e.webcamVideoElement,L=Number(e.gifWidth),H=Number(e.gifHeight),N=Number(e.interval),G=Number(e.sampleInterval),j=a?0:N*1e3,X=[],S=C.length?C.length:e.numFrames,P=S,Q=new ve(e),Z=r.getFontSize(e),ee=e.textXCoordinate?e.textXCoordinate:I==="left"?1:I==="right"?L:L/2,me=e.textYCoordinate?e.textYCoordinate:M==="top"?1:M==="center"?H/2:H,ue=`${m} ${Z} ${k}`,te=c?Math.floor(c.scaledWidth/2):0,ie=c?U-c.scaledWidth:0,ne=c?Math.floor(c.scaledHeight/2):0,oe=c?R-c.scaledHeight:0,ge=function re(){let ae=P-1;C.length?(i.putImageData(C[S-P],0,0),J()):le();function le(){try{ie>U&&(ie=U),oe>R&&(oe=R),te<0&&(te=0),ne<0&&(ne=0),i.filter=u,i.drawImage(V,te,ne,ie,oe,0,0,L,H),J()}catch(g){if(g.name==="NS_ERROR_NOT_AVAILABLE")r.requestTimeout(le,100);else throw g}}function J(){let g;y&&X.push(i.getImageData(0,0,L,H)),z&&(i.font=ue,i.fillStyle=x,i.textAlign=I,i.textBaseline=M,i.fillText(z,ee,me)),g=i.getImageData(0,0,L,H),Q.addFrameImageData(g),P=ae,E((S-P)/S),ae>0&&r.requestTimeout(re,j),P||Q.getBase64GIF(function(p){n({error:!1,errorCode:"",errorMsg:"",image:p,cameraStream:l,videoElement:V,webcamVideoElement:Y,savedRenderingContexts:X,keepCameraOn:v})})}};S=S!==void 0?S:10,N=N!==void 0?N:.1,o.width=L,o.height=H,i=o.getContext("2d"),function re(){if(!C.length&&V.currentTime===0){r.requestTimeout(re,100);return}ge()}()},getCropDimensions:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.videoWidth,o=e.videoHeight,i=e.gifWidth,s=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return n>o?(a.width=Math.round(n*(s/o))-i,a.scaledWidth=Math.round(a.width*(o/s))):(a.height=Math.round(o*(i/n))-s,a.scaledHeight=Math.round(a.height*(n/i))),a}},B={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function t(e){t.attempts=t.attempts||0;let n=e.cameraStream,o=e.completedCallback,i=e.videoElement;i&&(i.videoWidth>0&&i.videoHeight>0?(i.removeEventListener("loadeddata",B.findVideoSize),o({videoElement:i,cameraStream:n,videoWidth:i.videoWidth,videoHeight:i.videoHeight})):t.attempts<10?(t.attempts+=1,r.requestTimeout(function(){B.findVideoSize(e)},400)):o({videoElement:i,cameraStream:n,videoWidth:B.defaultVideoDimensions.width,videoHeight:B.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){r.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){let n=r.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,o=e.cameraStream,i=e.completedCallback,s=e.streamedCallback,a=e.videoElement;if(r.isFunction(s)&&s(),n){if(r.isString(n))a.src=n,a.innerHTML=`<source src="${n}" type="video/${r.getExtension(n)}" />`;else if(n instanceof Blob){try{a.src=r.URL.createObjectURL(n)}catch{}a.innerHTML=`<source src="${n}" type="${n.type}" />`}}else if(a.mozSrcObject)a.mozSrcObject=o;else if(r.URL)try{a.srcObject=o,a.src=r.URL.createObjectURL(o)}catch{a.srcObject=o}a.play(),r.requestTimeout(function l(){l.count=l.count||0,B.loadedData===!0?(B.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}),B.loadedData=!1):(l.count+=1,l.count>10?B.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}):l())},0)},startStreaming:function(e){let n=r.isFunction(e.error)?e.error:r.noop,o=r.isFunction(e.streamed)?e.streamed:r.noop,i=r.isFunction(e.completed)?e.completed:r.noop,s=e.crossOrigin,a=e.existingVideo,l=e.lastCameraStream,c=e.options,u=e.webcamVideoElement,x=r.isElement(a)?a:u||D.createElement("video"),k=void 0;s&&(x.crossOrigin=c.crossOrigin),x.autoplay=!0,x.loop=!0,x.muted=!0,x.addEventListener("loadeddata",function(m){B.loadedData=!0,c.offset&&(x.currentTime=c.offset)}),a?B.stream({videoElement:x,existingVideo:a,completedCallback:i}):l?B.stream({videoElement:x,cameraStream:l,streamedCallback:o,completedCallback:i}):r.getUserMedia({video:!0},function(m){B.stream({videoElement:x,cameraStream:m,streamedCallback:o,completedCallback:i})},n)},startVideoStreaming:function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.timeout!==void 0?n.timeout:0,i=n.callback,s=n.webcamVideoElement,a;o>0&&(a=r.requestTimeout(function(){B.onStreamingTimeout(i)},1e4)),B.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=c.cameraStream,x=c.videoElement,k=c.videoHeight,m=c.videoWidth;e({cameraStream:u,videoElement:x,videoHeight:k,videoWidth:m})},lastCameraStream:n.lastCameraStream,webcamVideoElement:s,crossOrigin:n.crossOrigin,options:n})},stopVideoStreaming:function(e){e=r.isObject(e)?e:{};let n=e,o=n.keepCameraOn,i=n.videoElement,s=n.webcamVideoElement,a=e.cameraStream||{},l=a.getTracks?a.getTracks()||[]:[],c=Boolean(l.length),u=l[0];!o&&c&&r.isFunction(u.stop)&&u.stop(),r.isElement(i)&&!s&&(i.pause(),r.isFunction(r.URL.revokeObjectURL)&&!r.webWorkerError&&i.src&&r.URL.revokeObjectURL(i.src),r.removeElement(i))}};function Ae(t){t=r.isObject(t)?t:{},B.stopVideoStreaming(t)}function ze(t,e){let n=t.options||{},o=n.images,i=n.video,s=Number(n.gifWidth),a=Number(n.gifHeight),l=Number(n.numFrames),c=t.cameraStream,u=t.videoElement,x=t.videoWidth,k=t.videoHeight,m=pe.getCropDimensions({videoWidth:x,videoHeight:k,gifHeight:a,gifWidth:s}),v=e;n.crop=m,n.videoElement=u,n.videoWidth=x,n.videoHeight=k,n.cameraStream=c,r.isElement(u)&&(u.width=s+m.width,u.height=a+m.height,n.webcamVideoElement||(r.setCSSAttr(u,{position:"fixed",opacity:"0"}),D.body.appendChild(u)),u.play(),pe.getGIF(n,function(w){(!o||!o.length)&&(!i||!i.length)&&Ae(w),v(w)}))}function Je(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.existingVideo,o=t.options,i={getUserMedia:!0,"globalThis.URL":!0},s=q.validate(i),a=0,l,c,u=void 0,x=void 0;if(s.error)return e(s);if(r.isElement(n)&&n.src){if(c=n.src,l=r.getExtension(c),!r.isSupported.videoCodecs[l])return e(q.messages.videoCodecs)}else r.isArray(n)&&r.each(n,function(k,m){if(m instanceof Blob?l=m.type.substr(m.type.lastIndexOf("/")+1,m.length):l=m.substr(m.lastIndexOf(".")+1,m.length),r.isSupported.videoCodecs[l])return n=m,!1});B.startStreaming({completed:function(m){m.options=o||{},ze(m,e)},existingVideo:n,crossOrigin:o.crossOrigin,options:o})}function et(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.lastCameraStream,o=t.options,i=t.webcamVideoElement;if(!We())return e(q.validate());if(o.savedRenderingContexts.length){pe.getGIF(o,function(s){e(s)});return}B.startVideoStreaming(function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};s.options=o||{},ze(s,e)},{lastCameraStream:n,callback:e,webcamVideoElement:i,crossOrigin:o.crossOrigin})}function Ie(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t)||{},o=t.cameraStream,i=n.images,s=i?i.length:0,a=n.video,l=n.webcamVideoElement;n=r.normalizeOptions(n,{gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)}),s?Ke({images:i,imagesLength:s,callback:e,options:n}):a?Je({existingVideo:a,callback:e,options:n}):et({lastCameraStream:o,callback:e,webcamVideoElement:l,options:n})}function tt(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t),o=r.normalizeOptions(n,{interval:.1,numFrames:1,gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)});Ie(o,e)}var it={utils:je,error:De,defaultOptions:Ne,createGIF:Ie,takeSnapShot:tt,stopVideoStreaming:Ae,isSupported:$e,isWebCamGIFSupported:We,isExistingVideoGIFSupported:Xe,isExistingImagesGIFSupported:qe,VERSION:"0.4.5"},Oe=it;var nt={source:"images",width:200,height:200,crossOrigin:"Anonymous",progressCallback:t=>{},completeCallback:()=>{},numWorkers:2,sampleInterval:10,interval:.1,offset:null,numFrames:10,frameDuration:1,filter:"",waterMark:null,waterMarkHeight:null,waterMarkWidth:null,waterMarkXCoordinate:1,waterMarkYCoordinate:1,text:"",showFrameText:!0,fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,webcamVideoElement:null,keepCameraOn:!1,cameraStream:null,saveRenderingContexts:!1,savedRenderingContexts:[]},K=class{static get properties(){return{id:"gif",name:"GIF",extensions:["gif"],mimeTypes:["image/gif"],builder:K,options:nt}}constructor(e){this.options={...e},this.source=e.source,delete e.source,this.files=[],this.gifshot=Oe}async initialize(e){}async add(e){await this.initialize(),this.files.push(e)}async build(){switch(await this.initialize(),this._cleanOptions(this.options),this.source){case"images":this.options.images=this.files;break;case"video":this.options.video=this.files;break;case"webcam":Se(this.files.length===0);break;default:throw new Error("GIFBuilder: invalid source")}return await this._createGIF()}async _createGIF(){return new Promise((e,n)=>{this.gifshot.createGIF(this.options,o=>{if(o.error){n(o.errorMsg);return}e(o.image)})})}_cleanOptions(e){(e.video||e.images||e.gifWidth||e.gifHeight)&&console.warn("GIFBuilder: ignoring options"),delete e.video,delete e.images,e.gifWidth=e.width,e.gifHeight=e.height,delete e.width,delete e.height}};return Pe(se);})();
7
+ "use strict";var __exports__=(()=>{var Re=Object.create;var de=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var He=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Be=(t,e)=>{for(var n in e)de(t,n,{get:e[n],enumerable:!0})},ce=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Me(e))!Le.call(t,i)&&i!==n&&de(t,i,{get:()=>e[i],enumerable:!(o=Ue(e,i))||o.enumerable});return t},fe=(t,e,n)=>(ce(t,e,"default"),n&&ce(n,e,"default")),Ge=(t,e,n)=>(n=t!=null?Re(Ve(t)):{},ce(e||!t||!t.__esModule?de(n,"default",{value:t,enumerable:!0}):n,t)),Pe=t=>ce(de({},"__esModule",{value:!0}),t);var ye=He((rt,we)=>{we.exports=globalThis.loaders});var se={};Be(se,{GIFBuilder:()=>K,VideoLoader:()=>Ce});fe(se,Ge(ye(),1));async function he(t){let e=new Blob([t]),n=document.createElement("video");return n.src=URL.createObjectURL(e),n}var _e="4.3.3",Ce={dataType:null,batchType:null,name:"Video",id:"video",module:"video",version:_e,extensions:["mp4"],mimeTypes:["video/mp4"],options:{video:{}},parse:he};function Se(t,e){if(!t)throw new Error(e)}var D=globalThis.document||{},r={URL:globalThis.URL||globalThis.webkitURL||globalThis.mozURL||globalThis.msURL,getUserMedia:function(){if(!globalThis.navigator)return globalThis.navigator;let t=globalThis.navigator.getUserMedia||globalThis.navigator.webkitGetUserMedia||globalThis.navigator.mozGetUserMedia||globalThis.navigator.msGetUserMedia;return t&&t.bind(globalThis.navigator)}(),requestAnimFrame:globalThis.requestAnimationFrame||globalThis.webkitRequestAnimationFrame||globalThis.mozRequestAnimationFrame||globalThis.oRequestAnimationFrame||globalThis.msRequestAnimationFrame,requestTimeout:function(e,n){if(e=e||r.noop,n=n||0,!r.requestAnimFrame)return setTimeout(e,n);let o=new Date().getTime(),i=new Object,s=r.requestAnimFrame,a=function l(){new Date().getTime()-o>=n?e.call():i.value=s(l)};return i.value=s(a),i},Blob:globalThis.Blob||globalThis.BlobBuilder||globalThis.WebKitBlobBuilder||globalThis.MozBlobBuilder||globalThis.MSBlobBuilder,btoa:function(){let t=globalThis.btoa||function(e){let n="",o=0,i=e.length,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a,l,c,u,x,k,m;for(;o<i;)a=e.charCodeAt(o++),l=e.charCodeAt(o++),c=e.charCodeAt(o++),u=a>>2,x=(a&3)<<4|l>>4,k=(l&15)<<2|c>>6,m=c&63,isNaN(l)?k=m=64:isNaN(c)&&(m=64),n=n+s.charAt(u)+s.charAt(x)+s.charAt(k)+s.charAt(m);return n};return t?t.bind(globalThis):r.noop}(),isObject:function(e){return e&&Object.prototype.toString.call(e)==="[object Object]"},isEmptyObject:function(e){return r.isObject(e)&&!Object.keys(e).length},isArray:function(e){return e&&Array.isArray(e)},isFunction:function(e){return e&&typeof e=="function"},isElement:function(e){return e&&e.nodeType===1},isString:function(e){return typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"},isSupported:{canvas:function(){let e=D.createElement("canvas");return e&&e.getContext&&e.getContext("2d")},webworkers:function(){return globalThis.Worker},blob:function(){return r.Blob},Uint8Array:function(){return globalThis.Uint8Array},Uint32Array:function(){return globalThis.Uint32Array},videoCodecs:function(){let t=D.createElement("video"),e={mp4:!1,h264:!1,ogv:!1,ogg:!1,webm:!1};try{t&&t.canPlayType&&(e.mp4=t.canPlayType('video/mp4; codecs="mp4v.20.8"')!=="",e.h264=(t.canPlayType('video/mp4; codecs="avc1.42E01E"')||t.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"'))!=="",e.ogv=t.canPlayType('video/ogg; codecs="theora"')!=="",e.ogg=t.canPlayType('video/ogg; codecs="theora"')!=="",e.webm=t.canPlayType('video/webm; codecs="vp8, vorbis"')!==-1)}catch{}return e}()},noop:function(){},each:function(e,n){let o,i;if(r.isArray(e))for(o=-1,i=e.length;++o<i&&n(o,e[o])!==!1;);else if(r.isObject(e)){for(o in e)if(e.hasOwnProperty(o)&&n(o,e[o])===!1)break}},normalizeOptions:function(e,n){if(!r.isObject(e)||!r.isObject(n)||!Object.keys)return;let o={};return r.each(e,function(i,s){o[i]=e[i]}),r.each(n,function(i,s){let a=n[i];r.isObject(a)&&e[i]?o[i]=r.normalizeOptions(e[i],a):o[i]=a}),o},setCSSAttr:function(e,n,o){r.isElement(e)&&(r.isString(n)&&r.isString(o)?e.style[n]=o:r.isObject(n)&&r.each(n,function(i,s){e.style[i]=s}))},removeElement:function(e){r.isElement(e)&&e.parentNode&&e.parentNode.removeChild(e)},createWebWorker:function(e){if(!r.isString(e))return{};try{let n=new r.Blob([e],{type:"text/javascript"}),o=r.URL.createObjectURL(n),i=new Worker(o);return{objectUrl:o,worker:i}}catch(n){return`${n}`}},getExtension:function(e){return e.substr(e.lastIndexOf(".")+1,e.length)},getFontSize:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!D.body||e.resizeFont===!1)return e.fontSize;let n=e.text,o=e.gifWidth,i=parseInt(e.fontSize,10),s=parseInt(e.minFontSize,10),a=D.createElement("div"),l=D.createElement("span");for(a.setAttribute("width",o),a.appendChild(l),l.innerHTML=n,l.style.fontSize=`${i}px`,l.style.textIndent="-9999px",l.style.visibility="hidden",D.body.appendChild(l);l.offsetWidth>o&&i>=s;)l.style.fontSize=`${--i}px`;return D.body.removeChild(l),`${i}px`},webWorkerError:!1},je=Object.freeze({default:r}),q={validate:function(e){e=r.isObject(e)?e:{};let n={};return r.each(q.validators,function(o,i){let s=i.errorCode;if(!e[s]&&!i.condition)return n=i,n.error=!0,!1}),delete n.condition,n},isValid:function(e){return q.validate(e).error!==!0},validators:[{condition:r.isFunction(r.getUserMedia),errorCode:"getUserMedia",errorMsg:"The getUserMedia API is not supported in your browser"},{condition:r.isSupported.canvas(),errorCode:"canvas",errorMsg:"Canvas elements are not supported in your browser"},{condition:r.isSupported.webworkers(),errorCode:"webworkers",errorMsg:"The Web Workers API is not supported in your browser"},{condition:r.isFunction(r.URL),errorCode:"globalThis.URL",errorMsg:"The globalThis.URL API is not supported in your browser"},{condition:r.isSupported.blob(),errorCode:"globalThis.Blob",errorMsg:"The globalThis.Blob File API is not supported in your browser"},{condition:r.isSupported.Uint8Array(),errorCode:"globalThis.Uint8Array",errorMsg:"The globalThis.Uint8Array function constructor is not supported in your browser"},{condition:r.isSupported.Uint32Array(),errorCode:"globalThis.Uint32Array",errorMsg:"The globalThis.Uint32Array function constructor is not supported in your browser"}],messages:{videoCodecs:{errorCode:"videocodec",errorMsg:"The video codec you are trying to use is not supported in your browser"}}},De=Object.freeze({default:q}),Fe=function(){},be={sampleInterval:10,numWorkers:2,filter:"",gifWidth:200,gifHeight:200,interval:.1,numFrames:10,frameDuration:1,keepCameraOn:!1,images:[],video:null,webcamVideoElement:null,cameraStream:null,text:"",fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,progressCallback:Fe,completeCallback:Fe,saveRenderingContexts:!1,savedRenderingContexts:[],crossOrigin:"Anonymous"},Ne=Object.freeze({default:be});function $e(){return q.isValid()}function We(){return q.isValid()}function qe(){let t={getUserMedia:!0};return q.isValid(t)}function Xe(t){let e=!1;if(r.isArray(t)&&t.length){if(r.each(t,function(n,o){r.isSupported.videoCodecs[o]&&(e=!0)}),!e)return!1}else if(r.isString(t)&&t.length&&!r.isSupported.videoCodecs[t])return!1;return q.isValid({getUserMedia:!0})}function Ee(){let U,G,j,X,S,P=[],Q=[],Z=[],ee=[];function me(g,p,W){let h,b;for(G=g,j=p,X=W,S=new Array(256),h=0;h<256;h++)S[h]=new Array(4),b=S[h],b[0]=b[1]=b[2]=(h<<4+8)/256|0,Z[h]=65536/256|0,Q[h]=0}function ue(){let g=[],p=new Array(256);for(let h=0;h<256;h++)p[S[h][3]]=h;let W=0;for(let h=0;h<256;h++){let b=p[h];g[W++]=S[b][0],g[W++]=S[b][1],g[W++]=S[b][2]}return g}function te(){let g,p,W,h,b,d,f,F;for(f=0,F=0,g=0;g<256;g++){for(b=S[g],W=g,h=b[1],p=g+1;p<256;p++)d=S[p],d[1]<h&&(W=p,h=d[1]);if(d=S[W],g!=W&&(p=d[0],d[0]=b[0],b[0]=p,p=d[1],d[1]=b[1],b[1]=p,p=d[2],d[2]=b[2],b[2]=p,p=d[3],d[3]=b[3],b[3]=p),h!=f){for(P[f]=F+g>>1,p=f+1;p<h;p++)P[p]=g;f=h,F=g}}for(P[f]=F+255>>1,p=f+1;p<256;p++)P[p]=255}function ie(){let g,p,W,h,b,d,f,F,T,O,$,A,_,xe;for(j<1509&&(X=1),U=30+(X-1)/3,A=G,_=0,xe=j,$=j/(3*X),O=$/100|0,F=1024,d=2048,f=d>>6,f<=1&&(f=0),g=0;g<f;g++)ee[g]=F*((f*f-g*g)*256/(f*f));for(j<1509?T=3:j%499!==0?T=3*499:j%491!==0?T=3*491:j%487!==0?T=3*487:T=3*503,g=0;g<$;)if(W=(A[_+0]&255)<<4,h=(A[_+1]&255)<<4,b=(A[_+2]&255)<<4,p=le(W,h,b),ae(F,p,W,h,b),f!==0&&re(f,p,W,h,b),_+=T,_>=xe&&(_-=j),g++,O===0&&(O=1),g%O===0)for(F-=F/U,d-=d/30,f=d>>6,f<=1&&(f=0),p=0;p<f;p++)ee[p]=F*((f*f-p*p)*256/(f*f))}function ne(g,p,W){let h,b,d,f,F,T,O;for(F=1e3,O=-1,h=P[p],b=h-1;h<256||b>=0;)h<256&&(T=S[h],d=T[1]-p,d>=F?h=256:(h++,d<0&&(d=-d),f=T[0]-g,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3])))),b>=0&&(T=S[b],d=p-T[1],d>=F?b=-1:(b--,d<0&&(d=-d),f=T[0]-g,f<0&&(f=-f),d+=f,d<F&&(f=T[2]-W,f<0&&(f=-f),d+=f,d<F&&(F=d,O=T[3]))));return O}function oe(){return ie(),ge(),te(),ue()}function ge(){let g,p;for(g=0;g<256;g++)S[g][0]>>=4,S[g][1]>>=4,S[g][2]>>=4,S[g][3]=g}function re(g,p,W,h,b){let d,f,F,T,O,$,A;for(F=p-g,F<-1&&(F=-1),T=p+g,T>256&&(T=256),d=p+1,f=p-1,$=1;d<T||f>F;){if(O=ee[$++],d<T){A=S[d++];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}if(f>F){A=S[f--];try{A[0]-=O*(A[0]-W)/262144|0,A[1]-=O*(A[1]-h)/262144|0,A[2]-=O*(A[2]-b)/262144|0}catch{}}}}function ae(g,p,W,h,b){let d=S[p],f=g/1024;d[0]-=f*(d[0]-W)|0,d[1]-=f*(d[1]-h)|0,d[2]-=f*(d[2]-b)|0}function le(g,p,W){let h,b,d,f,F,T,O,$,A,_;for($=~(1<<31),A=$,T=-1,O=T,h=0;h<256;h++)_=S[h],b=_[0]-g,b<0&&(b=-b),d=_[1]-p,d<0&&(d=-d),b+=d,d=_[2]-W,d<0&&(d=-d),b+=d,b<$&&($=b,T=h),f=b-(Q[h]>>16-4),f<A&&(A=f,O=h),F=Z[h]>>10,Z[h]-=F,Q[h]+=F<<10;return Z[T]+=64,Q[T]-=65536,O}me.apply(this,arguments);let J={};return J.map=ne,J.process=oe,J}function ke(){let t=this;try{globalThis.onmessage=function(n){let o=n.data||{},i;o.gifshot&&(i=e.run(o),postMessage(i))}}catch{}var e={dataToRGB:function(o,i,s){let a=i*s*4,l=0,c=[];for(;l<a;)c.push(o[l++]),c.push(o[l++]),c.push(o[l++]),l++;return c},componentizedPaletteToArray:function(o){o=o||[];let i=[];for(let s=0;s<o.length;s+=3){let a=o[s],l=o[s+1],c=o[s+2];i.push(a<<16|l<<8|c)}return i},processFrameWithQuantizer:function(o,i,s,a){let l=this.dataToRGB(o,i,s),c=new Ee(l,l.length,a),u=c.process(),x=new Uint32Array(this.componentizedPaletteToArray(u)),k=i*s,m=new Uint8Array(k),v=0;for(let w=0;w<k;w++){let E=l[v++],y=l[v++],C=l[v++];m[w]=c.map(E,y,C)}return{pixels:m,palette:x}},run:function(o){o=o||{};let i=o,s=i.height,a=i.palette,l=i.sampleInterval,c=i.width,u=o.data;return this.processFrameWithQuantizer(u,c,s,l)}};return e}function Ye(t,e,n,o){let i=0;o=o===void 0?{}:o;let s=o.loop===void 0?null:o.loop,a=o.palette===void 0?null:o.palette;if(e<=0||n<=0||e>65535||n>65535)throw"Width/Height invalid.";function l(m){let v=m.length;if(v<2||v>256||v&v-1)throw"Invalid code/color length, must be power of 2 and 2 .. 256.";return v}t[i++]=71,t[i++]=73,t[i++]=70,t[i++]=56,t[i++]=57,t[i++]=97;let c=0,u=0;if(t[i++]=e&255,t[i++]=e>>8&255,t[i++]=n&255,t[i++]=n>>8&255,t[i++]=(a!==null?128:0)|c,t[i++]=u,t[i++]=0,s!==null){if(s<0||s>65535)throw"Loop count invalid.";t[i++]=33,t[i++]=255,t[i++]=11,t[i++]=78,t[i++]=69,t[i++]=84,t[i++]=83,t[i++]=67,t[i++]=65,t[i++]=80,t[i++]=69,t[i++]=50,t[i++]=46,t[i++]=48,t[i++]=3,t[i++]=1,t[i++]=s&255,t[i++]=s>>8&255,t[i++]=0}let x=!1;this.addFrame=function(m,v,w,E,y,C){if(x===!0&&(--i,x=!1),C=C===void 0?{}:C,m<0||v<0||m>65535||v>65535)throw"x/y invalid.";if(w<=0||E<=0||w>65535||E>65535)throw"Width/Height invalid.";if(y.length<w*E)throw"Not enough pixels for the frame size.";let z=!0,I=C.palette;if(I==null&&(z=!1,I=a),I==null)throw"Must supply either a local or global palette.";let M=l(I),V=0;for(;M>>=1;)++V;M=1<<V;let R=C.delay===void 0?0:C.delay,U=C.disposal===void 0?0:C.disposal;if(U<0||U>3)throw"Disposal out of range.";let Y=!1,L=0;if(C.transparent!==void 0&&C.transparent!==null&&(Y=!0,L=C.transparent,L<0||L>=M))throw"Transparent color index.";if((U!==0||Y||R!==0)&&(t[i++]=33,t[i++]=249,t[i++]=4,t[i++]=U<<2|(Y===!0?1:0),t[i++]=R&255,t[i++]=R>>8&255,t[i++]=L,t[i++]=0),t[i++]=44,t[i++]=m&255,t[i++]=m>>8&255,t[i++]=v&255,t[i++]=v>>8&255,t[i++]=w&255,t[i++]=w>>8&255,t[i++]=E&255,t[i++]=E>>8&255,t[i++]=z===!0?128|V-1:0,z===!0)for(let H=0,N=I.length;H<N;++H){let G=I[H];t[i++]=G>>16&255,t[i++]=G>>8&255,t[i++]=G&255}i=k(t,i,V<2?2:V,y)},this.end=function(){return x===!1&&(t[i++]=59,x=!0),i};function k(m,v,w,E){m[v++]=w;let y=v++,C=1<<w,z=C-1,I=C+1,M=I+1,V=w+1,R=0,U=0;function Y(G){for(;R>=G;)m[v++]=U&255,U>>=8,R-=8,v===y+256&&(m[y]=255,y=v++)}function L(G){U|=G<<R,R+=V,Y(8)}let H=E[0]&z,N={};L(C);for(let G=1,j=E.length;G<j;++G){let X=E[G]&z,S=H<<8|X,P=N[S];if(P===void 0){for(U|=H<<R,R+=V;R>=8;)m[v++]=U&255,U>>=8,R-=8,v===y+256&&(m[y]=255,y=v++);M===4096?(L(C),M=I+1,V=w+1,N={}):(M>=1<<V&&++V,N[S]=M++),H=X}else H=P}return L(H),L(I),Y(1),y+1===v?m[y]=0:(m[y]=v-y-1,m[v++]=0),v}}var Te=function(){},ve=function(e){this.canvas=null,this.ctx=null,this.repeat=0,this.frames=[],this.numRenderedFrames=0,this.onRenderCompleteCallback=Te,this.onRenderProgressCallback=Te,this.workers=[],this.availableWorkers=[],this.generatingGIF=!1,this.options=e,this.initializeWebWorkers(e)};ve.prototype={workerMethods:ke(),initializeWebWorkers:function(e){let n=this,o=`${Ee.toString()}(${ke.toString()}());`,i,s,a,l,c=-1,u="";for(l=e.numWorkers;++c<l;)i=r.createWebWorker(o),r.isObject(i)?(s=i.objectUrl,a=i.worker,n.workers.push({worker:a,objectUrl:s}),n.availableWorkers.push(a)):(u=i,r.webWorkerError=Boolean(i));this.workerError=u,this.canvas=D.createElement("canvas"),this.canvas.width=e.gifWidth,this.canvas.height=e.gifHeight,this.ctx=this.canvas.getContext("2d"),this.frames=[]},getWorker:function(){return this.availableWorkers.pop()},freeWorker:function(e){this.availableWorkers.push(e)},byteMap:function(){let t=[];for(let e=0;e<256;e++)t[e]=String.fromCharCode(e);return t}(),bufferToString:function(e){let n=e.length,o="",i=-1;for(;++i<n;)o+=this.byteMap[e[i]];return o},onFrameFinished:function(e){let n=this,o=n.frames,i=n.options,s=Boolean((i.images||[]).length),a=o.every(function(l){return!l.beingProcessed&&l.done});n.numRenderedFrames++,s&&e(n.numRenderedFrames/o.length),n.onRenderProgressCallback(n.numRenderedFrames*.75/o.length),a?n.generatingGIF||n.generateGIF(o,n.onRenderCompleteCallback):r.requestTimeout(function(){n.processNextFrame()},1)},processFrame:function(e){let n=this,o=this.options,i=this.options,s=i.progressCallback,a=i.sampleInterval,l=this.frames,c,u,x=function(){let v=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).data;delete c.data,c.pixels=Array.prototype.slice.call(v.pixels),c.palette=Array.prototype.slice.call(v.palette),c.done=!0,c.beingProcessed=!1,n.freeWorker(u),n.onFrameFinished(s)};if(c=l[e],c.beingProcessed||c.done){this.onFrameFinished();return}c.sampleInterval=a,c.beingProcessed=!0,c.gifshot=!0,u=this.getWorker(),u?(u.onmessage=x,u.postMessage(c)):x({data:n.workerMethods.run(c)})},startRendering:function(e){this.onRenderCompleteCallback=e;for(let n=0;n<this.options.numWorkers&&n<this.frames.length;n++)this.processFrame(n)},processNextFrame:function(){let e=-1;for(let n=0;n<this.frames.length;n++){let o=this.frames[n];if(!o.done&&!o.beingProcessed){e=n;break}}e>=0&&this.processFrame(e)},generateGIF:function(e,n){let o=[],i={loop:this.repeat},s=this.options,a=s.interval,l=s.frameDuration,c=s.images,u=Boolean(c.length),x=s.gifHeight,k=s.gifWidth,m=new Ye(o,k,x,i),v=this.onRenderProgressCallback,w=u?a*100:0,E,y;this.generatingGIF=!0,r.each(e,function(C,z){let I=z.palette;v(.75+.25*z.position*1/e.length);for(let M=0;M<l;M++)m.addFrame(0,0,k,x,z.pixels,{palette:I,delay:w})}),m.end(),v(1),this.frames=[],this.generatingGIF=!1,r.isFunction(n)&&(E=this.bufferToString(o),y=`data:image/gif;base64,${r.btoa(E)}`,n(y))},setRepeat:function(e){this.repeat=e},addFrame:function(e,n){n=r.isObject(n)?n:{};let o=this,i=o.ctx,s=o.options,a=s.gifWidth,l=s.gifHeight,c=r.getFontSize(n),u=n,x=u.filter,k=u.fontColor,m=u.fontFamily,v=u.fontWeight,w=u.gifHeight,E=u.gifWidth,y=u.text,C=u.textAlign,z=u.textBaseline,I=n.textXCoordinate?n.textXCoordinate:C==="left"?1:C==="right"?a:a/2,M=n.textYCoordinate?n.textYCoordinate:z==="top"?1:z==="center"?l/2:l,V=`${v} ${c} ${m}`,R;try{i.filter=x,i.drawImage(e,0,0,a,l),y&&(i.font=V,i.fillStyle=k,i.textAlign=C,i.textBaseline=z,i.fillText(y,I,M)),R=i.getImageData(0,0,a,l),o.addFrameImageData(R)}catch(U){return`${U}`}},addFrameImageData:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=this.frames,o=e.data;this.frames.push({data:o,width:e.width,height:e.height,palette:null,dithering:null,done:!1,beingProcessed:!1,position:n.length})},onRenderProgress:function(e){this.onRenderProgressCallback=e},isRendering:function(){return this.generatingGIF},getBase64GIF:function(e){let n=this,o=function(s){n.destroyWorkers(),r.requestTimeout(function(){e(s)},0)};n.startRendering(o)},destroyWorkers:function(){if(this.workerError)return;let e=this.workers;r.each(e,function(n,o){let i=o.worker,s=o.objectUrl;i.terminate(),r.URL.revokeObjectURL(s)})}};function Qe(t,e){t.getBase64GIF(function(n){e({error:!1,errorCode:"",errorMsg:"",image:n})})}function Ke(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=this,n=t.callback,o=t.images,i=t.options,s=t.imagesLength,a={getUserMedia:!0,"globalThis.URL":!0},l=q.validate(a),c=[],u=0,x,k;if(l.error)return n(l);k=new ve(i),r.each(o,function(v,w){let E=w;r.isElement(E)?(i.crossOrigin&&(E.crossOrigin=i.crossOrigin),c[v]=E,u+=1,u===s&&m()):r.isString(E)&&(x=new Image,i.crossOrigin&&(x.crossOrigin=i.crossOrigin),function(y){w.text&&(y.text=w.text),y.onerror=function(C){let z;if(--s,s===0)return z={},z.error="None of the requested images was capable of being retrieved",n(z)},y.onload=function(C){w.text?c[v]={img:y,text:y.text}:c[v]=y,u+=1,u===s&&m(),r.removeElement(y)},y.src=E}(x),r.setCSSAttr(x,{position:"fixed",opacity:"0"}),D.body.appendChild(x))});function m(){r.each(c,function(v,w){w&&(w.text?k.addFrame(w.img,i,w.text):k.addFrame(w,i))}),Qe(k,n)}}var Ze=function(){},pe={getGIF:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments[1];n=r.isFunction(n)?n:Ze;let o=D.createElement("canvas"),i,s=e.images,a=Boolean(s.length),l=e.cameraStream,c=e.crop,u=e.filter,x=e.fontColor,k=e.fontFamily,m=e.fontWeight,v=e.keepCameraOn,w=e.numWorkers,E=e.progressCallback,y=e.saveRenderingContexts,C=e.savedRenderingContexts,z=e.text,I=e.textAlign,M=e.textBaseline,V=e.videoElement,R=e.videoHeight,U=e.videoWidth,Y=e.webcamVideoElement,L=Number(e.gifWidth),H=Number(e.gifHeight),N=Number(e.interval),G=Number(e.sampleInterval),j=a?0:N*1e3,X=[],S=C.length?C.length:e.numFrames,P=S,Q=new ve(e),Z=r.getFontSize(e),ee=e.textXCoordinate?e.textXCoordinate:I==="left"?1:I==="right"?L:L/2,me=e.textYCoordinate?e.textYCoordinate:M==="top"?1:M==="center"?H/2:H,ue=`${m} ${Z} ${k}`,te=c?Math.floor(c.scaledWidth/2):0,ie=c?U-c.scaledWidth:0,ne=c?Math.floor(c.scaledHeight/2):0,oe=c?R-c.scaledHeight:0,ge=function re(){let ae=P-1;C.length?(i.putImageData(C[S-P],0,0),J()):le();function le(){try{ie>U&&(ie=U),oe>R&&(oe=R),te<0&&(te=0),ne<0&&(ne=0),i.filter=u,i.drawImage(V,te,ne,ie,oe,0,0,L,H),J()}catch(g){if(g.name==="NS_ERROR_NOT_AVAILABLE")r.requestTimeout(le,100);else throw g}}function J(){let g;y&&X.push(i.getImageData(0,0,L,H)),z&&(i.font=ue,i.fillStyle=x,i.textAlign=I,i.textBaseline=M,i.fillText(z,ee,me)),g=i.getImageData(0,0,L,H),Q.addFrameImageData(g),P=ae,E((S-P)/S),ae>0&&r.requestTimeout(re,j),P||Q.getBase64GIF(function(p){n({error:!1,errorCode:"",errorMsg:"",image:p,cameraStream:l,videoElement:V,webcamVideoElement:Y,savedRenderingContexts:X,keepCameraOn:v})})}};S=S!==void 0?S:10,N=N!==void 0?N:.1,o.width=L,o.height=H,i=o.getContext("2d"),function re(){if(!C.length&&V.currentTime===0){r.requestTimeout(re,100);return}ge()}()},getCropDimensions:function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.videoWidth,o=e.videoHeight,i=e.gifWidth,s=e.gifHeight,a={width:0,height:0,scaledWidth:0,scaledHeight:0};return n>o?(a.width=Math.round(n*(s/o))-i,a.scaledWidth=Math.round(a.width*(o/s))):(a.height=Math.round(o*(i/n))-s,a.scaledHeight=Math.round(a.height*(n/i))),a}},B={loadedData:!1,defaultVideoDimensions:{width:640,height:480},findVideoSize:function t(e){t.attempts=t.attempts||0;let n=e.cameraStream,o=e.completedCallback,i=e.videoElement;i&&(i.videoWidth>0&&i.videoHeight>0?(i.removeEventListener("loadeddata",B.findVideoSize),o({videoElement:i,cameraStream:n,videoWidth:i.videoWidth,videoHeight:i.videoHeight})):t.attempts<10?(t.attempts+=1,r.requestTimeout(function(){B.findVideoSize(e)},400)):o({videoElement:i,cameraStream:n,videoWidth:B.defaultVideoDimensions.width,videoHeight:B.defaultVideoDimensions.height}))},onStreamingTimeout:function(e){r.isFunction(e)&&e({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - Timed out while trying to start streaming",image:null,cameraStream:{}})},stream:function(e){let n=r.isArray(e.existingVideo)?e.existingVideo[0]:e.existingVideo,o=e.cameraStream,i=e.completedCallback,s=e.streamedCallback,a=e.videoElement;if(r.isFunction(s)&&s(),n){if(r.isString(n))a.src=n,a.innerHTML=`<source src="${n}" type="video/${r.getExtension(n)}" />`;else if(n instanceof Blob){try{a.src=r.URL.createObjectURL(n)}catch{}a.innerHTML=`<source src="${n}" type="${n.type}" />`}}else if(a.mozSrcObject)a.mozSrcObject=o;else if(r.URL)try{a.srcObject=o,a.src=r.URL.createObjectURL(o)}catch{a.srcObject=o}a.play(),r.requestTimeout(function l(){l.count=l.count||0,B.loadedData===!0?(B.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}),B.loadedData=!1):(l.count+=1,l.count>10?B.findVideoSize({videoElement:a,cameraStream:o,completedCallback:i}):l())},0)},startStreaming:function(e){let n=r.isFunction(e.error)?e.error:r.noop,o=r.isFunction(e.streamed)?e.streamed:r.noop,i=r.isFunction(e.completed)?e.completed:r.noop,s=e.crossOrigin,a=e.existingVideo,l=e.lastCameraStream,c=e.options,u=e.webcamVideoElement,x=r.isElement(a)?a:u||D.createElement("video"),k=void 0;s&&(x.crossOrigin=c.crossOrigin),x.autoplay=!0,x.loop=!0,x.muted=!0,x.addEventListener("loadeddata",function(m){B.loadedData=!0,c.offset&&(x.currentTime=c.offset)}),a?B.stream({videoElement:x,existingVideo:a,completedCallback:i}):l?B.stream({videoElement:x,cameraStream:l,streamedCallback:o,completedCallback:i}):r.getUserMedia({video:!0},function(m){B.stream({videoElement:x,cameraStream:m,streamedCallback:o,completedCallback:i})},n)},startVideoStreaming:function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=n.timeout!==void 0?n.timeout:0,i=n.callback,s=n.webcamVideoElement,a;o>0&&(a=r.requestTimeout(function(){B.onStreamingTimeout(i)},1e4)),B.startStreaming({error:function(){i({error:!0,errorCode:"getUserMedia",errorMsg:"There was an issue with the getUserMedia API - the user probably denied permission",image:null,cameraStream:{}})},streamed:function(){clearTimeout(a)},completed:function(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},u=c.cameraStream,x=c.videoElement,k=c.videoHeight,m=c.videoWidth;e({cameraStream:u,videoElement:x,videoHeight:k,videoWidth:m})},lastCameraStream:n.lastCameraStream,webcamVideoElement:s,crossOrigin:n.crossOrigin,options:n})},stopVideoStreaming:function(e){e=r.isObject(e)?e:{};let n=e,o=n.keepCameraOn,i=n.videoElement,s=n.webcamVideoElement,a=e.cameraStream||{},l=a.getTracks?a.getTracks()||[]:[],c=Boolean(l.length),u=l[0];!o&&c&&r.isFunction(u.stop)&&u.stop(),r.isElement(i)&&!s&&(i.pause(),r.isFunction(r.URL.revokeObjectURL)&&!r.webWorkerError&&i.src&&r.URL.revokeObjectURL(i.src),r.removeElement(i))}};function Ae(t){t=r.isObject(t)?t:{},B.stopVideoStreaming(t)}function ze(t,e){let n=t.options||{},o=n.images,i=n.video,s=Number(n.gifWidth),a=Number(n.gifHeight),l=Number(n.numFrames),c=t.cameraStream,u=t.videoElement,x=t.videoWidth,k=t.videoHeight,m=pe.getCropDimensions({videoWidth:x,videoHeight:k,gifHeight:a,gifWidth:s}),v=e;n.crop=m,n.videoElement=u,n.videoWidth=x,n.videoHeight=k,n.cameraStream=c,r.isElement(u)&&(u.width=s+m.width,u.height=a+m.height,n.webcamVideoElement||(r.setCSSAttr(u,{position:"fixed",opacity:"0"}),D.body.appendChild(u)),u.play(),pe.getGIF(n,function(w){(!o||!o.length)&&(!i||!i.length)&&Ae(w),v(w)}))}function Je(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.existingVideo,o=t.options,i={getUserMedia:!0,"globalThis.URL":!0},s=q.validate(i),a=0,l,c,u=void 0,x=void 0;if(s.error)return e(s);if(r.isElement(n)&&n.src){if(c=n.src,l=r.getExtension(c),!r.isSupported.videoCodecs[l])return e(q.messages.videoCodecs)}else r.isArray(n)&&r.each(n,function(k,m){if(m instanceof Blob?l=m.type.substr(m.type.lastIndexOf("/")+1,m.length):l=m.substr(m.lastIndexOf(".")+1,m.length),r.isSupported.videoCodecs[l])return n=m,!1});B.startStreaming({completed:function(m){m.options=o||{},ze(m,e)},existingVideo:n,crossOrigin:o.crossOrigin,options:o})}function et(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.callback,n=t.lastCameraStream,o=t.options,i=t.webcamVideoElement;if(!We())return e(q.validate());if(o.savedRenderingContexts.length){pe.getGIF(o,function(s){e(s)});return}B.startVideoStreaming(function(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};s.options=o||{},ze(s,e)},{lastCameraStream:n,callback:e,webcamVideoElement:i,crossOrigin:o.crossOrigin})}function Ie(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t)||{},o=t.cameraStream,i=n.images,s=i?i.length:0,a=n.video,l=n.webcamVideoElement;n=r.normalizeOptions(n,{gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)}),s?Ke({images:i,imagesLength:s,callback:e,options:n}):a?Je({existingVideo:a,callback:e,options:n}):et({lastCameraStream:o,callback:e,webcamVideoElement:l,options:n})}function tt(t,e){if(e=r.isFunction(t)?t:e,t=r.isObject(t)?t:{},!r.isFunction(e))return;let n=r.normalizeOptions(be,t),o=r.normalizeOptions(n,{interval:.1,numFrames:1,gifWidth:Math.floor(n.gifWidth),gifHeight:Math.floor(n.gifHeight)});Ie(o,e)}var it={utils:je,error:De,defaultOptions:Ne,createGIF:Ie,takeSnapShot:tt,stopVideoStreaming:Ae,isSupported:$e,isWebCamGIFSupported:We,isExistingVideoGIFSupported:Xe,isExistingImagesGIFSupported:qe,VERSION:"0.4.5"},Oe=it;var nt={source:"images",width:200,height:200,crossOrigin:"Anonymous",progressCallback:t=>{},completeCallback:()=>{},numWorkers:2,sampleInterval:10,interval:.1,offset:null,numFrames:10,frameDuration:1,filter:"",waterMark:null,waterMarkHeight:null,waterMarkWidth:null,waterMarkXCoordinate:1,waterMarkYCoordinate:1,text:"",showFrameText:!0,fontWeight:"normal",fontSize:"16px",minFontSize:"10px",resizeFont:!1,fontFamily:"sans-serif",fontColor:"#ffffff",textAlign:"center",textBaseline:"bottom",textXCoordinate:null,textYCoordinate:null,webcamVideoElement:null,keepCameraOn:!1,cameraStream:null,saveRenderingContexts:!1,savedRenderingContexts:[]},K=class{static get properties(){return{id:"gif",name:"GIF",extensions:["gif"],mimeTypes:["image/gif"],builder:K,options:nt}}constructor(e){this.options={...e},this.source=e.source,delete e.source,this.files=[],this.gifshot=Oe}async initialize(e){}async add(e){await this.initialize(),this.files.push(e)}async build(){switch(await this.initialize(),this._cleanOptions(this.options),this.source){case"images":this.options.images=this.files;break;case"video":this.options.video=this.files;break;case"webcam":Se(this.files.length===0);break;default:throw new Error("GIFBuilder: invalid source")}return await this._createGIF()}async _createGIF(){return new Promise((e,n)=>{this.gifshot.createGIF(this.options,o=>{if(o.error){n(o.errorMsg);return}e(o.image)})})}_cleanOptions(e){(e.video||e.images||e.gifWidth||e.gifHeight)&&console.warn("GIFBuilder: ignoring options"),delete e.video,delete e.images,e.gifWidth=e.width,e.gifHeight=e.height,delete e.width,delete e.height}};return Pe(se);})();
8
8
  return __exports__;
9
9
  });
package/dist/index.cjs CHANGED
@@ -34,7 +34,7 @@ async function parseVideo(arrayBuffer) {
34
34
  }
35
35
 
36
36
  // dist/video-loader.js
37
- var VERSION = true ? "4.3.2" : "latest";
37
+ var VERSION = true ? "4.3.3" : "latest";
38
38
  var VideoLoader = {
39
39
  dataType: null,
40
40
  batchType: null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "lib/parsers/parse-video.js", "video-loader.js", "lib/utils/assert.js", "lib/gifshot/gifshot.js", "gif-builder.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { VideoLoader } from \"./video-loader.js\";\nexport { default as GIFBuilder } from \"./gif-builder.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Parse to platform defined video type (HTMLVideoElement in browser)\nexport default async function parseVideo(arrayBuffer) {\n // TODO It is probably somewhat inefficent to convert a File/Blob to ArrayBuffer and back\n // and could perhaps cause problems for large videos.\n // TODO MIME type is also lost from the File or Response...\n const blob = new Blob([arrayBuffer]);\n const video = document.createElement('video');\n video.src = URL.createObjectURL(blob);\n return video;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport parseVideo from \"./lib/parsers/parse-video.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.2\" !== 'undefined' ? \"4.3.2\" : 'latest';\n/**\n * Loads a platform-specific image type that can be used as input data to WebGL textures\n */\nexport const VideoLoader = {\n dataType: null,\n batchType: null,\n name: 'Video',\n id: 'video',\n module: 'video',\n version: VERSION,\n extensions: ['mp4'],\n mimeTypes: ['video/mp4'],\n // tests: arrayBuffer => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer))),\n options: {\n video: {}\n },\n parse: parseVideo\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport function assert(condition, message) {\n if (!condition) {\n throw new Error(message);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// @ts-nocheck\n/* eslint-disable */\nconst document = globalThis.document || {};\n/* Copyrights for code authored by Yahoo Inc. is licensed under the following terms:\nMIT License\nCopyright 2017 Yahoo Inc.\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n/*\n utils.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nvar utils = {\n URL: globalThis.URL || globalThis.webkitURL || globalThis.mozURL || globalThis.msURL,\n getUserMedia: (function () {\n if (!globalThis.navigator)\n return globalThis.navigator;\n const getUserMedia = globalThis.navigator.getUserMedia ||\n globalThis.navigator.webkitGetUserMedia ||\n globalThis.navigator.mozGetUserMedia ||\n globalThis.navigator.msGetUserMedia;\n return getUserMedia ? getUserMedia.bind(globalThis.navigator) : getUserMedia;\n })(),\n requestAnimFrame: globalThis.requestAnimationFrame ||\n globalThis.webkitRequestAnimationFrame ||\n globalThis.mozRequestAnimationFrame ||\n globalThis.oRequestAnimationFrame ||\n globalThis.msRequestAnimationFrame,\n requestTimeout: function requestTimeout(callback, delay) {\n callback = callback || utils.noop;\n delay = delay || 0;\n if (!utils.requestAnimFrame) {\n return setTimeout(callback, delay);\n }\n const start = new Date().getTime();\n const handle = new Object();\n const requestAnimFrame = utils.requestAnimFrame;\n const loop = function loop() {\n const current = new Date().getTime();\n const delta = current - start;\n delta >= delay ? callback.call() : (handle.value = requestAnimFrame(loop));\n };\n handle.value = requestAnimFrame(loop);\n return handle;\n },\n Blob: globalThis.Blob ||\n globalThis.BlobBuilder ||\n globalThis.WebKitBlobBuilder ||\n globalThis.MozBlobBuilder ||\n globalThis.MSBlobBuilder,\n btoa: (function () {\n const btoa = globalThis.btoa ||\n function (input) {\n let output = '';\n let i = 0;\n const l = input.length;\n const key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n let chr1 = void 0;\n let chr2 = void 0;\n let chr3 = void 0;\n let enc1 = void 0;\n let enc2 = void 0;\n let enc3 = void 0;\n let enc4 = void 0;\n while (i < l) {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n }\n else if (isNaN(chr3)) {\n enc4 = 64;\n }\n output =\n output + key.charAt(enc1) + key.charAt(enc2) + key.charAt(enc3) + key.charAt(enc4);\n }\n return output;\n };\n return btoa ? btoa.bind(globalThis) : utils.noop;\n })(),\n isObject: function isObject(obj) {\n return obj && Object.prototype.toString.call(obj) === '[object Object]';\n },\n isEmptyObject: function isEmptyObject(obj) {\n return utils.isObject(obj) && !Object.keys(obj).length;\n },\n isArray: function isArray(arr) {\n return arr && Array.isArray(arr);\n },\n isFunction: function isFunction(func) {\n return func && typeof func === 'function';\n },\n isElement: function isElement(elem) {\n return elem && elem.nodeType === 1;\n },\n isString: function isString(value) {\n return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]';\n },\n isSupported: {\n canvas: function canvas() {\n const el = document.createElement('canvas');\n return el && el.getContext && el.getContext('2d');\n },\n webworkers: function webworkers() {\n return globalThis.Worker;\n },\n blob: function blob() {\n return utils.Blob;\n },\n Uint8Array: function Uint8Array() {\n return globalThis.Uint8Array;\n },\n Uint32Array: function Uint32Array() {\n return globalThis.Uint32Array;\n },\n videoCodecs: (function () {\n const testEl = document.createElement('video');\n const supportObj = {\n mp4: false,\n h264: false,\n ogv: false,\n ogg: false,\n webm: false\n };\n try {\n if (testEl && testEl.canPlayType) {\n // Check for MPEG-4 support\n supportObj.mp4 = testEl.canPlayType('video/mp4; codecs=\"mp4v.20.8\"') !== '';\n // Check for h264 support\n supportObj.h264 =\n (testEl.canPlayType('video/mp4; codecs=\"avc1.42E01E\"') ||\n testEl.canPlayType('video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"')) !== '';\n // Check for Ogv support\n supportObj.ogv = testEl.canPlayType('video/ogg; codecs=\"theora\"') !== '';\n // Check for Ogg support\n supportObj.ogg = testEl.canPlayType('video/ogg; codecs=\"theora\"') !== '';\n // Check for Webm support\n supportObj.webm = testEl.canPlayType('video/webm; codecs=\"vp8, vorbis\"') !== -1;\n }\n }\n catch (e) { }\n return supportObj;\n })()\n },\n noop: function noop() { },\n each: function each(collection, callback) {\n let x = void 0;\n let len = void 0;\n if (utils.isArray(collection)) {\n x = -1;\n len = collection.length;\n while (++x < len) {\n if (callback(x, collection[x]) === false) {\n break;\n }\n }\n }\n else if (utils.isObject(collection)) {\n for (x in collection) {\n if (collection.hasOwnProperty(x)) {\n if (callback(x, collection[x]) === false) {\n break;\n }\n }\n }\n }\n },\n normalizeOptions: function normalizeOptions(defaultOptions, userOptions) {\n if (!utils.isObject(defaultOptions) || !utils.isObject(userOptions) || !Object.keys) {\n return;\n }\n const newObj = {};\n utils.each(defaultOptions, function (key, val) {\n newObj[key] = defaultOptions[key];\n });\n utils.each(userOptions, function (key, val) {\n const currentUserOption = userOptions[key];\n if (!utils.isObject(currentUserOption)) {\n newObj[key] = currentUserOption;\n }\n else if (!defaultOptions[key]) {\n newObj[key] = currentUserOption;\n }\n else {\n newObj[key] = utils.normalizeOptions(defaultOptions[key], currentUserOption);\n }\n });\n return newObj;\n },\n setCSSAttr: function setCSSAttr(elem, attr, val) {\n if (!utils.isElement(elem)) {\n return;\n }\n if (utils.isString(attr) && utils.isString(val)) {\n elem.style[attr] = val;\n }\n else if (utils.isObject(attr)) {\n utils.each(attr, function (key, val) {\n elem.style[key] = val;\n });\n }\n },\n removeElement: function removeElement(node) {\n if (!utils.isElement(node)) {\n return;\n }\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n },\n createWebWorker: function createWebWorker(content) {\n if (!utils.isString(content)) {\n return {};\n }\n try {\n const blob = new utils.Blob([content], {\n type: 'text/javascript'\n });\n const objectUrl = utils.URL.createObjectURL(blob);\n const worker = new Worker(objectUrl);\n return {\n objectUrl,\n worker\n };\n }\n catch (e) {\n return `${e}`;\n }\n },\n getExtension: function getExtension(src) {\n return src.substr(src.lastIndexOf('.') + 1, src.length);\n },\n getFontSize: function getFontSize() {\n const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!document.body || options.resizeFont === false) {\n return options.fontSize;\n }\n const text = options.text;\n const containerWidth = options.gifWidth;\n let fontSize = parseInt(options.fontSize, 10);\n const minFontSize = parseInt(options.minFontSize, 10);\n const div = document.createElement('div');\n const span = document.createElement('span');\n div.setAttribute('width', containerWidth);\n div.appendChild(span);\n span.innerHTML = text;\n span.style.fontSize = `${fontSize}px`;\n span.style.textIndent = '-9999px';\n span.style.visibility = 'hidden';\n document.body.appendChild(span);\n while (span.offsetWidth > containerWidth && fontSize >= minFontSize) {\n span.style.fontSize = `${--fontSize}px`;\n }\n document.body.removeChild(span);\n return `${fontSize}px`;\n },\n webWorkerError: false\n};\nconst utils$2 = Object.freeze({\n default: utils\n});\n/*\n error.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nvar error = {\n validate: function validate(skipObj) {\n skipObj = utils.isObject(skipObj) ? skipObj : {};\n let errorObj = {};\n utils.each(error.validators, function (indece, currentValidator) {\n const errorCode = currentValidator.errorCode;\n if (!skipObj[errorCode] && !currentValidator.condition) {\n errorObj = currentValidator;\n errorObj.error = true;\n return false;\n }\n });\n delete errorObj.condition;\n return errorObj;\n },\n isValid: function isValid(skipObj) {\n const errorObj = error.validate(skipObj);\n const isValid = errorObj.error !== true;\n return isValid;\n },\n validators: [\n {\n condition: utils.isFunction(utils.getUserMedia),\n errorCode: 'getUserMedia',\n errorMsg: 'The getUserMedia API is not supported in your browser'\n },\n {\n condition: utils.isSupported.canvas(),\n errorCode: 'canvas',\n errorMsg: 'Canvas elements are not supported in your browser'\n },\n {\n condition: utils.isSupported.webworkers(),\n errorCode: 'webworkers',\n errorMsg: 'The Web Workers API is not supported in your browser'\n },\n {\n condition: utils.isFunction(utils.URL),\n errorCode: 'globalThis.URL',\n errorMsg: 'The globalThis.URL API is not supported in your browser'\n },\n {\n condition: utils.isSupported.blob(),\n errorCode: 'globalThis.Blob',\n errorMsg: 'The globalThis.Blob File API is not supported in your browser'\n },\n {\n condition: utils.isSupported.Uint8Array(),\n errorCode: 'globalThis.Uint8Array',\n errorMsg: 'The globalThis.Uint8Array function constructor is not supported in your browser'\n },\n {\n condition: utils.isSupported.Uint32Array(),\n errorCode: 'globalThis.Uint32Array',\n errorMsg: 'The globalThis.Uint32Array function constructor is not supported in your browser'\n }\n ],\n messages: {\n videoCodecs: {\n errorCode: 'videocodec',\n errorMsg: 'The video codec you are trying to use is not supported in your browser'\n }\n }\n};\nconst error$2 = Object.freeze({\n default: error\n});\n/*\n defaultOptions.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Helpers\nconst noop = function noop() { };\nconst defaultOptions = {\n sampleInterval: 10,\n numWorkers: 2,\n filter: '',\n gifWidth: 200,\n gifHeight: 200,\n interval: 0.1,\n numFrames: 10,\n frameDuration: 1,\n keepCameraOn: false,\n images: [],\n video: null,\n webcamVideoElement: null,\n cameraStream: null,\n text: '',\n fontWeight: 'normal',\n fontSize: '16px',\n minFontSize: '10px',\n resizeFont: false,\n fontFamily: 'sans-serif',\n fontColor: '#ffffff',\n textAlign: 'center',\n textBaseline: 'bottom',\n textXCoordinate: null,\n textYCoordinate: null,\n progressCallback: noop,\n completeCallback: noop,\n saveRenderingContexts: false,\n savedRenderingContexts: [],\n crossOrigin: 'Anonymous'\n};\nconst defaultOptions$2 = Object.freeze({\n default: defaultOptions\n});\n/*\n isSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction isSupported() {\n return error.isValid();\n}\n/*\n isWebCamGIFSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction isWebCamGIFSupported() {\n return error.isValid();\n}\n/*\n isSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction isSupported$1() {\n const options = {\n getUserMedia: true\n };\n return error.isValid(options);\n}\n/*\n isExistingVideoGIFSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction isExistingVideoGIFSupported(codecs) {\n let hasValidCodec = false;\n if (utils.isArray(codecs) && codecs.length) {\n utils.each(codecs, function (indece, currentCodec) {\n if (utils.isSupported.videoCodecs[currentCodec]) {\n hasValidCodec = true;\n }\n });\n if (!hasValidCodec) {\n return false;\n }\n }\n else if (utils.isString(codecs) && codecs.length) {\n if (!utils.isSupported.videoCodecs[codecs]) {\n return false;\n }\n }\n return error.isValid({\n getUserMedia: true\n });\n}\n/*\n NeuQuant.js\n */\n/*\n * NeuQuant Neural-Net Quantization Algorithm\n * ------------------------------------------\n *\n * Copyright (c) 1994 Anthony Dekker\n *\n * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See\n * \"Kohonen neural networks for optimal colour quantization\" in \"Network:\n * Computation in Neural Systems\" Vol. 5 (1994) pp 351-367. for a discussion of\n * the algorithm.\n *\n * Any party obtaining a copy of these files from the author, directly or\n * indirectly, is granted, free of charge, a full and unrestricted irrevocable,\n * world-wide, paid up, royalty-free, nonexclusive right and license to deal in\n * this software and documentation files (the \"Software\"), including without\n * limitation the rights to use, copy, modify, merge, publish, distribute,\n * sublicense, and/or sell copies of the Software, and to permit persons who\n * receive copies from any such party to do so, with the only requirement being\n * that this copyright notice remain intact.\n */\n/*\n * This class handles Neural-Net quantization algorithm\n * @author Kevin Weiner (original Java version - kweiner@fmsware.com)\n * @author Thibault Imbert (AS3 version - bytearray.org)\n * @version 0.1 AS3 implementation\n * @version 0.2 JS->AS3 \"translation\" by antimatter15\n * @version 0.3 JS clean up + using modern JS idioms by sole - http://soledadpenades.com\n * Also implement fix in color conversion described at http://stackoverflow.com/questions/16371712/neuquant-js-javascript-color-quantization-hidden-bug-in-js-conversion\n */\nfunction NeuQuant() {\n const netsize = 256; // number of colours used\n // four primes near 500 - assume no image has a length so large\n // that it is divisible by all four primes\n const prime1 = 499;\n const prime2 = 491;\n const prime3 = 487;\n const prime4 = 503;\n // minimum size for input image\n const minpicturebytes = 3 * prime4;\n // Network Definitions\n const maxnetpos = netsize - 1;\n const netbiasshift = 4; // bias for colour values\n const ncycles = 100; // no. of learning cycles\n // defs for freq and bias\n const intbiasshift = 16; // bias for fractions\n const intbias = 1 << intbiasshift;\n const gammashift = 10; // gamma = 1024\n const gamma = 1 << gammashift;\n const betashift = 10;\n const beta = intbias >> betashift; // beta = 1/1024\n const betagamma = intbias << (gammashift - betashift);\n // defs for decreasing radius factor\n // For 256 colors, radius starts at 32.0 biased by 6 bits\n // and decreases by a factor of 1/30 each cycle\n const initrad = netsize >> 3;\n const radiusbiasshift = 6;\n const radiusbias = 1 << radiusbiasshift;\n const initradius = initrad * radiusbias;\n const radiusdec = 30;\n // defs for decreasing alpha factor\n // Alpha starts at 1.0 biased by 10 bits\n const alphabiasshift = 10;\n const initalpha = 1 << alphabiasshift;\n let alphadec;\n // radbias and alpharadbias used for radpower calculation\n const radbiasshift = 8;\n const radbias = 1 << radbiasshift;\n const alpharadbshift = alphabiasshift + radbiasshift;\n const alpharadbias = 1 << alpharadbshift;\n // Input image\n let thepicture;\n // Height * Width * 3\n let lengthcount;\n // Sampling factor 1..30\n let samplefac;\n // The network itself\n let network;\n const netindex = [];\n // for network lookup - really 256\n const bias = [];\n // bias and freq arrays for learning\n const freq = [];\n const radpower = [];\n function NeuQuantConstructor(thepic, len, sample) {\n let i;\n let p;\n thepicture = thepic;\n lengthcount = len;\n samplefac = sample;\n network = new Array(netsize);\n for (i = 0; i < netsize; i++) {\n network[i] = new Array(4);\n p = network[i];\n p[0] = p[1] = p[2] = ((i << (netbiasshift + 8)) / netsize) | 0;\n freq[i] = (intbias / netsize) | 0; // 1 / netsize\n bias[i] = 0;\n }\n }\n function colorMap() {\n const map = [];\n const index = new Array(netsize);\n for (let i = 0; i < netsize; i++) {\n index[network[i][3]] = i;\n }\n let k = 0;\n for (let l = 0; l < netsize; l++) {\n const j = index[l];\n map[k++] = network[j][0];\n map[k++] = network[j][1];\n map[k++] = network[j][2];\n }\n return map;\n }\n // Insertion sort of network and building of netindex[0..255]\n // (to do after unbias)\n function inxbuild() {\n let i;\n let j;\n let smallpos;\n let smallval;\n let p;\n let q;\n let previouscol;\n let startpos;\n previouscol = 0;\n startpos = 0;\n for (i = 0; i < netsize; i++) {\n p = network[i];\n smallpos = i;\n smallval = p[1]; // index on g\n // find smallest in i..netsize-1\n for (j = i + 1; j < netsize; j++) {\n q = network[j];\n if (q[1] < smallval) {\n // index on g\n smallpos = j;\n smallval = q[1]; // index on g\n }\n }\n q = network[smallpos];\n // swap p (i) and q (smallpos) entries\n if (i != smallpos) {\n j = q[0];\n q[0] = p[0];\n p[0] = j;\n j = q[1];\n q[1] = p[1];\n p[1] = j;\n j = q[2];\n q[2] = p[2];\n p[2] = j;\n j = q[3];\n q[3] = p[3];\n p[3] = j;\n }\n // smallval entry is now in position i\n if (smallval != previouscol) {\n netindex[previouscol] = (startpos + i) >> 1;\n for (j = previouscol + 1; j < smallval; j++) {\n netindex[j] = i;\n }\n previouscol = smallval;\n startpos = i;\n }\n }\n netindex[previouscol] = (startpos + maxnetpos) >> 1;\n for (j = previouscol + 1; j < 256; j++) {\n netindex[j] = maxnetpos; // really 256\n }\n }\n // Main Learning Loop\n function learn() {\n let i;\n let j;\n let b;\n let g;\n let r;\n let radius;\n let rad;\n let alpha;\n let step;\n let delta;\n let samplepixels;\n let p;\n let pix;\n let lim;\n if (lengthcount < minpicturebytes) {\n samplefac = 1;\n }\n alphadec = 30 + (samplefac - 1) / 3;\n p = thepicture;\n pix = 0;\n lim = lengthcount;\n samplepixels = lengthcount / (3 * samplefac);\n delta = (samplepixels / ncycles) | 0;\n alpha = initalpha;\n radius = initradius;\n rad = radius >> radiusbiasshift;\n if (rad <= 1) {\n rad = 0;\n }\n for (i = 0; i < rad; i++) {\n radpower[i] = alpha * (((rad * rad - i * i) * radbias) / (rad * rad));\n }\n if (lengthcount < minpicturebytes) {\n step = 3;\n }\n else if (lengthcount % prime1 !== 0) {\n step = 3 * prime1;\n }\n else if (lengthcount % prime2 !== 0) {\n step = 3 * prime2;\n }\n else if (lengthcount % prime3 !== 0) {\n step = 3 * prime3;\n }\n else {\n step = 3 * prime4;\n }\n i = 0;\n while (i < samplepixels) {\n b = (p[pix + 0] & 0xff) << netbiasshift;\n g = (p[pix + 1] & 0xff) << netbiasshift;\n r = (p[pix + 2] & 0xff) << netbiasshift;\n j = contest(b, g, r);\n altersingle(alpha, j, b, g, r);\n if (rad !== 0) {\n // Alter neighbours\n alterneigh(rad, j, b, g, r);\n }\n pix += step;\n if (pix >= lim) {\n pix -= lengthcount;\n }\n i++;\n if (delta === 0) {\n delta = 1;\n }\n if (i % delta === 0) {\n alpha -= alpha / alphadec;\n radius -= radius / radiusdec;\n rad = radius >> radiusbiasshift;\n if (rad <= 1) {\n rad = 0;\n }\n for (j = 0; j < rad; j++) {\n radpower[j] = alpha * (((rad * rad - j * j) * radbias) / (rad * rad));\n }\n }\n }\n }\n // Search for BGR values 0..255 (after net is unbiased) and return colour index\n function map(b, g, r) {\n let i;\n let j;\n let dist;\n let a;\n let bestd;\n let p;\n let best;\n // Biggest possible distance is 256 * 3\n bestd = 1000;\n best = -1;\n i = netindex[g]; // index on g\n j = i - 1; // start at netindex[g] and work outwards\n while (i < netsize || j >= 0) {\n if (i < netsize) {\n p = network[i];\n dist = p[1] - g; // inx key\n if (dist >= bestd) {\n i = netsize; // stop iter\n }\n else {\n i++;\n if (dist < 0) {\n dist = -dist;\n }\n a = p[0] - b;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n a = p[2] - r;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n bestd = dist;\n best = p[3];\n }\n }\n }\n }\n if (j >= 0) {\n p = network[j];\n dist = g - p[1]; // inx key - reverse dif\n if (dist >= bestd) {\n j = -1; // stop iter\n }\n else {\n j--;\n if (dist < 0) {\n dist = -dist;\n }\n a = p[0] - b;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n a = p[2] - r;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n bestd = dist;\n best = p[3];\n }\n }\n }\n }\n }\n return best;\n }\n function process() {\n learn();\n unbiasnet();\n inxbuild();\n return colorMap();\n }\n // Unbias network to give byte values 0..255 and record position i\n // to prepare for sort\n function unbiasnet() {\n let i;\n let j;\n for (i = 0; i < netsize; i++) {\n network[i][0] >>= netbiasshift;\n network[i][1] >>= netbiasshift;\n network[i][2] >>= netbiasshift;\n network[i][3] = i; // record colour no\n }\n }\n // Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2))\n // in radpower[|i-j|]\n function alterneigh(rad, i, b, g, r) {\n let j;\n let k;\n let lo;\n let hi;\n let a;\n let m;\n let p;\n lo = i - rad;\n if (lo < -1) {\n lo = -1;\n }\n hi = i + rad;\n if (hi > netsize) {\n hi = netsize;\n }\n j = i + 1;\n k = i - 1;\n m = 1;\n while (j < hi || k > lo) {\n a = radpower[m++];\n if (j < hi) {\n p = network[j++];\n try {\n p[0] -= ((a * (p[0] - b)) / alpharadbias) | 0;\n p[1] -= ((a * (p[1] - g)) / alpharadbias) | 0;\n p[2] -= ((a * (p[2] - r)) / alpharadbias) | 0;\n }\n catch (e) { }\n }\n if (k > lo) {\n p = network[k--];\n try {\n p[0] -= ((a * (p[0] - b)) / alpharadbias) | 0;\n p[1] -= ((a * (p[1] - g)) / alpharadbias) | 0;\n p[2] -= ((a * (p[2] - r)) / alpharadbias) | 0;\n }\n catch (e) { }\n }\n }\n }\n // Move neuron i towards biased (b,g,r) by factor alpha\n function altersingle(alpha, i, b, g, r) {\n // alter hit neuron\n const n = network[i];\n const alphaMult = alpha / initalpha;\n n[0] -= (alphaMult * (n[0] - b)) | 0;\n n[1] -= (alphaMult * (n[1] - g)) | 0;\n n[2] -= (alphaMult * (n[2] - r)) | 0;\n }\n // Search for biased BGR values\n function contest(b, g, r) {\n // finds closest neuron (min dist) and updates freq\n // finds best neuron (min dist-bias) and returns position\n // for frequently chosen neurons, freq[i] is high and bias[i] is negative\n // bias[i] = gamma*((1/netsize)-freq[i])\n let i;\n let dist;\n let a;\n let biasdist;\n let betafreq;\n let bestpos;\n let bestbiaspos;\n let bestd;\n let bestbiasd;\n let n;\n bestd = ~(1 << 31);\n bestbiasd = bestd;\n bestpos = -1;\n bestbiaspos = bestpos;\n for (i = 0; i < netsize; i++) {\n n = network[i];\n dist = n[0] - b;\n if (dist < 0) {\n dist = -dist;\n }\n a = n[1] - g;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n a = n[2] - r;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n bestd = dist;\n bestpos = i;\n }\n biasdist = dist - (bias[i] >> (intbiasshift - netbiasshift));\n if (biasdist < bestbiasd) {\n bestbiasd = biasdist;\n bestbiaspos = i;\n }\n betafreq = freq[i] >> betashift;\n freq[i] -= betafreq;\n bias[i] += betafreq << gammashift;\n }\n freq[bestpos] += beta;\n bias[bestpos] -= betagamma;\n return bestbiaspos;\n }\n NeuQuantConstructor.apply(this, arguments);\n const exports = {};\n exports.map = map;\n exports.process = process;\n return exports;\n}\n/*\n processFrameWorker.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction workerCode() {\n const self = this;\n try {\n globalThis.onmessage = function (ev) {\n const data = ev.data || {};\n let response;\n if (data.gifshot) {\n response = workerMethods.run(data);\n postMessage(response);\n }\n };\n }\n catch (e) { }\n var workerMethods = {\n dataToRGB: function dataToRGB(data, width, height) {\n const length = width * height * 4;\n let i = 0;\n const rgb = [];\n while (i < length) {\n rgb.push(data[i++]);\n rgb.push(data[i++]);\n rgb.push(data[i++]);\n i++; // for the alpha channel which we don't care about\n }\n return rgb;\n },\n componentizedPaletteToArray: function componentizedPaletteToArray(paletteRGB) {\n paletteRGB = paletteRGB || [];\n const paletteArray = [];\n for (let i = 0; i < paletteRGB.length; i += 3) {\n const r = paletteRGB[i];\n const g = paletteRGB[i + 1];\n const b = paletteRGB[i + 2];\n paletteArray.push((r << 16) | (g << 8) | b);\n }\n return paletteArray;\n },\n // This is the \"traditional\" Animated_GIF style of going from RGBA to indexed color frames\n processFrameWithQuantizer: function processFrameWithQuantizer(imageData, width, height, sampleInterval) {\n const rgbComponents = this.dataToRGB(imageData, width, height);\n const nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval);\n const paletteRGB = nq.process();\n const paletteArray = new Uint32Array(this.componentizedPaletteToArray(paletteRGB));\n const numberPixels = width * height;\n const indexedPixels = new Uint8Array(numberPixels);\n let k = 0;\n for (let i = 0; i < numberPixels; i++) {\n const r = rgbComponents[k++];\n const g = rgbComponents[k++];\n const b = rgbComponents[k++];\n indexedPixels[i] = nq.map(r, g, b);\n }\n return {\n pixels: indexedPixels,\n palette: paletteArray\n };\n },\n run: function run(frame) {\n frame = frame || {};\n const _frame = frame;\n const height = _frame.height;\n const palette = _frame.palette;\n const sampleInterval = _frame.sampleInterval;\n const width = _frame.width;\n const imageData = frame.data;\n return this.processFrameWithQuantizer(imageData, width, height, sampleInterval);\n }\n };\n return workerMethods;\n}\n/*\n gifWriter.js\n */\n// (c) Dean McNamee <dean@gmail.com>, 2013.\n//\n// https://github.com/deanm/omggif\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n// IN THE SOFTWARE.\n//\n// omggif is a JavaScript implementation of a GIF 89a encoder and decoder,\n// including animation and compression. It does not rely on any specific\n// underlying system, so should run in the browser, Node, or Plask.\nfunction gifWriter(buf, width, height, gopts) {\n let p = 0;\n gopts = gopts === undefined ? {} : gopts;\n const loop_count = gopts.loop === undefined ? null : gopts.loop;\n const global_palette = gopts.palette === undefined ? null : gopts.palette;\n if (width <= 0 || height <= 0 || width > 65535 || height > 65535)\n throw 'Width/Height invalid.';\n function check_palette_and_num_colors(palette) {\n const num_colors = palette.length;\n if (num_colors < 2 || num_colors > 256 || num_colors & (num_colors - 1))\n throw 'Invalid code/color length, must be power of 2 and 2 .. 256.';\n return num_colors;\n }\n // - Header.\n buf[p++] = 0x47;\n buf[p++] = 0x49;\n buf[p++] = 0x46; // GIF\n buf[p++] = 0x38;\n buf[p++] = 0x39;\n buf[p++] = 0x61; // 89a\n // Handling of Global Color Table (palette) and background index.\n const gp_num_colors_pow2 = 0;\n const background = 0;\n // - Logical Screen Descriptor.\n // NOTE(deanm): w/h apparently ignored by implementations, but set anyway.\n buf[p++] = width & 0xff;\n buf[p++] = (width >> 8) & 0xff;\n buf[p++] = height & 0xff;\n buf[p++] = (height >> 8) & 0xff;\n // NOTE: Indicates 0-bpp original color resolution (unused?).\n buf[p++] =\n (global_palette !== null ? 0x80 : 0) | // Global Color Table Flag.\n gp_num_colors_pow2; // NOTE: No sort flag (unused?).\n buf[p++] = background; // Background Color Index.\n buf[p++] = 0; // Pixel aspect ratio (unused?).\n if (loop_count !== null) {\n // Netscape block for looping.\n if (loop_count < 0 || loop_count > 65535)\n throw 'Loop count invalid.';\n // Extension code, label, and length.\n buf[p++] = 0x21;\n buf[p++] = 0xff;\n buf[p++] = 0x0b;\n // NETSCAPE2.0\n buf[p++] = 0x4e;\n buf[p++] = 0x45;\n buf[p++] = 0x54;\n buf[p++] = 0x53;\n buf[p++] = 0x43;\n buf[p++] = 0x41;\n buf[p++] = 0x50;\n buf[p++] = 0x45;\n buf[p++] = 0x32;\n buf[p++] = 0x2e;\n buf[p++] = 0x30;\n // Sub-block\n buf[p++] = 0x03;\n buf[p++] = 0x01;\n buf[p++] = loop_count & 0xff;\n buf[p++] = (loop_count >> 8) & 0xff;\n buf[p++] = 0x00; // Terminator.\n }\n let ended = false;\n this.addFrame = function (x, y, w, h, indexed_pixels, opts) {\n if (ended === true) {\n --p;\n ended = false;\n } // Un-end.\n opts = opts === undefined ? {} : opts;\n // TODO(deanm): Bounds check x, y. Do they need to be within the virtual\n // canvas width/height, I imagine?\n if (x < 0 || y < 0 || x > 65535 || y > 65535)\n throw 'x/y invalid.';\n if (w <= 0 || h <= 0 || w > 65535 || h > 65535)\n throw 'Width/Height invalid.';\n if (indexed_pixels.length < w * h)\n throw 'Not enough pixels for the frame size.';\n let using_local_palette = true;\n let palette = opts.palette;\n if (palette === undefined || palette === null) {\n using_local_palette = false;\n palette = global_palette;\n }\n if (palette === undefined || palette === null)\n throw 'Must supply either a local or global palette.';\n let num_colors = check_palette_and_num_colors(palette);\n // Compute the min_code_size (power of 2), destroying num_colors.\n let min_code_size = 0;\n while ((num_colors >>= 1)) {\n ++min_code_size;\n }\n num_colors = 1 << min_code_size; // Now we can easily get it back.\n const delay = opts.delay === undefined ? 0 : opts.delay;\n // From the spec:\n // 0 - No disposal specified. The decoder is\n // not required to take any action.\n // 1 - Do not dispose. The graphic is to be left\n // in place.\n // 2 - Restore to background color. The area used by the\n // graphic must be restored to the background color.\n // 3 - Restore to previous. The decoder is required to\n // restore the area overwritten by the graphic with\n // what was there prior to rendering the graphic.\n // 4-7 - To be defined.\n // NOTE(deanm): Dispose background doesn't really work, apparently most\n // browsers ignore the background palette index and clear to transparency.\n const disposal = opts.disposal === undefined ? 0 : opts.disposal;\n if (disposal < 0 || disposal > 3)\n // 4-7 is reserved.\n throw 'Disposal out of range.';\n let use_transparency = false;\n let transparent_index = 0;\n if (opts.transparent !== undefined && opts.transparent !== null) {\n use_transparency = true;\n transparent_index = opts.transparent;\n if (transparent_index < 0 || transparent_index >= num_colors)\n throw 'Transparent color index.';\n }\n if (disposal !== 0 || use_transparency || delay !== 0) {\n // - Graphics Control Extension\n buf[p++] = 0x21;\n buf[p++] = 0xf9; // Extension / Label.\n buf[p++] = 4; // Byte size.\n buf[p++] = (disposal << 2) | (use_transparency === true ? 1 : 0);\n buf[p++] = delay & 0xff;\n buf[p++] = (delay >> 8) & 0xff;\n buf[p++] = transparent_index; // Transparent color index.\n buf[p++] = 0; // Block Terminator.\n }\n // - Image Descriptor\n buf[p++] = 0x2c; // Image Seperator.\n buf[p++] = x & 0xff;\n buf[p++] = (x >> 8) & 0xff; // Left.\n buf[p++] = y & 0xff;\n buf[p++] = (y >> 8) & 0xff; // Top.\n buf[p++] = w & 0xff;\n buf[p++] = (w >> 8) & 0xff;\n buf[p++] = h & 0xff;\n buf[p++] = (h >> 8) & 0xff;\n // NOTE: No sort flag (unused?).\n // TODO(deanm): Support interlace.\n buf[p++] = using_local_palette === true ? 0x80 | (min_code_size - 1) : 0;\n // - Local Color Table\n if (using_local_palette === true) {\n for (let i = 0, il = palette.length; i < il; ++i) {\n const rgb = palette[i];\n buf[p++] = (rgb >> 16) & 0xff;\n buf[p++] = (rgb >> 8) & 0xff;\n buf[p++] = rgb & 0xff;\n }\n }\n p = GifWriterOutputLZWCodeStream(buf, p, min_code_size < 2 ? 2 : min_code_size, indexed_pixels);\n };\n this.end = function () {\n if (ended === false) {\n buf[p++] = 0x3b; // Trailer.\n ended = true;\n }\n return p;\n };\n // Main compression routine, palette indexes -> LZW code stream.\n // |index_stream| must have at least one entry.\n function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {\n buf[p++] = min_code_size;\n let cur_subblock = p++; // Pointing at the length field.\n const clear_code = 1 << min_code_size;\n const code_mask = clear_code - 1;\n const eoi_code = clear_code + 1;\n let next_code = eoi_code + 1;\n let cur_code_size = min_code_size + 1; // Number of bits per code.\n let cur_shift = 0;\n // We have at most 12-bit codes, so we should have to hold a max of 19\n // bits here (and then we would write out).\n let cur = 0;\n function emit_bytes_to_buffer(bit_block_size) {\n while (cur_shift >= bit_block_size) {\n buf[p++] = cur & 0xff;\n cur >>= 8;\n cur_shift -= 8;\n if (p === cur_subblock + 256) {\n // Finished a subblock.\n buf[cur_subblock] = 255;\n cur_subblock = p++;\n }\n }\n }\n function emit_code(c) {\n cur |= c << cur_shift;\n cur_shift += cur_code_size;\n emit_bytes_to_buffer(8);\n }\n // I am not an expert on the topic, and I don't want to write a thesis.\n // However, it is good to outline here the basic algorithm and the few data\n // structures and optimizations here that make this implementation fast.\n // The basic idea behind LZW is to build a table of previously seen runs\n // addressed by a short id (herein called output code). All data is\n // referenced by a code, which represents one or more values from the\n // original input stream. All input bytes can be referenced as the same\n // value as an output code. So if you didn't want any compression, you\n // could more or less just output the original bytes as codes (there are\n // some details to this, but it is the idea). In order to achieve\n // compression, values greater then the input range (codes can be up to\n // 12-bit while input only 8-bit) represent a sequence of previously seen\n // inputs. The decompressor is able to build the same mapping while\n // decoding, so there is always a shared common knowledge between the\n // encoding and decoder, which is also important for \"timing\" aspects like\n // how to handle variable bit width code encoding.\n //\n // One obvious but very important consequence of the table system is there\n // is always a unique id (at most 12-bits) to map the runs. 'A' might be\n // 4, then 'AA' might be 10, 'AAA' 11, 'AAAA' 12, etc. This relationship\n // can be used for an effecient lookup strategy for the code mapping. We\n // need to know if a run has been seen before, and be able to map that run\n // to the output code. Since we start with known unique ids (input bytes),\n // and then from those build more unique ids (table entries), we can\n // continue this chain (almost like a linked list) to always have small\n // integer values that represent the current byte chains in the encoder.\n // This means instead of tracking the input bytes (AAAABCD) to know our\n // current state, we can track the table entry for AAAABC (it is guaranteed\n // to exist by the nature of the algorithm) and the next character D.\n // Therefor the tuple of (table_entry, byte) is guaranteed to also be\n // unique. This allows us to create a simple lookup key for mapping input\n // sequences to codes (table indices) without having to store or search\n // any of the code sequences. So if 'AAAA' has a table entry of 12, the\n // tuple of ('AAAA', K) for any input byte K will be unique, and can be our\n // key. This leads to a integer value at most 20-bits, which can always\n // fit in an SMI value and be used as a fast sparse array / object key.\n // Output code for the current contents of the index buffer.\n let ib_code = index_stream[0] & code_mask; // Load first input index.\n let code_table = {}; // Key'd on our 20-bit \"tuple\".\n emit_code(clear_code); // Spec says first code should be a clear code.\n // First index already loaded, process the rest of the stream.\n for (let i = 1, il = index_stream.length; i < il; ++i) {\n const k = index_stream[i] & code_mask;\n const cur_key = (ib_code << 8) | k; // (prev, k) unique tuple.\n const cur_code = code_table[cur_key]; // buffer + k.\n // Check if we have to create a new code table entry.\n if (cur_code === undefined) {\n // We don't have buffer + k.\n // Emit index buffer (without k).\n // This is an inline version of emit_code, because this is the core\n // writing routine of the compressor (and V8 cannot inline emit_code\n // because it is a closure here in a different context). Additionally\n // we can call emit_byte_to_buffer less often, because we can have\n // 30-bits (from our 31-bit signed SMI), and we know our codes will only\n // be 12-bits, so can safely have 18-bits there without overflow.\n // emit_code(ib_code);\n cur |= ib_code << cur_shift;\n cur_shift += cur_code_size;\n while (cur_shift >= 8) {\n buf[p++] = cur & 0xff;\n cur >>= 8;\n cur_shift -= 8;\n if (p === cur_subblock + 256) {\n // Finished a subblock.\n buf[cur_subblock] = 255;\n cur_subblock = p++;\n }\n }\n if (next_code === 4096) {\n // Table full, need a clear.\n emit_code(clear_code);\n next_code = eoi_code + 1;\n cur_code_size = min_code_size + 1;\n code_table = {};\n }\n else {\n // Table not full, insert a new entry.\n // Increase our variable bit code sizes if necessary. This is a bit\n // tricky as it is based on \"timing\" between the encoding and\n // decoder. From the encoders perspective this should happen after\n // we've already emitted the index buffer and are about to create the\n // first table entry that would overflow our current code bit size.\n if (next_code >= 1 << cur_code_size)\n ++cur_code_size;\n code_table[cur_key] = next_code++; // Insert into code table.\n }\n ib_code = k; // Index buffer to single input k.\n }\n else {\n ib_code = cur_code; // Index buffer to sequence in code table.\n }\n }\n emit_code(ib_code); // There will still be something in the index buffer.\n emit_code(eoi_code); // End Of Information.\n // Flush / finalize the sub-blocks stream to the buffer.\n emit_bytes_to_buffer(1);\n // Finish the sub-blocks, writing out any unfinished lengths and\n // terminating with a sub-block of length 0. If we have already started\n // but not yet used a sub-block it can just become the terminator.\n if (cur_subblock + 1 === p) {\n // Started but unused.\n buf[cur_subblock] = 0;\n }\n else {\n // Started and used, write length and additional terminator block.\n buf[cur_subblock] = p - cur_subblock - 1;\n buf[p++] = 0;\n }\n return p;\n }\n}\n/*\n animatedGIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\n// Helpers\nconst noop$2 = function noop() { };\nconst AnimatedGIF = function AnimatedGIF(options) {\n this.canvas = null;\n this.ctx = null;\n this.repeat = 0;\n this.frames = [];\n this.numRenderedFrames = 0;\n this.onRenderCompleteCallback = noop$2;\n this.onRenderProgressCallback = noop$2;\n this.workers = [];\n this.availableWorkers = [];\n this.generatingGIF = false;\n this.options = options;\n // Constructs and initializes the the web workers appropriately\n this.initializeWebWorkers(options);\n};\nAnimatedGIF.prototype = {\n workerMethods: workerCode(),\n initializeWebWorkers: function initializeWebWorkers(options) {\n const self = this;\n const processFrameWorkerCode = `${NeuQuant.toString()}(${workerCode.toString()}());`;\n let webWorkerObj = void 0;\n let objectUrl = void 0;\n let webWorker = void 0;\n let numWorkers = void 0;\n let x = -1;\n let workerError = '';\n numWorkers = options.numWorkers;\n while (++x < numWorkers) {\n webWorkerObj = utils.createWebWorker(processFrameWorkerCode);\n if (utils.isObject(webWorkerObj)) {\n objectUrl = webWorkerObj.objectUrl;\n webWorker = webWorkerObj.worker;\n self.workers.push({\n worker: webWorker,\n objectUrl\n });\n self.availableWorkers.push(webWorker);\n }\n else {\n workerError = webWorkerObj;\n utils.webWorkerError = Boolean(webWorkerObj);\n }\n }\n this.workerError = workerError;\n this.canvas = document.createElement('canvas');\n this.canvas.width = options.gifWidth;\n this.canvas.height = options.gifHeight;\n this.ctx = this.canvas.getContext('2d');\n this.frames = [];\n },\n // Return a worker for processing a frame\n getWorker: function getWorker() {\n return this.availableWorkers.pop();\n },\n // Restores a worker to the pool\n freeWorker: function freeWorker(worker) {\n this.availableWorkers.push(worker);\n },\n byteMap: (function () {\n const byteMap = [];\n for (let i = 0; i < 256; i++) {\n byteMap[i] = String.fromCharCode(i);\n }\n return byteMap;\n })(),\n bufferToString: function bufferToString(buffer) {\n const numberValues = buffer.length;\n let str = '';\n let x = -1;\n while (++x < numberValues) {\n str += this.byteMap[buffer[x]];\n }\n return str;\n },\n onFrameFinished: function onFrameFinished(progressCallback) {\n // The GIF is not written until we're done with all the frames\n // because they might not be processed in the same order\n const self = this;\n const frames = self.frames;\n const options = self.options;\n const hasExistingImages = Boolean((options.images || []).length);\n const allDone = frames.every(function (frame) {\n return !frame.beingProcessed && frame.done;\n });\n self.numRenderedFrames++;\n if (hasExistingImages) {\n progressCallback(self.numRenderedFrames / frames.length);\n }\n self.onRenderProgressCallback((self.numRenderedFrames * 0.75) / frames.length);\n if (allDone) {\n if (!self.generatingGIF) {\n self.generateGIF(frames, self.onRenderCompleteCallback);\n }\n }\n else {\n utils.requestTimeout(function () {\n self.processNextFrame();\n }, 1);\n }\n },\n processFrame: function processFrame(position) {\n const AnimatedGifContext = this;\n const options = this.options;\n const _options = this.options;\n const progressCallback = _options.progressCallback;\n const sampleInterval = _options.sampleInterval;\n const frames = this.frames;\n let frame = void 0;\n let worker = void 0;\n const done = function done() {\n const ev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const data = ev.data;\n // Delete original data, and free memory\n delete frame.data;\n frame.pixels = Array.prototype.slice.call(data.pixels);\n frame.palette = Array.prototype.slice.call(data.palette);\n frame.done = true;\n frame.beingProcessed = false;\n AnimatedGifContext.freeWorker(worker);\n AnimatedGifContext.onFrameFinished(progressCallback);\n };\n frame = frames[position];\n if (frame.beingProcessed || frame.done) {\n this.onFrameFinished();\n return;\n }\n frame.sampleInterval = sampleInterval;\n frame.beingProcessed = true;\n frame.gifshot = true;\n worker = this.getWorker();\n if (worker) {\n // Process the frame in a web worker\n worker.onmessage = done;\n worker.postMessage(frame);\n }\n else {\n // Process the frame in the current thread\n done({\n data: AnimatedGifContext.workerMethods.run(frame)\n });\n }\n },\n startRendering: function startRendering(completeCallback) {\n this.onRenderCompleteCallback = completeCallback;\n for (let i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {\n this.processFrame(i);\n }\n },\n processNextFrame: function processNextFrame() {\n let position = -1;\n for (let i = 0; i < this.frames.length; i++) {\n const frame = this.frames[i];\n if (!frame.done && !frame.beingProcessed) {\n position = i;\n break;\n }\n }\n if (position >= 0) {\n this.processFrame(position);\n }\n },\n // Takes the already processed data in frames and feeds it to a new\n // GifWriter instance in order to get the binary GIF file\n generateGIF: function generateGIF(frames, callback) {\n // TODO: Weird: using a simple JS array instead of a typed array,\n // the files are WAY smaller o_o. Patches/explanations welcome!\n const buffer = []; // new Uint8Array(width * height * frames.length * 5);\n const gifOptions = {\n loop: this.repeat\n };\n const options = this.options;\n const interval = options.interval;\n const frameDuration = options.frameDuration;\n const existingImages = options.images;\n const hasExistingImages = Boolean(existingImages.length);\n const height = options.gifHeight;\n const width = options.gifWidth;\n const gifWriter$$1 = new gifWriter(buffer, width, height, gifOptions);\n const onRenderProgressCallback = this.onRenderProgressCallback;\n const delay = hasExistingImages ? interval * 100 : 0;\n let bufferToString = void 0;\n let gif = void 0;\n this.generatingGIF = true;\n utils.each(frames, function (iterator, frame) {\n const framePalette = frame.palette;\n onRenderProgressCallback(0.75 + (0.25 * frame.position * 1.0) / frames.length);\n for (let i = 0; i < frameDuration; i++) {\n gifWriter$$1.addFrame(0, 0, width, height, frame.pixels, {\n palette: framePalette,\n delay\n });\n }\n });\n gifWriter$$1.end();\n onRenderProgressCallback(1.0);\n this.frames = [];\n this.generatingGIF = false;\n if (utils.isFunction(callback)) {\n bufferToString = this.bufferToString(buffer);\n gif = `data:image/gif;base64,${utils.btoa(bufferToString)}`;\n callback(gif);\n }\n },\n // From GIF: 0 = loop forever, null = not looping, n > 0 = loop n times and stop\n setRepeat: function setRepeat(r) {\n this.repeat = r;\n },\n addFrame: function addFrame(element, gifshotOptions) {\n gifshotOptions = utils.isObject(gifshotOptions) ? gifshotOptions : {};\n const self = this;\n const ctx = self.ctx;\n const options = self.options;\n const width = options.gifWidth;\n const height = options.gifHeight;\n const fontSize = utils.getFontSize(gifshotOptions);\n const _gifshotOptions = gifshotOptions;\n const filter = _gifshotOptions.filter;\n const fontColor = _gifshotOptions.fontColor;\n const fontFamily = _gifshotOptions.fontFamily;\n const fontWeight = _gifshotOptions.fontWeight;\n const gifHeight = _gifshotOptions.gifHeight;\n const gifWidth = _gifshotOptions.gifWidth;\n const text = _gifshotOptions.text;\n const textAlign = _gifshotOptions.textAlign;\n const textBaseline = _gifshotOptions.textBaseline;\n const textXCoordinate = gifshotOptions.textXCoordinate\n ? gifshotOptions.textXCoordinate\n : textAlign === 'left'\n ? 1\n : textAlign === 'right'\n ? width\n : width / 2;\n const textYCoordinate = gifshotOptions.textYCoordinate\n ? gifshotOptions.textYCoordinate\n : textBaseline === 'top'\n ? 1\n : textBaseline === 'center'\n ? height / 2\n : height;\n const font = `${fontWeight} ${fontSize} ${fontFamily}`;\n let imageData = void 0;\n try {\n ctx.filter = filter;\n ctx.drawImage(element, 0, 0, width, height);\n if (text) {\n ctx.font = font;\n ctx.fillStyle = fontColor;\n ctx.textAlign = textAlign;\n ctx.textBaseline = textBaseline;\n ctx.fillText(text, textXCoordinate, textYCoordinate);\n }\n imageData = ctx.getImageData(0, 0, width, height);\n self.addFrameImageData(imageData);\n }\n catch (e) {\n return `${e}`;\n }\n },\n addFrameImageData: function addFrameImageData() {\n const imageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const frames = this.frames;\n const imageDataArray = imageData.data;\n this.frames.push({\n data: imageDataArray,\n width: imageData.width,\n height: imageData.height,\n palette: null,\n dithering: null,\n done: false,\n beingProcessed: false,\n position: frames.length\n });\n },\n onRenderProgress: function onRenderProgress(callback) {\n this.onRenderProgressCallback = callback;\n },\n isRendering: function isRendering() {\n return this.generatingGIF;\n },\n getBase64GIF: function getBase64GIF(completeCallback) {\n const self = this;\n const onRenderComplete = function onRenderComplete(gif) {\n self.destroyWorkers();\n utils.requestTimeout(function () {\n completeCallback(gif);\n }, 0);\n };\n self.startRendering(onRenderComplete);\n },\n destroyWorkers: function destroyWorkers() {\n if (this.workerError) {\n return;\n }\n const workers = this.workers;\n // Explicitly ask web workers to die so they are explicitly GC'ed\n utils.each(workers, function (iterator, workerObj) {\n const worker = workerObj.worker;\n const objectUrl = workerObj.objectUrl;\n worker.terminate();\n utils.URL.revokeObjectURL(objectUrl);\n });\n }\n};\n/*\n getBase64GIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction getBase64GIF(animatedGifInstance, callback) {\n // This is asynchronous, rendered with WebWorkers\n animatedGifInstance.getBase64GIF(function (image) {\n callback({\n error: false,\n errorCode: '',\n errorMsg: '',\n image\n });\n });\n}\n/*\n existingImages.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction existingImages() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const self = this;\n const callback = obj.callback;\n const images = obj.images;\n const options = obj.options;\n let imagesLength = obj.imagesLength;\n const skipObj = {\n getUserMedia: true,\n 'globalThis.URL': true\n };\n const errorObj = error.validate(skipObj);\n const loadedImages = [];\n let loadedImagesLength = 0;\n let tempImage = void 0;\n let ag = void 0;\n if (errorObj.error) {\n return callback(errorObj);\n }\n // change workerPath to point to where Animated_GIF.worker.js is\n ag = new AnimatedGIF(options);\n utils.each(images, function (index, image) {\n const currentImage = image;\n // if (image.src) {\n // currentImage = currentImage.src;\n // }\n if (utils.isElement(currentImage)) {\n if (options.crossOrigin) {\n currentImage.crossOrigin = options.crossOrigin;\n }\n loadedImages[index] = currentImage;\n loadedImagesLength += 1;\n if (loadedImagesLength === imagesLength) {\n addLoadedImagesToGif();\n }\n }\n else if (utils.isString(currentImage)) {\n tempImage = new Image();\n if (options.crossOrigin) {\n tempImage.crossOrigin = options.crossOrigin;\n }\n (function (tempImage) {\n if (image.text) {\n tempImage.text = image.text;\n }\n tempImage.onerror = function (e) {\n let obj = void 0;\n --imagesLength; // skips over images that error out\n if (imagesLength === 0) {\n obj = {};\n obj.error = 'None of the requested images was capable of being retrieved';\n return callback(obj);\n }\n };\n tempImage.onload = function (e) {\n if (image.text) {\n loadedImages[index] = {\n img: tempImage,\n text: tempImage.text\n };\n }\n else {\n loadedImages[index] = tempImage;\n }\n loadedImagesLength += 1;\n if (loadedImagesLength === imagesLength) {\n addLoadedImagesToGif();\n }\n utils.removeElement(tempImage);\n };\n tempImage.src = currentImage;\n })(tempImage);\n utils.setCSSAttr(tempImage, {\n position: 'fixed',\n opacity: '0'\n });\n document.body.appendChild(tempImage);\n }\n });\n function addLoadedImagesToGif() {\n utils.each(loadedImages, function (index, loadedImage) {\n if (loadedImage) {\n if (loadedImage.text) {\n ag.addFrame(loadedImage.img, options, loadedImage.text);\n }\n else {\n ag.addFrame(loadedImage, options);\n }\n }\n });\n getBase64GIF(ag, callback);\n }\n}\n/*\n screenShot.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\n// Helpers\nconst noop$3 = function noop() { };\nconst screenShot = {\n getGIF: function getGIF() {\n const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n let callback = arguments[1];\n callback = utils.isFunction(callback) ? callback : noop$3;\n const canvas = document.createElement('canvas');\n let context = void 0;\n const existingImages = options.images;\n const hasExistingImages = Boolean(existingImages.length);\n const cameraStream = options.cameraStream;\n const crop = options.crop;\n const filter = options.filter;\n const fontColor = options.fontColor;\n const fontFamily = options.fontFamily;\n const fontWeight = options.fontWeight;\n const keepCameraOn = options.keepCameraOn;\n const numWorkers = options.numWorkers;\n const progressCallback = options.progressCallback;\n const saveRenderingContexts = options.saveRenderingContexts;\n const savedRenderingContexts = options.savedRenderingContexts;\n const text = options.text;\n const textAlign = options.textAlign;\n const textBaseline = options.textBaseline;\n const videoElement = options.videoElement;\n const videoHeight = options.videoHeight;\n const videoWidth = options.videoWidth;\n const webcamVideoElement = options.webcamVideoElement;\n const gifWidth = Number(options.gifWidth);\n const gifHeight = Number(options.gifHeight);\n let interval = Number(options.interval);\n const sampleInterval = Number(options.sampleInterval);\n const waitBetweenFrames = hasExistingImages ? 0 : interval * 1000;\n const renderingContextsToSave = [];\n let numFrames = savedRenderingContexts.length\n ? savedRenderingContexts.length\n : options.numFrames;\n let pendingFrames = numFrames;\n const ag = new AnimatedGIF(options);\n const fontSize = utils.getFontSize(options);\n const textXCoordinate = options.textXCoordinate\n ? options.textXCoordinate\n : textAlign === 'left'\n ? 1\n : textAlign === 'right'\n ? gifWidth\n : gifWidth / 2;\n const textYCoordinate = options.textYCoordinate\n ? options.textYCoordinate\n : textBaseline === 'top'\n ? 1\n : textBaseline === 'center'\n ? gifHeight / 2\n : gifHeight;\n const font = `${fontWeight} ${fontSize} ${fontFamily}`;\n let sourceX = crop ? Math.floor(crop.scaledWidth / 2) : 0;\n let sourceWidth = crop ? videoWidth - crop.scaledWidth : 0;\n let sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0;\n let sourceHeight = crop ? videoHeight - crop.scaledHeight : 0;\n const captureFrames = function captureSingleFrame() {\n const framesLeft = pendingFrames - 1;\n if (savedRenderingContexts.length) {\n context.putImageData(savedRenderingContexts[numFrames - pendingFrames], 0, 0);\n finishCapture();\n }\n else {\n drawVideo();\n }\n function drawVideo() {\n try {\n // Makes sure the canvas video heights/widths are in bounds\n if (sourceWidth > videoWidth) {\n sourceWidth = videoWidth;\n }\n if (sourceHeight > videoHeight) {\n sourceHeight = videoHeight;\n }\n if (sourceX < 0) {\n sourceX = 0;\n }\n if (sourceY < 0) {\n sourceY = 0;\n }\n context.filter = filter;\n context.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, gifWidth, gifHeight);\n finishCapture();\n }\n catch (e) {\n // There is a Firefox bug that sometimes throws NS_ERROR_NOT_AVAILABLE and\n // and IndexSizeError errors when drawing a video element to the canvas\n if (e.name === 'NS_ERROR_NOT_AVAILABLE') {\n // Wait 100ms before trying again\n utils.requestTimeout(drawVideo, 100);\n }\n else {\n throw e;\n }\n }\n }\n function finishCapture() {\n let imageData = void 0;\n if (saveRenderingContexts) {\n renderingContextsToSave.push(context.getImageData(0, 0, gifWidth, gifHeight));\n }\n // If there is text to display, make sure to display it on the canvas after the image is drawn\n if (text) {\n context.font = font;\n context.fillStyle = fontColor;\n context.textAlign = textAlign;\n context.textBaseline = textBaseline;\n context.fillText(text, textXCoordinate, textYCoordinate);\n }\n imageData = context.getImageData(0, 0, gifWidth, gifHeight);\n ag.addFrameImageData(imageData);\n pendingFrames = framesLeft;\n // Call back with an r value indicating how far along we are in capture\n progressCallback((numFrames - pendingFrames) / numFrames);\n if (framesLeft > 0) {\n // test\n utils.requestTimeout(captureSingleFrame, waitBetweenFrames);\n }\n if (!pendingFrames) {\n ag.getBase64GIF(function (image) {\n callback({\n error: false,\n errorCode: '',\n errorMsg: '',\n image,\n cameraStream,\n videoElement,\n webcamVideoElement,\n savedRenderingContexts: renderingContextsToSave,\n keepCameraOn\n });\n });\n }\n }\n };\n numFrames = numFrames !== undefined ? numFrames : 10;\n interval = interval !== undefined ? interval : 0.1; // In seconds\n canvas.width = gifWidth;\n canvas.height = gifHeight;\n context = canvas.getContext('2d');\n (function capture() {\n if (!savedRenderingContexts.length && videoElement.currentTime === 0) {\n utils.requestTimeout(capture, 100);\n return;\n }\n captureFrames();\n })();\n },\n getCropDimensions: function getCropDimensions() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const width = obj.videoWidth;\n const height = obj.videoHeight;\n const gifWidth = obj.gifWidth;\n const gifHeight = obj.gifHeight;\n const result = {\n width: 0,\n height: 0,\n scaledWidth: 0,\n scaledHeight: 0\n };\n if (width > height) {\n result.width = Math.round(width * (gifHeight / height)) - gifWidth;\n result.scaledWidth = Math.round(result.width * (height / gifHeight));\n }\n else {\n result.height = Math.round(height * (gifWidth / width)) - gifHeight;\n result.scaledHeight = Math.round(result.height * (width / gifWidth));\n }\n return result;\n }\n};\n/*\n videoStream.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nvar videoStream = {\n loadedData: false,\n defaultVideoDimensions: {\n width: 640,\n height: 480\n },\n findVideoSize: function findVideoSizeMethod(obj) {\n findVideoSizeMethod.attempts = findVideoSizeMethod.attempts || 0;\n const cameraStream = obj.cameraStream;\n const completedCallback = obj.completedCallback;\n const videoElement = obj.videoElement;\n if (!videoElement) {\n return;\n }\n if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {\n videoElement.removeEventListener('loadeddata', videoStream.findVideoSize);\n completedCallback({\n videoElement,\n cameraStream,\n videoWidth: videoElement.videoWidth,\n videoHeight: videoElement.videoHeight\n });\n }\n else if (findVideoSizeMethod.attempts < 10) {\n findVideoSizeMethod.attempts += 1;\n utils.requestTimeout(function () {\n videoStream.findVideoSize(obj);\n }, 400);\n }\n else {\n completedCallback({\n videoElement,\n cameraStream,\n videoWidth: videoStream.defaultVideoDimensions.width,\n videoHeight: videoStream.defaultVideoDimensions.height\n });\n }\n },\n onStreamingTimeout: function onStreamingTimeout(callback) {\n if (utils.isFunction(callback)) {\n callback({\n error: true,\n errorCode: 'getUserMedia',\n errorMsg: 'There was an issue with the getUserMedia API - Timed out while trying to start streaming',\n image: null,\n cameraStream: {}\n });\n }\n },\n stream: function stream(obj) {\n const existingVideo = utils.isArray(obj.existingVideo)\n ? obj.existingVideo[0]\n : obj.existingVideo;\n const cameraStream = obj.cameraStream;\n const completedCallback = obj.completedCallback;\n const streamedCallback = obj.streamedCallback;\n const videoElement = obj.videoElement;\n if (utils.isFunction(streamedCallback)) {\n streamedCallback();\n }\n if (existingVideo) {\n if (utils.isString(existingVideo)) {\n videoElement.src = existingVideo;\n videoElement.innerHTML = `<source src=\"${existingVideo}\" type=\"video/${utils.getExtension(existingVideo)}\" />`;\n }\n else if (existingVideo instanceof Blob) {\n try {\n videoElement.src = utils.URL.createObjectURL(existingVideo);\n }\n catch (e) { }\n videoElement.innerHTML = `<source src=\"${existingVideo}\" type=\"${existingVideo.type}\" />`;\n }\n }\n else if (videoElement.mozSrcObject) {\n videoElement.mozSrcObject = cameraStream;\n }\n else if (utils.URL) {\n try {\n videoElement.srcObject = cameraStream;\n videoElement.src = utils.URL.createObjectURL(cameraStream);\n }\n catch (e) {\n videoElement.srcObject = cameraStream;\n }\n }\n videoElement.play();\n utils.requestTimeout(function checkLoadedData() {\n checkLoadedData.count = checkLoadedData.count || 0;\n if (videoStream.loadedData === true) {\n videoStream.findVideoSize({\n videoElement,\n cameraStream,\n completedCallback\n });\n videoStream.loadedData = false;\n }\n else {\n checkLoadedData.count += 1;\n if (checkLoadedData.count > 10) {\n videoStream.findVideoSize({\n videoElement,\n cameraStream,\n completedCallback\n });\n }\n else {\n checkLoadedData();\n }\n }\n }, 0);\n },\n startStreaming: function startStreaming(obj) {\n const errorCallback = utils.isFunction(obj.error) ? obj.error : utils.noop;\n const streamedCallback = utils.isFunction(obj.streamed) ? obj.streamed : utils.noop;\n const completedCallback = utils.isFunction(obj.completed) ? obj.completed : utils.noop;\n const crossOrigin = obj.crossOrigin;\n const existingVideo = obj.existingVideo;\n const lastCameraStream = obj.lastCameraStream;\n const options = obj.options;\n const webcamVideoElement = obj.webcamVideoElement;\n const videoElement = utils.isElement(existingVideo)\n ? existingVideo\n : webcamVideoElement\n ? webcamVideoElement\n : document.createElement('video');\n const cameraStream = void 0;\n if (crossOrigin) {\n videoElement.crossOrigin = options.crossOrigin;\n }\n videoElement.autoplay = true;\n videoElement.loop = true;\n videoElement.muted = true;\n videoElement.addEventListener('loadeddata', function (event) {\n videoStream.loadedData = true;\n if (options.offset) {\n videoElement.currentTime = options.offset;\n }\n });\n if (existingVideo) {\n videoStream.stream({\n videoElement,\n existingVideo,\n completedCallback\n });\n }\n else if (lastCameraStream) {\n videoStream.stream({\n videoElement,\n cameraStream: lastCameraStream,\n streamedCallback,\n completedCallback\n });\n }\n else {\n utils.getUserMedia({\n video: true\n }, function (stream) {\n videoStream.stream({\n videoElement,\n cameraStream: stream,\n streamedCallback,\n completedCallback\n });\n }, errorCallback);\n }\n },\n startVideoStreaming: function startVideoStreaming(callback) {\n const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const timeoutLength = options.timeout !== undefined ? options.timeout : 0;\n const originalCallback = options.callback;\n const webcamVideoElement = options.webcamVideoElement;\n let noGetUserMediaSupportTimeout = void 0;\n // Some browsers apparently have support for video streaming because of the\n // presence of the getUserMedia function, but then do not answer our\n // calls for streaming.\n // So we'll set up this timeout and if nothing happens after a while, we'll\n // conclude that there's no actual getUserMedia support.\n if (timeoutLength > 0) {\n noGetUserMediaSupportTimeout = utils.requestTimeout(function () {\n videoStream.onStreamingTimeout(originalCallback);\n }, 10000);\n }\n videoStream.startStreaming({\n error: function error() {\n originalCallback({\n error: true,\n errorCode: 'getUserMedia',\n errorMsg: 'There was an issue with the getUserMedia API - the user probably denied permission',\n image: null,\n cameraStream: {}\n });\n },\n streamed: function streamed() {\n // The streaming started somehow, so we can assume there is getUserMedia support\n clearTimeout(noGetUserMediaSupportTimeout);\n },\n completed: function completed() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const cameraStream = obj.cameraStream;\n const videoElement = obj.videoElement;\n const videoHeight = obj.videoHeight;\n const videoWidth = obj.videoWidth;\n callback({\n cameraStream,\n videoElement,\n videoHeight,\n videoWidth\n });\n },\n lastCameraStream: options.lastCameraStream,\n webcamVideoElement,\n crossOrigin: options.crossOrigin,\n options\n });\n },\n stopVideoStreaming: function stopVideoStreaming(obj) {\n obj = utils.isObject(obj) ? obj : {};\n const _obj = obj;\n const keepCameraOn = _obj.keepCameraOn;\n const videoElement = _obj.videoElement;\n const webcamVideoElement = _obj.webcamVideoElement;\n const cameraStream = obj.cameraStream || {};\n const cameraStreamTracks = cameraStream.getTracks ? cameraStream.getTracks() || [] : [];\n const hasCameraStreamTracks = Boolean(cameraStreamTracks.length);\n const firstCameraStreamTrack = cameraStreamTracks[0];\n if (!keepCameraOn && hasCameraStreamTracks) {\n if (utils.isFunction(firstCameraStreamTrack.stop)) {\n // Stops the camera stream\n firstCameraStreamTrack.stop();\n }\n }\n if (utils.isElement(videoElement) && !webcamVideoElement) {\n // Pauses the video, revokes the object URL (freeing up memory), and remove the video element\n videoElement.pause();\n // Destroys the object url\n if (utils.isFunction(utils.URL.revokeObjectURL) && !utils.webWorkerError) {\n if (videoElement.src) {\n utils.URL.revokeObjectURL(videoElement.src);\n }\n }\n // Removes the video element from the DOM\n utils.removeElement(videoElement);\n }\n }\n};\n/*\n stopVideoStreaming.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction stopVideoStreaming(options) {\n options = utils.isObject(options) ? options : {};\n videoStream.stopVideoStreaming(options);\n}\n/*\n createAndGetGIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction createAndGetGIF(obj, callback) {\n const options = obj.options || {};\n const images = options.images;\n const video = options.video;\n const gifWidth = Number(options.gifWidth);\n const gifHeight = Number(options.gifHeight);\n const numFrames = Number(options.numFrames);\n const cameraStream = obj.cameraStream;\n const videoElement = obj.videoElement;\n const videoWidth = obj.videoWidth;\n const videoHeight = obj.videoHeight;\n const cropDimensions = screenShot.getCropDimensions({\n videoWidth,\n videoHeight,\n gifHeight,\n gifWidth\n });\n const completeCallback = callback;\n options.crop = cropDimensions;\n options.videoElement = videoElement;\n options.videoWidth = videoWidth;\n options.videoHeight = videoHeight;\n options.cameraStream = cameraStream;\n if (!utils.isElement(videoElement)) {\n return;\n }\n videoElement.width = gifWidth + cropDimensions.width;\n videoElement.height = gifHeight + cropDimensions.height;\n if (!options.webcamVideoElement) {\n utils.setCSSAttr(videoElement, {\n position: 'fixed',\n opacity: '0'\n });\n document.body.appendChild(videoElement);\n }\n // Firefox doesn't seem to obey autoplay if the element is not in the DOM when the content\n // is loaded, so we must manually trigger play after adding it, or the video will be frozen\n videoElement.play();\n screenShot.getGIF(options, function (obj) {\n if ((!images || !images.length) && (!video || !video.length)) {\n stopVideoStreaming(obj);\n }\n completeCallback(obj);\n });\n}\n/*\n existingVideo.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction existingVideo() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const callback = obj.callback;\n let existingVideo = obj.existingVideo;\n const options = obj.options;\n const skipObj = {\n getUserMedia: true,\n 'globalThis.URL': true\n };\n const errorObj = error.validate(skipObj);\n const loadedImages = 0;\n let videoType = void 0;\n let videoSrc = void 0;\n const tempImage = void 0;\n const ag = void 0;\n if (errorObj.error) {\n return callback(errorObj);\n }\n if (utils.isElement(existingVideo) && existingVideo.src) {\n videoSrc = existingVideo.src;\n videoType = utils.getExtension(videoSrc);\n if (!utils.isSupported.videoCodecs[videoType]) {\n return callback(error.messages.videoCodecs);\n }\n }\n else if (utils.isArray(existingVideo)) {\n utils.each(existingVideo, function (iterator, videoSrc) {\n if (videoSrc instanceof Blob) {\n videoType = videoSrc.type.substr(videoSrc.type.lastIndexOf('/') + 1, videoSrc.length);\n }\n else {\n videoType = videoSrc.substr(videoSrc.lastIndexOf('.') + 1, videoSrc.length);\n }\n if (utils.isSupported.videoCodecs[videoType]) {\n existingVideo = videoSrc;\n return false;\n }\n });\n }\n videoStream.startStreaming({\n completed: function completed(obj) {\n obj.options = options || {};\n createAndGetGIF(obj, callback);\n },\n existingVideo,\n crossOrigin: options.crossOrigin,\n options\n });\n}\n/*\n existingWebcam.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction existingWebcam() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const callback = obj.callback;\n const lastCameraStream = obj.lastCameraStream;\n const options = obj.options;\n const webcamVideoElement = obj.webcamVideoElement;\n if (!isWebCamGIFSupported()) {\n return callback(error.validate());\n }\n if (options.savedRenderingContexts.length) {\n screenShot.getGIF(options, function (obj) {\n callback(obj);\n });\n return;\n }\n videoStream.startVideoStreaming(function () {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n obj.options = options || {};\n createAndGetGIF(obj, callback);\n }, {\n lastCameraStream,\n callback,\n webcamVideoElement,\n crossOrigin: options.crossOrigin\n });\n}\n/*\n createGIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction createGIF(userOptions, callback) {\n callback = utils.isFunction(userOptions) ? userOptions : callback;\n userOptions = utils.isObject(userOptions) ? userOptions : {};\n if (!utils.isFunction(callback)) {\n return;\n }\n let options = utils.normalizeOptions(defaultOptions, userOptions) || {};\n const lastCameraStream = userOptions.cameraStream;\n const images = options.images;\n const imagesLength = images ? images.length : 0;\n const video = options.video;\n const webcamVideoElement = options.webcamVideoElement;\n options = utils.normalizeOptions(options, {\n gifWidth: Math.floor(options.gifWidth),\n gifHeight: Math.floor(options.gifHeight)\n });\n // If the user would like to create a GIF from an existing image(s)\n if (imagesLength) {\n existingImages({\n images,\n imagesLength,\n callback,\n options\n });\n }\n else if (video) {\n // If the user would like to create a GIF from an existing HTML5 video\n existingVideo({\n existingVideo: video,\n callback,\n options\n });\n }\n else {\n // If the user would like to create a GIF from a webcam stream\n existingWebcam({\n lastCameraStream,\n callback,\n webcamVideoElement,\n options\n });\n }\n}\n/*\n takeSnapShot.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction takeSnapShot(userOptions, callback) {\n callback = utils.isFunction(userOptions) ? userOptions : callback;\n userOptions = utils.isObject(userOptions) ? userOptions : {};\n if (!utils.isFunction(callback)) {\n return;\n }\n const mergedOptions = utils.normalizeOptions(defaultOptions, userOptions);\n const options = utils.normalizeOptions(mergedOptions, {\n interval: 0.1,\n numFrames: 1,\n gifWidth: Math.floor(mergedOptions.gifWidth),\n gifHeight: Math.floor(mergedOptions.gifHeight)\n });\n createGIF(options, callback);\n}\n/*\n API.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nconst API = {\n utils: utils$2,\n error: error$2,\n defaultOptions: defaultOptions$2,\n createGIF,\n takeSnapShot,\n stopVideoStreaming,\n isSupported,\n isWebCamGIFSupported,\n isExistingVideoGIFSupported,\n isExistingImagesGIFSupported: isSupported$1,\n VERSION: '0.4.5'\n};\nexport default API;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// A GIFBuilder based on the gifshot module\n// @ts-nocheck\nimport { assert } from \"./lib/utils/assert.js\";\nimport gifshot from \"./lib/gifshot/gifshot.js\"; // TODO - load dynamically to avoid bloating\n// These are gifshot module options\nconst GIF_BUILDER_OPTIONS = {\n source: 'images',\n width: 200, // Desired width of the image\n height: 200, // Desired height of the image\n crossOrigin: 'Anonymous', // Options are 'Anonymous', 'use-credentials', or a falsy value to not set a CORS attribute.\n // CALLBACKS\n progressCallback: (captureProgress) => { }, // Callback that provides the current progress of the current image\n completeCallback: () => { }, // Callback function that is called when the current image is completed\n // QUALITY SETTINGS\n numWorkers: 2, // how many web workers to use to process the animated GIF frames. Default is 2.\n sampleInterval: 10, // pixels to skip when creating the palette. Default is 10. Less is better, but slower.\n interval: 0.1, // The amount of time (in seconds) to wait between each frame capture\n offset: null, // The amount of time (in seconds) to start capturing the GIF (only for HTML5 videos)\n numFrames: 10, // The number of frames to use to create the animated GIF. Note: Each frame is captured every 100 milliseconds of a video and every ms for existing images\n frameDuration: 1, // The amount of time (10 = 1s) to stay on each frame\n // CSS FILTER OPTIONS\n filter: '', // CSS filter that will be applied to the image (eg. blur(5px))\n // WATERMARK OPTIONS\n waterMark: null, // If an image is given here, it will be stamped on top of the GIF frames\n waterMarkHeight: null, // Height of the waterMark\n waterMarkWidth: null, // Height of the waterMark\n waterMarkXCoordinate: 1, // The X (horizontal) Coordinate of the watermark image\n waterMarkYCoordinate: 1, // The Y (vertical) Coordinate of the watermark image\n // TEXT OPTIONS\n text: '', // The text that covers the animated GIF\n showFrameText: true, // If frame-specific text is supplied with the image array, you can force to not be displayed\n fontWeight: 'normal', // The font weight of the text that covers the animated GIF\n fontSize: '16px', // The font size of the text that covers the animated GIF\n minFontSize: '10px', // The minimum font size of the text that covers the animated GIF\n resizeFont: false, // Whether or not the animated GIF text will be resized to fit within the GIF container\n fontFamily: 'sans-serif', // The font family of the text that covers the animated GIF\n fontColor: '#ffffff', // The font color of the text that covers the animated GIF\n textAlign: 'center', // The horizontal text alignment of the text that covers the animated GIF\n textBaseline: 'bottom', // The vertical text alignment of the text that covers the animated GIF\n textXCoordinate: null, // The X (horizontal) Coordinate of the text that covers the animated GIF\n textYCoordinate: null, // The Y (vertical) Coordinate of the text that covers the animated GIF\n // ADVANCED OPTIONS\n // WEBCAM CAPTURE OPTIONS\n webcamVideoElement: null, // You can pass an existing video element to use for the webcam GIF creation process,\n keepCameraOn: false, // Whether or not you would like the user's camera to stay on after the GIF is created\n cameraStream: null, // Expects a cameraStream Media object\n // CANVAS OPTIMIZATION OPTIONS\n saveRenderingContexts: false, // Whether or not you would like to save all of the canvas image binary data\n savedRenderingContexts: [] // Array of canvas image data\n};\nexport default class GIFBuilder {\n static get properties() {\n return {\n id: 'gif',\n name: 'GIF',\n extensions: ['gif'],\n mimeTypes: ['image/gif'],\n builder: GIFBuilder,\n options: GIF_BUILDER_OPTIONS\n };\n }\n constructor(options) {\n this.options = { ...options };\n this.source = options.source;\n delete options.source;\n // Allow files to be added\n this.files = [];\n // Expose the gifshot module so that the full gifshot API is available to apps (Experimental)\n this.gifshot = gifshot;\n }\n async initialize(options) {\n // Expose the gifshot module so that the full gifshot API is available to apps (Experimental)\n // this.gifshot = await loadGifshotModule(options);\n }\n async add(file) {\n await this.initialize();\n this.files.push(file);\n }\n async build() {\n await this.initialize();\n this._cleanOptions(this.options);\n switch (this.source) {\n case 'images':\n this.options.images = this.files;\n break;\n case 'video':\n this.options.video = this.files;\n break;\n case 'webcam':\n assert(this.files.length === 0);\n break;\n default:\n throw new Error('GIFBuilder: invalid source');\n }\n return await this._createGIF();\n }\n // PRIVATE\n async _createGIF() {\n return new Promise((resolve, reject) => {\n this.gifshot.createGIF(this.options, (result) => {\n // callback object properties\n // --------------------------\n // image - Base 64 image\n // cameraStream - The webRTC MediaStream object\n // error - Boolean that determines if an error occurred\n // errorCode - Helpful error label\n // errorMsg - Helpful error message\n // savedRenderingContexts - An array of canvas image data (will only be set if the saveRenderingContexts option was used)\n if (result.error) {\n reject(result.errorMsg);\n return;\n }\n // image - Base 64 image\n resolve(result.image);\n // var image = obj.image,\n // animatedImage = document.createElement('img');\n // animatedImage.src = image;\n // document.body.appendChild(animatedImage);\n });\n });\n }\n // Remove some gifshot options\n _cleanOptions(options) {\n if (options.video || options.images || options.gifWidth || options.gifHeight) {\n console.warn('GIFBuilder: ignoring options'); // eslint-disable-line\n }\n // We control these through options.source instead\n delete options.video;\n delete options.images;\n // Use width/height props (to standardize across builders)\n options.gifWidth = options.width;\n options.gifHeight = options.height;\n delete options.width;\n delete options.height;\n }\n}\n"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { VideoLoader } from \"./video-loader.js\";\nexport { default as GIFBuilder } from \"./gif-builder.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Parse to platform defined video type (HTMLVideoElement in browser)\nexport default async function parseVideo(arrayBuffer) {\n // TODO It is probably somewhat inefficent to convert a File/Blob to ArrayBuffer and back\n // and could perhaps cause problems for large videos.\n // TODO MIME type is also lost from the File or Response...\n const blob = new Blob([arrayBuffer]);\n const video = document.createElement('video');\n video.src = URL.createObjectURL(blob);\n return video;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport parseVideo from \"./lib/parsers/parse-video.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.3\" !== 'undefined' ? \"4.3.3\" : 'latest';\n/**\n * Loads a platform-specific image type that can be used as input data to WebGL textures\n */\nexport const VideoLoader = {\n dataType: null,\n batchType: null,\n name: 'Video',\n id: 'video',\n module: 'video',\n version: VERSION,\n extensions: ['mp4'],\n mimeTypes: ['video/mp4'],\n // tests: arrayBuffer => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer))),\n options: {\n video: {}\n },\n parse: parseVideo\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport function assert(condition, message) {\n if (!condition) {\n throw new Error(message);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// @ts-nocheck\n/* eslint-disable */\nconst document = globalThis.document || {};\n/* Copyrights for code authored by Yahoo Inc. is licensed under the following terms:\nMIT License\nCopyright 2017 Yahoo Inc.\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n/*\n utils.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nvar utils = {\n URL: globalThis.URL || globalThis.webkitURL || globalThis.mozURL || globalThis.msURL,\n getUserMedia: (function () {\n if (!globalThis.navigator)\n return globalThis.navigator;\n const getUserMedia = globalThis.navigator.getUserMedia ||\n globalThis.navigator.webkitGetUserMedia ||\n globalThis.navigator.mozGetUserMedia ||\n globalThis.navigator.msGetUserMedia;\n return getUserMedia ? getUserMedia.bind(globalThis.navigator) : getUserMedia;\n })(),\n requestAnimFrame: globalThis.requestAnimationFrame ||\n globalThis.webkitRequestAnimationFrame ||\n globalThis.mozRequestAnimationFrame ||\n globalThis.oRequestAnimationFrame ||\n globalThis.msRequestAnimationFrame,\n requestTimeout: function requestTimeout(callback, delay) {\n callback = callback || utils.noop;\n delay = delay || 0;\n if (!utils.requestAnimFrame) {\n return setTimeout(callback, delay);\n }\n const start = new Date().getTime();\n const handle = new Object();\n const requestAnimFrame = utils.requestAnimFrame;\n const loop = function loop() {\n const current = new Date().getTime();\n const delta = current - start;\n delta >= delay ? callback.call() : (handle.value = requestAnimFrame(loop));\n };\n handle.value = requestAnimFrame(loop);\n return handle;\n },\n Blob: globalThis.Blob ||\n globalThis.BlobBuilder ||\n globalThis.WebKitBlobBuilder ||\n globalThis.MozBlobBuilder ||\n globalThis.MSBlobBuilder,\n btoa: (function () {\n const btoa = globalThis.btoa ||\n function (input) {\n let output = '';\n let i = 0;\n const l = input.length;\n const key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';\n let chr1 = void 0;\n let chr2 = void 0;\n let chr3 = void 0;\n let enc1 = void 0;\n let enc2 = void 0;\n let enc3 = void 0;\n let enc4 = void 0;\n while (i < l) {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n }\n else if (isNaN(chr3)) {\n enc4 = 64;\n }\n output =\n output + key.charAt(enc1) + key.charAt(enc2) + key.charAt(enc3) + key.charAt(enc4);\n }\n return output;\n };\n return btoa ? btoa.bind(globalThis) : utils.noop;\n })(),\n isObject: function isObject(obj) {\n return obj && Object.prototype.toString.call(obj) === '[object Object]';\n },\n isEmptyObject: function isEmptyObject(obj) {\n return utils.isObject(obj) && !Object.keys(obj).length;\n },\n isArray: function isArray(arr) {\n return arr && Array.isArray(arr);\n },\n isFunction: function isFunction(func) {\n return func && typeof func === 'function';\n },\n isElement: function isElement(elem) {\n return elem && elem.nodeType === 1;\n },\n isString: function isString(value) {\n return typeof value === 'string' || Object.prototype.toString.call(value) === '[object String]';\n },\n isSupported: {\n canvas: function canvas() {\n const el = document.createElement('canvas');\n return el && el.getContext && el.getContext('2d');\n },\n webworkers: function webworkers() {\n return globalThis.Worker;\n },\n blob: function blob() {\n return utils.Blob;\n },\n Uint8Array: function Uint8Array() {\n return globalThis.Uint8Array;\n },\n Uint32Array: function Uint32Array() {\n return globalThis.Uint32Array;\n },\n videoCodecs: (function () {\n const testEl = document.createElement('video');\n const supportObj = {\n mp4: false,\n h264: false,\n ogv: false,\n ogg: false,\n webm: false\n };\n try {\n if (testEl && testEl.canPlayType) {\n // Check for MPEG-4 support\n supportObj.mp4 = testEl.canPlayType('video/mp4; codecs=\"mp4v.20.8\"') !== '';\n // Check for h264 support\n supportObj.h264 =\n (testEl.canPlayType('video/mp4; codecs=\"avc1.42E01E\"') ||\n testEl.canPlayType('video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"')) !== '';\n // Check for Ogv support\n supportObj.ogv = testEl.canPlayType('video/ogg; codecs=\"theora\"') !== '';\n // Check for Ogg support\n supportObj.ogg = testEl.canPlayType('video/ogg; codecs=\"theora\"') !== '';\n // Check for Webm support\n supportObj.webm = testEl.canPlayType('video/webm; codecs=\"vp8, vorbis\"') !== -1;\n }\n }\n catch (e) { }\n return supportObj;\n })()\n },\n noop: function noop() { },\n each: function each(collection, callback) {\n let x = void 0;\n let len = void 0;\n if (utils.isArray(collection)) {\n x = -1;\n len = collection.length;\n while (++x < len) {\n if (callback(x, collection[x]) === false) {\n break;\n }\n }\n }\n else if (utils.isObject(collection)) {\n for (x in collection) {\n if (collection.hasOwnProperty(x)) {\n if (callback(x, collection[x]) === false) {\n break;\n }\n }\n }\n }\n },\n normalizeOptions: function normalizeOptions(defaultOptions, userOptions) {\n if (!utils.isObject(defaultOptions) || !utils.isObject(userOptions) || !Object.keys) {\n return;\n }\n const newObj = {};\n utils.each(defaultOptions, function (key, val) {\n newObj[key] = defaultOptions[key];\n });\n utils.each(userOptions, function (key, val) {\n const currentUserOption = userOptions[key];\n if (!utils.isObject(currentUserOption)) {\n newObj[key] = currentUserOption;\n }\n else if (!defaultOptions[key]) {\n newObj[key] = currentUserOption;\n }\n else {\n newObj[key] = utils.normalizeOptions(defaultOptions[key], currentUserOption);\n }\n });\n return newObj;\n },\n setCSSAttr: function setCSSAttr(elem, attr, val) {\n if (!utils.isElement(elem)) {\n return;\n }\n if (utils.isString(attr) && utils.isString(val)) {\n elem.style[attr] = val;\n }\n else if (utils.isObject(attr)) {\n utils.each(attr, function (key, val) {\n elem.style[key] = val;\n });\n }\n },\n removeElement: function removeElement(node) {\n if (!utils.isElement(node)) {\n return;\n }\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n },\n createWebWorker: function createWebWorker(content) {\n if (!utils.isString(content)) {\n return {};\n }\n try {\n const blob = new utils.Blob([content], {\n type: 'text/javascript'\n });\n const objectUrl = utils.URL.createObjectURL(blob);\n const worker = new Worker(objectUrl);\n return {\n objectUrl,\n worker\n };\n }\n catch (e) {\n return `${e}`;\n }\n },\n getExtension: function getExtension(src) {\n return src.substr(src.lastIndexOf('.') + 1, src.length);\n },\n getFontSize: function getFontSize() {\n const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (!document.body || options.resizeFont === false) {\n return options.fontSize;\n }\n const text = options.text;\n const containerWidth = options.gifWidth;\n let fontSize = parseInt(options.fontSize, 10);\n const minFontSize = parseInt(options.minFontSize, 10);\n const div = document.createElement('div');\n const span = document.createElement('span');\n div.setAttribute('width', containerWidth);\n div.appendChild(span);\n span.innerHTML = text;\n span.style.fontSize = `${fontSize}px`;\n span.style.textIndent = '-9999px';\n span.style.visibility = 'hidden';\n document.body.appendChild(span);\n while (span.offsetWidth > containerWidth && fontSize >= minFontSize) {\n span.style.fontSize = `${--fontSize}px`;\n }\n document.body.removeChild(span);\n return `${fontSize}px`;\n },\n webWorkerError: false\n};\nconst utils$2 = Object.freeze({\n default: utils\n});\n/*\n error.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nvar error = {\n validate: function validate(skipObj) {\n skipObj = utils.isObject(skipObj) ? skipObj : {};\n let errorObj = {};\n utils.each(error.validators, function (indece, currentValidator) {\n const errorCode = currentValidator.errorCode;\n if (!skipObj[errorCode] && !currentValidator.condition) {\n errorObj = currentValidator;\n errorObj.error = true;\n return false;\n }\n });\n delete errorObj.condition;\n return errorObj;\n },\n isValid: function isValid(skipObj) {\n const errorObj = error.validate(skipObj);\n const isValid = errorObj.error !== true;\n return isValid;\n },\n validators: [\n {\n condition: utils.isFunction(utils.getUserMedia),\n errorCode: 'getUserMedia',\n errorMsg: 'The getUserMedia API is not supported in your browser'\n },\n {\n condition: utils.isSupported.canvas(),\n errorCode: 'canvas',\n errorMsg: 'Canvas elements are not supported in your browser'\n },\n {\n condition: utils.isSupported.webworkers(),\n errorCode: 'webworkers',\n errorMsg: 'The Web Workers API is not supported in your browser'\n },\n {\n condition: utils.isFunction(utils.URL),\n errorCode: 'globalThis.URL',\n errorMsg: 'The globalThis.URL API is not supported in your browser'\n },\n {\n condition: utils.isSupported.blob(),\n errorCode: 'globalThis.Blob',\n errorMsg: 'The globalThis.Blob File API is not supported in your browser'\n },\n {\n condition: utils.isSupported.Uint8Array(),\n errorCode: 'globalThis.Uint8Array',\n errorMsg: 'The globalThis.Uint8Array function constructor is not supported in your browser'\n },\n {\n condition: utils.isSupported.Uint32Array(),\n errorCode: 'globalThis.Uint32Array',\n errorMsg: 'The globalThis.Uint32Array function constructor is not supported in your browser'\n }\n ],\n messages: {\n videoCodecs: {\n errorCode: 'videocodec',\n errorMsg: 'The video codec you are trying to use is not supported in your browser'\n }\n }\n};\nconst error$2 = Object.freeze({\n default: error\n});\n/*\n defaultOptions.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Helpers\nconst noop = function noop() { };\nconst defaultOptions = {\n sampleInterval: 10,\n numWorkers: 2,\n filter: '',\n gifWidth: 200,\n gifHeight: 200,\n interval: 0.1,\n numFrames: 10,\n frameDuration: 1,\n keepCameraOn: false,\n images: [],\n video: null,\n webcamVideoElement: null,\n cameraStream: null,\n text: '',\n fontWeight: 'normal',\n fontSize: '16px',\n minFontSize: '10px',\n resizeFont: false,\n fontFamily: 'sans-serif',\n fontColor: '#ffffff',\n textAlign: 'center',\n textBaseline: 'bottom',\n textXCoordinate: null,\n textYCoordinate: null,\n progressCallback: noop,\n completeCallback: noop,\n saveRenderingContexts: false,\n savedRenderingContexts: [],\n crossOrigin: 'Anonymous'\n};\nconst defaultOptions$2 = Object.freeze({\n default: defaultOptions\n});\n/*\n isSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction isSupported() {\n return error.isValid();\n}\n/*\n isWebCamGIFSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction isWebCamGIFSupported() {\n return error.isValid();\n}\n/*\n isSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction isSupported$1() {\n const options = {\n getUserMedia: true\n };\n return error.isValid(options);\n}\n/*\n isExistingVideoGIFSupported.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction isExistingVideoGIFSupported(codecs) {\n let hasValidCodec = false;\n if (utils.isArray(codecs) && codecs.length) {\n utils.each(codecs, function (indece, currentCodec) {\n if (utils.isSupported.videoCodecs[currentCodec]) {\n hasValidCodec = true;\n }\n });\n if (!hasValidCodec) {\n return false;\n }\n }\n else if (utils.isString(codecs) && codecs.length) {\n if (!utils.isSupported.videoCodecs[codecs]) {\n return false;\n }\n }\n return error.isValid({\n getUserMedia: true\n });\n}\n/*\n NeuQuant.js\n */\n/*\n * NeuQuant Neural-Net Quantization Algorithm\n * ------------------------------------------\n *\n * Copyright (c) 1994 Anthony Dekker\n *\n * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See\n * \"Kohonen neural networks for optimal colour quantization\" in \"Network:\n * Computation in Neural Systems\" Vol. 5 (1994) pp 351-367. for a discussion of\n * the algorithm.\n *\n * Any party obtaining a copy of these files from the author, directly or\n * indirectly, is granted, free of charge, a full and unrestricted irrevocable,\n * world-wide, paid up, royalty-free, nonexclusive right and license to deal in\n * this software and documentation files (the \"Software\"), including without\n * limitation the rights to use, copy, modify, merge, publish, distribute,\n * sublicense, and/or sell copies of the Software, and to permit persons who\n * receive copies from any such party to do so, with the only requirement being\n * that this copyright notice remain intact.\n */\n/*\n * This class handles Neural-Net quantization algorithm\n * @author Kevin Weiner (original Java version - kweiner@fmsware.com)\n * @author Thibault Imbert (AS3 version - bytearray.org)\n * @version 0.1 AS3 implementation\n * @version 0.2 JS->AS3 \"translation\" by antimatter15\n * @version 0.3 JS clean up + using modern JS idioms by sole - http://soledadpenades.com\n * Also implement fix in color conversion described at http://stackoverflow.com/questions/16371712/neuquant-js-javascript-color-quantization-hidden-bug-in-js-conversion\n */\nfunction NeuQuant() {\n const netsize = 256; // number of colours used\n // four primes near 500 - assume no image has a length so large\n // that it is divisible by all four primes\n const prime1 = 499;\n const prime2 = 491;\n const prime3 = 487;\n const prime4 = 503;\n // minimum size for input image\n const minpicturebytes = 3 * prime4;\n // Network Definitions\n const maxnetpos = netsize - 1;\n const netbiasshift = 4; // bias for colour values\n const ncycles = 100; // no. of learning cycles\n // defs for freq and bias\n const intbiasshift = 16; // bias for fractions\n const intbias = 1 << intbiasshift;\n const gammashift = 10; // gamma = 1024\n const gamma = 1 << gammashift;\n const betashift = 10;\n const beta = intbias >> betashift; // beta = 1/1024\n const betagamma = intbias << (gammashift - betashift);\n // defs for decreasing radius factor\n // For 256 colors, radius starts at 32.0 biased by 6 bits\n // and decreases by a factor of 1/30 each cycle\n const initrad = netsize >> 3;\n const radiusbiasshift = 6;\n const radiusbias = 1 << radiusbiasshift;\n const initradius = initrad * radiusbias;\n const radiusdec = 30;\n // defs for decreasing alpha factor\n // Alpha starts at 1.0 biased by 10 bits\n const alphabiasshift = 10;\n const initalpha = 1 << alphabiasshift;\n let alphadec;\n // radbias and alpharadbias used for radpower calculation\n const radbiasshift = 8;\n const radbias = 1 << radbiasshift;\n const alpharadbshift = alphabiasshift + radbiasshift;\n const alpharadbias = 1 << alpharadbshift;\n // Input image\n let thepicture;\n // Height * Width * 3\n let lengthcount;\n // Sampling factor 1..30\n let samplefac;\n // The network itself\n let network;\n const netindex = [];\n // for network lookup - really 256\n const bias = [];\n // bias and freq arrays for learning\n const freq = [];\n const radpower = [];\n function NeuQuantConstructor(thepic, len, sample) {\n let i;\n let p;\n thepicture = thepic;\n lengthcount = len;\n samplefac = sample;\n network = new Array(netsize);\n for (i = 0; i < netsize; i++) {\n network[i] = new Array(4);\n p = network[i];\n p[0] = p[1] = p[2] = ((i << (netbiasshift + 8)) / netsize) | 0;\n freq[i] = (intbias / netsize) | 0; // 1 / netsize\n bias[i] = 0;\n }\n }\n function colorMap() {\n const map = [];\n const index = new Array(netsize);\n for (let i = 0; i < netsize; i++) {\n index[network[i][3]] = i;\n }\n let k = 0;\n for (let l = 0; l < netsize; l++) {\n const j = index[l];\n map[k++] = network[j][0];\n map[k++] = network[j][1];\n map[k++] = network[j][2];\n }\n return map;\n }\n // Insertion sort of network and building of netindex[0..255]\n // (to do after unbias)\n function inxbuild() {\n let i;\n let j;\n let smallpos;\n let smallval;\n let p;\n let q;\n let previouscol;\n let startpos;\n previouscol = 0;\n startpos = 0;\n for (i = 0; i < netsize; i++) {\n p = network[i];\n smallpos = i;\n smallval = p[1]; // index on g\n // find smallest in i..netsize-1\n for (j = i + 1; j < netsize; j++) {\n q = network[j];\n if (q[1] < smallval) {\n // index on g\n smallpos = j;\n smallval = q[1]; // index on g\n }\n }\n q = network[smallpos];\n // swap p (i) and q (smallpos) entries\n if (i != smallpos) {\n j = q[0];\n q[0] = p[0];\n p[0] = j;\n j = q[1];\n q[1] = p[1];\n p[1] = j;\n j = q[2];\n q[2] = p[2];\n p[2] = j;\n j = q[3];\n q[3] = p[3];\n p[3] = j;\n }\n // smallval entry is now in position i\n if (smallval != previouscol) {\n netindex[previouscol] = (startpos + i) >> 1;\n for (j = previouscol + 1; j < smallval; j++) {\n netindex[j] = i;\n }\n previouscol = smallval;\n startpos = i;\n }\n }\n netindex[previouscol] = (startpos + maxnetpos) >> 1;\n for (j = previouscol + 1; j < 256; j++) {\n netindex[j] = maxnetpos; // really 256\n }\n }\n // Main Learning Loop\n function learn() {\n let i;\n let j;\n let b;\n let g;\n let r;\n let radius;\n let rad;\n let alpha;\n let step;\n let delta;\n let samplepixels;\n let p;\n let pix;\n let lim;\n if (lengthcount < minpicturebytes) {\n samplefac = 1;\n }\n alphadec = 30 + (samplefac - 1) / 3;\n p = thepicture;\n pix = 0;\n lim = lengthcount;\n samplepixels = lengthcount / (3 * samplefac);\n delta = (samplepixels / ncycles) | 0;\n alpha = initalpha;\n radius = initradius;\n rad = radius >> radiusbiasshift;\n if (rad <= 1) {\n rad = 0;\n }\n for (i = 0; i < rad; i++) {\n radpower[i] = alpha * (((rad * rad - i * i) * radbias) / (rad * rad));\n }\n if (lengthcount < minpicturebytes) {\n step = 3;\n }\n else if (lengthcount % prime1 !== 0) {\n step = 3 * prime1;\n }\n else if (lengthcount % prime2 !== 0) {\n step = 3 * prime2;\n }\n else if (lengthcount % prime3 !== 0) {\n step = 3 * prime3;\n }\n else {\n step = 3 * prime4;\n }\n i = 0;\n while (i < samplepixels) {\n b = (p[pix + 0] & 0xff) << netbiasshift;\n g = (p[pix + 1] & 0xff) << netbiasshift;\n r = (p[pix + 2] & 0xff) << netbiasshift;\n j = contest(b, g, r);\n altersingle(alpha, j, b, g, r);\n if (rad !== 0) {\n // Alter neighbours\n alterneigh(rad, j, b, g, r);\n }\n pix += step;\n if (pix >= lim) {\n pix -= lengthcount;\n }\n i++;\n if (delta === 0) {\n delta = 1;\n }\n if (i % delta === 0) {\n alpha -= alpha / alphadec;\n radius -= radius / radiusdec;\n rad = radius >> radiusbiasshift;\n if (rad <= 1) {\n rad = 0;\n }\n for (j = 0; j < rad; j++) {\n radpower[j] = alpha * (((rad * rad - j * j) * radbias) / (rad * rad));\n }\n }\n }\n }\n // Search for BGR values 0..255 (after net is unbiased) and return colour index\n function map(b, g, r) {\n let i;\n let j;\n let dist;\n let a;\n let bestd;\n let p;\n let best;\n // Biggest possible distance is 256 * 3\n bestd = 1000;\n best = -1;\n i = netindex[g]; // index on g\n j = i - 1; // start at netindex[g] and work outwards\n while (i < netsize || j >= 0) {\n if (i < netsize) {\n p = network[i];\n dist = p[1] - g; // inx key\n if (dist >= bestd) {\n i = netsize; // stop iter\n }\n else {\n i++;\n if (dist < 0) {\n dist = -dist;\n }\n a = p[0] - b;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n a = p[2] - r;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n bestd = dist;\n best = p[3];\n }\n }\n }\n }\n if (j >= 0) {\n p = network[j];\n dist = g - p[1]; // inx key - reverse dif\n if (dist >= bestd) {\n j = -1; // stop iter\n }\n else {\n j--;\n if (dist < 0) {\n dist = -dist;\n }\n a = p[0] - b;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n a = p[2] - r;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n bestd = dist;\n best = p[3];\n }\n }\n }\n }\n }\n return best;\n }\n function process() {\n learn();\n unbiasnet();\n inxbuild();\n return colorMap();\n }\n // Unbias network to give byte values 0..255 and record position i\n // to prepare for sort\n function unbiasnet() {\n let i;\n let j;\n for (i = 0; i < netsize; i++) {\n network[i][0] >>= netbiasshift;\n network[i][1] >>= netbiasshift;\n network[i][2] >>= netbiasshift;\n network[i][3] = i; // record colour no\n }\n }\n // Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2))\n // in radpower[|i-j|]\n function alterneigh(rad, i, b, g, r) {\n let j;\n let k;\n let lo;\n let hi;\n let a;\n let m;\n let p;\n lo = i - rad;\n if (lo < -1) {\n lo = -1;\n }\n hi = i + rad;\n if (hi > netsize) {\n hi = netsize;\n }\n j = i + 1;\n k = i - 1;\n m = 1;\n while (j < hi || k > lo) {\n a = radpower[m++];\n if (j < hi) {\n p = network[j++];\n try {\n p[0] -= ((a * (p[0] - b)) / alpharadbias) | 0;\n p[1] -= ((a * (p[1] - g)) / alpharadbias) | 0;\n p[2] -= ((a * (p[2] - r)) / alpharadbias) | 0;\n }\n catch (e) { }\n }\n if (k > lo) {\n p = network[k--];\n try {\n p[0] -= ((a * (p[0] - b)) / alpharadbias) | 0;\n p[1] -= ((a * (p[1] - g)) / alpharadbias) | 0;\n p[2] -= ((a * (p[2] - r)) / alpharadbias) | 0;\n }\n catch (e) { }\n }\n }\n }\n // Move neuron i towards biased (b,g,r) by factor alpha\n function altersingle(alpha, i, b, g, r) {\n // alter hit neuron\n const n = network[i];\n const alphaMult = alpha / initalpha;\n n[0] -= (alphaMult * (n[0] - b)) | 0;\n n[1] -= (alphaMult * (n[1] - g)) | 0;\n n[2] -= (alphaMult * (n[2] - r)) | 0;\n }\n // Search for biased BGR values\n function contest(b, g, r) {\n // finds closest neuron (min dist) and updates freq\n // finds best neuron (min dist-bias) and returns position\n // for frequently chosen neurons, freq[i] is high and bias[i] is negative\n // bias[i] = gamma*((1/netsize)-freq[i])\n let i;\n let dist;\n let a;\n let biasdist;\n let betafreq;\n let bestpos;\n let bestbiaspos;\n let bestd;\n let bestbiasd;\n let n;\n bestd = ~(1 << 31);\n bestbiasd = bestd;\n bestpos = -1;\n bestbiaspos = bestpos;\n for (i = 0; i < netsize; i++) {\n n = network[i];\n dist = n[0] - b;\n if (dist < 0) {\n dist = -dist;\n }\n a = n[1] - g;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n a = n[2] - r;\n if (a < 0) {\n a = -a;\n }\n dist += a;\n if (dist < bestd) {\n bestd = dist;\n bestpos = i;\n }\n biasdist = dist - (bias[i] >> (intbiasshift - netbiasshift));\n if (biasdist < bestbiasd) {\n bestbiasd = biasdist;\n bestbiaspos = i;\n }\n betafreq = freq[i] >> betashift;\n freq[i] -= betafreq;\n bias[i] += betafreq << gammashift;\n }\n freq[bestpos] += beta;\n bias[bestpos] -= betagamma;\n return bestbiaspos;\n }\n NeuQuantConstructor.apply(this, arguments);\n const exports = {};\n exports.map = map;\n exports.process = process;\n return exports;\n}\n/*\n processFrameWorker.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction workerCode() {\n const self = this;\n try {\n globalThis.onmessage = function (ev) {\n const data = ev.data || {};\n let response;\n if (data.gifshot) {\n response = workerMethods.run(data);\n postMessage(response);\n }\n };\n }\n catch (e) { }\n var workerMethods = {\n dataToRGB: function dataToRGB(data, width, height) {\n const length = width * height * 4;\n let i = 0;\n const rgb = [];\n while (i < length) {\n rgb.push(data[i++]);\n rgb.push(data[i++]);\n rgb.push(data[i++]);\n i++; // for the alpha channel which we don't care about\n }\n return rgb;\n },\n componentizedPaletteToArray: function componentizedPaletteToArray(paletteRGB) {\n paletteRGB = paletteRGB || [];\n const paletteArray = [];\n for (let i = 0; i < paletteRGB.length; i += 3) {\n const r = paletteRGB[i];\n const g = paletteRGB[i + 1];\n const b = paletteRGB[i + 2];\n paletteArray.push((r << 16) | (g << 8) | b);\n }\n return paletteArray;\n },\n // This is the \"traditional\" Animated_GIF style of going from RGBA to indexed color frames\n processFrameWithQuantizer: function processFrameWithQuantizer(imageData, width, height, sampleInterval) {\n const rgbComponents = this.dataToRGB(imageData, width, height);\n const nq = new NeuQuant(rgbComponents, rgbComponents.length, sampleInterval);\n const paletteRGB = nq.process();\n const paletteArray = new Uint32Array(this.componentizedPaletteToArray(paletteRGB));\n const numberPixels = width * height;\n const indexedPixels = new Uint8Array(numberPixels);\n let k = 0;\n for (let i = 0; i < numberPixels; i++) {\n const r = rgbComponents[k++];\n const g = rgbComponents[k++];\n const b = rgbComponents[k++];\n indexedPixels[i] = nq.map(r, g, b);\n }\n return {\n pixels: indexedPixels,\n palette: paletteArray\n };\n },\n run: function run(frame) {\n frame = frame || {};\n const _frame = frame;\n const height = _frame.height;\n const palette = _frame.palette;\n const sampleInterval = _frame.sampleInterval;\n const width = _frame.width;\n const imageData = frame.data;\n return this.processFrameWithQuantizer(imageData, width, height, sampleInterval);\n }\n };\n return workerMethods;\n}\n/*\n gifWriter.js\n */\n// (c) Dean McNamee <dean@gmail.com>, 2013.\n//\n// https://github.com/deanm/omggif\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n// IN THE SOFTWARE.\n//\n// omggif is a JavaScript implementation of a GIF 89a encoder and decoder,\n// including animation and compression. It does not rely on any specific\n// underlying system, so should run in the browser, Node, or Plask.\nfunction gifWriter(buf, width, height, gopts) {\n let p = 0;\n gopts = gopts === undefined ? {} : gopts;\n const loop_count = gopts.loop === undefined ? null : gopts.loop;\n const global_palette = gopts.palette === undefined ? null : gopts.palette;\n if (width <= 0 || height <= 0 || width > 65535 || height > 65535)\n throw 'Width/Height invalid.';\n function check_palette_and_num_colors(palette) {\n const num_colors = palette.length;\n if (num_colors < 2 || num_colors > 256 || num_colors & (num_colors - 1))\n throw 'Invalid code/color length, must be power of 2 and 2 .. 256.';\n return num_colors;\n }\n // - Header.\n buf[p++] = 0x47;\n buf[p++] = 0x49;\n buf[p++] = 0x46; // GIF\n buf[p++] = 0x38;\n buf[p++] = 0x39;\n buf[p++] = 0x61; // 89a\n // Handling of Global Color Table (palette) and background index.\n const gp_num_colors_pow2 = 0;\n const background = 0;\n // - Logical Screen Descriptor.\n // NOTE(deanm): w/h apparently ignored by implementations, but set anyway.\n buf[p++] = width & 0xff;\n buf[p++] = (width >> 8) & 0xff;\n buf[p++] = height & 0xff;\n buf[p++] = (height >> 8) & 0xff;\n // NOTE: Indicates 0-bpp original color resolution (unused?).\n buf[p++] =\n (global_palette !== null ? 0x80 : 0) | // Global Color Table Flag.\n gp_num_colors_pow2; // NOTE: No sort flag (unused?).\n buf[p++] = background; // Background Color Index.\n buf[p++] = 0; // Pixel aspect ratio (unused?).\n if (loop_count !== null) {\n // Netscape block for looping.\n if (loop_count < 0 || loop_count > 65535)\n throw 'Loop count invalid.';\n // Extension code, label, and length.\n buf[p++] = 0x21;\n buf[p++] = 0xff;\n buf[p++] = 0x0b;\n // NETSCAPE2.0\n buf[p++] = 0x4e;\n buf[p++] = 0x45;\n buf[p++] = 0x54;\n buf[p++] = 0x53;\n buf[p++] = 0x43;\n buf[p++] = 0x41;\n buf[p++] = 0x50;\n buf[p++] = 0x45;\n buf[p++] = 0x32;\n buf[p++] = 0x2e;\n buf[p++] = 0x30;\n // Sub-block\n buf[p++] = 0x03;\n buf[p++] = 0x01;\n buf[p++] = loop_count & 0xff;\n buf[p++] = (loop_count >> 8) & 0xff;\n buf[p++] = 0x00; // Terminator.\n }\n let ended = false;\n this.addFrame = function (x, y, w, h, indexed_pixels, opts) {\n if (ended === true) {\n --p;\n ended = false;\n } // Un-end.\n opts = opts === undefined ? {} : opts;\n // TODO(deanm): Bounds check x, y. Do they need to be within the virtual\n // canvas width/height, I imagine?\n if (x < 0 || y < 0 || x > 65535 || y > 65535)\n throw 'x/y invalid.';\n if (w <= 0 || h <= 0 || w > 65535 || h > 65535)\n throw 'Width/Height invalid.';\n if (indexed_pixels.length < w * h)\n throw 'Not enough pixels for the frame size.';\n let using_local_palette = true;\n let palette = opts.palette;\n if (palette === undefined || palette === null) {\n using_local_palette = false;\n palette = global_palette;\n }\n if (palette === undefined || palette === null)\n throw 'Must supply either a local or global palette.';\n let num_colors = check_palette_and_num_colors(palette);\n // Compute the min_code_size (power of 2), destroying num_colors.\n let min_code_size = 0;\n while ((num_colors >>= 1)) {\n ++min_code_size;\n }\n num_colors = 1 << min_code_size; // Now we can easily get it back.\n const delay = opts.delay === undefined ? 0 : opts.delay;\n // From the spec:\n // 0 - No disposal specified. The decoder is\n // not required to take any action.\n // 1 - Do not dispose. The graphic is to be left\n // in place.\n // 2 - Restore to background color. The area used by the\n // graphic must be restored to the background color.\n // 3 - Restore to previous. The decoder is required to\n // restore the area overwritten by the graphic with\n // what was there prior to rendering the graphic.\n // 4-7 - To be defined.\n // NOTE(deanm): Dispose background doesn't really work, apparently most\n // browsers ignore the background palette index and clear to transparency.\n const disposal = opts.disposal === undefined ? 0 : opts.disposal;\n if (disposal < 0 || disposal > 3)\n // 4-7 is reserved.\n throw 'Disposal out of range.';\n let use_transparency = false;\n let transparent_index = 0;\n if (opts.transparent !== undefined && opts.transparent !== null) {\n use_transparency = true;\n transparent_index = opts.transparent;\n if (transparent_index < 0 || transparent_index >= num_colors)\n throw 'Transparent color index.';\n }\n if (disposal !== 0 || use_transparency || delay !== 0) {\n // - Graphics Control Extension\n buf[p++] = 0x21;\n buf[p++] = 0xf9; // Extension / Label.\n buf[p++] = 4; // Byte size.\n buf[p++] = (disposal << 2) | (use_transparency === true ? 1 : 0);\n buf[p++] = delay & 0xff;\n buf[p++] = (delay >> 8) & 0xff;\n buf[p++] = transparent_index; // Transparent color index.\n buf[p++] = 0; // Block Terminator.\n }\n // - Image Descriptor\n buf[p++] = 0x2c; // Image Seperator.\n buf[p++] = x & 0xff;\n buf[p++] = (x >> 8) & 0xff; // Left.\n buf[p++] = y & 0xff;\n buf[p++] = (y >> 8) & 0xff; // Top.\n buf[p++] = w & 0xff;\n buf[p++] = (w >> 8) & 0xff;\n buf[p++] = h & 0xff;\n buf[p++] = (h >> 8) & 0xff;\n // NOTE: No sort flag (unused?).\n // TODO(deanm): Support interlace.\n buf[p++] = using_local_palette === true ? 0x80 | (min_code_size - 1) : 0;\n // - Local Color Table\n if (using_local_palette === true) {\n for (let i = 0, il = palette.length; i < il; ++i) {\n const rgb = palette[i];\n buf[p++] = (rgb >> 16) & 0xff;\n buf[p++] = (rgb >> 8) & 0xff;\n buf[p++] = rgb & 0xff;\n }\n }\n p = GifWriterOutputLZWCodeStream(buf, p, min_code_size < 2 ? 2 : min_code_size, indexed_pixels);\n };\n this.end = function () {\n if (ended === false) {\n buf[p++] = 0x3b; // Trailer.\n ended = true;\n }\n return p;\n };\n // Main compression routine, palette indexes -> LZW code stream.\n // |index_stream| must have at least one entry.\n function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {\n buf[p++] = min_code_size;\n let cur_subblock = p++; // Pointing at the length field.\n const clear_code = 1 << min_code_size;\n const code_mask = clear_code - 1;\n const eoi_code = clear_code + 1;\n let next_code = eoi_code + 1;\n let cur_code_size = min_code_size + 1; // Number of bits per code.\n let cur_shift = 0;\n // We have at most 12-bit codes, so we should have to hold a max of 19\n // bits here (and then we would write out).\n let cur = 0;\n function emit_bytes_to_buffer(bit_block_size) {\n while (cur_shift >= bit_block_size) {\n buf[p++] = cur & 0xff;\n cur >>= 8;\n cur_shift -= 8;\n if (p === cur_subblock + 256) {\n // Finished a subblock.\n buf[cur_subblock] = 255;\n cur_subblock = p++;\n }\n }\n }\n function emit_code(c) {\n cur |= c << cur_shift;\n cur_shift += cur_code_size;\n emit_bytes_to_buffer(8);\n }\n // I am not an expert on the topic, and I don't want to write a thesis.\n // However, it is good to outline here the basic algorithm and the few data\n // structures and optimizations here that make this implementation fast.\n // The basic idea behind LZW is to build a table of previously seen runs\n // addressed by a short id (herein called output code). All data is\n // referenced by a code, which represents one or more values from the\n // original input stream. All input bytes can be referenced as the same\n // value as an output code. So if you didn't want any compression, you\n // could more or less just output the original bytes as codes (there are\n // some details to this, but it is the idea). In order to achieve\n // compression, values greater then the input range (codes can be up to\n // 12-bit while input only 8-bit) represent a sequence of previously seen\n // inputs. The decompressor is able to build the same mapping while\n // decoding, so there is always a shared common knowledge between the\n // encoding and decoder, which is also important for \"timing\" aspects like\n // how to handle variable bit width code encoding.\n //\n // One obvious but very important consequence of the table system is there\n // is always a unique id (at most 12-bits) to map the runs. 'A' might be\n // 4, then 'AA' might be 10, 'AAA' 11, 'AAAA' 12, etc. This relationship\n // can be used for an effecient lookup strategy for the code mapping. We\n // need to know if a run has been seen before, and be able to map that run\n // to the output code. Since we start with known unique ids (input bytes),\n // and then from those build more unique ids (table entries), we can\n // continue this chain (almost like a linked list) to always have small\n // integer values that represent the current byte chains in the encoder.\n // This means instead of tracking the input bytes (AAAABCD) to know our\n // current state, we can track the table entry for AAAABC (it is guaranteed\n // to exist by the nature of the algorithm) and the next character D.\n // Therefor the tuple of (table_entry, byte) is guaranteed to also be\n // unique. This allows us to create a simple lookup key for mapping input\n // sequences to codes (table indices) without having to store or search\n // any of the code sequences. So if 'AAAA' has a table entry of 12, the\n // tuple of ('AAAA', K) for any input byte K will be unique, and can be our\n // key. This leads to a integer value at most 20-bits, which can always\n // fit in an SMI value and be used as a fast sparse array / object key.\n // Output code for the current contents of the index buffer.\n let ib_code = index_stream[0] & code_mask; // Load first input index.\n let code_table = {}; // Key'd on our 20-bit \"tuple\".\n emit_code(clear_code); // Spec says first code should be a clear code.\n // First index already loaded, process the rest of the stream.\n for (let i = 1, il = index_stream.length; i < il; ++i) {\n const k = index_stream[i] & code_mask;\n const cur_key = (ib_code << 8) | k; // (prev, k) unique tuple.\n const cur_code = code_table[cur_key]; // buffer + k.\n // Check if we have to create a new code table entry.\n if (cur_code === undefined) {\n // We don't have buffer + k.\n // Emit index buffer (without k).\n // This is an inline version of emit_code, because this is the core\n // writing routine of the compressor (and V8 cannot inline emit_code\n // because it is a closure here in a different context). Additionally\n // we can call emit_byte_to_buffer less often, because we can have\n // 30-bits (from our 31-bit signed SMI), and we know our codes will only\n // be 12-bits, so can safely have 18-bits there without overflow.\n // emit_code(ib_code);\n cur |= ib_code << cur_shift;\n cur_shift += cur_code_size;\n while (cur_shift >= 8) {\n buf[p++] = cur & 0xff;\n cur >>= 8;\n cur_shift -= 8;\n if (p === cur_subblock + 256) {\n // Finished a subblock.\n buf[cur_subblock] = 255;\n cur_subblock = p++;\n }\n }\n if (next_code === 4096) {\n // Table full, need a clear.\n emit_code(clear_code);\n next_code = eoi_code + 1;\n cur_code_size = min_code_size + 1;\n code_table = {};\n }\n else {\n // Table not full, insert a new entry.\n // Increase our variable bit code sizes if necessary. This is a bit\n // tricky as it is based on \"timing\" between the encoding and\n // decoder. From the encoders perspective this should happen after\n // we've already emitted the index buffer and are about to create the\n // first table entry that would overflow our current code bit size.\n if (next_code >= 1 << cur_code_size)\n ++cur_code_size;\n code_table[cur_key] = next_code++; // Insert into code table.\n }\n ib_code = k; // Index buffer to single input k.\n }\n else {\n ib_code = cur_code; // Index buffer to sequence in code table.\n }\n }\n emit_code(ib_code); // There will still be something in the index buffer.\n emit_code(eoi_code); // End Of Information.\n // Flush / finalize the sub-blocks stream to the buffer.\n emit_bytes_to_buffer(1);\n // Finish the sub-blocks, writing out any unfinished lengths and\n // terminating with a sub-block of length 0. If we have already started\n // but not yet used a sub-block it can just become the terminator.\n if (cur_subblock + 1 === p) {\n // Started but unused.\n buf[cur_subblock] = 0;\n }\n else {\n // Started and used, write length and additional terminator block.\n buf[cur_subblock] = p - cur_subblock - 1;\n buf[p++] = 0;\n }\n return p;\n }\n}\n/*\n animatedGIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\n// Helpers\nconst noop$2 = function noop() { };\nconst AnimatedGIF = function AnimatedGIF(options) {\n this.canvas = null;\n this.ctx = null;\n this.repeat = 0;\n this.frames = [];\n this.numRenderedFrames = 0;\n this.onRenderCompleteCallback = noop$2;\n this.onRenderProgressCallback = noop$2;\n this.workers = [];\n this.availableWorkers = [];\n this.generatingGIF = false;\n this.options = options;\n // Constructs and initializes the the web workers appropriately\n this.initializeWebWorkers(options);\n};\nAnimatedGIF.prototype = {\n workerMethods: workerCode(),\n initializeWebWorkers: function initializeWebWorkers(options) {\n const self = this;\n const processFrameWorkerCode = `${NeuQuant.toString()}(${workerCode.toString()}());`;\n let webWorkerObj = void 0;\n let objectUrl = void 0;\n let webWorker = void 0;\n let numWorkers = void 0;\n let x = -1;\n let workerError = '';\n numWorkers = options.numWorkers;\n while (++x < numWorkers) {\n webWorkerObj = utils.createWebWorker(processFrameWorkerCode);\n if (utils.isObject(webWorkerObj)) {\n objectUrl = webWorkerObj.objectUrl;\n webWorker = webWorkerObj.worker;\n self.workers.push({\n worker: webWorker,\n objectUrl\n });\n self.availableWorkers.push(webWorker);\n }\n else {\n workerError = webWorkerObj;\n utils.webWorkerError = Boolean(webWorkerObj);\n }\n }\n this.workerError = workerError;\n this.canvas = document.createElement('canvas');\n this.canvas.width = options.gifWidth;\n this.canvas.height = options.gifHeight;\n this.ctx = this.canvas.getContext('2d');\n this.frames = [];\n },\n // Return a worker for processing a frame\n getWorker: function getWorker() {\n return this.availableWorkers.pop();\n },\n // Restores a worker to the pool\n freeWorker: function freeWorker(worker) {\n this.availableWorkers.push(worker);\n },\n byteMap: (function () {\n const byteMap = [];\n for (let i = 0; i < 256; i++) {\n byteMap[i] = String.fromCharCode(i);\n }\n return byteMap;\n })(),\n bufferToString: function bufferToString(buffer) {\n const numberValues = buffer.length;\n let str = '';\n let x = -1;\n while (++x < numberValues) {\n str += this.byteMap[buffer[x]];\n }\n return str;\n },\n onFrameFinished: function onFrameFinished(progressCallback) {\n // The GIF is not written until we're done with all the frames\n // because they might not be processed in the same order\n const self = this;\n const frames = self.frames;\n const options = self.options;\n const hasExistingImages = Boolean((options.images || []).length);\n const allDone = frames.every(function (frame) {\n return !frame.beingProcessed && frame.done;\n });\n self.numRenderedFrames++;\n if (hasExistingImages) {\n progressCallback(self.numRenderedFrames / frames.length);\n }\n self.onRenderProgressCallback((self.numRenderedFrames * 0.75) / frames.length);\n if (allDone) {\n if (!self.generatingGIF) {\n self.generateGIF(frames, self.onRenderCompleteCallback);\n }\n }\n else {\n utils.requestTimeout(function () {\n self.processNextFrame();\n }, 1);\n }\n },\n processFrame: function processFrame(position) {\n const AnimatedGifContext = this;\n const options = this.options;\n const _options = this.options;\n const progressCallback = _options.progressCallback;\n const sampleInterval = _options.sampleInterval;\n const frames = this.frames;\n let frame = void 0;\n let worker = void 0;\n const done = function done() {\n const ev = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const data = ev.data;\n // Delete original data, and free memory\n delete frame.data;\n frame.pixels = Array.prototype.slice.call(data.pixels);\n frame.palette = Array.prototype.slice.call(data.palette);\n frame.done = true;\n frame.beingProcessed = false;\n AnimatedGifContext.freeWorker(worker);\n AnimatedGifContext.onFrameFinished(progressCallback);\n };\n frame = frames[position];\n if (frame.beingProcessed || frame.done) {\n this.onFrameFinished();\n return;\n }\n frame.sampleInterval = sampleInterval;\n frame.beingProcessed = true;\n frame.gifshot = true;\n worker = this.getWorker();\n if (worker) {\n // Process the frame in a web worker\n worker.onmessage = done;\n worker.postMessage(frame);\n }\n else {\n // Process the frame in the current thread\n done({\n data: AnimatedGifContext.workerMethods.run(frame)\n });\n }\n },\n startRendering: function startRendering(completeCallback) {\n this.onRenderCompleteCallback = completeCallback;\n for (let i = 0; i < this.options.numWorkers && i < this.frames.length; i++) {\n this.processFrame(i);\n }\n },\n processNextFrame: function processNextFrame() {\n let position = -1;\n for (let i = 0; i < this.frames.length; i++) {\n const frame = this.frames[i];\n if (!frame.done && !frame.beingProcessed) {\n position = i;\n break;\n }\n }\n if (position >= 0) {\n this.processFrame(position);\n }\n },\n // Takes the already processed data in frames and feeds it to a new\n // GifWriter instance in order to get the binary GIF file\n generateGIF: function generateGIF(frames, callback) {\n // TODO: Weird: using a simple JS array instead of a typed array,\n // the files are WAY smaller o_o. Patches/explanations welcome!\n const buffer = []; // new Uint8Array(width * height * frames.length * 5);\n const gifOptions = {\n loop: this.repeat\n };\n const options = this.options;\n const interval = options.interval;\n const frameDuration = options.frameDuration;\n const existingImages = options.images;\n const hasExistingImages = Boolean(existingImages.length);\n const height = options.gifHeight;\n const width = options.gifWidth;\n const gifWriter$$1 = new gifWriter(buffer, width, height, gifOptions);\n const onRenderProgressCallback = this.onRenderProgressCallback;\n const delay = hasExistingImages ? interval * 100 : 0;\n let bufferToString = void 0;\n let gif = void 0;\n this.generatingGIF = true;\n utils.each(frames, function (iterator, frame) {\n const framePalette = frame.palette;\n onRenderProgressCallback(0.75 + (0.25 * frame.position * 1.0) / frames.length);\n for (let i = 0; i < frameDuration; i++) {\n gifWriter$$1.addFrame(0, 0, width, height, frame.pixels, {\n palette: framePalette,\n delay\n });\n }\n });\n gifWriter$$1.end();\n onRenderProgressCallback(1.0);\n this.frames = [];\n this.generatingGIF = false;\n if (utils.isFunction(callback)) {\n bufferToString = this.bufferToString(buffer);\n gif = `data:image/gif;base64,${utils.btoa(bufferToString)}`;\n callback(gif);\n }\n },\n // From GIF: 0 = loop forever, null = not looping, n > 0 = loop n times and stop\n setRepeat: function setRepeat(r) {\n this.repeat = r;\n },\n addFrame: function addFrame(element, gifshotOptions) {\n gifshotOptions = utils.isObject(gifshotOptions) ? gifshotOptions : {};\n const self = this;\n const ctx = self.ctx;\n const options = self.options;\n const width = options.gifWidth;\n const height = options.gifHeight;\n const fontSize = utils.getFontSize(gifshotOptions);\n const _gifshotOptions = gifshotOptions;\n const filter = _gifshotOptions.filter;\n const fontColor = _gifshotOptions.fontColor;\n const fontFamily = _gifshotOptions.fontFamily;\n const fontWeight = _gifshotOptions.fontWeight;\n const gifHeight = _gifshotOptions.gifHeight;\n const gifWidth = _gifshotOptions.gifWidth;\n const text = _gifshotOptions.text;\n const textAlign = _gifshotOptions.textAlign;\n const textBaseline = _gifshotOptions.textBaseline;\n const textXCoordinate = gifshotOptions.textXCoordinate\n ? gifshotOptions.textXCoordinate\n : textAlign === 'left'\n ? 1\n : textAlign === 'right'\n ? width\n : width / 2;\n const textYCoordinate = gifshotOptions.textYCoordinate\n ? gifshotOptions.textYCoordinate\n : textBaseline === 'top'\n ? 1\n : textBaseline === 'center'\n ? height / 2\n : height;\n const font = `${fontWeight} ${fontSize} ${fontFamily}`;\n let imageData = void 0;\n try {\n ctx.filter = filter;\n ctx.drawImage(element, 0, 0, width, height);\n if (text) {\n ctx.font = font;\n ctx.fillStyle = fontColor;\n ctx.textAlign = textAlign;\n ctx.textBaseline = textBaseline;\n ctx.fillText(text, textXCoordinate, textYCoordinate);\n }\n imageData = ctx.getImageData(0, 0, width, height);\n self.addFrameImageData(imageData);\n }\n catch (e) {\n return `${e}`;\n }\n },\n addFrameImageData: function addFrameImageData() {\n const imageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const frames = this.frames;\n const imageDataArray = imageData.data;\n this.frames.push({\n data: imageDataArray,\n width: imageData.width,\n height: imageData.height,\n palette: null,\n dithering: null,\n done: false,\n beingProcessed: false,\n position: frames.length\n });\n },\n onRenderProgress: function onRenderProgress(callback) {\n this.onRenderProgressCallback = callback;\n },\n isRendering: function isRendering() {\n return this.generatingGIF;\n },\n getBase64GIF: function getBase64GIF(completeCallback) {\n const self = this;\n const onRenderComplete = function onRenderComplete(gif) {\n self.destroyWorkers();\n utils.requestTimeout(function () {\n completeCallback(gif);\n }, 0);\n };\n self.startRendering(onRenderComplete);\n },\n destroyWorkers: function destroyWorkers() {\n if (this.workerError) {\n return;\n }\n const workers = this.workers;\n // Explicitly ask web workers to die so they are explicitly GC'ed\n utils.each(workers, function (iterator, workerObj) {\n const worker = workerObj.worker;\n const objectUrl = workerObj.objectUrl;\n worker.terminate();\n utils.URL.revokeObjectURL(objectUrl);\n });\n }\n};\n/*\n getBase64GIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction getBase64GIF(animatedGifInstance, callback) {\n // This is asynchronous, rendered with WebWorkers\n animatedGifInstance.getBase64GIF(function (image) {\n callback({\n error: false,\n errorCode: '',\n errorMsg: '',\n image\n });\n });\n}\n/*\n existingImages.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction existingImages() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const self = this;\n const callback = obj.callback;\n const images = obj.images;\n const options = obj.options;\n let imagesLength = obj.imagesLength;\n const skipObj = {\n getUserMedia: true,\n 'globalThis.URL': true\n };\n const errorObj = error.validate(skipObj);\n const loadedImages = [];\n let loadedImagesLength = 0;\n let tempImage = void 0;\n let ag = void 0;\n if (errorObj.error) {\n return callback(errorObj);\n }\n // change workerPath to point to where Animated_GIF.worker.js is\n ag = new AnimatedGIF(options);\n utils.each(images, function (index, image) {\n const currentImage = image;\n // if (image.src) {\n // currentImage = currentImage.src;\n // }\n if (utils.isElement(currentImage)) {\n if (options.crossOrigin) {\n currentImage.crossOrigin = options.crossOrigin;\n }\n loadedImages[index] = currentImage;\n loadedImagesLength += 1;\n if (loadedImagesLength === imagesLength) {\n addLoadedImagesToGif();\n }\n }\n else if (utils.isString(currentImage)) {\n tempImage = new Image();\n if (options.crossOrigin) {\n tempImage.crossOrigin = options.crossOrigin;\n }\n (function (tempImage) {\n if (image.text) {\n tempImage.text = image.text;\n }\n tempImage.onerror = function (e) {\n let obj = void 0;\n --imagesLength; // skips over images that error out\n if (imagesLength === 0) {\n obj = {};\n obj.error = 'None of the requested images was capable of being retrieved';\n return callback(obj);\n }\n };\n tempImage.onload = function (e) {\n if (image.text) {\n loadedImages[index] = {\n img: tempImage,\n text: tempImage.text\n };\n }\n else {\n loadedImages[index] = tempImage;\n }\n loadedImagesLength += 1;\n if (loadedImagesLength === imagesLength) {\n addLoadedImagesToGif();\n }\n utils.removeElement(tempImage);\n };\n tempImage.src = currentImage;\n })(tempImage);\n utils.setCSSAttr(tempImage, {\n position: 'fixed',\n opacity: '0'\n });\n document.body.appendChild(tempImage);\n }\n });\n function addLoadedImagesToGif() {\n utils.each(loadedImages, function (index, loadedImage) {\n if (loadedImage) {\n if (loadedImage.text) {\n ag.addFrame(loadedImage.img, options, loadedImage.text);\n }\n else {\n ag.addFrame(loadedImage, options);\n }\n }\n });\n getBase64GIF(ag, callback);\n }\n}\n/*\n screenShot.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\n// Helpers\nconst noop$3 = function noop() { };\nconst screenShot = {\n getGIF: function getGIF() {\n const options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n let callback = arguments[1];\n callback = utils.isFunction(callback) ? callback : noop$3;\n const canvas = document.createElement('canvas');\n let context = void 0;\n const existingImages = options.images;\n const hasExistingImages = Boolean(existingImages.length);\n const cameraStream = options.cameraStream;\n const crop = options.crop;\n const filter = options.filter;\n const fontColor = options.fontColor;\n const fontFamily = options.fontFamily;\n const fontWeight = options.fontWeight;\n const keepCameraOn = options.keepCameraOn;\n const numWorkers = options.numWorkers;\n const progressCallback = options.progressCallback;\n const saveRenderingContexts = options.saveRenderingContexts;\n const savedRenderingContexts = options.savedRenderingContexts;\n const text = options.text;\n const textAlign = options.textAlign;\n const textBaseline = options.textBaseline;\n const videoElement = options.videoElement;\n const videoHeight = options.videoHeight;\n const videoWidth = options.videoWidth;\n const webcamVideoElement = options.webcamVideoElement;\n const gifWidth = Number(options.gifWidth);\n const gifHeight = Number(options.gifHeight);\n let interval = Number(options.interval);\n const sampleInterval = Number(options.sampleInterval);\n const waitBetweenFrames = hasExistingImages ? 0 : interval * 1000;\n const renderingContextsToSave = [];\n let numFrames = savedRenderingContexts.length\n ? savedRenderingContexts.length\n : options.numFrames;\n let pendingFrames = numFrames;\n const ag = new AnimatedGIF(options);\n const fontSize = utils.getFontSize(options);\n const textXCoordinate = options.textXCoordinate\n ? options.textXCoordinate\n : textAlign === 'left'\n ? 1\n : textAlign === 'right'\n ? gifWidth\n : gifWidth / 2;\n const textYCoordinate = options.textYCoordinate\n ? options.textYCoordinate\n : textBaseline === 'top'\n ? 1\n : textBaseline === 'center'\n ? gifHeight / 2\n : gifHeight;\n const font = `${fontWeight} ${fontSize} ${fontFamily}`;\n let sourceX = crop ? Math.floor(crop.scaledWidth / 2) : 0;\n let sourceWidth = crop ? videoWidth - crop.scaledWidth : 0;\n let sourceY = crop ? Math.floor(crop.scaledHeight / 2) : 0;\n let sourceHeight = crop ? videoHeight - crop.scaledHeight : 0;\n const captureFrames = function captureSingleFrame() {\n const framesLeft = pendingFrames - 1;\n if (savedRenderingContexts.length) {\n context.putImageData(savedRenderingContexts[numFrames - pendingFrames], 0, 0);\n finishCapture();\n }\n else {\n drawVideo();\n }\n function drawVideo() {\n try {\n // Makes sure the canvas video heights/widths are in bounds\n if (sourceWidth > videoWidth) {\n sourceWidth = videoWidth;\n }\n if (sourceHeight > videoHeight) {\n sourceHeight = videoHeight;\n }\n if (sourceX < 0) {\n sourceX = 0;\n }\n if (sourceY < 0) {\n sourceY = 0;\n }\n context.filter = filter;\n context.drawImage(videoElement, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, gifWidth, gifHeight);\n finishCapture();\n }\n catch (e) {\n // There is a Firefox bug that sometimes throws NS_ERROR_NOT_AVAILABLE and\n // and IndexSizeError errors when drawing a video element to the canvas\n if (e.name === 'NS_ERROR_NOT_AVAILABLE') {\n // Wait 100ms before trying again\n utils.requestTimeout(drawVideo, 100);\n }\n else {\n throw e;\n }\n }\n }\n function finishCapture() {\n let imageData = void 0;\n if (saveRenderingContexts) {\n renderingContextsToSave.push(context.getImageData(0, 0, gifWidth, gifHeight));\n }\n // If there is text to display, make sure to display it on the canvas after the image is drawn\n if (text) {\n context.font = font;\n context.fillStyle = fontColor;\n context.textAlign = textAlign;\n context.textBaseline = textBaseline;\n context.fillText(text, textXCoordinate, textYCoordinate);\n }\n imageData = context.getImageData(0, 0, gifWidth, gifHeight);\n ag.addFrameImageData(imageData);\n pendingFrames = framesLeft;\n // Call back with an r value indicating how far along we are in capture\n progressCallback((numFrames - pendingFrames) / numFrames);\n if (framesLeft > 0) {\n // test\n utils.requestTimeout(captureSingleFrame, waitBetweenFrames);\n }\n if (!pendingFrames) {\n ag.getBase64GIF(function (image) {\n callback({\n error: false,\n errorCode: '',\n errorMsg: '',\n image,\n cameraStream,\n videoElement,\n webcamVideoElement,\n savedRenderingContexts: renderingContextsToSave,\n keepCameraOn\n });\n });\n }\n }\n };\n numFrames = numFrames !== undefined ? numFrames : 10;\n interval = interval !== undefined ? interval : 0.1; // In seconds\n canvas.width = gifWidth;\n canvas.height = gifHeight;\n context = canvas.getContext('2d');\n (function capture() {\n if (!savedRenderingContexts.length && videoElement.currentTime === 0) {\n utils.requestTimeout(capture, 100);\n return;\n }\n captureFrames();\n })();\n },\n getCropDimensions: function getCropDimensions() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const width = obj.videoWidth;\n const height = obj.videoHeight;\n const gifWidth = obj.gifWidth;\n const gifHeight = obj.gifHeight;\n const result = {\n width: 0,\n height: 0,\n scaledWidth: 0,\n scaledHeight: 0\n };\n if (width > height) {\n result.width = Math.round(width * (gifHeight / height)) - gifWidth;\n result.scaledWidth = Math.round(result.width * (height / gifHeight));\n }\n else {\n result.height = Math.round(height * (gifWidth / width)) - gifHeight;\n result.scaledHeight = Math.round(result.height * (width / gifWidth));\n }\n return result;\n }\n};\n/*\n videoStream.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nvar videoStream = {\n loadedData: false,\n defaultVideoDimensions: {\n width: 640,\n height: 480\n },\n findVideoSize: function findVideoSizeMethod(obj) {\n findVideoSizeMethod.attempts = findVideoSizeMethod.attempts || 0;\n const cameraStream = obj.cameraStream;\n const completedCallback = obj.completedCallback;\n const videoElement = obj.videoElement;\n if (!videoElement) {\n return;\n }\n if (videoElement.videoWidth > 0 && videoElement.videoHeight > 0) {\n videoElement.removeEventListener('loadeddata', videoStream.findVideoSize);\n completedCallback({\n videoElement,\n cameraStream,\n videoWidth: videoElement.videoWidth,\n videoHeight: videoElement.videoHeight\n });\n }\n else if (findVideoSizeMethod.attempts < 10) {\n findVideoSizeMethod.attempts += 1;\n utils.requestTimeout(function () {\n videoStream.findVideoSize(obj);\n }, 400);\n }\n else {\n completedCallback({\n videoElement,\n cameraStream,\n videoWidth: videoStream.defaultVideoDimensions.width,\n videoHeight: videoStream.defaultVideoDimensions.height\n });\n }\n },\n onStreamingTimeout: function onStreamingTimeout(callback) {\n if (utils.isFunction(callback)) {\n callback({\n error: true,\n errorCode: 'getUserMedia',\n errorMsg: 'There was an issue with the getUserMedia API - Timed out while trying to start streaming',\n image: null,\n cameraStream: {}\n });\n }\n },\n stream: function stream(obj) {\n const existingVideo = utils.isArray(obj.existingVideo)\n ? obj.existingVideo[0]\n : obj.existingVideo;\n const cameraStream = obj.cameraStream;\n const completedCallback = obj.completedCallback;\n const streamedCallback = obj.streamedCallback;\n const videoElement = obj.videoElement;\n if (utils.isFunction(streamedCallback)) {\n streamedCallback();\n }\n if (existingVideo) {\n if (utils.isString(existingVideo)) {\n videoElement.src = existingVideo;\n videoElement.innerHTML = `<source src=\"${existingVideo}\" type=\"video/${utils.getExtension(existingVideo)}\" />`;\n }\n else if (existingVideo instanceof Blob) {\n try {\n videoElement.src = utils.URL.createObjectURL(existingVideo);\n }\n catch (e) { }\n videoElement.innerHTML = `<source src=\"${existingVideo}\" type=\"${existingVideo.type}\" />`;\n }\n }\n else if (videoElement.mozSrcObject) {\n videoElement.mozSrcObject = cameraStream;\n }\n else if (utils.URL) {\n try {\n videoElement.srcObject = cameraStream;\n videoElement.src = utils.URL.createObjectURL(cameraStream);\n }\n catch (e) {\n videoElement.srcObject = cameraStream;\n }\n }\n videoElement.play();\n utils.requestTimeout(function checkLoadedData() {\n checkLoadedData.count = checkLoadedData.count || 0;\n if (videoStream.loadedData === true) {\n videoStream.findVideoSize({\n videoElement,\n cameraStream,\n completedCallback\n });\n videoStream.loadedData = false;\n }\n else {\n checkLoadedData.count += 1;\n if (checkLoadedData.count > 10) {\n videoStream.findVideoSize({\n videoElement,\n cameraStream,\n completedCallback\n });\n }\n else {\n checkLoadedData();\n }\n }\n }, 0);\n },\n startStreaming: function startStreaming(obj) {\n const errorCallback = utils.isFunction(obj.error) ? obj.error : utils.noop;\n const streamedCallback = utils.isFunction(obj.streamed) ? obj.streamed : utils.noop;\n const completedCallback = utils.isFunction(obj.completed) ? obj.completed : utils.noop;\n const crossOrigin = obj.crossOrigin;\n const existingVideo = obj.existingVideo;\n const lastCameraStream = obj.lastCameraStream;\n const options = obj.options;\n const webcamVideoElement = obj.webcamVideoElement;\n const videoElement = utils.isElement(existingVideo)\n ? existingVideo\n : webcamVideoElement\n ? webcamVideoElement\n : document.createElement('video');\n const cameraStream = void 0;\n if (crossOrigin) {\n videoElement.crossOrigin = options.crossOrigin;\n }\n videoElement.autoplay = true;\n videoElement.loop = true;\n videoElement.muted = true;\n videoElement.addEventListener('loadeddata', function (event) {\n videoStream.loadedData = true;\n if (options.offset) {\n videoElement.currentTime = options.offset;\n }\n });\n if (existingVideo) {\n videoStream.stream({\n videoElement,\n existingVideo,\n completedCallback\n });\n }\n else if (lastCameraStream) {\n videoStream.stream({\n videoElement,\n cameraStream: lastCameraStream,\n streamedCallback,\n completedCallback\n });\n }\n else {\n utils.getUserMedia({\n video: true\n }, function (stream) {\n videoStream.stream({\n videoElement,\n cameraStream: stream,\n streamedCallback,\n completedCallback\n });\n }, errorCallback);\n }\n },\n startVideoStreaming: function startVideoStreaming(callback) {\n const options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n const timeoutLength = options.timeout !== undefined ? options.timeout : 0;\n const originalCallback = options.callback;\n const webcamVideoElement = options.webcamVideoElement;\n let noGetUserMediaSupportTimeout = void 0;\n // Some browsers apparently have support for video streaming because of the\n // presence of the getUserMedia function, but then do not answer our\n // calls for streaming.\n // So we'll set up this timeout and if nothing happens after a while, we'll\n // conclude that there's no actual getUserMedia support.\n if (timeoutLength > 0) {\n noGetUserMediaSupportTimeout = utils.requestTimeout(function () {\n videoStream.onStreamingTimeout(originalCallback);\n }, 10000);\n }\n videoStream.startStreaming({\n error: function error() {\n originalCallback({\n error: true,\n errorCode: 'getUserMedia',\n errorMsg: 'There was an issue with the getUserMedia API - the user probably denied permission',\n image: null,\n cameraStream: {}\n });\n },\n streamed: function streamed() {\n // The streaming started somehow, so we can assume there is getUserMedia support\n clearTimeout(noGetUserMediaSupportTimeout);\n },\n completed: function completed() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const cameraStream = obj.cameraStream;\n const videoElement = obj.videoElement;\n const videoHeight = obj.videoHeight;\n const videoWidth = obj.videoWidth;\n callback({\n cameraStream,\n videoElement,\n videoHeight,\n videoWidth\n });\n },\n lastCameraStream: options.lastCameraStream,\n webcamVideoElement,\n crossOrigin: options.crossOrigin,\n options\n });\n },\n stopVideoStreaming: function stopVideoStreaming(obj) {\n obj = utils.isObject(obj) ? obj : {};\n const _obj = obj;\n const keepCameraOn = _obj.keepCameraOn;\n const videoElement = _obj.videoElement;\n const webcamVideoElement = _obj.webcamVideoElement;\n const cameraStream = obj.cameraStream || {};\n const cameraStreamTracks = cameraStream.getTracks ? cameraStream.getTracks() || [] : [];\n const hasCameraStreamTracks = Boolean(cameraStreamTracks.length);\n const firstCameraStreamTrack = cameraStreamTracks[0];\n if (!keepCameraOn && hasCameraStreamTracks) {\n if (utils.isFunction(firstCameraStreamTrack.stop)) {\n // Stops the camera stream\n firstCameraStreamTrack.stop();\n }\n }\n if (utils.isElement(videoElement) && !webcamVideoElement) {\n // Pauses the video, revokes the object URL (freeing up memory), and remove the video element\n videoElement.pause();\n // Destroys the object url\n if (utils.isFunction(utils.URL.revokeObjectURL) && !utils.webWorkerError) {\n if (videoElement.src) {\n utils.URL.revokeObjectURL(videoElement.src);\n }\n }\n // Removes the video element from the DOM\n utils.removeElement(videoElement);\n }\n }\n};\n/*\n stopVideoStreaming.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction stopVideoStreaming(options) {\n options = utils.isObject(options) ? options : {};\n videoStream.stopVideoStreaming(options);\n}\n/*\n createAndGetGIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction createAndGetGIF(obj, callback) {\n const options = obj.options || {};\n const images = options.images;\n const video = options.video;\n const gifWidth = Number(options.gifWidth);\n const gifHeight = Number(options.gifHeight);\n const numFrames = Number(options.numFrames);\n const cameraStream = obj.cameraStream;\n const videoElement = obj.videoElement;\n const videoWidth = obj.videoWidth;\n const videoHeight = obj.videoHeight;\n const cropDimensions = screenShot.getCropDimensions({\n videoWidth,\n videoHeight,\n gifHeight,\n gifWidth\n });\n const completeCallback = callback;\n options.crop = cropDimensions;\n options.videoElement = videoElement;\n options.videoWidth = videoWidth;\n options.videoHeight = videoHeight;\n options.cameraStream = cameraStream;\n if (!utils.isElement(videoElement)) {\n return;\n }\n videoElement.width = gifWidth + cropDimensions.width;\n videoElement.height = gifHeight + cropDimensions.height;\n if (!options.webcamVideoElement) {\n utils.setCSSAttr(videoElement, {\n position: 'fixed',\n opacity: '0'\n });\n document.body.appendChild(videoElement);\n }\n // Firefox doesn't seem to obey autoplay if the element is not in the DOM when the content\n // is loaded, so we must manually trigger play after adding it, or the video will be frozen\n videoElement.play();\n screenShot.getGIF(options, function (obj) {\n if ((!images || !images.length) && (!video || !video.length)) {\n stopVideoStreaming(obj);\n }\n completeCallback(obj);\n });\n}\n/*\n existingVideo.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction existingVideo() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const callback = obj.callback;\n let existingVideo = obj.existingVideo;\n const options = obj.options;\n const skipObj = {\n getUserMedia: true,\n 'globalThis.URL': true\n };\n const errorObj = error.validate(skipObj);\n const loadedImages = 0;\n let videoType = void 0;\n let videoSrc = void 0;\n const tempImage = void 0;\n const ag = void 0;\n if (errorObj.error) {\n return callback(errorObj);\n }\n if (utils.isElement(existingVideo) && existingVideo.src) {\n videoSrc = existingVideo.src;\n videoType = utils.getExtension(videoSrc);\n if (!utils.isSupported.videoCodecs[videoType]) {\n return callback(error.messages.videoCodecs);\n }\n }\n else if (utils.isArray(existingVideo)) {\n utils.each(existingVideo, function (iterator, videoSrc) {\n if (videoSrc instanceof Blob) {\n videoType = videoSrc.type.substr(videoSrc.type.lastIndexOf('/') + 1, videoSrc.length);\n }\n else {\n videoType = videoSrc.substr(videoSrc.lastIndexOf('.') + 1, videoSrc.length);\n }\n if (utils.isSupported.videoCodecs[videoType]) {\n existingVideo = videoSrc;\n return false;\n }\n });\n }\n videoStream.startStreaming({\n completed: function completed(obj) {\n obj.options = options || {};\n createAndGetGIF(obj, callback);\n },\n existingVideo,\n crossOrigin: options.crossOrigin,\n options\n });\n}\n/*\n existingWebcam.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction existingWebcam() {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n const callback = obj.callback;\n const lastCameraStream = obj.lastCameraStream;\n const options = obj.options;\n const webcamVideoElement = obj.webcamVideoElement;\n if (!isWebCamGIFSupported()) {\n return callback(error.validate());\n }\n if (options.savedRenderingContexts.length) {\n screenShot.getGIF(options, function (obj) {\n callback(obj);\n });\n return;\n }\n videoStream.startVideoStreaming(function () {\n const obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n obj.options = options || {};\n createAndGetGIF(obj, callback);\n }, {\n lastCameraStream,\n callback,\n webcamVideoElement,\n crossOrigin: options.crossOrigin\n });\n}\n/*\n createGIF.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nfunction createGIF(userOptions, callback) {\n callback = utils.isFunction(userOptions) ? userOptions : callback;\n userOptions = utils.isObject(userOptions) ? userOptions : {};\n if (!utils.isFunction(callback)) {\n return;\n }\n let options = utils.normalizeOptions(defaultOptions, userOptions) || {};\n const lastCameraStream = userOptions.cameraStream;\n const images = options.images;\n const imagesLength = images ? images.length : 0;\n const video = options.video;\n const webcamVideoElement = options.webcamVideoElement;\n options = utils.normalizeOptions(options, {\n gifWidth: Math.floor(options.gifWidth),\n gifHeight: Math.floor(options.gifHeight)\n });\n // If the user would like to create a GIF from an existing image(s)\n if (imagesLength) {\n existingImages({\n images,\n imagesLength,\n callback,\n options\n });\n }\n else if (video) {\n // If the user would like to create a GIF from an existing HTML5 video\n existingVideo({\n existingVideo: video,\n callback,\n options\n });\n }\n else {\n // If the user would like to create a GIF from a webcam stream\n existingWebcam({\n lastCameraStream,\n callback,\n webcamVideoElement,\n options\n });\n }\n}\n/*\n takeSnapShot.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\nfunction takeSnapShot(userOptions, callback) {\n callback = utils.isFunction(userOptions) ? userOptions : callback;\n userOptions = utils.isObject(userOptions) ? userOptions : {};\n if (!utils.isFunction(callback)) {\n return;\n }\n const mergedOptions = utils.normalizeOptions(defaultOptions, userOptions);\n const options = utils.normalizeOptions(mergedOptions, {\n interval: 0.1,\n numFrames: 1,\n gifWidth: Math.floor(mergedOptions.gifWidth),\n gifHeight: Math.floor(mergedOptions.gifHeight)\n });\n createGIF(options, callback);\n}\n/*\n API.js\n */\n/* Copyright 2017 Yahoo Inc.\n * Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.\n */\n// Dependencies\nconst API = {\n utils: utils$2,\n error: error$2,\n defaultOptions: defaultOptions$2,\n createGIF,\n takeSnapShot,\n stopVideoStreaming,\n isSupported,\n isWebCamGIFSupported,\n isExistingVideoGIFSupported,\n isExistingImagesGIFSupported: isSupported$1,\n VERSION: '0.4.5'\n};\nexport default API;\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// A GIFBuilder based on the gifshot module\n// @ts-nocheck\nimport { assert } from \"./lib/utils/assert.js\";\nimport gifshot from \"./lib/gifshot/gifshot.js\"; // TODO - load dynamically to avoid bloating\n// These are gifshot module options\nconst GIF_BUILDER_OPTIONS = {\n source: 'images',\n width: 200, // Desired width of the image\n height: 200, // Desired height of the image\n crossOrigin: 'Anonymous', // Options are 'Anonymous', 'use-credentials', or a falsy value to not set a CORS attribute.\n // CALLBACKS\n progressCallback: (captureProgress) => { }, // Callback that provides the current progress of the current image\n completeCallback: () => { }, // Callback function that is called when the current image is completed\n // QUALITY SETTINGS\n numWorkers: 2, // how many web workers to use to process the animated GIF frames. Default is 2.\n sampleInterval: 10, // pixels to skip when creating the palette. Default is 10. Less is better, but slower.\n interval: 0.1, // The amount of time (in seconds) to wait between each frame capture\n offset: null, // The amount of time (in seconds) to start capturing the GIF (only for HTML5 videos)\n numFrames: 10, // The number of frames to use to create the animated GIF. Note: Each frame is captured every 100 milliseconds of a video and every ms for existing images\n frameDuration: 1, // The amount of time (10 = 1s) to stay on each frame\n // CSS FILTER OPTIONS\n filter: '', // CSS filter that will be applied to the image (eg. blur(5px))\n // WATERMARK OPTIONS\n waterMark: null, // If an image is given here, it will be stamped on top of the GIF frames\n waterMarkHeight: null, // Height of the waterMark\n waterMarkWidth: null, // Height of the waterMark\n waterMarkXCoordinate: 1, // The X (horizontal) Coordinate of the watermark image\n waterMarkYCoordinate: 1, // The Y (vertical) Coordinate of the watermark image\n // TEXT OPTIONS\n text: '', // The text that covers the animated GIF\n showFrameText: true, // If frame-specific text is supplied with the image array, you can force to not be displayed\n fontWeight: 'normal', // The font weight of the text that covers the animated GIF\n fontSize: '16px', // The font size of the text that covers the animated GIF\n minFontSize: '10px', // The minimum font size of the text that covers the animated GIF\n resizeFont: false, // Whether or not the animated GIF text will be resized to fit within the GIF container\n fontFamily: 'sans-serif', // The font family of the text that covers the animated GIF\n fontColor: '#ffffff', // The font color of the text that covers the animated GIF\n textAlign: 'center', // The horizontal text alignment of the text that covers the animated GIF\n textBaseline: 'bottom', // The vertical text alignment of the text that covers the animated GIF\n textXCoordinate: null, // The X (horizontal) Coordinate of the text that covers the animated GIF\n textYCoordinate: null, // The Y (vertical) Coordinate of the text that covers the animated GIF\n // ADVANCED OPTIONS\n // WEBCAM CAPTURE OPTIONS\n webcamVideoElement: null, // You can pass an existing video element to use for the webcam GIF creation process,\n keepCameraOn: false, // Whether or not you would like the user's camera to stay on after the GIF is created\n cameraStream: null, // Expects a cameraStream Media object\n // CANVAS OPTIMIZATION OPTIONS\n saveRenderingContexts: false, // Whether or not you would like to save all of the canvas image binary data\n savedRenderingContexts: [] // Array of canvas image data\n};\nexport default class GIFBuilder {\n static get properties() {\n return {\n id: 'gif',\n name: 'GIF',\n extensions: ['gif'],\n mimeTypes: ['image/gif'],\n builder: GIFBuilder,\n options: GIF_BUILDER_OPTIONS\n };\n }\n constructor(options) {\n this.options = { ...options };\n this.source = options.source;\n delete options.source;\n // Allow files to be added\n this.files = [];\n // Expose the gifshot module so that the full gifshot API is available to apps (Experimental)\n this.gifshot = gifshot;\n }\n async initialize(options) {\n // Expose the gifshot module so that the full gifshot API is available to apps (Experimental)\n // this.gifshot = await loadGifshotModule(options);\n }\n async add(file) {\n await this.initialize();\n this.files.push(file);\n }\n async build() {\n await this.initialize();\n this._cleanOptions(this.options);\n switch (this.source) {\n case 'images':\n this.options.images = this.files;\n break;\n case 'video':\n this.options.video = this.files;\n break;\n case 'webcam':\n assert(this.files.length === 0);\n break;\n default:\n throw new Error('GIFBuilder: invalid source');\n }\n return await this._createGIF();\n }\n // PRIVATE\n async _createGIF() {\n return new Promise((resolve, reject) => {\n this.gifshot.createGIF(this.options, (result) => {\n // callback object properties\n // --------------------------\n // image - Base 64 image\n // cameraStream - The webRTC MediaStream object\n // error - Boolean that determines if an error occurred\n // errorCode - Helpful error label\n // errorMsg - Helpful error message\n // savedRenderingContexts - An array of canvas image data (will only be set if the saveRenderingContexts option was used)\n if (result.error) {\n reject(result.errorMsg);\n return;\n }\n // image - Base 64 image\n resolve(result.image);\n // var image = obj.image,\n // animatedImage = document.createElement('img');\n // animatedImage.src = image;\n // document.body.appendChild(animatedImage);\n });\n });\n }\n // Remove some gifshot options\n _cleanOptions(options) {\n if (options.video || options.images || options.gifWidth || options.gifHeight) {\n console.warn('GIFBuilder: ignoring options'); // eslint-disable-line\n }\n // We control these through options.source instead\n delete options.video;\n delete options.images;\n // Use width/height props (to standardize across builders)\n options.gifWidth = options.width;\n options.gifHeight = options.height;\n delete options.width;\n delete options.height;\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,eAAO,WAAkC,aAAa;AAIlD,QAAMA,QAAO,IAAI,KAAK,CAAC,WAAW,CAAC;AACnC,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,MAAM,IAAI,gBAAgBA,KAAI;AACpC,SAAO;AACX;;;ACNA,IAAM,UAAU,OAAiC,UAAU;AAIpD,IAAM,cAAc;AAAA,EACvB,UAAU;AAAA,EACV,WAAW;AAAA,EACX,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,YAAY,CAAC,KAAK;AAAA,EAClB,WAAW,CAAC,WAAW;AAAA;AAAA,EAEvB,SAAS;AAAA,IACL,OAAO,CAAC;AAAA,EACZ;AAAA,EACA,OAAO;AACX;;;ACrBO,SAAS,OAAO,WAAW,SAAS;AACvC,MAAI,CAAC,WAAW;AACZ,UAAM,IAAI,MAAM,OAAO;AAAA,EAC3B;AACJ;;;ACFA,IAAMC,YAAW,WAAW,YAAY,CAAC;AAczC,IAAI,QAAQ;AAAA,EACR,KAAK,WAAW,OAAO,WAAW,aAAa,WAAW,UAAU,WAAW;AAAA,EAC/E,cAAe,WAAY;AAC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"AnimatedGIF", "done", "existingImages", "bufferToString", "onRenderComplete", "getBase64GIF", "tempImage", "obj", "canvas", "existingVideo", "stream", "error", "stopVideoStreaming", "videoSrc"]
7
7
  }
@@ -4,7 +4,7 @@
4
4
  import parseVideo from "./lib/parsers/parse-video.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : 'latest';
7
+ const VERSION = typeof "4.3.3" !== 'undefined' ? "4.3.3" : 'latest';
8
8
  /**
9
9
  * Loads a platform-specific image type that can be used as input data to WebGL textures
10
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/video",
3
- "version": "4.3.3",
3
+ "version": "4.3.4",
4
4
  "description": "Framework-independent loaders and writers for video (MP4, WEBM, ...)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,12 +41,12 @@
41
41
  "build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
42
42
  },
43
43
  "dependencies": {
44
- "@loaders.gl/loader-utils": "4.3.3",
45
- "@loaders.gl/worker-utils": "4.3.3",
44
+ "@loaders.gl/loader-utils": "4.3.4",
45
+ "@loaders.gl/worker-utils": "4.3.4",
46
46
  "gifshot": "^0.4.5"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@loaders.gl/core": "^4.3.0"
50
50
  },
51
- "gitHead": "65cb9a984f8aa95d11f50e92189d7fb32786dc41"
51
+ "gitHead": "d18246f4ef6382f787a6ae2e9e21d8a7f40e5917"
52
52
  }