/*! Parts of this script are from the TurboWarp Packager , licensed as follows: Copyright (C) 2021-2024 Thomas Weber The Source Code Form of this program is available under the terms of the Mozilla Public License, v. 2.0. You can obtain a copy of the license at https://www.mozilla.org/en-US/MPL/2.0/. Parts of this script are from Scratch , licensed as follows: Copyright (c) 2016, Massachusetts Institute of Technology All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*! For license information please see scaffolding-min.js.LICENSE.txt */ !function(t){function e(e){for(var n,i,s=e[0],o=e[1],a=0,u=[];a{if("string"!=typeof t)return!1;for(let e=0;er?1:0}return n===1/0&&r===1/0||n===-1/0&&r===-1/0?0:n-r}static isInt(t){return"number"==typeof t?!!isNaN(t)||t===Math.floor(t):"boolean"==typeof t||"string"==typeof t&&t.indexOf(".")<0}static get LIST_INVALID(){return"INVALID"}static get LIST_ALL(){return"ALL"}static toListIndex(t,e,n){if("number"!=typeof t){if("all"===t)return n?s.LIST_ALL:s.LIST_INVALID;if("last"===t)return e>0?e:s.LIST_INVALID;if("random"===t||"any"===t)return e>0?1+Math.floor(Math.random()*e):s.LIST_INVALID}return(t=Math.floor(s.toNumber(t)))<1||t>e?s.LIST_INVALID:t}}t.exports=s},function(t,e){t.exports={BOOLEAN:"Boolean",BUTTON:"button",LABEL:"label",COMMAND:"command",CONDITIONAL:"conditional",EVENT:"event",HAT:"hat",LOOP:"loop",REPORTER:"reporter",XML:"xml"}},function(t,e){t.exports={ANGLE:"angle",BOOLEAN:"Boolean",COLOR:"color",NUMBER:"number",STRING:"string",MATRIX:"matrix",NOTE:"note",IMAGE:"image",COSTUME:"costume",SOUND:"sound"}},function(t,e){t.exports=class{static degToRad(t){return t*Math.PI/180}static radToDeg(t){return 180*t/Math.PI}static clamp(t,e,n){return Math.min(Math.max(t,e),n)}static wrapClamp(t,e,n){const r=n-e+1;return t-Math.floor((t-e)/r)*r}static tan(t){switch(t%=360){case-270:case 90:return 1/0;case-90:case 270:return-1/0;default:return Math.round(1e10*Math.tan(Math.PI*t/180))/1e10}}static reducedSortOrdering(t){const e=t.slice(0).sort(((t,e)=>t-e));return t.map((t=>e.indexOf(t)))}static inclusiveRandIntWithout(t,e,n){const r=e-t,i=t+Math.floor(Math.random()*r);return i>=n?i+1:i}static scale(t,e,n,r,i){return(t-e)/(n-e)*(i-r)+r}}},function(t,e,n){"use strict";var r=n(106),i=n(107),s=n(57),o=n(56),a=n(55);function c(t,e){return Object.keys(e).forEach((function(n){t[n]=e[n]})),t}t.exports=function t(){var e=c({},a),n="en",u={},l=function(t){return t},h=null,d="warning",p={};function f(t,e,s){var o="string"==typeof t?t:t.default,a=b(o,"object"==typeof t&&t.id||l(o),s||n);return(a.format||(a.format=i(r(a.message),s||n,p)))(e)}f.rich=function(t,e,s){var o="string"==typeof t?t:t.default,a=b(o,"object"==typeof t&&t.id||l(o),s||n);return(a.toParts||(a.toParts=i.toParts(r(a.message,{tagsType:m}),s||n,p)))(e)};var m="<>";function g(t,e){var n=t[2];return function(t,e){var r="object"==typeof n?function(t,e){return Object.keys(t).reduce((function(n,r){return n[r]=t[r](e),n}),{})}(n,e):n;return"function"==typeof t?t(r):t}}function b(t,e,n){var r=o(n,u)||"en",i=u[r]||(u[r]={}),s=i[e];if("string"==typeof s&&(s=i[e]={message:s}),!s){var a='Translation for "'+e+'" in "'+r+'" is missing';if("warning"===d)"undefined"!=typeof console&&console.warn(a);else if("ignore"!==d)throw new Error(a);var c="function"==typeof h?h(t,e,r)||t:h||t;s=i[e]={message:c}}return s}function y(t,e,r,i,a){"object"==typeof r&&"object"!=typeof i&&(a=i,i=r,r=0);var c=o(a||n,s),u=c&&s[c][t]||v;return i["="+ +e]||i[u(e-r)]||i.other}function v(){return"other"}return p[m]=g,f.setup=function(t){return(t=t||{}).locale&&(n=t.locale),"translations"in t&&(u=t.translations||{}),t.generateId&&(l=t.generateId),"missingReplacement"in t&&(h=t.missingReplacement),t.missingTranslation&&(d=t.missingTranslation),t.formats&&(t.formats.number&&c(e.number,t.formats.number),t.formats.date&&c(e.date,t.formats.date),t.formats.time&&c(e.time,t.formats.time)),t.types&&((p=t.types)[m]=g),{locale:n,translations:u,generateId:l,missingReplacement:h,missingTranslation:d,formats:e,types:p}},f.number=function(t,r,i){var s=r&&e.number[r]||e.parseNumberPattern(r)||e.number.default;return new Intl.NumberFormat(i||n,s).format(t)},f.date=function(t,r,i){var s=r&&e.date[r]||e.parseDatePattern(r)||e.date.default;return new Intl.DateTimeFormat(i||n,s).format(t)},f.time=function(t,r,i){var s=r&&e.time[r]||e.parseDatePattern(r)||e.time.default;return new Intl.DateTimeFormat(i||n,s).format(t)},f.select=function(t,e){return e[t]||e.other},f.custom=function(t,e,n,r){return t[1]in p?p[t[1]](t,e)(n,r):n},f.plural=y.bind(null,"cardinal"),f.selectordinal=y.bind(null,"ordinal"),f.namespace=t,f}()},function(t,e,n){const r=n(0);class i{static withoutTrailingDigits(t){let e=t.length-1;for(;e>=0&&"0123456789".indexOf(t.charAt(e))>-1;)e--;return t.slice(0,e+1)}static unusedName(t,e){if(e.indexOf(t)<0)return t;t=i.withoutTrailingDigits(t);let n=2;for(;e.indexOf(t+n)>=0;)n++;return t+n}static caseInsensitiveUnusedName(t,e){const n=t=>e.some((e=>e.toLowerCase()===t.toLowerCase()));if(!n(t))return t;t=i.withoutTrailingDigits(t);let r=2;for(;n("".concat(t).concat(r));)r++;return"".concat(t).concat(r)}static splitFirst(t,e){const n=t.indexOf(e);return n>=0?[t.substring(0,n),t.substring(n+1)]:[t,null]}static stringify(t){return JSON.stringify(t,((t,e)=>"number"!=typeof e||e!==1/0&&e!==-1/0&&!isNaN(e)?e:0))}static replaceUnsafeChars(t){if("string"!=typeof t){if(!Array.isArray(t))return r.error("Unexpected input recieved in replaceUnsafeChars"),t;t=String(t)}return t.replace(/[<>&'"]/g,(t=>{switch(t){case"<":return"lt";case">":return"gt";case"&":return"amp";case"'":return"apos";case'"':return"quot"}}))}}t.exports=i},function(t,e){const n="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";t.exports=function(){const t=n.length,e=[];for(let r=0;r<20;r++)e[r]=n.charAt(Math.random()*t);return e.join("")}},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){const r=n(7),i=n(29);class s{constructor(t,e,n,i){switch(this.id=t||r(),this.name=e,this.type=n,this.isCloud=i,this.type){case s.SCALAR_TYPE:this.value=0;break;case s.LIST_TYPE:this.value=[];break;case s.BROADCAST_MESSAGE_TYPE:this.value=this.name;break;default:throw new Error("Invalid variable type: ".concat(this.type))}}toXML(t){return t=!0===t,'').concat(i(this.name),"")}static get SCALAR_TYPE(){return""}static get LIST_TYPE(){return"list"}static get BROADCAST_MESSAGE_TYPE(){return"broadcast_msg"}}t.exports=s},function(t,e,n){var r;"undefined"!=typeof self&&self,r=function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){"use strict";e.__esModule=!0,e.copyExistingProperties=function(t,e){Object.keys(e).forEach((function(n){e.hasOwnProperty(n)&&t.hasOwnProperty(n)&&(e[n]=t[n])}))},e.copyNamedProperties=function(t,e,n){t.forEach((function(t){var r=e[t];void 0!==r&&(n[t]=r)}))},e.isBuffer=function(t,e){return o||(o=t.createBuffer()),e instanceof o.constructor},e.isRenderbuffer=function(t,e){return a||(a=t.createRenderbuffer()),e instanceof a.constructor},e.isShader=function(t,e){return c||(c=t.createShader(t.VERTEX_SHADER)),e instanceof c.constructor},e.isTexture=function(t,e){return u||(u=t.createTexture()),e instanceof u.constructor},e.isSampler=function(t,e){if(!l){if(!t.createSampler)return!1;l=t.createSampler()}return e instanceof l.constructor},e.warn=e.error=void 0;var r,i=(r=n(2))&&r.__esModule?r:{default:r},s=i.default.console&&i.default.console.error&&"function"==typeof i.default.console.error?i.default.console.error.bind(i.default.console):function(){};e.error=s;var o,a,c,u,l,h=i.default.console&&i.default.console.warn&&"function"==typeof i.default.console.warn?i.default.console.warn.bind(i.default.console):function(){};e.warn=h},function(t,e,n){"use strict";e.__esModule=!0,e.getGLTypeForTypedArray=function(t){if(t instanceof Int8Array)return s;if(t instanceof Uint8Array)return o;if(t instanceof Uint8ClampedArray)return o;if(t instanceof Int16Array)return a;if(t instanceof Uint16Array)return c;if(t instanceof Int32Array)return u;if(t instanceof Uint32Array)return l;if(t instanceof Float32Array)return h;throw"unsupported typed array type"},e.getGLTypeForTypedArrayType=function(t){if(t===Int8Array)return s;if(t===Uint8Array)return o;if(t===Uint8ClampedArray)return o;if(t===Int16Array)return a;if(t===Uint16Array)return c;if(t===Int32Array)return u;if(t===Uint32Array)return l;if(t===Float32Array)return h;throw"unsupported typed array type"},e.getTypedArrayTypeForGLType=function(t){var e=d[t];if(!e)throw"unknown gl type";return e},e.isArrayBuffer=void 0;var r,i=(r=n(2))&&r.__esModule?r:{default:r},s=5120,o=5121,a=5122,c=5123,u=5124,l=5125,h=5126,d={},p=d;p[s]=Int8Array,p[o]=Uint8Array,p[a]=Int16Array,p[c]=Uint16Array,p[u]=Int32Array,p[l]=Uint32Array,p[h]=Float32Array,p[32819]=Uint16Array,p[32820]=Uint16Array,p[33635]=Uint16Array,p[5131]=Uint16Array,p[33640]=Uint32Array,p[35899]=Uint32Array,p[35902]=Uint32Array,p[36269]=Uint32Array,p[34042]=Uint32Array;var f=i.default.SharedArrayBuffer?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof i.default.SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};e.isArrayBuffer=f},function(t,e,n){"use strict";e.__esModule=!0,e.default=void 0;var r=void 0!==r?r:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};e.default=r},function(t,e,n){"use strict";e.__esModule=!0,e.add=function(t,e,n){return(n=n||new r(3))[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n},e.copy=function(t,e){return(e=e||new r(3))[0]=t[0],e[1]=t[1],e[2]=t[2],e},e.create=function(t,e,n){var i=new r(3);return t&&(i[0]=t),e&&(i[1]=e),n&&(i[2]=n),i},e.cross=function(t,e,n){n=n||new r(3);var i=t[2]*e[0]-t[0]*e[2],s=t[0]*e[1]-t[1]*e[0];return n[0]=t[1]*e[2]-t[2]*e[1],n[1]=i,n[2]=s,n},e.distance=function(t,e){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(n*n+r*r+i*i)},e.distanceSq=function(t,e){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i},e.divide=function(t,e,n){return(n=n||new r(3))[0]=t[0]/e[0],n[1]=t[1]/e[1],n[2]=t[2]/e[2],n},e.divScalar=function(t,e,n){return(n=n||new r(3))[0]=t[0]/e,n[1]=t[1]/e,n[2]=t[2]/e,n},e.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},e.lerp=function(t,e,n,i){return(i=i||new r(3))[0]=(1-n)*t[0]+n*e[0],i[1]=(1-n)*t[1]+n*e[1],i[2]=(1-n)*t[2]+n*e[2],i},e.length=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])},e.lengthSq=function(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]},e.mulScalar=function(t,e,n){return(n=n||new r(3))[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n},e.multiply=function(t,e,n){return(n=n||new r(3))[0]=t[0]*e[0],n[1]=t[1]*e[1],n[2]=t[2]*e[2],n},e.negate=function(t,e){return(e=e||new r(3))[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},e.normalize=function(t,e){e=e||new r(3);var n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=Math.sqrt(n);return i>1e-5?(e[0]=t[0]/i,e[1]=t[1]/i,e[2]=t[2]/i):(e[0]=0,e[1]=0,e[2]=0),e},e.setDefaultType=function(t){var e=r;return r=t,e},e.subtract=function(t,e,n){return(n=n||new r(3))[0]=t[0]-e[0],n[1]=t[1]-e[1],n[2]=t[2]-e[2],n};var r=Float32Array},function(t,e,n){"use strict";e.__esModule=!0,e.isWebGL1=function(t){return!t.texStorage2D},e.isWebGL2=function(t){return!!t.texStorage2D},e.glEnumToString=void 0;var r,i,s=(r={},i={},function(t,e){return function(t){var e=t.constructor.name;if(!r[e]){for(var n in t)if("number"==typeof t[n]){var s=i[t[n]];i[t[n]]=s?"".concat(s," | ").concat(n):n}r[e]=!0}}(t),i[e]||"0x"+e.toString(16)});e.glEnumToString=s},function(t,e,n){"use strict";e.__esModule=!0,e.createAttributeSetters=K,e.createProgram=L,e.createProgramFromScripts=function(t,e,n,r,i){for(var s=C(n,r,i),o=[],a=0;a=0?O.FRAGMENT_SHADER:t.indexOf("vert")>=0?O.VERTEX_SHADER:void 0}function P(t,e){e.forEach((function(e){t.deleteShader(e)}))}function L(t,e,n,r,i){for(var o=C(n,r,i),a=[],c=[],u=0;u1&&"[0]"===r.name.substr(-3),a=r.type,c=m[a];if(!c)throw"unknown type: 0x"+a.toString(16);if(c.bindPoint){var u=n;n+=r.size,i=o?c.arraySetter(t,a,u,s,r.size):c.setter(t,a,u,s,r.size)}else i=c.arraySetter&&o?c.arraySetter(t,s):c.setter(t,s);return i.location=s,i}for(var i={},s=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),o=0;o0)throw"numComponents "+s+" not correct for length "+i;return o}(e),n},e.createBufferFromArray=y,e.createBufferFromTypedArray=c,e.createBufferInfoFromArrays=function(t,e){var n={attribs:g(t,e)},i=e.indices;if(i){var s=m(i,"indices");n.indices=c(t,s,t.ELEMENT_ARRAY_BUFFER),n.numElements=s.length,n.elementType=r.getGLTypeForTypedArray(s)}else n.numElements=function(t,e){var n,r;for(r=0;r0)throw"Can not guess numComponents for attribute '"+t+"'. Tried "+n+" but "+e+" values is not evenly divisible by "+n+". You should specify it.";return n}function f(t,e){return t.numComponents||t.size||p(e,l(t).length)}function m(t,e){if(r.isArrayBuffer(t))return t;if(r.isArrayBuffer(t.data))return t.data;Array.isArray(t)&&(t={data:t});var n=t.type;return n||(n=u(e)?Uint16Array:Float32Array),new n(t.data)}function g(t,e){var n={};return Object.keys(e).forEach((function(i){if(!u(i)){var s,a,l,h,d,g=e[i],b=g.attrib||g.name||g.attribName||o.attribPrefix+i;if("number"==typeof g||"number"==typeof g.data){d=g.data||g;var y=g.type||Float32Array,v=d*y.BYTES_PER_ELEMENT;a=r.getGLTypeForTypedArrayType(y),l=void 0!==g.normalize?g.normalize:(T=y)===Int8Array||T===Uint8Array,h=g.numComponents||g.size||p(i,d),s=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,s),t.bufferData(t.ARRAY_BUFFER,v,g.drawType||t.STATIC_DRAW)}else{var w=m(g,i);s=c(t,w,void 0,g.drawType),a=r.getGLTypeForTypedArray(w),l=void 0!==g.normalize?g.normalize:function(t){return t instanceof Int8Array||t instanceof Uint8Array}(w),h=f(g,i),d=w.length}n[b]={buffer:s,numComponents:h,type:a,normalize:l,stride:g.stride||0,offset:g.offset||0,divisor:void 0===g.divisor?void 0:g.divisor,drawType:g.drawType}}var T})),t.bindBuffer(t.ARRAY_BUFFER,null),n}var b=["position","positions","a_position"];function y(t,e,n){var r="indices"===n?t.ELEMENT_ARRAY_BUFFER:t.ARRAY_BUFFER;return c(t,m(e,n),r)}},function(t,e,n){"use strict";e.__esModule=!0,e.setTextureDefaults_=function(t){o.copyExistingProperties(t,u),t.textureColor&&H(t.textureColor)},e.createSampler=$,e.createSamplers=function(t,e){var n={};return Object.keys(e).forEach((function(r){n[r]=$(t,e[r])})),n},e.setSamplerParameters=_,e.createTexture=ft,e.setEmptyTexture=pt,e.setTextureFromArray=dt,e.loadTextureFromUrl=ut,e.setTextureFromElement=it,e.setTextureFilteringForSize=tt,e.setTextureParameters=J,e.setDefaultTextureColor=H,e.createTextures=function(t,e,n){n=n||st;var r=0,i=[],s={},o={};function a(){0===r&&setTimeout((function(){n(i.length?i:void 0,s,o)}),0)}return Object.keys(e).forEach((function(n){var c,u,l=e[n];("string"==typeof(u=l.src)||Array.isArray(u)&&"string"==typeof u[0])&&(c=function(t,e,s){o[n]=s,--r,t&&i.push(t),a()},++r),s[n]=ft(t,l,c)})),a(),s},e.resizeTexture=function(t,e,n,r,i){r=r||n.width,i=i||n.height;var s=n.target||t.TEXTURE_2D;t.bindTexture(s,e);var o,a=n.level||0,c=n.internalFormat||n.format||t.RGBA,u=z(c),h=n.format||u.format,d=n.src;if(o=d&&(l(d)||Array.isArray(d)&&"number"==typeof d[0])?n.type||G(t,d,u.type):n.type||u.type,s===t.TEXTURE_CUBE_MAP)for(var p=0;p<6;++p)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,a,c,r,i,0,h,o,null);else t.texImage2D(s,a,c,r,i,0,h,o,null)},e.getNumComponentsForFormat=function(t){var e=L[t];if(!e)throw"unknown format: "+t;return e.numColorComponents},e.getBytesPerElementForInternalFormat=F;var r,i=c(n(4)),s=c(n(1)),o=c(n(0)),a=(r=n(2))&&r.__esModule?r:{default:r};function c(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(t,n):{};r.get||r.set?Object.defineProperty(e,n,r):e[n]=t[n]}return e.default=t,e}var u={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},l=s.isArrayBuffer,h=a.default.document&&a.default.document.createElement?a.default.document.createElement("canvas").getContext("2d"):null,d=6406,p=6407,f=6408,m=6409,g=6410,b=6402,y=34041,v=5120,w=5121,T=5122,E=5123,A=5124,k=5125,I=5126,S=5131,x=36193,O=33640,M=33319,N=33320,C=6403,R=36244,D=36248,P=36249,L={},B=L;B[6406]={numColorComponents:1},B[6409]={numColorComponents:1},B[6410]={numColorComponents:2},B[p]={numColorComponents:3},B[f]={numColorComponents:4},B[C]={numColorComponents:1},B[36244]={numColorComponents:1},B[M]={numColorComponents:2},B[33320]={numColorComponents:2},B[p]={numColorComponents:3},B[36248]={numColorComponents:3},B[f]={numColorComponents:4},B[36249]={numColorComponents:4},B[6402]={numColorComponents:1},B[34041]={numColorComponents:2};var U={},j=U;function F(t,e){var n=U[t];if(!n)throw"unknown internal format";var r=n.bytesPerElementMap[e];if(void 0===r)throw"unknown internal format";return r}function z(t){var e=U[t];if(!e)throw"unknown internal format";return{format:e.textureFormat,type:Array.isArray(e.type)?e.type[0]:e.type}}function V(t){return!(t&t-1)}function G(t,e,n){return l(e)?s.getGLTypeForTypedArray(e):n||t.UNSIGNED_BYTE}function Y(t,e,n,r,i){if(i%1!=0)throw"can't guess dimensions";if(n||r){if(r){if(!n&&(n=i/r)%1)throw"can't guess dimensions"}else if((r=i/n)%1)throw"can't guess dimensions"}else{var s=Math.sqrt(i/(e===t.TEXTURE_CUBE_MAP?6:1));s%1==0?(n=s,r=s):(n=i,r=1)}return{width:n,height:r}}function H(t){u.textureColor=new Uint8Array([255*t[0],255*t[1],255*t[2],255*t[3]])}j[6406]={textureFormat:d,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[w,S,x,I]},j[6409]={textureFormat:m,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[w,S,x,I]},j[6410]={textureFormat:g,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[w,S,x,I]},j[p]={textureFormat:p,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[w,S,x,I,33635]},j[f]={textureFormat:f,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[w,S,x,I,32819,32820]},j[33321]={textureFormat:C,colorRenderable:!0,textureFilterable:!0,bytesPerElement:1,type:w},j[36756]={textureFormat:C,colorRenderable:!1,textureFilterable:!0,bytesPerElement:1,type:v},j[33325]={textureFormat:C,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[I,S]},j[33326]={textureFormat:C,colorRenderable:!1,textureFilterable:!1,bytesPerElement:4,type:I},j[33330]={textureFormat:R,colorRenderable:!0,textureFilterable:!1,bytesPerElement:1,type:w},j[33329]={textureFormat:R,colorRenderable:!0,textureFilterable:!1,bytesPerElement:1,type:v},j[33332]={textureFormat:R,colorRenderable:!0,textureFilterable:!1,bytesPerElement:2,type:E},j[33331]={textureFormat:R,colorRenderable:!0,textureFilterable:!1,bytesPerElement:2,type:T},j[33334]={textureFormat:R,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:k},j[33333]={textureFormat:R,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:A},j[33323]={textureFormat:M,colorRenderable:!0,textureFilterable:!0,bytesPerElement:2,type:w},j[36757]={textureFormat:M,colorRenderable:!1,textureFilterable:!0,bytesPerElement:2,type:v},j[33327]={textureFormat:M,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[I,S]},j[33328]={textureFormat:M,colorRenderable:!1,textureFilterable:!1,bytesPerElement:8,type:I},j[33336]={textureFormat:N,colorRenderable:!0,textureFilterable:!1,bytesPerElement:2,type:w},j[33335]={textureFormat:N,colorRenderable:!0,textureFilterable:!1,bytesPerElement:2,type:v},j[33338]={textureFormat:N,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:E},j[33337]={textureFormat:N,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:T},j[33340]={textureFormat:N,colorRenderable:!0,textureFilterable:!1,bytesPerElement:8,type:k},j[33339]={textureFormat:N,colorRenderable:!0,textureFilterable:!1,bytesPerElement:8,type:A},j[32849]={textureFormat:p,colorRenderable:!0,textureFilterable:!0,bytesPerElement:3,type:w},j[35905]={textureFormat:p,colorRenderable:!1,textureFilterable:!0,bytesPerElement:3,type:w},j[36194]={textureFormat:p,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[w,33635]},j[36758]={textureFormat:p,colorRenderable:!1,textureFilterable:!0,bytesPerElement:3,type:v},j[35898]={textureFormat:p,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[I,S,35899]},j[35901]={textureFormat:p,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[I,S,35902]},j[34843]={textureFormat:p,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[I,S]},j[34837]={textureFormat:p,colorRenderable:!1,textureFilterable:!1,bytesPerElement:12,type:I},j[36221]={textureFormat:D,colorRenderable:!1,textureFilterable:!1,bytesPerElement:3,type:w},j[36239]={textureFormat:D,colorRenderable:!1,textureFilterable:!1,bytesPerElement:3,type:v},j[36215]={textureFormat:D,colorRenderable:!1,textureFilterable:!1,bytesPerElement:6,type:E},j[36233]={textureFormat:D,colorRenderable:!1,textureFilterable:!1,bytesPerElement:6,type:T},j[36209]={textureFormat:D,colorRenderable:!1,textureFilterable:!1,bytesPerElement:12,type:k},j[36227]={textureFormat:D,colorRenderable:!1,textureFilterable:!1,bytesPerElement:12,type:A},j[32856]={textureFormat:f,colorRenderable:!0,textureFilterable:!0,bytesPerElement:4,type:w},j[35907]={textureFormat:f,colorRenderable:!0,textureFilterable:!0,bytesPerElement:4,type:w},j[36759]={textureFormat:f,colorRenderable:!1,textureFilterable:!0,bytesPerElement:4,type:v},j[32855]={textureFormat:f,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[w,32820,O]},j[32854]={textureFormat:f,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[w,32819]},j[32857]={textureFormat:f,colorRenderable:!0,textureFilterable:!0,bytesPerElement:4,type:O},j[34842]={textureFormat:f,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[I,S]},j[34836]={textureFormat:f,colorRenderable:!1,textureFilterable:!1,bytesPerElement:16,type:I},j[36220]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:w},j[36238]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:v},j[36975]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:O},j[36214]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:8,type:E},j[36232]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:8,type:T},j[36226]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:16,type:A},j[36208]={textureFormat:P,colorRenderable:!0,textureFilterable:!1,bytesPerElement:16,type:k},j[33189]={textureFormat:b,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[E,k]},j[33190]={textureFormat:b,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:k},j[36012]={textureFormat:b,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:I},j[35056]={textureFormat:y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:34042},j[36013]={textureFormat:y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:4,type:36269},Object.keys(j).forEach((function(t){var e=j[t];if(e.bytesPerElementMap={},Array.isArray(e.bytesPerElement))e.bytesPerElement.forEach((function(t,n){var r=e.type[n];e.bytesPerElementMap[r]=t}));else{var n=e.type;e.bytesPerElementMap[n]=e.bytesPerElement}}));var W={};function K(t,e){void 0!==e.colorspaceConversion&&(W.colorspaceConversion=t.getParameter(t.UNPACK_COLORSPACE_CONVERSION_WEBGL),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.colorspaceConversion)),void 0!==e.premultiplyAlpha&&(W.premultiplyAlpha=t.getParameter(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha)),void 0!==e.flipY&&(W.flipY=t.getParameter(t.UNPACK_FLIP_Y_WEBGL),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY))}function q(t,e){void 0!==e.colorspaceConversion&&t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,W.colorspaceConversion),void 0!==e.premultiplyAlpha&&t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,W.premultiplyAlpha),void 0!==e.flipY&&t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,W.flipY)}function Q(t){W.unpackAlignment=t.getParameter(t.UNPACK_ALIGNMENT),i.isWebGL2(t)&&(W.unpackRowLength=t.getParameter(t.UNPACK_ROW_LENGTH),W.unpackImageHeight=t.getParameter(t.UNPACK_IMAGE_HEIGHT),W.unpackSkipPixels=t.getParameter(t.UNPACK_SKIP_PIXELS),W.unpackSkipRows=t.getParameter(t.UNPACK_SKIP_ROWS),W.unpackSkipImages=t.getParameter(t.UNPACK_SKIP_IMAGES))}function X(t){t.pixelStorei(t.UNPACK_ALIGNMENT,W.unpackAlignment),i.isWebGL2(t)&&(t.pixelStorei(t.UNPACK_ROW_LENGTH,W.unpackRowLength),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,W.unpackImageHeight),t.pixelStorei(t.UNPACK_SKIP_PIXELS,W.unpackSkipPixels),t.pixelStorei(t.UNPACK_SKIP_ROWS,W.unpackSkipRows),t.pixelStorei(t.UNPACK_SKIP_IMAGES,W.unpackSkipImages))}function Z(t,e,n,r){r.minMag&&(n.call(t,e,t.TEXTURE_MIN_FILTER,r.minMag),n.call(t,e,t.TEXTURE_MAG_FILTER,r.minMag)),r.min&&n.call(t,e,t.TEXTURE_MIN_FILTER,r.min),r.mag&&n.call(t,e,t.TEXTURE_MAG_FILTER,r.mag),r.wrap&&(n.call(t,e,t.TEXTURE_WRAP_S,r.wrap),n.call(t,e,t.TEXTURE_WRAP_T,r.wrap),(e===t.TEXTURE_3D||o.isSampler(t,e))&&n.call(t,e,t.TEXTURE_WRAP_R,r.wrap)),r.wrapR&&n.call(t,e,t.TEXTURE_WRAP_R,r.wrapR),r.wrapS&&n.call(t,e,t.TEXTURE_WRAP_S,r.wrapS),r.wrapT&&n.call(t,e,t.TEXTURE_WRAP_T,r.wrapT),r.minLod&&n.call(t,e,t.TEXTURE_MIN_LOD,r.minLod),r.maxLod&&n.call(t,e,t.TEXTURE_MAX_LOD,r.maxLod),r.baseLevel&&n.call(t,e,t.TEXTURE_BASE_LEVEL,r.baseLevel),r.maxLevel&&n.call(t,e,t.TEXTURE_MAX_LEVEL,r.maxLevel)}function J(t,e,n){var r=n.target||t.TEXTURE_2D;t.bindTexture(r,e),Z(t,r,t.texParameteri,n)}function _(t,e,n){Z(t,e,t.samplerParameteri,n)}function $(t,e){var n=t.createSampler();return _(t,n,e),n}function tt(t,e,n,r,s,o,a){n=n||u.textureOptions,o=o||t.RGBA,a=a||t.UNSIGNED_BYTE;var c=n.target||t.TEXTURE_2D;if(r=r||n.width,s=s||n.height,t.bindTexture(c,e),function(t,e,n,r){if(!i.isWebGL2(t))return V(e)&&V(n);var s=U[r];if(!s)throw"unknown internal format";return s.colorRenderable&&s.textureFilterable}(t,r,s,o))t.generateMipmap(c);else{var l=function(t){var e=U[t];if(!e)throw"unknown internal format";return e.textureFilterable}(o)?t.LINEAR:t.NEAREST;t.texParameteri(c,t.TEXTURE_MIN_FILTER,l),t.texParameteri(c,t.TEXTURE_MAG_FILTER,l),t.texParameteri(c,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(c,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}}function et(t){return!0===t.auto||void 0===t.auto&&void 0===t.level}function nt(t,e){return(e=e||{}).cubeFaceOrder||[t.TEXTURE_CUBE_MAP_POSITIVE_X,t.TEXTURE_CUBE_MAP_NEGATIVE_X,t.TEXTURE_CUBE_MAP_POSITIVE_Y,t.TEXTURE_CUBE_MAP_NEGATIVE_Y,t.TEXTURE_CUBE_MAP_POSITIVE_Z,t.TEXTURE_CUBE_MAP_NEGATIVE_Z]}function rt(t,e){var n=nt(t,e).map((function(t,e){return{face:t,ndx:e}}));return n.sort((function(t,e){return t.face-e.face})),n}function it(t,e,n,r){var i=(r=r||u.textureOptions).target||t.TEXTURE_2D,s=r.level||0,o=n.width,c=n.height,l=r.internalFormat||r.format||t.RGBA,d=z(l),p=r.format||d.format,f=r.type||d.type;if(K(t,r),t.bindTexture(i,e),i===t.TEXTURE_CUBE_MAP){var m,g,b=n.width,y=n.height;if(b/6===y)m=y,g=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===b)m=b,g=[0,0,0,1,0,2,0,3,0,4,0,5];else if(b/3==y/2)m=b/3,g=[0,0,1,0,2,0,0,1,1,1,2,1];else{if(b/2!=y/3)throw"can't figure out cube map from element: "+(n.src?n.src:n.nodeName);m=b/2,g=[0,0,1,0,0,1,1,1,0,2,1,2]}h?(h.canvas.width=m,h.canvas.height=m,o=m,c=m,rt(t,r).forEach((function(e){var r=g[2*e.ndx+0]*m,i=g[2*e.ndx+1]*m;h.drawImage(n,r,i,m,m,0,0,m,m),t.texImage2D(e.face,s,l,p,f,h.canvas)})),h.canvas.width=1,h.canvas.height=1):a.default.createImageBitmap&&(o=m,c=m,rt(t,r).forEach((function(u){var h=g[2*u.ndx+0]*m,d=g[2*u.ndx+1]*m;t.texImage2D(u.face,s,l,m,m,0,p,f,null),a.default.createImageBitmap(n,h,d,m,m,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then((function(n){K(t,r),t.bindTexture(i,e),t.texImage2D(u.face,s,l,p,f,n),q(t,r),et(r)&&tt(t,e,r,o,c,l,f)}))})))}else if(i===t.TEXTURE_3D||i===t.TEXTURE_2D_ARRAY){var v=Math.min(n.width,n.height),w=Math.max(n.width,n.height),T=w/v;if(T%1!=0)throw"can not compute 3D dimensions of element";var E=n.width===w?1:0,A=n.height===w?1:0;Q(t),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ROW_LENGTH,n.width),t.pixelStorei(t.UNPACK_IMAGE_HEIGHT,0),t.pixelStorei(t.UNPACK_SKIP_IMAGES,0),t.texImage3D(i,s,l,v,v,v,0,p,f,null);for(var k=0;k=0?y(r,e):n.indexOf("tan")>=0||n.indexOf("binorm")>=0?g(r,e):n.indexOf("norm")>=0&&b(r,e)})),t}function w(t,e,n){return t=t||2,{position:{numComponents:2,data:[(e=e||0)+-1*(t*=.5),(n=n||0)+-1*t,e+1*t,n+-1*t,e+-1*t,n+1*t,e+1*t,n+1*t]},normal:[0,0,1,0,0,1,0,0,1,0,0,1],texcoord:[0,0,1,0,0,1,1,1],indices:[0,1,2,2,1,3]}}function T(t,e,n,r,i){t=t||1,e=e||1,n=n||1,r=r||1,i=i||o.identity();for(var s=(n+1)*(r+1),a=d(3,s),c=d(3,s),u=d(2,s),l=0;l<=r;l++)for(var h=0;h<=n;h++){var p=h/n,f=l/r;a.push(t*p-.5*t,0,e*f-.5*e),c.push(0,1,0),u.push(p,f)}for(var m=n+1,g=d(3,n*r*2,Uint16Array),b=0;b 0");r=r||0,s=s||0;for(var a=(i=i||Math.PI)-r,c=(o=o||2*Math.PI)-s,u=(e+1)*(n+1),l=d(3,u),h=d(3,u),p=d(2,u),f=0;f<=n;f++)for(var m=0;m<=e;m++){var g=m/e,b=f/n,y=c*g,v=a*b,w=Math.sin(y),T=Math.cos(y),E=Math.sin(v),A=T*E,k=Math.cos(v),I=w*E;l.push(t*A,t*k,t*I),h.push(A,k,I),p.push(1-g,b)}for(var S=e+1,x=d(3,e*n*2,Uint16Array),O=0;Oi?(A=n,E=1,k=e):k=t+T/i*(e-t),-2!==T&&T!==i+2||(k=0,E=0),A-=n/2;for(var I=0;Ii?0:S*y,T<0?-1:T>i?1:v,T<0||T>i?0:x*y),f.push(I/r,1-E)}}for(var O=0;O 0");var c=(o=o||1)-(s=s||0),u=2*(i+1)*4,l=d(3,u),h=d(3,u),p=d(2,u);function f(t,e,n){return t+(e-t)*n}function m(e,n,o,u,d,m){for(var g=0;g<=i;g++){var b=n/1,y=g/i,v=2*(b-.5),w=(s+y*c)*Math.PI,T=Math.sin(w),E=Math.cos(w),A=f(t,e,T),k=v*r,I=E*t,S=T*A;l.push(k,I,S);var x=a.add(a.multiply([0,T,E],o),u);h.push(x),p.push(b*d+m,y)}}for(var g=0;g<2;g++){var b=2*(g/1-.5);m(e,g,[1,1,1],[0,0,0],1,0),m(e,g,[0,0,0],[b,0,0],0,0),m(n,g,[1,1,1],[0,0,0],1,0),m(n,g,[0,0,0],[b,0,0],0,1)}var y=d(3,2*i*4,Uint16Array);function v(t,e){for(var n=0;n0&&g!==e){var w=l+(g+1),T=l+g,E=l+g-p,A=l+(g+1)-p;u.push(w,T,E),u.push(w,E,A)}}l+=e+1}return{position:o,normal:a,texcoord:c,indices:u}}function R(t){return function(e){var n=t.apply(this,Array.prototype.slice.call(arguments,1));return r.createBuffersFromArrays(e,n)}}function D(t){return function(e){var n=t.apply(null,Array.prototype.slice.call(arguments,1));return r.createBufferInfoFromArrays(e,n)}}var P=["numComponents","size","type","normalize","stride","offset","attrib","name","attribName"];function L(t,e,n,r){r=r||0;for(var i=t.length,s=0;s0&&void 0!==arguments[0]?arguments[0]:n.nowObj;this.startTime=0,this.nowObj=t}static get USE_PERFORMANCE(){return!1}static get legacyDateCode(){return{now:function(){return(new Date).getTime()}}}static get nowObj(){return n.USE_PERFORMANCE&&"undefined"!=typeof self&&self.performance&&"now"in self.performance?self.performance:Date.now?Date:n.legacyDateCode}time(){return this.nowObj.now()}start(){this.startTime=this.nowObj.now()}timeElapsed(){return this.nowObj.now()-this.startTime}setTimeout(t,n){return e.setTimeout(t,n)}clearTimeout(t){e.clearTimeout(t)}}t.exports=n}).call(this,n(8))},function(t,e,n){const r=n(112),i=n(114);class s{static base64ToUint8Array(t){const e=r(t),n=e.length,i=new Uint8Array(n);for(let t=0;t1&&(r+=e);const i=n.inputs[r];return void 0===i?null:i.block}getOpcode(t){return void 0===t?null:t.opcode}getFields(t){return void 0===t?null:t.fields}getInputs(t){if(void 0===t)return null;let e=this._cache.inputs[t.id];if(void 0!==e)return e;e={};for(const n in t.inputs)n.substring(0,f.BRANCH_INPUT_PREFIX.length)!==f.BRANCH_INPUT_PREFIX&&(e[n]=t.inputs[n]);return this._cache.inputs[t.id]=e,e}getMutation(t){return void 0===t?null:t.mutation}getTopLevelScript(t){let e=this._blocks[t];if(void 0===e)return null;for(;null!==e.parent;)e=this._blocks[e.parent];return e.id}getProcedureDefinition(t){const e=this._cache.procedureDefinitions[t];if(void 0!==e)return e;for(const e in this._blocks){if(!Object.prototype.hasOwnProperty.call(this._blocks,e))continue;const n=this._blocks[e];if("procedures_definition"===n.opcode){const r=this._getCustomBlockInternal(n);if(r&&r.mutation.proccode===t)return this._cache.procedureDefinitions[t]=e,e}}return this._cache.procedureDefinitions[t]=null,null}getProcedureParamNamesAndIds(t){return this.getProcedureParamNamesIdsAndDefaults(t).slice(0,2)}getProcedureParamNamesIdsAndDefaults(t){const e=this._cache.procedureParamNames[t];if(void 0!==e)return e;for(const e in this._blocks){if(!Object.prototype.hasOwnProperty.call(this._blocks,e))continue;const n=this._blocks[e];if("procedures_prototype"===n.opcode&&n.mutation.proccode===t){const e=JSON.parse(n.mutation.argumentnames),r=JSON.parse(n.mutation.argumentids),i=JSON.parse(n.mutation.argumentdefaults);return this._cache.procedureParamNames[t]=[e,r,i],this._cache.procedureParamNames[t]}}const n=this.runtime.getAddonBlock(t);return n?(this._cache.procedureParamNames[t]=n.namesIdsDefaults,n.namesIdsDefaults):(this._cache.procedureParamNames[t]=null,null)}populateProcedureCache(){if(!this._cache.proceduresPopulated){for(const t in this._blocks){if(!Object.prototype.hasOwnProperty.call(this._blocks,t))continue;const e=this._blocks[t];if("procedures_prototype"!==e.opcode){if("procedures_definition"===e.opcode){const n=this._getCustomBlockInternal(e);if(n){const e=n.mutation.proccode;this._cache.procedureDefinitions[e]||(this._cache.procedureDefinitions[e]=t);continue}}}else{const t=e.mutation.proccode;if(!this._cache.procedureParamNames[t]){const n=JSON.parse(e.mutation.argumentnames),r=JSON.parse(e.mutation.argumentids),i=JSON.parse(e.mutation.argumentdefaults);this._cache.procedureParamNames[t]=[n,r,i]}}}this._cache.proceduresPopulated=!0}}duplicate(){const t=new f(this.runtime,this.forceNoGlow);return t._blocks=a.simple(this._blocks),t._scripts=a.simple(this._scripts),t}blocklyListen(t){if("object"!=typeof t)return;if("string"!=typeof t.blockId&&"string"!=typeof t.varId&&"string"!=typeof t.commentId)return;const e=this.runtime.getTargetForStage(),n=this.runtime.getEditingTarget();if("stackclick"!==t.element)switch(t.type){case"create":{const e=r(t);for(let t=0;tt.isOriginal));for(const e of n)if(e.lookupVariableByNameAndType(t.varName,t.varType,!0))return;e.createVariable(t.varId,t.varName,t.varType,t.isCloud),this.emitProjectChanged()}break;case"var_rename":if(n&&Object.prototype.hasOwnProperty.call(n.variables,t.varId))n.renameVariable(t.varId,t.newName),n.blocks.updateBlocksAfterVarRename(t.varId,t.newName);else{e.renameVariable(t.varId,t.newName);const n=this.runtime.targets;for(let e=0;e0&&"data_variable"!==e.opcode&&"data_listcontents"!==e.opcode){const t=p(e.id,e.fields);let n=this.runtime.monitorBlocks.getBlock(t);n||(n=JSON.parse(JSON.stringify(e)),n.id=t,this.runtime.monitorBlocks.createBlock(n)),e=n}const n=e.isMonitored;e.isMonitored=t.value;let r=!1;"data_variable"===e.opcode?r=!this.runtime.getTargetForStage().variables[e.fields.VARIABLE.id]:"data_listcontents"===e.opcode&&(r=!this.runtime.getTargetForStage().variables[e.fields.LIST.id]);const i=r||Object.prototype.hasOwnProperty.call(this.runtime.monitorBlockInfo,e.opcode)&&this.runtime.monitorBlockInfo[e.opcode].isSpriteSpecific;e.targetId=i?e.targetId||this.runtime.getEditingTarget().id:null,n&&!e.isMonitored?this.runtime.requestHideMonitor(e.id):!n&&e.isMonitored&&(this.runtime.requestShowMonitor(e.id)||this.runtime.requestAddMonitor(o({id:e.id,targetId:e.targetId,spriteName:e.targetId?this.runtime.getTargetById(e.targetId).getName():null,opcode:e.opcode,params:this._getBlockParams(e),value:"",mode:"data_listcontents"===e.opcode?"list":"default"})));break}}this.emitProjectChanged(),this.resetCache()}}moveBlock(t){if(!Object.prototype.hasOwnProperty.call(this._blocks,t.id))return;const e=this._blocks[t.id];let n=!1;if(t.newCoordinate&&(n=e.x!==t.newCoordinate.x||e.y!==t.newCoordinate.y,e.x=t.newCoordinate.x,e.y=t.newCoordinate.y),void 0!==t.oldParent){const e=this._blocks[t.oldParent];void 0!==t.oldInput&&e.inputs[t.oldInput].block===t.id?e.inputs[t.oldInput].block=null:e.next===t.id&&(e.next=null),this._blocks[t.id].parent=null,n=!0}if(void 0===t.newParent)this._addScript(t.id);else{if(this._deleteScript(t.id),void 0===t.newInput)this._blocks[t.newParent].next=t.id;else{let e=null;Object.prototype.hasOwnProperty.call(this._blocks[t.newParent].inputs,t.newInput)&&(e=this._blocks[t.newParent].inputs[t.newInput].shadow),this._blocks[t.id].shadow&&(e=t.id),this._blocks[t.newParent].inputs[t.newInput]={name:t.newInput,block:t.id,shadow:e}}this._blocks[t.id].parent=t.newParent,n=!0}this.resetCache(),n&&this.emitProjectChanged()}runAllMonitored(t){null===this._cache._monitored&&(this._cache._monitored=Object.keys(this._blocks).filter((t=>this.getBlock(t).isMonitored)).map((e=>{const n=this.getBlock(e).targetId;return{blockId:e,target:n?t.getTargetById(n):null}})));const e=this._cache._monitored;for(let n=0;nthis.deleteBlock(t)))}getAllVariableAndListReferences(t,e){const n=t||this._blocks,r=Object.create(null);for(const t in n){let i=null,s=null;if(n[t].fields.VARIABLE?(i=n[t].fields.VARIABLE,s=d.SCALAR_TYPE):n[t].fields.LIST?(i=n[t].fields.LIST,s=d.LIST_TYPE):e&&n[t].fields.BROADCAST_OPTION&&(i=n[t].fields.BROADCAST_OPTION,s=d.BROADCAST_MESSAGE_TYPE),i){const t=i.id;r[t]?r[t].push({referencingField:i,type:s}):r[t]=[{referencingField:i,type:s}]}}return r}updateBlocksAfterVarRename(t,e){const n=this._blocks;for(const r in n){let i=null;if(n[r].fields.VARIABLE?i=n[r].fields.VARIABLE:n[r].fields.LIST&&(i=n[r].fields.LIST),i){t===i.id&&(i.value=e)}}}updateTargetSpecificBlocks(t){const e=this._blocks;for(const n in e)t&&"event_whenthisspriteclicked"===e[n].opcode?e[n].opcode="event_whenstageclicked":t||"event_whenstageclicked"!==e[n].opcode||(e[n].opcode="event_whenthisspriteclicked")}updateAssetName(t,e,n){let r;if("costume"===n)r=this._getCostumeField.bind(this);else if("sound"===n)r=this._getSoundField.bind(this);else if("backdrop"===n)r=this._getBackdropField.bind(this);else{if("sprite"!==n)return;r=this._getSpriteField.bind(this)}const i=this._blocks;for(const n in i){const i=r(n);i&&i.value===t&&(i.value=e)}this.resetCache()}updateSensingOfReference(t,e,n){const r=this._blocks;let i=!1;for(const s in r){const o=r[s];if("sensing_of"===o.opcode&&o.fields.PROPERTY.value===t&&o.inputs.OBJECT.block===o.inputs.OBJECT.shadow){this.getBlock(o.inputs.OBJECT.block).fields.OBJECT.value===n&&(o.fields.PROPERTY.value=e,i=!0)}}return i&&this.resetCache(),i}_getCostumeField(t){const e=this.getBlock(t);return e&&Object.prototype.hasOwnProperty.call(e.fields,"COSTUME")?e.fields.COSTUME:null}_getSoundField(t){const e=this.getBlock(t);return e&&Object.prototype.hasOwnProperty.call(e.fields,"SOUND_MENU")?e.fields.SOUND_MENU:null}_getBackdropField(t){const e=this.getBlock(t);return e&&Object.prototype.hasOwnProperty.call(e.fields,"BACKDROP")?e.fields.BACKDROP:null}_getSpriteField(t){const e=this.getBlock(t);if(!e)return null;const n=["TOWARDS","TO","OBJECT","VIDEOONMENU2","DISTANCETOMENU","TOUCHINGOBJECTMENU","CLONE_OPTION"];for(let t=0;tthis.blockToXML(e,t))).join()}blockToXML(t,e){const n=this._blocks[t];if(!n)return;const r=n.shadow?"shadow":"block";let i="<".concat(r,'\n id="').concat(s(n.id),'"\n type="').concat(s(n.opcode),'"\n ').concat(n.topLevel?'x="'.concat(n.x,'" y="').concat(n.y,'"'):"","\n >");const o=n.comment;o&&(e?Object.prototype.hasOwnProperty.call(e,o)?i+=e[o].toXML():h.warn("Could not find comment with id: ".concat(o," in provided comment descriptions.")):h.warn("Cannot serialize comment with id: ".concat(o,"; no comment descriptions provided."))),n.mutation&&(i+=this.mutationToXML(n.mutation));for(const t in n.inputs){if(!Object.prototype.hasOwnProperty.call(n.inputs,t))continue;const r=n.inputs[t];(r.block||r.shadow)&&(i+=''),r.block&&(i+=this.blockToXML(r.block,e)),r.shadow&&r.shadow!==r.block&&(i+=this.blockToXML(r.shadow,e)),i+="")}for(const t in n.fields){if(!Object.prototype.hasOwnProperty.call(n.fields,t))continue;const e=n.fields[t];i+='".concat(a,"")}return n.next&&(i+="".concat(this.blockToXML(n.next,e),"")),i+=""),i}mutationToXML(t){let e="<".concat(t.tagName);for(const n in t){if("children"===n||"tagName"===n)continue;let r="string"==typeof t[n]?s(t[n]):t[n];"blockInfo"===n&&(r=s(JSON.stringify(t[n]))),e+=" ".concat(n,'="').concat(r,'"')}e+=">";for(let n=0;n"),e}_getBlockParams(t){const e={};for(const n in t.fields)e[n]=t.fields[n].value;for(const n in t.inputs){const r=this._blocks[t.inputs[n].block];for(const t in r.fields)e[t]=r.fields[t].value}return e}_getCustomBlockInternal(t){if(t.inputs&&t.inputs.custom_block)return this._blocks[t.inputs.custom_block.block]}_addScript(t){this._scripts.indexOf(t)>-1||(this._scripts.push(t),this._blocks[t].topLevel=!0)}_deleteScript(t){const e=this._scripts.indexOf(t);e>-1&&this._scripts.splice(e,1),this._blocks[t]&&(this._blocks[t].topLevel=!1)}}u.getCached=function(t,e,n){let r=t._cache._executeCached[e];if(void 0!==r)return r;const i=t.getBlock(e);return void 0===i?null:(r=void 0===n?{id:e,opcode:t.getOpcode(i),fields:t.getFields(i),inputs:t.getInputs(i),mutation:t.getMutation(i)}:new n(t,{id:e,opcode:t.getOpcode(i),fields:t.getFields(i),inputs:t.getInputs(i),mutation:t.getMutation(i)}),t._cache._executeCached[e]=r,r)};const m=l._RuntimeScriptCache;l.getScripts=function(t,e){let n=t._cache.scripts[e];if(!n){n=t._cache.scripts[e]=[];const r=t._scripts;for(let i=0;i=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function f(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(t).length;default:if(r)return V(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return N(this,e,n);case"utf8":case"utf-8":return S(this,e,n);case"ascii":return O(this,e,n);case"latin1":case"binary":return M(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function g(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function b(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:y(t,e,n,r,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):y(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,n,r,i){var s,o=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var l=-1;for(s=n;sa&&(n=a-c),s=n;s>=0;s--){for(var h=!0,d=0;di&&(r=i):r=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o>8,i=n%256,s.push(i),s.push(r);return s}(e,t.length-n),t,n,r)}function I(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function S(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(s=t[i+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(t){var e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},c.prototype.compare=function(t,e,n,r,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(r,i),l=t.slice(e,n),h=0;hi)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":return T(this,t,e,n);case"latin1":case"binary":return E(this,t,e,n);case"base64":return A(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function O(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",s=e;sn)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,n,r,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function P(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function L(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function B(t,e,n,r,i,s){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(t,e,n,r,s){return s||B(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function j(t,e,n,r,s){return s||B(t,0,n,8),i.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){var n,r=this.length;if((t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},c.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||R(t,e,this.length);for(var r=this[t],i=1,s=0;++s=(i*=128)&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||R(t,e,this.length);for(var r=e,i=1,s=this[t+--r];r>0&&(i*=256);)s+=this[t+--r]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||D(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+i]=t/s&255;return e+n},c.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):L(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);D(this,t,e,n,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o|0)-a&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):P(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):P(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):L(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,n){return U(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return U(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return j(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return j(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function G(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(8))},function(t,e,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,t.exports.once=function(t,e){return new Promise((function(n,r){function i(n){t.removeListener(e,s),r(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}b(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&b(t,"error",e,n)}(t,i,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function h(t,e,n,r){var i,s,o,a;if(u(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=l(t))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=d.bind(r);return i.listener=n,r.wrapFn=i,i}function f(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[t];if(void 0===c)return!1;if("function"==typeof c)s(c,this,e);else{var u=c.length,l=g(c,u);for(n=0;n=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},a.prototype.listeners=function(t){return f(this,t,!0)},a.prototype.rawListeners=function(t){return f(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},a.prototype.listenerCount=m,a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){n(103),t.exports={TextEncoder:TextEncoder,TextDecoder:TextDecoder}},function(t,e,n){(function(e,n,r,i){t.exports=function t(e,n,r){function i(o,a){if(!n[o]){if(!e[o]){if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[o]={exports:{}};e[o][0].call(u.exports,(function(t){return i(e[o][1][t]||t)}),u,u.exports,t,e,n,r)}return n[o].exports}for(var s=!1,o=0;o>2,a=(3&e)<<4|n>>4,c=1>6:64,u=2>4,n=(15&o)<<4|(a=s.indexOf(t.charAt(u++)))>>2,r=(3&a)<<6|(c=s.indexOf(t.charAt(u++))),d[l++]=e,64!==a&&(d[l++]=n),64!==c&&(d[l++]=r);return d}},{"./support":30,"./utils":32}],2:[function(t,e,n){"use strict";var r=t("./external"),i=t("./stream/DataWorker"),s=t("./stream/Crc32Probe"),o=t("./stream/DataLengthProbe");function a(t,e,n,r,i){this.compressedSize=t,this.uncompressedSize=e,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var t=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),e=this;return t.on("end",(function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),t},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(t,e,n){return t.pipe(new s).pipe(new o("uncompressedSize")).pipe(e.compressWorker(n)).pipe(new o("compressedSize")).withStreamInfo("compression",e)},e.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,n){"use strict";var r=t("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,n){"use strict";var r=t("./utils"),i=function(){for(var t,e=[],n=0;n<256;n++){t=n;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==r.getTypeOf(t)?function(t,e,n,r){var s=i,o=r+n;t^=-1;for(var a=r;a>>8^s[255&(t^e[a])];return~t}(0|e,t,t.length,0):function(t,e,n,r){var s=i,o=r+n;t^=-1;for(var a=r;a>>8^s[255&(t^e.charCodeAt(a))];return~t}(0|e,t,t.length,0):0}},{"./utils":32}],5:[function(t,e,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(t,e,n){"use strict";var r=null;r="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:r}},{lie:37}],7:[function(t,e,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=t("pako"),s=t("./utils"),o=t("./stream/GenericWorker"),a=r?"uint8array":"array";function c(t,e){o.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}n.magic="\b\0",s.inherits(c,o),c.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(a,t.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new i[this._pakoAction]({chunkSize:65536,raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},n.compressWorker=function(t){return new c("Deflate",t)},n.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,n){"use strict";function r(t,e){var n,r="";for(n=0;n>>=8;return r}function i(t,e,n,i,o,l){var h,d,p=t.file,f=t.compression,m=l!==a.utf8encode,g=s.transformTo("string",l(p.name)),b=s.transformTo("string",a.utf8encode(p.name)),y=p.comment,v=s.transformTo("string",l(y)),w=s.transformTo("string",a.utf8encode(y)),T=b.length!==p.name.length,E=w.length!==y.length,A="",k="",I="",S=p.dir,x=p.date,O={crc32:0,compressedSize:0,uncompressedSize:0};e&&!n||(O.crc32=t.crc32,O.compressedSize=t.compressedSize,O.uncompressedSize=t.uncompressedSize);var M=0;e&&(M|=8),m||!T&&!E||(M|=2048);var N=0,C=0;S&&(N|=16),"UNIX"===o?(C=798,N|=function(t,e){var n=t;return t||(n=e?16893:33204),(65535&n)<<16}(p.unixPermissions,S)):(C=20,N|=function(t){return 63&(t||0)}(p.dosPermissions)),h=x.getUTCHours(),h<<=6,h|=x.getUTCMinutes(),h<<=5,h|=x.getUTCSeconds()/2,d=x.getUTCFullYear()-1980,d<<=4,d|=x.getUTCMonth()+1,d<<=5,d|=x.getUTCDate(),T&&(k=r(1,1)+r(c(g),4)+b,A+="up"+r(k.length,2)+k),E&&(I=r(1,1)+r(c(v),4)+w,A+="uc"+r(I.length,2)+I);var R="";return R+="\n\0",R+=r(M,2),R+=f.magic,R+=r(h,2),R+=r(d,2),R+=r(O.crc32,4),R+=r(O.compressedSize,4),R+=r(O.uncompressedSize,4),R+=r(g.length,2),R+=r(A.length,2),{fileRecord:u.LOCAL_FILE_HEADER+R+g+A,dirRecord:u.CENTRAL_FILE_HEADER+r(C,2)+R+r(v.length,2)+"\0\0\0\0"+r(N,4)+r(i,4)+g+A+v}}var s=t("../utils"),o=t("../stream/GenericWorker"),a=t("../utf8"),c=t("../crc32"),u=t("../signature");function l(t,e,n,r){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}s.inherits(l,o),l.prototype.push=function(t){var e=t.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,o.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:n?(e+100*(n-r-1))/n:100}}))},l.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var n=i(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},l.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,n=i(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),e)this.push({data:function(t){return u.DATA_DESCRIPTOR+r(t.crc32,4)+r(t.compressedSize,4)+r(t.uncompressedSize,4)}(t),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},l.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)n=(n<<8)+this.byteAt(e);return this.index+=t,n},readString:function(t){return r.transformTo("string",this.readData(t))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=i},{"../utils":32}],19:[function(t,e,n){"use strict";var r=t("./Uint8ArrayReader");function i(t){r.call(this,t)}t("../utils").inherits(i,r),i.prototype.readData=function(t){this.checkOffset(t);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,n){"use strict";var r=t("./DataReader");function i(t){r.call(this,t)}t("../utils").inherits(i,r),i.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},i.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},i.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},i.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=i},{"../utils":32,"./DataReader":18}],21:[function(t,e,n){"use strict";var r=t("./ArrayReader"),i=t("./DataReader");function s(t){i.call(this,t)}t("../utils").inherits(s,r),s.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=s},{"../utils":32,"./ArrayReader":17,"./DataReader":18}],22:[function(t,e,n){"use strict";var r=t("../utils"),i=t("../support"),s=t("./ArrayReader"),o=t("./StringReader"),a=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");e.exports=function(t){var e=r.getTypeOf(t);return r.checkSupport(e),"string"!==e||i.uint8array?"nodebuffer"===e?new a(t):i.uint8array?new c(r.transformTo("uint8array",t)):new s(r.transformTo("array",t)):new o(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,n){"use strict";var r=t("./GenericWorker"),i=t("../utils");function s(t){r.call(this,"ConvertWorker to "+t),this.destType=t}i.inherits(s,r),s.prototype.processChunk=function(t){this.push({data:i.transformTo(this.destType,t.data),meta:t.meta})},e.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,n){"use strict";var r=t("./GenericWorker"),i=t("../crc32");function s(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(s,r),s.prototype.processChunk=function(t){this.streamInfo.crc32=i(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,n){"use strict";var r=t("../utils"),i=t("./GenericWorker");function s(t){i.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}r.inherits(s,i),s.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}i.prototype.processChunk.call(this,t)},e.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,n){"use strict";var r=t("../utils"),i=t("./GenericWorker");function s(t){i.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then((function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=r.getTypeOf(t),e.isPaused||e._tickAndRepeat()}),(function(t){e.error(t)}))}r.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+65536);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":case"nodebuffer":t=this.data.subarray(this.index,e);break;case"array":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,n){"use strict";function r(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var n=0;n "+t:t}},e.exports=r},{}],29:[function(t,n,r){"use strict";var i=t("../utils"),s=t("./ConvertWorker"),o=t("./GenericWorker"),a=t("../base64"),c=t("../support"),u=t("../external"),l=null;if(c.nodestream)try{l=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function h(t,n){return new u.Promise((function(r,s){var o=[],c=t._internalType,u=t._outputType,l=t._mimeType;t.on("data",(function(t,e){o.push(t),n&&n(e)})).on("error",(function(t){o=[],s(t)})).on("end",(function(){try{var t=function(t,e,n){switch(t){case"blob":return i.newBlob(i.transformTo("arraybuffer",e),n);case"base64":return a.encode(e);default:return i.transformTo(t,e)}}(u,function(t,n){var r,i=0,s=null,o=0;for(r=0;r>>6:(n<65536?e[o++]=224|n>>>12:(e[o++]=240|n>>>18,e[o++]=128|n>>>12&63),e[o++]=128|n>>>6&63),e[o++]=128|63&n);return e}(t)},n.utf8decode=function(t){return i.nodebuffer?r.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,n,i,s,o=t.length,c=new Array(2*o);for(e=n=0;e>10&1023,c[n++]=56320|1023&i)}return c.length!==n&&(c.subarray?c=c.subarray(0,n):c.length=n),r.applyFromCharCode(c)}(t=r.transformTo(i.uint8array?"uint8array":"array",t))},r.inherits(u,o),u.prototype.processChunk=function(t){var e=r.transformTo(i.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var s=e;(e=new Uint8Array(s.length+this.leftOver.length)).set(this.leftOver,0),e.set(s,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var o=function(t,e){var n;for((e=e||t.length)>t.length&&(e=t.length),n=e-1;0<=n&&128==(192&t[n]);)n--;return n<0||0===n?e:n+a[t[n]]>e?n:e}(e),c=e;o!==e.length&&(i.uint8array?(c=e.subarray(0,o),this.leftOver=e.subarray(o,e.length)):(c=e.slice(0,o),this.leftOver=e.slice(o,e.length))),this.push({data:n.utf8decode(c),meta:t.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=u,r.inherits(l,o),l.prototype.processChunk=function(t){this.push({data:n.utf8encode(t.data),meta:t.meta})},n.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,r){"use strict";var i=t("./support"),s=t("./base64"),o=t("./nodejsUtils"),a=t("./external");function c(t){return t}function u(t,e){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(t){var e,n,r,i=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4>>6:(n<65536?e[o++]=224|n>>>12:(e[o++]=240|n>>>18,e[o++]=128|n>>>12&63),e[o++]=128|n>>>6&63),e[o++]=128|63&n);return e},n.buf2binstring=function(t){return c(t,t.length)},n.binstring2buf=function(t){for(var e=new r.Buf8(t.length),n=0,i=e.length;n>10&1023,u[r++]=56320|1023&i)}return c(u,r)},n.utf8border=function(t,e){var n;for((e=e||t.length)>t.length&&(e=t.length),n=e-1;0<=n&&128==(192&t[n]);)n--;return n<0||0===n?e:n+o[t[n]]>e?n:e}},{"./common":41}],43:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){for(var i=65535&t,s=t>>>16&65535,o=0;0!==n;){for(n-=o=2e3>>1:t>>>1;e[n]=t}return e}();e.exports=function(t,e,n,i){var s=r,o=i+n;t^=-1;for(var a=i;a>>8^s[255&(t^e[a])];return~t}},{}],46:[function(t,e,n){"use strict";var r,i=t("../utils/common"),s=t("./trees"),o=t("./adler32"),a=t("./crc32"),c=t("./messages"),u=0,l=4,h=0,d=-2,p=-1,f=4,m=2,g=8,b=9,y=286,v=30,w=19,T=2*y+1,E=15,A=3,k=258,I=k+A+1,S=42,x=113,O=1,M=2,N=3,C=4;function R(t,e){return t.msg=c[e],e}function D(t){return(t<<1)-(4t.avail_out&&(n=t.avail_out),0!==n&&(i.arraySet(t.output,e.pending_buf,e.pending_out,n,t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))}function B(t,e){s._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,L(t.strm)}function U(t,e){t.pending_buf[t.pending++]=e}function j(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function F(t,e){var n,r,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match,c=t.strstart>t.w_size-I?t.strstart-(t.w_size-I):0,u=t.window,l=t.w_mask,h=t.prev,d=t.strstart+k,p=u[s+o-1],f=u[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(u[(n=e)+o]===f&&u[n+o-1]===p&&u[n]===u[s]&&u[++n]===u[s+1]){s+=2,n++;do{}while(u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&u[++s]===u[++n]&&sc&&0!=--i);return o<=t.lookahead?o:t.lookahead}function z(t){var e,n,r,s,c,u,l,h,d,p,f=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=f+(f-I)){for(i.arraySet(t.window,t.window,f,f,0),t.match_start-=f,t.strstart-=f,t.block_start-=f,e=n=t.hash_size;r=t.head[--e],t.head[e]=f<=r?r-f:0,--n;);for(e=n=f;r=t.prev[--e],t.prev[e]=f<=r?r-f:0,--n;);s+=f}if(0===t.strm.avail_in)break;if(u=t.strm,l=t.window,h=t.strstart+t.lookahead,p=void 0,(d=s)<(p=u.avail_in)&&(p=d),n=0===p?0:(u.avail_in-=p,i.arraySet(l,u.input,u.next_in,p,h),1===u.state.wrap?u.adler=o(u.adler,l,p,h):2===u.state.wrap&&(u.adler=a(u.adler,l,p,h)),u.next_in+=p,u.total_in+=p,p),t.lookahead+=n,t.lookahead+t.insert>=A)for(c=t.strstart-t.insert,t.ins_h=t.window[c],t.ins_h=(t.ins_h<=A&&(t.ins_h=(t.ins_h<=A)if(r=s._tr_tally(t,t.strstart-t.match_start,t.match_length-A),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=A){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=A&&(t.ins_h=(t.ins_h<=A&&t.match_length<=t.prev_length){for(i=t.strstart+t.lookahead-A,r=s._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-A),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=i&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead<=1){if(z(t),0===t.lookahead&&e===u)return O;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var r=t.block_start+n;if((0===t.strstart||t.strstart>=r)&&(t.lookahead=t.strstart-r,t.strstart=r,B(t,!1),0===t.strm.avail_out))return O;if(t.strstart-t.block_start>=t.w_size-I&&(B(t,!1),0===t.strm.avail_out))return O}return t.insert=0,e===l?(B(t,!0),0===t.strm.avail_out?N:C):(t.strstart>t.block_start&&(B(t,!1),t.strm.avail_out),O)})),new Y(4,4,8,4,V),new Y(4,5,16,8,V),new Y(4,6,32,32,V),new Y(4,4,16,16,G),new Y(8,16,32,32,G),new Y(8,16,128,128,G),new Y(8,32,128,256,G),new Y(32,128,258,1024,G),new Y(32,258,258,4096,G)],n.deflateInit=function(t,e){return q(t,e,g,15,8,0)},n.deflateInit2=q,n.deflateReset=K,n.deflateResetKeep=W,n.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?d:(t.state.gzhead=e,h):d},n.deflate=function(t,e){var n,i,o,c;if(!t||!t.state||5>8&255),U(i,i.gzhead.time>>16&255),U(i,i.gzhead.time>>24&255),U(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),U(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(U(i,255&i.gzhead.extra.length),U(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=a(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(U(i,0),U(i,0),U(i,0),U(i,0),U(i,0),U(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),U(i,3),i.status=x);else{var p=g+(i.w_bits-8<<4)<<8;p|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(p|=32),p+=31-p%31,i.status=x,j(i,p),0!==i.strstart&&(j(i,t.adler>>>16),j(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(t.adler=a(t.adler,i.pending_buf,i.pending-o,o)),L(t),o=i.pending,i.pending!==i.pending_buf_size));)U(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(t.adler=a(t.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(t.adler=a(t.adler,i.pending_buf,i.pending-o,o)),L(t),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(t.adler=a(t.adler,i.pending_buf,i.pending-o,o)),0===c&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(t.adler=a(t.adler,i.pending_buf,i.pending-o,o)),L(t),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(t.adler=a(t.adler,i.pending_buf,i.pending-o,o)),0===c&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&L(t),i.pending+2<=i.pending_buf_size&&(U(i,255&t.adler),U(i,t.adler>>8&255),t.adler=0,i.status=x)):i.status=x),0!==i.pending){if(L(t),0===t.avail_out)return i.last_flush=-1,h}else if(0===t.avail_in&&D(e)<=D(n)&&e!==l)return R(t,-5);if(666===i.status&&0!==t.avail_in)return R(t,-5);if(0!==t.avail_in||0!==i.lookahead||e!==u&&666!==i.status){var f=2===i.strategy?function(t,e){for(var n;;){if(0===t.lookahead&&(z(t),0===t.lookahead)){if(e===u)return O;break}if(t.match_length=0,n=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(B(t,!1),0===t.strm.avail_out))return O}return t.insert=0,e===l?(B(t,!0),0===t.strm.avail_out?N:C):t.last_lit&&(B(t,!1),0===t.strm.avail_out)?O:M}(i,e):3===i.strategy?function(t,e){for(var n,r,i,o,a=t.window;;){if(t.lookahead<=k){if(z(t),t.lookahead<=k&&e===u)return O;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=A&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=A?(n=s._tr_tally(t,1,t.match_length-A),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(B(t,!1),0===t.strm.avail_out))return O}return t.insert=0,e===l?(B(t,!0),0===t.strm.avail_out?N:C):t.last_lit&&(B(t,!1),0===t.strm.avail_out)?O:M}(i,e):r[i.level].func(i,e);if(f!==N&&f!==C||(i.status=666),f===O||f===N)return 0===t.avail_out&&(i.last_flush=-1),h;if(f===M&&(1===e?s._tr_align(i):5!==e&&(s._tr_stored_block(i,0,0,!1),3===e&&(P(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),L(t),0===t.avail_out))return i.last_flush=-1,h}return e!==l?h:i.wrap<=0?1:(2===i.wrap?(U(i,255&t.adler),U(i,t.adler>>8&255),U(i,t.adler>>16&255),U(i,t.adler>>24&255),U(i,255&t.total_in),U(i,t.total_in>>8&255),U(i,t.total_in>>16&255),U(i,t.total_in>>24&255)):(j(i,t.adler>>>16),j(i,65535&t.adler)),L(t),0=n.w_size&&(0===a&&(P(n.head),n.strstart=0,n.block_start=0,n.insert=0),p=new i.Buf8(n.w_size),i.arraySet(p,e,f-n.w_size,n.w_size,0),e=p,f=n.w_size),c=t.avail_in,u=t.next_in,l=t.input,t.avail_in=f,t.next_in=0,t.input=e,z(n);n.lookahead>=A;){for(r=n.strstart,s=n.lookahead-(A-1);n.ins_h=(n.ins_h<>>=w=v>>>24,f-=w,0==(w=v>>>16&255))S[s++]=65535&v;else{if(!(16&w)){if(!(64&w)){v=m[(65535&v)+(p&(1<>>=w,f-=w),f<15&&(p+=I[r++]<>>=w=v>>>24,f-=w,!(16&(w=v>>>16&255))){if(!(64&w)){v=g[(65535&v)+(p&(1<>>=w,f-=w,(w=s-o)>3,p&=(1<<(f-=T<<3))-1,t.next_in=r,t.next_out=s,t.avail_in=r>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=d,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new r.Buf32(p),e.distcode=e.distdyn=new r.Buf32(f),e.sane=1,e.back=-1,l):h}function y(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,b(t)):h}function v(t,e){var n,r;return t&&t.state?(r=t.state,e<0?(n=0,e=-e):(n=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=o.wsize?(r.arraySet(o.window,e,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(s=o.wsize-o.wnext)&&(s=i),r.arraySet(o.window,e,n-i,s,o.wnext),(i-=s)?(r.arraySet(o.window,e,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=s(n.check,z,2,0),T=w=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&w)<<8)+(w>>8))%31){t.msg="incorrect header check",n.mode=30;break}if(8!=(15&w)){t.msg="unknown compression method",n.mode=30;break}if(T-=4,L=8+(15&(w>>>=4)),0===n.wbits)n.wbits=L;else if(L>n.wbits){t.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(z[0]=255&w,z[1]=w>>>8&255,n.check=s(n.check,z,2,0)),T=w=0,n.mode=3;case 3:for(;T<32;){if(0===y)break t;y--,w+=p[g++]<>>8&255,z[2]=w>>>16&255,z[3]=w>>>24&255,n.check=s(n.check,z,4,0)),T=w=0,n.mode=4;case 4:for(;T<16;){if(0===y)break t;y--,w+=p[g++]<>8),512&n.flags&&(z[0]=255&w,z[1]=w>>>8&255,n.check=s(n.check,z,2,0)),T=w=0,n.mode=5;case 5:if(1024&n.flags){for(;T<16;){if(0===y)break t;y--,w+=p[g++]<>>8&255,n.check=s(n.check,z,2,0)),T=w=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(y<(S=n.length)&&(S=y),S&&(n.head&&(L=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,p,g,S,L)),512&n.flags&&(n.check=s(n.check,p,S,g)),y-=S,g+=S,n.length-=S),n.length))break t;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===y)break t;for(S=0;L=p[g+S++],n.head&&L&&n.length<65536&&(n.head.name+=String.fromCharCode(L)),L&&S>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=12;break;case 10:for(;T<32;){if(0===y)break t;y--,w+=p[g++]<>>=7&T,T-=7&T,n.mode=27;break}for(;T<3;){if(0===y)break t;y--,w+=p[g++]<>>=1)){case 0:n.mode=14;break;case 1:if(k(n),n.mode=20,6!==e)break;w>>>=2,T-=2;break t;case 2:n.mode=17;break;case 3:t.msg="invalid block type",n.mode=30}w>>>=2,T-=2;break;case 14:for(w>>>=7&T,T-=7&T;T<32;){if(0===y)break t;y--,w+=p[g++]<>>16^65535)){t.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&w,T=w=0,n.mode=15,6===e)break t;case 15:n.mode=16;case 16:if(S=n.length){if(y>>=5,T-=5,n.ndist=1+(31&w),w>>>=5,T-=5,n.ncode=4+(15&w),w>>>=4,T-=4,286>>=3,T-=3}for(;n.have<19;)n.lens[V[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,U={bits:n.lenbits},B=a(0,n.lens,0,19,n.lencode,0,n.work,U),n.lenbits=U.bits,B){t.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,C=65535&F,!((M=F>>>24)<=T);){if(0===y)break t;y--,w+=p[g++]<>>=M,T-=M,n.lens[n.have++]=C;else{if(16===C){for(j=M+2;T>>=M,T-=M,0===n.have){t.msg="invalid bit length repeat",n.mode=30;break}L=n.lens[n.have-1],S=3+(3&w),w>>>=2,T-=2}else if(17===C){for(j=M+3;T>>=M)),w>>>=3,T-=3}else{for(j=M+7;T>>=M)),w>>>=7,T-=7}if(n.have+S>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=30;break}for(;S--;)n.lens[n.have++]=L}}if(30===n.mode)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,U={bits:n.lenbits},B=a(c,n.lens,0,n.nlen,n.lencode,0,n.work,U),n.lenbits=U.bits,B){t.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,U={bits:n.distbits},B=a(u,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,U),n.distbits=U.bits,B){t.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===e)break t;case 20:n.mode=21;case 21:if(6<=y&&258<=v){t.next_out=b,t.avail_out=v,t.next_in=g,t.avail_in=y,n.hold=w,n.bits=T,o(t,A),b=t.next_out,f=t.output,v=t.avail_out,g=t.next_in,p=t.input,y=t.avail_in,w=n.hold,T=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;N=(F=n.lencode[w&(1<>>16&255,C=65535&F,!((M=F>>>24)<=T);){if(0===y)break t;y--,w+=p[g++]<>R)])>>>16&255,C=65535&F,!(R+(M=F>>>24)<=T);){if(0===y)break t;y--,w+=p[g++]<>>=R,T-=R,n.back+=R}if(w>>>=M,T-=M,n.back+=M,n.length=C,0===N){n.mode=26;break}if(32&N){n.back=-1,n.mode=12;break}if(64&N){t.msg="invalid literal/length code",n.mode=30;break}n.extra=15&N,n.mode=22;case 22:if(n.extra){for(j=n.extra;T>>=n.extra,T-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;N=(F=n.distcode[w&(1<>>16&255,C=65535&F,!((M=F>>>24)<=T);){if(0===y)break t;y--,w+=p[g++]<>R)])>>>16&255,C=65535&F,!(R+(M=F>>>24)<=T);){if(0===y)break t;y--,w+=p[g++]<>>=R,T-=R,n.back+=R}if(w>>>=M,T-=M,n.back+=M,64&N){t.msg="invalid distance code",n.mode=30;break}n.offset=C,n.extra=15&N,n.mode=24;case 24:if(n.extra){for(j=n.extra;T>>=n.extra,T-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===v)break t;if(S=A-v,n.offset>S){if((S=n.offset-S)>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=30;break}x=S>n.wnext?(S-=n.wnext,n.wsize-S):n.wnext-S,S>n.length&&(S=n.length),O=n.window}else O=f,x=b-n.offset,S=n.length;for(vy?(w=U[j+h[k]],D[P+h[k]]):(w=96,0),p=1<>M)+(f-=p)]=v<<24|w<<16|T,0!==f;);for(p=1<>=1;if(0!==p?(R&=p-1,R+=p):R=0,k++,0==--L[A]){if(A===S)break;A=e[n+h[k]]}if(x>>7)]}function U(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function j(t,e,n){t.bi_valid>m-n?(t.bi_buf|=e<>m-t.bi_valid,t.bi_valid+=n-m):(t.bi_buf|=e<>>=1,n<<=1,0<--e;);return n>>>1}function V(t,e,n){var r,i,s=new Array(f+1),o=0;for(r=1;r<=f;r++)s[r]=o=o+n[r-1]<<1;for(i=0;i<=e;i++){var a=t[2*i+1];0!==a&&(t[2*i]=z(s[a]++,a))}}function G(t){var e;for(e=0;e>1;1<=n;n--)W(t,s,n);for(i=c;n=t.heap[1],t.heap[1]=t.heap[t.heap_len--],W(t,s,1),r=t.heap[1],t.heap[--t.heap_max]=n,t.heap[--t.heap_max]=r,s[2*i]=s[2*n]+s[2*r],t.depth[i]=(t.depth[n]>=t.depth[r]?t.depth[n]:t.depth[r])+1,s[2*n+1]=s[2*r+1]=i,t.heap[1]=i++,W(t,s,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var n,r,i,s,o,a,c=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,h=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,m=e.stat_desc.extra_base,g=e.stat_desc.max_length,b=0;for(s=0;s<=f;s++)t.bl_count[s]=0;for(c[2*t.heap[t.heap_max]+1]=0,n=t.heap_max+1;n>=7;r>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return i;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return s;for(e=32;e>>3,(a=t.static_len+3+7>>>3)<=o&&(o=a)):o=a=n+5,n+4<=o&&-1!==e?J(t,e,n,r):4===t.strategy||a===o?(j(t,2+(r?1:0),3),K(t,I,S)):(j(t,4+(r?1:0),3),function(t,e,n,r){var i;for(j(t,e-257,5),j(t,n-1,5),j(t,r-4,4),i=0;i>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(O[n]+u+1)]++,t.dyn_dtree[2*B(e)]++),t.last_lit===t.lit_bufsize-1},n._tr_align=function(t){j(t,2,3),F(t,b,I),function(t){16===t.bi_valid?(U(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":41}],53:[function(t,e,n){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,e,n){(function(t){!function(t,e){"use strict";if(!t.setImmediate){var n,r,s,o,a=1,c={},u=!1,l=t.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(t);h=h&&h.setTimeout?h:t,n="[object process]"==={}.toString.call(t.process)?function(t){i.nextTick((function(){p(t)}))}:function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?(o="setImmediate$"+Math.random()+"$",t.addEventListener?t.addEventListener("message",f,!1):t.attachEvent("onmessage",f),function(e){t.postMessage(o+e,"*")}):t.MessageChannel?((s=new MessageChannel).port1.onmessage=function(t){p(t.data)},function(t){s.port2.postMessage(t)}):l&&"onreadystatechange"in l.createElement("script")?(r=l.documentElement,function(t){var e=l.createElement("script");e.onreadystatechange=function(){p(t),e.onreadystatechange=null,r.removeChild(e),e=null},r.appendChild(e)}):function(t){setTimeout(p,0,t)},h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r>24&255;return{r:t>>16&255,g:t>>8&255,b:255&t,a:e>0?e:255}}static hexToRgb(t){t.startsWith("#")&&(t=t.substring(1));const e=parseInt(t,16);if(isNaN(e))return null;if(6===t.length)return{r:e>>16&255,g:e>>8&255,b:255&e};if(3===t.length){const t=e>>8&15,n=e>>4&15,r=15&e;return{r:t<<4|t,g:n<<4|n,b:r<<4|r}}return null}static rgbToHex(t){return n.decimalToHex(n.rgbToDecimal(t))}static rgbToDecimal(t){return(t.r<<16)+(t.g<<8)+t.b}static hexToDecimal(t){return n.rgbToDecimal(n.hexToRgb(t))}static hsvToRgb(t){let e=t.h%360;e<0&&(e+=360);const n=Math.max(0,Math.min(t.s,1)),r=Math.max(0,Math.min(t.v,1)),i=Math.floor(e/60),s=e/60-i,o=r*(1-n),a=r*(1-n*s),c=r*(1-n*(1-s));let u,l,h;switch(i){default:case 0:u=r,l=c,h=o;break;case 1:u=a,l=r,h=o;break;case 2:u=o,l=r,h=c;break;case 3:u=o,l=a,h=r;break;case 4:u=c,l=o,h=r;break;case 5:u=r,l=o,h=a}return{r:Math.floor(255*u),g:Math.floor(255*l),b:Math.floor(255*h)}}static rgbToHsv(t){const e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(Math.min(e,n),r),s=Math.max(Math.max(e,n),r);let o=0,a=0;if(i!==s){o=60*((e===i?3:n===i?5:1)-(e===i?n-r:n===i?r-e:e-n)/(s-i))%360,a=(s-i)/s}return{h:o,s:a,v:s}}static mixRgb(t,e,n){if(n<=0)return t;if(n>=1)return e;const r=1-n;return{r:r*t.r+n*e.r,g:r*t.g+n*e.g,b:r*t.b+n*e.b}}}t.exports=n},function(t,e,n){t.exports=function(){"use strict";var t=Array.prototype.slice;function e(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function n(t){return o(t)?t:q(t)}function r(t){return a(t)?t:Q(t)}function i(t){return c(t)?t:X(t)}function s(t){return o(t)&&!u(t)?t:Z(t)}function o(t){return!(!t||!t[h])}function a(t){return!(!t||!t[d])}function c(t){return!(!t||!t[p])}function u(t){return a(t)||c(t)}function l(t){return!(!t||!t[f])}e(r,n),e(i,n),e(s,n),n.isIterable=o,n.isKeyed=a,n.isIndexed=c,n.isAssociative=u,n.isOrdered=l,n.Keyed=r,n.Indexed=i,n.Set=s;var h="@@__IMMUTABLE_ITERABLE__@@",d="@@__IMMUTABLE_KEYED__@@",p="@@__IMMUTABLE_INDEXED__@@",f="@@__IMMUTABLE_ORDERED__@@",m="delete",g=5,b=1<>>0;if(""+n!==e||4294967295===n)return NaN;e=n}return e<0?S(t)+e:e}function O(){return!0}function M(t,e,n){return(0===t||void 0!==n&&t<=-n)&&(void 0===e||void 0!==n&&e>=n)}function N(t,e){return R(t,e,0)}function C(t,e){return R(t,e,e)}function R(t,e,n){return void 0===t?n:t<0?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}var D=0,P=1,L=2,B="function"==typeof Symbol&&Symbol.iterator,U="@@iterator",j=B||U;function F(t){this.next=t}function z(t,e,n,r){var i=0===t?e:1===t?n:[e,n];return r?r.value=i:r={value:i,done:!1},r}function V(){return{value:void 0,done:!0}}function G(t){return!!W(t)}function Y(t){return t&&"function"==typeof t.next}function H(t){var e=W(t);return e&&e.call(t)}function W(t){var e=t&&(B&&t[B]||t[U]);if("function"==typeof e)return e}function K(t){return t&&"number"==typeof t.length}function q(t){return null==t?ot():o(t)?t.toSeq():ut(t)}function Q(t){return null==t?ot().toKeyedSeq():o(t)?a(t)?t.toSeq():t.fromEntrySeq():at(t)}function X(t){return null==t?ot():o(t)?a(t)?t.entrySeq():t.toIndexedSeq():ct(t)}function Z(t){return(null==t?ot():o(t)?a(t)?t.entrySeq():t:ct(t)).toSetSeq()}F.prototype.toString=function(){return"[Iterator]"},F.KEYS=D,F.VALUES=P,F.ENTRIES=L,F.prototype.inspect=F.prototype.toSource=function(){return this.toString()},F.prototype[j]=function(){return this},e(q,n),q.of=function(){return q(arguments)},q.prototype.toSeq=function(){return this},q.prototype.toString=function(){return this.__toString("Seq {","}")},q.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},q.prototype.__iterate=function(t,e){return ht(this,t,e,!0)},q.prototype.__iterator=function(t,e){return dt(this,t,e,!0)},e(Q,q),Q.prototype.toKeyedSeq=function(){return this},e(X,q),X.of=function(){return X(arguments)},X.prototype.toIndexedSeq=function(){return this},X.prototype.toString=function(){return this.__toString("Seq [","]")},X.prototype.__iterate=function(t,e){return ht(this,t,e,!1)},X.prototype.__iterator=function(t,e){return dt(this,t,e,!1)},e(Z,q),Z.of=function(){return Z(arguments)},Z.prototype.toSetSeq=function(){return this},q.isSeq=st,q.Keyed=Q,q.Set=Z,q.Indexed=X;var J,_,$,tt="@@__IMMUTABLE_SEQ__@@";function et(t){this._array=t,this.size=t.length}function nt(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}function rt(t){this._iterable=t,this.size=t.length||t.size}function it(t){this._iterator=t,this._iteratorCache=[]}function st(t){return!(!t||!t[tt])}function ot(){return J||(J=new et([]))}function at(t){var e=Array.isArray(t)?new et(t).fromEntrySeq():Y(t)?new it(t).fromEntrySeq():G(t)?new rt(t).fromEntrySeq():"object"==typeof t?new nt(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function ct(t){var e=lt(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function ut(t){var e=lt(t)||"object"==typeof t&&new nt(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function lt(t){return K(t)?new et(t):Y(t)?new it(t):G(t)?new rt(t):void 0}function ht(t,e,n,r){var i=t._cache;if(i){for(var s=i.length-1,o=0;o<=s;o++){var a=i[n?s-o:o];if(!1===e(a[1],r?a[0]:o,t))return o+1}return o}return t.__iterateUncached(e,n)}function dt(t,e,n,r){var i=t._cache;if(i){var s=i.length-1,o=0;return new F((function(){var t=i[n?s-o:o];return o++>s?V():z(e,r?t[0]:o-1,t[1])}))}return t.__iteratorUncached(e,n)}function pt(t,e){return e?ft(e,t,"",{"":t}):mt(t)}function ft(t,e,n,r){return Array.isArray(e)?t.call(r,n,X(e).map((function(n,r){return ft(t,n,r,e)}))):gt(e)?t.call(r,n,Q(e).map((function(n,r){return ft(t,n,r,e)}))):e}function mt(t){return Array.isArray(t)?X(t).map(mt).toList():gt(t)?Q(t).map(mt).toMap():t}function gt(t){return t&&(t.constructor===Object||void 0===t.constructor)}function bt(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!("function"!=typeof t.equals||"function"!=typeof e.equals||!t.equals(e))}function yt(t,e){if(t===e)return!0;if(!o(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||a(t)!==a(e)||c(t)!==c(e)||l(t)!==l(e))return!1;if(0===t.size&&0===e.size)return!0;var n=!u(t);if(l(t)){var r=t.entries();return e.every((function(t,e){var i=r.next().value;return i&&bt(i[1],t)&&(n||bt(i[0],e))}))&&r.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var s=t;t=e,e=s}var h=!0,d=e.__iterate((function(e,r){if(n?!t.has(e):i?!bt(e,t.get(r,v)):!bt(t.get(r,v),e))return h=!1,!1}));return h&&t.size===d}function vt(t,e){if(!(this instanceof vt))return new vt(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(_)return _;_=this}}function wt(t,e){if(!t)throw new Error(e)}function Tt(t,e,n){if(!(this instanceof Tt))return new Tt(t,e,n);if(wt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),n=void 0===n?1:Math.abs(n),er?V():z(t,i,n[e?r-i++:i++])}))},e(nt,Q),nt.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},nt.prototype.has=function(t){return this._object.hasOwnProperty(t)},nt.prototype.__iterate=function(t,e){for(var n=this._object,r=this._keys,i=r.length-1,s=0;s<=i;s++){var o=r[e?i-s:s];if(!1===t(n[o],o,this))return s+1}return s},nt.prototype.__iterator=function(t,e){var n=this._object,r=this._keys,i=r.length-1,s=0;return new F((function(){var o=r[e?i-s:s];return s++>i?V():z(t,o,n[o])}))},nt.prototype[f]=!0,e(rt,X),rt.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var n=H(this._iterable),r=0;if(Y(n))for(var i;!(i=n.next()).done&&!1!==t(i.value,r++,this););return r},rt.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var n=H(this._iterable);if(!Y(n))return new F(V);var r=0;return new F((function(){var e=n.next();return e.done?e:z(t,r++,e.value)}))},e(it,X),it.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var n,r=this._iterator,i=this._iteratorCache,s=0;s=r.length){var e=n.next();if(e.done)return e;r[i]=e.value}return z(t,i,r[i++])}))},e(vt,X),vt.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},vt.prototype.get=function(t,e){return this.has(t)?this._value:e},vt.prototype.includes=function(t){return bt(this._value,t)},vt.prototype.slice=function(t,e){var n=this.size;return M(t,e,n)?this:new vt(this._value,C(e,n)-N(t,n))},vt.prototype.reverse=function(){return this},vt.prototype.indexOf=function(t){return bt(this._value,t)?0:-1},vt.prototype.lastIndexOf=function(t){return bt(this._value,t)?this.size:-1},vt.prototype.__iterate=function(t,e){for(var n=0;n=0&&e=0&&nn?V():z(t,s++,o)}))},Tt.prototype.equals=function(t){return t instanceof Tt?this._start===t._start&&this._end===t._end&&this._step===t._step:yt(this,t)},e(Et,n),e(At,Et),e(kt,Et),e(It,Et),Et.Keyed=At,Et.Indexed=kt,Et.Set=It;var St="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var n=65535&(t|=0),r=65535&(e|=0);return n*r+((t>>>16)*r+n*(e>>>16)<<16>>>0)|0};function xt(t){return t>>>1&1073741824|3221225471&t}function Ot(t){if(!1===t||null==t)return 0;if("function"==typeof t.valueOf&&(!1===(t=t.valueOf())||null==t))return 0;if(!0===t)return 1;var e=typeof t;if("number"===e){if(t!=t||t===1/0)return 0;var n=0|t;for(n!==t&&(n^=4294967295*t);t>4294967295;)n^=t/=4294967295;return xt(n)}if("string"===e)return t.length>Ft?Mt(t):Nt(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return Ct(t);if("function"==typeof t.toString)return Nt(t.toString());throw new Error("Value type "+e+" cannot be hashed.")}function Mt(t){var e=Gt[t];return void 0===e&&(e=Nt(t),Vt===zt&&(Vt=0,Gt={}),Vt++,Gt[t]=e),e}function Nt(t){for(var e=0,n=0;n0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}var Lt,Bt="function"==typeof WeakMap;Bt&&(Lt=new WeakMap);var Ut=0,jt="__immutablehash__";"function"==typeof Symbol&&(jt=Symbol(jt));var Ft=16,zt=255,Vt=0,Gt={};function Yt(t){wt(t!==1/0,"Cannot perform this action with an infinite size.")}function Ht(t){return null==t?ie():Wt(t)&&!l(t)?t:ie().withMutations((function(e){var n=r(t);Yt(n.size),n.forEach((function(t,n){return e.set(n,t)}))}))}function Wt(t){return!(!t||!t[qt])}e(Ht,At),Ht.of=function(){var e=t.call(arguments,0);return ie().withMutations((function(t){for(var n=0;n=e.length)throw new Error("Missing value for key: "+e[n]);t.set(e[n],e[n+1])}}))},Ht.prototype.toString=function(){return this.__toString("Map {","}")},Ht.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Ht.prototype.set=function(t,e){return se(this,t,e)},Ht.prototype.setIn=function(t,e){return this.updateIn(t,v,(function(){return e}))},Ht.prototype.remove=function(t){return se(this,t,v)},Ht.prototype.deleteIn=function(t){return this.updateIn(t,(function(){return v}))},Ht.prototype.update=function(t,e,n){return 1===arguments.length?t(this):this.updateIn([t],e,n)},Ht.prototype.updateIn=function(t,e,n){n||(n=e,e=void 0);var r=ge(this,En(t),e,n);return r===v?void 0:r},Ht.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):ie()},Ht.prototype.merge=function(){return de(this,void 0,arguments)},Ht.prototype.mergeWith=function(e){return de(this,e,t.call(arguments,1))},Ht.prototype.mergeIn=function(e){var n=t.call(arguments,1);return this.updateIn(e,ie(),(function(t){return"function"==typeof t.merge?t.merge.apply(t,n):n[n.length-1]}))},Ht.prototype.mergeDeep=function(){return de(this,pe,arguments)},Ht.prototype.mergeDeepWith=function(e){var n=t.call(arguments,1);return de(this,fe(e),n)},Ht.prototype.mergeDeepIn=function(e){var n=t.call(arguments,1);return this.updateIn(e,ie(),(function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,n):n[n.length-1]}))},Ht.prototype.sort=function(t){return Ge(hn(this,t))},Ht.prototype.sortBy=function(t,e){return Ge(hn(this,e,t))},Ht.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Ht.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new k)},Ht.prototype.asImmutable=function(){return this.__ensureOwner()},Ht.prototype.wasAltered=function(){return this.__altered},Ht.prototype.__iterator=function(t,e){return new te(this,t,e)},Ht.prototype.__iterate=function(t,e){var n=this,r=0;return this._root&&this._root.iterate((function(e){return r++,t(e[1],e[0],n)}),e),r},Ht.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?re(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ht.isMap=Wt;var Kt,qt="@@__IMMUTABLE_MAP__@@",Qt=Ht.prototype;function Xt(t,e){this.ownerID=t,this.entries=e}function Zt(t,e,n){this.ownerID=t,this.bitmap=e,this.nodes=n}function Jt(t,e,n){this.ownerID=t,this.count=e,this.nodes=n}function _t(t,e,n){this.ownerID=t,this.keyHash=e,this.entries=n}function $t(t,e,n){this.ownerID=t,this.keyHash=e,this.entry=n}function te(t,e,n){this._type=e,this._reverse=n,this._stack=t._root&&ne(t._root)}function ee(t,e){return z(t,e[0],e[1])}function ne(t,e){return{node:t,index:0,__prev:e}}function re(t,e,n,r){var i=Object.create(Qt);return i.size=t,i._root=e,i.__ownerID=n,i.__hash=r,i.__altered=!1,i}function ie(){return Kt||(Kt=re(0))}function se(t,e,n){var r,i;if(t._root){var s=E(w),o=E(T);if(r=oe(t._root,t.__ownerID,0,void 0,e,n,s,o),!o.value)return t;i=t.size+(s.value?n===v?-1:1:0)}else{if(n===v)return t;i=1,r=new Xt(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=i,t._root=r,t.__hash=void 0,t.__altered=!0,t):r?re(i,r):ie()}function oe(t,e,n,r,i,s,o,a){return t?t.update(e,n,r,i,s,o,a):s===v?t:(A(a),A(o),new $t(e,r,[i,s]))}function ae(t){return t.constructor===$t||t.constructor===_t}function ce(t,e,n,r,i){if(t.keyHash===r)return new _t(e,r,[t.entry,i]);var s,o=(0===n?t.keyHash:t.keyHash>>>n)&y,a=(0===n?r:r>>>n)&y;return new Zt(e,1<>>=1)o[a]=1&n?e[s++]:void 0;return o[r]=i,new Jt(t,s+1,o)}function de(t,e,n){for(var i=[],s=0;s>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function ye(t,e,n,r){var i=r?t:I(t);return i[e]=n,i}function ve(t,e,n,r){var i=t.length+1;if(r&&e+1===i)return t[e]=n,t;for(var s=new Array(i),o=0,a=0;a=Te)return ue(t,c,r,i);var d=t&&t===this.ownerID,p=d?c:I(c);return h?a?u===l-1?p.pop():p[u]=p.pop():p[u]=[r,i]:p.push([r,i]),d?(this.entries=p,this):new Xt(t,p)}},Zt.prototype.get=function(t,e,n,r){void 0===e&&(e=Ot(n));var i=1<<((0===t?e:e>>>t)&y),s=this.bitmap;return s&i?this.nodes[be(s&i-1)].get(t+g,e,n,r):r},Zt.prototype.update=function(t,e,n,r,i,s,o){void 0===n&&(n=Ot(r));var a=(0===e?n:n>>>e)&y,c=1<=Ee)return he(t,d,u,a,f);if(l&&!f&&2===d.length&&ae(d[1^h]))return d[1^h];if(l&&f&&1===d.length&&ae(f))return f;var m=t&&t===this.ownerID,b=l?f?u:u^c:u|c,w=l?f?ye(d,h,f,m):we(d,h,m):ve(d,h,f,m);return m?(this.bitmap=b,this.nodes=w,this):new Zt(t,b,w)},Jt.prototype.get=function(t,e,n,r){void 0===e&&(e=Ot(n));var i=(0===t?e:e>>>t)&y,s=this.nodes[i];return s?s.get(t+g,e,n,r):r},Jt.prototype.update=function(t,e,n,r,i,s,o){void 0===n&&(n=Ot(r));var a=(0===e?n:n>>>e)&y,c=i===v,u=this.nodes,l=u[a];if(c&&!l)return this;var h=oe(l,t,e+g,n,r,i,s,o);if(h===l)return this;var d=this.count;if(l){if(!h&&--d0&&r=0&&t>>e&y;if(r>=this.array.length)return new Oe([],t);var i,s=0===r;if(e>0){var o=this.array[r];if((i=o&&o.removeBefore(t,e-g,n))===o&&s)return this}if(s&&!i)return this;var a=Ue(this,t);if(!s)for(var c=0;c>>e&y;if(i>=this.array.length)return this;if(e>0){var s=this.array[i];if((r=s&&s.removeAfter(t,e-g,n))===s&&i===this.array.length-1)return this}var o=Ue(this,t);return o.array.splice(i+1),r&&(o.array[i]=r),o};var Me,Ne,Ce={};function Re(t,e){var n=t._origin,r=t._capacity,i=Ve(r),s=t._tail;return o(t._root,t._level,0);function o(t,e,n){return 0===e?a(t,n):c(t,e,n)}function a(t,o){var a=o===i?s&&s.array:t&&t.array,c=o>n?0:n-o,u=r-o;return u>b&&(u=b),function(){if(c===u)return Ce;var t=e?--u:c++;return a&&a[t]}}function c(t,i,s){var a,c=t&&t.array,u=s>n?0:n-s>>i,l=1+(r-s>>i);return l>b&&(l=b),function(){for(;;){if(a){var t=a();if(t!==Ce)return t;a=null}if(u===l)return Ce;var n=e?--l:u++;a=o(c&&c[n],i-g,s+(n<=t.size||e<0)return t.withMutations((function(t){e<0?Fe(t,e).set(0,n):Fe(t,0,e+1).set(e,n)}));e+=t._origin;var r=t._tail,i=t._root,s=E(T);return e>=Ve(t._capacity)?r=Be(r,t.__ownerID,0,e,n,s):i=Be(i,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=i,t._tail=r,t.__hash=void 0,t.__altered=!0,t):De(t._origin,t._capacity,t._level,i,r):t}function Be(t,e,n,r,i,s){var o,a=r>>>n&y,c=t&&a0){var u=t&&t.array[a],l=Be(u,e,n-g,r,i,s);return l===u?t:((o=Ue(t,e)).array[a]=l,o)}return c&&t.array[a]===i?t:(A(s),o=Ue(t,e),void 0===i&&a===o.array.length-1?o.array.pop():o.array[a]=i,o)}function Ue(t,e){return e&&t&&e===t.ownerID?t:new Oe(t?t.array.slice():[],e)}function je(t,e){if(e>=Ve(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>r&y],r-=g;return n}}function Fe(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var r=t.__ownerID||new k,i=t._origin,s=t._capacity,o=i+e,a=void 0===n?s:n<0?s+n:i+n;if(o===i&&a===s)return t;if(o>=a)return t.clear();for(var c=t._level,u=t._root,l=0;o+l<0;)u=new Oe(u&&u.array.length?[void 0,u]:[],r),l+=1<<(c+=g);l&&(o+=l,i+=l,a+=l,s+=l);for(var h=Ve(s),d=Ve(a);d>=1<h?new Oe([],r):p;if(p&&d>h&&og;b-=g){var v=h>>>b&y;m=m.array[v]=Ue(m.array[v],r)}m.array[h>>>g&y]=p}if(a=d)o-=d,a-=d,c=g,u=null,f=f&&f.removeBefore(r,0,o);else if(o>i||d>>c&y;if(w!==d>>>c&y)break;w&&(l+=(1<i&&(u=u.removeBefore(r,c,o-l)),u&&ds&&(s=u.size),o(c)||(u=u.map((function(t){return pt(t)}))),r.push(u)}return s>t.size&&(t=t.setSize(s)),me(t,e,r)}function Ve(t){return t>>g<=b&&o.size>=2*s.size?(r=(i=o.filter((function(t,e){return void 0!==t&&a!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(r.__ownerID=i.__ownerID=t.__ownerID)):(r=s.remove(e),i=a===o.size-1?o.pop():o.set(a,void 0))}else if(c){if(n===o.get(a)[1])return t;r=s,i=o.set(a,[e,n])}else r=s.set(e,o.size),i=o.set(o.size,[e,n]);return t.__ownerID?(t.size=r.size,t._map=r,t._list=i,t.__hash=void 0,t):He(r,i)}function qe(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function Qe(t){this._iter=t,this.size=t.size}function Xe(t){this._iter=t,this.size=t.size}function Ze(t){this._iter=t,this.size=t.size}function Je(t){var e=vn(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=wn,e.__iterateUncached=function(e,n){var r=this;return t.__iterate((function(t,n){return!1!==e(n,t,r)}),n)},e.__iteratorUncached=function(e,n){if(e===L){var r=t.__iterator(e,n);return new F((function(){var t=r.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t}))}return t.__iterator(e===P?D:P,n)},e}function _e(t,e,n){var r=vn(t);return r.size=t.size,r.has=function(e){return t.has(e)},r.get=function(r,i){var s=t.get(r,v);return s===v?i:e.call(n,s,r,t)},r.__iterateUncached=function(r,i){var s=this;return t.__iterate((function(t,i,o){return!1!==r(e.call(n,t,i,o),i,s)}),i)},r.__iteratorUncached=function(r,i){var s=t.__iterator(L,i);return new F((function(){var i=s.next();if(i.done)return i;var o=i.value,a=o[0];return z(r,a,e.call(n,o[1],a,t),i)}))},r}function $e(t,e){var n=vn(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=Je(t);return e.reverse=function(){return t.flip()},e}),n.get=function(n,r){return t.get(e?n:-1-n,r)},n.has=function(n){return t.has(e?n:-1-n)},n.includes=function(e){return t.includes(e)},n.cacheResult=wn,n.__iterate=function(e,n){var r=this;return t.__iterate((function(t,n){return e(t,n,r)}),!n)},n.__iterator=function(e,n){return t.__iterator(e,!n)},n}function tn(t,e,n,r){var i=vn(t);return r&&(i.has=function(r){var i=t.get(r,v);return i!==v&&!!e.call(n,i,r,t)},i.get=function(r,i){var s=t.get(r,v);return s!==v&&e.call(n,s,r,t)?s:i}),i.__iterateUncached=function(i,s){var o=this,a=0;return t.__iterate((function(t,s,c){if(e.call(n,t,s,c))return a++,i(t,r?s:a-1,o)}),s),a},i.__iteratorUncached=function(i,s){var o=t.__iterator(L,s),a=0;return new F((function(){for(;;){var s=o.next();if(s.done)return s;var c=s.value,u=c[0],l=c[1];if(e.call(n,l,u,t))return z(i,r?u:a++,l,s)}}))},i}function en(t,e,n){var r=Ht().asMutable();return t.__iterate((function(i,s){r.update(e.call(n,i,s,t),0,(function(t){return t+1}))})),r.asImmutable()}function nn(t,e,n){var r=a(t),i=(l(t)?Ge():Ht()).asMutable();t.__iterate((function(s,o){i.update(e.call(n,s,o,t),(function(t){return(t=t||[]).push(r?[o,s]:s),t}))}));var s=yn(t);return i.map((function(e){return mn(t,s(e))}))}function rn(t,e,n,r){var i=t.size;if(void 0!==e&&(e|=0),void 0!==n&&(n===1/0?n=i:n|=0),M(e,n,i))return t;var s=N(e,i),o=C(n,i);if(s!=s||o!=o)return rn(t.toSeq().cacheResult(),e,n,r);var a,c=o-s;c==c&&(a=c<0?0:c);var u=vn(t);return u.size=0===a?a:t.size&&a||void 0,!r&&st(t)&&a>=0&&(u.get=function(e,n){return(e=x(this,e))>=0&&ea)return V();var t=i.next();return r||e===P?t:z(e,c-1,e===D?void 0:t.value[1],t)}))},u}function sn(t,e,n){var r=vn(t);return r.__iterateUncached=function(r,i){var s=this;if(i)return this.cacheResult().__iterate(r,i);var o=0;return t.__iterate((function(t,i,a){return e.call(n,t,i,a)&&++o&&r(t,i,s)})),o},r.__iteratorUncached=function(r,i){var s=this;if(i)return this.cacheResult().__iterator(r,i);var o=t.__iterator(L,i),a=!0;return new F((function(){if(!a)return V();var t=o.next();if(t.done)return t;var i=t.value,c=i[0],u=i[1];return e.call(n,u,c,s)?r===L?t:z(r,c,u,t):(a=!1,V())}))},r}function on(t,e,n,r){var i=vn(t);return i.__iterateUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterate(i,s);var a=!0,c=0;return t.__iterate((function(t,s,u){if(!a||!(a=e.call(n,t,s,u)))return c++,i(t,r?s:c-1,o)})),c},i.__iteratorUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterator(i,s);var a=t.__iterator(L,s),c=!0,u=0;return new F((function(){var t,s,l;do{if((t=a.next()).done)return r||i===P?t:z(i,u++,i===D?void 0:t.value[1],t);var h=t.value;s=h[0],l=h[1],c&&(c=e.call(n,l,s,o))}while(c);return i===L?t:z(i,s,l,t)}))},i}function an(t,e){var n=a(t),i=[t].concat(e).map((function(t){return o(t)?n&&(t=r(t)):t=n?at(t):ct(Array.isArray(t)?t:[t]),t})).filter((function(t){return 0!==t.size}));if(0===i.length)return t;if(1===i.length){var s=i[0];if(s===t||n&&a(s)||c(t)&&c(s))return s}var u=new et(i);return n?u=u.toKeyedSeq():c(t)||(u=u.toSetSeq()),(u=u.flatten(!0)).size=i.reduce((function(t,e){if(void 0!==t){var n=e.size;if(void 0!==n)return t+n}}),0),u}function cn(t,e,n){var r=vn(t);return r.__iterateUncached=function(r,i){var s=0,a=!1;function c(t,u){var l=this;t.__iterate((function(t,i){return(!e||u0}function fn(t,e,r){var i=vn(t);return i.size=new et(r).map((function(t){return t.size})).min(),i.__iterate=function(t,e){for(var n,r=this.__iterator(P,e),i=0;!(n=r.next()).done&&!1!==t(n.value,i++,this););return i},i.__iteratorUncached=function(t,i){var s=r.map((function(t){return t=n(t),H(i?t.reverse():t)})),o=0,a=!1;return new F((function(){var n;return a||(n=s.map((function(t){return t.next()})),a=n.some((function(t){return t.done}))),a?V():z(t,o++,e.apply(null,n.map((function(t){return t.value}))))}))},i}function mn(t,e){return st(t)?e:t.constructor(e)}function gn(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function bn(t){return Yt(t.size),S(t)}function yn(t){return a(t)?r:c(t)?i:s}function vn(t){return Object.create((a(t)?Q:c(t)?X:Z).prototype)}function wn(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):q.prototype.cacheResult.call(this)}function Tn(t,e){return t>e?1:t=0;n--)e={value:arguments[n],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):Qn(t,e)},Yn.prototype.pushAll=function(t){if(0===(t=i(t)).size)return this;Yt(t.size);var e=this.size,n=this._head;return t.reverse().forEach((function(t){e++,n={value:t,next:n}})),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Qn(e,n)},Yn.prototype.pop=function(){return this.slice(1)},Yn.prototype.unshift=function(){return this.push.apply(this,arguments)},Yn.prototype.unshiftAll=function(t){return this.pushAll(t)},Yn.prototype.shift=function(){return this.pop.apply(this,arguments)},Yn.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Xn()},Yn.prototype.slice=function(t,e){if(M(t,e,this.size))return this;var n=N(t,this.size);if(C(e,this.size)!==this.size)return kt.prototype.slice.call(this,t,e);for(var r=this.size-n,i=this._head;n--;)i=i.next;return this.__ownerID?(this.size=r,this._head=i,this.__hash=void 0,this.__altered=!0,this):Qn(r,i)},Yn.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Qn(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Yn.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var n=0,r=this._head;r&&!1!==t(r.value,n++,this);)r=r.next;return n},Yn.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var n=0,r=this._head;return new F((function(){if(r){var e=r.value;return r=r.next,z(t,n++,e)}return V()}))},Yn.isStack=Hn;var Wn,Kn="@@__IMMUTABLE_STACK__@@",qn=Yn.prototype;function Qn(t,e,n,r){var i=Object.create(qn);return i.size=t,i._head=e,i.__ownerID=n,i.__hash=r,i.__altered=!1,i}function Xn(){return Wn||(Wn=Qn(0))}function Zn(t,e){var n=function(n){t.prototype[n]=e[n]};return Object.keys(e).forEach(n),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(n),t}qn[Kn]=!0,qn.withMutations=Qt.withMutations,qn.asMutable=Qt.asMutable,qn.asImmutable=Qt.asImmutable,qn.wasAltered=Qt.wasAltered,n.Iterator=F,Zn(n,{toArray:function(){Yt(this.size);var t=new Array(this.size||0);return this.valueSeq().__iterate((function(e,n){t[n]=e})),t},toIndexedSeq:function(){return new Qe(this)},toJS:function(){return this.toSeq().map((function(t){return t&&"function"==typeof t.toJS?t.toJS():t})).__toJS()},toJSON:function(){return this.toSeq().map((function(t){return t&&"function"==typeof t.toJSON?t.toJSON():t})).__toJS()},toKeyedSeq:function(){return new qe(this,!0)},toMap:function(){return Ht(this.toKeyedSeq())},toObject:function(){Yt(this.size);var t={};return this.__iterate((function(e,n){t[n]=e})),t},toOrderedMap:function(){return Ge(this.toKeyedSeq())},toOrderedSet:function(){return Un(a(this)?this.valueSeq():this)},toSet:function(){return Mn(a(this)?this.valueSeq():this)},toSetSeq:function(){return new Xe(this)},toSeq:function(){return c(this)?this.toIndexedSeq():a(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Yn(a(this)?this.valueSeq():this)},toList:function(){return ke(a(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(t,e){return 0===this.size?t+e:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+e},concat:function(){return mn(this,an(this,t.call(arguments,0)))},includes:function(t){return this.some((function(e){return bt(e,t)}))},entries:function(){return this.__iterator(L)},every:function(t,e){Yt(this.size);var n=!0;return this.__iterate((function(r,i,s){if(!t.call(e,r,i,s))return n=!1,!1})),n},filter:function(t,e){return mn(this,tn(this,t,e,!0))},find:function(t,e,n){var r=this.findEntry(t,e);return r?r[1]:n},forEach:function(t,e){return Yt(this.size),this.__iterate(e?t.bind(e):t)},join:function(t){Yt(this.size),t=void 0!==t?""+t:",";var e="",n=!0;return this.__iterate((function(r){n?n=!1:e+=t,e+=null!=r?r.toString():""})),e},keys:function(){return this.__iterator(D)},map:function(t,e){return mn(this,_e(this,t,e))},reduce:function(t,e,n){var r,i;return Yt(this.size),arguments.length<2?i=!0:r=e,this.__iterate((function(e,s,o){i?(i=!1,r=e):r=t.call(n,r,e,s,o)})),r},reduceRight:function(t,e,n){var r=this.toKeyedSeq().reverse();return r.reduce.apply(r,arguments)},reverse:function(){return mn(this,$e(this,!0))},slice:function(t,e){return mn(this,rn(this,t,e,!0))},some:function(t,e){return!this.every(er(t),e)},sort:function(t){return mn(this,hn(this,t))},values:function(){return this.__iterator(P)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some((function(){return!0}))},count:function(t,e){return S(t?this.toSeq().filter(t,e):this)},countBy:function(t,e){return en(this,t,e)},equals:function(t){return yt(this,t)},entrySeq:function(){var t=this;if(t._cache)return new et(t._cache);var e=t.toSeq().map(tr).toIndexedSeq();return e.fromEntrySeq=function(){return t.toSeq()},e},filterNot:function(t,e){return this.filter(er(t),e)},findEntry:function(t,e,n){var r=n;return this.__iterate((function(n,i,s){if(t.call(e,n,i,s))return r=[i,n],!1})),r},findKey:function(t,e){var n=this.findEntry(t,e);return n&&n[0]},findLast:function(t,e,n){return this.toKeyedSeq().reverse().find(t,e,n)},findLastEntry:function(t,e,n){return this.toKeyedSeq().reverse().findEntry(t,e,n)},findLastKey:function(t,e){return this.toKeyedSeq().reverse().findKey(t,e)},first:function(){return this.find(O)},flatMap:function(t,e){return mn(this,un(this,t,e))},flatten:function(t){return mn(this,cn(this,t,!0))},fromEntrySeq:function(){return new Ze(this)},get:function(t,e){return this.find((function(e,n){return bt(n,t)}),void 0,e)},getIn:function(t,e){for(var n,r=this,i=En(t);!(n=i.next()).done;){var s=n.value;if((r=r&&r.get?r.get(s,v):v)===v)return e}return r},groupBy:function(t,e){return nn(this,t,e)},has:function(t){return this.get(t,v)!==v},hasIn:function(t){return this.getIn(t,v)!==v},isSubset:function(t){return t="function"==typeof t.includes?t:n(t),this.every((function(e){return t.includes(e)}))},isSuperset:function(t){return(t="function"==typeof t.isSubset?t:n(t)).isSubset(this)},keyOf:function(t){return this.findKey((function(e){return bt(e,t)}))},keySeq:function(){return this.toSeq().map($n).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return dn(this,t)},maxBy:function(t,e){return dn(this,e,t)},min:function(t){return dn(this,t?nr(t):sr)},minBy:function(t,e){return dn(this,e?nr(e):sr,t)},rest:function(){return this.slice(1)},skip:function(t){return this.slice(Math.max(0,t))},skipLast:function(t){return mn(this,this.toSeq().reverse().skip(t).reverse())},skipWhile:function(t,e){return mn(this,on(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(er(t),e)},sortBy:function(t,e){return mn(this,hn(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return mn(this,this.toSeq().reverse().take(t).reverse())},takeWhile:function(t,e){return mn(this,sn(this,t,e))},takeUntil:function(t,e){return this.takeWhile(er(t),e)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=or(this))}});var Jn=n.prototype;Jn[h]=!0,Jn[j]=Jn.values,Jn.__toJS=Jn.toArray,Jn.__toStringMapper=rr,Jn.inspect=Jn.toSource=function(){return this.toString()},Jn.chain=Jn.flatMap,Jn.contains=Jn.includes,Zn(r,{flip:function(){return mn(this,Je(this))},mapEntries:function(t,e){var n=this,r=0;return mn(this,this.toSeq().map((function(i,s){return t.call(e,[s,i],r++,n)})).fromEntrySeq())},mapKeys:function(t,e){var n=this;return mn(this,this.toSeq().flip().map((function(r,i){return t.call(e,r,i,n)})).flip())}});var _n=r.prototype;function $n(t,e){return e}function tr(t,e){return[e,t]}function er(t){return function(){return!t.apply(this,arguments)}}function nr(t){return function(){return-t.apply(this,arguments)}}function rr(t){return"string"==typeof t?JSON.stringify(t):String(t)}function ir(){return I(arguments)}function sr(t,e){return te?-1:0}function or(t){if(t.size===1/0)return 0;var e=l(t),n=a(t),r=e?1:0;return ar(t.__iterate(n?e?function(t,e){r=31*r+cr(Ot(t),Ot(e))|0}:function(t,e){r=r+cr(Ot(t),Ot(e))|0}:e?function(t){r=31*r+Ot(t)|0}:function(t){r=r+Ot(t)|0}),r)}function ar(t,e){return e=St(e,3432918353),e=St(e<<15|e>>>-15,461845907),e=St(e<<13|e>>>-13,5),e=St((e=e+3864292196^t)^e>>>16,2246822507),e=xt((e=St(e^e>>>13,3266489909))^e>>>16)}function cr(t,e){return t^e+2654435769+(t<<6)+(t>>2)}return _n[d]=!0,_n[j]=Jn.entries,_n.__toJS=Jn.toObject,_n.__toStringMapper=function(t,e){return JSON.stringify(e)+": "+rr(t)},Zn(i,{toKeyedSeq:function(){return new qe(this,!1)},filter:function(t,e){return mn(this,tn(this,t,e,!1))},findIndex:function(t,e){var n=this.findEntry(t,e);return n?n[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return mn(this,$e(this,!1))},slice:function(t,e){return mn(this,rn(this,t,e,!1))},splice:function(t,e){var n=arguments.length;if(e=Math.max(0|e,0),0===n||2===n&&!e)return this;t=N(t,t<0?this.count():this.size);var r=this.slice(0,t);return mn(this,1===n?r:r.concat(I(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var n=this.findLastEntry(t,e);return n?n[0]:-1},first:function(){return this.get(0)},flatten:function(t){return mn(this,cn(this,t,!1))},get:function(t,e){return(t=x(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,n){return n===t}),void 0,e)},has:function(t){return(t=x(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0&&void 0!==arguments[0]?arguments[0]:this.warpMode;return this.reset(),this.warpMode=Boolean(t),this}static create(t){const e=i.pop();return void 0!==e?(e.warpMode=Boolean(t),e):new s(t)}static release(t){void 0!==t&&i.push(t.reset())}}class o{constructor(t){this.topBlock=t,this.stack=[],this.stackFrames=[],this.status=0,this.isKilled=!1,this.target=null,this.blockContainer=null,this.requestScriptGlowInFrame=!1,this.blockGlowInFrame=null,this.warpTimer=null,this.justReported=null,this.triedToCompile=!1,this.isCompiled=!1,this.timer=null,this.generator=null,this.procedures=null,this.executableHat=!1,this.compatibilityStackFrame=null}static get STATUS_RUNNING(){return 0}static get STATUS_PROMISE_WAIT(){return 1}static get STATUS_YIELD(){return 2}static get STATUS_YIELD_TICK(){return 3}static get STATUS_DONE(){return 4}static getIdFromTargetAndBlock(t,e){return"".concat(t.id,"&").concat(e)}getId(){return o.getIdFromTargetAndBlock(this.target,this.topBlock)}pushStack(t){if(this.stack.push(t),this.stack.length>this.stackFrames.length){const t=this.stackFrames[this.stackFrames.length-1];this.stackFrames.push(s.create(void 0!==t&&t.warpMode))}}reuseStackForNextBlock(t){this.stack[this.stack.length-1]=t,this.stackFrames[this.stackFrames.length-1].reuse()}popStack(){return s.release(this.stackFrames.pop()),this.stack.pop()}stopThisScript(){let t=this.peekStack();for(;null!==t;){const e=this.target.blocks.getBlock(t);if(this.peekStackFrame().waitingReporter)break;if(void 0!==e&&"procedures_call"===e.opcode){this.goToNextBlock();break}this.popStack(),t=this.peekStack()}0===this.stack.length&&(this.requestScriptGlowInFrame=!1,this.status=o.STATUS_DONE)}peekStack(){return this.stack.length>0?this.stack[this.stack.length-1]:null}peekStackFrame(){return this.stackFrames.length>0?this.stackFrames[this.stackFrames.length-1]:null}peekParentStackFrame(){return this.stackFrames.length>1?this.stackFrames[this.stackFrames.length-2]:null}pushReportedValue(t){this.justReported=void 0===t?null:t}initParams(){const t=this.peekStackFrame();null===t.params&&(t.params={})}pushParam(t,e){this.peekStackFrame().params[t]=e}getParam(t){for(let e=this.stackFrames.length-1;e>=0;e--){const n=this.stackFrames[e];if(null!==n.params)return Object.prototype.hasOwnProperty.call(n.params,t)?n.params[t]:null}return null}getAllparams(){return this.peekStackFrame().params}atStackTop(){return this.peekStack()===this.topBlock}goToNextBlock(){const t=this.target.blocks.getNextBlock(this.peekStack());this.reuseStackForNextBlock(t)}isRecursiveCall(t){let e=5;for(let n=this.stackFrames.length-1-1;n>=0;n--){const r=this.target.blocks.getBlock(this.stackFrames[n].op.id)||this.target.runtime.flyoutBlocks.getBlock(this.stackFrames[n].op.id);if("procedures_call"===r.opcode&&r.mutation.proccode===t)return!0;if(--e<0)return!1}return!1}tryCompile(){if(!this.blockContainer)return;const t=n(186);this.triedToCompile=!0;const e=!this.stackClick,i=this.topBlock,s=this.blockContainer.getBlock(i)?this.blockContainer:this.target.runtime.flyoutBlocks,o=e&&s.getCachedCompileResult(i);if(o&&!o.success)return;let a;if(o)a=o.value;else try{a=t(this),e&&s.cacheCompileResult(i,a)}catch(t){return r.error("cannot compile script",this.target.getName(),t),e&&s.cacheCompileError(i,t),void this.target.runtime.emitCompileError(this.target,t)}this.procedures={};for(const t of Object.keys(a.procedures))this.procedures[t]=a.procedures[t](this);this.generator=a.startingFunction(this)(),this.executableHat=a.executableHat,this.blockContainer.forceNoGlow||(this.blockGlowInFrame=this.topBlock,this.requestScriptGlowInFrame=!0),this.isCompiled=!0}}o._StackFrame=s,t.exports=o},function(t,e,n){const r=n(231),i=n(244),s=n(77),o=n(73),a=n(246),c=n(76),u=n(49),l=n(74),h=n(247),d=n(48);t.exports={BitmapAdapter:i,convertFonts:l,inlineSvgFonts:s,loadSvgString:o,sanitizeSvg:a,serializeSvgToString:c,SvgElement:u,SVGRenderer:r,fixForVanilla:h,DOMPurify:d}},function(t,e,n){const r=n(39),i=n(15),s=n(47),o=n(9),a=n(46),c=n(40),u=n(12),l=n(0),h=n(7),d=n(4),p=n(6),f=n(72),m=n(255),{loadCostume:g}=n(31),{loadSound:b}=n(30),{deserializeCostume:y,deserializeSound:v}=n(81),w=Object.prototype.hasOwnProperty,T=["argument","colour","control","data","event","looks","math","motion","operator","procedures","sensing","sound"],E=12,A=13,k={math_number:[4,"NUM"],math_positive_number:[5,"NUM"],math_whole_number:[6,"NUM"],math_integer:[7,"NUM"],math_angle:[8,"NUM"],colour_picker:[9,"COLOUR"],text:[10,"TEXT"],event_broadcast_menu:[11,"BROADCAST_OPTION"],data_variable:[E,"VARIABLE"],data_listcontents:[A,"LIST"]},I=8e3,S=function(t){const e=function(t){if(w.call(k,t.opcode)){const e=k[t.opcode],n=e[0],r=e[1],i=t.fields[r],s=[n,i.value];return"event_broadcast_menu"===t.opcode?s.push(i.id):"data_variable"!==t.opcode&&"data_listcontents"!==t.opcode||(s.push(i.id),t.topLevel&&(s.push(t.x?Math.round(t.x):0),s.push(t.y?Math.round(t.y):0))),s}return null}(t);if(e)return e;const n=Object.create(null);return n.opcode=t.opcode,n.next=t.next,n.parent=t.parent,n.inputs=function(t){const e=Object.create(null);for(const n in t)w.call(t,n)&&(t[n].block===t[n].shadow?e[n]=[1,t[n].block]:null===t[n].shadow?e[n]=[2,t[n].block]:e[n]=[3,t[n].block,t[n].shadow]);return e}(t.inputs),n.fields=function(t){const e=Object.create(null);for(const n in t)w.call(t,n)&&(e[n]=[t[n].value],Object.prototype.hasOwnProperty.call(t[n],"id")&&e[n].push(t[n].id));return e}(t.fields),n.shadow=t.shadow,t.topLevel?(n.topLevel=!0,n.x=t.x?Math.round(t.x):0,n.y=t.y?Math.round(t.y):0):n.topLevel=!1,t.mutation&&(n.mutation=t.mutation),t.comment&&(n.comment=t.comment),n},x=function(t,e){const n=t.inputs;for(const t in n){const r=n[t];for(let t=1;t{if(!e.extensionManager)return null;const n=e.extensionManager.getExtensionURLs(),r={};for(const e of t){const t=n[e];"string"==typeof t&&(r[e]=t)}return 0===Object.keys(r).length?null:r},N=function(t){const e=Object.create(null),n=new Set;for(const r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;e[r]=S(t[r]);const i=O(t[r].opcode);i&&n.add(i)}for(const t in e){const n=e[t];e[t]=x(n,e)}for(const t in e){const n=e[t];Array.isArray(n)&&[E,A].indexOf(n[0])<0&&(l.warn("Found an unexpected top level primitive with block ID: ".concat(t,"; deleting it from serialized blocks.")),delete e[t])}return[e,Array.from(n)]},C=function(t){const e=Object.create(null);e.name=t.name;const n=t.broken||t;return e.bitmapResolution=n.bitmapResolution,e.dataFormat=n.dataFormat.toLowerCase(),e.assetId=n.assetId,e.md5ext=n.md5,e.rotationCenterX=n.rotationCenterX,e.rotationCenterY=n.rotationCenterY,e},R=function(t){const e=Object.create(null);e.name=t.name;const n=t.broken||t;return e.assetId=n.assetId,e.dataFormat=n.dataFormat.toLowerCase(),e.format=n.format,e.rate=n.rate,e.sampleCount=n.sampleCount,e.md5ext=n.md5,e},D=t=>"number"==typeof t||"string"==typeof t||"boolean"==typeof t,P=t=>{if(Array.isArray(t)){let e=null;for(let n=0;nI?(i.text=r.text.substring(0,I),i.extraText=r.text.substring(I)):i.text=r.text,e[n]=i}return e}(t.comments),(t.currentCostume<0||t.currentCostume>=t.costumes.length)&&(l.warn("currentCostume property for target ".concat(t.name," is out of range")),t.currentCostume=d.clamp(t.currentCostume,0,t.costumes.length-1)),n.currentCostume=t.currentCostume,n.costumes=t.costumes.map(C),n.sounds=t.sounds.map(R),Object.prototype.hasOwnProperty.call(t,"volume")&&(n.volume=t.volume),Object.prototype.hasOwnProperty.call(t,"layerOrder")&&(n.layerOrder=t.layerOrder),n.isStage?(Object.prototype.hasOwnProperty.call(t,"tempo")&&(n.tempo=t.tempo),Object.prototype.hasOwnProperty.call(t,"videoTransparency")&&(n.videoTransparency=t.videoTransparency),Object.prototype.hasOwnProperty.call(t,"videoState")&&(n.videoState=t.videoState),Object.prototype.hasOwnProperty.call(t,"textToSpeechLanguage")&&(n.textToSpeechLanguage=t.textToSpeechLanguage)):(n.visible=t.visible,n.x=t.x,n.y=t.y,n.size=t.size,n.direction=t.direction,n.draggable=t.draggable,n.rotationStyle=t.rotationStyle),r.forEach((t=>{e.add(t)})),n},B=(t,e)=>{const n={};let r=!0;for(const[i,s]of Object.entries(t))e.has(i)&&null!=s&&(r=!1,n[i]=t[i]);return r?null:n},U=function(t,e,n,r){if(!Array.isArray(t))return t;const i=Object.create(null),s=h();switch(i.id=s,i.next=null,i.parent=e,i.shadow=n,i.inputs=Object.create(null),t[0]){case 4:i.opcode="math_number",i.fields={NUM:{name:"NUM",value:t[1]}},i.topLevel=!1;break;case 5:i.opcode="math_positive_number",i.fields={NUM:{name:"NUM",value:t[1]}},i.topLevel=!1;break;case 6:i.opcode="math_whole_number",i.fields={NUM:{name:"NUM",value:t[1]}},i.topLevel=!1;break;case 7:i.opcode="math_integer",i.fields={NUM:{name:"NUM",value:t[1]}},i.topLevel=!1;break;case 8:i.opcode="math_angle",i.fields={NUM:{name:"NUM",value:t[1]}},i.topLevel=!1;break;case 9:i.opcode="colour_picker",i.fields={COLOUR:{name:"COLOUR",value:t[1]}},i.topLevel=!1;break;case 10:i.opcode="text",i.fields={TEXT:{name:"TEXT",value:t[1]}},i.topLevel=!1;break;case 11:i.opcode="event_broadcast_menu",i.fields={BROADCAST_OPTION:{name:"BROADCAST_OPTION",value:t[1],id:t[2],variableType:o.BROADCAST_MESSAGE_TYPE}},i.topLevel=!1;break;case E:i.opcode="data_variable",i.fields={VARIABLE:{name:"VARIABLE",value:t[1],id:t[2],variableType:o.SCALAR_TYPE}},t.length>3&&(i.topLevel=!0,i.x=t[3],i.y=t[4]);break;case A:i.opcode="data_listcontents",i.fields={LIST:{name:"LIST",value:t[1],id:t[2],variableType:o.LIST_TYPE}},t.length>3&&(i.topLevel=!0,i.x=t[3],i.y=t[4]);break;default:return l.error("Found unknown primitive type during deserialization: ".concat(JSON.stringify(t))),null}return r[s]=i,s},j=function(t,e,n){const r={};for(const i in t){if(!w.call(t,i))continue;const s=t[i];if(!Array.isArray(s))continue;let o=null,a=null;const c=s[0];1===c?o=a=U(s[1],e,!0,n):2===c?o=U(s[1],e,!1,n):(o=U(s[1],e,!1,n),a=U(s[2],e,!0,n)),r[i]={name:i,block:o,shadow:a}}return r},F=function(t){const e={};for(const n in t){if(!w.call(t,n))continue;const r=t[n];Array.isArray(r)&&(e[n]={name:n,value:r[0]},r.length>1&&(e[n].id=r[1]),"BROADCAST_OPTION"===n?e[n].variableType=o.BROADCAST_MESSAGE_TYPE:"VARIABLE"===n?e[n].variableType=o.SCALAR_TYPE:"LIST"===n&&(e[n].variableType=o.LIST_TYPE))}return e},z=function(t){for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const n=t[e];Array.isArray(n)?(delete t[e],U(n,null,!1,t)):(n.id=e,n.inputs=j(n.inputs,e,t),n.fields=F(n.fields))}return t};t.exports={serialize:function(t,e){let{allowOptimization:n=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=Object.create(null),i=new Set,s=e?[t.getTargetById(e)]:t.targets.filter((t=>t.isOriginal)),o=function(t){const e=t.map((t=>t.getLayerOrder()));return d.reducedSortOrdering(e)}(s),a=s.map((t=>t.toJSON()));t.renderer&&!e&&a.forEach(((t,e)=>{t.layerOrder=o[e]}));const c=a.map((t=>L(t,i))).map(((t,e)=>{const n=s[e],r=B(n.extensionStorage,i);return r&&(t.extensionStorage=r),t})),u=t.fontManager.serializeJSON();if(e){const e=c[0];i.size&&(e.extensions=Array.from(i));const n=M(i,t);return n&&(e.extensionURLs=n),u&&(e.customFonts=u),c[0]}const l=B(t.extensionStorage,i);l&&(r.extensionStorage=l),r.targets=c,r.monitors=function(t,e,n){const r=(e.stageWidth-480)/2,i=(e.stageHeight-360)/2;return t.valueSeq().filter((t=>{const e=O(t.opcode);return!e||!!t.visible&&(n.add(e),!0)})).map((t=>{const e={id:t.id,mode:t.mode,opcode:t.opcode,params:t.params,spriteName:t.spriteName,value:Array.isArray(t.value)?[]:0,width:t.width,height:t.height,x:t.x-r,y:t.y-i,visible:t.visible};return"list"!==t.mode&&(e.sliderMin=t.sliderMin,e.sliderMax=t.sliderMax,e.isDiscrete=t.isDiscrete),e})).toArray()}(t.getMonitorState(),t,i),r.extensions=Array.from(i);const h=M(i,t);h&&(r.extensionURLs=h),u&&(r.customFonts=u);const p=Object.create(null);return p.semver="3.0.0",p.vm="0.2.0",t.origin&&(p.origin=t.origin),p.agent="",p.platform=Object.assign({},t.platform),r.meta=p,n&&m(r),r},deserialize:async function(t,e,n,h){await((t,e)=>{if(!t.meta||!t.meta.platform)return;if(t.meta.platform.name===e.platform.name)return;let n=e.listenerCount(r.PLATFORM_MISMATCH);return 0!==n?new Promise((i=>{e.emit(r.PLATFORM_MISMATCH,t.meta.platform,(()=>{n--,0===n&&i()}))})):void 0})(t,e);const m={extensionIDs:new Set,extensionURLs:new Map};if(t.meta&&t.meta.origin?e.origin=t.meta.origin:e.origin=null,t.extensionURLs)for(const[e,n]of Object.entries(t.extensionURLs))m.extensionURLs.set(e,n);let w;w=t.customFonts?e.fontManager.deserialize(t.customFonts,n,h):Promise.resolve();const T=((h?[t]:t.targets)||[]).map(((t,e)=>Object.assign(t,{targetPaneOrder:e}))).sort(((t,e)=>t.layerOrder-e.layerOrder)),E=t.monitors||[];return w.then((()=>T.map((t=>function(t,e,n){if(!Object.prototype.hasOwnProperty.call(t,"name"))return Promise.resolve(null);const r={costumePromises:null,soundPromises:null,soundBank:e.audioEngine&&e.audioEngine.createBank()};return r.costumePromises=(t.costumes||[]).map((t=>{const r={asset:t.asset,assetId:t.assetId,skinId:null,name:t.name,bitmapResolution:t.bitmapResolution,rotationCenterX:t.rotationCenterX,rotationCenterY:t.rotationCenterY},i=t.dataFormat||t.assetType&&t.assetType.runtimeFormat||"png",s=Object.prototype.hasOwnProperty.call(t,"md5ext")?t.md5ext:"".concat(t.assetId,".").concat(i);return r.md5=s,r.dataFormat=i,e.wrapAssetRequest((()=>y(r,e,n).then((()=>g(s,r,e)))))})),r.soundPromises=(t.sounds||[]).map((t=>{const i={assetId:t.assetId,format:t.format,rate:t.rate,sampleCount:t.sampleCount,name:t.name,md5:t.md5ext,dataFormat:t.dataFormat,data:null};return e.wrapAssetRequest((()=>v(i,e,n).then((()=>b(i,e,r.soundBank)))))})),r}(t,e,n))))).then((t=>Promise.resolve(t))).then((t=>Promise.all(T.map(((n,r)=>function(t,e,n,r,c){if(!Object.prototype.hasOwnProperty.call(t,"name"))return Promise.resolve(null);const l=new i(e),h=new s(l,e);if(Object.prototype.hasOwnProperty.call(t,"name")&&(h.name=t.name),Object.prototype.hasOwnProperty.call(t,"blocks")){z(t.blocks);for(const e in t.blocks){if(!Object.prototype.hasOwnProperty.call(t.blocks,e))continue;const r=t.blocks[e];l.createBlock(r);const i=O(r.opcode);i&&n.extensionIDs.add(i)}}const{costumePromises:p}=c,{soundBank:f,soundPromises:m}=c,g=h.createClone(t.isStage?u.BACKGROUND_LAYER:u.SPRITE_LAYER);if(Object.prototype.hasOwnProperty.call(t,"tempo")&&(g.tempo=t.tempo),Object.prototype.hasOwnProperty.call(t,"volume")&&(g.volume=t.volume),Object.prototype.hasOwnProperty.call(t,"videoTransparency")&&(g.videoTransparency=t.videoTransparency),Object.prototype.hasOwnProperty.call(t,"videoState")&&(g.videoState=t.videoState),Object.prototype.hasOwnProperty.call(t,"textToSpeechLanguage")&&(g.textToSpeechLanguage=t.textToSpeechLanguage),Object.prototype.hasOwnProperty.call(t,"variables"))for(const n in t.variables){const r=t.variables[n],i=3===r.length&&r[2]&&t.isStage&&e.canAddCloudVariable(),s=new o(n,r[0],o.SCALAR_TYPE,i);i&&e.addCloudVariable(),s.value=r[1],g.variables[s.id]=s}if(Object.prototype.hasOwnProperty.call(t,"lists"))for(const e in t.lists){const n=t.lists[e],r=new o(e,n[0],o.LIST_TYPE,!1);r.value=n[1],g.variables[r.id]=r}if(Object.prototype.hasOwnProperty.call(t,"broadcasts"))for(const e in t.broadcasts){const n=t.broadcasts[e],r=new o(e,n,o.BROADCAST_MESSAGE_TYPE,!1);g.variables[r.id]=r}if(Object.prototype.hasOwnProperty.call(t,"comments"))for(const e in t.comments){const n=t.comments[e],r=new a(e,n.text+("string"==typeof n.extraText?n.extraText:""),n.x,n.y,n.width,n.height,n.minimized);n.blockId&&(r.blockId=n.blockId),g.comments[r.id]=r}return Object.prototype.hasOwnProperty.call(t,"x")&&(g.x=t.x),Object.prototype.hasOwnProperty.call(t,"y")&&(g.y=t.y),Object.prototype.hasOwnProperty.call(t,"direction")&&(g.direction=d.wrapClamp(t.direction,-179,180)),Object.prototype.hasOwnProperty.call(t,"size")&&(g.size=t.size),Object.prototype.hasOwnProperty.call(t,"visible")&&(g.visible=t.visible),Object.prototype.hasOwnProperty.call(t,"currentCostume")&&(g.currentCostume=d.clamp(t.currentCostume,0,t.costumes.length-1)),Object.prototype.hasOwnProperty.call(t,"rotationStyle")&&(g.rotationStyle=t.rotationStyle),Object.prototype.hasOwnProperty.call(t,"isStage")&&(g.isStage=t.isStage),Object.prototype.hasOwnProperty.call(t,"targetPaneOrder")&&(g.targetPaneOrder=t.targetPaneOrder),Object.prototype.hasOwnProperty.call(t,"draggable")&&(g.draggable=t.draggable),Object.prototype.hasOwnProperty.call(t,"extensionStorage")&&(g.extensionStorage=t.extensionStorage),Promise.all(p).then((t=>{h.costumes=t})),Promise.all(m).then((t=>{h.sounds=t,h.soundBank=f||null})),Promise.all(p.concat(m)).then((()=>g))}(n,e,m,0,t[r])))))).then((t=>t.map(((t,e)=>(t.layerOrder=e,t))).sort(((t,e)=>t.targetPaneOrder-e.targetPaneOrder)).map((t=>(delete t.targetPaneOrder,t))))).then((t=>function(t){const e=f.getAllVarRefsForTargets(t,!0);t.forEach((t=>{Object.keys(t.variables).forEach((e=>{const n=p.replaceUnsafeChars(e);n!==e&&(t.variables[e].id=n,t.variables[n]=t.variables[e],delete t.variables[e])}))}));for(const t in e){const n=p.replaceUnsafeChars(t);t!==n&&f.updateVariableIdentifiers(e[t],n)}return t}(t))).then((n=>(E.map((t=>function(t,e,n,r){const i=(e.stageWidth-480)/2,s=(e.stageHeight-360)/2;if(t.x+=i,t.y+=s,t.x=d.clamp(t.x,0,e.stageWidth),t.y=d.clamp(t.y,0,e.stageHeight),t.spriteName){const e=n.filter((e=>e.sprite.name===t.spriteName));e&&e.length>0?t.targetId=e[0].id:l.warn("Tried to deserialize sprite specific monitor ".concat(t.opcode," but could not find sprite ").concat(t.spriteName,"."))}const a=e.monitorBlockInfo[t.opcode];if("data_listcontents"===t.opcode){const e=t.targetId?n.find((e=>e.id===t.targetId)):n.find((t=>t.isStage));e&&Object.prototype.hasOwnProperty.call(e.variables,t.id)&&(t.params.LIST=e.variables[t.id].name)}const u={};for(const e in t.params){const n={name:e,value:t.params[e]};u[e]=n}"data_variable"!==t.opcode&&"data_listcontents"!==t.opcode&&a&&a.isSpriteSpecific?t.id=a.getId(t.targetId,u):t.id=p.replaceUnsafeChars(t.id);const h=e.monitorBlocks._blocks[t.id];if(h)h.isMonitored=t.visible,h.targetId=t.targetId;else{const n={id:t.id,opcode:t.opcode,inputs:{},fields:u,topLevel:!0,next:null,parent:null,shadow:!1,x:0,y:0,isMonitored:t.visible,targetId:t.targetId};if("data_variable"===t.opcode){const e=n.fields.VARIABLE;e.id=t.id,e.variableType=o.SCALAR_TYPE}else if("data_listcontents"===t.opcode){const e=n.fields.LIST;e.id=t.id,e.variableType=o.LIST_TYPE}e.monitorBlocks.createBlock(n);const i=O(n.opcode);i&&r.extensionIDs.add(i)}e.requestAddMonitor(c(t))}(t,e,n,m))),Object.prototype.hasOwnProperty.call(t,"extensionStorage")&&(e.extensionStorage=t.extensionStorage),n))).then((t=>({targets:t,extensions:m})))},deserializeBlocks:z,serializeBlocks:N,deserializeStandaloneBlocks:t=>{if((t=JSON.parse(JSON.stringify(t))).extensionURLs){const e=new Map;for(const[n,r]of Object.entries(t.extensionURLs))e.set(n,r);return{blocks:t.blocks,extensionURLs:e}}return{blocks:t,extensionURLs:new Map}},serializeStandaloneBlocks:(t,e)=>{const n=new Set;for(const e of t){const t=O(e.opcode);t&&n.add(t)}const r=M(n,e);return r?{blocks:t,extensionURLs:r}:t},getExtensionIdForOpcode:O}},function(t,e,n){const r=n(10),i=n(32),s=n(264);t.exports=class{constructor(t,e){this._renderer=e,this._id=t,this._rotationCenter=r.v3.create(0,0),this._texture=null,this._uniforms={u_skinSize:[0,0],u_skin:null},this._silhouette=new s,this.private=!1}dispose(){this._id=i.ID_NONE}get id(){return this._id}get rotationCenter(){return this._rotationCenter}get size(){return[0,0]}useNearest(t,e){return!0}calculateRotationCenter(){return[this.size[0]/2,this.size[1]/2]}getTexture(t){return this._emptyImageTexture}getFenceBounds(t,e){return t.getAABB(e)}getUniforms(t){return this._uniforms.u_skin=this.getTexture(t),this._uniforms.u_skinSize=this.size,this._uniforms}emitWasAltered(){this._renderer.skinWasAltered(this)}updateSilhouette(){this._silhouette.unlazy()}_setTexture(t){const e=this._renderer.gl;e.bindTexture(e.TEXTURE_2D,this._texture),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),this._silhouette.update(t)}setEmptyImageData(){if(this._texture=null,!this._emptyImageData){this._emptyImageData=new ImageData(1,1);const t=this._renderer.gl,e={auto:!0,wrap:t.CLAMP_TO_EDGE,src:this._emptyImageData};this._emptyImageTexture=r.createTexture(t,e)}this._rotationCenter[0]=0,this._rotationCenter[1]=0,this._silhouette.update(this._emptyImageData),this.emitWasAltered()}isTouchingNearest(t){return this._silhouette.isTouchingNearest(t)}isTouchingLinear(t){return this._silhouette.isTouchingLinear(t)}}},function(t,e,n){const r=n(10);class i{constructor(t){this._gl=t,this._shaderCache={};for(const t in i.DRAW_MODE)Object.prototype.hasOwnProperty.call(i.DRAW_MODE,t)&&(this._shaderCache[t]=[])}getShader(t,e){const n=this._shaderCache[t];t===i.DRAW_MODE.silhouette&&(e&=~(i.EFFECT_INFO.color.mask|i.EFFECT_INFO.brightness.mask));let r=n[e];return r||(r=n[e]=this._buildShader(t,e)),r}_buildShader(t,e){const s=i.EFFECTS.length,o=["#define DRAW_MODE_".concat(t)];for(let t=0;t{console.error(t);const e=t.match(/\*\*\* Error compiling shader: ([\s\S]+)/);l=e?e[1].trim():t}));if(!h)throw new Error("Failed to compile shader (mode ".concat(t,", effects ").concat(e,"): ").concat(l));return h}}i.EFFECT_INFO={color:{uniformName:"u_color",mask:1,converter:t=>t/200%1,shapeChanges:!1},fisheye:{uniformName:"u_fisheye",mask:2,converter:t=>Math.max(0,(t+100)/100),shapeChanges:!0},whirl:{uniformName:"u_whirl",mask:4,converter:t=>-t*Math.PI/180,shapeChanges:!0},pixelate:{uniformName:"u_pixelate",mask:8,converter:t=>Math.abs(t)/10,shapeChanges:!0},mosaic:{uniformName:"u_mosaic",mask:16,converter:t=>(t=Math.round((Math.abs(t)+10)/10),Math.max(1,Math.min(t,512))),shapeChanges:!0},brightness:{uniformName:"u_brightness",mask:32,converter:t=>Math.max(-100,Math.min(t,100))/100,shapeChanges:!1},ghost:{uniformName:"u_ghost",mask:64,converter:t=>1-Math.max(0,Math.min(t,100))/100,shapeChanges:!1}},i.EFFECTS=Object.keys(i.EFFECT_INFO),i.DRAW_MODE={default:"default",straightAlpha:"straightAlpha",silhouette:"silhouette",colorMask:"colorMask",line:"line",background:"background"},t.exports=i},function(t,e){const n="undefined"==typeof document,r=n?"":"",i=n?"":"",s=`${n?"":""}debug${r}`,o=`${n?"":""}info${r}`,a=`${n?"":""}warn${r}`,c=`${n?"":""}error${r}`,u=(t="")=>{const e=e=>u(t?`${t} ${e}`:e),n=t?[`${i}${t}${r}`]:[];return e.debug=e.log=console.debug.bind(console,...n,s),e.info=console.log.bind(console,...n,o),e.warn=e.warning=console.warn.bind(console,...n,a),e.error=console.error.bind(console,...n,c),e};u.enable=u.disable=()=>{},t.exports=u},function(t,e,n){const r=n(58);t.exports=class extends r{constructor(t,e,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;super(),this._socket=t.getScratchLinkSocket("BLE"),this._socket.setOnOpen(this.requestPeripheral.bind(this)),this._socket.setOnClose(this.handleDisconnectError.bind(this)),this._socket.setOnError(this._handleRequestError.bind(this)),this._socket.setHandleMessage(this._handleMessage.bind(this)),this._sendMessage=this._socket.sendMessage.bind(this._socket),this._availablePeripherals={},this._connectCallback=r,this._connected=!1,this._characteristicDidChangeCallback=null,this._resetCallback=i,this._discoverTimeoutID=null,this._extensionId=e,this._peripheralOptions=n,this._runtime=t,this._socket.open()}requestPeripheral(){this._availablePeripherals={},this._discoverTimeoutID&&window.clearTimeout(this._discoverTimeoutID),this._discoverTimeoutID=window.setTimeout(this._handleDiscoverTimeout.bind(this),15e3),this.sendRemoteRequest("discover",this._peripheralOptions).catch((t=>{this._handleRequestError(t)}))}connectPeripheral(t){this.sendRemoteRequest("connect",{peripheralId:t}).then((()=>{this._connected=!0,this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTED),this._connectCallback()})).catch((t=>{this._handleRequestError(t)}))}disconnect(){this._connected&&(this._connected=!1),this._socket.isOpen()&&this._socket.close(),this._discoverTimeoutID&&window.clearTimeout(this._discoverTimeoutID),this._runtime.emit(this._runtime.constructor.PERIPHERAL_DISCONNECTED)}isConnected(){return this._connected}startNotifications(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const r={serviceId:t,characteristicId:e};return this._characteristicDidChangeCallback=n,this.sendRemoteRequest("startNotifications",r).catch((t=>{this.handleDisconnectError(t)}))}read(t,e){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const r={serviceId:t,characteristicId:e};return arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&(r.startNotifications=!0),n&&(this._characteristicDidChangeCallback=n),this.sendRemoteRequest("read",r).catch((t=>{this.handleDisconnectError(t)}))}write(t,e,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;const s={serviceId:t,characteristicId:e,message:n};return r&&(s.encoding=r),null!==i&&(s.withResponse=i),this.sendRemoteRequest("write",s).catch((t=>{this.handleDisconnectError(t)}))}didReceiveCall(t,e){switch(t){case"didDiscoverPeripheral":this._availablePeripherals[e.peripheralId]=e,this._runtime.emit(this._runtime.constructor.PERIPHERAL_LIST_UPDATE,this._availablePeripherals),this._discoverTimeoutID&&window.clearTimeout(this._discoverTimeoutID);break;case"userDidPickPeripheral":this._availablePeripherals[e.peripheralId]=e,this._runtime.emit(this._runtime.constructor.USER_PICKED_PERIPHERAL,this._availablePeripherals),this._discoverTimeoutID&&window.clearTimeout(this._discoverTimeoutID);break;case"userDidNotPickPeripheral":this._runtime.emit(this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT),this._discoverTimeoutID&&window.clearTimeout(this._discoverTimeoutID);break;case"characteristicDidChange":this._characteristicDidChangeCallback&&this._characteristicDidChangeCallback(e.message);break;case"ping":return 42}}handleDisconnectError(){this._connected&&(this.disconnect(),this._resetCallback&&this._resetCallback(),this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTION_LOST_ERROR,{message:"Scratch lost connection to",extensionId:this._extensionId}))}_handleRequestError(){this._runtime.emit(this._runtime.constructor.PERIPHERAL_REQUEST_ERROR,{message:"Scratch lost connection to",extensionId:this._extensionId})}_handleDiscoverTimeout(){this._discoverTimeoutID&&window.clearTimeout(this._discoverTimeoutID),this._runtime.emit(this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT)}}},function(t,e,n){const r=n(0);t.exports=function(t){if("string"!=typeof t){if(!Array.isArray(t))return r.error("Unexpected input recieved in replaceUnsafeChars"),t;t=String(t)}return t.replace(/[<>&'"]/g,(t=>{switch(t){case"<":return"<";case">":return">";case"&":return"&";case"'":return"'";case'"':return"""}}))}},function(t,e,n){const r=n(6),i=n(0),s=function(t,e,n,r){return t.assetId=e.assetId,n.audioEngine?n.audioEngine.decodeSoundPlayer(Object.assign({},t,{data:e.data})).then((e=>{t.soundId=e.id;const i=e.buffer;return t.rate=i.sampleRate,t.sampleCount=i.length,null!==r&&r.addSoundPlayer(e),n.isPackaged&&(t.asset=null),t})):(i.warn("No audio engine present; cannot load sound asset: ",t.md5),Promise.resolve(t))},o=function(t,e,n){const r=t.asset,i=t.assetId,o=t.sampleCount,a=t.rate,c=t.format,u=t.dataFormat;return t.assetId=e.storage.defaultAssetId.Sound,t.asset=e.storage.get(t.assetId),t.md5="".concat(t.assetId,".").concat(t.asset.dataFormat),s(t,t.asset,e,n).then((t=>(t.broken={},t.broken.assetId=i,t.broken.md5="".concat(i,".").concat(u),t.broken.asset=r,t.broken.sampleCount=o,t.broken.rate=a,t.broken.format=c,t.broken.dataFormat=u,t)))};t.exports={loadSound:function(t,e,n){if(!e.storage)return i.warn("No storage module present; cannot load sound asset: ",t.md5),Promise.resolve(t);const a=r.splitFirst(t.md5,"."),c=a[0],u=a[1].toLowerCase();return t.dataFormat=u,(t.asset&&Promise.resolve(t.asset)||e.storage.load(e.storage.AssetType.Sound,c,u)).then((r=>(t.asset=r,r?s(t,r,e,n):(i.warn("Failed to find sound data: ",t.md5),o(t,e,n))))).catch((r=>(i.warn("Failed to load sound: ".concat(t.md5," with error: ").concat(r)),o(t,e,n))))},loadSoundFromAsset:s}},function(t,e,n){const r=n(6),i=n(0),s=n(71),{loadSvgString:o,serializeSvgToString:a}=n(23),{parseVectorMetadata:c}=n(78),u=function(t,e,n,r){return new Promise((i=>{let s=t.asset.decodeText();if(void 0===n){const e=c(s);e&&(n=e,t.rotationCenterX=n[0],t.rotationCenterY=n[1])}if(r&&2===r){const n=a(o(s,!0));if(s!==n){s=n;const r=e.storage;t.asset.encodeTextData(n,r.DataFormat.SVG,!0),t.assetId=t.asset.assetId,t.md5="".concat(t.assetId,".").concat(t.dataFormat)}}t.skinId=e.renderer.createSVGSkin(s,n),t.size=e.renderer.getSkinSize(t.skinId),n||(n=e.renderer.getSkinRotationCenter(t.skinId),t.rotationCenterX=n[0],t.rotationCenterY=n[1],t.bitmapResolution=1),e.isPackaged&&(t.asset=null),i(t)}))},l=new class{constructor(){this.pool=[],this.clearSoon=null}clear(){this.clearSoon||(this.clearSoon=new Promise((t=>setTimeout(t,1e3))).then((()=>{this.pool.length=0,this.clearSoon=null})))}create(){return this.pool.pop()||document.createElement("canvas")}release(t){this.clear(),this.pool.push(t)}},h=t=>new Promise(((e,n)=>{const r=new Image;r.onload=function(){e(r),r.onload=null,r.onerror=null},r.onerror=function(){n(new Error("Costume load failed. Asset could not be read.")),r.onload=null,r.onerror=null},r.src=t})),d=new s((async t=>{let e;for(let n=0;n<3;n++)try{if("function"==typeof createImageBitmap){const e=await createImageBitmap(new Blob([t.data.buffer],{type:t.assetType.contentType}));if(!e)throw new Error("createImageBitmap resolved with ".concat(e));return e}return await h(t.encodeDataURI())}catch(t){e||(e=t),i.warn(t),await new Promise((t=>setTimeout(t,2e3*Math.random())))}throw e}),25),p=function(t,e,n){return function(t,e,n){return t&&t.asset?e.v2BitmapAdapter?Promise.all([t.asset,t.textLayerAsset].map((t=>t?d.do(t):null))).then((r=>{let[i,s]=r;if(!i)throw new Error("Loading bitmap costume base failed.");const o=1===t.bitmapResolution?2:1;let a,c;if(s){c=l.create(),c.width=i.width,c.height=i.height;const t=c.getContext("2d");t.drawImage(i,0,0),t.drawImage(s,0,0),a=c}else a=i;return 1!==o&&(a=e.v2BitmapAdapter.resize(a,a.width*o,a.height*o),c&&l.release(c)),a.reusable=!1,n&&(n[0]=n[0]*o,n[1]=n[1]*o,t.rotationCenterX=n[0],t.rotationCenterY=n[1]),t.bitmapResolution=2,delete t.textLayerMD5,delete t.textLayerAsset,{image:a,rotationCenter:n,assetMatchesBase:1===o&&!s}})).finally((()=>{delete t.textLayerMD5,delete t.textLayerAsset})):Promise.reject("No V2 Bitmap adapter present."):Promise.reject("Costume load failed. Assets were missing.")}(t,e,n).then((n=>(n.assetMatchesBase||function(n){if(!e.v2BitmapAdapter)return Promise.reject("No V2 Bitmap adapter present.");const r=e.storage;t.asset=r.createAsset(r.AssetType.ImageBitmap,r.DataFormat.PNG,e.v2BitmapAdapter.convertDataURIToBinary(n),null,!0),t.dataFormat=r.DataFormat.PNG,t.assetId=t.asset.assetId,t.md5="".concat(t.assetId,".").concat(t.dataFormat)}((t=>{if(t instanceof HTMLCanvasElement)return t.toDataURL();const e=l.create();e.width=t.width,e.height=t.height,e.getContext("2d").drawImage(t,0,0);const n=e.toDataURL();return l.release(e),n})(n.image)),n))).then((n=>{let r,{image:i,rotationCenter:s}=n;s&&(r=[s[0]/2,s[1]/2]),t.skinId=e.renderer.createBitmapSkin(i,t.bitmapResolution,r);const o=e.renderer.getSkinSize(t.skinId);return t.size=[2*o[0],2*o[1]],s||(s=e.renderer.getSkinRotationCenter(t.skinId),t.rotationCenterX=2*s[0],t.rotationCenterY=2*s[1],t.bitmapResolution=2),e.isPackaged&&(t.asset=null),t}))},f=function(t,e){const n=t.asset,r=t.assetId,i=t.rotationCenterX,s=t.rotationCenterY,o=t.bitmapResolution,a=t.dataFormat,c=e.storage.AssetType,l=t.dataFormat===c.ImageVector.runtimeFormat;t.assetId=l?e.storage.defaultAssetId.ImageVector:e.storage.defaultAssetId.ImageBitmap,t.asset=e.storage.get(t.assetId),t.md5="".concat(t.assetId,".").concat(t.asset.dataFormat);return(l?u(t,e):p(t,e)).then((t=>(t.broken={},t.broken.assetId=r,t.broken.md5="".concat(r,".").concat(a),t.broken.asset=n,t.broken.dataFormat=a,t.broken.rotationCenterX=i,t.broken.rotationCenterY=s,t.broken.bitmapResolution=o,t)))},m=function(t,e,n){t.assetId=t.asset.assetId;if(!e.renderer)return i.warn("No rendering module present; cannot load costume: ",t.name),Promise.resolve(t);const r=e.storage.AssetType;let s;return"number"!=typeof t.rotationCenterX||isNaN(t.rotationCenterX)||"number"!=typeof t.rotationCenterY||isNaN(t.rotationCenterY)||(s=[t.rotationCenterX,t.rotationCenterY]),t.asset.assetType.runtimeFormat===r.ImageVector.runtimeFormat?u(t,e,s,n).catch((n=>(i.warn("Error loading vector image: ".concat(n)),f(t,e)))):p(t,e,s).catch((n=>(i.warn("Error loading bitmap image: ".concat(n)),f(t,e))))};t.exports={loadCostume:function(t,e,n,s){const o=r.splitFirst(t,"."),a=o[0],c=o[1].toLowerCase();if(e.dataFormat=c,e.asset)return m(e,n,s);if(!n.storage)return i.warn("No storage module present; cannot load costume asset: ",t),Promise.resolve(e);if(!n.storage.defaultAssetId)return i.warn("No default assets found"),Promise.resolve(e);const u=n.storage.AssetType,l="svg"===c?u.ImageVector:u.ImageBitmap,h=n.storage.load(l,a,c);let d;return d=e.textLayerMD5?n.storage.load(u.ImageBitmap,e.textLayerMD5,"png"):Promise.resolve(null),Promise.all([h,d]).then((t=>t[0]?(e.asset=t[0],t[1]&&(e.textLayerAsset=t[1]),m(e,n,s)):f(e,n))).catch((t=>(i.warn("Error loading costume: ",t),f(e,n))))},loadCostumeFromAsset:m}},function(t,e){t.exports={ID_NONE:-1,Events:{UseHighQualityRenderChanged:"UseHighQualityRenderChanged",AllowPrivateSkinAccessChanged:"AllowPrivateSkinAccessChanged",NativeSizeChanged:"NativeSizeChanged"}}},function(t,e,n){const r=n(27);r.enable(),t.exports=r("scratch-audioengine")},function(module,exports,__webpack_require__){(function(process,global){var __WEBPACK_AMD_DEFINE_RESULT__;(function(){"use strict";var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_MD5_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS?root=global:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_MD5_NO_COMMON_JS&&"object"==typeof module&&module.exports,AMD=__webpack_require__(254),ARRAY_BUFFER=!root.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[128,32768,8388608,-2147483648],SHIFT=[0,8,16,24],OUTPUT_TYPES=["hex","array","digest","buffer","arrayBuffer","base64"],BASE64_ENCODE_CHAR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),blocks=[],buffer8;if(ARRAY_BUFFER){var buffer=new ArrayBuffer(68);buffer8=new Uint8Array(buffer),blocks=new Uint32Array(buffer)}!root.JS_MD5_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!ARRAY_BUFFER||!root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var createOutputMethod=function(t){return function(e){return new Md5(!0).update(e)[t]()}},createMethod=function(){var t=createOutputMethod("hex");NODE_JS&&(t=nodeWrap(t)),t.create=function(){return new Md5},t.update=function(e){return t.create().update(e)};for(var e=0;e>2]|=t[s]<>6,c[i++]=128|63&r):r<55296||r>=57344?(c[i++]=224|r>>12,c[i++]=128|r>>6&63,c[i++]=128|63&r):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++s)),c[i++]=240|r>>18,c[i++]=128|r>>12&63,c[i++]=128|r>>6&63,c[i++]=128|63&r);else for(i=this.start;s>2]|=r<>2]|=(192|r>>6)<>2]|=(128|63&r)<=57344?(a[i>>2]|=(224|r>>12)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<>2]|=(240|r>>18)<>2]|=(128|r>>12&63)<>2]|=(128|r>>6&63)<>2]|=(128|63&r)<=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}},Md5.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[e>>2]|=EXTRA[3&e],e>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Md5.prototype.hash=function(){var t,e,n,r,i,s,o=this.blocks;this.first?e=((e=((t=((t=o[0]-680876937)<<7|t>>>25)-271733879|0)^(n=((n=(-271733879^(r=((r=(-1732584194^2004318071&t)+o[1]-117830708)<<12|r>>>20)+t|0)&(-271733879^t))+o[2]-1126478375)<<17|n>>>15)+r|0)&(r^t))+o[3]-1316259209)<<22|e>>>10)+n|0:(t=this.h0,e=this.h1,n=this.h2,e=((e+=((t=((t+=((r=this.h3)^e&(n^r))+o[0]-680876936)<<7|t>>>25)+e|0)^(n=((n+=(e^(r=((r+=(n^t&(e^n))+o[1]-389564586)<<12|r>>>20)+t|0)&(t^e))+o[2]+606105819)<<17|n>>>15)+r|0)&(r^t))+o[3]-1044525330)<<22|e>>>10)+n|0),e=((e+=((t=((t+=(r^e&(n^r))+o[4]-176418897)<<7|t>>>25)+e|0)^(n=((n+=(e^(r=((r+=(n^t&(e^n))+o[5]+1200080426)<<12|r>>>20)+t|0)&(t^e))+o[6]-1473231341)<<17|n>>>15)+r|0)&(r^t))+o[7]-45705983)<<22|e>>>10)+n|0,e=((e+=((t=((t+=(r^e&(n^r))+o[8]+1770035416)<<7|t>>>25)+e|0)^(n=((n+=(e^(r=((r+=(n^t&(e^n))+o[9]-1958414417)<<12|r>>>20)+t|0)&(t^e))+o[10]-42063)<<17|n>>>15)+r|0)&(r^t))+o[11]-1990404162)<<22|e>>>10)+n|0,e=((e+=((t=((t+=(r^e&(n^r))+o[12]+1804603682)<<7|t>>>25)+e|0)^(n=((n+=(e^(r=((r+=(n^t&(e^n))+o[13]-40341101)<<12|r>>>20)+t|0)&(t^e))+o[14]-1502002290)<<17|n>>>15)+r|0)&(r^t))+o[15]+1236535329)<<22|e>>>10)+n|0,e=((e+=((r=((r+=(e^n&((t=((t+=(n^r&(e^n))+o[1]-165796510)<<5|t>>>27)+e|0)^e))+o[6]-1069501632)<<9|r>>>23)+t|0)^t&((n=((n+=(t^e&(r^t))+o[11]+643717713)<<14|n>>>18)+r|0)^r))+o[0]-373897302)<<20|e>>>12)+n|0,e=((e+=((r=((r+=(e^n&((t=((t+=(n^r&(e^n))+o[5]-701558691)<<5|t>>>27)+e|0)^e))+o[10]+38016083)<<9|r>>>23)+t|0)^t&((n=((n+=(t^e&(r^t))+o[15]-660478335)<<14|n>>>18)+r|0)^r))+o[4]-405537848)<<20|e>>>12)+n|0,e=((e+=((r=((r+=(e^n&((t=((t+=(n^r&(e^n))+o[9]+568446438)<<5|t>>>27)+e|0)^e))+o[14]-1019803690)<<9|r>>>23)+t|0)^t&((n=((n+=(t^e&(r^t))+o[3]-187363961)<<14|n>>>18)+r|0)^r))+o[8]+1163531501)<<20|e>>>12)+n|0,e=((e+=((r=((r+=(e^n&((t=((t+=(n^r&(e^n))+o[13]-1444681467)<<5|t>>>27)+e|0)^e))+o[2]-51403784)<<9|r>>>23)+t|0)^t&((n=((n+=(t^e&(r^t))+o[7]+1735328473)<<14|n>>>18)+r|0)^r))+o[12]-1926607734)<<20|e>>>12)+n|0,e=((e+=((s=(r=((r+=((i=e^n)^(t=((t+=(i^r)+o[5]-378558)<<4|t>>>28)+e|0))+o[8]-2022574463)<<11|r>>>21)+t|0)^t)^(n=((n+=(s^e)+o[11]+1839030562)<<16|n>>>16)+r|0))+o[14]-35309556)<<23|e>>>9)+n|0,e=((e+=((s=(r=((r+=((i=e^n)^(t=((t+=(i^r)+o[1]-1530992060)<<4|t>>>28)+e|0))+o[4]+1272893353)<<11|r>>>21)+t|0)^t)^(n=((n+=(s^e)+o[7]-155497632)<<16|n>>>16)+r|0))+o[10]-1094730640)<<23|e>>>9)+n|0,e=((e+=((s=(r=((r+=((i=e^n)^(t=((t+=(i^r)+o[13]+681279174)<<4|t>>>28)+e|0))+o[0]-358537222)<<11|r>>>21)+t|0)^t)^(n=((n+=(s^e)+o[3]-722521979)<<16|n>>>16)+r|0))+o[6]+76029189)<<23|e>>>9)+n|0,e=((e+=((s=(r=((r+=((i=e^n)^(t=((t+=(i^r)+o[9]-640364487)<<4|t>>>28)+e|0))+o[12]-421815835)<<11|r>>>21)+t|0)^t)^(n=((n+=(s^e)+o[15]+530742520)<<16|n>>>16)+r|0))+o[2]-995338651)<<23|e>>>9)+n|0,e=((e+=((r=((r+=(e^((t=((t+=(n^(e|~r))+o[0]-198630844)<<6|t>>>26)+e|0)|~n))+o[7]+1126891415)<<10|r>>>22)+t|0)^((n=((n+=(t^(r|~e))+o[14]-1416354905)<<15|n>>>17)+r|0)|~t))+o[5]-57434055)<<21|e>>>11)+n|0,e=((e+=((r=((r+=(e^((t=((t+=(n^(e|~r))+o[12]+1700485571)<<6|t>>>26)+e|0)|~n))+o[3]-1894986606)<<10|r>>>22)+t|0)^((n=((n+=(t^(r|~e))+o[10]-1051523)<<15|n>>>17)+r|0)|~t))+o[1]-2054922799)<<21|e>>>11)+n|0,e=((e+=((r=((r+=(e^((t=((t+=(n^(e|~r))+o[8]+1873313359)<<6|t>>>26)+e|0)|~n))+o[15]-30611744)<<10|r>>>22)+t|0)^((n=((n+=(t^(r|~e))+o[6]-1560198380)<<15|n>>>17)+r|0)|~t))+o[13]+1309151649)<<21|e>>>11)+n|0,e=((e+=((r=((r+=(e^((t=((t+=(n^(e|~r))+o[4]-145523070)<<6|t>>>26)+e|0)|~n))+o[11]-1120210379)<<10|r>>>22)+t|0)^((n=((n+=(t^(r|~e))+o[2]+718787259)<<15|n>>>17)+r|0)|~t))+o[9]-343485551)<<21|e>>>11)+n|0,this.first?(this.h0=t+1732584193|0,this.h1=e-271733879|0,this.h2=n-1732584194|0,this.h3=r+271733878|0,this.first=!1):(this.h0=this.h0+t|0,this.h1=this.h1+e|0,this.h2=this.h2+n|0,this.h3=this.h3+r|0)},Md5.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3;return HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]},Md5.prototype.toString=Md5.prototype.hex,Md5.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,r=this.h3;return[255&t,t>>8&255,t>>16&255,t>>24&255,255&e,e>>8&255,e>>16&255,e>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255]},Md5.prototype.array=Md5.prototype.digest,Md5.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),e=new Uint32Array(t);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,t},Md5.prototype.buffer=Md5.prototype.arrayBuffer,Md5.prototype.base64=function(){for(var t,e,n,r="",i=this.array(),s=0;s<15;)t=i[s++],e=i[s++],n=i[s++],r+=BASE64_ENCODE_CHAR[t>>>2]+BASE64_ENCODE_CHAR[63&(t<<4|e>>>4)]+BASE64_ENCODE_CHAR[63&(e<<2|n>>>6)]+BASE64_ENCODE_CHAR[63&n];return t=i[s],r+=BASE64_ENCODE_CHAR[t>>>2]+BASE64_ENCODE_CHAR[t<<4&63]+"=="};var exports=createMethod();COMMON_JS?module.exports=exports:(root.md5=exports,AMD&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return exports}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))})()}).call(this,__webpack_require__(35),__webpack_require__(8))},function(t,e){var n,r,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var c,u=[],l=!1,h=-1;function d(){l&&c&&(l=!1,c.length?u=c.concat(u):h=-1,u.length&&p())}function p(){if(!l){var t=a(d);l=!0;for(var e=u.length;e;){for(c=u,u=[];++h1)for(var n=1;n0&&(this._lastUpdateTime=t),this._count=Math.min(this._maxTokens,this._count+n),this._count>0&&(this._count--,!0)}}},function(t,e,n){(function(e){let n=e.fetch;t.exports={fetchWithTimeout:(t,e,r)=>{let i=null;const s=window.AbortController?new window.AbortController:null,o=s?s.signal:null;return Promise.race([n(t,Object.assign({signal:o},e)).then((t=>(clearTimeout(i),t)),(t=>{throw clearTimeout(i),t})),new Promise(((t,e)=>{i=setTimeout((()=>{s&&s.abort(),e(new Error("Fetch timed out after ".concat(r," ms")))}),r)}))])},setFetch:t=>{n=t}}}).call(this,n(8))},function(t,e,n){function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const s=n(17),{OrderedMap:o}=n(21),a=n(60),c=n(296),u=n(3),l=n(15),h=n(64),d=n(2),p=n(184),f=n(185),m=n(44),g=n(43),b=n(68),y=n(36),v=n(22),w=n(0),T=n(54),E=n(12),A=n(9),k=n(29),I=n(191),S=n(192),x=n(38),O=n(194),M=n(195),N=n(196),C=n(197),R=n(198),D=n(199),P=n(200),L=n(69),B=n(6),U=n(7),j={scratch3_control:n(201),scratch3_event:n(202),scratch3_looks:n(203),scratch3_motion:n(204),scratch3_operators:n(205),scratch3_sound:n(206),scratch3_sensing:n(207),scratch3_data:n(208),scratch3_procedures:n(209)},F=n(210),z=n(211),V=["#0FBD8C","#0DA57A","#0B8E69"],G=" // _twconfig_",Y=(()=>{const t={};return t[u.ANGLE]={shadow:{type:"math_angle",fieldName:"NUM"}},t[u.COLOR]={shadow:{type:"colour_picker",fieldName:"COLOUR"}},t[u.NUMBER]={shadow:{type:"math_number",fieldName:"NUM"}},t[u.STRING]={shadow:{type:"text",fieldName:"TEXT"}},t[u.BOOLEAN]={check:"Boolean"},t[u.MATRIX]={shadow:{type:"matrix",fieldName:"MATRIX"}},t[u.NOTE]={shadow:{type:"note",fieldName:"NOTE"}},t[u.IMAGE]={fieldType:"field_image"},t[u.COSTUME]={shadow:{type:"looks_costume",fieldName:"COSTUME"}},t[u.SOUND]={shadow:{type:"sound_sounds_menu",fieldName:"SOUND_MENU"}},t})(),H=t=>{let e=0;return{canAddCloudVariable:()=>e{e++},removeCloudVariable:()=>{e--},hasCloudVariables:()=>e>0,getNumberOfCloudVariables:()=>e}};let W=-1,K=-1,q=-1;class Q extends s{constructor(){super(),this.targets=[],this.executableTargets=[],this.threads=[],this.threadMap=new Map,this.sequencer=new f(this),this.flyoutBlocks=new l(this,!0),this.monitorBlocks=new l(this,!0),this._editingTarget=null,this._primitives={},this._blockInfo=[],this._hats={},this._flowing={},this._scriptGlowsPreviousFrame=[],this._nonMonitorThreadCount=0,this._lastStepDoneThreads=null,this._cloneCounter=0,this._refreshTargets=!1,this.monitorBlockInfo={},this._monitorState=o({}),this._prevMonitorState=o({}),this.turboMode=!1,this.frameLoop=new z(this),this.currentStepTime=1e3/30,this.updateCurrentMSecs(),this.redrawRequested=!1,this._registerBlockPackages(),this.ioDevices={clock:new M(this),cloud:new N(this),keyboard:new C(this),mouse:new R(this),mouseWheel:new D(this),userData:new P,video:new L(this)},this.peripheralExtensions={},this.profiler=null,this.cloudOptions={limit:10};const t=H(this.cloudOptions);this.hasCloudData=t.hasCloudVariables,this.canAddCloudVariable=t.canAddCloudVariable,this.getNumberOfCloudVariables=t.getNumberOfCloudVariables,this.addCloudVariable=this._initializeAddCloudVariable(t),this.removeCloudVariable=this._initializeRemoveCloudVariable(t),this.origin=null,this.platform=Object.assign({},O),this._initScratchLink(),this.resetRunId(),this._stageTarget=null,this.addonBlocks={},this.stageWidth=Q.STAGE_WIDTH,this.stageHeight=Q.STAGE_HEIGHT,this.runtimeOptions={maxClones:Q.MAX_CLONES,miscLimits:!0,fencing:!0},this.compilerOptions={enabled:!0,warpTimer:!1},this.debug=!1,this._lastStepTime=Date.now(),this.interpolationEnabled=!1,this._defaultStoredSettings=this._generateAllProjectOptions(),this.isPackaged=!1,this.externalCommunicationMethods={cloudVariables:!1,customExtensions:!1},this.on(Q.HAS_CLOUD_DATA_UPDATE,(t=>{this.setExternalCommunicationMethod("cloudVariables",t)})),this.enforcePrivacy=!0,this.extensionButtons=new Map,this.fontManager=new S(this),this.extensionStorage={},this.totalAssetRequests=0,this.finishedAssetRequests=0}static get STAGE_WIDTH(){return 480}static get STAGE_HEIGHT(){return 360}static get SCRIPT_GLOW_ON(){return"SCRIPT_GLOW_ON"}static get SCRIPT_GLOW_OFF(){return"SCRIPT_GLOW_OFF"}static get BLOCK_GLOW_ON(){return"BLOCK_GLOW_ON"}static get BLOCK_GLOW_OFF(){return"BLOCK_GLOW_OFF"}static get HAS_CLOUD_DATA_UPDATE(){return"HAS_CLOUD_DATA_UPDATE"}static get TURBO_MODE_ON(){return"TURBO_MODE_ON"}static get TURBO_MODE_OFF(){return"TURBO_MODE_OFF"}static get RUNTIME_OPTIONS_CHANGED(){return"RUNTIME_OPTIONS_CHANGED"}static get COMPILER_OPTIONS_CHANGED(){return"COMPILER_OPTIONS_CHANGED"}static get FRAMERATE_CHANGED(){return"FRAMERATE_CHANGED"}static get INTERPOLATION_CHANGED(){return"INTERPOLATION_CHANGED"}static get STAGE_SIZE_CHANGED(){return"STAGE_SIZE_CHANGED"}static get COMPILE_ERROR(){return"COMPILE_ERROR"}static get BEFORE_EXECUTE(){return"BEFORE_EXECUTE"}static get AFTER_EXECUTE(){return"AFTER_EXECUTE"}static get ASSET_PROGRESS(){return"ASSET_PROGRESS"}static get PROJECT_START(){return"PROJECT_START"}static get PROJECT_RUN_START(){return"PROJECT_RUN_START"}static get PROJECT_RUN_STOP(){return"PROJECT_RUN_STOP"}static get PROJECT_STOP_ALL(){return"PROJECT_STOP_ALL"}static get STOP_FOR_TARGET(){return"STOP_FOR_TARGET"}static get VISUAL_REPORT(){return"VISUAL_REPORT"}static get PROJECT_LOADED(){return"PROJECT_LOADED"}static get PROJECT_CHANGED(){return"PROJECT_CHANGED"}static get TOOLBOX_EXTENSIONS_NEED_UPDATE(){return"TOOLBOX_EXTENSIONS_NEED_UPDATE"}static get TARGETS_UPDATE(){return"TARGETS_UPDATE"}static get MONITORS_UPDATE(){return"MONITORS_UPDATE"}static get BLOCK_DRAG_UPDATE(){return"BLOCK_DRAG_UPDATE"}static get BLOCK_DRAG_END(){return"BLOCK_DRAG_END"}static get EXTENSION_ADDED(){return"EXTENSION_ADDED"}static get EXTENSION_FIELD_ADDED(){return"EXTENSION_FIELD_ADDED"}static get PERIPHERAL_LIST_UPDATE(){return"PERIPHERAL_LIST_UPDATE"}static get USER_PICKED_PERIPHERAL(){return"USER_PICKED_PERIPHERAL"}static get PERIPHERAL_CONNECTED(){return"PERIPHERAL_CONNECTED"}static get PERIPHERAL_DISCONNECTED(){return"PERIPHERAL_DISCONNECTED"}static get PERIPHERAL_REQUEST_ERROR(){return"PERIPHERAL_REQUEST_ERROR"}static get PERIPHERAL_CONNECTION_LOST_ERROR(){return"PERIPHERAL_CONNECTION_LOST_ERROR"}static get PERIPHERAL_SCAN_TIMEOUT(){return"PERIPHERAL_SCAN_TIMEOUT"}static get MIC_LISTENING(){return"MIC_LISTENING"}static get BLOCKSINFO_UPDATE(){return"BLOCKSINFO_UPDATE"}static get RUNTIME_STARTED(){return"RUNTIME_STARTED"}static get RUNTIME_STOPPED(){return"RUNTIME_STOPPED"}static get RUNTIME_DISPOSED(){return"RUNTIME_DISPOSED"}static get BLOCKS_NEED_UPDATE(){return"BLOCKS_NEED_UPDATE"}static get PLATFORM_MISMATCH(){return"PLATFORM_MISMATCH"}static get THREAD_STEP_INTERVAL(){return 1e3/60}static get THREAD_STEP_INTERVAL_COMPATIBILITY(){return 1e3/30}static get MAX_CLONES(){return 300}_initializeAddCloudVariable(t){return()=>{const e=this.hasCloudData();t.addCloudVariable(),!e&&this.hasCloudData()&&this.emit(Q.HAS_CLOUD_DATA_UPDATE,!0)}}_initializeRemoveCloudVariable(t){return()=>{const e=this.hasCloudData();t.removeCloudVariable(),e&&!this.hasCloudData()&&this.emit(Q.HAS_CLOUD_DATA_UPDATE,!1)}}_registerBlockPackages(){for(const t in j)if(Object.prototype.hasOwnProperty.call(j,t)){const e=new j[t](this);if(e.getPrimitives){const t=e.getPrimitives();for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(this._primitives[n]=t[n].bind(e))}if(e.getHats){const t=e.getHats();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this._hats[e]=t[e])}e.getMonitored&&(this.monitorBlockInfo=Object.assign({},this.monitorBlockInfo,e.getMonitored())),this.compilerRegisterExtension(t,e)}}compilerRegisterExtension(t,e){this["ext_".concat(t)]=e}getMonitorState(){return this._monitorState}_makeExtensionMenuId(t,e){return"".concat(e,"_menu_").concat(t)}makeMessageContextForTarget(t){const e={};(t=t||this.getEditingTarget()||this.getTargetForStage())&&(e.targetType=t.isStage?y.STAGE:y.SPRITE)}_registerExtensionPrimitives(t){const e={id:t.id,name:T(t.name),showStatusButton:t.showStatusButton,blockIconURI:t.blockIconURI,menuIconURI:t.menuIconURI};t.color1?(e.color1=t.color1,e.color2=t.color2,e.color3=t.color3):(e.color1=V[0],e.color2=V[1],e.color3=V[2]),this._blockInfo.push(e),this._fillExtensionCategory(e,t);for(const n in e.customFieldTypes)if(Object.prototype.hasOwnProperty.call(t.customFieldTypes,n)){const t=e.customFieldTypes[n];this.emit(Q.EXTENSION_FIELD_ADDED,{name:"field_".concat(t.extendedName),implementation:t.fieldImplementation})}this.emit(Q.EXTENSION_ADDED,e)}_refreshExtensionPrimitives(t){const e=this._blockInfo.find((e=>e.id===t.id));e&&(e.name=T(t.name),this._fillExtensionCategory(e,t),this.emit(Q.BLOCKSINFO_UPDATE,e))}_fillExtensionCategory(t,e){t.blocks=[],t.customFieldTypes={},t.menus=[],t.menuInfo={};for(const n in e.menus)if(Object.prototype.hasOwnProperty.call(e.menus,n)){const r=e.menus[n],i=this._buildMenuForScratchBlocks(n,r,t);t.menus.push(i),t.menuInfo[n]=r}for(const n in e.customFieldTypes)if(Object.prototype.hasOwnProperty.call(e.customFieldTypes,n)){const r=e.customFieldTypes[n],i=this._buildCustomFieldInfo(n,r,e.id,t);t.customFieldTypes[n]=i}if(e.docsURI){const n={info:{},xml:"')};t.blocks.push(n)}for(const n of e.blocks)try{const e=this._convertForScratchBlocks(n,t);if(t.blocks.push(e),e.json){const t=e.json.type;n.blockType!==d.EVENT&&(this._primitives[t]=e.info.func),n.blockType===d.EVENT||n.blockType===d.HAT?this._hats[t]={edgeActivated:n.isEdgeActivated,restartExistingThreads:n.shouldRestartExistingThreads}:n.blockType===d.CONDITIONAL?this._flowing[t]={conditional:!0,loop:!1}:n.blockType===d.LOOP&&(this._flowing[t]={conditional:!1,loop:!0})}}catch(t){w.error("Error parsing block: ",{block:n,error:t})}}_convertMenuItems(t){if("function"!=typeof t){const e=this.makeMessageContextForTarget();return t.map((t=>{const n=T(t,e);switch(typeof n){case"string":return[n,n];case"object":return[T(t.text,e),t.value];default:throw new Error("Can't interpret menu item: ".concat(JSON.stringify(t)))}}))}return t}_buildMenuForScratchBlocks(t,e,n){const r=this._makeExtensionMenuId(t,n.id),i=this._convertMenuItems(e.items);return{json:{message0:"%1",type:r,inputsInline:!0,output:"String",colour:n.color1,colourSecondary:n.color2,colourTertiary:n.color3,outputShape:e.acceptReporters?b.OUTPUT_SHAPE_ROUND:b.OUTPUT_SHAPE_SQUARE,args0:[{type:"field_dropdown",name:t,options:i}]}}}_buildCustomFieldInfo(t,e,n,r){const i="".concat(n,"_").concat(t);return{fieldName:t,extendedName:i,argumentTypeInfo:{shadow:{type:i,fieldName:"field_".concat(i)}},scratchBlocksDefinition:this._buildCustomFieldTypeForScratchBlocks(i,e.output,e.outputShape,r),fieldImplementation:e.implementation}}_buildCustomFieldTypeForScratchBlocks(t,e,n,r){return{json:{type:t,message0:"%1",inputsInline:!0,output:e,colour:r.color1,colourSecondary:r.color2,colourTertiary:r.color3,outputShape:n,args0:[{name:"field_".concat(t),type:"field_".concat(t)}]}}}_convertForScratchBlocks(t,e){return"---"===t?this._convertSeparatorForScratchBlocks(t):t.blockType===d.LABEL?this._convertLabelForScratchBlocks(t):t.blockType===d.BUTTON?this._convertButtonForScratchBlocks(t,e):t.blockType===d.XML?this._convertXmlForScratchBlocks(t):this._convertBlockForScratchBlocks(t,e)}_convertBlockForScratchBlocks(t,e){var n,r,i;const s="".concat(e.id,"_").concat(t.opcode),o={type:s,inputsInline:!0,category:e.name,extensions:[],colour:null!==(n=t.color1)&&void 0!==n?n:e.color1,colourSecondary:null!==(r=t.color2)&&void 0!==r?r:e.color2,colourTertiary:null!==(i=t.color3)&&void 0!==i?i:e.color3},a={argsMap:{},blockJSON:o,categoryInfo:e,blockInfo:t,inputList:[]},c=t.blockIconURI||e.blockIconURI;if(o.extensions.push("from_extension"),o.colour===V[0]&&o.colourSecondary===V[1]&&o.colourTertiary===V[2]&&o.extensions.push("default_extension_colors"),c){o.extensions.push("scratch_extension"),o.message0="%1 %2";const t={type:"field_image",src:c,width:40,height:40},e={type:"field_vertical_separator"};o.args0=[t,e]}switch(t.blockType){case d.COMMAND:o.outputShape=b.OUTPUT_SHAPE_SQUARE,o.previousStatement=null,t.isTerminal||(o.nextStatement=null);break;case d.REPORTER:o.output=t.allowDropAnywhere?null:"String",o.outputShape=b.OUTPUT_SHAPE_ROUND;break;case d.BOOLEAN:o.output="Boolean",o.outputShape=b.OUTPUT_SHAPE_HEXAGONAL;break;case d.HAT:case d.EVENT:Object.prototype.hasOwnProperty.call(t,"isEdgeActivated")||(t.isEdgeActivated=!0),o.outputShape=b.OUTPUT_SHAPE_SQUARE,o.nextStatement=null;break;case d.CONDITIONAL:case d.LOOP:t.branchCount=t.branchCount||1,o.outputShape=b.OUTPUT_SHAPE_SQUARE,o.previousStatement=null,t.isTerminal||(o.nextStatement=null)}t.blockShape&&(o.outputShape=t.blockShape);const u=Array.isArray(t.text)?t.text:[t.text];let l=0,h=0,p=0;const f=this._convertPlaceholders.bind(this,a),m=this.makeMessageContextForTarget();for(;l0?h+1:"")}],++h,++p)}if(t.blockType===d.REPORTER||t.blockType===d.BOOLEAN)t.disableMonitor||0!==a.inputList.length||(o.checkboxInFlyout=!0);else if(t.branchIconURI||t.blockType===d.LOOP&&!Object.prototype.hasOwnProperty.call(t,"branchIconURI")){var g;o["lastDummyAlign".concat(p)]="RIGHT",o["message".concat(p)]="%1",o["args".concat(p)]=[{type:"field_image",src:null!==(g=t.branchIconURI)&&void 0!==g?g:"media://repeat.svg",width:24,height:24,alt:"*",flip_rtl:!0}],++p}const y=t.isDynamic?''):"",v=a.inputList.join(""),w='').concat(y).concat(v,"");if(t.extensions)for(const e of t.extensions)o.extensions.includes(e)||o.extensions.push(e);return{info:a.blockInfo,json:a.blockJSON,xml:w}}_convertSeparatorForScratchBlocks(t){return{info:t,xml:''}}_convertLabelForScratchBlocks(t){return{info:t,xml:'')}}_convertButtonForScratchBlocks(t,e){const n=this.makeMessageContextForTarget(),r=T(t.text,n);if(["MAKE_A_LIST","MAKE_A_PROCEDURE","MAKE_A_VARIABLE"].includes(t.func))return{info:t,xml:'')};const i="".concat(e.id,"_").concat(t.func);return this.extensionButtons.set(i,t.callFunc),{info:t,xml:'')}}_convertXmlForScratchBlocks(t){return{info:t,xml:t.xml}}handleExtensionButtonPress(t){this.extensionButtons.get(t)()}_constructInlineImageJson(t){return t.dataURI||w.warn("Missing data URI in extension block with argument type IMAGE"),{type:"field_image",src:t.dataURI||"",width:24,height:24,flip_rtl:t.flipRTL||!1}}_convertPlaceholders(t,e,n){const r=t.blockInfo.arguments[n]||{};let i,s=Y[r.type]||{};if(!Y[r.type]&&t.categoryInfo.customFieldTypes[r.type]&&(s=t.categoryInfo.customFieldTypes[r.type].argumentTypeInfo),"field_image"===s.fieldType)i=this._constructInlineImageJson(r);else{i={type:"input_value",name:n};const e=void 0===r.defaultValue?null:T(r.defaultValue,this.makeMessageContextForTarget()).toString();let o,a,c;if(s.check&&(i.check=s.check),r.menu){const e=t.categoryInfo.menuInfo[r.menu];e.acceptReporters?(o=n,a=this._makeExtensionMenuId(r.menu,t.categoryInfo.id),c=r.menu):(i.type="field_dropdown",i.options=this._convertMenuItems(e.items),o=null,a=null,c=n)}else o=n,a=s.shadow&&s.shadow.type||null,c=s.shadow&&s.shadow.fieldName||null;o&&t.inputList.push('')),a&&t.inputList.push('')),null!==e&&c&&t.inputList.push('').concat(k(e),"")),a&&t.inputList.push(""),o&&t.inputList.push("")}const o="args".concat(t.outLineNum),a=t.blockJSON[o]=t.blockJSON[o]||[];i&&a.push(i);const c=a.length;return t.argsMap[n]=c,"%".concat(c)}getBlocksXML(t){return this._blockInfo.map((e=>{const{name:n,color1:r,color2:i}=e,s=e.blocks.filter((e=>{let n=!0;return t&&e.info.filter&&(n=e.info.filter.includes(t.isStage?y.STAGE:y.SPRITE)),n&&!e.info.hideFromPalette})),o='colour="'.concat(k(r),'" secondaryColour="').concat(k(i),'"');let a="";e.menuIconURI?a=e.menuIconURI:e.blockIconURI&&(a=e.blockIconURI);const c=a?'iconURI="'.concat(k(a),'"'):"";let u="";e.showStatusButton&&(u='showStatusButton="true"');let l='"),l+=s.map((t=>t.xml)).join(""),l+="",{id:e.id,xml:l}}))}getBlocksJSON(){return this._blockInfo.reduce(((t,e)=>t.concat(e.blocks.map((t=>t.json)))),[])}_initScratchLink(){if("undefined"!=typeof self&&"undefined"!=typeof document&&document.getElementById&&self.origin&&"null"!==self.origin&&self.navigator&&self.navigator.userAgent&&!self.navigator.userAgent.includes("Node.js")&&!self.navigator.userAgent.includes("jsdom")){if(!document.getElementById("scratch-link-extension-script")){const t=document.createElement("script");t.id="scratch-link-extension-script",document.body.appendChild(t),self.postMessage("inject-scratch-link-script",self.origin)}}}getScratchLinkSocket(t){return(this._linkSocketFactory||this._defaultScratchLinkSocketFactory)(t)}configureScratchLinkSocketFactory(t){this._linkSocketFactory=t}_defaultScratchLinkSocketFactory(t){const e=self.Scratch,n=e&&e.ScratchLinkSafariSocket;return n&&n.isSafariHelperCompatible()?new n(t):new I(t)}registerPeripheralExtension(t,e){this.peripheralExtensions[t]=e}scanForPeripheral(t){this.peripheralExtensions[t]&&this.peripheralExtensions[t].scan()}connectPeripheral(t,e){this.peripheralExtensions[t]&&this.peripheralExtensions[t].connect(e)}disconnectPeripheral(t){this.peripheralExtensions[t]&&this.peripheralExtensions[t].disconnect()}getPeripheralIsConnected(t){let e=!1;return this.peripheralExtensions[t]&&(e=this.peripheralExtensions[t].isConnected()),e}emitMicListening(t){this.emit(Q.MIC_LISTENING,t)}getOpcodeFunction(t){return this._primitives[t]}getIsHat(t){return Object.prototype.hasOwnProperty.call(this._hats,t)}getIsEdgeActivatedHat(t){return Object.prototype.hasOwnProperty.call(this._hats,t)&&this._hats[t].edgeActivated}attachAudioEngine(t){this.audioEngine=t}attachRenderer(t){this.renderer=t,this.renderer.setLayerGroupOrdering(E.LAYER_GROUPS),this.renderer.offscreenTouching=!this.runtimeOptions.fencing,this.updatePrivacy()}attachV2BitmapAdapter(t){this.v2BitmapAdapter=t}attachStorage(t){if(this.storage=t,this.isPackaged){const e=t.createAsset;let n=0;t.createAsset=function(t,r,i,s,o){return s||(s=(++n).toString()),e.call(this,t,r,i,s,!1)}}x.setFetch(t.scratchFetch.scratchFetch),this.resetRunId()}_pushThread(t,e,n){const r=new v(t);return r.target=e,r.stackClick=Boolean(n&&n.stackClick),r.updateMonitor=Boolean(n&&n.updateMonitor),r.blockContainer=r.updateMonitor?this.monitorBlocks:e.blocks,r.pushStack(t),this.threads.push(r),r.stackClick||r.updateMonitor||this.threadMap.set(r.getId(),r),n&&n.updateMonitor||!this.compilerOptions.enabled||r.tryCompile(),r}_stopThread(t){t.isKilled=!0,this.sequencer.retireThread(t)}_restartThread(t){const e=new v(t.topBlock);e.target=t.target,e.stackClick=t.stackClick,e.updateMonitor=t.updateMonitor,e.blockContainer=t.blockContainer,e.pushStack(t.topBlock),t.triedToCompile&&this.compilerOptions.enabled&&e.tryCompile(),e.stackClick||e.updateMonitor||this.threadMap.set(e.getId(),e);const n=this.threads.indexOf(t);return n>-1?(this.threads[n]=e,e):(this.threads.push(t),t)}emitCompileError(t,e){this.emit(Q.COMPILE_ERROR,t,e)}isActiveThread(t){return t.stack.length>0&&t.status!==v.STATUS_DONE&&this.threads.indexOf(t)>-1}isWaitingThread(t){return t.status===v.STATUS_PROMISE_WAIT||t.status===v.STATUS_YIELD_TICK||!this.isActiveThread(t)}toggleScript(t,e){e=Object.assign({target:this._editingTarget,stackClick:!1},e);for(let n=0;n=0;e--){const r=n[e],i=r.blocks.getScripts();for(let e=0;e=0;n--){const i=r[n],s=h.getScripts(i.blocks,t);for(let t=0;t{const{blockId:o,fieldsOfInputs:a}=t;for(const t in e)if(a[t].value!==e[t])return;if(i.restartExistingThreads){const t=this.threadMap.get(v.getIdFromTargetAndBlock(n,o));if(t)return void r.push(this._restartThread(t))}else for(let t=0;t{t.isCompiled?t.executableHat&&(g.saveGlobalState(),g(t),g.restoreGlobalState()):(m(this.sequencer,t),t.goToNextBlock())})),r}dispose(){this.stopAll(),this.targets.forEach((t=>{t.isOriginal&&t.deleteMonitors()})),this.targets.map(this.disposeTarget,this),this.extensionStorage={};const t=o({});t.equals(this._monitorState)||(this._monitorState=t,this.emit(Q.MONITORS_UPDATE,this._monitorState)),this.emit(Q.RUNTIME_DISPOSED),this.ioDevices.clock.resetProjectTimer(),this.fontManager.clear(),this.hasCloudData()&&this.emit(Q.HAS_CLOUD_DATA_UPDATE,!1),this.ioDevices.cloud.clear();const e=H(this.cloudOptions);this.hasCloudData=e.hasCloudVariables,this.canAddCloudVariable=e.canAddCloudVariable,this.getNumberOfCloudVariables=e.getNumberOfCloudVariables,this.addCloudVariable=this._initializeAddCloudVariable(e),this.removeCloudVariable=this._initializeRemoveCloudVariable(e),this.resetProgress()}addTarget(t){this.targets.push(t),this.executableTargets.push(t),t.isStage&&!this._stageTarget&&(this._stageTarget=t)}moveExecutable(t,e){const n=this.executableTargets.indexOf(t);this.executableTargets.splice(n,1);let r=n+e;return r>this.executableTargets.length&&(r=this.executableTargets.length),r<=0&&(r=this.executableTargets.length>0&&this.executableTargets[0].isStage?1:0),this.executableTargets.splice(r,0,t),r}setExecutablePosition(t,e){const n=this.executableTargets.indexOf(t);return this.moveExecutable(t,e-n)}removeExecutable(t){const e=this.executableTargets.indexOf(t);e>-1&&this.executableTargets.splice(e,1)}disposeTarget(t){this.targets=this.targets.filter((e=>t!==e||(e.dispose(),!1))),this._stageTarget===t&&(this._stageTarget=null)}stopForTarget(t,e){this.emit(Q.STOP_FOR_TARGET,t,e);for(let n=0;nt.clearEdgeActivatedValues()));for(let t=0;t!t.isKilled)),this.updateThreadMap();for(const t in this._hats){if(!Object.prototype.hasOwnProperty.call(this._hats,t))continue;this._hats[t].edgeActivated&&this.startHats(t)}this.redrawRequested=!1,this._pushMonitors(),null!==this.profiler&&(-1===K&&(K=this.profiler.idByName("Sequencer.stepThreads")),this.profiler.start(K)),this.emit(Q.BEFORE_EXECUTE);const t=this.sequencer.stepThreads();null!==this.profiler&&this.profiler.stop(),this.emit(Q.AFTER_EXECUTE),this._updateGlows(t),this._emitProjectRunStatus(this.threads.length+t.length-this._getMonitorThreadCount([...this.threads,...t])),this._lastStepDoneThreads=t,this.renderer&&(null!==this.profiler&&(-1===q&&(q=this.profiler.idByName("RenderWebGL.draw")),this.profiler.start(q)),document.hidden||this.frameLoop._interpolationAnimation||this.renderer.draw(),null!==this.profiler&&this.profiler.stop()),this._refreshTargets&&(this.emit(Q.TARGETS_UPDATE,!1),this._refreshTargets=!1),this._prevMonitorState.equals(this._monitorState)||(this.emit(Q.MONITORS_UPDATE,this._monitorState),this._prevMonitorState=this._monitorState),null!==this.profiler&&(this.profiler.stop(),this.profiler.reportFrames()),this.interpolationEnabled&&(this._lastStepTime=Date.now())}_getMonitorThreadCount(t){let e=0;return t.forEach((t=>{t.updateMonitor&&e++})),e}_pushMonitors(){this.monitorBlocks.runAllMonitored(this)}setEditingTarget(t){const e=this._editingTarget;this._editingTarget=t,this._scriptGlowsPreviousFrame=[],this._updateGlows(),e!==this._editingTarget&&this.requestToolboxExtensionsUpdate()}setCompatibilityMode(t){t?this.setFramerate(30):this.setFramerate(60)}setFramerate(t){t>250&&(t=250),t<0&&(t=1),this.frameLoop.setFramerate(t),this.emit(Q.FRAMERATE_CHANGED,t)}setInterpolation(t){this.interpolationEnabled=t,this.frameLoop.setInterpolation(this.interpolationEnabled),this.emit(Q.INTERPOLATION_CHANGED,t)}setRuntimeOptions(t){this.runtimeOptions=Object.assign({},this.runtimeOptions,t),this.emit(Q.RUNTIME_OPTIONS_CHANGED,this.runtimeOptions),this.renderer&&(this.renderer.offscreenTouching=!this.runtimeOptions.fencing)}setCompilerOptions(t){this.compilerOptions=Object.assign({},this.compilerOptions,t),this.resetAllCaches(),this.emit(Q.COMPILER_OPTIONS_CHANGED,this.compilerOptions)}setStageSize(t,e){if(t=Math.round(Math.max(1,t)),e=Math.round(Math.max(1,e)),this.stageWidth!==t||this.stageHeight!==e){const n=t-this.stageWidth,r=e-this.stageHeight;if(this._monitorState.size>0){const t=n/2,e=r/2;for(const n of this._monitorState.valueSeq()){const r=n.set("x",n.get("x")+t).set("y",n.get("y")+e);this.requestUpdateMonitor(r)}this.emit(Q.MONITORS_UPDATE,this._monitorState)}this.stageWidth=t,this.stageHeight=e,this.renderer&&this.renderer.setStageSize(-t/2,t/2,-e/2,e/2),this.emit(Q.STAGE_SIZE_CHANGED,t,e)}}setInEditor(t){}convertToPackagedRuntime(){if(this.storage)throw new Error("convertToPackagedRuntime must be called before attachStorage");this.isPackaged=!0}resetAllCaches(){for(const t of this.targets)t.isOriginal&&t.blocks.resetCache();this.flyoutBlocks.resetCache(),this.monitorBlocks.resetCache()}addAddonBlock(t){const e=t.procedureCode,n=t.arguments||[],s=n,o=n.map(((t,e)=>"arg".concat(e))),a=n.map((()=>""));if(this.addonBlocks[e]=function(t){for(var e=1;et.id===n));if(!r){const t='';r={id:n,name:T({id:"tw.blocks.addons",default:"Addons",description:"Name of the addon block category in the extension list"}),color1:"#29beb8",color2:"#3aa8a4",color3:"#3aa8a4",menuIconURI:"data:image/svg+xml;,".concat(encodeURIComponent(t)),blocks:[],customFieldTypes:{},menus:[]},this._blockInfo.unshift(r)}r.blocks.push({info:{},xml:'"})}this.resetAllCaches()}getAddonBlock(t){return Object.prototype.hasOwnProperty.call(this.addonBlocks,t)?this.addonBlocks[t]:null}findProjectOptionsComment(){const t=this.getTargetForStage().comments;for(const e of Object.values(t))if(e.text.includes(G))return e;return null}parseProjectOptions(){const t=this.findProjectOptionsComment();if(!t)return;const e=t.text.split("\n").find((t=>t.endsWith(G)));if(!e)return void w.warn("Config comment does not contain valid line");const n=e.substr(0,e.length-14);let r;try{if(r=a.parse(n),!r||"object"!=typeof r)throw new Error("Invalid object")}catch(t){return void w.warn("Config comment has invalid JSON",t)}"number"==typeof r.framerate&&this.setFramerate(r.framerate),r.turbo&&(this.turboMode=!0,this.emit(Q.TURBO_MODE_ON)),r.interpolation&&this.setInterpolation(!0),r.runtimeOptions&&this.setRuntimeOptions(r.runtimeOptions),r.hq&&this.renderer&&this.renderer.setUseHighQualityRender(!0);const i=+r.width||this.stageWidth,s=+r.height||this.stageHeight;i===this.stageWidth&&s===this.stageHeight||this.setStageSize(i,s)}_generateAllProjectOptions(){return{framerate:this.frameLoop.framerate,runtimeOptions:this.runtimeOptions,interpolation:this.interpolationEnabled,turbo:this.turboMode,hq:!!this.renderer&&this.renderer.useHighQualityRender,width:this.stageWidth,height:this.stageHeight}}generateDifferingProjectOptions(){const t=(e,n)=>{const r={};for(const i of Object.keys(n)){const s=n[i],o=e[i];if("object"==typeof s&&s){const e=t(o,s);Object.keys(e).length>0&&(r[i]=e)}else s!==o&&(r[i]=s)}return r};return t(this._defaultStoredSettings,this._generateAllProjectOptions())}storeProjectOptions(){const t=this.generateDifferingProjectOptions(),e="Configuration for https://turbowarp.org/\nYou can move, resize, and minimize this comment, but don't edit it by hand. This comment can be deleted to remove the stored settings.\n".concat(a.stringify(t)).concat(G),n=this.findProjectOptionsComment();if(n)n.text=e;else{this.getTargetForStage().createComment(U(),null,e,50,50,350,170,!1)}this.emitProjectChanged()}precompile(){this.allScriptsDo(((t,e)=>{const n=e.blocks.getBlock(t);if(this.getIsHat(n.opcode)){const n=new v(t);n.target=e,n.blockContainer=e.blocks,n.tryCompile()}}))}enableDebug(){this.resetAllCaches(),this.debug=!0}_updateGlows(t){const e=[];e.push(...this.threads),t&&e.push(...t);const n=[],r=[];for(let t=0;t0&&this.emit(Q.PROJECT_RUN_START),this._nonMonitorThreadCount>0&&0===t&&this.emit(Q.PROJECT_RUN_STOP),this._nonMonitorThreadCount=t}quietGlow(t){const e=this._scriptGlowsPreviousFrame.indexOf(t);e>-1&&this._scriptGlowsPreviousFrame.splice(e,1)}glowBlock(t,e){e?this.emit(Q.BLOCK_GLOW_ON,{id:t}):this.emit(Q.BLOCK_GLOW_OFF,{id:t})}glowScript(t,e){e?this.emit(Q.SCRIPT_GLOW_ON,{id:t}):this.emit(Q.SCRIPT_GLOW_OFF,{id:t})}emitBlockDragUpdate(t){this.emit(Q.BLOCK_DRAG_UPDATE,t)}emitBlockEndDrag(t,e){this.emit(Q.BLOCK_DRAG_END,t,e)}visualReport(t,e,n){t===this.getEditingTarget()&&this.emit(Q.VISUAL_REPORT,{id:e,value:String(n)})}requestAddMonitor(t){const e=t.get("id");this.requestUpdateMonitor(t)||(this._monitorState=this._monitorState.set(e,t))}requestUpdateMonitor(t){const e=t.get("id");return!!this._monitorState.has(e)&&(this._monitorState=this._monitorState.set(e,this._monitorState.get(e).mergeWith(((t,e)=>null==e?t:e),t)),!0)}requestRemoveMonitor(t){this._monitorState=this._monitorState.delete(t)}requestHideMonitor(t){return this.requestUpdateMonitor(new Map([["id",t],["visible",!1]]))}requestShowMonitor(t){return this.requestUpdateMonitor(new Map([["id",t],["visible",!0]]))}requestRemoveMonitorByTargetId(t){this._monitorState=this._monitorState.filterNot((e=>e.targetId===t))}getTargetById(t){for(let e=0;et.id===e));if(!r)return;const i=r.blocks.find((t=>t.info.opcode===n));return i?{category:"extension",label:"".concat(r.name,": ").concat(i.info.text)}:void 0}createNewGlobalVariable(t,e,n){const r="string"==typeof n?n:A.SCALAR_TYPE,i=this.getAllVarNamesOfType(r),s=B.unusedName(t,i),o=new A(e||U(),s,r);return this.getTargetForStage().variables[o.id]=o,o}requestRedraw(){this.redrawRequested=!0}requestTargetsUpdate(t){t.isOriginal&&(this._refreshTargets=!0)}requestBlocksUpdate(){this.emit(Q.BLOCKS_NEED_UPDATE)}requestToolboxExtensionsUpdate(){this.emit(Q.TOOLBOX_EXTENSIONS_NEED_UPDATE)}start(){this.frameLoop.running||(this.frameLoop.start(),this.emit(Q.RUNTIME_STARTED))}stop(){this.quit()}quit(){this.frameLoop.running&&(this.frameLoop.stop(),this.emit(Q.RUNTIME_STOPPED))}enableProfiling(t){p.available()&&(this.profiler=new p(t))}disableProfiling(){this.profiler=null}updateCurrentMSecs(){this.currentMSecs=Date.now()}updatePrivacy(){const t=this.enforcePrivacy&&Object.values(this.externalCommunicationMethods).some((t=>t));this.renderer&&this.renderer.setPrivateSkinAccess&&this.renderer.setPrivateSkinAccess(!t)}setEnforcePrivacy(t){this.enforcePrivacy=t,this.updatePrivacy()}setExternalCommunicationMethod(t,e){if(!Object.prototype.hasOwnProperty.call(this.externalCommunicationMethods,t))throw new Error("Unknown method: ".concat(t));this.externalCommunicationMethods[t]=e,this.updatePrivacy()}emitAssetProgress(){this.emit(Q.ASSET_PROGRESS,this.finishedAssetRequests,this.totalAssetRequests)}resetProgress(){this.finishedAssetRequests=0,this.totalAssetRequests=0,this.emitAssetProgress()}wrapAssetRequest(t){this.totalAssetRequests++,this.emitAssetProgress();return t().then((t=>(this.finishedAssetRequests++,this.emitAssetProgress(),t)),(t=>{throw this.finishedAssetRequests++,this.emitAssetProgress(),t}))}}t.exports=Q},function(t,e,n){const{Record:r}=n(21),i=r({id:null,spriteName:null,targetId:null,opcode:null,value:null,params:null,mode:"default",sliderMin:0,sliderMax:100,isDiscrete:!0,x:null,y:null,width:0,height:0,visible:!0});t.exports=i},function(t,e){t.exports=function(t,e){let n="";for(const t in e){let r=e[t].value;"CURRENTMENU"===t&&(r=r.toLowerCase()),n+="_".concat(r)}return"".concat(t).concat(n)}},function(t,e,n){const r=n(1),i=n(6),s=n(2),o=n(9),a=n(0),{IntermediateScript:c,IntermediateRepresentation:u}=n(65),l=n(187),h="",d="list",p=t=>t.substring(1);class f{constructor(t){this.thread=t,this.target=t.target,this.blocks=t.blockContainer,this.runtime=this.target.runtime,this.stage=this.runtime.getTargetForStage(),this.script=new c,this.script.warpTimer=this.target.runtime.compilerOptions.warpTimer,this.variableCache={},this.usesTimer=!1}setProcedureVariant(t){const e=p(t);this.script.procedureVariant=t,this.script.procedureCode=e,this.script.isProcedure=!0,this.script.yields=!1;const n=this.blocks.getProcedureParamNamesIdsAndDefaults(e);if(null===n)throw new Error("IR: cannot find procedure: ".concat(t));const[r,i,s]=n;this.script.arguments=r}enableWarp(){this.script.isWarp=!0}getBlockById(t){return this.blocks.getBlock(t)||this.blocks.runtime.flyoutBlocks.getBlock(t)}getBlockInfo(t){const[e,n]=i.splitFirst(t,"_");if(!e||!n)return null;const r=this.runtime._blockInfo.find((t=>t.id===e));if(!r)return null;const s=r.blocks.find((t=>t.info.opcode===n));return s||null}descendInputOfBlock(t,e){const n=t.inputs[e];if(!n)return a.warn("IR: ".concat(t.opcode,": missing input ").concat(e),t),{kind:"constant",value:0};const r=n.block,i=this.getBlockById(r);return i?this.descendInput(i):(a.warn("IR: ".concat(t.opcode,": could not find input ").concat(e," with ID ").concat(r)),{kind:"constant",value:0})}descendInput(t){switch(t.opcode){case"colour_picker":return{kind:"constant",value:t.fields.COLOUR.value};case"math_angle":case"math_integer":case"math_number":case"math_positive_number":case"math_whole_number":return{kind:"constant",value:t.fields.NUM.value};case"text":return{kind:"constant",value:t.fields.TEXT.value};case"argument_reporter_string_number":{const e=t.fields.VALUE.value,n=this.script.arguments.lastIndexOf(e);return-1===n&&"last key pressed"===e.toLowerCase()?{kind:"tw.lastKeyPressed"}:-1===n?{kind:"constant",value:0}:{kind:"procedures.argument",index:n}}case"argument_reporter_boolean":{const e=t.fields.VALUE.value,n=this.script.arguments.lastIndexOf(e);return-1===n?"is compiled?"===e.toLowerCase()||"is turbowarp?"===e.toLowerCase()?{kind:"constant",value:!0}:{kind:"constant",value:0}:{kind:"procedures.argument",index:n}}case"control_get_counter":return{kind:"counter.get"};case"data_variable":return{kind:"var.get",variable:this.descendVariable(t,"VARIABLE",h)};case"data_itemoflist":return{kind:"list.get",list:this.descendVariable(t,"LIST",d),index:this.descendInputOfBlock(t,"INDEX")};case"data_lengthoflist":return{kind:"list.length",list:this.descendVariable(t,"LIST",d)};case"data_listcontainsitem":return{kind:"list.contains",list:this.descendVariable(t,"LIST",d),item:this.descendInputOfBlock(t,"ITEM")};case"data_itemnumoflist":return{kind:"list.indexOf",list:this.descendVariable(t,"LIST",d),item:this.descendInputOfBlock(t,"ITEM")};case"data_listcontents":return{kind:"list.contents",list:this.descendVariable(t,"LIST",d)};case"event_broadcast_menu":{const e=t.fields.BROADCAST_OPTION,n=this.target.lookupBroadcastMsg(e.id,e.value);return{kind:"constant",value:n?n.name:""}}case"looks_backdropnumbername":return"number"===t.fields.NUMBER_NAME.value?{kind:"looks.backdropNumber"}:{kind:"looks.backdropName"};case"looks_costumenumbername":return"number"===t.fields.NUMBER_NAME.value?{kind:"looks.costumeNumber"}:{kind:"looks.costumeName"};case"looks_size":return{kind:"looks.size"};case"motion_direction":return{kind:"motion.direction"};case"motion_xposition":return{kind:"motion.x"};case"motion_yposition":return{kind:"motion.y"};case"operator_add":return{kind:"op.add",left:this.descendInputOfBlock(t,"NUM1"),right:this.descendInputOfBlock(t,"NUM2")};case"operator_and":return{kind:"op.and",left:this.descendInputOfBlock(t,"OPERAND1"),right:this.descendInputOfBlock(t,"OPERAND2")};case"operator_contains":return{kind:"op.contains",string:this.descendInputOfBlock(t,"STRING1"),contains:this.descendInputOfBlock(t,"STRING2")};case"operator_divide":return{kind:"op.divide",left:this.descendInputOfBlock(t,"NUM1"),right:this.descendInputOfBlock(t,"NUM2")};case"operator_equals":return{kind:"op.equals",left:this.descendInputOfBlock(t,"OPERAND1"),right:this.descendInputOfBlock(t,"OPERAND2")};case"operator_gt":return{kind:"op.greater",left:this.descendInputOfBlock(t,"OPERAND1"),right:this.descendInputOfBlock(t,"OPERAND2")};case"operator_join":return{kind:"op.join",left:this.descendInputOfBlock(t,"STRING1"),right:this.descendInputOfBlock(t,"STRING2")};case"operator_length":return{kind:"op.length",string:this.descendInputOfBlock(t,"STRING")};case"operator_letter_of":return{kind:"op.letterOf",letter:this.descendInputOfBlock(t,"LETTER"),string:this.descendInputOfBlock(t,"STRING")};case"operator_lt":return{kind:"op.less",left:this.descendInputOfBlock(t,"OPERAND1"),right:this.descendInputOfBlock(t,"OPERAND2")};case"operator_mathop":{const e=this.descendInputOfBlock(t,"NUM");switch(t.fields.OPERATOR.value.toLowerCase()){case"abs":return{kind:"op.abs",value:e};case"floor":return{kind:"op.floor",value:e};case"ceiling":return{kind:"op.ceiling",value:e};case"sqrt":return{kind:"op.sqrt",value:e};case"sin":return{kind:"op.sin",value:e};case"cos":return{kind:"op.cos",value:e};case"tan":return{kind:"op.tan",value:e};case"asin":return{kind:"op.asin",value:e};case"acos":return{kind:"op.acos",value:e};case"atan":return{kind:"op.atan",value:e};case"ln":return{kind:"op.ln",value:e};case"log":return{kind:"op.log",value:e};case"e ^":return{kind:"op.e^",value:e};case"10 ^":return{kind:"op.10^",value:e};default:return{kind:"constant",value:0}}}case"operator_mod":return{kind:"op.mod",left:this.descendInputOfBlock(t,"NUM1"),right:this.descendInputOfBlock(t,"NUM2")};case"operator_multiply":return{kind:"op.multiply",left:this.descendInputOfBlock(t,"NUM1"),right:this.descendInputOfBlock(t,"NUM2")};case"operator_not":return{kind:"op.not",operand:this.descendInputOfBlock(t,"OPERAND")};case"operator_or":return{kind:"op.or",left:this.descendInputOfBlock(t,"OPERAND1"),right:this.descendInputOfBlock(t,"OPERAND2")};case"operator_random":{const e=this.descendInputOfBlock(t,"FROM"),n=this.descendInputOfBlock(t,"TO");if("constant"===e.kind&&"constant"===n.kind){const t=e.value,i=n.value,s=r.toNumber(t),o=r.toNumber(i);return s===o?{kind:"constant",value:s}:r.isInt(t)&&r.isInt(i)?{kind:"op.random",low:s<=o?e:n,high:s<=o?n:e,useInts:!0,useFloats:!1}:{kind:"op.random",low:s<=o?e:n,high:s<=o?n:e,useInts:!1,useFloats:!0}}if("constant"===e.kind){if(!r.isInt(r.toNumber(e.value)))return{kind:"op.random",low:e,high:n,useInts:!1,useFloats:!0}}else if("constant"===n.kind&&!r.isInt(r.toNumber(n.value)))return{kind:"op.random",low:e,high:n,useInts:!1,useFloats:!0};return{kind:"op.random",low:e,high:n,useInts:!1,useFloats:!1}}case"operator_round":return{kind:"op.round",value:this.descendInputOfBlock(t,"NUM")};case"operator_subtract":return{kind:"op.subtract",left:this.descendInputOfBlock(t,"NUM1"),right:this.descendInputOfBlock(t,"NUM2")};case"procedures_call":return this.descendProcedure(t);case"sensing_answer":return{kind:"sensing.answer"};case"sensing_coloristouchingcolor":return{kind:"sensing.colorTouchingColor",target:this.descendInputOfBlock(t,"COLOR2"),mask:this.descendInputOfBlock(t,"COLOR")};case"sensing_current":switch(t.fields.CURRENTMENU.value.toLowerCase()){case"year":return{kind:"sensing.year"};case"month":return{kind:"sensing.month"};case"date":return{kind:"sensing.date"};case"dayofweek":return{kind:"sensing.dayofweek"};case"hour":return{kind:"sensing.hour"};case"minute":return{kind:"sensing.minute"};case"second":return{kind:"sensing.second"}}return{kind:"constant",value:0};case"sensing_dayssince2000":return{kind:"sensing.daysSince2000"};case"sensing_distanceto":return{kind:"sensing.distance",target:this.descendInputOfBlock(t,"DISTANCETOMENU")};case"sensing_keypressed":return{kind:"keyboard.pressed",key:this.descendInputOfBlock(t,"KEY_OPTION")};case"sensing_mousedown":return{kind:"mouse.down"};case"sensing_mousex":return{kind:"mouse.x"};case"sensing_mousey":return{kind:"mouse.y"};case"sensing_of":return{kind:"sensing.of",property:t.fields.PROPERTY.value,object:this.descendInputOfBlock(t,"OBJECT")};case"sensing_timer":return this.usesTimer=!0,{kind:"timer.get"};case"sensing_touchingcolor":return{kind:"sensing.touchingColor",color:this.descendInputOfBlock(t,"COLOR")};case"sensing_touchingobject":return{kind:"sensing.touching",object:this.descendInputOfBlock(t,"TOUCHINGOBJECTMENU")};case"sensing_username":return{kind:"sensing.username"};case"sound_sounds_menu":return{kind:"constant",value:t.fields.SOUND_MENU.value};case"tw_getLastKeyPressed":return{kind:"tw.lastKeyPressed"};default:{if(this.runtime.getOpcodeFunction(t.opcode)){if(l.inputs.includes(t.opcode))return this.descendCompatLayer(t);const e=this.getBlockInfo(t.opcode);if(e){const n=e.info.blockType;if(n===s.REPORTER||n===s.BOOLEAN)return this.descendCompatLayer(t)}}const e=Object.keys(t.inputs),n=Object.keys(t.fields);if(0===e.length&&1===n.length)return{kind:"constant",value:t.fields[n[0]].value};throw a.warn("IR: Unknown input: ".concat(t.opcode),t),new Error("IR: Unknown input: ".concat(t.opcode))}}}descendStackedBlock(t){switch(t.opcode){case"control_all_at_once":return{kind:"control.if",condition:{kind:"constant",value:!0},whenTrue:this.descendSubstack(t,"SUBSTACK"),whenFalse:[]};case"control_clear_counter":return{kind:"counter.clear"};case"control_create_clone_of":return{kind:"control.createClone",target:this.descendInputOfBlock(t,"CLONE_OPTION")};case"control_delete_this_clone":return this.script.yields=!0,{kind:"control.deleteClone"};case"control_forever":return this.analyzeLoop(),{kind:"control.while",condition:{kind:"constant",value:!0},do:this.descendSubstack(t,"SUBSTACK")};case"control_for_each":return this.analyzeLoop(),{kind:"control.for",variable:this.descendVariable(t,"VARIABLE",h),count:this.descendInputOfBlock(t,"VALUE"),do:this.descendSubstack(t,"SUBSTACK")};case"control_if":return{kind:"control.if",condition:this.descendInputOfBlock(t,"CONDITION"),whenTrue:this.descendSubstack(t,"SUBSTACK"),whenFalse:[]};case"control_if_else":return{kind:"control.if",condition:this.descendInputOfBlock(t,"CONDITION"),whenTrue:this.descendSubstack(t,"SUBSTACK"),whenFalse:this.descendSubstack(t,"SUBSTACK2")};case"control_incr_counter":return{kind:"counter.increment"};case"control_repeat":return this.analyzeLoop(),{kind:"control.repeat",times:this.descendInputOfBlock(t,"TIMES"),do:this.descendSubstack(t,"SUBSTACK")};case"control_repeat_until":{this.analyzeLoop(),this.usesTimer=!1;const e=this.descendInputOfBlock(t,"CONDITION"),n=this.usesTimer;return n&&(this.script.yields=!0),{kind:"control.while",condition:{kind:"op.not",operand:e},do:this.descendSubstack(t,"SUBSTACK"),warpTimer:n}}case"control_stop":{const e=t.fields.STOP_OPTION.value;return"all"===e?(this.script.yields=!0,{kind:"control.stopAll"}):"other scripts in sprite"===e||"other scripts in stage"===e?{kind:"control.stopOthers"}:"this script"===e?{kind:"control.stopScript"}:{kind:"noop"}}case"control_wait":return this.script.yields=!0,{kind:"control.wait",seconds:this.descendInputOfBlock(t,"DURATION")};case"control_wait_until":return this.script.yields=!0,{kind:"control.waitUntil",condition:this.descendInputOfBlock(t,"CONDITION")};case"control_while":return this.analyzeLoop(),{kind:"control.while",condition:this.descendInputOfBlock(t,"CONDITION"),do:this.descendSubstack(t,"SUBSTACK"),warpTimer:!1};case"data_addtolist":return{kind:"list.add",list:this.descendVariable(t,"LIST",d),item:this.descendInputOfBlock(t,"ITEM")};case"data_changevariableby":{const e=this.descendVariable(t,"VARIABLE",h);return{kind:"var.set",variable:e,value:{kind:"op.add",left:{kind:"var.get",variable:e},right:this.descendInputOfBlock(t,"VALUE")}}}case"data_deletealloflist":return{kind:"list.deleteAll",list:this.descendVariable(t,"LIST",d)};case"data_deleteoflist":{const e=this.descendInputOfBlock(t,"INDEX");return"constant"===e.kind&&"all"===e.value?{kind:"list.deleteAll",list:this.descendVariable(t,"LIST",d)}:{kind:"list.delete",list:this.descendVariable(t,"LIST",d),index:e}}case"data_hidelist":return{kind:"list.hide",list:this.descendVariable(t,"LIST",d)};case"data_hidevariable":return{kind:"var.hide",variable:this.descendVariable(t,"VARIABLE",h)};case"data_insertatlist":return{kind:"list.insert",list:this.descendVariable(t,"LIST",d),index:this.descendInputOfBlock(t,"INDEX"),item:this.descendInputOfBlock(t,"ITEM")};case"data_replaceitemoflist":return{kind:"list.replace",list:this.descendVariable(t,"LIST",d),index:this.descendInputOfBlock(t,"INDEX"),item:this.descendInputOfBlock(t,"ITEM")};case"data_setvariableto":return{kind:"var.set",variable:this.descendVariable(t,"VARIABLE",h),value:this.descendInputOfBlock(t,"VALUE")};case"data_showlist":return{kind:"list.show",list:this.descendVariable(t,"LIST",d)};case"data_showvariable":return{kind:"var.show",variable:this.descendVariable(t,"VARIABLE",h)};case"event_broadcast":return{kind:"event.broadcast",broadcast:this.descendInputOfBlock(t,"BROADCAST_INPUT")};case"event_broadcastandwait":return this.script.yields=!0,{kind:"event.broadcastAndWait",broadcast:this.descendInputOfBlock(t,"BROADCAST_INPUT")};case"looks_changeeffectby":return{kind:"looks.changeEffect",effect:t.fields.EFFECT.value.toLowerCase(),value:this.descendInputOfBlock(t,"CHANGE")};case"looks_changesizeby":return{kind:"looks.changeSize",size:this.descendInputOfBlock(t,"CHANGE")};case"looks_cleargraphiceffects":return{kind:"looks.clearEffects"};case"looks_goforwardbackwardlayers":return"forward"===t.fields.FORWARD_BACKWARD.value?{kind:"looks.forwardLayers",layers:this.descendInputOfBlock(t,"NUM")}:{kind:"looks.backwardLayers",layers:this.descendInputOfBlock(t,"NUM")};case"looks_gotofrontback":return"front"===t.fields.FRONT_BACK.value?{kind:"looks.goToFront"}:{kind:"looks.goToBack"};case"looks_hide":return{kind:"looks.hide"};case"looks_nextbackdrop":return{kind:"looks.nextBackdrop"};case"looks_nextcostume":return{kind:"looks.nextCostume"};case"looks_seteffectto":return{kind:"looks.setEffect",effect:t.fields.EFFECT.value.toLowerCase(),value:this.descendInputOfBlock(t,"VALUE")};case"looks_setsizeto":return{kind:"looks.setSize",size:this.descendInputOfBlock(t,"SIZE")};case"looks_show":return{kind:"looks.show"};case"looks_switchbackdropto":return{kind:"looks.switchBackdrop",backdrop:this.descendInputOfBlock(t,"BACKDROP")};case"looks_switchcostumeto":return{kind:"looks.switchCostume",costume:this.descendInputOfBlock(t,"COSTUME")};case"motion_changexby":return{kind:"motion.changeX",dx:this.descendInputOfBlock(t,"DX")};case"motion_changeyby":return{kind:"motion.changeY",dy:this.descendInputOfBlock(t,"DY")};case"motion_gotoxy":return{kind:"motion.setXY",x:this.descendInputOfBlock(t,"X"),y:this.descendInputOfBlock(t,"Y")};case"motion_ifonedgebounce":return{kind:"motion.ifOnEdgeBounce"};case"motion_movesteps":return{kind:"motion.step",steps:this.descendInputOfBlock(t,"STEPS")};case"motion_pointindirection":return{kind:"motion.setDirection",direction:this.descendInputOfBlock(t,"DIRECTION")};case"motion_setrotationstyle":return{kind:"motion.setRotationStyle",style:t.fields.STYLE.value};case"motion_setx":return{kind:"motion.setX",x:this.descendInputOfBlock(t,"X")};case"motion_sety":return{kind:"motion.setY",y:this.descendInputOfBlock(t,"Y")};case"motion_turnleft":return{kind:"motion.setDirection",direction:{kind:"op.subtract",left:{kind:"motion.direction"},right:this.descendInputOfBlock(t,"DEGREES")}};case"motion_turnright":return{kind:"motion.setDirection",direction:{kind:"op.add",left:{kind:"motion.direction"},right:this.descendInputOfBlock(t,"DEGREES")}};case"pen_clear":return{kind:"pen.clear"};case"pen_changePenColorParamBy":return{kind:"pen.changeParam",param:this.descendInputOfBlock(t,"COLOR_PARAM"),value:this.descendInputOfBlock(t,"VALUE")};case"pen_changePenHueBy":return{kind:"pen.legacyChangeHue",hue:this.descendInputOfBlock(t,"HUE")};case"pen_changePenShadeBy":return{kind:"pen.legacyChangeShade",shade:this.descendInputOfBlock(t,"SHADE")};case"pen_penDown":return{kind:"pen.down"};case"pen_penUp":return{kind:"pen.up"};case"pen_setPenColorParamTo":return{kind:"pen.setParam",param:this.descendInputOfBlock(t,"COLOR_PARAM"),value:this.descendInputOfBlock(t,"VALUE")};case"pen_setPenColorToColor":return{kind:"pen.setColor",color:this.descendInputOfBlock(t,"COLOR")};case"pen_setPenHueToNumber":return{kind:"pen.legacySetHue",hue:this.descendInputOfBlock(t,"HUE")};case"pen_setPenShadeToNumber":return{kind:"pen.legacySetShade",shade:this.descendInputOfBlock(t,"SHADE")};case"pen_setPenSizeTo":return{kind:"pen.setSize",size:this.descendInputOfBlock(t,"SIZE")};case"pen_changePenSizeBy":return{kind:"pen.changeSize",size:this.descendInputOfBlock(t,"SIZE")};case"pen_stamp":return{kind:"pen.stamp"};case"procedures_call":{const e=t.mutation.proccode;if(t.mutation.return){const e=this.descendVisualReport(t);if(e)return e}return"tw:debugger;"===e?{kind:"tw.debugger"}:this.descendProcedure(t)}case"procedures_return":return{kind:"procedures.return",value:this.descendInputOfBlock(t,"VALUE")};case"sensing_resettimer":return{kind:"timer.reset"};default:{if(this.runtime.getOpcodeFunction(t.opcode)){if(l.stacked.includes(t.opcode))return this.descendCompatLayer(t);const e=this.getBlockInfo(t.opcode);if(e){const n=e.info.blockType;if(n===s.COMMAND||n===s.CONDITIONAL||n===s.LOOP)return this.descendCompatLayer(t)}}const e=this.descendVisualReport(t);if(e)return e;throw a.warn("IR: Unknown stacked block: ".concat(t.opcode),t),new Error("IR: Unknown stacked block: ".concat(t.opcode))}}}descendSubstack(t,e){const n=t.inputs[e];if(!n)return[];const r=n.block;return this.walkStack(r)}walkStack(t){const e=[];let n=t;for(;null!==n;){const t=this.getBlockById(n);if(!t)break;const r=this.descendStackedBlock(t);e.push(r),n=t.next}return e}descendVariable(t,e,n){const r=t.fields[e],i=r.id;if(i&&Object.prototype.hasOwnProperty.call(this.variableCache,i))return this.variableCache[i];const s=this._descendVariable(i,r.value,n);return this.variableCache[s.id]=s,s}_descendVariable(t,e,n){const r=this.target,i=this.stage;if(Object.prototype.hasOwnProperty.call(r.variables,t)){const e=r.variables[t];return{scope:"target",id:e.id,name:e.name,isCloud:e.isCloud}}if(!r.isStage&&i&&Object.prototype.hasOwnProperty.call(i.variables,t)){const e=i.variables[t];return{scope:"stage",id:e.id,name:e.name,isCloud:e.isCloud}}for(const t in r.variables)if(Object.prototype.hasOwnProperty.call(r.variables,t)){const i=r.variables[t];if(i.name===e&&i.type===n)return{scope:"target",id:i.id,name:i.name,isCloud:i.isCloud}}if(!r.isStage&&i)for(const t in i.variables)if(Object.prototype.hasOwnProperty.call(i.variables,t)){const r=i.variables[t];if(r.name===e&&r.type===n)return{scope:"stage",id:r.id,name:r.name,isCloud:r.isCloud}}const s=new o(t,e,n,!1);if(r.variables[t]=s,r.sprite)for(const i of r.sprite.clones)Object.prototype.hasOwnProperty.call(i.variables,t)||(i.variables[t]=new o(t,e,n,!1));return{scope:"target",id:t,name:s.name,isCloud:s.isCloud}}descendProcedure(t){const e=t.mutation.proccode,n=this.blocks.getProcedureParamNamesIdsAndDefaults(e);if(null===n)return{kind:"noop"};const[r,i,s]=n;if(this.runtime.getAddonBlock(e)){this.script.yields=!0;const n={};for(let e=0;e0;){this.compilingProcedures=this.proceduresToCompile,this.proceduresToCompile=new Map;for(const[t,n]of this.compilingProcedures.entries())if(e[t]){const n=e[t];this.procedures[t]=n,this.addProcedureDependencies(n.dependedProcedures)}else{const r="W"===t.charAt(0),i=new f(this.thread);i.setProcedureVariant(t),r&&i.enableWarp();const s=this.generateScriptTree(i,n);this.procedures[t]=s,e[t]=s}}for(;this.analyzeScript(t););const n=new u;return n.entry=t,n.procedures=this.procedures,n}}}},function(t,e,n){const r={Timer:n(13),Cast:n(1),log:n(0),blockUtility:n(189),thread:null};let i="";const s={};i+="let stuckCounter = 0;\nconst isStuck = () => {\n // The real time is not checked on every call for performance.\n stuckCounter++;\n if (stuckCounter === 100) {\n stuckCounter = 0;\n return globalState.thread.target.runtime.sequencer.timer.timeElapsed() > 500;\n }\n return false;\n};",s.startHats="const startHats = (requestedHat, optMatchFields) => {\n const thread = globalState.thread;\n const threads = thread.target.runtime.startHats(requestedHat, optMatchFields);\n return threads;\n}",s.waitThreads="const waitThreads = function*(threads) {\n const thread = globalState.thread;\n const runtime = thread.target.runtime;\n\n while (true) {\n // determine whether any threads are running\n let anyRunning = false;\n for (let i = 0; i < threads.length; i++) {\n if (runtime.threads.indexOf(threads[i]) !== -1) {\n anyRunning = true;\n break;\n }\n }\n if (!anyRunning) {\n // all threads are finished, can resume\n return;\n }\n\n let allWaiting = true;\n for (let i = 0; i < threads.length; i++) {\n if (!runtime.isWaitingThread(threads[i])) {\n allWaiting = false;\n break;\n }\n }\n if (allWaiting) {\n thread.status = 3; // STATUS_YIELD_TICK\n }\n\n yield;\n }\n}",s.executeInCompatibilityLayer="let hasResumedFromPromise = false;\nconst waitPromise = function*(promise) {\n const thread = globalState.thread;\n let returnValue;\n\n // enter STATUS_PROMISE_WAIT and yield\n // this will stop script execution until the promise handlers reset the thread status\n // because promise handlers might execute immediately, configure thread.status here\n thread.status = 1; // STATUS_PROMISE_WAIT\n\n promise\n .then(value => {\n returnValue = value;\n thread.status = 0; // STATUS_RUNNING\n }, error => {\n globalState.log.warn('Promise rejected in compiled script:', error);\n returnValue = '' + error;\n thread.status = 0; // STATUS_RUNNING\n });\n\n yield;\n\n return returnValue;\n};\nconst isPromise = value => (\n // see engine/execute.js\n value !== null &&\n typeof value === 'object' &&\n typeof value.then === 'function'\n);\nconst executeInCompatibilityLayer = function*(inputs, blockFunction, isWarp, useFlags, blockId, branchInfo) {\n const thread = globalState.thread;\n const blockUtility = globalState.blockUtility;\n const stackFrame = branchInfo ? branchInfo.stackFrame : {};\n\n const finish = (returnValue) => {\n if (branchInfo) {\n if (typeof returnValue === 'undefined' && blockUtility._startedBranch) {\n branchInfo.isLoop = blockUtility._startedBranch[1];\n return blockUtility._startedBranch[0];\n }\n branchInfo.isLoop = branchInfo.defaultIsLoop;\n return returnValue;\n }\n return returnValue;\n };\n\n const executeBlock = () => {\n blockUtility.init(thread, blockId, stackFrame);\n return blockFunction(inputs, blockUtility);\n };\n\n let returnValue = executeBlock();\n if (isPromise(returnValue)) {\n returnValue = finish(yield* waitPromise(returnValue));\n if (useFlags) hasResumedFromPromise = true;\n return returnValue;\n }\n\n if (thread.status === 1 /* STATUS_PROMISE_WAIT */ || thread.status === 4 /* STATUS_DONE */) {\n // Something external is forcing us to stop\n yield;\n // Make up a return value because whatever is forcing us to stop can't specify one\n return '';\n }\n\n while (thread.status === 2 /* STATUS_YIELD */ || thread.status === 3 /* STATUS_YIELD_TICK */) {\n // Yielded threads will run next iteration.\n if (thread.status === 2 /* STATUS_YIELD */) {\n thread.status = 0; // STATUS_RUNNING\n // Yield back to the event loop when stuck or not in warp mode.\n if (!isWarp || isStuck()) {\n yield;\n }\n } else {\n // status is STATUS_YIELD_TICK, always yield to the event loop\n yield;\n }\n\n returnValue = executeBlock();\n if (isPromise(returnValue)) {\n returnValue = finish(yield* waitPromise(returnValue));\n if (useFlags) hasResumedFromPromise = true;\n return returnValue;\n }\n\n if (thread.status === 1 /* STATUS_PROMISE_WAIT */ || thread.status === 4 /* STATUS_DONE */) {\n yield;\n return finish('');\n }\n }\n\n return finish(returnValue);\n}",s.createBranchInfo="const createBranchInfo = (isLoop) => ({\n defaultIsLoop: isLoop,\n isLoop: false,\n branch: 0,\n stackFrame: {}\n});",s.retire="const retire = () => {\n const thread = globalState.thread;\n thread.target.runtime.sequencer.retireThread(thread);\n}",s.toBoolean="const toBoolean = value => {\n if (typeof value === 'boolean') {\n return value;\n }\n if (typeof value === 'string') {\n if (value === '' || value === '0' || value.toLowerCase() === 'false') {\n return false;\n }\n return true;\n }\n return !!value;\n}",s.limitPrecision="const limitPrecision = value => {\n const rounded = Math.round(value);\n const delta = value - rounded;\n return (Math.abs(delta) < 1e-9) ? rounded : value;\n}",i+="const isNotActuallyZero = val => {\n if (typeof val !== 'string') return false;\n for (let i = 0; i < val.length; i++) {\n const code = val.charCodeAt(i);\n if (code === 48 || code === 9) {\n return false;\n }\n }\n return true;\n};",i+="const compareEqualSlow = (v1, v2) => {\n const n1 = +v1;\n if (isNaN(n1) || (n1 === 0 && isNotActuallyZero(v1))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();\n const n2 = +v2;\n if (isNaN(n2) || (n2 === 0 && isNotActuallyZero(v2))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();\n return n1 === n2;\n};\nconst compareEqual = (v1, v2) => (typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) && !isNaN(v2) || v1 === v2) ? v1 === v2 : compareEqualSlow(v1, v2);",s.compareGreaterThan="const compareGreaterThanSlow = (v1, v2) => {\n let n1 = +v1;\n let n2 = +v2;\n if (n1 === 0 && isNotActuallyZero(v1)) {\n n1 = NaN;\n } else if (n2 === 0 && isNotActuallyZero(v2)) {\n n2 = NaN;\n }\n if (isNaN(n1) || isNaN(n2)) {\n const s1 = ('' + v1).toLowerCase();\n const s2 = ('' + v2).toLowerCase();\n return s1 > s2;\n }\n return n1 > n2;\n};\nconst compareGreaterThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) ? v1 > v2 : compareGreaterThanSlow(v1, v2)",s.compareLessThan="const compareLessThanSlow = (v1, v2) => {\n let n1 = +v1;\n let n2 = +v2;\n if (n1 === 0 && isNotActuallyZero(v1)) {\n n1 = NaN;\n } else if (n2 === 0 && isNotActuallyZero(v2)) {\n n2 = NaN;\n }\n if (isNaN(n1) || isNaN(n2)) {\n const s1 = ('' + v1).toLowerCase();\n const s2 = ('' + v2).toLowerCase();\n return s1 < s2;\n }\n return n1 < n2;\n};\nconst compareLessThan = (v1, v2) => typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v2) ? v1 < v2 : compareLessThanSlow(v1, v2)",s.randomInt="const randomInt = (low, high) => low + Math.floor(Math.random() * ((high + 1) - low))",s.randomFloat="const randomFloat = (low, high) => (Math.random() * (high - low)) + low",s.timer="const timer = () => {\n const t = new globalState.Timer({\n now: () => globalState.thread.target.runtime.currentMSecs\n });\n t.start();\n return t;\n}",s.daysSince2000="const daysSince2000 = () => (Date.now() - 946684800000) / (24 * 60 * 60 * 1000)",s.distance="const distance = menu => {\n const thread = globalState.thread;\n if (thread.target.isStage) return 10000;\n\n let targetX = 0;\n let targetY = 0;\n if (menu === '_mouse_') {\n targetX = thread.target.runtime.ioDevices.mouse.getScratchX();\n targetY = thread.target.runtime.ioDevices.mouse.getScratchY();\n } else {\n const distTarget = thread.target.runtime.getSpriteTargetByName(menu);\n if (!distTarget) return 10000;\n targetX = distTarget.x;\n targetY = distTarget.y;\n }\n\n const dx = thread.target.x - targetX;\n const dy = thread.target.y - targetY;\n return Math.sqrt((dx * dx) + (dy * dy));\n}",i+="const listIndexSlow = (index, length) => {\n if (index === 'last') {\n return length - 1;\n } else if (index === 'random' || index === 'any') {\n if (length > 0) {\n return (Math.random() * length) | 0;\n }\n return -1;\n }\n index = (+index || 0) | 0;\n if (index < 1 || index > length) {\n return -1;\n }\n return index - 1;\n};\nconst listIndex = (index, length) => {\n if (typeof index !== 'number') {\n return listIndexSlow(index, length);\n }\n index = index | 0;\n return index < 1 || index > length ? -1 : index - 1;\n};",s.listGet="const listGet = (list, idx) => {\n const index = listIndex(idx, list.length);\n if (index === -1) {\n return '';\n }\n return list[index];\n}",s.listReplace="const listReplace = (list, idx, value) => {\n const index = listIndex(idx, list.value.length);\n if (index === -1) {\n return;\n }\n list.value[index] = value;\n list._monitorUpToDate = false;\n}",s.listInsert="const listInsert = (list, idx, value) => {\n const index = listIndex(idx, list.value.length + 1);\n if (index === -1) {\n return;\n }\n list.value.splice(index, 0, value);\n list._monitorUpToDate = false;\n}",s.listDelete="const listDelete = (list, idx) => {\n if (idx === 'all') {\n list.value = [];\n return;\n }\n const index = listIndex(idx, list.value.length);\n if (index === -1) {\n return;\n }\n list.value.splice(index, 1);\n list._monitorUpToDate = false;\n}",s.listContains="const listContains = (list, item) => {\n // TODO: evaluate whether indexOf is worthwhile here\n if (list.value.indexOf(item) !== -1) {\n return true;\n }\n for (let i = 0; i < list.value.length; i++) {\n if (compareEqual(list.value[i], item)) {\n return true;\n }\n }\n return false;\n}",s.listIndexOf="const listIndexOf = (list, item) => {\n for (let i = 0; i < list.value.length; i++) {\n if (compareEqual(list.value[i], item)) {\n return i + 1;\n }\n }\n return 0;\n}",s.listContents="const listContents = list => {\n for (let i = 0; i < list.value.length; i++) {\n const listItem = list.value[i];\n // this is an intentional break from what scratch 3 does to address our automatic string -> number conversions\n // it fixes more than it breaks\n if ((listItem + '').length !== 1) {\n return list.value.join(' ');\n }\n }\n return list.value.join('');\n}",s.colorToList="const colorToList = color => globalState.Cast.toRgbColorList(color)",s.mod="const mod = (n, modulus) => {\n let result = n % modulus;\n if (result / modulus < 0) result += modulus;\n return result;\n}",s.tan="const tan = (angle) => {\n switch (angle % 360) {\n case -270: case 90: return Infinity;\n case -90: case 270: return -Infinity;\n }\n return Math.round(Math.tan((Math.PI * angle) / 180) * 1e10) / 1e10;\n}",s.yieldThenCall="const yieldThenCall = function* (callback, ...args) {\n yield;\n return callback(...args);\n}",s.yieldThenCallGenerator="const yieldThenCallGenerator = function* (callback, ...args) {\n yield;\n return yield* callback(...args);\n}";const o=t=>{r.thread=t,t.generator.next()},a=[];o.scopedEval=t=>{const e=(t=>{let e="let stuckCounter = 0;\nconst isStuck = () => {\n // The real time is not checked on every call for performance.\n stuckCounter++;\n if (stuckCounter === 100) {\n stuckCounter = 0;\n return globalState.thread.target.runtime.sequencer.timer.timeElapsed() > 500;\n }\n return false;\n};const isNotActuallyZero = val => {\n if (typeof val !== 'string') return false;\n for (let i = 0; i < val.length; i++) {\n const code = val.charCodeAt(i);\n if (code === 48 || code === 9) {\n return false;\n }\n }\n return true;\n};const compareEqualSlow = (v1, v2) => {\n const n1 = +v1;\n if (isNaN(n1) || (n1 === 0 && isNotActuallyZero(v1))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();\n const n2 = +v2;\n if (isNaN(n2) || (n2 === 0 && isNotActuallyZero(v2))) return ('' + v1).toLowerCase() === ('' + v2).toLowerCase();\n return n1 === n2;\n};\nconst compareEqual = (v1, v2) => (typeof v1 === 'number' && typeof v2 === 'number' && !isNaN(v1) && !isNaN(v2) || v1 === v2) ? v1 === v2 : compareEqualSlow(v1, v2);const listIndexSlow = (index, length) => {\n if (index === 'last') {\n return length - 1;\n } else if (index === 'random' || index === 'any') {\n if (length > 0) {\n return (Math.random() * length) | 0;\n }\n return -1;\n }\n index = (+index || 0) | 0;\n if (index < 1 || index > length) {\n return -1;\n }\n return index - 1;\n};\nconst listIndex = (index, length) => {\n if (typeof index !== 'number') {\n return listIndexSlow(index, length);\n }\n index = index | 0;\n return index < 1 || index > length ? -1 : index - 1;\n};";for(const n of Object.keys(s))t.includes(n)&&(e+="".concat(s[n],";"));return e+="return ".concat(t),e})(t);try{return new Function("globalState",e)(r)}catch(t){throw r.log.error("was unable to compile script",e),t}},o.runtimeFunctions=s,o.saveGlobalState=()=>{a.push(r.thread)},o.restoreGlobalState=()=>{r.thread=a.pop()},t.exports=o},function(t,e,n){const r=n(67),i=n(63),s=n(0),o=n(22),{Map:a}=n(21),c=n(1),u=new r;let l=-1;const h=function(t,e,n,r,i){const s=r.id,u=r.opcode,l=r._isHat,h=r._isConditional,d=r._isLoop;if(n.pushReportedValue(t),l)if(n.stackClick)n.status=o.STATUS_RUNNING;else if(e.runtime.getIsEdgeActivatedHat(u)){const r=n.target.hasEdgeActivatedValue(s),i=n.target.updateEdgeActivatedValue(s,t);(r?!i&&t:t)?n.status=o.STATUS_RUNNING:e.retireThread(n)}else t?n.status=o.STATUS_RUNNING:e.retireThread(n);else if((h||d)&&void 0!==t)e.stepToBranch(n,c.toNumber(t),d);else{if(i&&void 0!==t&&n.atStackTop()&&(n.stackClick&&e.runtime.visualReport(n.target,s,t),n.updateMonitor)){const n=e.runtime.monitorBlocks.getBlock(s).targetId;if(n&&!e.runtime.getTargetById(n))return;e.runtime.requestUpdateMonitor(a({id:s,spriteName:n?e.runtime.getTargetById(n).getName():null,value:t}))}n.status=o.STATUS_RUNNING}},d=(t,e,n,r,i)=>{if(h(t,e,n,r,i),i&&(!r._isHat||n.stackClick)){let t,e;do{const r=n.popStack();if(null===r)return;if(e=n.target.blocks.getNextBlock(r),null!==e)break;t=n.peekStackFrame()}while(null!==t&&!t.isLoop);n.pushStack(e)}},p=(t,e,n,r,i)=>{n.status===o.STATUS_RUNNING&&(n.status=o.STATUS_PROMISE_WAIT),t.then((t=>{d(t,e,n,r,i)}),(t=>{s.warn("Primitive rejected promise: ",t),d("".concat(t),e,n,r,i)}))};class f{constructor(t,e){this.id=e.id,this.opcode=e.opcode,this.fields=e.fields,this.inputs=e.inputs,this.mutation=e.mutation,this._profiler=null,this._profilerFrame=null,this._isHat=!1,this._blockFunction=null,this._definedBlockFunction=!1,this._isShadowBlock=!1,this._shadowValue=null,this._fields=Object.assign({},this.fields),this._inputs=Object.assign({},this.inputs),this._argValues={mutation:this.mutation},this._parentKey=null,this._parentValues=null,this._ops=[];const{runtime:n}=u.sequencer,{opcode:r,fields:s,inputs:o}=this;this._isHat=n.getIsHat(r),this._blockFunction=n.getOpcodeFunction(r),this._definedBlockFunction=void 0!==this._blockFunction;const a=n._flowing[r];this._isConditional=!(!a||!a.conditional),this._isLoop=!(!a||!a.loop);const c=Object.keys(s);this._isShadowBlock=!this._definedBlockFunction&&1===c.length&&0===Object.keys(o).length,this._shadowValue=this._isShadowBlock&&s[c[0]].value;for(const t in s)this._argValues[t]="VARIABLE"===t||"LIST"===t||"BROADCAST_OPTION"===t?{id:s[t].id,name:s[t].value}:s[t].value;if(delete this._inputs.custom_block,"BROADCAST_INPUT"in this._inputs){this._argValues.BROADCAST_OPTION={id:null,name:null};const e=this._inputs.BROADCAST_INPUT;if(e.block===e.shadow){const n=t.getBlock(e.shadow).fields.BROADCAST_OPTION;this._argValues.BROADCAST_OPTION.id=n.id,this._argValues.BROADCAST_OPTION.name=n.value,delete this._inputs.BROADCAST_INPUT}}for(const e in this._inputs){const n=this._inputs[e];if(n.block){const r=i.getCached(t,n.block,f);if(r._isHat)continue;this._ops.push(...r._ops),r._parentKey=e,r._parentValues=this._argValues,r._isShadowBlock&&(this._argValues[e]=r._shadowValue)}}this._definedBlockFunction&&this._ops.push(this)}}t.exports=function(t,e){const n=t.runtime;u.sequencer=t,u.thread=e;const r=e.peekStack(),s=e.peekStackFrame();let a=e.blockContainer,d=i.getCached(a,r,f);if(null===d&&(a=n.flyoutBlocks,d=i.getCached(a,r,f),null===d))return void t.retireThread(e);const m=d._ops,g=m.length;let b=0;if(null!==s.reported){const t=s.reported;for(;bt.id===e));if(r){const t=r._parentKey,e=r._parentValues;"BROADCAST_INPUT"===t?(e.BROADCAST_OPTION.id=null,e.BROADCAST_OPTION.name=c.toString(n)):e[t]=n}}if(t.length>0){const e=t.reverse().find((t=>m.find((e=>e.id===t.opCached))));b=e?m.findIndex((t=>t.id===e.opCached))+1:0}if(null!==e.justReported&&m[b]&&m[b].id===s.reporting){const t=m[b],n=e.justReported;e.justReported=null;const r=t._parentKey,i=t._parentValues;"BROADCAST_INPUT"===r?(i.BROADCAST_OPTION.id=null,i.BROADCAST_OPTION.name=c.toString(n)):i[r]=n,b+=1}s.reporting=null,s.reported=null,s.waitingReporter=!1}const y=b;for(;b{const e=t._parentKey,n=t._parentValues;return"BROADCAST_INPUT"===e?{opCached:t.id,inputValue:n[e].BROADCAST_OPTION.name}:{opCached:t.id,inputValue:n[e]}}));break}if(e.status===o.STATUS_RUNNING)if(n)h(d,t,e,r,n);else{const t=r._parentKey,e=r._parentValues;"BROADCAST_INPUT"===t?(e.BROADCAST_OPTION.id=null,e.BROADCAST_OPTION.name=c.toString(d)):e[t]=d}else if(e.status===o.STATUS_DONE)break}var v;if(null!==n.profiler){d._profiler!==n.profiler&&function(t,e){e._profiler=t,-1===l&&(l=t.idByName("blockFunction"));const n=e._ops;for(let e=0;et.play(this,e)};return Object.defineProperty(this,"audioPlayer",{configurable:!1,enumerable:!0,writable:!1,value:e}),e}initAudio(){}static get ROTATION_STYLE_ALL_AROUND(){return"all around"}static get ROTATION_STYLE_LEFT_RIGHT(){return"left-right"}static get ROTATION_STYLE_NONE(){return"don't rotate"}static get VIDEO_STATE(){return{OFF:"off",ON:"on",ON_FLIPPED:"on-flipped"}}emitVisualChange(){this.onTargetVisualChange&&this.onTargetVisualChange(this)}setXY(t,e,n){if(this.isStage)return;if(this.dragging&&!n)return;const r=this.x,i=this.y;if(this.renderer){const n=this.runtime.runtimeOptions.fencing?this.renderer.getFencedPositionOfDrawable(this.drawableID,[t,e]):[t,e];this.x=n[0],this.y=n[1],this.renderer.updateDrawablePosition(this.drawableID,n),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())}else this.x=t,this.y=e;this.onTargetMoved&&this.onTargetMoved(this,r,i,n),this.runtime.requestTargetsUpdate(this)}_getRenderedDirectionAndScale(){let t=this.direction,e=[this.size,this.size];if(this.rotationStyle===u.ROTATION_STYLE_NONE)t=90;else if(this.rotationStyle===u.ROTATION_STYLE_LEFT_RIGHT){t=90;e=[(this.direction<0?-1:1)*this.size,this.size]}return{direction:t,scale:e}}setDirection(t){if(!this.isStage&&isFinite(t)){if(this.direction=r.wrapClamp(t,-179,180),this.renderer){const{direction:t,scale:e}=this._getRenderedDirectionAndScale();this.renderer.updateDrawableDirectionScale(this.drawableID,t,e),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())}this.runtime.requestTargetsUpdate(this)}}setDraggable(t){this.isStage||(this.draggable=!!t,this.runtime.requestTargetsUpdate(this))}setVisible(t){this.isStage||(this.visible=!!t,this.renderer&&(this.renderer.updateDrawableVisible(this.drawableID,this.visible),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())),this.runtime.requestTargetsUpdate(this))}setSize(t){if(!this.isStage){if(this.renderer){const e=this.renderer.getCurrentSkinSize(this.drawableID),n=e[0],i=e[1],s=this.runtime.runtimeOptions.fencing,o=s?Math.min(1,Math.max(5/n,5/i)):0,a=s?Math.min(1.5*this.runtime.stageWidth/n,1.5*this.runtime.stageHeight/i):1/0;this.size=100*r.clamp(t/100,o,a);const{direction:c,scale:u}=this._getRenderedDirectionAndScale();this.renderer.updateDrawableDirectionScale(this.drawableID,c,u),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())}else this.size=t;this.runtime.requestTargetsUpdate(this)}}setEffect(t,e){Object.prototype.hasOwnProperty.call(this.effects,t)&&(this.effects[t]=e,this.renderer&&(this.renderer.updateDrawableEffect(this.drawableID,t,e),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())))}clearEffects(){for(const t in this.effects)Object.prototype.hasOwnProperty.call(this.effects,t)&&(this.effects[t]=0);if(this.renderer){for(const t in this.effects)Object.prototype.hasOwnProperty.call(this.effects,t)&&this.renderer.updateDrawableEffect(this.drawableID,t,0);this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())}}setCostume(t){if((t=Math.round(t))!==1/0&&t!==-1/0&&t||(t=0),this.currentCostume=r.wrapClamp(t,0,this.sprite.costumes.length-1),this.renderer){const t=this.sprite.costumes[this.currentCostume];this.renderer.updateDrawableSkinId(this.drawableID,t.skinId),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())}this.runtime.requestTargetsUpdate(this)}addCostume(t,e){"number"!=typeof e||isNaN(e)?this.sprite.addCostumeAt(t,this.sprite.costumes.length):this.sprite.addCostumeAt(t,e)}renameCostume(t,e){const n=this.sprite.costumes.filter(((e,n)=>t!==n)).map((t=>t.name)),r=this.getCostumes()[t].name,s=i.unusedName(e,n);if(this.getCostumes()[t].name=s,this.isStage){const t=this.runtime.targets;for(let e=0;e=e)return null;const n=this.sprite.deleteCostumeAt(t);return t===this.currentCostume&&t===e-1?this.setCostume(t-1):tt.name));t.name=i.unusedName(t.name,n),"number"!=typeof e||isNaN(e)?this.sprite.sounds.push(t):this.sprite.sounds.splice(e,0,t)}renameSound(t,e){const n=this.sprite.sounds.filter(((e,n)=>t!==n)).map((t=>t.name)),r=this.sprite.sounds[t].name,s=i.unusedName(e,n);this.sprite.sounds[t].name=s,this.blocks.updateAssetName(r,s,"sound")}deleteSound(t){if(t<0||t>=this.sprite.sounds.length)return null;const e=this.sprite.sounds.splice(t,1)[0];return this.runtime.requestTargetsUpdate(this),e}setRotationStyle(t){if(t===u.ROTATION_STYLE_NONE?this.rotationStyle=u.ROTATION_STYLE_NONE:t===u.ROTATION_STYLE_ALL_AROUND?this.rotationStyle=u.ROTATION_STYLE_ALL_AROUND:t===u.ROTATION_STYLE_LEFT_RIGHT&&(this.rotationStyle=u.ROTATION_STYLE_LEFT_RIGHT),this.renderer){const{direction:t,scale:e}=this._getRenderedDirectionAndScale();this.renderer.updateDrawableDirectionScale(this.drawableID,t,e),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw())}this.runtime.requestTargetsUpdate(this)}getCostumeIndexByName(t){const e=this.getCostumes();for(let n=0;nt/2||n.top>e/2||n.bottom<-e/2)return!0}return!1}isTouchingSprite(t){t=s.toString(t);const e=this.runtime.getSpriteTargetByName(t);if(!e||!this.renderer)return!1;const n=e.sprite.clones.filter((t=>!t.dragging)).map((t=>t.drawableID));return this.renderer.isTouchingDrawables(this.drawableID,n)}isTouchingColor(t){return!!this.renderer&&this.renderer.isTouchingColor(this.drawableID,t)}colorIsTouchingColor(t,e){return!!this.renderer&&this.renderer.isTouchingColor(this.drawableID,t,e)}getLayerOrder(){return this.renderer?this.renderer.getDrawableOrder(this.drawableID):null}goToFront(){this.renderer&&this.renderer.setDrawableOrder(this.drawableID,1/0,c.SPRITE_LAYER),this.runtime.setExecutablePosition(this,1/0)}goToBack(){this.renderer&&this.renderer.setDrawableOrder(this.drawableID,-1/0,c.SPRITE_LAYER,!1),this.runtime.setExecutablePosition(this,-1/0)}goForwardLayers(t){this.renderer&&this.renderer.setDrawableOrder(this.drawableID,t,c.SPRITE_LAYER,!0),this.runtime.moveExecutable(this,t)}goBackwardLayers(t){this.renderer&&this.renderer.setDrawableOrder(this.drawableID,-t,c.SPRITE_LAYER,!0),this.runtime.moveExecutable(this,-t)}goBehindOther(t){if(this.renderer){const e=this.renderer.setDrawableOrder(t.drawableID,0,c.SPRITE_LAYER,!0);this.renderer.setDrawableOrder(this.drawableID,e,c.SPRITE_LAYER)}const e=this.runtime.executableTargets.indexOf(t);this.runtime.setExecutablePosition(this,e)}keepInFence(t,e,n){let r=n;r||(r={left:-this.runtime.stageWidth/2,right:this.runtime.stageWidth/2,top:this.runtime.stageHeight/2,bottom:-this.runtime.stageHeight/2});const i=this.getBounds();if(!i)return;i.left+=t-this.x,i.right+=t-this.x,i.top+=e-this.y,i.bottom+=e-this.y;let s=0,o=0;return i.leftr.right&&(s+=r.right-i.right),i.top>r.top&&(o+=r.top-i.top),i.bottom{const e=t.createClone();return e.x=400*(Math.random()-.5)/2,e.y=300*(Math.random()-.5)/2,e.direction=this.direction,e.draggable=this.draggable,e.visible=this.visible,e.size=this.size,e.currentCostume=this.currentCostume,e.rotationStyle=this.rotationStyle,e.effects=JSON.parse(JSON.stringify(this.effects)),e.variables=this.duplicateVariables(e.blocks),e.updateAllDrawableProperties(),e}))}onGreenFlag(){this.clearEffects()}onStopAll(){this.clearEffects()}postSpriteInfo(t){const e=Object.prototype.hasOwnProperty.call(t,"force")?t.force:null,n=Object.prototype.hasOwnProperty.call(t,"x"),r=Object.prototype.hasOwnProperty.call(t,"y");(n||r)&&this.setXY(n?t.x:this.x,r?t.y:this.y,e),Object.prototype.hasOwnProperty.call(t,"direction")&&this.setDirection(t.direction),Object.prototype.hasOwnProperty.call(t,"draggable")&&this.setDraggable(t.draggable),Object.prototype.hasOwnProperty.call(t,"rotationStyle")&&this.setRotationStyle(t.rotationStyle),Object.prototype.hasOwnProperty.call(t,"visible")&&this.setVisible(t.visible),Object.prototype.hasOwnProperty.call(t,"size")&&this.setSize(t.size)}startDrag(){this.dragging=!0}stopDrag(){this.dragging=!1}toJSON(){const t=this.getCostumes();return{id:this.id,name:this.getName(),isStage:this.isStage,x:this.x,y:this.y,size:this.size,direction:this.direction,draggable:this.draggable,currentCostume:this.currentCostume,costume:t[this.currentCostume],costumeCount:t.length,visible:this.visible,rotationStyle:this.rotationStyle,comments:this.comments,blocks:this.blocks._blocks,variables:this.variables,costumes:t,sounds:this.getSounds(),textToSpeechLanguage:this.textToSpeechLanguage,tempo:this.tempo,volume:this.volume,videoTransparency:this.videoTransparency,videoState:this.videoState}}dispose(){this.isOriginal||this.runtime.changeCloneCounter(-1),this.runtime.stopForTarget(this),this.runtime.removeExecutable(this),this.sprite.removeClone(this),this.renderer&&null!==this.drawableID&&(this.renderer.destroyDrawable(this.drawableID,this.isStage?c.BACKGROUND_LAYER:c.SPRITE_LAYER),this.visible&&(this.emitVisualChange(),this.runtime.requestRedraw()))}}t.exports=u},function(t,e,n){const r=n(7),i=n(29);class s{constructor(t,e,n,i,o,a,c){this.id=t||r(),this.text=e,this.x=n,this.y=i,this.width=Math.max(Number(o),s.MIN_WIDTH),this.height=Math.max(Number(a),s.MIN_HEIGHT),this.minimized=c||!1,this.blockId=null}toXML(){return'').concat(i(this.text),"")}static get MIN_WIDTH(){return 20}static get MIN_HEIGHT(){return 20}static get DEFAULT_WIDTH(){return 100}static get DEFAULT_HEIGHT(){return 100}}t.exports=s},function(t,e,n){const r=n(45),i=n(15),{loadSoundFromAsset:s}=n(30),{loadCostumeFromAsset:o}=n(31),a=n(79),c=n(6),u=n(12);class l{constructor(t,e){this.runtime=e,t||(t=new i(e)),this.blocks=t,this.name="",this.costumes_=[],this.sounds=[],this.clones=[],this.soundBank=null,this.runtime&&this.runtime.audioEngine&&(this.soundBank=this.runtime.audioEngine.createBank())}set costumes(t){this.costumes_=[];for(const e of t)this.addCostumeAt(e,this.costumes_.length)}get costumes(){return this.costumes_}addCostumeAt(t,e){t.name||(t.name="");const n=this.costumes_.map((t=>t.name));t.name=c.unusedName(t.name,n),this.costumes_.splice(e,0,t)}deleteCostumeAt(t){return this.costumes.splice(t,1)[0]}createClone(t){const e=new r(this,this.runtime);if(e.isOriginal=0===this.clones.length,this.clones.push(e),e.initAudio(),e.isOriginal){const n="string"==typeof t?t:u.SPRITE_LAYER;e.initDrawable(n),this.runtime.fireTargetWasCreated(e)}else this.runtime.fireTargetWasCreated(e,this.clones[0]);return e}removeClone(t){this.runtime.fireTargetWasRemoved(t);const e=this.clones.indexOf(t);e>=0&&this.clones.splice(e,1)}duplicate(){const t=new l(null,this.runtime),e=this.blocks._blocks,n=Object.keys(e).map((t=>e[t])),r=JSON.parse(JSON.stringify(n));a(r),r.forEach((e=>{t.blocks.createBlock(e)}));const i=this.runtime.targets.map((t=>t.sprite.name));t.name=c.unusedName(this.name,i);const u=[];return t.costumes=this.costumes_.map((t=>{const e=Object.assign({},t);return u.push(o(e,this.runtime)),e})),t.sounds=this.sounds.map((e=>{const n=Object.assign({},e),r=e.asset;return u.push(s(n,r,this.runtime,t.soundBank)),n})),Promise.all(u).then((()=>t))}dispose(){this.soundBank&&this.soundBank.dispose()}}t.exports=l},function(t,e,n){t.exports=function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,n){return e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(t,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function r(t,i,s){return r=n()?Reflect.construct:function(t,n,r){var i=[null];i.push.apply(i,n);var s=new(Function.bind.apply(t,i));return r&&e(s,r.prototype),s},r.apply(null,arguments)}function i(t){return s(t)||o(t)||a(t)||u()}function s(t){if(Array.isArray(t))return c(t)}function o(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function a(t,e){if(t){if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n1?n-1:0),i=1;i/gm),Z=g(/\${[\w\W]*}/gm),J=g(/^data-[\-\w.\u00B7-\uFFFF]+$/),_=g(/^aria-[\-\w]+$/),$=g(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),tt=g(/^(?:\w+script|data):/i),et=g(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),nt=g(/^html$/i),rt=g(/^[a-z][.\w]*(-[.\w]+)+$/i),it=function(){return"undefined"==typeof window?null:window},st=function(e,n){if("object"!==t(e)||"function"!=typeof e.createPolicy)return null;var r=null,i="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(i)&&(r=n.currentScript.getAttribute(i));var s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML:function(t){return t},createScriptURL:function(t){return t}})}catch(t){return console.warn("TrustedTypes policy "+s+" could not be created."),null}};function ot(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:it(),n=function(t){return ot(t)};if(n.version="2.5.8",n.removed=[],!e||!e.document||9!==e.document.nodeType)return n.isSupported=!1,n;var r=e.document,s=e.document,o=e.DocumentFragment,a=e.HTMLTemplateElement,c=e.Node,u=e.Element,l=e.NodeFilter,h=e.NamedNodeMap,d=void 0===h?e.NamedNodeMap||e.MozNamedAttrMap:h,p=e.HTMLFormElement,f=e.DOMParser,g=e.trustedTypes,b=u.prototype,y=B(b,"cloneNode"),v=B(b,"nextSibling"),w=B(b,"childNodes"),R=B(b,"parentNode");if("function"==typeof a){var D=s.createElement("template");D.content&&D.content.ownerDocument&&(s=D.content.ownerDocument)}var at=st(g,r),ct=at?at.createHTML(""):"",ut=s,lt=ut.implementation,ht=ut.createNodeIterator,dt=ut.createDocumentFragment,pt=ut.getElementsByTagName,ft=r.importNode,mt={};try{mt=L(s).documentMode?s.documentMode:{}}catch(t){}var gt={};n.isSupported="function"==typeof R&<&&void 0!==lt.createHTMLDocument&&9!==mt;var bt,yt,vt=Q,wt=X,Tt=Z,Et=J,At=_,kt=tt,It=et,St=rt,xt=$,Ot=null,Mt=P({},[].concat(i(U),i(j),i(F),i(V),i(Y))),Nt=null,Ct=P({},[].concat(i(H),i(W),i(K),i(q))),Rt=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Dt=null,Pt=null,Lt=!0,Bt=!0,Ut=!1,jt=!0,Ft=!1,zt=!0,Vt=!1,Gt=!1,Yt=!1,Ht=!1,Wt=!1,Kt=!1,qt=!0,Qt=!1,Xt="user-content-",Zt=!0,Jt=!1,_t={},$t=null,te=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ee=null,ne=P({},["audio","video","img","source","image","track"]),re=null,ie=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),se="http://www.w3.org/1998/Math/MathML",oe="http://www.w3.org/2000/svg",ae="http://www.w3.org/1999/xhtml",ce=ae,ue=!1,le=null,he=P({},[se,oe,ae],I),de=["application/xhtml+xml","text/html"],pe="text/html",fe=null,me=s.createElement("form"),ge=function(t){return t instanceof RegExp||t instanceof Function},be=function(e){fe&&fe===e||(e&&"object"===t(e)||(e={}),e=L(e),bt=bt=-1===de.indexOf(e.PARSER_MEDIA_TYPE)?pe:e.PARSER_MEDIA_TYPE,yt="application/xhtml+xml"===bt?I:k,Ot="ALLOWED_TAGS"in e?P({},e.ALLOWED_TAGS,yt):Mt,Nt="ALLOWED_ATTR"in e?P({},e.ALLOWED_ATTR,yt):Ct,le="ALLOWED_NAMESPACES"in e?P({},e.ALLOWED_NAMESPACES,I):he,re="ADD_URI_SAFE_ATTR"in e?P(L(ie),e.ADD_URI_SAFE_ATTR,yt):ie,ee="ADD_DATA_URI_TAGS"in e?P(L(ne),e.ADD_DATA_URI_TAGS,yt):ne,$t="FORBID_CONTENTS"in e?P({},e.FORBID_CONTENTS,yt):te,Dt="FORBID_TAGS"in e?P({},e.FORBID_TAGS,yt):{},Pt="FORBID_ATTR"in e?P({},e.FORBID_ATTR,yt):{},_t="USE_PROFILES"in e&&e.USE_PROFILES,Lt=!1!==e.ALLOW_ARIA_ATTR,Bt=!1!==e.ALLOW_DATA_ATTR,Ut=e.ALLOW_UNKNOWN_PROTOCOLS||!1,jt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Ft=e.SAFE_FOR_TEMPLATES||!1,zt=!1!==e.SAFE_FOR_XML,Vt=e.WHOLE_DOCUMENT||!1,Ht=e.RETURN_DOM||!1,Wt=e.RETURN_DOM_FRAGMENT||!1,Kt=e.RETURN_TRUSTED_TYPE||!1,Yt=e.FORCE_BODY||!1,qt=!1!==e.SANITIZE_DOM,Qt=e.SANITIZE_NAMED_PROPS||!1,Zt=!1!==e.KEEP_CONTENT,Jt=e.IN_PLACE||!1,xt=e.ALLOWED_URI_REGEXP||xt,ce=e.NAMESPACE||ae,Rt=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&ge(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Rt.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&ge(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Rt.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Rt.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ft&&(Bt=!1),Wt&&(Ht=!0),_t&&(Ot=P({},i(Y)),Nt=[],!0===_t.html&&(P(Ot,U),P(Nt,H)),!0===_t.svg&&(P(Ot,j),P(Nt,W),P(Nt,q)),!0===_t.svgFilters&&(P(Ot,F),P(Nt,W),P(Nt,q)),!0===_t.mathMl&&(P(Ot,V),P(Nt,K),P(Nt,q))),e.ADD_TAGS&&(Ot===Mt&&(Ot=L(Ot)),P(Ot,e.ADD_TAGS,yt)),e.ADD_ATTR&&(Nt===Ct&&(Nt=L(Nt)),P(Nt,e.ADD_ATTR,yt)),e.ADD_URI_SAFE_ATTR&&P(re,e.ADD_URI_SAFE_ATTR,yt),e.FORBID_CONTENTS&&($t===te&&($t=L($t)),P($t,e.FORBID_CONTENTS,yt)),Zt&&(Ot["#text"]=!0),Vt&&P(Ot,["html","head","body"]),Ot.table&&(P(Ot,["tbody"]),delete Dt.tbody),m&&m(e),fe=e)},ye=P({},["mi","mo","mn","ms","mtext"]),ve=P({},["annotation-xml"]),we=P({},["title","style","font","a","script"]),Te=P({},j);P(Te,F),P(Te,z);var Ee=P({},V);P(Ee,G);var Ae=function(t){var e=R(t);e&&e.tagName||(e={namespaceURI:ce,tagName:"template"});var n=k(t.tagName),r=k(e.tagName);return!!le[t.namespaceURI]&&(t.namespaceURI===oe?e.namespaceURI===ae?"svg"===n:e.namespaceURI===se?"svg"===n&&("annotation-xml"===r||ye[r]):Boolean(Te[n]):t.namespaceURI===se?e.namespaceURI===ae?"math"===n:e.namespaceURI===oe?"math"===n&&ve[r]:Boolean(Ee[n]):t.namespaceURI===ae?!(e.namespaceURI===oe&&!ve[r])&&!(e.namespaceURI===se&&!ye[r])&&!Ee[n]&&(we[n]||!Te[n]):!("application/xhtml+xml"!==bt||!le[t.namespaceURI]))},ke=function(t){A(n.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){try{t.outerHTML=ct}catch(e){t.remove()}}},Ie=function(t,e){try{A(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){A(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!Nt[t])if(Ht||Wt)try{ke(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Se=function(t){var e,n;if(Yt)t=""+t;else{var r=S(t,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===bt&&ce===ae&&(t=''+t+"");var i=at?at.createHTML(t):t;if(ce===ae)try{e=(new f).parseFromString(i,bt)}catch(t){}if(!e||!e.documentElement){e=lt.createDocument(ce,"template",null);try{e.documentElement.innerHTML=ue?ct:i}catch(t){}}var o=e.body||e.documentElement;return t&&n&&o.insertBefore(s.createTextNode(n),o.childNodes[0]||null),ce===ae?pt.call(e,Vt?"html":"body")[0]:Vt?e.documentElement:o},xe=function(t){return ht.call(t.ownerDocument||t,t,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null,!1)},Oe=function(t){return t instanceof p&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof d)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Me=function(e){return"object"===t(c)?e instanceof c:e&&"object"===t(e)&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},Ne=function(t,e,r){gt[t]&&T(gt[t],(function(t){t.call(n,e,r,fe)}))},Ce=function(t){var e;if(Ne("beforeSanitizeElements",t,null),Oe(t))return ke(t),!0;if(N(/[\u0080-\uFFFF]/,t.nodeName))return ke(t),!0;var r=yt(t.nodeName);if(Ne("uponSanitizeElement",t,{tagName:r,allowedTags:Ot}),t.hasChildNodes()&&!Me(t.firstElementChild)&&(!Me(t.content)||!Me(t.content.firstElementChild))&&N(/<[/\w]/g,t.innerHTML)&&N(/<[/\w]/g,t.textContent))return ke(t),!0;if("select"===r&&N(/