/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/etro@0.13.0/dist/etro-cjs.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var extendStatics=function(t,e){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},extendStatics(t,e)};function __extends(t,e){function r(){this.constructor=t}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var __assign=function(){return __assign=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},__assign.apply(this,arguments)};function __awaiter(t,e,r,i){return new(r||(r=Promise))((function(e,n){function o(t){try{s(i.next(t))}catch(t){n(t)}}function a(t){try{s(i.throw(t))}catch(t){n(t)}}function s(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r((function(t){t(i)}))).then(o,a)}s((i=i.apply(t,[])).next())}))}function __generator(t,e){var r,i,n,o,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){a.label=o[1];break}if(6===o[0]&&a.label<n[1]){a.label=n[1],n=o;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(o);break}n[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var DeprecatedEvent=function(){function t(t,e){void 0===e&&(e=void 0),this.replacement=t,this.message=e}return t.prototype.toString=function(){var t="";return this.replacement&&(t+="Use ".concat(this.replacement," instead.")),this.message&&(t+=" ".concat(this.message)),t},t}(),deprecatedEvents={},TypeId=function(){function t(t){this._parts=t.split(".")}return t.prototype.contains=function(t){if(t._parts.length>this._parts.length)return!1;for(var e=0;e<t._parts.length;e++)if(t._parts[e]!==this._parts[e])return!1;return!0},t.prototype.toString=function(){return this._parts.join(".")},t}();function deprecate(t,e,r){void 0===r&&(r=void 0),deprecatedEvents[t]=new DeprecatedEvent(e,r)}function subscribeOnce(t,e,r){var i=function(e){unsubscribe(t,i),r(e)};subscribe(t,e,i)}function subscribeMany(t,e,r){listeners.has(t)||listeners.set(t,[]),listeners.get(t).push({type:new TypeId(e),listener:r})}function subscribe(t,e,r,i){void 0===i&&(i={}),Object.keys(deprecatedEvents).includes(e)&&console.warn("Event ".concat(e," is deprecated. ").concat(deprecatedEvents[e])),i.once?subscribeOnce(t,e,r):subscribeMany(t,e,r)}function unsubscribe(t,e){if(!listeners.has(t)||!listeners.get(t).map((function(t){return t.listener})).includes(e))throw new Error("No matching event listener to remove");var r=listeners.get(t).filter((function(t){return t.listener!==e}));listeners.set(t,r)}function _publish(t,e,r){r.target=t,r.type=e;var i=new TypeId(e);if(!listeners.has(t))return null;for(var n=[],o=0;o<listeners.get(t).length;o++){var a=listeners.get(t)[o];i.contains(a.type)&&n.push(a.listener)}for(o=0;o<n.length;o++){(0,n[o])(r)}return r}function publish(t,e,r){if(Object.keys(deprecatedEvents).includes(e)&&deprecatedEvents[e].replacement)throw new Error("Event ".concat(e," is deprecated. ").concat(deprecatedEvents[e]));for(var i in deprecatedEvents){e===deprecatedEvents[i].replacement&&_publish(t,i,__assign({},r))}return _publish(t,e,r)}var listeners=new WeakMap,event=Object.freeze({__proto__:null,deprecate:deprecate,publish:publish,subscribe:subscribe,unsubscribe:unsubscribe});function getPropertyDescriptor(t,e){do{var r=Object.getOwnPropertyDescriptor(t,e);if(r)return r;t=Object.getPrototypeOf(t)}while(t)}function applyOptions(t,e){var r=e.getDefaultOptions();for(var i in t)if(!r.hasOwnProperty(i))throw new Error("Invalid option: '"+i+"'");for(var i in t=__assign(__assign({},r),t)){var n=getPropertyDescriptor(e,i);n&&!n.set||(e[i]=t[i])}}var valCache=new WeakMap;function cacheValue(t,e,r){valCache.has(t.movie)||valCache.set(t.movie,new WeakMap);var i=valCache.get(t.movie);return i.has(t)||i.set(t,{}),i.get(t)[e]=r,r}function hasCachedValue(t,e){return valCache.has(t.movie)&&valCache.get(t.movie).has(t)&&e in valCache.get(t.movie).get(t)}function getCachedValue(t,e){return valCache.get(t.movie).get(t)[e]}function clearCachedValues(t){valCache.delete(t)}var KeyFrame=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.value=t,this.interpolationKeys=[]}return t.prototype.withKeys=function(t){return this.interpolationKeys=t,this},t.prototype.evaluate=function(t){if(0===this.value.length)throw new Error("Empty keyframe");if(void 0===t)throw new Error("|time| is undefined or null");if(t<this.value[0][0])throw new Error("No keyframe point before |time|");for(var e=0;e<this.value.length;e++){var r=this.value[e][0],i=this.value[e][1],n=3===this.value[e].length?this.value[e][2]:linearInterp;if(!(e+1<this.value.length))return i;var o=this.value[e+1][0],a=this.value[e+1][1];if(r<=t&&t<o){if("number"!=typeof i&&"object"!=typeof a)return i;if(typeof i!=typeof a)throw new Error("Type mismatch in keyframe values");return n(i,a,(t-r)/(o-r),this.interpolationKeys)}}},t}();function val(t,e,r){if(hasCachedValue(t,e))return getCachedValue(t,e);for(var i=e.split("."),n=t[i.shift()];i.length>0;)n=n[i.shift()];var o,a=t.propertyFilters[e];return o=n instanceof KeyFrame?n.evaluate(r):"function"==typeof n?n(t,r):n,cacheValue(t,e,a?a.call(t,o):o)}function linearInterp(t,e,r,i){if(typeof t!=typeof e)throw new Error("Type mismatch");if("number"!=typeof t&&"object"!=typeof t)return t;if("object"==typeof t){if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))throw new Error("Prototype mismatch");for(var n=Object.create(Object.getPrototypeOf(t)),o=Object.keys(t)||i,a=0;a<o.length;a++){var s=o[a];t.hasOwnProperty(s)&&e.hasOwnProperty(s)&&(n[s]=linearInterp(t[s],e[s],r))}return n}return(1-r)*t+r*e}function cosineInterp(t,e,r,i){if(typeof t!=typeof e)throw new Error("Type mismatch");if("number"!=typeof t&&"object"!=typeof t)return t;if("object"==typeof t&&"object"==typeof e){if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))throw new Error("Prototype mismatch");for(var n=Object.create(Object.getPrototypeOf(t)),o=Object.keys(t)||i,a=0;a<o.length;a++){var s=o[a];t.hasOwnProperty(s)&&e.hasOwnProperty(s)&&(n[s]=cosineInterp(t[s],e[s],r))}return n}var u=Math.cos(Math.PI/2*r);return u*t+(1-u)*e}var Color=function(){function t(t,e,r,i){void 0===i&&(i=1),this.r=t,this.g=e,this.b=r,this.a=i}return t.prototype.toString=function(){return"rgba(".concat(this.r,", ").concat(this.g,", ").concat(this.b,", ").concat(this.a,")")},t}(),parseColorCanvas=document.createElement("canvas");parseColorCanvas.width=parseColorCanvas.height=1;var parseColorCtx=parseColorCanvas.getContext("2d");function parseColor(t){parseColorCtx.clearRect(0,0,1,1),parseColorCtx.fillStyle=t,parseColorCtx.fillRect(0,0,1,1);var e=parseColorCtx.getImageData(0,0,1,1).data;return new Color(e[0],e[1],e[2],e[3]/255)}var Font=function(){function t(t,e,r,i,n,o,a,s){void 0===i&&(i="normal"),void 0===n&&(n="normal"),void 0===o&&(o="normal"),void 0===a&&(a="normal"),void 0===s&&(s="normal"),this.size=t,this.sizeUnit=e,this.family=r,this.style=i,this.variant=n,this.weight=o,this.stretch=a,this.lineHeight=s}return t.prototype.toString=function(){var t="";return"normal"!==this.style&&(t+=this.style+" "),"normal"!==this.variant&&(t+=this.variant+" "),"normal"!==this.weight&&(t+=this.weight+" "),"normal"!==this.stretch&&(t+=this.stretch+" "),t+="".concat(this.size).concat(this.sizeUnit," "),"normal"!==this.lineHeight&&(t+=this.lineHeight+" "),t+=this.family},t}(),parseFontEl=document.createElement("div");function parseFont(t){parseFontEl.setAttribute("style","font: ".concat(t));var e=parseFontEl.style,r=e.fontSize,i=e.fontFamily,n=e.fontStyle,o=e.fontVariant,a=e.fontWeight,s=e.lineHeight;parseFontEl.removeAttribute("style");var u=parseFloat(r),c=r.substring(u.toString().length);return new Font(u,c,i,n,o,a,s)}function mapPixels(t,e,r,i,n,o,a,s){void 0===s&&(s=!0),i=i||0,n=n||0,o=o||e.width,a=a||e.height;for(var u=r.getImageData(i,n,o,a),c=0,h=u.data.length;c<h;c+=4)t(u.data,c);s&&r.putImageData(u,i,n)}function AudioSourceMixin(t){var e=function(e){function r(t){var r,i=this;if(!t.source)throw new Error('Property "source" is required in options');var n=t.onload;delete t.onload,(i=e.call(this,__assign(__assign({},t),{duration:null!==(r=t.duration)&&void 0!==r?r:0}))||this)._initialized=!1,i._sourceStartTime=t.sourceStartTime||0,applyOptions(t,i);var o=function(){if(t.duration<0)throw new Error("Invalid options.duration. It must be a non-negative value.");if(i.sourceStartTime>i.source.duration)throw new Error("options.sourceStartTime cannot exceed options.source.duration");i._unstretchedDuration=t.duration||i.source.duration-i.sourceStartTime,i.duration=i._unstretchedDuration/i.playbackRate,n&&n.bind(i)(i.source,t)};return i.source.readyState>=2?o():i.source.addEventListener("loadedmetadata",o),i.source.addEventListener("durationchange",(function(){i.duration=t.duration||i.source.duration-i.sourceStartTime})),i}return __extends(r,e),r.prototype.whenReady=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:return[4,e.prototype.whenReady.call(this)];case 1:return r.sent(),this.source.readyState<4?[4,new Promise((function(e){t.source.addEventListener("canplaythrough",e)}))]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},r.prototype.attach=function(t){var r=this;e.prototype.attach.call(this,t),subscribe(t,"audiodestinationupdate",(function(t){r.audioNode.disconnect(r._lastAudioDestination),r.audioNode.connect(t.destination),r._lastAudioDestination=t.destination})),this._audioNode=this.audioNode||t.actx.createMediaElementSource(this.source),this.audioNode.connect(t.actx.destination),this._lastAudioDestination=t.actx.destination},r.prototype.detach=function(){var t=this.movie.actx.destination;e.prototype.detach.call(this),this.audioNode.disconnect(t)},r.prototype.start=function(){this.source.currentTime=this.currentTime+this.sourceStartTime,this.source.play()},r.prototype.seek=function(t){e.prototype.seek.call(this,t),isNaN(this.currentTime)?this.source.currentTime=this.sourceStartTime:this.source.currentTime=this.currentTime+this.sourceStartTime},r.prototype.render=function(){e.prototype.render.call(this),this.source.muted=val(this,"muted",this.currentTime),this.source.volume=val(this,"volume",this.currentTime),this.source.playbackRate=val(this,"playbackRate",this.currentTime)},r.prototype.stop=function(){e.prototype.stop.call(this),this.source.pause()},Object.defineProperty(r.prototype,"audioNode",{get:function(){return this._audioNode},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"playbackRate",{get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,void 0!==this._unstretchedDuration&&(this.duration=this._unstretchedDuration/t)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"startTime",{get:function(){return this.__startTime},set:function(t){if(this.__startTime=t,this._initialized){var e=this.movie.currentTime-this.startTime;this.source.currentTime=this.sourceStartTime+e}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"sourceStartTime",{get:function(){return this._sourceStartTime},set:function(t){if(this._sourceStartTime=t,this._initialized){var e=this.movie.currentTime-this.startTime;this.source.currentTime=e+this.sourceStartTime}},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"ready",{get:function(){return Object.getOwnPropertyDescriptor(t.prototype,"ready").get.call(this)&&4===this.source.readyState},enumerable:!1,configurable:!0}),r.prototype.getDefaultOptions=function(){return __assign(__assign({},t.prototype.getDefaultOptions()),{source:void 0,sourceStartTime:0,duration:void 0,muted:!1,volume:1,playbackRate:1})},r}(t);return e}var Base$1=function(){function t(t){if(null===t.duration||void 0===t.duration)throw new Error('Property "duration" is required in BaseOptions');if(null===t.startTime||void 0===t.startTime)throw new Error('Property "startTime" is required in BaseOptions');this._startTime=t.startTime,this._duration=t.duration,applyOptions(t,this),this.active=!1,this.enabled=!0,this._occurrenceCount=0,this._movie=null}return t.prototype.whenReady=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2]}))}))},t.prototype.tryAttach=function(t){0===this._occurrenceCount&&this.attach(t),this._occurrenceCount++},t.prototype.attach=function(t){this._movie=t},t.prototype.tryDetach=function(){if(null===this.movie)throw new Error("No movie to detach from");this._occurrenceCount--,0===this._occurrenceCount&&this.detach()},t.prototype.detach=function(){this._movie=null},t.prototype.start=function(){},t.prototype.seek=function(t){this._currentTime=t},t.prototype.progress=function(t){this._currentTime=t},t.prototype.render=function(){},t.prototype.stop=function(){this._currentTime=void 0},Object.defineProperty(t.prototype,"parent",{get:function(){return this._movie},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startTime",{get:function(){return this._startTime},set:function(t){this._startTime=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._currentTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"duration",{get:function(){return this._duration},set:function(t){this._duration=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movie",{get:function(){return this._movie},enumerable:!1,configurable:!0}),t.prototype.getDefaultOptions=function(){return{startTime:void 0,duration:void 0}},t}();Base$1.prototype.type="layer",Base$1.prototype.publicExcludes=["active"],Base$1.prototype.propertyFilters={};var Audio=function(t){function e(e){if("string"==typeof e.source){var r=document.createElement("audio");r.src=e.source,e.source=r}return t.call(this,e)||this}return __extends(e,t),e.prototype.getDefaultOptions=function(){return __assign(__assign({},Object.getPrototypeOf(this).getDefaultOptions()),{sourceStartTime:0,duration:void 0})},e}(AudioSourceMixin(Base$1)),CustomArrayListener=function(){},CustomArray=function(t){function e(e,r){t.call(this);for(var i=0,n=e;i<n.length;i++){var o=n[i];r.onAdd(o)}return new Proxy(e,{deleteProperty:function(t,e){var i=t[e];return delete t[e],r.onRemove(i),!0},set:function(t,e,i){var n=t[e];return t[e]=i,isNaN(Number(e))||(void 0!==n&&r.onRemove(n),r.onAdd(i)),!0}})}return __extends(e,t),e}(Array),VisualEffectsListener=function(t){function e(e){var r=t.call(this)||this;return r._layer=e,r}return __extends(e,t),e.prototype.onAdd=function(t){t.tryAttach(this._layer)},e.prototype.onRemove=function(t){t.tryDetach()},e}(CustomArrayListener),VisualEffects=function(t){function e(e,r){return t.call(this,e,new VisualEffectsListener(r))||this}return __extends(e,t),e}(CustomArray),Visual$1=function(t){function e(e){var r=t.call(this,e)||this;return applyOptions(e,r),r.canvas=document.createElement("canvas"),r.cctx=r.canvas.getContext("2d"),r.effects=new VisualEffects([],r),r}return __extends(e,t),e.prototype.whenReady=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,t.prototype.whenReady.call(this)];case 1:return e.sent(),[4,Promise.all(this.effects.map((function(t){return t.whenReady()})))];case 2:return e.sent(),[2]}}))}))},e.prototype.render=function(){var t=val(this,"width",this.currentTime),e=val(this,"height",this.currentTime);0!==t&&0!==e&&(this.beginRender(),this.doRender(),this.endRender())},e.prototype.beginRender=function(){this.canvas.width=val(this,"width",this.currentTime),this.canvas.height=val(this,"height",this.currentTime),this.cctx.globalAlpha=val(this,"opacity",this.currentTime)},e.prototype.doRender=function(){this.background&&(this.cctx.fillStyle=val(this,"background",this.currentTime),this.cctx.fillRect(0,0,this.canvas.width,this.canvas.height));var t=val(this,"border",this.currentTime);t&&t.color&&(this.cctx.strokeStyle=t.color,this.cctx.lineWidth=t.thickness||1)},e.prototype.endRender=function(){(val(this,"width",this.currentTime)||val(this.movie,"width",this.movie.currentTime))*(val(this,"height",this.currentTime)||val(this.movie,"height",this.movie.currentTime))>0&&this._applyEffects()},e.prototype._applyEffects=function(){for(var t=0;t<this.effects.length;t++){var e=this.effects[t];e&&e.enabled&&e.apply(this,this.movie.currentTime-this.startTime)}},e.prototype.addEffect=function(t){return this.effects.push(t),this},Object.defineProperty(e.prototype,"ready",{get:function(){return Object.getOwnPropertyDescriptor(Base$1.prototype,"ready").get.call(this)&&this.effects.every((function(t){return t.ready}))},enumerable:!1,configurable:!0}),e.prototype.getDefaultOptions=function(){return __assign(__assign({},Base$1.prototype.getDefaultOptions()),{x:0,y:0,width:null,height:null,background:null,border:null,opacity:1})},e}(Base$1);function VisualSourceMixin(t){var e=function(e){function r(t){var r;if(!t.source)throw new Error('Property "source" is required in options');return applyOptions(t,r=e.call(this,t)||this),r}return __extends(r,e),r.prototype.whenReady=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:return[4,e.prototype.whenReady.call(this)];case 1:return r.sent(),[4,new Promise((function(e){t.source instanceof HTMLImageElement?t.source.complete?e():t.source.addEventListener("load",(function(){e()})):4===t.source.readyState?e():t.source.addEventListener("canplaythrough",(function(){e()}))}))];case 2:return r.sent(),[2]}}))}))},r.prototype.doRender=function(){e.prototype.doRender.call(this),this.cctx.drawImage(this.source,val(this,"sourceX",this.currentTime),val(this,"sourceY",this.currentTime),val(this,"sourceWidth",this.currentTime),val(this,"sourceHeight",this.currentTime),val(this,"destX",this.currentTime),val(this,"destY",this.currentTime),val(this,"destWidth",this.currentTime),val(this,"destHeight",this.currentTime))},Object.defineProperty(r.prototype,"ready",{get:function(){var e=Object.getOwnPropertyDescriptor(t.prototype,"ready").get.call(this),r=this.source instanceof HTMLImageElement?this.source.complete:4===this.source.readyState;return e&&r},enumerable:!1,configurable:!0}),r.prototype.getDefaultOptions=function(){return __assign(__assign({},t.prototype.getDefaultOptions()),{source:void 0,sourceX:0,sourceY:0,sourceWidth:void 0,sourceHeight:void 0,destX:0,destY:0,destWidth:void 0,destHeight:void 0})},r}(t);return e.prototype.propertyFilters=__assign(__assign({},Visual$1.prototype.propertyFilters),{sourceWidth:function(t){var e=this.source instanceof HTMLImageElement?this.source.width:this.source.videoWidth;return null!=t?t:e},sourceHeight:function(t){var e=this.source instanceof HTMLImageElement?this.source.height:this.source.videoHeight;return null!=t?t:e},destWidth:function(t){return null!=t?t:val(this,"sourceWidth",this.currentTime)},destHeight:function(t){return null!=t?t:val(this,"sourceHeight",this.currentTime)},width:function(t){return null!=t?t:val(this,"destWidth",this.currentTime)},height:function(t){return null!=t?t:val(this,"destHeight",this.currentTime)}}),e}Visual$1.prototype.publicExcludes=Base$1.prototype.publicExcludes.concat(["canvas","cctx","effects"]),Visual$1.prototype.propertyFilters=__assign(__assign({},Base$1.prototype.propertyFilters),{width:function(t){return null!=t?t:this._movie.width},height:function(t){return null!=t?t:this._movie.height}});var TextStrokePosition,Image=function(t){function e(e){if("string"==typeof e.source){var r=document.createElement("img");r.src=e.source,e.source=r}return t.call(this,e)||this}return __extends(e,t),e}(VisualSourceMixin(Visual$1));!function(t){t[t.Inside=0]="Inside",t[t.Center=1]="Center",t[t.Outside=2]="Outside"}(TextStrokePosition||(TextStrokePosition={}));var Text=function(t){function e(e){var r;if(!e.text)throw new Error('Property "text" is required in TextOptions');return applyOptions(e,r=t.call(this,__assign({background:null},e))||this),r}return __extends(e,t),e.prototype.doRender=function(){var e,r;t.prototype.doRender.call(this);var i=val(this,"text",this.currentTime),n=val(this,"font",this.currentTime),o=this.maxWidth?val(this,"maxWidth",this.currentTime):void 0;this.cctx.font=n,this.cctx.fillStyle=val(this,"color",this.currentTime),this.cctx.textAlign=val(this,"textAlign",this.currentTime),this.cctx.textBaseline=val(this,"textBaseline",this.currentTime),this.cctx.direction=val(this,"textDirection",this.currentTime),this.cctx.fillText(i,val(this,"textX",this.currentTime),val(this,"textY",this.currentTime),o);var a=val(this,"textStroke",this.currentTime);if(a){this.cctx.strokeStyle=a.color,this.cctx.lineWidth=null!==(e=a.thickness)&&void 0!==e?e:1;var s=null!==(r=a.position)&&void 0!==r?r:"outer",u=this.cctx.globalCompositeOperation;switch(s){case TextStrokePosition.Inside:this.cctx.globalCompositeOperation="source-atop",this.cctx.lineWidth*=2;break;case TextStrokePosition.Center:break;case TextStrokePosition.Outside:this.cctx.globalCompositeOperation="destination-over",this.cctx.lineWidth*=2}this.cctx.strokeText(i,val(this,"textX",this.currentTime),val(this,"textY",this.currentTime),o),this.cctx.globalCompositeOperation=u}this._prevText=i,this._prevFont=n,this._prevMaxWidth=o},e.prototype.getDefaultOptions=function(){return __assign(__assign({},Visual$1.prototype.getDefaultOptions()),{background:null,text:void 0,font:"10px sans-serif",color:parseColor("#fff"),textX:0,textY:0,maxWidth:null,textAlign:"start",textBaseline:"top",textDirection:"ltr",textStroke:null})},e}(Visual$1),Video=function(t){function e(e){var r;if("string"==typeof e.source){var i=document.createElement("video");i.src=e.source,e.source=i}return t.call(this,__assign(__assign({},e),{duration:null!==(r=e.duration)&&void 0!==r?r:0}))||this}return __extends(e,t),e}(AudioSourceMixin(VisualSourceMixin(Visual$1))),index$1=Object.freeze({__proto__:null,Audio:Audio,AudioSourceMixin:AudioSourceMixin,Base:Base$1,Image:Image,Text:Text,get TextStrokePosition(){return TextStrokePosition},Video:Video,Visual:Visual$1,VisualSourceMixin:VisualSourceMixin}),Base=function(){function t(){this.enabled=!0,this._occurrenceCount=0,this._target=null}return t.prototype.whenReady=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2]}))}))},t.prototype.tryAttach=function(t){0===this._occurrenceCount&&this.attach(t),this._occurrenceCount++},t.prototype.attach=function(t){this._target=t},t.prototype.tryDetach=function(){if(null===this._target)throw new Error("No movie to detach from");this._occurrenceCount--,0===this._occurrenceCount&&this.detach()},t.prototype.detach=function(){this._target=null},t.prototype.apply=function(t,e){},Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._target?this._target.currentTime:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._target},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movie",{get:function(){return this._target?this._target.movie:void 0},enumerable:!1,configurable:!0}),t.prototype.getDefaultOptions=function(){return{}},t}();Base.prototype.type="effect",Base.prototype.publicExcludes=[],Base.prototype.propertyFilters={};var Visual=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.apply=function(e,r){t.prototype.apply.call(this,e,r)},e}(Base),Shader=function(t){function e(r){void 0===r&&(r={});var i=t.call(this)||this,n=r.fragmentSource||e._IDENTITY_FRAGMENT_SOURCE,o=r.uniforms||{},a=r.textures||{},s=r.sourceTextureOptions||{},u=i._initGl();return i._program=e._initShaderProgram(u,e._VERTEX_SOURCE,n),i._buffers=e._initRectBuffers(u),i._initTextures(o,a,s),i._initAttribs(),i._initUniforms(o),i}return __extends(e,t),e.prototype._initGl=function(){this._canvas=document.createElement("canvas");var t=this._canvas.getContext("webgl");if(null===t)throw new Error("Unable to initialize WebGL. Your browser or machine may not support it.");return this._gl=t,t},e.prototype._initTextures=function(t,r,i){var n=this._gl,o=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS);for(var a in r.length>o&&console.warn("Too many textures!"),this._userTextures={},r){var s=r[a],u=__assign(__assign({},e._DEFAULT_TEXTURE_OPTIONS),s);if(u.createUniform){if(t[a])throw new Error("Texture - uniform naming conflict: ".concat(a,"!"));t[a]="1i"}this._userTextures[a]=u}this._sourceTextureOptions=__assign(__assign({},e._DEFAULT_TEXTURE_OPTIONS),i)},e.prototype._initAttribs=function(){var t=this._gl;this._attribLocations={vertexPosition:t.getAttribLocation(this._program,"a_VertexPosition"),textureCoord:t.getAttribLocation(this._program,"a_TextureCoord")}},e.prototype._initUniforms=function(t){var e=this._gl;for(var r in this._uniformLocations={source:e.getUniformLocation(this._program,"u_Source"),size:e.getUniformLocation(this._program,"u_Size")},this._userUniforms={},t){var i=t[r];this._userUniforms[r]="string"==typeof i?{type:i}:i}for(var n in t){var o="u_"+n.charAt(0).toUpperCase()+(n.length>1?n.slice(1):"");this._uniformLocations[n]=e.getUniformLocation(this._program,o)}},e.prototype.apply=function(t,e){this._checkDimensions(t),this._refreshGl(),this._enablePositionAttrib(),this._enableTexCoordAttrib(),this._prepareTextures(t,e),this._gl.useProgram(this._program),this._prepareUniforms(t,e),this._draw(t)},e.prototype._checkDimensions=function(t){var e=this._gl;this._canvas.width===t.canvas.width&&this._canvas.height===t.canvas.height||(this._canvas.width=t.canvas.width,this._canvas.height=t.canvas.height,e.viewport(0,0,t.canvas.width,t.canvas.height))},e.prototype._refreshGl=function(){var t=this._gl;t.clearColor(0,0,0,1),t.blendFuncSeparate(t.SRC_ALPHA,t.SRC_ALPHA,t.ONE,t.ZERO),t.enable(t.BLEND),t.disable(t.DEPTH_TEST),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)},e.prototype._enablePositionAttrib=function(){var t=this._gl,e=t.FLOAT;t.bindBuffer(t.ARRAY_BUFFER,this._buffers.position),t.vertexAttribPointer(this._attribLocations.vertexPosition,2,e,!1,0,0),t.enableVertexAttribArray(this._attribLocations.vertexPosition)},e.prototype._enableTexCoordAttrib=function(){var t=this._gl,e=t.FLOAT;t.bindBuffer(t.ARRAY_BUFFER,this._buffers.textureCoord),t.vertexAttribPointer(this._attribLocations.textureCoord,2,e,!1,0,0),t.enableVertexAttribArray(this._attribLocations.textureCoord)},e.prototype._prepareTextures=function(t,r){var i=this._gl;i.activeTexture(i.TEXTURE0),this._inputTexture=e._loadTexture(i,t.canvas,this._sourceTextureOptions),i.bindTexture(i.TEXTURE_2D,this._inputTexture);var n=0;for(var o in this._userTextures){var a=this._userTextures[o];i.activeTexture(i.TEXTURE0+(e.INTERNAL_TEXTURE_UNITS+n));var s=e._loadTexture(i,val(this,o,r),a);i.bindTexture(i[a.target],s),n++}},e.prototype._prepareUniforms=function(t,e){var r=this._gl;for(var i in this._uniformLocations.source&&r.uniform1i(this._uniformLocations.source,0),this._uniformLocations.size&&r.uniform2iv(this._uniformLocations.size,[t.canvas.width,t.canvas.height]),this._userUniforms){var n=this._userUniforms[i],o=val(this,i,e),a=this._prepareValue(o,n.type,e,n),s=this._uniformLocations[i];r["uniform"+n.type](s,a)}r.uniform1i(this._uniformLocations.test,0)},e.prototype._draw=function(t){var e=this._gl;e.drawArrays(e.TRIANGLE_STRIP,0,4),t.cctx.clearRect(0,0,t.canvas.width,t.canvas.height),t.cctx.drawImage(this._canvas,0,0)},e.prototype._prepareValue=function(t,r,i,n){void 0===n&&(n={});var o=n.defaultFloatComponent||0;if("1i"===r){var a=0;for(var s in this._userTextures){t===val(this,s,i)&&(t=e.INTERNAL_TEXTURE_UNITS+a),a++}}if("3fv"===r){if(Array.isArray(t)&&(3===t.length||4===t.length))return t;if("object"==typeof t)return[void 0!==t.r?t.r:o,void 0!==t.g?t.g:o,void 0!==t.b?t.b:o];throw new Error("Invalid type: ".concat(r," or value: ").concat(t))}if("4fv"===r){if(Array.isArray(t)&&4===t.length)return t;if("object"==typeof t)return[void 0!==t.r?t.r:o,void 0!==t.g?t.g:o,void 0!==t.b?t.b:o,void 0!==t.a?t.a:o];throw new Error("Invalid type: ".concat(r," or value: ").concat(t))}return t},e._initRectBuffers=function(t){return{position:e._initBuffer(t,[-1,1,1,1,-1,-1,1,-1]),textureCoord:e._initBuffer(t,[0,0,1,0,0,1,1,1])}},e._initBuffer=function(t,e){var r=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),r},e._loadTexture=function(t,r,i){void 0===i&&(i={});var n=t[(i=__assign(__assign({},e._DEFAULT_TEXTURE_OPTIONS),i)).target],o=i.level,a=t[i.internalFormat],s=t[i.srcFormat],u=t[i.srcType],c=t[i.wrapS],h=t[i.wrapT],l=t[i.minFilter],p=t[i.magFilter],d=t.createTexture();t.bindTexture(n,d),t.texImage2D(n,o,a,s,u,r);var f=n instanceof HTMLVideoElement?n.videoWidth:n.width,v=n instanceof HTMLVideoElement?n.videoHeight:n.height;return t.texParameteri(n,t.TEXTURE_MIN_FILTER,l),t.texParameteri(n,t.TEXTURE_MAG_FILTER,p),f&&isPowerOf2(f)&&v&&isPowerOf2(v)?(t.texParameteri(n,t.TEXTURE_WRAP_S,c),t.texParameteri(n,t.TEXTURE_WRAP_T,h),t.generateMipmap(n)):(c===t.CLAMP_TO_EDGE&&h===t.CLAMP_TO_EDGE||console.warn("Wrap mode is not CLAMP_TO_EDGE for a non-power-of-two texture. Defaulting to CLAMP_TO_EDGE"),t.texParameteri(n,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(n,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),d},e._initShaderProgram=function(t,r,i){var n=e._loadShader(t,t.VERTEX_SHADER,r),o=e._loadShader(t,t.FRAGMENT_SHADER,i),a=t.createProgram();return t.attachShader(a,n),t.attachShader(a,o),t.linkProgram(a),t.getProgramParameter(a,t.LINK_STATUS)?a:(console.warn("Unable to link shader program: "+t.getProgramInfoLog(a)),null)},e._loadShader=function(t,e,r){var i=t.createShader(e);return t.shaderSource(i,r),t.compileShader(i),t.getShaderParameter(i,t.COMPILE_STATUS)?i:(console.warn("An error occured compiling shader: "+t.getShaderInfoLog(i)),t.deleteShader(i),null)},e.INTERNAL_TEXTURE_UNITS=1,e._DEFAULT_TEXTURE_OPTIONS={createUniform:!0,target:"TEXTURE_2D",level:0,internalFormat:"RGBA",srcFormat:"RGBA",srcType:"UNSIGNED_BYTE",minFilter:"LINEAR",magFilter:"LINEAR",wrapS:"CLAMP_TO_EDGE",wrapT:"CLAMP_TO_EDGE"},e._VERTEX_SOURCE="\n    attribute vec4 a_VertexPosition;\n    attribute vec2 a_TextureCoord;\n\n    varying highp vec2 v_TextureCoord;\n\n    void main() {\n        // no need for projection or model-view matrices, since we're just rendering a rectangle\n        // that fills the screen (see position values)\n        gl_Position = a_VertexPosition;\n        v_TextureCoord = a_TextureCoord;\n    }\n  ",e._IDENTITY_FRAGMENT_SOURCE="\n    precision mediump float;\n\n    uniform sampler2D u_Source;\n\n    varying highp vec2 v_TextureCoord;\n\n    void main() {\n        gl_FragColor = texture2D(u_Source, v_TextureCoord);\n    }\n  ",e}(Visual),isPowerOf2=function(t){return 0===(t&&t-1)},Brightness=function(t){function e(e){void 0===e&&(e={});var r=t.call(this,{fragmentSource:"\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform float u_Brightness;\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          vec4 color = texture2D(u_Source, v_TextureCoord);\n          vec3 rgb = clamp(color.rgb + u_Brightness / 255.0, 0.0, 1.0);\n          gl_FragColor = vec4(rgb, color.a);\n        }\n      ",uniforms:{brightness:"1f"}})||this;return r.brightness=e.brightness||0,r}return __extends(e,t),e}(Shader),Channels=function(t){function e(e){void 0===e&&(e={});var r=t.call(this,{fragmentSource:"\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform vec4 u_Factors;\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          vec4 color = texture2D(u_Source, v_TextureCoord);\n          gl_FragColor = clamp(u_Factors * color, 0.0, 1.0);\n        }\n      ",uniforms:{factors:{type:"4fv",defaultFloatComponent:1}}})||this;return r.factors=e.factors||{},r}return __extends(e,t),e}(Shader),ChromaKey=function(t){function e(e){void 0===e&&(e={});var r=t.call(this,{fragmentSource:"\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform vec3 u_Target;\n        uniform float u_Threshold;\n        uniform bool u_Interpolate;\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          vec4 color = texture2D(u_Source, v_TextureCoord);\n          float alpha = color.a;\n          vec3 dist = abs(color.rgb - u_Target / 255.0);\n          if (!u_Interpolate) {\n            // Standard way that most video editors probably use (all-or-nothing method)\n            float thresh = u_Threshold / 255.0;\n            bool transparent = dist.r <= thresh && dist.g <= thresh && dist.b <= thresh;\n            if (transparent)\n              alpha = 0.0;\n          } else {\n            /*\n             better way IMHO:\n             Take the average of the absolute differences between the pixel and the target for each channel\n             */\n            float transparency = (dist.r + dist.g + dist.b) / 3.0;\n            // TODO: custom or variety of interpolation methods\n            alpha = transparency;\n          }\n          gl_FragColor = vec4(color.rgb, alpha);\n        }\n      ",uniforms:{target:"3fv",threshold:"1f",interpolate:"1i"}})||this;return r.target=e.target||new Color(0,0,0),r.threshold=e.threshold||0,r.interpolate=e.interpolate||!1,r}return __extends(e,t),e}(Shader),Contrast=function(t){function e(e){void 0===e&&(e={});var r=t.call(this,{fragmentSource:"\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform float u_Contrast;\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          vec4 color = texture2D(u_Source, v_TextureCoord);\n          vec3 rgb = clamp(u_Contrast * (color.rgb - 0.5) + 0.5, 0.0, 1.0);\n          gl_FragColor = vec4(rgb, color.a);\n        }\n      ",uniforms:{contrast:"1f"}})||this;return r.contrast=e.contrast||1,r}return __extends(e,t),e}(Shader),EllipticalMaskOptions=function(){},EllipticalMask=function(t){function e(e){var r=t.call(this)||this;return r.x=e.x,r.y=e.y,r.radiusX=e.radiusX,r.radiusY=e.radiusY,r.rotation=e.rotation||0,r.startAngle=e.startAngle||0,r.endAngle=void 0!==e.endAngle?e.endAngle:2*Math.PI,r.anticlockwise=e.anticlockwise||!1,r._tmpCanvas=document.createElement("canvas"),r._tmpCtx=r._tmpCanvas.getContext("2d"),r}return __extends(e,t),e.prototype.apply=function(t,e){var r=t.cctx,i=t.canvas,n=val(this,"x",e),o=val(this,"y",e),a=val(this,"radiusX",e),s=val(this,"radiusY",e),u=val(this,"rotation",e),c=val(this,"startAngle",e),h=val(this,"endAngle",e),l=val(this,"anticlockwise",e);this._tmpCanvas.width=t.canvas.width,this._tmpCanvas.height=t.canvas.height,this._tmpCtx.drawImage(i,0,0),r.clearRect(0,0,i.width,i.height),r.save(),r.beginPath(),r.ellipse(n,o,a,s,u,c,h,l),r.closePath(),r.clip(),r.drawImage(this._tmpCanvas,0,0),r.restore()},e}(Visual),StackEffectsListener=function(t){function e(e){var r=t.call(this)||this;return r._stack=e,r}return __extends(e,t),e.prototype.onAdd=function(t){this._stack.parent&&t.tryAttach(this._stack.parent)},e.prototype.onRemove=function(t){this._stack.parent&&t.tryDetach()},e}(CustomArrayListener),StackEffects=function(t){function e(e,r){return t.call(this,e,new StackEffectsListener(r))||this}return __extends(e,t),e}(CustomArray),Stack=function(t){function e(e){var r=t.call(this)||this;return r.effects=new StackEffects(e.effects,r),e.effects.forEach((function(t){return r.effects.push(t)})),r}return __extends(e,t),e.prototype.attach=function(e){t.prototype.attach.call(this,e),this.effects.filter((function(t){return!!t})).forEach((function(t){t.tryAttach(e)}))},e.prototype.detach=function(){t.prototype.detach.call(this),this.effects.filter((function(t){return!!t})).forEach((function(t){t.tryDetach()}))},e.prototype.apply=function(t,e){for(var r=0;r<this.effects.length;r++){var i=this.effects[r];i&&i.apply(t,e)}},e.prototype.addEffect=function(t){return this.effects.push(t),this},e}(Visual),GaussianBlur=function(t){function e(e){return t.call(this,{effects:[new GaussianBlurHorizontal(e),new GaussianBlurVertical(e)]})||this}return __extends(e,t),e}(Stack),GaussianBlurComponent=function(t){function e(e){var r=t.call(this,{fragmentSource:e.fragmentSource,uniforms:{radius:"1i"},textures:{shape:{minFilter:"NEAREST",magFilter:"NEAREST"}}})||this;return r.radius=e.radius,r._radiusCache=void 0,r}return __extends(e,t),e.prototype.apply=function(r,i){var n=val(this,"radius",i);n!==this._radiusCache&&(this.shape=e._render1DKernel(e._gen1DKernel(n))),this._radiusCache=n,t.prototype.apply.call(this,r,i)},e._render1DKernel=function(t){var e=document.createElement("canvas");e.width=t.length,e.height=1;for(var r=e.getContext("2d"),i=r.createImageData(e.width,e.height),n=0;n<t.length;n++)i.data[4*n+0]=255*t[n],i.data[4*n+1]=0,i.data[4*n+2]=0,i.data[4*n+3]=255;return r.putImageData(i,0,0),e},e._gen1DKernel=function(t){for(var r=e._genPascalRow(2*t+1),i=0,n=0;n<r.length;n++)i+=r[n];for(n=0;n<r.length;n++)r[n]/=i;return r},e._genPascalRow=function(t){if(t<0)throw new Error("Invalid index ".concat(t));for(var e=[1],r=1;r<t;r++){var i=[];i.length=e.length+1,i[0]=i[i.length-1]=1;for(var n=1;n<i.length-1;n++)i[n]=e[n-1]+e[n];e=i}return e},e}(Shader);GaussianBlurComponent.prototype.publicExcludes=Shader.prototype.publicExcludes.concat(["shape"]);var GaussianBlurHorizontal=function(t){function e(e){return t.call(this,{fragmentSource:"\n        #define MAX_RADIUS 250\n\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform ivec2 u_Size;   // pixel dimensions of input and output\n        uniform sampler2D u_Shape;  // pseudo one-dimension of blur distribution (would be 1D but webgl doesn't support it)\n        uniform int u_Radius;   // TODO: support floating-point radii\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          /*\n           * Ideally, totalWeight should end up being 1, but due to rounding errors, it sometimes ends up less than 1\n           * (I believe JS canvas stores values as integers, which rounds down for the majority of the Gaussian curve)\n           * So, normalize by accumulating all the weights and dividing by that.\n           */\n          float totalWeight = 0.0;\n          vec4 avg = vec4(0.0);\n          // GLSL can only use constants in for-loop declaration, so start at zero, and stop before 2 * u_Radius + 1,\n          // opposed to starting at -u_Radius and stopping _at_ +u_Radius.\n          for (int i = 0; i < 2 * MAX_RADIUS + 1; i++) {\n            if (i >= 2 * u_Radius + 1)\n              break;  // GLSL can only use constants in for-loop declaration, so we break here.\n            // (2 * u_Radius + 1) is the width of u_Shape, by definition\n            float weight = texture2D(u_Shape, vec2(float(i) / float(2 * u_Radius + 1), 0.5)).r;   // TODO: use single-channel format\n            totalWeight += weight;\n            vec4 sample = texture2D(u_Source, v_TextureCoord + vec2(i - u_Radius, 0.0) / vec2(u_Size));\n            avg += weight * sample;\n          }\n          gl_FragColor = avg / totalWeight;\n        }\n      ",radius:e.radius})||this}return __extends(e,t),e}(GaussianBlurComponent),GaussianBlurVertical=function(t){function e(e){return t.call(this,{fragmentSource:"\n        #define MAX_RADIUS 250\n\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform ivec2 u_Size;   // pixel dimensions of input and output\n        uniform sampler2D u_Shape;  // pseudo one-dimension of blur distribution (would be 1D but webgl doesn't support it)\n        uniform int u_Radius;   // TODO: support floating-point radii\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          /*\n           * Ideally, totalWeight should end up being 1, but due to rounding errors, it sometimes ends up less than 1\n           * (I believe JS canvas stores values as integers, which rounds down for the majority of the Gaussian curve)\n           * So, normalize by accumulating all the weights and dividing by that.\n           */\n          float totalWeight = 0.0;\n          vec4 avg = vec4(0.0);\n          // GLSL can only use constants in for-loop declaration, so start at zero, and stop before 2 * u_Radius + 1,\n          // opposed to starting at -u_Radius and stopping _at_ +u_Radius.\n          for (int i = 0; i < 2 * MAX_RADIUS + 1; i++) {\n            if (i >= 2 * u_Radius + 1)\n              break;  // GLSL can only use constants in for-loop declaration, so we break here.\n            // (2 * u_Radius + 1) is the width of u_Shape, by definition\n            float weight = texture2D(u_Shape, vec2(float(i) / float(2 * u_Radius + 1), 0.5)).r;   // TODO: use single-channel format\n            totalWeight += weight;\n            vec4 sample = texture2D(u_Source, v_TextureCoord + vec2(0.0, i - u_Radius) / vec2(u_Size));\n            avg += weight * sample;\n          }\n          gl_FragColor = avg / totalWeight;\n        }\n      ",radius:e.radius})||this}return __extends(e,t),e}(GaussianBlurComponent),Grayscale=function(t){function e(){return t.call(this,{fragmentSource:"\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform vec4 u_Factors;\n\n        varying highp vec2 v_TextureCoord;\n\n        float max3(float x, float y, float z) {\n          return max(x, max(y, z));\n        }\n\n        float min3(float x, float y, float z) {\n          return min(x, min(y, z));\n        }\n\n        void main() {\n          vec4 color = texture2D(u_Source, v_TextureCoord);\n          // Desaturate\n          float value = (max3(color.r, color.g, color.b) + min3(color.r, color.g, color.b)) / 2.0;\n          gl_FragColor = vec4(value, value, value, color.a);\n        }\n      "})||this}return __extends(e,t),e}(Shader),Pixelate=function(t){function e(e){void 0===e&&(e={});var r=t.call(this,{fragmentSource:"\n        precision mediump float;\n\n        uniform sampler2D u_Source;\n        uniform ivec2 u_Size;\n        uniform int u_PixelSize;\n\n        varying highp vec2 v_TextureCoord;\n\n        void main() {\n          int ps = u_PixelSize;\n\n          // Snap to nearest block's center\n          vec2 loc = vec2(u_Size) * v_TextureCoord; // pixel-space\n          vec2 snappedLoc = float(ps) * floor(loc / float(ps));\n          vec2 centeredLoc = snappedLoc + vec2(float(u_PixelSize) / 2.0 + 0.5);\n          vec2 clampedLoc = clamp(centeredLoc, vec2(0.0), vec2(u_Size));\n          gl_FragColor = texture2D(u_Source, clampedLoc / vec2(u_Size));\n        }\n      ",uniforms:{pixelSize:"1i"}})||this;return r.pixelSize=e.pixelSize||1,r}return __extends(e,t),e.prototype.apply=function(e,r){var i=val(this,"pixelSize",r);if(i%1!=0||i<0)throw new Error("Pixel size must be a nonnegative integer");t.prototype.apply.call(this,e,r)},e}(Shader),Transform=function(t){function e(r){var i=t.call(this)||this;return i.matrix=r.matrix,i._tmpMatrix=new e.Matrix,i._tmpCanvas=document.createElement("canvas"),i._tmpCtx=i._tmpCanvas.getContext("2d"),i}return __extends(e,t),e.prototype.apply=function(t,e){t.canvas.width!==this._tmpCanvas.width&&(this._tmpCanvas.width=t.canvas.width),t.canvas.height!==this._tmpCanvas.height&&(this._tmpCanvas.height=t.canvas.height),this._tmpMatrix.data=val(this,"matrix",e).data,this._tmpCtx.setTransform(this._tmpMatrix.a,this._tmpMatrix.b,this._tmpMatrix.c,this._tmpMatrix.d,this._tmpMatrix.e,this._tmpMatrix.f),this._tmpCtx.drawImage(t.canvas,0,0),this._tmpCtx.setTransform(1,0,0,0,1,0),t.cctx.clearRect(0,0,t.canvas.width,t.canvas.height),t.cctx.drawImage(this._tmpCanvas,0,0)},e}(Visual);!function(t){var e=function(){function t(t){this.data=t||[1,0,0,0,1,0,0,0,1]}return t.prototype.identity=function(){for(var e=0;e<this.data.length;e++)this.data[e]=t.IDENTITY.data[e];return this},t.prototype.cell=function(t,e,r){return void 0!==r&&(this.data[3*e+t]=r),this.data[3*e+t]},Object.defineProperty(t.prototype,"a",{get:function(){return this.data[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this.data[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"c",{get:function(){return this.data[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"d",{get:function(){return this.data[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"e",{get:function(){return this.data[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"f",{get:function(){return this.data[5]},enumerable:!1,configurable:!0}),t.prototype.multiply=function(e){for(var r=0;r<3;r++)for(var i=0;i<3;i++){for(var n=0,o=0;o<3;o++)n+=this.cell(r,o)*e.cell(o,i);t._TMP_MATRIX.cell(r,i,n)}for(o=0;o<t._TMP_MATRIX.data.length;o++)this.data[o]=t._TMP_MATRIX.data[o];return this},t.prototype.translate=function(e,r){return this.multiply(new t([1,0,e,0,1,r,0,0,1])),this},t.prototype.scale=function(e,r){return this.multiply(new t([e,0,0,0,r,0,0,0,1])),this},t.prototype.rotate=function(e){var r=Math.cos(e),i=Math.sin(e);return this.multiply(new t([r,i,0,-i,r,0,0,0,1])),this},t.IDENTITY=new t,t._TMP_MATRIX=new t,t}();t.Matrix=e}(Transform||(Transform={}));var index=Object.freeze({__proto__:null,Base:Base,Brightness:Brightness,Channels:Channels,ChromaKey:ChromaKey,Contrast:Contrast,EllipticalMask:EllipticalMask,EllipticalMaskOptions:EllipticalMaskOptions,GaussianBlur:GaussianBlur,GaussianBlurHorizontal:GaussianBlurHorizontal,GaussianBlurVertical:GaussianBlurVertical,Grayscale:Grayscale,Pixelate:Pixelate,Shader:Shader,Stack:Stack,get Transform(){return Transform},Visual:Visual}),MovieEffectsListener=function(t){function e(e){var r=t.call(this)||this;return r._movie=e,r}return __extends(e,t),e.prototype.onAdd=function(t){t.tryAttach(this._movie)},e.prototype.onRemove=function(t){t.tryDetach()},e}(CustomArrayListener),MovieEffects=function(t){function e(e,r){return t.call(this,e,new MovieEffectsListener(r))||this}return __extends(e,t),e}(CustomArray),MovieLayersListener=function(t){function e(e){var r=t.call(this)||this;return r._movie=e,r}return __extends(e,t),e.prototype.onAdd=function(t){t.tryAttach(this._movie)},e.prototype.onRemove=function(t){t.tryDetach()},e}(CustomArrayListener),MovieLayers=function(t){function e(e,r){return t.call(this,e,new MovieLayersListener(r))||this}return __extends(e,t),e}(CustomArray),MovieOptions=function(){},Movie=function(){function t(t){if(this._recording=!1,this.actx=t.actx||t.audioContext||new AudioContext||new window.webkitAudioContext,delete t.actx,!t.canvas)throw new Error('Required option "canvas" not provided to Movie');this._canvas=this._visibleCanvas=t.canvas,delete t.canvas,this._cctx=this.canvas.getContext("2d"),applyOptions(t,this),this.effects=new MovieEffects([],this),this.layers=new MovieLayers([],this),this._paused=!0,this._ended=!1,this._renderingFrame=!1,this.currentTime=0}return t.prototype._whenReady=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,Promise.all([Promise.all(this.layers.map((function(t){return t.whenReady()}))),Promise.all(this.effects.map((function(t){return t.whenReady()})))])];case 1:return t.sent(),[2]}}))}))},t.prototype.play=function(t){var e;return void 0===t&&(t={}),__awaiter(this,void 0,void 0,(function(){var r=this;return __generator(this,(function(i){switch(i.label){case 0:return[4,this._whenReady()];case 1:if(i.sent(),!this.paused)throw new Error("Already playing");return this._paused=this._ended=!1,this._lastRealTime=performance.now(),this._endTime=t.duration?this.currentTime+t.duration:this.duration,null===(e=t.onStart)||void 0===e||e.call(t),publish(this,"movie.play",{}),[4,new Promise((function(e){r.renderingFrame||r._render(void 0,e,t.onDraw),r._renderingFrame=!1}))];case 2:return i.sent(),this._lastRealTime=void 0,[2]}}))}))},t.prototype._show=function(){this._canvas=this._visibleCanvas,this._cctx=this.canvas.getContext("2d"),publish(this,"audiodestinationupdate",{movie:this,destination:this.actx.destination})},t.prototype.stream=function(t){return __awaiter(this,void 0,void 0,(function(){var e,r,i,n,o=this;return __generator(this,(function(a){switch(a.label){case 0:if(!t||!t.frameRate)throw new Error('Required option "frameRate" not provided to Movie.stream');if(!1===t.video&&!1===t.audio)throw new Error("Both video and audio cannot be disabled");if(!this.paused)throw new Error("Cannot stream movie while it's already playing");return[4,this._whenReady()];case 1:return a.sent(),this._canvas=document.createElement("canvas"),this.canvas.width=this._visibleCanvas.width,this.canvas.height=this._visibleCanvas.height,this._cctx=this.canvas.getContext("2d"),e=[],!1!==t.video&&(r=this.canvas.captureStream(t.frameRate),e=e.concat(r.getTracks())),this.layers.some((function(t){return t instanceof Audio||t instanceof Video}))&&!1!==t.audio&&(i=this.actx.createMediaStreamDestination(),n=i.stream,e=e.concat(n.getTracks()),publish(this,"audiodestinationupdate",{movie:this,destination:i})),this._currentStream=new MediaStream(e),[4,this.play({onStart:function(){t.onStart(o._currentStream)},duration:t.duration})];case 2:return a.sent(),this._currentStream.getTracks().forEach((function(t){t.stop()})),this._currentStream=null,this._show(),[2]}}))}))},t.prototype.record=function(t){var e;return __awaiter(this,void 0,void 0,(function(){var r,i,n,o,a=this;return __generator(this,(function(s){switch(s.label){case 0:if(!1===t.video&&!1===t.audio)throw new Error("Both video and audio cannot be disabled");if(!this.paused)throw new Error("Cannot record movie while it's already playing");if(r=t.type||"video/webm",MediaRecorder&&MediaRecorder.isTypeSupported&&!MediaRecorder.isTypeSupported(r))throw new Error("Please pass a valid MIME type for the exported video");return[4,new Promise((function(e){a.stream({frameRate:t.frameRate,duration:t.duration,video:t.video,audio:t.audio,onStart:e}).then((function(){a._recorder.requestData(),a._recorder.stop()}))}))];case 1:return i=s.sent(),n=[],o=__assign(__assign({},t.mediaRecorderOptions||{}),{mimeType:r}),this._recorder=new MediaRecorder(i,o),this._recorder.ondataavailable=function(t){t.data.size>0&&n.push(t.data)},this._recorder.start(),this._recording=!0,null===(e=t.onStart)||void 0===e||e.call(t,this._recorder),publish(this,"movie.record",{options:t}),[4,new Promise((function(t,e){a._recorder.onstop=function(){t()},a._recorder.onerror=e}))];case 2:return s.sent(),this._paused=!0,this._ended=!0,this._recording=!1,[2,new Blob(n,{type:r})]}}))}))},t.prototype.pause=function(){this._paused=!0;for(var t=0;t<this.layers.length;t++)if(Object.prototype.hasOwnProperty.call(this.layers,t)){var e=this.layers[t];e.active&&(e.stop(),e.active=!1)}return publish(this,"movie.pause",{}),this},t.prototype.stop=function(){return this.pause(),this.currentTime=0,this},t.prototype._render=function(t,e,r){var i=this;if(void 0===t&&(t=performance.now()),void 0===e&&(e=void 0),void 0===r&&(r=void 0),clearCachedValues(this),this.rendering){if(this.ready){publish(this,"movie.loadeddata",{movie:this}),this._recording&&"paused"===this._recorder.state&&this._recorder.resume();var n=this._currentStream?this._endTime:this.duration;if(this._updateCurrentTime(t,n),this.currentTime===n&&(this.recording&&publish(this,"movie.recordended",{movie:this}),this.currentTime===this.duration&&publish(this,"movie.ended",{movie:this,repeat:this.repeat}),this._currentTime=0,publish(this,"movie.timeupdate",{movie:this}),this._renderingFrame=!1,this.recording||!this.repeat)){this._paused=!0,this._ended=!0;for(var o=0;o<this.layers.length;o++)if(Object.prototype.hasOwnProperty.call(this.layers,o)){var a=this.layers[o];if(!a||!a.active)continue;a.stop(),a.active=!1}return publish(this,"movie.pause",{}),void(e&&e())}this._renderBackground(t),this._renderLayers(),this._applyEffects(),null==r||r()}else this.recording&&"recording"===this._recorder.state&&this._recorder.pause();if(this._renderingFrame&&this.ready)return this._renderingFrame=!1,void(e&&e());window.requestAnimationFrame((function(){i._render(void 0,e)}))}else e&&e()},t.prototype._updateCurrentTime=function(t,e){if(!this._renderingFrame){var r=t/1e3,i=r-this._lastRealTime;this._lastRealTime=r,i>0&&(this._currentTime+=i,publish(this,"movie.timeupdate",{movie:this})),this.currentTime>e&&(this._currentTime=e)}},t.prototype._renderBackground=function(t){this.cctx.clearRect(0,0,this.canvas.width,this.canvas.height);var e=val(this,"background",t);e&&(this.cctx.fillStyle=e,this.cctx.fillRect(0,0,this.canvas.width,this.canvas.height))},t.prototype._renderLayers=function(){for(var t=0;t<this.layers.length;t++)if(Object.prototype.hasOwnProperty.call(this.layers,t)){var e=this.layers[t];if(e){var r=this.currentTime-e.startTime;if(!val(e,"enabled",r)||this.currentTime<e.startTime||this.currentTime>e.startTime+e.duration)e.active&&!this._renderingFrame&&(e.stop(),e.active=!1);else if(this._renderingFrame||e.progress(r),e.active||!val(e,"enabled",r)||this._renderingFrame||(e.start(),e.active=!0),e.render(),e instanceof Visual$1){var i=e.canvas;i.width*i.height>0&&this.cctx.drawImage(i,val(e,"x",r),val(e,"y",r),i.width,i.height)}}}},t.prototype._applyEffects=function(){for(var t=0;t<this.effects.length;t++){var e=this.effects[t];e&&e.apply(this,this.currentTime)}},t.prototype.refresh=function(){var t=this;if(!this.paused)throw new Error("Already playing");return new Promise((function(e){t._renderingFrame=!0,t._render(void 0,e)}))},t.prototype._publishToLayers=function(t,e){for(var r=0;r<this.layers.length;r++)Object.prototype.hasOwnProperty.call(this.layers,r)&&publish(this.layers[r],t,e)},Object.defineProperty(t.prototype,"rendering",{get:function(){return!this.paused||this._renderingFrame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingFrame",{get:function(){return this._renderingFrame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"recording",{get:function(){return this._recording},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"duration",{get:function(){return this.layers.reduce((function(t,e){return Math.max(e.startTime+e.duration,t)}),0)},enumerable:!1,configurable:!0}),t.prototype.addLayer=function(t){return this.layers.push(t),this},t.prototype.addEffect=function(t){return this.effects.push(t),this},Object.defineProperty(t.prototype,"paused",{get:function(){return this._paused},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ended",{get:function(){return this._ended},enumerable:!1,configurable:!0}),t.prototype.seek=function(t){this._currentTime=t;for(var e=0;e<this.layers.length;e++){var r=this.layers[e];if(r){var i=t-r.startTime;i>=0&&i<=r.duration?r.seek(i):r.seek(void 0)}}publish(this,"movie.seek",{})},Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._currentTime},set:function(t){this.seek(t)},enumerable:!1,configurable:!0}),t.prototype.setCurrentTime=function(t,e){var r=this;return void 0===e&&(e=!0),new Promise((function(i,n){r.seek(t),e?r.refresh().then(i).catch(n):i()}))},Object.defineProperty(t.prototype,"ready",{get:function(){var t=this.layers.every((function(t){return t.ready})),e=this.effects.every((function(t){return t.ready}));return t&&e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvas",{get:function(){return this._canvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cctx",{get:function(){return this._cctx},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.canvas.width},set:function(t){this.canvas.width=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.canvas.height},set:function(t){this.canvas.height=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"movie",{get:function(){return this},enumerable:!1,configurable:!0}),t.prototype.getDefaultOptions=function(){return{canvas:void 0,background:parseColor("#000"),repeat:!1}},t}();Movie.prototype.type="movie",Movie.prototype.propertyFilters={},deprecate("movie.audiodestinationupdate","audiodestinationupdate"),deprecate("movie.ended",void 0),deprecate("movie.loadeddata",void 0),deprecate("movie.pause",void 0,"Wait for `play()`, `stream()`, or `record()` to resolve instead."),deprecate("movie.play",void 0,"Provide an `onStart` callback to `play()`, `stream()`, or `record()` instead."),deprecate("movie.record",void 0,"Provide an `onStart` callback to `record()` instead."),deprecate("movie.recordended",void 0,"Wait for `record()` to resolve instead."),deprecate("movie.seek",void 0,"Override the `seek` method on layers instead."),deprecate("movie.timeupdate",void 0,"Override the `progress` method on layers instead.");var etro=Object.freeze({__proto__:null,Color:Color,Font:Font,KeyFrame:KeyFrame,Movie:Movie,MovieOptions:MovieOptions,applyOptions:applyOptions,clearCachedValues:clearCachedValues,cosineInterp:cosineInterp,effect:index,event:event,layer:index$1,linearInterp:linearInterp,mapPixels:mapPixels,parseColor:parseColor,parseFont:parseFont,val:val});module.exports=etro;
//# sourceMappingURL=/sm/98a14a587af7504f2df595371e50cb183aea3781b973f352e5da31deb98ae0bf.map