diff --git a/dist/app.min.js b/dist/app.min.js index 63bfe4580..eecb7ae64 100644 --- a/dist/app.min.js +++ b/dist/app.min.js @@ -7,13 +7,13 @@ a.length?c.pop():{});var e=JSON.stringify(c);if(b[e]){if(b[e].error)throw b[e].e utils.defer=function(){const a={};a.promise=new Promise((b,c)=>{a.resolve=b;a.reject=c});return a};utils.sleep=function(a=0){return new Promise(b=>setTimeout(b,a))};utils.takeWhile=(a,b)=>{const c=[];for(let d=0;d{const b=Math.min(...a.map(d=>d.length)),c=[];for(let d=0;de[d]);return c};utils.partition=(a,b)=>{const c=[[],[]];a.forEach(d=>{const e=b(d)?0:1;c[e].push(d)});return c}; utils.pick=(a,b)=>b.reduce((c,d)=>{c[d]=a[d];return c},{});utils.isNetsBloxDomain=function(a){return!!a.match(/^(?:\w+:\/+)?[^/]*\bnetsblox\.org\b\/?/i)};if("undefined"===typeof Map){var Map=function(){this._content={};this.size=0};Map.prototype.set=function(a,b){this._content.hasOwnProperty(a)||this.size++;this._content[a]=b};Map.prototype.get=function(a){return this._content[a]};Map.prototype.delete=function(a){this._content.hasOwnProperty(a)&&this.size--;delete this._content[a]}} Date.now||(Date.now=function(){return(new Date).getTime()}); -!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b():"function"==typeof define&&define.amd?define(b):b()}(0,function(){function a(){}function b(k){if(!(this instanceof b))throw new TypeError("Promises must be constructed via new");if("function"!=typeof k)throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=void 0;this._deferreds=[];g(k,this)}function c(k,n){for(;3===k._state;)k=k._value;0!==k._state?(k._handled=!0,b._immediateFn(function(){var p=1=== -k._state?n.onFulfilled:n.onRejected;if(null!==p){try{var q=p(k._value)}catch(r){return void e(n.promise,r)}d(n.promise,q)}else(1===k._state?d:e)(n.promise,k._value)})):k._deferreds.push(n)}function d(k,n){try{if(n===k)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var p=n.then;if(n instanceof b)return k._state=3,k._value=n,void f(k);if("function"==typeof p)return void g(function(q,r){return function(){q.apply(r,arguments)}}(p,n), -k)}k._state=1;k._value=n;f(k)}catch(q){e(k,q)}}function e(k,n){k._state=2;k._value=n;f(k)}function f(k){2===k._state&&0===k._deferreds.length&&b._immediateFn(function(){k._handled||b._unhandledRejectionFn(k._value)});for(var n=0,p=k._deferreds.length;p>n;n++)c(k,k._deferreds[n]);k._deferreds=null}function g(k,n){var p=!1;try{k(function(q){p||(p=!0,d(n,q))},function(q){p||(p=!0,e(n,q))})}catch(q){p||(p=!0,e(n,q))}}var h=function(k){var n=this.constructor;return this.then(function(p){return n.resolve(k()).then(function(){return p})}, -function(p){return n.resolve(k()).then(function(){return n.reject(p)})})},m=setTimeout;b.prototype["catch"]=function(k){return this.then(null,k)};b.prototype.then=function(k,n){var p=new this.constructor(a);return c(this,new function(q,r,t){this.onFulfilled="function"==typeof q?q:null;this.onRejected="function"==typeof r?r:null;this.promise=t}(k,n,p)),p};b.prototype["finally"]=h;b.all=function(k){return new b(function(n,p){function q(v,w){try{if(w&&("object"==typeof w||"function"==typeof w)){var y= -w.then;if("function"==typeof y)return void y.call(w,function(x){q(v,x)},p)}r[v]=w;0==--t&&n(r)}catch(x){p(x)}}if(!k||"undefined"==typeof k.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(k);if(0===r.length)return n([]);for(var t=r.length,u=0;r.length>u;u++)q(u,r[u])})};b.resolve=function(k){return k&&"object"==typeof k&&k.constructor===b?k:new b(function(n){n(k)})};b.reject=function(k){return new b(function(n,p){p(k)})};b.race=function(k){return new b(function(n, -p){for(var q=0,r=k.length;r>q;q++)k[q].then(n,p)})};b._immediateFn="function"==typeof setImmediate&&function(k){setImmediate(k)}||function(k){m(k,0)};b._unhandledRejectionFn=function(k){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",k)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object");}();l.Promise?l.Promise.prototype["finally"]|| -(l.Promise.prototype["finally"]=h):l.Promise=b});function ServicesRegistry(a,b){this.cloud=b;this.setServicesHosts(a.servicesHosts)}ServicesRegistry.prototype.reset=function(){this.auxServicesHosts=[]};ServicesRegistry.prototype.onInvalidHosts=function(a){console.error("Invalid services hosts detected:",a)}; +!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b():"function"==typeof define&&define.amd?define(b):b()}(0,function(){function a(){}function b(h){if(!(this instanceof b))throw new TypeError("Promises must be constructed via new");if("function"!=typeof h)throw new TypeError("not a function");this._state=0;this._handled=!1;this._value=void 0;this._deferreds=[];g(h,this)}function c(h,n){for(;3===h._state;)h=h._value;0!==h._state?(h._handled=!0,b._immediateFn(function(){var p=1=== +h._state?n.onFulfilled:n.onRejected;if(null!==p){try{var q=p(h._value)}catch(r){return void e(n.promise,r)}d(n.promise,q)}else(1===h._state?d:e)(n.promise,h._value)})):h._deferreds.push(n)}function d(h,n){try{if(n===h)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var p=n.then;if(n instanceof b)return h._state=3,h._value=n,void f(h);if("function"==typeof p)return void g(function(q,r){return function(){q.apply(r,arguments)}}(p,n), +h)}h._state=1;h._value=n;f(h)}catch(q){e(h,q)}}function e(h,n){h._state=2;h._value=n;f(h)}function f(h){2===h._state&&0===h._deferreds.length&&b._immediateFn(function(){h._handled||b._unhandledRejectionFn(h._value)});for(var n=0,p=h._deferreds.length;p>n;n++)c(h,h._deferreds[n]);h._deferreds=null}function g(h,n){var p=!1;try{h(function(q){p||(p=!0,d(n,q))},function(q){p||(p=!0,e(n,q))})}catch(q){p||(p=!0,e(n,q))}}var k=function(h){var n=this.constructor;return this.then(function(p){return n.resolve(h()).then(function(){return p})}, +function(p){return n.resolve(h()).then(function(){return n.reject(p)})})},m=setTimeout;b.prototype["catch"]=function(h){return this.then(null,h)};b.prototype.then=function(h,n){var p=new this.constructor(a);return c(this,new function(q,r,t){this.onFulfilled="function"==typeof q?q:null;this.onRejected="function"==typeof r?r:null;this.promise=t}(h,n,p)),p};b.prototype["finally"]=k;b.all=function(h){return new b(function(n,p){function q(v,w){try{if(w&&("object"==typeof w||"function"==typeof w)){var y= +w.then;if("function"==typeof y)return void y.call(w,function(x){q(v,x)},p)}r[v]=w;0==--t&&n(r)}catch(x){p(x)}}if(!h||"undefined"==typeof h.length)throw new TypeError("Promise.all accepts an array");var r=Array.prototype.slice.call(h);if(0===r.length)return n([]);for(var t=r.length,u=0;r.length>u;u++)q(u,r[u])})};b.resolve=function(h){return h&&"object"==typeof h&&h.constructor===b?h:new b(function(n){n(h)})};b.reject=function(h){return new b(function(n,p){p(h)})};b.race=function(h){return new b(function(n, +p){for(var q=0,r=h.length;r>q;q++)h[q].then(n,p)})};b._immediateFn="function"==typeof setImmediate&&function(h){setImmediate(h)}||function(h){m(h,0)};b._unhandledRejectionFn=function(h){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",h)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object");}();l.Promise?l.Promise.prototype["finally"]|| +(l.Promise.prototype["finally"]=k):l.Promise=b});function ServicesRegistry(a,b){this.cloud=b;this.setServicesHosts(a.servicesHosts)}ServicesRegistry.prototype.reset=function(){this.auxServicesHosts=[]};ServicesRegistry.prototype.onInvalidHosts=function(a){console.error("Invalid services hosts detected:",a)}; ServicesRegistry.prototype.fetchHosts=function(a){a="/services/hosts/all/"+encodeURIComponent(a);return this.cloud.fetch(a).then(b=>b.json()).then(b=>this.setServicesHosts(b)).catch(b=>{console.error("Unable to fetch hosts: "+b);this.reset()})}; ServicesRegistry.prototype.setServicesHosts=function(a){const b=a.findIndex(c=>{({categories:c}=c);return 0===c.length});-1fetch(d.url).then(e=>e.json()).catch(()=>b.push(d)));Promise.allSettled(c).then(()=>{const d=this.allHosts().map(f=>f.url),e=b.filter(f=>d.includes(f.url));if(e.length)a.onInvalidHosts(e)})};ServicesRegistry.prototype.allHosts=function(){return[this.defaultHost].concat(this.auxServicesHosts)}; @@ -31,11 +31,11 @@ function getMinimumFontHeight(){var a=document.createElement("canvas"),b,c;a.wid function getDocumentPositionOf(a){a=a.getBoundingClientRect();return{x:a.left+(window.pageXOffset||document.documentElement.scrollLeft),y:a.top+(window.pageYOffset||document.documentElement.scrollTop)}} function copy(a){var b;if("object"!==typeof a)return a;var c=a.valueOf();if(a!==c)return new a.constructor(c);if(a instanceof a.constructor&&a.constructor!==Object){c=Object.create(a.constructor.prototype);var d=Object.keys(a);var e=d.length;for(b=0;b{g=f[g];return g.hasOwnProperty("configurable")&&!g.configurable})||(b._isRetinaEnabled=!0,b._bak=f,Object.defineProperty(b,"isRetinaEnabled",{get:function(){return this._isRetinaEnabled},set:function(g){var h=a(this),m=this.width,l=this.height;this._isRetinaEnabled=g;a(this)!= -h&&(this.width=m,this.height=l)},configurable:!0}),Object.defineProperty(b,"width",{get:function(){return f.width.get.call(this)/a(this)},set:function(g){try{var h=a(this);f.width.set.call(this,g*h);this.getContext("2d").scale(h,h)}catch(m){console.log("Retina Display Support Problem",m),f.width.set.call(this,g)}}}),Object.defineProperty(b,"height",{get:function(){return f.height.get.call(this)/a(this)},set:function(g){var h=a(this);f.height.set.call(this,g*h);this.getContext("2d").scale(h,h)}}), -e.drawImage=function(g){var h=a(g);switch(arguments.length){case 9:var m=arguments[1];var l=arguments[2];var k=arguments[3];var n=arguments[4];var p=arguments[5];var q=arguments[6];var r=arguments[7];var t=arguments[8];break;case 5:l=m=0;k=g.width;n=g.height;p=arguments[1];q=arguments[2];r=arguments[3];t=arguments[4];break;case 3:l=m=0;k=g.width;n=g.height;p=arguments[1];q=arguments[2];r=g.width;t=g.height;break;default:throw Error("Called drawImage() with "+arguments.length+" arguments");}f.drawImage.call(this, -g,m*h,l*h,k*h,n*h,p,q,r,t)},e.getImageData=function(g,h,m,l){var k=a(this.canvas);return f.getImageData.call(this,g*k,h*k,m*k,l*k)},Object.defineProperty(e,"shadowOffsetX",{get:function(){return f.shadowOffsetX.get.call(this)/a(this.canvas)},set:function(g){var h=a(this.canvas);f.shadowOffsetX.set.call(this,g*h)}}),Object.defineProperty(e,"shadowOffsetY",{get:function(){return f.shadowOffsetY.get.call(this)/a(this.canvas)},set:function(g){var h=a(this.canvas);f.shadowOffsetY.set.call(this,g*h)}}), -Object.defineProperty(e,"shadowBlur",{get:function(){return f.shadowBlur.get.call(this)/a(this.canvas)},set:function(g){var h=a(this.canvas);f.shadowBlur.set.call(this,g*h)}}))} +"height"),shadowOffsetX:Object.getOwnPropertyDescriptor(e,"shadowOffsetX"),shadowOffsetY:Object.getOwnPropertyDescriptor(e,"shadowOffsetY"),shadowBlur:Object.getOwnPropertyDescriptor(e,"shadowBlur")};c===d||Object.keys(f).some(g=>{g=f[g];return g.hasOwnProperty("configurable")&&!g.configurable})||(b._isRetinaEnabled=!0,b._bak=f,Object.defineProperty(b,"isRetinaEnabled",{get:function(){return this._isRetinaEnabled},set:function(g){var k=a(this),m=this.width,l=this.height;this._isRetinaEnabled=g;a(this)!= +k&&(this.width=m,this.height=l)},configurable:!0}),Object.defineProperty(b,"width",{get:function(){return f.width.get.call(this)/a(this)},set:function(g){try{var k=a(this);f.width.set.call(this,g*k);this.getContext("2d").scale(k,k)}catch(m){console.log("Retina Display Support Problem",m),f.width.set.call(this,g)}}}),Object.defineProperty(b,"height",{get:function(){return f.height.get.call(this)/a(this)},set:function(g){var k=a(this);f.height.set.call(this,g*k);this.getContext("2d").scale(k,k)}}), +e.drawImage=function(g){var k=a(g);switch(arguments.length){case 9:var m=arguments[1];var l=arguments[2];var h=arguments[3];var n=arguments[4];var p=arguments[5];var q=arguments[6];var r=arguments[7];var t=arguments[8];break;case 5:l=m=0;h=g.width;n=g.height;p=arguments[1];q=arguments[2];r=arguments[3];t=arguments[4];break;case 3:l=m=0;h=g.width;n=g.height;p=arguments[1];q=arguments[2];r=g.width;t=g.height;break;default:throw Error("Called drawImage() with "+arguments.length+" arguments");}f.drawImage.call(this, +g,m*k,l*k,h*k,n*k,p,q,r,t)},e.getImageData=function(g,k,m,l){var h=a(this.canvas);return f.getImageData.call(this,g*h,k*h,m*h,l*h)},Object.defineProperty(e,"shadowOffsetX",{get:function(){return f.shadowOffsetX.get.call(this)/a(this.canvas)},set:function(g){var k=a(this.canvas);f.shadowOffsetX.set.call(this,g*k)}}),Object.defineProperty(e,"shadowOffsetY",{get:function(){return f.shadowOffsetY.get.call(this)/a(this.canvas)},set:function(g){var k=a(this.canvas);f.shadowOffsetY.set.call(this,g*k)}}), +Object.defineProperty(e,"shadowBlur",{get:function(){return f.shadowBlur.get.call(this)/a(this.canvas)},set:function(g){var k=a(this.canvas);f.shadowBlur.set.call(this,g*k)}}))} function isRetinaSupported(){var a=document.createElement("canvas").getContext("2d");a=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1;var b=HTMLCanvasElement.prototype,c=CanvasRenderingContext2D.prototype,d={drawImage:c.drawImage,getImageData:c.getImageData,width:Object.getOwnPropertyDescriptor(b,"width"),height:Object.getOwnPropertyDescriptor(b,"height"),shadowOffsetX:Object.getOwnPropertyDescriptor(c, "shadowOffsetX"),shadowOffsetY:Object.getOwnPropertyDescriptor(c,"shadowOffsetY"),shadowBlur:Object.getOwnPropertyDescriptor(c,"shadowBlur")};return a!==window.devicePixelRatio&&!Object.keys(d).some(e=>{e=d[e];return e.hasOwnProperty("configurable")&&!e.configurable})}function isRetinaEnabled(){return HTMLCanvasElement.prototype.hasOwnProperty("_isRetinaEnabled")} function disableRetinaSupport(){if(isRetinaEnabled()){var a=HTMLCanvasElement.prototype;var b=CanvasRenderingContext2D.prototype;var c=a._bak;Object.defineProperty(a,"width",c.width);Object.defineProperty(a,"height",c.height);b.drawImage=c.drawImage;b.getImageData=c.getImageData;Object.defineProperty(b,"shadowOffsetX",c.shadowOffsetX);Object.defineProperty(b,"shadowOffsetY",c.shadowOffsetY);Object.defineProperty(b,"shadowBlur",c.shadowBlur);delete a._isRetinaEnabled;delete a.isRetinaEnabled;delete a._bak}} @@ -47,7 +47,7 @@ Color.prototype.toString=function(){return"rgba("+Math.round(this.r)+","+Math.ro Color.prototype.eq=function(a,b){return a&&this.r===a.r&&this.g===a.g&&this.b===a.b&&(b?this.a===a.a:!0)};Color.prototype.isCloseTo=function(a,b,c){function d(e,f){e-=f;return 0>e?255+e:e}c=2.55*(c||10);return a&&d(this.r,a.r)g&&(g+=1);1g?f:g<2/3?e+(f-e)*(2/3-g)*6:e}0==b?this.b=this.g=this.r=c:(b=.5>c?c*(1+b):c+b-c*b,c=2*c-b,this.r=d(c,b,a+1/3),this.g=d(c,b,a),this.b=d(c,b,a-1/3));this.r*=255;this.g*=255;this.b*=255};Color.prototype.mixed=function(a,b){a=Math.min(Math.max(a,0),1);var c=1-a;return new Color(this.r*a+b.r*c,this.g*a+b.g*c,this.b*a+b.b*c)}; Color.prototype.darker=function(a){var b=.8333;a&&(b=(100-a)/100);return this.mixed(b,new Color(0,0,0))};Color.prototype.lighter=function(a){var b=.8333;a&&(b=(100-a)/100);return this.mixed(b,WHITE)};Color.prototype.dansDarker=function(){var a=this.hsv(),b=new Color;b.set_hsv(a[0],a[1],Math.max(a[2]-.16,0));return b};Color.prototype.inverted=function(){return new Color(255-this.r,255-this.g,255-this.b)};Color.prototype.solid=function(){return new Color(this.r,this.g,this.b)}; function Point(a,b){this.x=a||0;this.y=b||0}Point.prototype.toString=function(){return Math.round(this.x.toString())+"@"+Math.round(this.y.toString())};Point.prototype.copy=function(){return new Point(this.x,this.y)};Point.prototype.eq=function(a){return this.x===a.x&&this.y===a.y};Point.prototype.lt=function(a){return this.xa.x&&this.y>a.y};Point.prototype.ge=function(a){return this.x>=a.x&&this.y>=a.y}; @@ -89,7 +89,7 @@ Morph.prototype.setExtent=function(a){a.eq(this.extent())||(this.changed(),this. Morph.prototype.getImage=function(){if(this.cachedImage&&!this.shouldRerender)return this.cachedImage;var a=newCanvas(this.extent(),!1,this.cachedImage);this.isCachingImage&&(this.cachedImage=a);this.render(a.getContext("2d"));this.shouldRerender=!1;return a};Morph.prototype.render=function(a){a.fillStyle=this.getRenderColor().toString();a.fillRect(0,0,this.width(),this.height());this.cachedTexture?this.renderCachedTexture(a):this.texture&&this.renderTexture(this.texture,a)}; Morph.prototype.getRenderColor=function(){return this.color};Morph.prototype.fixLayout=function(){};Morph.prototype.fixHolesLayout=function(){};Morph.prototype.renderTexture=function(a,b){this.cachedTexture=new Image;this.cachedTexture.onload=()=>this.changed();this.cachedTexture.src=this.texture=a}; Morph.prototype.renderCachedTexture=function(a){var b=this.cachedTexture,c=Math.floor(this.width()/b.width),d=Math.floor(this.height()/b.height),e,f;a.save();a.globalAlpha=this.alpha;a.beginPath();a.rect(0,0,this.width(),this.height());a.clip();for(f=0;f<=d;f+=1)for(e=0;e<=c;e+=1)a.drawImage(b,e*b.width,f*b.height);a.restore()}; -Morph.prototype.drawOn=function(a,b){var c=b.intersect(this.bounds),d=this.position();if(c.extent().gt(ZERO)){a.save();a.globalAlpha=this.alpha;if(this.isCachingImage){b=this.getImage();var e=c.translateBy(d.neg());var f=e.left();var g=e.top();var h=Math.min(e.width(),b.width-f);e=Math.min(e.height(),b.height-g);if(1>h||1>e)return;a.drawImage(b,f,g,h,e,c.left(),c.top(),h,e)}else a.beginPath(),a.rect(c.left(),c.top(),c.width(),c.height()),a.clip(),a.translate(d.x,d.y),this.render(a),MorphicPreferences.showHoles&& +Morph.prototype.drawOn=function(a,b){var c=b.intersect(this.bounds),d=this.position();if(c.extent().gt(ZERO)){a.save();a.globalAlpha=this.alpha;if(this.isCachingImage){b=this.getImage();var e=c.translateBy(d.neg());var f=e.left();var g=e.top();var k=Math.min(e.width(),b.width-f);e=Math.min(e.height(),b.height-g);if(1>k||1>e)return;a.drawImage(b,f,g,k,e,c.left(),c.top(),k,e)}else a.beginPath(),a.rect(c.left(),c.top(),c.width(),c.height()),a.clip(),a.translate(d.x,d.y),this.render(a),MorphicPreferences.showHoles&& (a.translate(-d.x,-d.y),a.globalAlpha=.25,a.fillStyle="white",this.holes.forEach(m=>{m=m.translateBy(d).intersect(c);a.fillRect(m.left(),m.top(),m.width(),m.height())}));a.restore()}};Morph.prototype.fullDrawOn=function(a,b){this.isVisible&&(this.drawOn(a,b),this.children.forEach(c=>c.fullDrawOn(a,b)))};Morph.prototype.hide=function(){this.isVisible=!1;this.changed()};Morph.prototype.show=function(){this.isVisible=!0;this.changed()}; Morph.prototype.toggleVisibility=function(){this.isVisible=!this.isVisible;this.changed()};Morph.prototype.fullImage=function(){var a=this.fullBounds(),b=newCanvas(a.extent()),c=b.getContext("2d");c.translate(-a.origin.x,-a.origin.y);this.fullDrawOn(c,a);return b}; Morph.prototype.shadowImage=function(a,b){var c=a||new Point(7,7);var d=b||new Color(0,0,0);if(this.fullShadowSource){b=this.fullBounds().extent();var e=this.fullImage()}else b=this.extent(),e=this.getImage();a=newCanvas(b);var f=a.getContext("2d");f.drawImage(e,0,0);f.globalCompositeOperation="destination-out";f.drawImage(e,-c.x,-c.y);c=newCanvas(b);f=c.getContext("2d");f.drawImage(a,0,0);f.globalCompositeOperation="source-atop";f.fillStyle=d.toString();f.fillRect(0,0,b.x,b.y);return c}; @@ -109,8 +109,8 @@ Morph.prototype.glideTo=function(a,b,c,d){var e=this.world(),f=new Animation(g=> Morph.prototype.fadeTo=function(a,b,c,d){var e=this.world(),f=this.alpha;this.children.forEach(g=>g.fadeTo(a,b,c));e.animations.push(new Animation(g=>{this.alpha=g;this.changed()},()=>this.alpha,a-this.alpha,b||200,c,()=>{this.alpha=f;d&&d()}))};Morph.prototype.perish=function(a,b){this.fadeTo(0,a||100,null,()=>{this.destroy();b&&b()})};Morph.prototype.nop=nop;Morph.prototype.resize=function(){this.world().activeHandle=new HandleMorph(this)}; Morph.prototype.move=function(){this.world().activeHandle=new HandleMorph(this,null,null,null,null,"move")};Morph.prototype.moveCenter=function(){this.world().activeHandle=new HandleMorph(this,null,null,null,null,"moveCenter")};Morph.prototype.hint=function(a){var b;(b=a)?a.toString&&(b=a.toString()):b="NULL";a=new MenuMorph(this,b);a.isDraggable=!0;a.popUpCenteredAtHand(this.world())}; Morph.prototype.inform=function(a){var b;(b=a)?a.toString&&(b=a.toString()):b="NULL";a=new MenuMorph(this,b);a.addItem("Ok");a.isDraggable=!0;a.popUpCenteredAtHand(this.world())}; -Morph.prototype.prompt=function(a,b,c,d,e,f,g,h,m=nop){var l;g&&(l=!0);a=new MenuMorph(b||null,a||"",c||null);var k=new StringFieldMorph(d||"",e||100,MorphicPreferences.prompterFontSize,MorphicPreferences.prompterFontName,!1,!1,l);a.items.push(k);if(g||MorphicPreferences.useSliderForInput)e=new SliderMorph(f||0,g,parseFloat(d),Math.floor((g-f)/4),"horizontal"),e.alpha=1,e.color=new Color(225,225,225),e.button.color=a.borderColor,e.button.highlightColor=e.button.color.copy(),e.button.highlightColor.b+= -100,e.button.pressColor=e.button.color.copy(),e.button.pressColor.b+=150,e.setHeight(MorphicPreferences.prompterSliderSize),e.action=h?n=>{k.changed();k.text.text=Math.round(n).toString();k.text.fixLayout();k.text.changed();k.text.edit();m(Math.round(n))}:n=>{k.changed();k.text.text=n.toString();k.text.fixLayout();k.text.changed();m(n)},a.items.push(e);a.addLine(2);a.addItem("Ok",()=>k.string());a.addItem("Cancel",()=>{m(d);return null});a.isDraggable=!0;a.popUpAtHand(this.world());k.text.edit()}; +Morph.prototype.prompt=function(a,b,c,d,e,f,g,k,m=nop){var l;g&&(l=!0);a=new MenuMorph(b||null,a||"",c||null);var h=new StringFieldMorph(d||"",e||100,MorphicPreferences.prompterFontSize,MorphicPreferences.prompterFontName,!1,!1,l);a.items.push(h);if(g||MorphicPreferences.useSliderForInput)e=new SliderMorph(f||0,g,parseFloat(d),Math.floor((g-f)/4),"horizontal"),e.alpha=1,e.color=new Color(225,225,225),e.button.color=a.borderColor,e.button.highlightColor=e.button.color.copy(),e.button.highlightColor.b+= +100,e.button.pressColor=e.button.color.copy(),e.button.pressColor.b+=150,e.setHeight(MorphicPreferences.prompterSliderSize),e.action=k?n=>{h.changed();h.text.text=Math.round(n).toString();h.text.fixLayout();h.text.changed();h.text.edit();m(Math.round(n))}:n=>{h.changed();h.text.text=n.toString();h.text.fixLayout();h.text.changed();m(n)},a.items.push(e);a.addLine(2);a.addItem("Ok",()=>h.string());a.addItem("Cancel",()=>{m(d);return null});a.isDraggable=!0;a.popUpAtHand(this.world());h.text.edit()}; Morph.prototype.pickColor=function(a,b,c,d){a=new MenuMorph(b||null,a||"",c||null);var e=new ColorPickerMorph(d);a.items.push(e);a.addLine(2);a.addItem("Ok",()=>e.getChoice());a.addItem("Cancel",()=>null);a.isDraggable=!0;a.popUpAtHand(this.world())};Morph.prototype.inspect=function(a){var b=this.world instanceof Function?this.world():this.root()||this.world,c=this;a&&(c=a);a=new InspectorMorph(c);a.setPosition(b.hand.position());a.keepWithin(b);b.add(a);a.changed()}; Morph.prototype.inspectKeyEvent=function(a){this.inform("Key pressed: "+String.fromCharCode(a.charCode)+"\n------------------------\ncharCode: "+a.charCode.toString()+"\nkeyCode: "+a.keyCode.toString()+"\nkey: "+a.key.toString()+"\nshiftKey: "+a.shiftKey.toString()+"\naltKey: "+a.altKey.toString()+"\nctrlKey: "+a.ctrlKey.toString()+"\ncmdKey: "+a.metaKey.toString())}; Morph.prototype.contextMenu=function(){var a;return this.customContextMenu?this.customContextMenu:(a=this.world instanceof Function?this.world():this.world)&&a.isDevMode?this.parent===a?this.developersMenu():this.hierarchyMenu():this.userMenu()||this.parent&&this.parent.userMenu()}; @@ -128,8 +128,8 @@ HandleMorph.prototype.init=function(a,b,c,d,e,f){var g=MorphicPreferences.handle HandleMorph.prototype.fixLayout=function(){this.target&&("moveCenter"===this.type?this.setCenter(this.target.center()):"movePivot"===this.type?this.setCenter(this.target.rotationCenter()):this.setPosition(this.target.bottomRight().subtract(this.extent().add(this.inset))),this.target.add(this),this.target.changed())}; HandleMorph.prototype.render=function(a){"movePivot"===this.type?this.isHighlighted?this.renderCrosshairsOn(a,.5):this.renderCrosshairsOn(a,.6):this.isHighlighted?this.renderHandleOn(a,new Color(100,100,255),WHITE):this.renderHandleOn(a,this.color,new Color(100,100,100))}; HandleMorph.prototype.renderCrosshairsOn=function(a,b){var c=this.width()/2;a.fillStyle="rgba(255, 255, 255, 0.5)";a.beginPath();a.arc(c,c,.9*c,radians(0),radians(360),!1);a.fill();a.strokeStyle="black";a.lineWidth=1;a.beginPath();a.arc(c,c,c*b,radians(0),radians(360),!1);a.stroke();a.moveTo(0,c);a.lineTo(this.width(),c);a.stroke();a.moveTo(c,0);a.lineTo(c,this.height());a.stroke()}; -HandleMorph.prototype.renderHandleOn=function(a,b,c){var d=0===this.type.indexOf("move"),e=new Point(0,this.height()),f=new Point(this.width(),0),g;a.lineWidth=1;a.lineCap="round";a.strokeStyle=b.toString();if(d){b=e.copy();var h=f.copy();for(g=0;g<=this.height();g+=6)b.y=e.y-g,h.y=f.y-g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke()}b=e.copy();h=f.copy();for(g=0;g<=this.width();g+=6)b.x=e.x+g,h.x=f.x+g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke(); -a.strokeStyle=c.toString();if(d)for(b=e.copy(),h=f.copy(),g=-2;g<=this.height();g+=6)b.y=e.y-g,h.y=f.y-g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke();b=e.copy();h=f.copy();for(g=2;g<=this.width();g+=6)b.x=e.x+g,h.x=f.x+g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(h.x,h.y),a.closePath(),a.stroke()};HandleMorph.prototype.step=null; +HandleMorph.prototype.renderHandleOn=function(a,b,c){var d=0===this.type.indexOf("move"),e=new Point(0,this.height()),f=new Point(this.width(),0),g;a.lineWidth=1;a.lineCap="round";a.strokeStyle=b.toString();if(d){b=e.copy();var k=f.copy();for(g=0;g<=this.height();g+=6)b.y=e.y-g,k.y=f.y-g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(k.x,k.y),a.closePath(),a.stroke()}b=e.copy();k=f.copy();for(g=0;g<=this.width();g+=6)b.x=e.x+g,k.x=f.x+g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(k.x,k.y),a.closePath(),a.stroke(); +a.strokeStyle=c.toString();if(d)for(b=e.copy(),k=f.copy(),g=-2;g<=this.height();g+=6)b.y=e.y-g,k.y=f.y-g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(k.x,k.y),a.closePath(),a.stroke();b=e.copy();k=f.copy();for(g=2;g<=this.width();g+=6)b.x=e.x+g,k.x=f.x+g,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(k.x,k.y),a.closePath(),a.stroke()};HandleMorph.prototype.step=null; HandleMorph.prototype.mouseDownLeft=function(a){var b=this.root();if(!this.target)return null;var c=0===this.type.indexOf("move")?a.subtract(this.center()):a.subtract(this.bounds.origin);this.step=()=>{if(b.hand.mouseButton){var d=b.hand.bounds.origin.copy().subtract(c);"resize"===this.type?(d=d.add(this.extent().add(this.inset)).subtract(this.target.bounds.origin),d=d.max(this.minExtent),this.target.setExtent(d),this.setPosition(this.target.bottomRight().subtract(this.extent().add(this.inset)))): "moveCenter"===this.type?this.target.setCenter(d):"movePivot"===this.type?(this.target.setPivot(d),this.setCenter(this.target.rotationCenter())):this.target.setPosition(d.subtract(this.target.extent()).add(this.extent()))}else this.step=null};this.target.step||(this.target.step=nop)};HandleMorph.prototype.rootForGrab=function(){return this};HandleMorph.prototype.mouseEnter=function(){this.isHighlighted=!0;this.changed()};HandleMorph.prototype.mouseLeave=function(){this.isHighlighted=!1;this.changed()}; HandleMorph.prototype.attach=function(){var a=this.overlappedMorphs(),b=new MenuMorph(this,"choose target:");a.forEach(c=>{b.addItem(c.toString().slice(0,50),()=>{this.isDraggable=!1;this.target=c;this.fixLayout()})});0=m||0===g&&"-"===m||"."===m&&0===e)f+=m,"."===m&&(e+=1)}d=f}else d=c.value;d.length=m||0===g&&"-"===m||"."===m&&0===e)f+=m,"."===m&&(e+=1)}d=f}else d=c.value;d.lengtha?0:a>b?b:a;this.parent&&this.target.isScrollable&&(a=this.parent.right()-this.viewPadding,b=this.parent.left()+this.viewPadding,c.x>a&&(this.target.setLeft(this.target.left()+a-c.x),c.x=a),c.x{this.prompt(a.title+"\nborder\nwidth:",this.setBorderWidth,this,this.border.toString(),null,0,100,!0)},"set the border's\nline size");a.addItem("border color...",()=>{this.pickColor(a.title+"\nborder color:",this.setBorderColor,this,this.borderColor)},"set the border's\nline color");a.addItem("corner size...",()=>{this.prompt(a.title+"\ncorner\nsize:",this.setCornerSize, this,this.edge.toString(),null,0,100,!0)},"set the corner's\nradius");return a};BoxMorph.prototype.setBorderWidth=function(a){"number"===typeof a?this.border=Math.max(a,0):(a=parseFloat(a),isNaN(a)||(this.border=Math.max(a,0)));this.changed()};BoxMorph.prototype.setBorderColor=function(a){a&&(this.borderColor=a,this.changed())};BoxMorph.prototype.setCornerSize=function(a){"number"===typeof a?this.edge=Math.max(a,0):(a=parseFloat(a),isNaN(a)||(this.edge=Math.max(a,0)));this.changed()}; -BoxMorph.prototype.colorSetters=function(){return["color","borderColor"]};BoxMorph.prototype.numericalSetters=function(){var a=BoxMorph.uber.numericalSetters.call(this);a.push("setBorderWidth","setCornerSize");return a};SpeechBubbleMorph.prototype=new BoxMorph;SpeechBubbleMorph.prototype.constructor=SpeechBubbleMorph;SpeechBubbleMorph.uber=BoxMorph.prototype;function SpeechBubbleMorph(a,b,c,d,e,f,g,h){this.init(a,b,c,d,e,f,g,h)} -SpeechBubbleMorph.prototype.init=function(a,b,c,d,e,f,g,h){this.isPointingRight=!0;this.contents=a||"";this.padding=f||0;this.isThought=g||!1;this.isClickable=!1;SpeechBubbleMorph.uber.init.call(this,c||6,d||(0===d?0:1),e||new Color(140,140,140));this.hasShadow=!0!==h;this.noDropShadow=!0;this.fullShadowSource=!1;this.color=b||new Color(230,230,230);this.fixLayout()}; +BoxMorph.prototype.colorSetters=function(){return["color","borderColor"]};BoxMorph.prototype.numericalSetters=function(){var a=BoxMorph.uber.numericalSetters.call(this);a.push("setBorderWidth","setCornerSize");return a};SpeechBubbleMorph.prototype=new BoxMorph;SpeechBubbleMorph.prototype.constructor=SpeechBubbleMorph;SpeechBubbleMorph.uber=BoxMorph.prototype;function SpeechBubbleMorph(a,b,c,d,e,f,g,k){this.init(a,b,c,d,e,f,g,k)} +SpeechBubbleMorph.prototype.init=function(a,b,c,d,e,f,g,k){this.isPointingRight=!0;this.contents=a||"";this.padding=f||0;this.isThought=g||!1;this.isClickable=!1;SpeechBubbleMorph.uber.init.call(this,c||6,d||(0===d?0:1),e||new Color(140,140,140));this.hasShadow=!0!==k;this.noDropShadow=!0;this.fullShadowSource=!1;this.color=b||new Color(230,230,230);this.fixLayout()}; SpeechBubbleMorph.prototype.popUp=function(a,b,c){this.fixLayout();this.setPosition(b.subtract(new Point(0,this.height())));this.keepWithin(a);a.add(this);this.fullChanged();a.hand.destroyTemporaries();a.hand.temporaries.push(this);c?this.isClickable=!0:this.mouseEnter=this.destroy}; SpeechBubbleMorph.prototype.fixLayout=function(){this.contentsMorph&&this.contentsMorph.destroy();this.contents instanceof Morph?this.contentsMorph=this.contents:isString(this.contents)?this.contentsMorph=new TextMorph(this.contents,MorphicPreferences.bubbleHelpFontSize,null,!1,!0,"center"):this.contents instanceof HTMLCanvasElement?(this.contentsMorph=new Morph,this.contentsMorph.setExtent(new Point(this.contents.width,this.contents.height)),this.contentsMorph.cachedImage=this.contents):this.contentsMorph= new TextMorph(this.contents.toString(),MorphicPreferences.bubbleHelpFontSize,null,!1,!0,"center");this.add(this.contentsMorph);this.bounds.setExtent(new Point(this.contentsMorph.width()+(this.padding?2*this.padding:2*this.edge),this.contentsMorph.height()+this.edge+2*this.border+2*this.padding+2));this.contentsMorph.setPosition(this.position().add(new Point(this.padding||this.edge,this.border+this.padding+1)));this.hasShadow&&(this.removeShadow(),this.addShadow(new Point(2,2),80))}; -SpeechBubbleMorph.prototype.outlinePath=function(a,b,c){function d(h,m,l){a.moveTo(h+l,m);a.arc(h,m,l,radians(0),radians(360))}var e=b+c,f=this.width(),g=this.height();a.arc(e,e,b,radians(-180),radians(-90),!1);a.arc(f-e,e,b,radians(-90),radians(-0),!1);a.arc(f-e,g-e-b,b,radians(0),radians(90),!1);this.isThought||(this.isPointingRight?(a.lineTo(e+b,g-e),a.lineTo(b/2+c,g-c)):(a.lineTo(f-(b/2+c),g-c),a.lineTo(f-(e+b),g-e)));a.arc(e,g-e-b,b,radians(90),radians(180),!1);!0===this.isThought&&(a.lineTo(c, +SpeechBubbleMorph.prototype.outlinePath=function(a,b,c){function d(k,m,l){a.moveTo(k+l,m);a.arc(k,m,l,radians(0),radians(360))}var e=b+c,f=this.width(),g=this.height();a.arc(e,e,b,radians(-180),radians(-90),!1);a.arc(f-e,e,b,radians(-90),radians(-0),!1);a.arc(f-e,g-e-b,b,radians(0),radians(90),!1);this.isThought||(this.isPointingRight?(a.lineTo(e+b,g-e),a.lineTo(b/2+c,g-c)):(a.lineTo(f-(b/2+c),g-c),a.lineTo(f-(e+b),g-e)));a.arc(e,g-e-b,b,radians(90),radians(180),!1);!0===this.isThought&&(a.lineTo(c, e),this.isPointingRight?(e=b/4,d(e+c,g-e-c,e),e=b/3.2,d(2*e+c,g-e-2*c,e),e=b/2.8,d(3*e+2*c,g-e-4*c,e)):(e=b/4,d(f-(e+c),g-e-c,e),e=b/3.2,d(f-(2*e+c),g-e-2*c,e),e=b/2.8,d(f-(3*e+2*c),g-e-4*c,e)))}; SpeechBubbleMorph.prototype.shadowImage=function(a,b){var c=a||new Point(7,7);var d=b||new Color(0,0,0);b=this.extent();var e=this.getImage();a=newCanvas(b);var f=a.getContext("2d");f.drawImage(e,0,0);f.globalCompositeOperation="destination-out";f.drawImage(e,-c.x,-c.y);c=newCanvas(b);f=c.getContext("2d");f.drawImage(a,0,0);f.globalCompositeOperation="source-atop";f.fillStyle=d.toString();f.fillRect(0,0,b.x,b.y);return c}; SpeechBubbleMorph.prototype.shadowImageBlurred=function(a,b){a=a||new Point(7,7);var c=this.shadowBlur,d=b||new Color(0,0,0);var e=this.extent().add(2*c);b=this.getImage();e=newCanvas(e);var f=e.getContext("2d");f.shadowOffsetX=a.x;f.shadowOffsetY=a.y;f.shadowBlur=c;f.shadowColor=d.toString();f.drawImage(b,c-a.x,c-a.y);f.shadowOffsetX=0;f.shadowOffsetY=0;f.shadowBlur=0;f.globalCompositeOperation="destination-out";f.drawImage(b,c-a.x,c-a.y);return e};DialMorph.prototype=new Morph; DialMorph.prototype.constructor=DialMorph;DialMorph.uber=Morph.prototype;function DialMorph(a,b,c,d,e){this.init(a,b,c,d,e)}DialMorph.prototype.init=function(a,b,c,d,e){this.action=this.target=null;this.min=a||0;this.max=b||360;this.value=Math.max(this.min,(c||0)%this.max);this.tick=d||15;this.fillColor=null;DialMorph.uber.init.call(this);this.color=new Color(230,230,230);this.setRadius(e||4*MorphicPreferences.menuFontSize)}; DialMorph.prototype.setRadius=function(a){this.radius=a;this.setExtent(new Point(2*this.radius,2*this.radius))};DialMorph.prototype.setValue=function(a,b,c){var d=this.max-this.min;this.value=this.min+(+(a||0)%d+d)%d;b&&(this.value=this.valueMath.abs(d)?0>a?90:270:Math.round((0<=d?0:180)-57.2957795131*Math.atan(a/d)))+90)/360*b+this.min};DialMorph.prototype.setExtent=function(a){a=Math.min(a.x,a.y);this.radius=a/2;DialMorph.uber.setExtent.call(this,new Point(a,a))}; -DialMorph.prototype.render=function(a){var b,c=this.color.lighter().toString(),d=this.max-this.min,e=d/this.tick,f=.75*this.radius,g=.85*f,h=.95*f;a.fillStyle=c;a.beginPath();a.arc(this.radius,this.radius,f+Math.min(1,this.radius-f),0,2*Math.PI,!1);a.closePath();a.fill();a.fillStyle=this.color.toString();a.beginPath();a.arc(this.radius,this.radius,f,0,2*Math.PI,!1);a.closePath();a.fill();var m=2*(this.value-this.min)*Math.PI/d-Math.PI/2;a.fillStyle=(this.fillColor||this.color.darker()).toString(); -a.beginPath();a.arc(this.radius,this.radius,f,Math.PI/-2,m,!1);a.lineTo(this.radius,this.radius);a.closePath();a.fill();a.strokeStyle=(new Color(35,35,35)).toString();a.lineWidth=1;for(b=0;b{b.hand.mouseButton?this.setValue(this.getValueOf(b.hand.bounds.origin),16!==b.currentKey):this.step=null}}; DialMorph.prototype.developersMenu=function(){var a=DialMorph.uber.developersMenu.call(this);a.addLine();a.addItem("set target","setTarget","select another morph\nwhose numerical property\nwill be controlled by this one");return a}; DialMorph.prototype.setTarget=function(){var a=this.overlappedMorphs(),b=new MenuMorph(this,"choose target:");a.push(this.world());a.forEach(c=>{b.addItem(c.toString().slice(0,50),()=>{this.target=c;this.setTargetSetter()})});1===a.length?(this.target=a[0],this.setTargetSetter()):0{a&&(this.target[a]=null,this.buildPanes(),this.target.changed())},this,"property")}; InspectorMorph.prototype.renameProperty=function(){var a=this.list.selected;this.prompt("property name:",b=>{try{delete this.target[a],this.target[b]=this.currentProperty}catch(c){this.inform(c)}this.buildPanes();this.target.changed()},this,a)};InspectorMorph.prototype.removeProperty=function(){var a=this.list.selected;try{delete this.target[a],this.currentProperty=null,this.buildPanes(),this.target.changed()}catch(b){this.inform(b)}}; InspectorMorph.prototype.step=function(){this.updateCurrentSelection();var a=this.target.toString();this.label.text!==a&&(this.label.text=a,this.fixLayout())};InspectorMorph.prototype.updateReferences=function(a){var b=this.list.activeIndex();InspectorMorph.uber.updateReferences.call(this,a);this.buildPanes();this.list.activateIndex(b)};MenuMorph.prototype=new BoxMorph;MenuMorph.prototype.constructor=MenuMorph;MenuMorph.uber=BoxMorph.prototype;function MenuMorph(a,b,c,d){this.init(a,b,c,d)} -MenuMorph.prototype.init=function(a,b,c,d){this.target=a;this.title=b||null;this.environment=c||null;this.fontSize=d||null;this.items=[];this.world=this.label=null;this.hasFocus=this.isListContents=!1;this.submenu=this.selection=null;MenuMorph.uber.init.call(this);this.isDraggable=!1;this.noDropShadow=!0;this.fullShadowSource=!1;this.edge=this.border=null};MenuMorph.prototype.addItem=function(a,b,c,d,e,f,g,h,m){this.items.push([m?a||"close":localize(a||"close"),b||nop,c,d,e||!1,f||!1,g,h,m])}; +MenuMorph.prototype.init=function(a,b,c,d){this.target=a;this.title=b||null;this.environment=c||null;this.fontSize=d||null;this.items=[];this.world=this.label=null;this.hasFocus=this.isListContents=!1;this.submenu=this.selection=null;MenuMorph.uber.init.call(this);this.isDraggable=!1;this.noDropShadow=!0;this.fullShadowSource=!1;this.edge=this.border=null};MenuMorph.prototype.addItem=function(a,b,c,d,e,f,g,k,m){this.items.push([m?a||"close":localize(a||"close"),b||nop,c,d,e||!1,f||!1,g,k,m])}; MenuMorph.prototype.addMenu=function(a,b,c,d){this.addPair(a,b,isNil(c)?"\u25ba":c,null,d)};MenuMorph.prototype.addPair=function(a,b,c,d,e){this.addItem(a,b,d,null,null,null,null,c,e)};MenuMorph.prototype.addLine=function(a){this.items.push([0,a||1])}; MenuMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();var a=new TextMorph(localize(this.title),this.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,!0,!1,"center");a.alignment="center";a.color=WHITE;a.backgroundColor=this.borderColor;a.fixLayout();this.label=new BoxMorph(3,0);MorphicPreferences.isFlat&&(this.label.edge=0);this.label.color=this.borderColor;this.label.borderColor=this.borderColor;this.label.setExtent(a.extent().add(4));this.label.add(a); this.label.text=a}; @@ -252,14 +252,14 @@ MenuMorph.prototype.processKeyUp=function(a){nop(a)};MenuMorph.prototype.process MenuMorph.prototype.selectUp=function(){var a=detect(this.children,c=>c instanceof ScrollFrameMorph);a=(a?a.contents.children:this.children).filter(c=>c instanceof MenuItemMorph);if(this.selection){var b=a.indexOf(this.selection)-1;0>b&&(b=a.length-1);this.select(a[b])}else a.length&&this.select(a[0])}; MenuMorph.prototype.selectDown=function(){var a=detect(this.children,c=>c instanceof ScrollFrameMorph);a=(a?a.contents.children:this.children).filter(c=>c instanceof MenuItemMorph);if(this.selection){var b=a.indexOf(this.selection)+1;b>=a.length&&(b=0);this.select(a[b])}else a.length&&this.select(a[0])};MenuMorph.prototype.enterSubmenu=function(){this.selection&&this.selection.action instanceof MenuMorph&&(this.selection.popUpSubmenu(),this.submenu&&this.submenu.getFocus())}; MenuMorph.prototype.leaveSubmenu=function(){const a=this.world.activeMenu===this;var b=this.parent;this.parent instanceof MenuMorph&&(b.submenu=null,b.hasFocus=!0,this.destroy(),a&&(b.world.keyboardFocus=b,b.world.activeMenu=b))};MenuMorph.prototype.select=function(a){this.unselectAllItems();a.userState="highlight";a.rerender();a.scrollIntoView();this.selection=a}; -MenuMorph.prototype.destroy=function(){this.hasFocus&&(this.world.keyboardFocus=null);this.isListContents||this.world.activeMenu!==this||(this.world.activeMenu=null);MenuMorph.uber.destroy.call(this)};StringMorph.prototype=new Morph;StringMorph.prototype.constructor=StringMorph;StringMorph.uber=Morph.prototype;StringMorph.prototype.measureCtx=newCanvas().getContext("2d");function StringMorph(a,b,c,d,e,f,g,h,m,l){this.init(a,b,c,d,e,f,g,h,m,l)} -StringMorph.prototype.init=function(a,b,c,d,e,f,g,h,m,l){this.text=a||(""===a?"":"StringMorph");this.fontSize=b||12;this.fontName=l||MorphicPreferences.globalFontFamily;this.fontStyle=c||"sans-serif";this.isBold=d||!1;this.isItalic=e||!1;this.enableLinks=this.isEditable=!1;this.isNumeric=f||!1;this.isPassword=!1;this.shadowOffset=g||ZERO;this.shadowColor=h||null;this.isShowingBlanks=!1;this.blanksColor=new Color(180,140,140);this.isScrollable=!0;this.currentlySelecting=!1;this.endMark=this.startMark= +MenuMorph.prototype.destroy=function(){this.hasFocus&&(this.world.keyboardFocus=null);this.isListContents||this.world.activeMenu!==this||(this.world.activeMenu=null);MenuMorph.uber.destroy.call(this)};StringMorph.prototype=new Morph;StringMorph.prototype.constructor=StringMorph;StringMorph.uber=Morph.prototype;StringMorph.prototype.measureCtx=newCanvas().getContext("2d");function StringMorph(a,b,c,d,e,f,g,k,m,l){this.init(a,b,c,d,e,f,g,k,m,l)} +StringMorph.prototype.init=function(a,b,c,d,e,f,g,k,m,l){this.text=a||(""===a?"":"StringMorph");this.fontSize=b||12;this.fontName=l||MorphicPreferences.globalFontFamily;this.fontStyle=c||"sans-serif";this.isBold=d||!1;this.isItalic=e||!1;this.enableLinks=this.isEditable=!1;this.isNumeric=f||!1;this.isPassword=!1;this.shadowOffset=g||ZERO;this.shadowColor=k||null;this.isShowingBlanks=!1;this.blanksColor=new Color(180,140,140);this.isScrollable=!0;this.currentlySelecting=!1;this.endMark=this.startMark= 0;this.markedTextColor=WHITE;this.markedBackgroundColor=new Color(60,60,120);StringMorph.uber.init.call(this,!0);this.color=m||new Color(0,0,0);this.fixLayout()};StringMorph.prototype.toString=function(){return"a "+(this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0])+'("'+this.text.slice(0,30)+'...")'};StringMorph.prototype.password=function(a,b){var c="",d;for(d=0;d{m||(a.fillStyle=e,a.beginPath(),a.arc(h+d/2,f,d/2,radians(0),radians(360)),a.fill(),h+=d);m=!1;""!==l&&(a.fillStyle=this.getRenderColor().toString(),a.fillText(l,h,c),h+=a.measureText(l).width)})}; +fontHeight(this.fontSize)+f):a.fillText(d,e,fontHeight(this.fontSize)+f);c=Math.min(this.startMark,this.endMark);for(b=Math.max(this.startMark,this.endMark);c{m||(a.fillStyle=e,a.beginPath(),a.arc(k+d/2,f,d/2,radians(0),radians(360)),a.fill(),k+=d);m=!1;""!==l&&(a.fillStyle=this.getRenderColor().toString(),a.fillText(l,k,c),k+=a.measureText(l).width)})}; StringMorph.prototype.slotPosition=function(a){var b=this.isPassword?this.password("*",this.text.length):this.text;a=Math.min(Math.max(a,0),b.length);this.measureCtx.font=this.font();this.pos=a;return new Point(this.left()+this.measureCtx.measureText(b.slice(0,a)).width,this.top())}; StringMorph.prototype.slotAt=function(a){var b=this.isPassword?this.password("*",this.text.length):this.text,c=0,d=0;for(this.measureCtx.font=this.font();a.x-this.left()>d;)if(d+=this.measureCtx.measureText(b[c]).width,c+=1,c===b.length&&this.measureCtx.measureText(b).width-this.measureCtx.measureText(b[c-1]).width/2d-this.measureCtx.measureText(b[c-1]).width/2?c:c-1};StringMorph.prototype.upFrom=function(a){return a}; StringMorph.prototype.downFrom=function(a){return a};StringMorph.prototype.startOfLine=function(){return 0};StringMorph.prototype.endOfLine=function(){return this.text.length};StringMorph.prototype.previousWordFrom=function(a){for(--a;0{this.words=this.words.concat(g.split(" "));this.words.push("\n")});this.words.forEach(g=>{"\n"===g?(this.lines.push(c),this.lineSlots.push(f),this.maxLineWidth=Math.max(this.maxLineWidth,b.measureText(c).width),c=""):(0this.maxWidth?(this.lines.push(c), this.lineSlots.push(f),this.maxLineWidth=Math.max(this.maxLineWidth,b.measureText(c).width),c=g+" "):c=d):c=c+g+" ",f+=g.length+1)})};TextMorph.prototype.fixLayout=function(){this.parse();var a=Math.abs(this.shadowOffset.x);var b=Math.abs(this.shadowOffset.y);b=this.lines.length*(fontHeight(this.fontSize)+b);this.bounds=0===this.maxWidth?this.bounds.origin.extent(new Point(this.maxLineWidth+a,b)):this.bounds.origin.extent(new Point(this.maxWidth+a,b));this.parent&&this.parent.layoutChanged&&this.parent.layoutChanged()}; -TextMorph.prototype.render=function(a){var b=Math.abs(this.shadowOffset.x),c=Math.abs(this.shadowOffset.y),d=this.getShadowRenderColor();a.font=this.font();a.textAlign="left";a.textBaseline="bottom";this.backgroundColor&&(a.fillStyle=this.backgroundColor.toString(),a.fillRect(0,0,this.width(),this.height()));if(d){var e=Math.max(this.shadowOffset.x,0);var f=Math.max(this.shadowOffset.y,0);a.fillStyle=d.toString();for(d=0;d(fontHeight(this.fontSize)+e)*b;)b+=1;b=Math.max(b,1);f.font=this.font();e=f.measureText(this.lines[b-1]).width;e="right"===this.alignment?this.width()-e:"center"===this.alignment?(this.width()-e)/2:0;for(d=this.lines[b-1].length;ce;)e+=f.measureText(this.lines[b-1][c]).width,c+=1;return a.x-this.left()>e-f.measureText(this.lines[b-1][c]).width/2? @@ -299,15 +299,15 @@ TextMorph.prototype.setAlignmentToCenter=function(){this.alignment="center";this TextMorph.prototype.setFontSize=StringMorph.prototype.setFontSize;TextMorph.prototype.numericalSetters=StringMorph.prototype.numericalSetters; TextMorph.prototype.evaluationMenu=function(){var a=new MenuMorph(this,null);a.addItem("do it","doIt","evaluate the\nselected expression");a.addItem("show it","showIt","evaluate the\nselected expression\nand show the result");a.addItem("inspect it","inspectIt","evaluate the\nselected expression\nand inspect the result");a.addLine();a.addItem("select all","selectAllAndEdit");return a};TextMorph.prototype.setReceiver=function(a){this.receiver=a;this.customContextMenu=this.evaluationMenu()}; TextMorph.prototype.doIt=function(){this.receiver.evaluateString(this.selection());this.edit()};TextMorph.prototype.showIt=function(){var a=this.receiver.evaluateString(this.selection());null!==a&&this.inform(a)};TextMorph.prototype.inspectIt=function(){var a=this.receiver.evaluateString(this.selection()),b=this.world();isObject(a)&&(a=new InspectorMorph(a),a.setPosition(b.hand.position()),a.keepWithin(b),b.add(a),a.changed())};TriggerMorph.prototype=new Morph;TriggerMorph.prototype.constructor=TriggerMorph; -TriggerMorph.uber=Morph.prototype;function TriggerMorph(a,b,c,d,e,f,g,h,m,l,k){this.init(a,b,c,d,e,f,g,h,m,l,k)} -TriggerMorph.prototype.init=function(a,b,c,d,e,f,g,h,m,l,k){this.target=a||null;this.action=b||null;this.doubleClickAction=k||null;this.environment=f||null;this.labelString=c||" ";this.label=null;this.hint=g||null;this.schedule=null;this.fontSize=d||MorphicPreferences.menuFontSize;this.fontStyle=e||"sans-serif";this.highlightColor=new Color(192,192,192);this.pressColor=new Color(128,128,128);this.labelColor=h||new Color(0,0,0);this.labelBold=m||!1;this.labelItalic=l||!1;this.userState="normal";TriggerMorph.uber.init.call(this); +TriggerMorph.uber=Morph.prototype;function TriggerMorph(a,b,c,d,e,f,g,k,m,l,h){this.init(a,b,c,d,e,f,g,k,m,l,h)} +TriggerMorph.prototype.init=function(a,b,c,d,e,f,g,k,m,l,h){this.target=a||null;this.action=b||null;this.doubleClickAction=h||null;this.environment=f||null;this.labelString=c||" ";this.label=null;this.hint=g||null;this.schedule=null;this.fontSize=d||MorphicPreferences.menuFontSize;this.fontStyle=e||"sans-serif";this.highlightColor=new Color(192,192,192);this.pressColor=new Color(128,128,128);this.labelColor=k||new Color(0,0,0);this.labelBold=m||!1;this.labelItalic=l||!1;this.userState="normal";TriggerMorph.uber.init.call(this); this.color=WHITE;this.createLabel()};TriggerMorph.prototype.render=function(a){var b=this.color;"highlight"===this.userState?this.color=this.highlightColor:"pressed"===this.userState&&(this.color=this.pressColor);TriggerMorph.uber.render.call(this,a);this.color=b}; TriggerMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();this.label=new StringMorph(this.labelString,this.fontSize,this.fontStyle,this.labelBold,this.labelItalic,!1,null,null,this.labelColor);this.fixLayout();this.add(this.label)};TriggerMorph.prototype.fixLayout=function(){this.label.setPosition(this.center().subtract(this.label.extent().floorDivideBy(2)))}; TriggerMorph.prototype.trigger=function(){this.schedule&&(this.schedule.isActive=!1);if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call(),this):this.target.call(this.environment,this.action,this);else if("function"===typeof this.action)this.action.call(this.target);else this.target[this.action]()}; TriggerMorph.prototype.triggerDoubleClick=function(){if(this.doubleClickAction)if(this.schedule&&(this.schedule.isActive=!1),"function"===typeof this.target)"function"===typeof this.doubleClickAction?this.target.call(this.environment,this.doubleClickAction.call(),this):this.target.call(this.environment,this.doubleClickAction,this);else if("function"===typeof this.doubleClickAction)this.doubleClickAction.call(this.target);else this.target[this.doubleClickAction]()}; TriggerMorph.prototype.mouseEnter=function(){var a=this.hint instanceof Function?this.hint():this.hint;this.userState="highlight";this.rerender();a&&this.bubbleHelp(a)};TriggerMorph.prototype.mouseLeave=function(){this.userState="normal";this.rerender();this.schedule&&(this.schedule.isActive=!1);this.hint&&this.world().hand.destroyTemporaries()};TriggerMorph.prototype.mouseDownLeft=function(){this.userState="pressed";this.rerender()}; TriggerMorph.prototype.mouseClickLeft=function(){this.userState="highlight";this.rerender();this.trigger()};TriggerMorph.prototype.mouseDoubleClick=function(){this.triggerDoubleClick()};TriggerMorph.prototype.rootForGrab=function(){return this.isDraggable?TriggerMorph.uber.rootForGrab.call(this):null};TriggerMorph.prototype.bubbleHelp=function(a){var b=this.world();this.schedule=new Animation(nop,nop,0,500,nop,()=>this.popUpbubbleHelp(a));b.animations.push(this.schedule)}; -TriggerMorph.prototype.popUpbubbleHelp=function(a){(new SpeechBubbleMorph(localize(a),null,null,1)).popUp(this.world(),this.rightCenter().add(new Point(-8,0)))};MenuItemMorph.prototype=new TriggerMorph;MenuItemMorph.prototype.constructor=MenuItemMorph;MenuItemMorph.uber=TriggerMorph.prototype;function MenuItemMorph(a,b,c,d,e,f,g,h,m,l,k,n){this.shortcutString=n||null;this.shortcut=null;this.init(a,b,c,d,e,f,g,h,m,l,k)} +TriggerMorph.prototype.popUpbubbleHelp=function(a){(new SpeechBubbleMorph(localize(a),null,null,1)).popUp(this.world(),this.rightCenter().add(new Point(-8,0)))};MenuItemMorph.prototype=new TriggerMorph;MenuItemMorph.prototype.constructor=MenuItemMorph;MenuItemMorph.uber=TriggerMorph.prototype;function MenuItemMorph(a,b,c,d,e,f,g,k,m,l,h,n){this.shortcutString=n||null;this.shortcut=null;this.init(a,b,c,d,e,f,g,k,m,l,h)} MenuItemMorph.prototype.createLabel=function(){this.label&&this.label.destroy();this.label=this.createLabelPart(this.labelString);this.add(this.label);var a=this.label.width();var b=this.label.height();this.shortcut&&this.shortcut.destroy();this.shortcutString&&(this.shortcut=this.createLabelPart(this.shortcutString),a+=this.shortcut.width()+4,b=Math.max(b,this.shortcut.height()),this.add(this.shortcut));this.setExtent(new Point(a+8,b))}; MenuItemMorph.prototype.fixLayout=function(){var a=this.center();this.label.setCenter(a);this.label.setLeft(this.left()+4);this.shortcut&&(this.shortcut.setCenter(a),this.shortcut.setRight(this.right()-4))}; MenuItemMorph.prototype.createLabelPart=function(a){if(isString(a))return this.createLabelString(a);if(a instanceof Array){var b=new Morph;b.alpha=0;var c=this.createIcon(a[0]);b.add(c);a=this.createLabelString(a[1]);b.add(a);a.setCenter(c.center());a.setLeft(c.right()+4);b.bounds=c.bounds.merge(a.bounds);b.rerender();return b}return this.createIcon(a)}; @@ -371,15 +371,15 @@ f.mouseEnter(),f.mouseEnterDragging&&this.mouseButton&&f.mouseEnterDragging(this HandMorph.prototype.processMouseScroll=function(a){for(var b=this.morphAtPointer();b&&!b.mouseScroll;)b=b.parent;b&&b.mouseScroll(a.detail/-3||(Object.prototype.hasOwnProperty.call(a,"wheelDeltaY")?a.wheelDeltaY/120:a.wheelDelta/120),a.wheelDeltaX/120||0)}; HandMorph.prototype.processDrop=function(a){function b(r){for(var t=new Image,u=new FileReader;!n.droppedSVG;)n=n.parent;const v=new Promise(w=>t.onload=()=>w(n.droppedSVG(t,r.name)));u=new FileReader;u.onloadend=w=>t.src=w.target.result;u.readAsDataURL(r);return v}function c(r){for(var t=new Image,u=new FileReader;!n.droppedImage;)n=n.parent;const v=new Promise(w=>{t.onload=()=>{q=newCanvas(new Point(t.width,t.height),!0);q.getContext("2d").drawImage(t,0,0);w(n.droppedImage(q,r.name))}});u=new FileReader; u.onloadend=w=>t.src=w.target.result;u.readAsDataURL(r);return v}function d(r){for(var t=new Audio,u=new FileReader;!n.droppedAudio;)n=n.parent;u.onloadend=v=>{t.src=v.target.result;n.droppedAudio(t,r.name)};u.readAsDataURL(r)}function e(r){for(var t=new FileReader;!n.droppedText;)n=n.parent;t.onloadend=u=>{n.droppedText(u.target.result,r.name,r.type)};t.readAsText(r)}function f(r){for(var t=new FileReader;!n.droppedBinary;)n=n.parent;t.onloadend=u=>{n.droppedBinary(u.target.result,r.name)};t.readAsArrayBuffer(r)} -function g(r,t){var u=new XMLHttpRequest;u.open("GET",r);u.onreadystatechange=()=>{if(4===u.readyState)if(u.responseText)t(u.responseText);else throw Error("unable to retrieve "+r);};u.send()}function h(r){var t="";var u=r.indexOf('r.then(()=>m(t),()=>m(t)), -Promise.resolve());if(k)if(l=k.slice(k.lastIndexOf(".")+1).toLowerCase(),contains(["gif","png","jpg","jpeg","bmp"],l)){for(;!n.droppedImage;)n=n.parent;p=new Image;p.onload=()=>{q=newCanvas(new Point(p.width,p.height),!0);q.getContext("2d").drawImage(p,0,0);n.droppedImage(q)};p.src=k}else{if("svg"===l&&!MorphicPreferences.rasterizeSVGs){for(;!n.droppedSVG;)n=n.parent;g(k,r=>{var t=new Image;t.onload=()=>{n.droppedSVG(t,k.slice(k.lastIndexOf("/")+1,k.lastIndexOf(".")))};t.src="data:image/svg+xml;utf8,"+ -encodeURIComponent(r)})}}else if(a){for(;!n.droppedImage;)n=n.parent;p=new Image;p.onload=()=>{q=newCanvas(new Point(p.width,p.height),!0);q.getContext("2d").drawImage(p,0,0);n.droppedImage(q)};if(l=h(a))p.src=l}};HandMorph.prototype.destroyTemporaries=function(){this.temporaries.forEach(a=>{a.isClickable&&a.bounds.containsPoint(this.position())||(a.destroy(),this.temporaries.splice(this.temporaries.indexOf(a),1))})};WorldMorph.prototype=new FrameMorph;WorldMorph.prototype.constructor=WorldMorph; +function g(r,t){var u=new XMLHttpRequest;u.open("GET",r);u.onreadystatechange=()=>{if(4===u.readyState)if(u.responseText)t(u.responseText);else throw Error("unable to retrieve "+r);};u.send()}function k(r){var t="";var u=r.indexOf('r.then(()=>m(t),()=>m(t)), +Promise.resolve());if(h)if(l=h.slice(h.lastIndexOf(".")+1).toLowerCase(),contains(["gif","png","jpg","jpeg","bmp"],l)){for(;!n.droppedImage;)n=n.parent;p=new Image;p.onload=()=>{q=newCanvas(new Point(p.width,p.height),!0);q.getContext("2d").drawImage(p,0,0);n.droppedImage(q)};p.src=h}else{if("svg"===l&&!MorphicPreferences.rasterizeSVGs){for(;!n.droppedSVG;)n=n.parent;g(h,r=>{var t=new Image;t.onload=()=>{n.droppedSVG(t,h.slice(h.lastIndexOf("/")+1,h.lastIndexOf(".")))};t.src="data:image/svg+xml;utf8,"+ +encodeURIComponent(r)})}}else if(a){for(;!n.droppedImage;)n=n.parent;p=new Image;p.onload=()=>{q=newCanvas(new Point(p.width,p.height),!0);q.getContext("2d").drawImage(p,0,0);n.droppedImage(q)};if(l=k(a))p.src=l}};HandMorph.prototype.destroyTemporaries=function(){this.temporaries.forEach(a=>{a.isClickable&&a.bounds.containsPoint(this.position())||(a.destroy(),this.temporaries.splice(this.temporaries.indexOf(a),1))})};WorldMorph.prototype=new FrameMorph;WorldMorph.prototype.constructor=WorldMorph; WorldMorph.uber=FrameMorph.prototype;WorldMorph.prototype.customMorphs=[];function WorldMorph(a,b){this.init(a,b)} WorldMorph.prototype.init=function(a,b){WorldMorph.uber.init.call(this);this.color=new Color(205,205,205);this.alpha=1;this.bounds=new Rectangle(0,0,a.width,a.height);this.isVisible=!0;this.isDraggable=!1;this.currentKey=null;this.worldCanvas=a;for(this.stamp=Date.now();this.stamp===Date.now();)nop();this.stamp=Date.now();this.useFillPage=b;void 0===this.useFillPage&&(this.useFillPage=!0);this.isDevMode=!1;this.broken=[];this.animations=[];this.hand=new HandMorph(this);this.activeHandle=this.activeMenu= this.lastEditedText=this.cursor=this.keyboardFocus=this.keyboardHandler=null;this.initKeyboardHandler();this.resetKeyboardHandler();this.initEventListeners()};WorldMorph.prototype.fullDrawOn=function(a,b){WorldMorph.uber.fullDrawOn.call(this,a,b);this.hand.fullDrawOn(a,b)};WorldMorph.prototype.updateBroken=function(){var a=this.worldCanvas.getContext("2d");this.condenseDamages();this.broken.forEach(b=>{b.extent().gt(ZERO)&&this.fullDrawOn(a,b)});this.broken=[]}; WorldMorph.prototype.stepAnimations=function(){this.animations.forEach(a=>a.step());this.animations=this.animations.filter(a=>a.isActive)}; -WorldMorph.prototype.condenseDamages=function(){function a(c){var d=[],e=c.length,f=l=>l.isNearTo(m,20),g,h;for(h=0;hl.isNearTo(m,20),g,k;for(k=0;k{c.reactToWorldResize&&c.reactToWorldResize(this.bounds.copy())})};WorldMorph.prototype.getGlobalPixelColor=function(a){a=Morph.prototype.fullImage.call(this).getContext("2d").getImageData(a.x,a.y,1,1).data;return new Color(a[0],a[1],a[2])}; @@ -398,25 +398,25 @@ a.addLine());this.isDevMode?a.addItem("user mode...","toggleDevMode","disable de WorldMorph.prototype.userCreateMorph=function(){function a(e){e=e.fullCopy();e.isDraggable=!0;e.pickUp(b)}var b=this,c;var d=new MenuMorph(this,"make a morph");d.addItem("rectangle",()=>a(new Morph));d.addItem("box",()=>a(new BoxMorph));d.addItem("circle box",()=>a(new CircleBoxMorph));d.addLine();d.addItem("slider",()=>a(new SliderMorph));d.addItem("dial",()=>{c=new DialMorph;c.pickUp(this)});d.addItem("frame",()=>{c=new FrameMorph;c.setExtent(new Point(350,250));a(c)});d.addItem("scroll frame", ()=>{c=new ScrollFrameMorph;c.contents.acceptsDrops=!0;c.contents.adjustBounds();c.setExtent(new Point(350,250));a(c)});d.addItem("handle",()=>a(new HandleMorph));d.addLine();d.addItem("string",()=>{c=new StringMorph("Hello, World!");c.isEditable=!0;a(c)});d.addItem("text",()=>{c=new TextMorph("Ich wei\u00df nicht, was soll es bedeuten, dass ich so traurig bin, ein M\u00e4rchen aus uralten Zeiten, das kommt mir nicht aus dem Sinn. Die Luft ist k\u00fchl und es dunkelt, und ruhig flie\u00dft der Rhein; der Gipfel des Berges funkelt im Abendsonnenschein. Die sch\u00f6nste Jungfrau sitzet dort oben wunderbar, ihr gold'nes Geschmeide blitzet, sie k\u00e4mmt ihr goldenes Haar, sie k\u00e4mmt es mit goldenem Kamme, und singt ein Lied dabei; das hat eine wundersame, gewalt'ge Melodei. Den Schiffer im kleinen Schiffe, ergreift es mit wildem Weh; er schaut nicht die Felsenriffe, er schaut nur hinauf in die H\u00f6h'. Ich glaube, die Wellen verschlingen am Ende Schiffer und Kahn, und das hat mit ihrem Singen, die Loreley getan."); c.isEditable=!0;c.maxWidth=300;c.fixLayout();a(c)});d.addItem("speech bubble",()=>{c=new SpeechBubbleMorph("Hello, World!");a(c)});d.addLine();d.addItem("gray scale palette",()=>a(new GrayPaletteMorph));d.addItem("color palette",()=>a(new ColorPaletteMorph));d.addItem("color picker",()=>a(new ColorPickerMorph));d.addLine();d.addItem("sensor demo",()=>{c=new MouseSensorMorph;c.setColor(new Color(230,200,100));c.edge=35;c.border=15;c.borderColor=new Color(200,100,50);c.alpha=.2;c.setExtent(new Point(100, -100));a(c)});d.addItem("animation demo",()=>{var e=new BouncerMorph;e.setPosition(new Point(50,20));e.setExtent(new Point(300,200));e.alpha=.9;e.speed=3;var f=new BouncerMorph;f.setColor(new Color(50,50,50));f.setPosition(new Point(80,80));f.setExtent(new Point(80,250));f.type="horizontal";f.direction="right";f.alpha=.9;f.speed=5;var g=new BouncerMorph;g.setColor(new Color(20,20,20));g.setPosition(new Point(90,140));g.setExtent(new Point(40,30));g.type="horizontal";g.direction="right";g.speed=3;var h= -new BouncerMorph;h.setColor(new Color(200,20,20));h.setPosition(new Point(90,140));h.setExtent(new Point(20,20));h.type="vertical";h.direction="up";h.speed=8;var m=new BouncerMorph;m.setColor(new Color(20,200,20));m.setPosition(new Point(120,140));m.setExtent(new Point(20,20));m.type="vertical";m.direction="down";m.speed=4;f.add(h);f.add(g);e.add(m);e.add(f);a(e)});d.addItem("pen",()=>a(new PenMorph));this.customMorphs.length&&(d.addLine(),this.customMorphs.forEach(e=>{if(e instanceof Array){var f= +100));a(c)});d.addItem("animation demo",()=>{var e=new BouncerMorph;e.setPosition(new Point(50,20));e.setExtent(new Point(300,200));e.alpha=.9;e.speed=3;var f=new BouncerMorph;f.setColor(new Color(50,50,50));f.setPosition(new Point(80,80));f.setExtent(new Point(80,250));f.type="horizontal";f.direction="right";f.alpha=.9;f.speed=5;var g=new BouncerMorph;g.setColor(new Color(20,20,20));g.setPosition(new Point(90,140));g.setExtent(new Point(40,30));g.type="horizontal";g.direction="right";g.speed=3;var k= +new BouncerMorph;k.setColor(new Color(200,20,20));k.setPosition(new Point(90,140));k.setExtent(new Point(20,20));k.type="vertical";k.direction="up";k.speed=8;var m=new BouncerMorph;m.setColor(new Color(20,200,20));m.setPosition(new Point(120,140));m.setExtent(new Point(20,20));m.type="vertical";m.direction="down";m.speed=4;f.add(k);f.add(g);e.add(m);e.add(f);a(e)});d.addItem("pen",()=>a(new PenMorph));this.customMorphs.length&&(d.addLine(),this.customMorphs.forEach(e=>{if(e instanceof Array){var f= new MenuMorph;e[1].forEach(g=>f.addItem(g,()=>a(g instanceof Array?g[0]:g)));d.addMenu(e[0],f)}else d.addItem(e.toString(),()=>a(e))}));d.popUpAtHand(this)};WorldMorph.prototype.toggleDevMode=function(){this.isDevMode=!this.isDevMode};WorldMorph.prototype.hideAll=function(){this.children.forEach(a=>a.hide())};WorldMorph.prototype.showAllHiddens=function(){this.forAllChildren(a=>{a.isVisible||a.show()})}; WorldMorph.prototype.about=function(){var a="",b;for(b in modules)Object.prototype.hasOwnProperty.call(modules,b)&&(a+="\n"+b+" ("+modules[b]+")");""!==a&&(a="\n\nmodules:\n\nmorphic ("+morphicVersion+")"+a);this.inform("morphic.js\n\na lively Web GUI\ninspired by Squeak\n"+morphicVersion+"\n\nwritten by Jens M\u00f6nig\njens@moenig.org"+a)}; WorldMorph.prototype.edit=function(a){if(this.lastEditedText!==a){isNil(this.lastEditedText)||this.stopEditing();if(!a.isEditable)return null;this.cursor&&this.cursor.destroy();this.worldCanvas.focus();this.keyboardHandler.focus();this.keyboardFocus=this.cursor=new CursorMorph(a,this.keyboardHandler);a.parent.add(this.cursor);MorphicPreferences.useSliderForInput&&(a.parentThatIsA(MenuMorph)||this.slide(a));this.lastEditedText!==a&&a.escalateEvent("freshTextEdit",a);this.lastEditedText=a}}; WorldMorph.prototype.slide=function(a){var b=parseFloat(a.text);isNaN(b)&&(b=0);var c=new MenuMorph;b=new SliderMorph(b-25,b+25,b,10,"horizontal");b.alpha=1;b.color=new Color(225,225,225);b.button.color=c.borderColor;b.button.highlightColor=b.button.color.copy();b.button.highlightColor.b+=100;b.button.pressColor=b.button.color.copy();b.button.pressColor.b+=150;b.setExtent(new Point(10*MorphicPreferences.scrollBarSize,MorphicPreferences.menuFontSize));b.action=d=>{a.changed();a.text=Math.round(d).toString(); a.fixLayout();a.rerender();a.escalateEvent("reactToSliderEdit",a)};c.items.push(b);c.popup(this,a.bottomLeft().add(new Point(0,5)))};WorldMorph.prototype.stopEditing=function(){this.cursor&&(this.cursor.target.escalateEvent("reactToEdit",this.cursor.target),this.cursor.target.clearSelection(),this.cursor.destroy(),this.cursor=null);this.keyboardFocus&&this.keyboardFocus.stopEditing&&this.keyboardFocus.stopEditing();this.lastEditedText=this.keyboardFocus=null}; WorldMorph.prototype.toggleBlurredShadows=function(){useBlurredShadows=!useBlurredShadows};WorldMorph.prototype.togglePreferences=function(){MorphicPreferences=MorphicPreferences===standardSettings?touchScreenSettings:standardSettings};WorldMorph.prototype.toggleHolesDisplay=function(){MorphicPreferences.showHoles=!MorphicPreferences.showHoles;this.rerender()}; -(function(a){function b(l){this.name=l}class c{constructor(){this.ide=null;this.registry=[];this.pendingExtensions=[];this.eventQueue=[]}initialize(l){this.ide=l;this.pendingExtensions.forEach(k=>this.load(k));this.pendingExtensions=[];this.eventQueue=[]}load(l){const k=l.prototype.isSupported();if(!0!==k)"string"===typeof k?this.ide.showMessage(`Unable to load extension: ${k}`):this.ide.showMessage("Unable to load extension.");else if(this.registry.find(p=>p.constructor.name===l.name))console.log(`skipping extension ${l.name} (already loaded)`); -else{var n=new l(this.ide);try{this.validate(n)}catch(p){this.ide.showMessage(`Unable to load extension "${n.name}": ${p.message}`);return}this.registry.push(n);this.ide.controlBar.extensionsButton.show();n.getCategories().forEach(p=>this.registerCategory(p));this.ide.createCategories();this.ide.createCorralBar();this.ide.fixLayout();SpriteMorph.prototype.initBlocks();this.eventQueue.forEach(p=>n[p]())}}onNewProject(){this.registry.forEach(l=>l.onNewProject())}onOpenRole(){this.registry.forEach(l=> -l.onOpenRole());this.eventQueue.includes("onOpenRole")||(this.eventQueue=["onOpenRole"])}onNewSprite(l){this.registry.forEach(k=>k.onNewSprite(l))}onRenameSprite(l,k){this.registry.forEach(n=>n.onRenameSprite(l,k))}onSetStageSize(l,k){this.registry.forEach(n=>n.onSetStageSize(l,k))}onRunScripts(){this.registry.forEach(l=>l.onRunScripts())}onStopAllScripts(){this.registry.forEach(l=>l.onStopAllScripts())}onPauseAll(){this.registry.forEach(l=>l.onPauseAll())}onResumeAll(){this.registry.forEach(l=>l.onResumeAll())}register(l){this.isReady()? -this.load(l):this.pendingExtensions.push(l)}isReady(){return!!this.ide}validate(l){const k=l.getPalette();l.getBlocks().forEach(n=>{if(SpriteMorph.prototype[n.name]||StageMorph.prototype[n.name]||Process.prototype[n.name])throw Error(`Cannot override existing "${n.name}" block`);this.findWatcherReceivers(k,n.name).forEach(p=>{if(!n.receivers.includes(p))throw Error(`Cannot add a watcher toggle for "${n.spec}" on ${p.name}.`+` Did you forget to add ".for(${p.name})" when defining the block?`);})})}getLabelPart(l){const k= -this.registry.flatMap(n=>n.getLabelParts()).find(n=>n.spec===l);if(k)return k.factory(l)}registerCategory(l){const {name:k,color:n}=l;SpriteMorph.prototype.categories.splice(SpriteMorph.prototype.categories.length-3,0,k);SpriteMorph.prototype.blockColor[k]=n}getPaletteContents(l,k){return this.registry.flatMap(n=>n.getPalette()).filter(n=>n.isVisible(l,k)).flatMap(n=>n.contents)}findWatcherReceivers(l,k){return l.filter(n=>n.contents.find(p=>"watcher"===p.type&&p.name===k)).map(n=>n.targetObject).reduce((n, -p)=>{n.includes(p)||n.push(p);return n},[])}initBlocks(){const l=this.registry.flatMap(n=>n.getBlocks()),k=this.registry.flatMap(n=>n.getPalette());l.forEach(n=>{SpriteMorph.prototype.blocks[n.name]={type:n.type,category:n.category,spec:n.spec,defaults:n.defaults,help:n.help,terminal:n.isTerminal};const p=this.findWatcherReceivers(k,n.name);p.forEach(q=>{if(!n.receivers.includes(q))throw Error(`Cannot add a watcher toggle for ${n.spec} on ${q.name}.`+` Did you forget to add ".for(${q.name})" when defining the block?`); -});0===p.length&&p.push(Process);p.forEach(q=>q.prototype[n.name]=n.impl)})}getUserMenu(l,k){const n=this.registry.flatMap(p=>p.getUserMenu(l));0k.addItem(p[0],p[1])))}}b.prototype.getMenu=function(){return null};b.prototype.getSettings=function(){return[]};b.prototype.getCategories=function(){return[]};b.prototype.getBlocks=function(){return[]};b.prototype.getPalette=function(){return[]};b.prototype.getLabelParts=function(){return[]};b.prototype.getUserMenu= -function(l){return[]};b.prototype.onRunScripts=b.prototype.onStopAllScripts=b.prototype.onPauseAll=b.prototype.onResumeAll=b.prototype.onNewSprite=b.prototype.onRenameSprite=b.prototype.onSetStageSize=b.prototype.onNewProject=b.prototype.onOpenRole=function(){};b.prototype.triggerHatBlock=function(l){let k=NetsBloxExtensions.ide.stage;k.children.concat(k).forEach(n=>{isSnapObject(n)&&n.allHatBlocksFor(l,!0).forEach(p=>k.threads.startProcess(p,n,k.isThreadSafe))})};b.prototype.isSupported=function(){return!0}; -class d{constructor(l,k,n,p="",q="",r=!1){this.label=l;this.toggle=k;this.test=n;this.onHint=p;this.offHint=q;this.hide=r}}d.createFromLocalStorage=function(l,k,n=!1,p="",q="",r=!1){return new d(l,()=>{window.localStorage.setItem(k,"true"!=(window.localStorage.getItem(k)??n))},()=>"true"==(window.localStorage.getItem(k)??n),p,q,r)};b.ExtensionSetting=d;class e{constructor(l,k){"%"!==l[0]&&(l="%"+l);this.spec=l;this.factory=k}}class f{constructor(l,k,n){this.category=l;this.contents=k;this.targetObject= -n}isVisible(l,k){return this.category===k&&(!this.targetObject||l instanceof this.targetObject)}}class g{constructor(l,k,n,p,q=[],r,t=null){this.name=l;this.type=k;this.category=n;this.spec=p;this.defaults=q;this.impl=r;this.receivers=[];this.help=t;this.isTerminal=!1}help(l){this.help=l;return this}terminal(){this.isTerminal=!0;return this}for(...l){this.receivers=l;return this}}class h{constructor(l,k=new Color(120,120,120)){this.name=l;this.color=k}}class m{constructor(l){this.name=l;this.type= -"block"}withWatcherToggle(){this.type="watcher";return this}}b.PaletteCategory=f;b.Palette={};b.Palette.Block=m;b.Palette.Space={name:"-",type:"space"};b.Palette.BigSpace={name:"=",type:"space"};b.Block=g;b.Category=h;b.LabelPart=e;a.Extension=b;a.ExtensionRegistry=c;a.NetsBloxExtensions=new c})(this);modules.locale="2020-August-05";var SnapTranslator=new Localizer;function localize(a){return SnapTranslator.translate(a)}function Localizer(a,b){this.language=a||"en";this.dict=b||{}} +(function(a){function b(l){this.name=l}class c{constructor(){this.ide=null;this.registry=[];this.pendingExtensions=[];this.eventQueue=[]}initialize(l){this.ide=l;this.pendingExtensions.forEach(h=>this.load(h));this.pendingExtensions=[];this.eventQueue=[]}load(l){const h=l.prototype.isSupported();if(!0!==h)"string"===typeof h?this.ide.showMessage(`Unable to load extension: ${h}`):this.ide.showMessage("Unable to load extension.");else if(this.registry.find(p=>p.constructor.name===l.name))console.log(`skipping extension ${l.name} (already loaded)`); +else{var n=new l(this.ide);try{this.validate(n)}catch(p){this.ide.showMessage(`Unable to load extension "${n.name}": ${p.message}`);return}this.registry.push(n);n.getCategories().forEach(p=>this.registerCategory(p));this.ide.createCategories();this.ide.createCorralBar();this.ide.fixLayout();SpriteMorph.prototype.initBlocks();this.eventQueue.forEach(p=>n[p]())}}onNewProject(){this.registry.forEach(l=>l.onNewProject())}onOpenRole(){this.registry.forEach(l=>l.onOpenRole());this.eventQueue.includes("onOpenRole")|| +(this.eventQueue=["onOpenRole"])}onNewSprite(l){this.registry.forEach(h=>h.onNewSprite(l))}onRenameSprite(l,h){this.registry.forEach(n=>n.onRenameSprite(l,h))}onSetStageSize(l,h){this.registry.forEach(n=>n.onSetStageSize(l,h))}onRunScripts(){this.registry.forEach(l=>l.onRunScripts())}onStopAllScripts(){this.registry.forEach(l=>l.onStopAllScripts())}onPauseAll(){this.registry.forEach(l=>l.onPauseAll())}onResumeAll(){this.registry.forEach(l=>l.onResumeAll())}register(l){this.isReady()?this.load(l): +this.pendingExtensions.push(l)}isReady(){return!!this.ide}validate(l){const h=l.getPalette();l.getBlocks().forEach(n=>{if(SpriteMorph.prototype[n.name]||StageMorph.prototype[n.name]||Process.prototype[n.name])throw Error(`Cannot override existing "${n.name}" block`);this.findWatcherReceivers(h,n.name).forEach(p=>{if(!n.receivers.includes(p))throw Error(`Cannot add a watcher toggle for "${n.spec}" on ${p.name}.`+` Did you forget to add ".for(${p.name})" when defining the block?`);})})}getLabelPart(l){const h= +this.registry.flatMap(n=>n.getLabelParts()).find(n=>n.spec===l);if(h)return h.factory(l)}registerCategory(l){const {name:h,color:n}=l;SpriteMorph.prototype.categories.splice(SpriteMorph.prototype.categories.length-3,0,h);SpriteMorph.prototype.blockColor[h]=n}getPaletteContents(l,h){return this.registry.flatMap(n=>n.getPalette()).filter(n=>n.isVisible(l,h)).flatMap(n=>n.contents)}findWatcherReceivers(l,h){return l.filter(n=>n.contents.find(p=>"watcher"===p.type&&p.name===h)).map(n=>n.targetObject).reduce((n, +p)=>{n.includes(p)||n.push(p);return n},[])}initBlocks(){const l=this.registry.flatMap(n=>n.getBlocks()),h=this.registry.flatMap(n=>n.getPalette());l.forEach(n=>{SpriteMorph.prototype.blocks[n.name]={type:n.type,category:n.category,spec:n.spec,defaults:n.defaults,help:n.help,terminal:n.isTerminal};const p=this.findWatcherReceivers(h,n.name);p.forEach(q=>{if(!n.receivers.includes(q))throw Error(`Cannot add a watcher toggle for ${n.spec} on ${q.name}.`+` Did you forget to add ".for(${q.name})" when defining the block?`); +});0===p.length&&p.push(Process);p.forEach(q=>q.prototype[n.name]=n.impl)})}getUserMenu(l,h){const n=this.registry.flatMap(p=>p.getUserMenu(l));0h.addItem(p[0],p[1])))}}b.prototype.getMenu=function(){return null};b.prototype.getSettings=function(){return[]};b.prototype.getCategories=function(){return[]};b.prototype.getBlocks=function(){return[]};b.prototype.getPalette=function(){return[]};b.prototype.getLabelParts=function(){return[]};b.prototype.getUserMenu= +function(l){return[]};b.prototype.onRunScripts=b.prototype.onStopAllScripts=b.prototype.onPauseAll=b.prototype.onResumeAll=b.prototype.onNewSprite=b.prototype.onRenameSprite=b.prototype.onSetStageSize=b.prototype.onNewProject=b.prototype.onOpenRole=function(){};b.prototype.triggerHatBlock=function(l){let h=NetsBloxExtensions.ide.stage;h.children.concat(h).forEach(n=>{isSnapObject(n)&&n.allHatBlocksFor(l,!0).forEach(p=>h.threads.startProcess(p,n,h.isThreadSafe))})};b.prototype.isSupported=function(){return!0}; +class d{constructor(l,h,n,p="",q="",r=!1){this.label=l;this.toggle=h;this.test=n;this.onHint=p;this.offHint=q;this.hide=r}}d.createFromLocalStorage=function(l,h,n=!1,p="",q="",r=!1){return new d(l,()=>{window.localStorage.setItem(h,"true"!=(window.localStorage.getItem(h)??n))},()=>"true"==(window.localStorage.getItem(h)??n),p,q,r)};b.ExtensionSetting=d;class e{constructor(l,h){"%"!==l[0]&&(l="%"+l);this.spec=l;this.factory=h}}class f{constructor(l,h,n){this.category=l;this.contents=h;this.targetObject= +n}isVisible(l,h){return this.category===h&&(!this.targetObject||l instanceof this.targetObject)}}class g{constructor(l,h,n,p,q=[],r,t=null){this.name=l;this.type=h;this.category=n;this.spec=p;this.defaults=q;this.impl=r;this.receivers=[];this.help=t;this.isTerminal=!1}help(l){this.help=l;return this}terminal(){this.isTerminal=!0;return this}for(...l){this.receivers=l;return this}}class k{constructor(l,h=new Color(120,120,120)){this.name=l;this.color=h}}class m{constructor(l){this.name=l;this.type= +"block"}withWatcherToggle(){this.type="watcher";return this}}b.PaletteCategory=f;b.Palette={};b.Palette.Block=m;b.Palette.Space={name:"-",type:"space"};b.Palette.BigSpace={name:"=",type:"space"};b.Block=g;b.Category=k;b.LabelPart=e;a.Extension=b;a.ExtensionRegistry=c;a.NetsBloxExtensions=new c})(this);modules.locale="2020-August-05";var SnapTranslator=new Localizer;function localize(a){return SnapTranslator.translate(a)}function Localizer(a,b){this.language=a||"en";this.dict=b||{}} Localizer.prototype.translate=function(a){return Object.prototype.hasOwnProperty.call(this.dict[this.language],a)?this.dict[this.language][a]:a};Localizer.prototype.languages=function(){var a,b=[];for(a in this.dict)Object.prototype.hasOwnProperty.call(this.dict,a)&&b.push(a);return b.sort()};Localizer.prototype.languageName=function(a){return this.dict[a].language_name||a}; Localizer.prototype.credits=function(){var a="";this.languages().forEach(b=>{a=a+"\n"+this.languageName(b)+" ("+b+") - "+this.dict[b].language_translator+" - "+this.dict[b].last_changed});return a};Localizer.prototype.unload=function(){var a,b=["language_name","language_translator","last_changed"];this.languages().forEach(c=>{var d;if("en"!==c)for(d in a=this.dict[c],a)Object.prototype.hasOwnProperty.call(a,d)&&!contains(b,d)&&delete a[d]})}; SnapTranslator.dict.en={language_name:"English",language_translator:"Jens M\u00f6nig","translator_e-mail":"jens@moenig.org",last_changed:"2020-07-09",__shout__go__:"green flag clicked",any:"random","length of %s":"length of text %s","file menu import hint":"load an exported project file\nor block library, a costume\nor a sound","settings menu prefer empty slots hint":"check to focus on empty slots\nwhen dragging & dropping reporters","costumes tab help":"import a picture from another web page or from\na file on your computer by dropping it here\n", @@ -462,8 +462,8 @@ SymbolMorph.prototype.renderSymbolGearBig=function(a,b){var c=this.symbolWidth() SymbolMorph.prototype.renderSymbolFile=function(a,b){var c=this.size,d=this.symbolWidth(),e=Math.min(d,c)/2;a.fillStyle=b.toString();a.beginPath();a.moveTo(0,0);a.lineTo(e,0);a.lineTo(e,e);a.lineTo(d,e);a.lineTo(d,c);a.lineTo(0,c);a.closePath();a.fill();a.fillStyle=b.darker(25).toString();a.beginPath();a.moveTo(e,0);a.lineTo(d,e);a.lineTo(e,e);a.lineTo(e,0);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolFullScreen=function(a,b){var c=this.size,d=this.symbolWidth(),e=d/2,f=d/20,g=d/2;a.strokeStyle=b.toString();a.lineWidth=d/5;a.beginPath();a.moveTo(e-f,e+f);a.lineTo(2*f,c-2*f);a.stroke();a.strokeStyle=b.toString();a.lineWidth=d/5;a.beginPath();a.moveTo(e+f,e-f);a.lineTo(c-2*f,2*f);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,c);a.lineTo(0,c-g);a.lineTo(g,c);a.closePath();a.fill();a.fillStyle=b.toString();a.beginPath();a.moveTo(c,0);a.lineTo(c-g,0); a.lineTo(c,g);a.closePath();a.fill()}; -SymbolMorph.prototype.renderSymbolGrow=function(a,b){function c(){a.strokeStyle=b.toString();a.lineWidth=e/7;a.beginPath();a.moveTo(f-3*g,f+3*g);a.lineTo(2*g,d-2*g);a.stroke();a.strokeStyle=b.toString();a.lineWidth=e/7;a.beginPath();a.moveTo(f+3*g,f-3*g);a.lineTo(d-2*g,2*g);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,d);a.lineTo(0,d-h);a.lineTo(h,d);a.closePath();a.fill();a.fillStyle=b.toString();a.beginPath();a.moveTo(d,0);a.lineTo(d-h,0);a.lineTo(d,h);a.closePath();a.fill()}var d= -this.size,e=this.symbolWidth(),f=e/2,g=e/20,h=e/3;c();a.translate(this.size,0);a.rotate(radians(90));c()}; +SymbolMorph.prototype.renderSymbolGrow=function(a,b){function c(){a.strokeStyle=b.toString();a.lineWidth=e/7;a.beginPath();a.moveTo(f-3*g,f+3*g);a.lineTo(2*g,d-2*g);a.stroke();a.strokeStyle=b.toString();a.lineWidth=e/7;a.beginPath();a.moveTo(f+3*g,f-3*g);a.lineTo(d-2*g,2*g);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,d);a.lineTo(0,d-k);a.lineTo(k,d);a.closePath();a.fill();a.fillStyle=b.toString();a.beginPath();a.moveTo(d,0);a.lineTo(d-k,0);a.lineTo(d,k);a.closePath();a.fill()}var d= +this.size,e=this.symbolWidth(),f=e/2,g=e/20,k=e/3;c();a.translate(this.size,0);a.rotate(radians(90));c()}; SymbolMorph.prototype.renderSymbolNormalScreen=function(a,b){var c=this.size,d=this.symbolWidth(),e=d/2,f=d/20;a.strokeStyle=b.toString();a.lineWidth=d/5;a.beginPath();a.moveTo(e-3*f,e+3*f);a.lineTo(f,c-f);a.stroke();a.strokeStyle=b.toString();a.lineWidth=d/5;a.beginPath();a.moveTo(e+3*f,e-3*f);a.lineTo(c-f,f);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(e+f,e-f);a.lineTo(d,e-f);a.lineTo(e+f,0);a.closePath();a.fill();a.fillStyle=b.toString();a.beginPath();a.moveTo(e-f,e+f);a.lineTo(0, e+f);a.lineTo(e-f,d);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolShrink=function(a,b){function c(){a.strokeStyle=b.toString();a.lineWidth=e/8;a.beginPath();a.moveTo(f-3*g,f+3*g);a.lineTo(g,d-g);a.stroke();a.strokeStyle=b.toString();a.lineWidth=e/8;a.beginPath();a.moveTo(f+3*g,f-3*g);a.lineTo(d-g,g);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(f+2*g,f-2*g);a.lineTo(e-g,f-2*g);a.lineTo(f+2*g,0+g);a.closePath();a.fill();a.fillStyle=b.toString();a.beginPath();a.moveTo(f-2*g,f+2*g);a.lineTo(0+g,f+2*g);a.lineTo(f-2*g,e- @@ -472,13 +472,13 @@ SymbolMorph.prototype.renderSymbolNormalStage=function(a,b){var c=this.symbolWid SymbolMorph.prototype.renderSymbolTurtleOutline=function(a,b){var c=this.symbolWidth(),d=this.size;a.strokeStyle=b.toString();a.beginPath();a.moveTo(0,0);a.lineTo(c,d/2);a.lineTo(0,d);a.lineTo(d/2,d/2);a.closePath();a.stroke()};SymbolMorph.prototype.renderSymbolPause=function(a,b){var c=this.symbolWidth()/5,d=this.size;a.fillStyle=b.toString();a.fillRect(0,0,2*c,d);a.fillRect(3*c,0,2*c,d)}; SymbolMorph.prototype.renderSymbolFlag=function(a,b){var c=this.symbolWidth(),d=this.size,e=Math.max(c/12,1);a.lineWidth=e;a.strokeStyle=b.toString();a.beginPath();a.moveTo(e/2,0);a.lineTo(e/2,d);a.stroke();a.lineWidth=d/2;a.beginPath();a.moveTo(0,d/4);a.bezierCurveTo(.8*c,d/4,.1*c,.5*d,c,.5*d);a.stroke()}; SymbolMorph.prototype.renderSymbolOctagon=function(a,b){var c=this.symbolWidth(),d=(c-.383*c)/2;a.fillStyle=b.toString();a.beginPath();a.moveTo(d,0);a.lineTo(c-d,0);a.lineTo(c,d);a.lineTo(c,c-d);a.lineTo(c-d,c);a.lineTo(d,c);a.lineTo(0,c-d);a.lineTo(0,d);a.closePath();a.fill()}; -SymbolMorph.prototype.renderSymbolCloud=function(a,b){var c=this.symbolWidth(),d=this.size,e=2*d/5,f=d/4,g=3*d/10,h=d/5;a.fillStyle=b.toString();a.beginPath();a.arc(f,d-f,f,radians(90),radians(259),!1);a.arc(c/20*5,d/9*4,h,radians(165),radians(300),!1);a.arc(c/20*11,e,e,radians(200),radians(357),!1);a.arc(c-g,d-g,g,radians(269),radians(90),!1);a.closePath();a.fill()}; -SymbolMorph.prototype.renderSymbolCloudGradient=function(a,b){var c=this.symbolWidth(),d=this.size,e=2*d/5,f=d/4,g=3*d/10,h=d/5;var m=a.createRadialGradient(0,0,0,0,0,c);m.addColorStop(0,b.lighter(25).toString());m.addColorStop(1,b.darker(25).toString());a.fillStyle=m;a.beginPath();a.arc(f,d-f,f,radians(90),radians(259),!1);a.arc(c/20*5,d/9*4,h,radians(165),radians(300),!1);a.arc(c/20*11,e,e,radians(200),radians(357),!1);a.arc(c-g,d-g,g,radians(269),radians(90),!1);a.closePath();a.fill()}; -SymbolMorph.prototype.renderSymbolCloudOutline=function(a,b){var c=this.symbolWidth(),d=this.size,e=2*d/5,f=d/4,g=3*d/10,h=d/5;a.strokeStyle=b.toString();a.beginPath();a.arc(f+1,d-f-1,f,radians(90),radians(180),!1);a.arc(c/20*5,d/9*4,h,radians(150),radians(300),!1);a.arc(c/20*11,e+1,e,radians(210),radians(335),!1);a.arc(c-g-1,d-g-1,g,radians(280),radians(90),!1);a.closePath();a.stroke()}; +SymbolMorph.prototype.renderSymbolCloud=function(a,b){var c=this.symbolWidth(),d=this.size,e=2*d/5,f=d/4,g=3*d/10,k=d/5;a.fillStyle=b.toString();a.beginPath();a.arc(f,d-f,f,radians(90),radians(259),!1);a.arc(c/20*5,d/9*4,k,radians(165),radians(300),!1);a.arc(c/20*11,e,e,radians(200),radians(357),!1);a.arc(c-g,d-g,g,radians(269),radians(90),!1);a.closePath();a.fill()}; +SymbolMorph.prototype.renderSymbolCloudGradient=function(a,b){var c=this.symbolWidth(),d=this.size,e=2*d/5,f=d/4,g=3*d/10,k=d/5;var m=a.createRadialGradient(0,0,0,0,0,c);m.addColorStop(0,b.lighter(25).toString());m.addColorStop(1,b.darker(25).toString());a.fillStyle=m;a.beginPath();a.arc(f,d-f,f,radians(90),radians(259),!1);a.arc(c/20*5,d/9*4,k,radians(165),radians(300),!1);a.arc(c/20*11,e,e,radians(200),radians(357),!1);a.arc(c-g,d-g,g,radians(269),radians(90),!1);a.closePath();a.fill()}; +SymbolMorph.prototype.renderSymbolCloudOutline=function(a,b){var c=this.symbolWidth(),d=this.size,e=2*d/5,f=d/4,g=3*d/10,k=d/5;a.strokeStyle=b.toString();a.beginPath();a.arc(f+1,d-f-1,f,radians(90),radians(180),!1);a.arc(c/20*5,d/9*4,k,radians(150),radians(300),!1);a.arc(c/20*11,e+1,e,radians(210),radians(335),!1);a.arc(c-g-1,d-g-1,g,radians(280),radians(90),!1);a.closePath();a.stroke()}; SymbolMorph.prototype.renderSymbolTurnRight=function(a,b){var c=this.symbolWidth(),d=Math.max(c/10,1),e=c/2;a.lineWidth=d;a.strokeStyle=b.toString();a.beginPath();a.arc(e,2*e,e-d/2,radians(0),radians(-90),!1);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(c,e);a.lineTo(e,0);a.lineTo(e,2*e);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolTurnLeft=function(a,b){var c=this.symbolWidth(),d=Math.max(c/10,1);c/=2;a.lineWidth=d;a.strokeStyle=b.toString();a.beginPath();a.arc(c,2*c,c-d/2,radians(180),radians(-90),!0);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,c);a.lineTo(c,0);a.lineTo(c,2*c);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolTurnAround=function(a,b){var c=this.symbolWidth(),d=Math.max(c/10,1);c/=2;a.lineWidth=d;a.strokeStyle=b.toString();a.beginPath();a.arc(c,c,c-d/2,radians(-45),radians(225),!1);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,.1*c);a.lineTo(.8*c,0);a.lineTo(.7*c,.7*c);a.closePath();a.fill()}; -SymbolMorph.prototype.renderSymbolStorage=function(a,b){function c(h){a.fillStyle=b.toString();a.beginPath();a.arc(d/2,h-e,f,radians(60),radians(120),!1);a.lineTo(0,h-2*g);a.arc(d/2,h-e-2*g,f,radians(120),radians(60),!0);a.closePath();a.fill();a.fillStyle=b.darker(25).toString();a.beginPath();a.arc(d/2,h+6*g+1,f,radians(-120),radians(-60),!1);a.stroke()}var d=this.symbolWidth(),e=this.size,f=e,g=e/11;a.strokeStyle=b.toString();c(e);c(e-3*g);c(e-6*g)}; +SymbolMorph.prototype.renderSymbolStorage=function(a,b){function c(k){a.fillStyle=b.toString();a.beginPath();a.arc(d/2,k-e,f,radians(60),radians(120),!1);a.lineTo(0,k-2*g);a.arc(d/2,k-e-2*g,f,radians(120),radians(60),!0);a.closePath();a.fill();a.fillStyle=b.darker(25).toString();a.beginPath();a.arc(d/2,k+6*g+1,f,radians(-120),radians(-60),!1);a.stroke()}var d=this.symbolWidth(),e=this.size,f=e,g=e/11;a.strokeStyle=b.toString();c(e);c(e-3*g);c(e-6*g)}; SymbolMorph.prototype.renderSymbolPoster=function(a,b){var c=this.symbolWidth(),d=this.size,e=.75*d,f=d/5;a.fillStyle=b.toString();a.strokeStyle=b.toString();a.lineWidth=c/15;a.beginPath();a.moveTo(c/2,d/3);a.lineTo(c/6,d);a.stroke();a.beginPath();a.moveTo(c/2,d/3);a.lineTo(c/2,d);a.stroke();a.beginPath();a.moveTo(c/2,d/3);a.lineTo(5*c/6,d);a.stroke();a.beginPath();a.moveTo(0,0);a.lineTo(c,0);a.lineTo(c,e-f);a.lineTo(c-f,e-f);a.lineTo(c-f,e);a.lineTo(0,e);a.closePath();a.fill();a.fillStyle=b.darker(25).toString(); a.beginPath();a.moveTo(c,e-f);a.lineTo(c-f,e-f);a.lineTo(c-f,e);a.closePath();a.fill()};SymbolMorph.prototype.renderSymbolFlash=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/3,f=d/3,g=f/3;a.fillStyle=b.toString();a.beginPath();a.moveTo(e,0);a.lineTo(0,f);a.lineTo(e,f);a.lineTo(0,2*f);a.lineTo(e,2*f);a.lineTo(0,d);a.lineTo(c,2*f-g);a.lineTo(2*e,2*f-g);a.lineTo(c,f-g);a.lineTo(2*e,f-g);a.lineTo(c,0);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolBrush=function(a,b){var c=this.symbolWidth(),d=this.size,e=Math.max(c/30,.5);a.fillStyle=b.toString();a.lineWidth=2*e;a.beginPath();a.moveTo(c/8*3,d/2);a.quadraticCurveTo(0,d/2,e,d-e);a.quadraticCurveTo(c/2,d,c/2,d/8*5);a.closePath();a.fill();a.lineJoin="round";a.lineCap="round";a.strokeStyle=b.toString();a.moveTo(c/8*3,d/2);a.lineTo(.75*c,e);a.quadraticCurveTo(c,0,c-e,.25*d);a.stroke();a.moveTo(c/2,d/8*5);a.lineTo(c-e,.25*d);a.stroke()}; @@ -493,7 +493,7 @@ SymbolMorph.prototype.renderSymbolEraser=function(a,b){var c=this.symbolWidth(), SymbolMorph.prototype.renderSymbolPipette=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/4,f=e/2;c=Math.max(c/20,.5);a.strokeStyle=b.toString();a.lineWidth=2*c;a.beginPath();a.moveTo(c,d-c);a.quadraticCurveTo(f,d-f,f,d-e);a.lineTo(2*e,1.5*e);a.stroke();a.beginPath();a.moveTo(c,d-c);a.quadraticCurveTo(f,d-f,e,d-f);a.lineTo(2.5*e,2*e);a.stroke();a.fillStyle=b.toString();a.arc(3*e,e,e-c,radians(0),radians(360),!1);a.fill();a.beginPath();a.moveTo(2*e,e);a.lineTo(3*e,2*e);a.stroke()}; SymbolMorph.prototype.renderSymbolSpeechBubble=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/3,f=Math.max(c/20,.5);a.fillStyle=b.toString();a.lineWidth=2*f;a.beginPath();a.moveTo(e,2*e);a.quadraticCurveTo(f,2*e,f,e);a.quadraticCurveTo(f,f,e,f);a.lineTo(2*e,f);a.quadraticCurveTo(c-f,f,c-f,e);a.quadraticCurveTo(c-f,2*e,2*e,2*e);a.lineTo(e/2,d-f);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolSpeechBubbleOutline=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/3,f=Math.max(c/20,.5);a.strokeStyle=b.toString();a.lineWidth=2*f;a.beginPath();a.moveTo(e,2*e);a.quadraticCurveTo(f,2*e,f,e);a.quadraticCurveTo(f,f,e,f);a.lineTo(2*e,f);a.quadraticCurveTo(c-f,f,c-f,e);a.quadraticCurveTo(c-f,2*e,2*e,2*e);a.lineTo(e/2,d-f);a.closePath();a.stroke()}; -SymbolMorph.prototype.renderSymbolLoop=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=e/2,g=d/2,h=Math.max(d/10,.5);a.lineWidth=2*h;a.strokeStyle=b.toString();a.beginPath();a.moveTo(0,d-h);a.lineTo(e,d-h);a.arc(e,g,g-h,radians(90),radians(0),!0);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(3*f-h,0);a.lineTo(e-h,g);a.lineTo(c,g);a.closePath();a.fill()}; +SymbolMorph.prototype.renderSymbolLoop=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=e/2,g=d/2,k=Math.max(d/10,.5);a.lineWidth=2*k;a.strokeStyle=b.toString();a.beginPath();a.moveTo(0,d-k);a.lineTo(e,d-k);a.arc(e,g,g-k,radians(90),radians(0),!0);a.stroke();a.fillStyle=b.toString();a.beginPath();a.moveTo(3*f-k,0);a.lineTo(e-k,g);a.lineTo(c,g);a.closePath();a.fill()}; SymbolMorph.prototype.renderSymbolTurnBack=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=d/2;c=Math.max(c/20,.5);a.fillStyle=b.toString();a.lineWidth=2*c;a.beginPath();a.moveTo(0,f);a.lineTo(e,0);a.lineTo(e,d);a.closePath();a.fill();a.lineWidth=3*c;a.strokeStyle=b.toString();a.beginPath();a.arc(e,d,f,radians(0),radians(-90),!0);a.stroke()}; SymbolMorph.prototype.renderSymbolTurnForward=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=d/2,g=Math.max(c/20,.5);a.fillStyle=b.toString();a.lineWidth=2*g;a.beginPath();a.moveTo(c,f);a.lineTo(e,0);a.lineTo(e,d);a.closePath();a.fill();a.lineWidth=3*g;a.strokeStyle=b.toString();a.beginPath();a.arc(e,d,f,radians(-180),radians(-90),!1);a.stroke()}; SymbolMorph.prototype.renderSymbolArrowUp=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=Math.max(c/20,.5);a.fillStyle=b.toString();a.lineWidth=2*f;a.beginPath();a.moveTo(f,e);a.lineTo(e,f);a.lineTo(c-f,e);a.lineTo(.65*c,e);a.lineTo(.65*c,d-f);a.lineTo(.35*c,d-f);a.lineTo(.35*c,e);a.closePath();a.fill()}; @@ -507,8 +507,8 @@ SymbolMorph.prototype.renderSymbolArrowRight=function(a,b){var c=this.symbolWidt SymbolMorph.prototype.renderSymbolArrowRightThin=function(a,b){var c=this.symbolWidth();a.save();a.translate(c,0);a.rotate(radians(90));this.renderSymbolArrowUpThin(a,b);a.restore()}; SymbolMorph.prototype.renderSymbolRobot=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/6,f=e/2,g=Math.max(c/20,.5);a.fillStyle=b.toString();a.beginPath();a.moveTo(e+g,e);a.lineTo(2*e,e);a.lineTo(2.5*e,1.5*e);a.lineTo(3.5*e,1.5*e);a.lineTo(4*e,e);a.lineTo(5*e-g,e);a.lineTo(4*e,3*e);a.lineTo(4*e,4*e-g);a.lineTo(2*e,4*e-g);a.lineTo(2*e,3*e);a.closePath();a.fill();a.beginPath();a.moveTo(2.75*e,e+g);a.lineTo(2.4*e,e);a.lineTo(2.2*e,0);a.lineTo(3.8*e,0);a.lineTo(3.6*e,e);a.lineTo(3.25*e,e+g);a.closePath(); a.fill();a.beginPath();a.moveTo(2.5*e,4*e);a.lineTo(e,4*e);a.lineTo(f+g,d);a.lineTo(2*e,d);a.closePath();a.fill();a.beginPath();a.moveTo(3.5*e,4*e);a.lineTo(5*e,4*e);a.lineTo(c-(f+g),d);a.lineTo(4*e,d);a.closePath();a.fill();a.beginPath();a.moveTo(e,e);a.lineTo(g,1.5*e);a.lineTo(g,3.25*e);a.lineTo(1.5*e,3.5*e);a.closePath();a.fill();a.beginPath();a.moveTo(5*e,e);a.lineTo(c-g,1.5*e);a.lineTo(c-g,3.25*e);a.lineTo(4.5*e,3.5*e);a.closePath();a.fill()}; -SymbolMorph.prototype.renderSymbolMagnifyingGlass=function(a,b){var c=this.symbolWidth(),d=this.size,e=.3*c,f=2*c/3-Math.sqrt(e),g=d/3+Math.sqrt(e),h=Math.max(c/5,.5);a.strokeStyle=b.toString();c=a.createRadialGradient(f,g,0,f+e,g+e,c);c.addColorStop(0,b.inverted().lighter(50).toString());c.addColorStop(1,b.inverted().darker(25).toString());a.fillStyle=c;a.beginPath();a.arc(f,g,e,radians(0),radians(360),!1);a.fill();a.lineWidth=h/2;a.beginPath();a.arc(f,g,e,radians(0),radians(360),!1);a.stroke(); -a.lineWidth=h;a.beginPath();a.moveTo(h/2,d-h/2);a.lineTo(f-Math.sqrt(e+h),g+Math.sqrt(e+h));a.closePath();a.stroke()}; +SymbolMorph.prototype.renderSymbolMagnifyingGlass=function(a,b){var c=this.symbolWidth(),d=this.size,e=.3*c,f=2*c/3-Math.sqrt(e),g=d/3+Math.sqrt(e),k=Math.max(c/5,.5);a.strokeStyle=b.toString();c=a.createRadialGradient(f,g,0,f+e,g+e,c);c.addColorStop(0,b.inverted().lighter(50).toString());c.addColorStop(1,b.inverted().darker(25).toString());a.fillStyle=c;a.beginPath();a.arc(f,g,e,radians(0),radians(360),!1);a.fill();a.lineWidth=k/2;a.beginPath();a.arc(f,g,e,radians(0),radians(360),!1);a.stroke(); +a.lineWidth=k;a.beginPath();a.moveTo(k/2,d-k/2);a.lineTo(f-Math.sqrt(e+k),g+Math.sqrt(e+k));a.closePath();a.stroke()}; SymbolMorph.prototype.renderSymbolMagnifierOutline=function(a,b){var c=this.symbolWidth(),d=this.size,e=.3*c,f=2*c/3-Math.sqrt(e),g=d/3+Math.sqrt(e);c=Math.max(c/5,.5);a.strokeStyle=b.toString();a.lineWidth=.5*c;a.beginPath();a.arc(f,g,e,radians(0),radians(360),!1);a.stroke();a.lineWidth=c;a.beginPath();a.moveTo(c/2,d-c/2);a.lineTo(f-Math.sqrt(e+c),g+Math.sqrt(e+c));a.closePath();a.stroke()}; SymbolMorph.prototype.renderSymbolSelection=function(a,b){var c=this.symbolWidth(),d=this.size;a.save();a.setLineDash([3]);this.renderSymbolRectangle(a,b);a.restore();a.save();a.fillStyle=b.toString();a.translate(.7*c,.4*d);a.scale(.5,.5);a.rotate(radians(135));this.renderSymbolArrowDownOutline(a,b);a.fill();a.restore()}; SymbolMorph.prototype.renderSymbolOctagonOutline=function(a,b){var c=this.symbolWidth(),d=(c-.383*c)/2,e=Math.max(c/20,.5);a.strokeStyle=b.toString();a.lineWidth=2*e;a.beginPath();a.moveTo(d,e);a.lineTo(c-d,e);a.lineTo(c-e,d);a.lineTo(c-e,c-d);a.lineTo(c-d,c-e);a.lineTo(d,c-e);a.lineTo(e,c-d);a.lineTo(e,d);a.closePath();a.stroke()};SymbolMorph.prototype.renderSymbolClosedBrushPath=SymbolMorph.prototype.renderSymbolCloudOutline; @@ -523,8 +523,8 @@ SymbolMorph.prototype.renderSymbolGlobe=function(a,b,c){var d=this.symbolWidth() SymbolMorph.prototype.renderSymbolFlipHorizontal=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/2,f=c/15;a.strokeStyle=b.toString();a.lineWidth=c/15;a.beginPath();a.moveTo(0+f,d-f/2);a.lineTo(e-1.2*f,d-f/2);a.lineTo(e-1.2*f,2*f);a.closePath();a.stroke();a.fillStyle=b.toString();a.lineWidth=c/15;a.beginPath();a.moveTo(c-f,d-f/2);a.lineTo(e+1.2*f,d-f/2);a.lineTo(e+1.2*f,2*f);a.closePath();a.stroke();a.fill()}; SymbolMorph.prototype.renderSymbolFlipVertical=function(a,b){a.translate(0,this.size);a.rotate(radians(-90));this.renderSymbolFlipHorizontal(a,b)}; SymbolMorph.prototype.renderSymbolNetsBloxLogo=function(a,b){var c=this.symbolWidth(),d=this.size,e=c/14,f=c-2*e;a.beginPath();a.arc(c/2,d/2,2*e,radians(180),radians(270));a.strokeStyle=b.toString();a.beginPath();a.arc(c/2,d/2,e,0,radians(360));a.stroke();a.beginPath();a.arc(c/2,d/2,2*e,0,radians(90));a.stroke();a.beginPath();a.arc(c/2,d/2,3*e,0,radians(90));a.stroke();a.beginPath();a.arc(c/2,d/2,2*e,radians(180),radians(270));a.stroke();a.beginPath();a.arc(c/2,d/2,3*e,radians(180),radians(270)); -a.stroke();b=-60;let g=e;d/=2;f/=2;for(c=f-2*e-c/48;300>b;){var h=g,m=d,l=radians(b);const k=c*Math.cos(l),n=c*Math.sin(l),p=e*Math.cos(l)+h,q=e*Math.sin(l)+m;a.beginPath();a.arc(h,m,e,l,l+2*Math.PI);a.moveTo(p,q);a.lineTo(h+k,m+n);a.stroke();g+=f*Math.cos(radians(b));d+=f*Math.sin(radians(b));b+=60}}; -SymbolMorph.prototype.renderSymbolQueue=function(a,b){var c=this.symbolWidth()/5,d=c/2,e=3*c,f=1*d+e/2,g=d;a.fillStyle=b.toString();var h=function(m){m+=c;var l=e/2;a.fillStyle=b.toString();a.beginPath();a.moveTo(m,f);a.lineTo(m+-1*c,f+l/2);a.lineTo(m+-1*c,f-l/2);a.fill()};h(g);g+=c+d;a.fillRect(g,d,c,e);g+=c+d;a.fillRect(g,d,c,e);h(g+(c+d))}; +a.stroke();b=-60;let g=e;d/=2;f/=2;for(c=f-2*e-c/48;300>b;){var k=g,m=d,l=radians(b);const h=c*Math.cos(l),n=c*Math.sin(l),p=e*Math.cos(l)+k,q=e*Math.sin(l)+m;a.beginPath();a.arc(k,m,e,l,l+2*Math.PI);a.moveTo(p,q);a.lineTo(k+h,m+n);a.stroke();g+=f*Math.cos(radians(b));d+=f*Math.sin(radians(b));b+=60}}; +SymbolMorph.prototype.renderSymbolQueue=function(a,b){var c=this.symbolWidth()/5,d=c/2,e=3*c,f=1*d+e/2,g=d;a.fillStyle=b.toString();var k=function(m){m+=c;var l=e/2;a.fillStyle=b.toString();a.beginPath();a.moveTo(m,f);a.lineTo(m+-1*c,f+l/2);a.lineTo(m+-1*c,f-l/2);a.fill()};k(g);g+=c+d;a.fillRect(g,d,c,e);g+=c+d;a.fillRect(g,d,c,e);k(g+(c+d))}; SymbolMorph.prototype.renderSymbolMail=function(a,b){var c=this.symbolWidth(),d=this.size;a.lineWidth=Math.max(c/12,1);a.fillStyle=b.toString();a.strokeStyle=b.darker(50).toString();a.fillRect(0,0,c,d);a.rect(0,0,c,d);a.moveTo(0,0);a.lineTo(c/2,2*d/3);a.lineTo(c,0);a.stroke()}; SymbolMorph.prototype.renderSymbolEncircledCircle=function(a,b){var c=this.symbolWidth(),d=Math.max(c/30,.5);a.strokeStyle=b.toString();a.fillStyle=b.toString();a.beginPath();a.arc(c/2,c/2,c/4,radians(0),radians(360),!1);a.fill();a.beginPath();a.lineWidth=2*d;a.arc(c/2,c/2,c/2-d,radians(0),radians(360),!1);a.stroke()}; SymbolMorph.prototype.renderSymbolJumpForward=function(a,b){var c=3/7*this.symbolWidth(),d=4/7*this.size,e=1.5/7*this.size,f=1/7*this.symbolWidth();a.fillStyle=b.toString();a.beginPath();a.moveTo(0,e);a.lineTo(c,e+Math.round(d/2));a.lineTo(0,e+d);a.lineTo(0,e);a.closePath();a.fill();a.beginPath();a.moveTo(c,e);a.lineTo(2*c,e+Math.round(d/2));a.lineTo(c,e+d);a.lineTo(c,e);a.closePath();a.fill();a.fillRect(2*c,e,f,d)}; @@ -541,16 +541,16 @@ PushButtonMorph.prototype.render=function(a){"highlight"===this.userState?(this. this.color),this.drawEdges(a,this.color,this.color.lighter(this.contrast),this.color.darker(this.contrast)))}; PushButtonMorph.prototype.drawOutline=function(a){var b=MorphicPreferences.isFlat&&!this.is3D;if(!this.outline||b)return null;if(this.outlineGradient){var c=a.createLinearGradient(0,0,0,this.height());c.addColorStop(0,this.outlineColor.darker().toString());c.addColorStop(1,"white")}else c=this.outlineColor.toString();a.fillStyle=c;a.beginPath();this.outlinePath(a,b?0:this.corner,0);a.closePath();a.fill()}; PushButtonMorph.prototype.drawBackground=function(a,b){var c=MorphicPreferences.isFlat&&!this.is3D;a.fillStyle=b.toString();a.beginPath();this.outlinePath(a,c?0:Math.max(this.corner-this.outline,0),this.outline);a.closePath();a.fill();a.lineWidth=this.outline}; -PushButtonMorph.prototype.drawEdges=function(a,b,c,d){if(!MorphicPreferences.isFlat||this.is3D){var e=Math.max(this.corner,this.outline+this.edge),f=this.width(),g=this.height();var h=a.createLinearGradient(0,this.outline,0,this.outline+this.edge);h.addColorStop(0,c.toString());h.addColorStop(1,b.toString());a.strokeStyle=h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(e,this.outline+this.edge/2);a.lineTo(f-e,this.outline+this.edge/2);a.stroke();h=a.createRadialGradient(this.corner, -this.corner,Math.max(this.corner-this.outline-this.edge,0),this.corner,this.corner,Math.max(this.corner-this.outline,0));h.addColorStop(0,b.toString());h.addColorStop(1,c.toString());a.strokeStyle=h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.arc(this.corner,this.corner,Math.max(this.corner-this.outline-this.edge/2,0),radians(180),radians(270),!1);a.stroke();h=a.createLinearGradient(this.outline,0,this.outline+this.edge,0);h.addColorStop(0,c.toString());h.addColorStop(1,b.toString()); -a.strokeStyle=h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(this.outline+this.edge/2,e);a.lineTo(this.outline+this.edge/2,g-e);a.stroke();h=a.createLinearGradient(0,g-this.outline,0,g-this.outline-this.edge);h.addColorStop(0,d.toString());h.addColorStop(1,b.toString());a.strokeStyle=h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(e,g-this.outline-this.edge/2);a.lineTo(f-e,g-this.outline-this.edge/2);a.stroke();h=a.createRadialGradient(f-this.corner,g-this.corner, -Math.max(this.corner-this.outline-this.edge,0),f-this.corner,g-this.corner,Math.max(this.corner-this.outline,0));h.addColorStop(0,b.toString());h.addColorStop(1,d.toString());a.strokeStyle=h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.arc(f-this.corner,g-this.corner,Math.max(this.corner-this.outline-this.edge/2,0),radians(0),radians(90),!1);a.stroke();h=a.createLinearGradient(f-this.outline,0,f-this.outline-this.edge,0);h.addColorStop(0,d.toString());h.addColorStop(1,b.toString());a.strokeStyle= -h;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(f-this.outline-this.edge/2,e);a.lineTo(f-this.outline-this.edge/2,g-e);a.stroke()}};PushButtonMorph.prototype.outlinePath=BoxMorph.prototype.outlinePath; +PushButtonMorph.prototype.drawEdges=function(a,b,c,d){if(!MorphicPreferences.isFlat||this.is3D){var e=Math.max(this.corner,this.outline+this.edge),f=this.width(),g=this.height();var k=a.createLinearGradient(0,this.outline,0,this.outline+this.edge);k.addColorStop(0,c.toString());k.addColorStop(1,b.toString());a.strokeStyle=k;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(e,this.outline+this.edge/2);a.lineTo(f-e,this.outline+this.edge/2);a.stroke();k=a.createRadialGradient(this.corner, +this.corner,Math.max(this.corner-this.outline-this.edge,0),this.corner,this.corner,Math.max(this.corner-this.outline,0));k.addColorStop(0,b.toString());k.addColorStop(1,c.toString());a.strokeStyle=k;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.arc(this.corner,this.corner,Math.max(this.corner-this.outline-this.edge/2,0),radians(180),radians(270),!1);a.stroke();k=a.createLinearGradient(this.outline,0,this.outline+this.edge,0);k.addColorStop(0,c.toString());k.addColorStop(1,b.toString()); +a.strokeStyle=k;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(this.outline+this.edge/2,e);a.lineTo(this.outline+this.edge/2,g-e);a.stroke();k=a.createLinearGradient(0,g-this.outline,0,g-this.outline-this.edge);k.addColorStop(0,d.toString());k.addColorStop(1,b.toString());a.strokeStyle=k;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(e,g-this.outline-this.edge/2);a.lineTo(f-e,g-this.outline-this.edge/2);a.stroke();k=a.createRadialGradient(f-this.corner,g-this.corner, +Math.max(this.corner-this.outline-this.edge,0),f-this.corner,g-this.corner,Math.max(this.corner-this.outline,0));k.addColorStop(0,b.toString());k.addColorStop(1,d.toString());a.strokeStyle=k;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.arc(f-this.corner,g-this.corner,Math.max(this.corner-this.outline-this.edge/2,0),radians(0),radians(90),!1);a.stroke();k=a.createLinearGradient(f-this.outline,0,f-this.outline-this.edge,0);k.addColorStop(0,d.toString());k.addColorStop(1,b.toString());a.strokeStyle= +k;a.lineCap="round";a.lineWidth=this.edge;a.beginPath();a.moveTo(f-this.outline-this.edge/2,e);a.lineTo(f-this.outline-this.edge/2,g-e);a.stroke()}};PushButtonMorph.prototype.outlinePath=BoxMorph.prototype.outlinePath; PushButtonMorph.prototype.createLabel=function(){var a=!MorphicPreferences.isFlat||this.is3D;null!==this.label&&this.label.destroy();this.labelString instanceof SymbolMorph?(this.label=this.labelString.fullCopy(),a&&(this.label.shadowOffset=this.labelShadowOffset,this.label.shadowColor=this.labelShadowColor),this.label.color=this.labelColor):this.label=new StringMorph(localize(this.labelString),this.fontSize,this.fontStyle,!0,!1,!1,a?this.labelShadowOffset:null,this.labelShadowColor,this.labelColor); this.add(this.label)};PushButtonMorph.prototype.trigger=function(){this.isDisabled||PushButtonMorph.uber.trigger.call(this)};PushButtonMorph.prototype.mouseDownLeft=function(){this.isDisabled||PushButtonMorph.uber.mouseDownLeft.call(this)};PushButtonMorph.prototype.mouseClickLeft=function(){this.isDisabled||PushButtonMorph.uber.mouseClickLeft.call(this)};PushButtonMorph.prototype.isEnabled=function(){return!this.isDisabled}; PushButtonMorph.prototype.updateLabelColors=function(){var a=!MorphicPreferences.isFlat||this.is3D;this.label&&(this.label.color=this.labelColor,this.label.fontSize=this.fontSize,a&&(this.label.shadowOffset=this.labelShadowOffset,this.label.shadowColor=this.labelShadowColor),this.label.fixLayout(!0))};PushButtonMorph.prototype.disable=function(){this.isDisabled=!0;this.forAllChildren(a=>a.alpha=.3);this.rerender()}; -PushButtonMorph.prototype.enable=function(){this.isDisabled=!1;this.forAllChildren(a=>a.alpha=1);this.rerender()};ToggleButtonMorph.prototype=new PushButtonMorph;ToggleButtonMorph.prototype.constructor=ToggleButtonMorph;ToggleButtonMorph.uber=PushButtonMorph.prototype;ToggleButtonMorph.prototype.contrast=30;ToggleButtonMorph.prototype.labelPressColor=null;function ToggleButtonMorph(a,b,c,d,e,f,g,h,m,l){this.init(a,b,c,d,e,f,g,h,m,l)} -ToggleButtonMorph.prototype.init=function(a,b,c,d,e,f,g,h,m,l){this.state=!1;this.query=e||(()=>!0);this.minWidth=h||null;this.hasPreview=m||!1;this.isPicture=l||!1;this.hasNeutralBackground=!1;this.trueStateLabel=null;ToggleButtonMorph.uber.init.call(this,b,c,d,f,g);a&&(this.color=a[0],this.highlightColor=a[1],this.pressColor=a[2]);this.refresh();this.rerender()}; +PushButtonMorph.prototype.enable=function(){this.isDisabled=!1;this.forAllChildren(a=>a.alpha=1);this.rerender()};ToggleButtonMorph.prototype=new PushButtonMorph;ToggleButtonMorph.prototype.constructor=ToggleButtonMorph;ToggleButtonMorph.uber=PushButtonMorph.prototype;ToggleButtonMorph.prototype.contrast=30;ToggleButtonMorph.prototype.labelPressColor=null;function ToggleButtonMorph(a,b,c,d,e,f,g,k,m,l){this.init(a,b,c,d,e,f,g,k,m,l)} +ToggleButtonMorph.prototype.init=function(a,b,c,d,e,f,g,k,m,l){this.state=!1;this.query=e||(()=>!0);this.minWidth=k||null;this.hasPreview=m||!1;this.isPicture=l||!1;this.hasNeutralBackground=!1;this.trueStateLabel=null;ToggleButtonMorph.uber.init.call(this,b,c,d,f,g);a&&(this.color=a[0],this.highlightColor=a[1],this.pressColor=a[2]);this.refresh();this.rerender()}; ToggleButtonMorph.prototype.mouseEnter=function(){var a=this.hint instanceof Function?this.hint():this.hint;if(!this.state||this.hasNeutralBackground)this.userState="highlight",this.rerender();a&&this.bubbleHelp(a)};ToggleButtonMorph.prototype.mouseLeave=function(){if(!this.state||this.hasNeutralBackground)this.userState="normal",this.rerender();this.schedule&&(this.schedule.isActive=!1);this.hint&&this.world().hand.destroyTemporaries()}; ToggleButtonMorph.prototype.mouseDownLeft=function(){this.state||(this.userState="pressed",this.rerender())};ToggleButtonMorph.prototype.mouseClickLeft=function(){this.state||(this.userState="highlight",this.rerender());this.trigger()};ToggleButtonMorph.prototype.trigger=function(){ToggleButtonMorph.uber.trigger.call(this);this.refresh()}; ToggleButtonMorph.prototype.refresh=function(){(this.state="function"===typeof this.query?this.query.call(this.target):this.target[this.query]())?(this.userState="pressed",this.labelPressColor&&this.label.setColor(this.labelPressColor),this.trueStateLabel&&(this.label.hide(),this.trueStateLabel.show())):(this.userState="normal",this.labelPressColor&&this.label.setColor(this.labelColor),this.trueStateLabel&&(this.label.show(),this.trueStateLabel.hide()));this.rerender()}; @@ -567,17 +567,17 @@ this.label.rerender())):this.label=this.labelString instanceof Morph?this.labelS ToggleButtonMorph.prototype.updateLabelColors=function(){var a=!MorphicPreferences.isFlat||this.is3D;ToggleButtonMorph.uber.updateLabelColors.call(this);this.trueStateLabel&&(this.trueStateLabel.color=this.labelColor,a&&(this.trueStateLabel.shadowOffset=this.labelShadowOffset,this.trueStateLabel.shadowColor=this.labelShadowColor),this.trueStateLabel.fixLayout(!0))};TabMorph.prototype=new ToggleButtonMorph;TabMorph.prototype.constructor=TabMorph;TabMorph.uber=ToggleButtonMorph.prototype; function TabMorph(a,b,c,d,e,f,g){this.init(a,b,c,d,e,f,g)}TabMorph.prototype.fixLayout=function(){null!==this.label&&(this.updateLabelColors(),this.setExtent(new Point(this.label.width()+2*this.padding+3*this.corner+2*this.edge,(this.label instanceof StringMorph?this.label.rawHeight():this.label.height())+2*this.padding+this.edge)),this.label.setCenter(this.center()))};TabMorph.prototype.refresh=function(){this.state&&this.parent&&this.parent.add(this);TabMorph.uber.refresh.call(this)}; TabMorph.prototype.drawBackground=function(a,b){var c=this.width(),d=this.height(),e=this.corner;a.fillStyle=b.toString();a.beginPath();a.moveTo(0,d);a.bezierCurveTo(e,d,e,0,2*e,0);a.lineTo(c-2*e,0);a.bezierCurveTo(c-e,0,c-e,d,c,d);a.closePath();a.fill()};TabMorph.prototype.drawOutline=function(){nop()}; -TabMorph.prototype.drawEdges=function(a,b,c,d){if(!MorphicPreferences.isFlat||this.is3D){var e=this.width(),f=this.height(),g=this.corner,h=this.edge,m=h/2;nop(b);b=a.createLinearGradient(0,0,e,0);b.addColorStop(0,c.toString());b.addColorStop(1,d.toString());a.strokeStyle=b;a.lineCap="round";a.lineWidth=h;a.beginPath();a.moveTo(0,f+m);a.bezierCurveTo(g,f,g,0,2*g,m);a.lineTo(e-2*g,m);a.bezierCurveTo(e-g,0,e-g,f,e,f+m);a.stroke()}};ToggleMorph.prototype=new PushButtonMorph; -ToggleMorph.prototype.constructor=ToggleMorph;ToggleMorph.uber=PushButtonMorph.prototype;function ToggleMorph(a,b,c,d,e,f,g,h,m){this.init(a,b,c,d,e,f,g,h,m)} -ToggleMorph.prototype.init=function(a,b,c,d,e,f,g,h,m){this.padding=1;a=a||"checkbox";this.corner="checkbox"===a?0:fontHeight(this.fontSize)/2+this.outline+this.padding;this.state=!1;this.query=e||(()=>!0);this.tick=null;this.captionString=d||null;this.labelAlignment="right";this.element=h||null;this.builder=m||null;this.toggleElement=null;ToggleMorph.uber.init.call(this,b,c,"checkbox"===a?"\u2713":"\u25cf",f,g);this.fixLayout();this.refresh()}; +TabMorph.prototype.drawEdges=function(a,b,c,d){if(!MorphicPreferences.isFlat||this.is3D){var e=this.width(),f=this.height(),g=this.corner,k=this.edge,m=k/2;nop(b);b=a.createLinearGradient(0,0,e,0);b.addColorStop(0,c.toString());b.addColorStop(1,d.toString());a.strokeStyle=b;a.lineCap="round";a.lineWidth=k;a.beginPath();a.moveTo(0,f+m);a.bezierCurveTo(g,f,g,0,2*g,m);a.lineTo(e-2*g,m);a.bezierCurveTo(e-g,0,e-g,f,e,f+m);a.stroke()}};ToggleMorph.prototype=new PushButtonMorph; +ToggleMorph.prototype.constructor=ToggleMorph;ToggleMorph.uber=PushButtonMorph.prototype;function ToggleMorph(a,b,c,d,e,f,g,k,m){this.init(a,b,c,d,e,f,g,k,m)} +ToggleMorph.prototype.init=function(a,b,c,d,e,f,g,k,m){this.padding=1;a=a||"checkbox";this.corner="checkbox"===a?0:fontHeight(this.fontSize)/2+this.outline+this.padding;this.state=!1;this.query=e||(()=>!0);this.tick=null;this.captionString=d||null;this.labelAlignment="right";this.element=k||null;this.builder=m||null;this.toggleElement=null;ToggleMorph.uber.init.call(this,b,c,"checkbox"===a?"\u2713":"\u25cf",f,g);this.fixLayout();this.refresh()}; ToggleMorph.prototype.fixLayout=function(){var a=2*this.padding+2*this.outline;null!==this.tick&&(this.bounds.setHeight(this.tick.rawHeight()+a),this.bounds.setWidth(this.tick.width()+a),this.bounds.setWidth(Math.max(this.width(),this.height())),this.bounds.setHeight(Math.max(this.width(),this.height())),this.tick.setCenter(this.center()));this.state?this.tick.show():this.tick.hide();if(this.toggleElement&&"right"===this.labelAlignment){var b=this.top()+(this.height()-this.toggleElement.height())/ 2;this.toggleElement.setPosition(new Point(this.right()+a,b))}null!==this.label&&(b=this.top()+(this.height()-this.label.height())/2,"right"===this.labelAlignment?this.label.setPosition(new Point(this.toggleElement?this.toggleElement instanceof ToggleElementMorph?this.toggleElement.right():this.toggleElement.right()+a:this.right()+a,b)):this.label.setPosition(new Point(this.left()-this.label.width()-a,b)))}; ToggleMorph.prototype.createLabel=function(){var a=!MorphicPreferences.isFlat||this.is3D;null===this.label&&this.captionString&&(this.label=new TextMorph(localize(this.captionString),this.fontSize,this.fontStyle,!0),this.add(this.label));null===this.tick&&(this.tick=new StringMorph(localize(this.labelString),this.fontSize,this.fontStyle,!0,!1,!1,a?new Point(1,1):null,new Color(240,240,240)),this.add(this.tick));null===this.toggleElement&&this.element&&(this.element instanceof Morph?this.toggleElement= new ToggleElementMorph(this.target,this.action,this.element,this.query,this.environment,this.hint,this.builder):this.element instanceof HTMLCanvasElement&&(this.toggleElement=new Morph,this.toggleElement.isCachingImage=!0,this.toggleElement.bounds.setExtent(new Point(this.element.width,this.element.height)),this.toggleElement.cachedImage=this.element),this.add(this.toggleElement))};ToggleMorph.prototype.trigger=function(){ToggleMorph.uber.trigger.call(this);this.refresh()}; ToggleMorph.prototype.refresh=function(){(this.state="function"===typeof this.query?this.query.call(this.target):this.target[this.query]())?this.tick.show():this.tick.hide();this.toggleElement&&this.toggleElement.refresh&&this.toggleElement.refresh()};ToggleMorph.prototype.mouseDownLeft=function(){PushButtonMorph.uber.mouseDownLeft.call(this);this.tick&&this.tick.setCenter(this.center().add(1))}; ToggleMorph.prototype.mouseClickLeft=function(){PushButtonMorph.uber.mouseClickLeft.call(this);this.tick&&this.tick.setCenter(this.center())};ToggleMorph.prototype.mouseLeave=function(){PushButtonMorph.uber.mouseLeave.call(this);this.tick&&this.tick.setCenter(this.center())};ToggleElementMorph.prototype=new TriggerMorph;ToggleElementMorph.prototype.constructor=ToggleElementMorph;ToggleElementMorph.uber=TriggerMorph.prototype;ToggleElementMorph.prototype.contrast=50; -ToggleElementMorph.prototype.shadowOffset=new Point(2,2);ToggleElementMorph.prototype.shadowAlpha=.6;ToggleElementMorph.prototype.fontSize=10;ToggleElementMorph.prototype.inactiveColor=new Color(180,180,180);function ToggleElementMorph(a,b,c,d,e,f,g,h){this.init(a,b,c,d,e,f,g,h)} -ToggleElementMorph.prototype.init=function(a,b,c,d,e,f,g,h){this.target=a||null;this.action=b||null;this.element=c;this.query=d||(()=>!0);this.environment=e||null;this.hint=f||null;this.builder=g||"nop";this.captionString=h||null;this.labelAlignment="right";this.state=!1;TriggerMorph.uber.init.call(this);this.color=c.color;this.createLabel()}; +ToggleElementMorph.prototype.shadowOffset=new Point(2,2);ToggleElementMorph.prototype.shadowAlpha=.6;ToggleElementMorph.prototype.fontSize=10;ToggleElementMorph.prototype.inactiveColor=new Color(180,180,180);function ToggleElementMorph(a,b,c,d,e,f,g,k){this.init(a,b,c,d,e,f,g,k)} +ToggleElementMorph.prototype.init=function(a,b,c,d,e,f,g,k){this.target=a||null;this.action=b||null;this.element=c;this.query=d||(()=>!0);this.environment=e||null;this.hint=f||null;this.builder=g||"nop";this.captionString=k||null;this.labelAlignment="right";this.state=!1;TriggerMorph.uber.init.call(this);this.color=c.color;this.createLabel()}; ToggleElementMorph.prototype.render=function(a){var b=!MorphicPreferences.isFlat||this.is3D,c=()=>{b&&this.element.addShadow(this.shadowOffset,"normal"===this.userState?0:this.shadowAlpha)};this.color=this.element.color;this.element.removeShadow();this.element[this.builder]();"pressed"!==this.userState&&(this.element.removeShadow(),this.element.setColor(this.inactiveColor),this.element[this.builder](this.contrast),"highlight"===this.userState&&(this.element.removeShadow(),this.element.setColor(this.color.lighter(this.contrast)), this.element[this.builder](this.contrast)));this.element.doWithAlpha?a.drawImage(this.element.doWithAlpha(1,()=>{c();return this.element.fullImage()}),0,0):(c(),a.drawImage(this.element.fullImage(),0,0));this.element.removeShadow();this.element.setColor(this.color);this.element[this.builder]()};ToggleElementMorph.prototype.setColor=function(a){this.element.setColor(a);this.fixLayout();this.refresh()}; ToggleElementMorph.prototype.fixLayout=function(){this.element.fixLayout();this.bounds.setExtent(this.element.fullBounds().extent().add(2*this.shadowBlur))}; @@ -588,24 +588,24 @@ DialogBoxMorph.prototype.buttonFontSize=12;DialogBoxMorph.prototype.buttonCorner DialogBoxMorph.prototype.init=function(a,b,c){this.is3D=!1;this.target=a||null;this.action=b||null;this.environment=c||null;this.buttons=this.body=this.head=this.label=this.labelString=this.key=null;DialogBoxMorph.uber.init.call(this);this.noDropShadow=this.isDraggable=!0;this.fullShadowSource=!1;this.color=PushButtonMorph.prototype.color;this.createLabel();this.createButtons();this.setExtent(new Point(300,150))}; DialogBoxMorph.prototype.inform=function(a,b,c,d){var e=new TextMorph(b,this.fontSize,this.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);this.key||(this.key="inform"+a+b);e.enableLinks=!0;this.labelString=a;this.createLabel();d&&this.setPicture(d);b&&this.addBody(e);this.addButton("ok","OK");this.fixLayout();this.popUp(c)}; DialogBoxMorph.prototype.askYesNo=function(a,b,c,d){var e=new TextMorph(b,this.fontSize,this.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);this.key||(this.key="decide"+a+b);this.labelString=a;this.createLabel();d&&this.setPicture(d);this.addBody(e);this.addButton("ok","Yes");this.addButton("cancel","No");this.fixLayout();this.popUp(c)}; -DialogBoxMorph.prototype.prompt=function(a,b,c,d,e,f,g,h,m,l,k=2){var n=Math.pow(10,k),p=new InputFieldMorph(b,g||!1,e||null,e?f||!1:!1);p.setWidth(250);if(g){if(d){var q=new AlignmentMorph("column",this.padding);d.setPosition(q.position());q.add(d)}if(!isNil(h)&&!isNil(m)){var r=new SliderMorph(h*n,m*n,parseFloat(b)*n,(m-h)/10*n,"horizontal");r.alpha=1;r.color=this.color.lighter(50);r.setHeight(.7*p.height());r.setWidth(p.width());r.action=t=>{l&&l(t/n);p.setContents(t/n);p.edit()};q||=new AlignmentMorph("column", -this.padding);q.add(r)}q&&(q.fixLayout(),this.setPicture(q),q.fixLayout())}else d&&this.setPicture(d);this.reactToChoice=function(t){r&&(r.value=t*n,r.fixLayout(),r.rerender());l&&l(t)};p.reactToInput=function(){var t=p.getValue();r&&(t=Math.max(t,h),r.value=t*n,r.fixLayout(),r.rerender());l&&l(t)};this.labelString=a;this.createLabel();this.key||(this.key="prompt"+a+b);this.addBody(p);p.fixLayout();this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c)}; -DialogBoxMorph.prototype.promptCode=function(a,b,c,d,e){var f=new ScrollFrameMorph,g=new TextMorph(b||""),h=new AlignmentMorph("column",this.padding),m=d?Math.max(d.width,400):400;this.getInput=function(){return g.text};f.padding=6;f.setWidth(m);f.acceptsDrops=!1;f.contents.acceptsDrops=!1;g.fontName="monospace";g.fontStyle="monospace";g.fontSize=11;g.setPosition(f.topLeft().add(f.padding));g.enableSelecting();g.isEditable=!0;f.setHeight(m/4);f.fixLayout=nop;f.edge=InputFieldMorph.prototype.edge; -f.fontSize=InputFieldMorph.prototype.fontSize;f.typeInPadding=InputFieldMorph.prototype.typeInPadding;f.contrast=InputFieldMorph.prototype.contrast;f.render=InputFieldMorph.prototype.render;f.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;f.addContents(g);g.fixLayout();d&&this.setPicture(d);this.labelString=a;this.createLabel();this.key||(this.key="promptCode"+a+b);h.setColor(this.color);h.add(f);e&&h.add(new TextMorph(localize(e),10,null,!1,null,null,null,null,MorphicPreferences.isFlat? -null:new Point(1,1),WHITE));h.fixLayout();this.addBody(h);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c);g.edit()}; -DialogBoxMorph.prototype.promptVector=function(a,b,c,d,e,f,g,h){function m(t){return new TextMorph(localize(t),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}var l=new AlignmentMorph("row",4),k=new InputFieldMorph(b.x.toString(),!0),n=new InputFieldMorph(b.y.toString(),!0);b=new AlignmentMorph("column",2);var p=new AlignmentMorph("column",2),q=new AlignmentMorph("column",2),r=new AlignmentMorph("column",this.padding);q.alignment="left";q.setColor(this.color);r.setColor(this.color); -b.alignment="left";b.setColor(this.color);p.alignment="left";p.setColor(this.color);b.add(m(d));b.add(k);p.add(m(e));p.add(n);l.add(b);l.add(p);q.add(l);h&&r.add(m(h));r.add(q);l.fixLayout();b.fixLayout();p.fixLayout();q.fixLayout();r.fixLayout();this.labelString=a;this.createLabel();g&&this.setPicture(g);this.addBody(r);this.addButton("ok","OK");c instanceof Point&&this.addButton(()=>{k.setContents(c.x.toString());n.setContents(c.y.toString())},"Default");this.addButton("cancel","Cancel");this.fixLayout(); -this.edit=function(){k.edit()};this.getInput=function(){return new Point(k.getValue(),n.getValue())};this.key||(this.key="vector"+a);this.popUp(f)}; -DialogBoxMorph.prototype.promptCredentials=function(a,b,c,d,e,f,g,h,m,l){function k(G){return new TextMorph(localize(G),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}function n(G,S){G=new PushButtonMorph(D,()=>window.open(S)," "+localize(G)+" ");G.fontSize=10;G.corner=D.buttonCorner;G.edge=D.buttonEdge;G.outline=D.buttonOutline;G.outlineColor=D.buttonOutlineColor;G.outlineGradient=D.buttonOutlineGradient;G.padding=D.buttonPadding;G.contrast=D.buttonContrast; -G.fixLayout();return G}function p(){function G(J,M){M=new SpeechBubbleMorph(localize(M));M.isPointingRight=!1;M.fixLayout();M.popUp(h,J.leftCenter().subtract(new Point(M.width()+2,0)));J.edit&&J.edit()}var S=r.getValue();if("login"===b)var N=[q,t];else if("signup"===b)N=[q,E,O,r,t,u];else if("changePassword"===b)N=[v,t,u];else if("resetPassword"===b||"resendVerification"===b)N=[q];if(N=detect(N,J=>!J.getValue()))return G(N,"please fill out\nthis field"),!1;if("signup"===b){if(-1{l&&l(t/n);p.setContents(t/n);p.edit()};q||=new AlignmentMorph("column", +this.padding);q.add(r)}q&&(q.fixLayout(),this.setPicture(q),q.fixLayout())}else d&&this.setPicture(d);this.reactToChoice=function(t){r&&(r.value=t*n,r.fixLayout(),r.rerender());l&&l(t)};p.reactToInput=function(){var t=p.getValue();r&&(t=Math.max(t,k),r.value=t*n,r.fixLayout(),r.rerender());l&&l(t)};this.labelString=a;this.createLabel();this.key||(this.key="prompt"+a+b);this.addBody(p);p.fixLayout();this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c)}; +DialogBoxMorph.prototype.promptCode=function(a,b,c,d,e){var f=new ScrollFrameMorph,g=new TextMorph(b||""),k=new AlignmentMorph("column",this.padding),m=d?Math.max(d.width,400):400;this.getInput=function(){return g.text};f.padding=6;f.setWidth(m);f.acceptsDrops=!1;f.contents.acceptsDrops=!1;g.fontName="monospace";g.fontStyle="monospace";g.fontSize=11;g.setPosition(f.topLeft().add(f.padding));g.enableSelecting();g.isEditable=!0;f.setHeight(m/4);f.fixLayout=nop;f.edge=InputFieldMorph.prototype.edge; +f.fontSize=InputFieldMorph.prototype.fontSize;f.typeInPadding=InputFieldMorph.prototype.typeInPadding;f.contrast=InputFieldMorph.prototype.contrast;f.render=InputFieldMorph.prototype.render;f.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;f.addContents(g);g.fixLayout();d&&this.setPicture(d);this.labelString=a;this.createLabel();this.key||(this.key="promptCode"+a+b);k.setColor(this.color);k.add(f);e&&k.add(new TextMorph(localize(e),10,null,!1,null,null,null,null,MorphicPreferences.isFlat? +null:new Point(1,1),WHITE));k.fixLayout();this.addBody(k);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.popUp(c);g.edit()}; +DialogBoxMorph.prototype.promptVector=function(a,b,c,d,e,f,g,k){function m(t){return new TextMorph(localize(t),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}var l=new AlignmentMorph("row",4),h=new InputFieldMorph(b.x.toString(),!0),n=new InputFieldMorph(b.y.toString(),!0);b=new AlignmentMorph("column",2);var p=new AlignmentMorph("column",2),q=new AlignmentMorph("column",2),r=new AlignmentMorph("column",this.padding);q.alignment="left";q.setColor(this.color);r.setColor(this.color); +b.alignment="left";b.setColor(this.color);p.alignment="left";p.setColor(this.color);b.add(m(d));b.add(h);p.add(m(e));p.add(n);l.add(b);l.add(p);q.add(l);k&&r.add(m(k));r.add(q);l.fixLayout();b.fixLayout();p.fixLayout();q.fixLayout();r.fixLayout();this.labelString=a;this.createLabel();g&&this.setPicture(g);this.addBody(r);this.addButton("ok","OK");c instanceof Point&&this.addButton(()=>{h.setContents(c.x.toString());n.setContents(c.y.toString())},"Default");this.addButton("cancel","Cancel");this.fixLayout(); +this.edit=function(){h.edit()};this.getInput=function(){return new Point(h.getValue(),n.getValue())};this.key||(this.key="vector"+a);this.popUp(f)}; +DialogBoxMorph.prototype.promptCredentials=function(a,b,c,d,e,f,g,k,m,l){function h(G){return new TextMorph(localize(G),10,null,!1,null,null,null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE)}function n(G,S){G=new PushButtonMorph(D,()=>window.open(S)," "+localize(G)+" ");G.fontSize=10;G.corner=D.buttonCorner;G.edge=D.buttonEdge;G.outline=D.buttonOutline;G.outlineColor=D.buttonOutlineColor;G.outlineGradient=D.buttonOutlineGradient;G.padding=D.buttonPadding;G.contrast=D.buttonContrast; +G.fixLayout();return G}function p(){function G(J,M){M=new SpeechBubbleMorph(localize(M));M.isPointingRight=!1;M.fixLayout();M.popUp(k,J.leftCenter().subtract(new Point(M.width()+2,0)));J.edit&&J.edit()}var S=r.getValue();if("login"===b)var N=[q,t];else if("signup"===b)N=[q,E,O,r,t,u];else if("changePassword"===b)N=[v,t,u];else if("resetPassword"===b||"resendVerification"===b)N=[q];if(N=detect(N,J=>!J.getValue()))return G(N,"please fill out\nthis field"),!1;if("signup"===b){if(-1q.getValue().length)return G(q,"User name must be four\ncharacters or longer"),!1;if(-1S.length)return G(r,"please provide a valid\nemail address"),!1}if("changePassword"===b||"signup"===b){if(6>t.getValue().length)return G(t,"password must be six\ncharacters or longer"),!1;if(t.getValue()!==u.getValue())return G(u,"passwords do\nnot match"),!1}return"signup"!==b||w?!0:(G(T,"please agree to\nthe TOS"), !1)}var q=new InputFieldMorph,r=new InputFieldMorph,t=new InputFieldMorph,u=new InputFieldMorph,v=new InputFieldMorph,w=!1,y=new AlignmentMorph("row",4),x=new AlignmentMorph("column",2),z=new AlignmentMorph("column",2),A=new AlignmentMorph("column",2),B=new AlignmentMorph("row",4),C=new AlignmentMorph("column",this.padding),F={},K=(new Date).getFullYear(),I=K-20,D=this;var E=new InputFieldMorph(null,!1,{January:["January"],February:["February"],March:["March"],April:["April"],May:["May"],June:["June"], July:["July"],August:["August"],September:["September"],October:["October"],November:["November"],December:["December"]},!0);for(K;K>I;--K)F[K.toString()+" "]=K;F[I+" "+localize("or before")]="< "+K;var O=new InputFieldMorph(null,!1,F,!0);A.alignment="left";A.setColor(this.color);C.setColor(this.color);x.alignment="left";x.setColor(this.color);z.alignment="left";z.setColor(this.color);q.setWidth(200);E.setWidth(100);O.contents().minWidth=80;O.setWidth(80);r.setWidth(200);t.setWidth(200);u.setWidth(200); -v.setWidth(200);t.contents().text.toggleIsPassword();u.contents().text.toggleIsPassword();v.contents().text.toggleIsPassword();"login"===b&&(A.add(k("User name:")),A.add(q));if("signup"===b){A.add(k("User name:"));A.add(q);x.add(k("Birth date:"));x.add(E);z.add(k("year:"));z.add(O);y.add(x);y.add(z);A.add(y);var P=k("foo");A.add(P);A.add(r);A.add(k("Password:"));A.add(t);A.add(k("Repeat Password:"));A.add(u)}"login"===b&&(A.add(k("Password:")),A.add(t));"changePassword"===b&&(A.add(k("Old password:")), -A.add(v),A.add(k("New password:")),A.add(t),A.add(k("Repeat new password:")),A.add(u));if("resetPassword"===b||"resendVerification"===b)A.add(k("User name:")),A.add(q);l&&C.add(k(l));C.add(A);(c||e)&&C.add(B);c&&B.add(n(d,c));e&&B.add(n(f,e));if(g){var T=new ToggleMorph("checkbox",this,()=>w=!w,g,()=>w);T.edge=this.buttonEdge/2;T.outline=this.buttonOutline/2;T.outlineColor=this.buttonOutlineColor;T.outlineGradient=this.buttonOutlineGradient;T.contrast=this.buttonContrast;T.fixLayout();C.add(T)}y.fixLayout(); +v.setWidth(200);t.contents().text.toggleIsPassword();u.contents().text.toggleIsPassword();v.contents().text.toggleIsPassword();"login"===b&&(A.add(h("User name:")),A.add(q));if("signup"===b){A.add(h("User name:"));A.add(q);x.add(h("Birth date:"));x.add(E);z.add(h("year:"));z.add(O);y.add(x);y.add(z);A.add(y);var P=h("foo");A.add(P);A.add(r);A.add(h("Password:"));A.add(t);A.add(h("Repeat Password:"));A.add(u)}"login"===b&&(A.add(h("Password:")),A.add(t));"changePassword"===b&&(A.add(h("Old password:")), +A.add(v),A.add(h("New password:")),A.add(t),A.add(h("Repeat new password:")),A.add(u));if("resetPassword"===b||"resendVerification"===b)A.add(h("User name:")),A.add(q);l&&C.add(h(l));C.add(A);(c||e)&&C.add(B);c&&B.add(n(d,c));e&&B.add(n(f,e));if(g){var T=new ToggleMorph("checkbox",this,()=>w=!w,g,()=>w);T.edge=this.buttonEdge/2;T.outline=this.buttonOutline/2;T.outlineColor=this.buttonOutlineColor;T.outlineGradient=this.buttonOutlineGradient;T.contrast=this.buttonContrast;T.fixLayout();C.add(T)}y.fixLayout(); x.fixLayout();z.fixLayout();A.fixLayout();B.fixLayout();C.fixLayout();this.labelString=a;this.createLabel();m&&this.setPicture(m);this.addBody(C);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.fixLayout();this.accept=function(){p()&&DialogBoxMorph.prototype.accept.call(D)};this.edit=function(){"changePassword"===b?v.edit():q.edit()};this.getInput=function(){return{username:q.getValue(),email:r.getValue(),oldpassword:v.getValue(),password:t.getValue(),passwordRepeat:u.getValue(), choice:w}};this.reactToChoice=function(){if("signup"===b){P.changed();var G=P,S=(new Date).getFullYear()+(new Date).getMonth()/12,N=+O.getValue()||0,J=E.getValue();J instanceof Array&&(J=J[0]);isNaN(N)&&(N=0);J="January February March April May June July August September October November December".split(" ").indexOf(J);isNaN(J)&&(J=0);G.text=13>=S-(N+J/12)?"E-mail address of parent or guardian:":"E-mail address:";P.text=localize(P.text);P.fixLayout();P.rerender()}};this.reactToChoice();this.key|| -(this.key="credentials"+a+b);this.popUp(h)};DialogBoxMorph.prototype.accept=function(){if(this.action)if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call()):this.target.call(this.environment,this.action);else if("function"===typeof this.action)this.action.call(this.target,this.getInput());else this.target[this.action](this.getInput());this.destroy()};DialogBoxMorph.prototype.withKey=function(a){this.key=a;return this}; +(this.key="credentials"+a+b);this.popUp(k)};DialogBoxMorph.prototype.accept=function(){if(this.action)if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call()):this.target.call(this.environment,this.action);else if("function"===typeof this.action)this.action.call(this.target,this.getInput());else this.target[this.action](this.getInput());this.destroy()};DialogBoxMorph.prototype.withKey=function(a){this.key=a;return this}; DialogBoxMorph.prototype.popUp=function(a){a&&(this.key&&(this.instances[a.stamp]?this.instances[a.stamp][this.key]&&this.instances[a.stamp][this.key].destroy():this.instances[a.stamp]={},this.instances[a.stamp][this.key]=this),a.add(this),a.keyboardFocus=this,this.setCenter(a.center()),this.edit())};DialogBoxMorph.prototype.destroy=function(){DialogBoxMorph.uber.destroy.call(this);this.key&&delete this.instances[this.key]};DialogBoxMorph.prototype.ok=function(){this.accept()}; DialogBoxMorph.prototype.cancel=function(){this.destroy()};DialogBoxMorph.prototype.edit=function(){this.children.forEach(a=>{a.edit&&a.edit()})};DialogBoxMorph.prototype.getInput=function(){return this.body instanceof InputFieldMorph?this.body.getValue():null};DialogBoxMorph.prototype.justDropped=function(a){a.world.keyboardFocus=this;this.edit()};DialogBoxMorph.prototype.destroy=function(){var a=this.world();a.keyboardFocus=null;a.hand.destroyTemporaries();DialogBoxMorph.uber.destroy.call(this)}; DialogBoxMorph.prototype.normalizeSpaces=function(a){var b="",c,d=!1;for(c=0;cn.destroy());this.children=[];this.isListContents||(this.edge=MorphicPreferences.isFlat?0:5,this.border=MorphicPreferences.isFlat?1:2);this.color=WHITE;this.borderColor=new Color(60,60,60);this.bounds.setExtent(ZERO);var h=this.left()+1;var m=this.top()+1.5*this.fontSize+2;var l=new StringMorph("",this.fontSize);this.items.forEach(n=>{b=" "!==n[0][1];c=new BoxMorph(1,1);b?(d=BLACK,e=this.fontSize,f=2.5*this.fontSize, -g=new Point(h+2-2*this.fontSize,m)):(d=WHITE,e=1.5*this.fontSize,f=4*this.fontSize,g=new Point(h+1,m),h+=e-1);c.setColor(d);c.setWidth(e);c.setHeight(f);a=new PianoKeyMorph(this.target,n[1],[c,n[0]],this.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,this.environment,n[2],n[3],n[4],n[5],n[6],l);a.setPosition(g);this.add(a)});var k=this.fullBounds();l.setPosition(new Point(k.width()/2-this.fontSize,2));this.add(l);k=this.fullBounds();this.bounds.setExtent(k.extent().add(2))}; +PianoMenuMorph.prototype.createItems=function(){var a,b,c,d,e,f,g;this.children.forEach(n=>n.destroy());this.children=[];this.isListContents||(this.edge=MorphicPreferences.isFlat?0:5,this.border=MorphicPreferences.isFlat?1:2);this.color=WHITE;this.borderColor=new Color(60,60,60);this.bounds.setExtent(ZERO);var k=this.left()+1;var m=this.top()+1.5*this.fontSize+2;var l=new StringMorph("",this.fontSize);this.items.forEach(n=>{b=" "!==n[0][1];c=new BoxMorph(1,1);b?(d=BLACK,e=this.fontSize,f=2.5*this.fontSize, +g=new Point(k+2-2*this.fontSize,m)):(d=WHITE,e=1.5*this.fontSize,f=4*this.fontSize,g=new Point(k+1,m),k+=e-1);c.setColor(d);c.setWidth(e);c.setHeight(f);a=new PianoKeyMorph(this.target,n[1],[c,n[0]],this.fontSize||MorphicPreferences.menuFontSize,MorphicPreferences.menuFontName,this.environment,n[2],n[3],n[4],n[5],n[6],l);a.setPosition(g);this.add(a)});var h=this.fullBounds();l.setPosition(new Point(h.width()/2-this.fontSize,2));this.add(l);h=this.fullBounds();this.bounds.setExtent(h.extent().add(2))}; PianoMenuMorph.prototype.select=function(a){this.unselectAllItems();a.mouseEnter();this.selection=a;this.world.keyboardFocus=this;this.hasFocus=!0};PianoMenuMorph.prototype.unselectAllItems=function(){this.children.forEach(a=>{a instanceof MenuItemMorph&&a.mouseLeave()});this.changed()};PianoMenuMorph.prototype.selectKey=function(a){var b;isNil(a)||((b=detect(this.children,c=>c.action===a))?this.select(b):this.selectKey(48))}; PianoMenuMorph.prototype.processKeyDown=function(a){switch(a.keyCode){case 13:case 32:this.selection&&this.selection.mouseClickLeft();break;case 27:return this.destroy();case 37:case 40:case 189:return this.selectDown();case 38:case 39:case 187:case 220:return this.selectUp();default:switch(a.key){case "C":return this.selectKey(48);case "c":return this.selectKey(60);case "D":return this.selectKey(50);case "d":return this.selectKey(62);case "E":return this.selectKey(52);case "e":return this.selectKey(64); case "F":return this.selectKey(53);case "f":return this.selectKey(65);case "G":return this.selectKey(55);case "g":return this.selectKey(67);case "A":return this.selectKey(57);case "a":return this.selectKey(69);case "B":case "H":return this.selectKey(59);case "b":case "h":return this.selectKey(71);default:nop()}}};PianoMenuMorph.prototype.selectUp=function(){var a=48;this.selection&&(a=this.selection.action+1,72a&&(a=72));this.selectKey(a)};PianoMenuMorph.prototype.destroy=function(){this.children.forEach(a=>{a.note&&a.note.stop()});PianoMenuMorph.uber.destroy.call(this)};PianoKeyMorph.prototype=new MenuItemMorph;PianoKeyMorph.prototype.constructor=PianoKeyMorph;PianoKeyMorph.uber=MenuItemMorph.prototype;function PianoKeyMorph(a,b,c,d,e,f,g,h,m,l,k,n){this.init(a,b,c,d,e,f,g,h,m,l,k,n);this.feedback=n} -PianoKeyMorph.prototype.init=function(a,b,c,d,e,f,g,h,m,l,k,n){this.note=new Note(b);PianoKeyMorph.uber.init.call(this,a,b,c,d,e,f,g,h,m,l,k,n)};PianoKeyMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();this.label=new Morph;var a=this.createIcon(this.labelString[0]);this.label.add(a);this.bounds.setExtent(a.extent());this.label.bounds=this.position().extent(this.label.extent());this.label.bounds.setExtent(ZERO);this.add(this.label)}; +PianoMenuMorph.prototype.selectDown=function(){var a=48;this.selection&&(a=this.selection.action-1,48>a&&(a=72));this.selectKey(a)};PianoMenuMorph.prototype.destroy=function(){this.children.forEach(a=>{a.note&&a.note.stop()});PianoMenuMorph.uber.destroy.call(this)};PianoKeyMorph.prototype=new MenuItemMorph;PianoKeyMorph.prototype.constructor=PianoKeyMorph;PianoKeyMorph.uber=MenuItemMorph.prototype;function PianoKeyMorph(a,b,c,d,e,f,g,k,m,l,h,n){this.init(a,b,c,d,e,f,g,k,m,l,h,n);this.feedback=n} +PianoKeyMorph.prototype.init=function(a,b,c,d,e,f,g,k,m,l,h,n){this.note=new Note(b);PianoKeyMorph.uber.init.call(this,a,b,c,d,e,f,g,k,m,l,h,n)};PianoKeyMorph.prototype.createLabel=function(){null!==this.label&&this.label.destroy();this.label=new Morph;var a=this.createIcon(this.labelString[0]);this.label.add(a);this.bounds.setExtent(a.extent());this.label.bounds=this.position().extent(this.label.extent());this.label.bounds.setExtent(ZERO);this.add(this.label)}; PianoKeyMorph.prototype.mouseEnter=function(){var a=this.parentThatIsA(PianoMenuMorph),b=a?a.soundType:1;a&&(a.unselectAllItems(),a.selection=this,a.world.keyboardFocus=a,a.hasFocus=!0);this.label.children[0].hide();this.userState="highlight";this.rerender();this.feedback.text=this.labelString[1];this.feedback.fixLayout();this.note.play(b);setTimeout(()=>this.note.stop(!0),400)}; PianoKeyMorph.prototype.mouseLeave=function(){this.note.stop(!0);this.label.children[0].show();this.userState="normal";this.rerender()};modules.blocks="2021-November-27";SyntaxElementMorph.prototype=new Morph;SyntaxElementMorph.prototype.constructor=SyntaxElementMorph;SyntaxElementMorph.uber=Morph.prototype;SyntaxElementMorph.prototype.contrast=65; SyntaxElementMorph.prototype.setScale=function(a){this.scale=a=Math.min(Math.max(a,1),25);this.corner=3*a;this.rounding=9*a;this.edge=a;this.flatEdge=.5*a;this.jag=5*a;this.inset=6*a;this.hatHeight=12*a;this.hatWidth=70*a;this.rfBorder=3*a;this.minWidth=0;this.dent=8*a;this.bottomPadding=3*a;this.cSlotPadding=4*a;this.typeInPadding=a;this.labelPadding=4*a;this.labelFontName="Verdana";this.labelFontStyle="sans-serif";this.fontSize=10*a;this.embossing=new Point(-1*Math.max(a/2,1),-1*Math.max(a/2,1)); @@ -678,10 +678,10 @@ SyntaxElementMorph.prototype.allInputs=function(){return this.allChildren().slic SyntaxElementMorph.prototype.tagExitBlocks=function(a,b){"doReport"===this.selector?this.partOfCustomCommand=b:"doStopThis"===this.selector?this.exitTag=a:this instanceof RingMorph||this.children.forEach(c=>{c.tagExitBlocks&&c.tagExitBlocks(a,b)})}; SyntaxElementMorph.prototype.replaceInput=function(a,b){var c=this.parentThatIsA(ScriptsMorph),d=b,e=this.children.indexOf(a),f=0;-1===e&&b instanceof MultiArgMorph&&this.children.forEach(g=>{g instanceof ArgLabelMorph&&g.argMorph()===a&&(e=f);f+=1});a.cachedSlotSpec&&(a.cachedSlotSpec=null);b.cachedSlotSpec&&(b.cachedSlotSpec=null);this.changed();b.parent&&b.parent.removeChild(b);a instanceof MultiArgMorph&&(a.inputs().forEach(g=>a.replaceInput(g,new InputSlotMorph)),(this.dynamicInputLabels||a.collapse)&& b instanceof ReporterBlockMorph&&(d=new ArgLabelMorph(b,a.collapse)));d.parent=this;this.children[e]=d;a instanceof ReporterBlockMorph&&c&&!a.isPrototype&&(!(a instanceof RingMorph)||a instanceof RingMorph&&a.contents())&&(c.add(a),a.moveBy(d.extent()),a.fixBlockColor());d instanceof MultiArgMorph||d instanceof ArgLabelMorph||d.constructor===CommandSlotMorph?(d.fixLayout(),this.fixLabelColor&&this.fixLabelColor()):this.fixLayout();this.cachedInputs=null}; -SyntaxElementMorph.prototype.revertToDefaultInput=function(a,b){var c=this.parts().indexOf(a),d=this.inputs().indexOf(a),e=new InputSlotMorph,f=this.parts().filter(function(g){return g instanceof StructInputSlotMorph}).reduce(function(g,h){return g+h.fields.length},0);c=-1!==c?c-f:c;-1!==c&&(this instanceof BlockMorph?(e=this.labelPart(this.parseSpec(this.blockSpec)[c]),this.isCustomBlock&&(c=this.isGlobal?this.definition:this.scriptTarget().getMethod(this.blockSpec),e instanceof InputSlotMorph&& +SyntaxElementMorph.prototype.revertToDefaultInput=function(a,b){var c=this.parts().indexOf(a),d=this.inputs().indexOf(a),e=new InputSlotMorph,f=this.parts().filter(function(g){return g instanceof StructInputSlotMorph}).reduce(function(g,k){return g+k.fields.length},0);c=-1!==c?c-f:c;-1!==c&&(this instanceof BlockMorph?(e=this.labelPart(this.parseSpec(this.blockSpec)[c]),this.isCustomBlock&&(c=this.isGlobal?this.definition:this.scriptTarget().getMethod(this.blockSpec),e instanceof InputSlotMorph&& e.setChoices.apply(e,c.inputOptionsOfIdx(d)),(e instanceof InputSlotMorph||e instanceof BooleanSlotMorph)&&e.setContents(c.defaultValueOfInputIdx(d)))):this instanceof MultiArgMorph?e=this.labelPart(this.slotSpec):this instanceof ReporterSlotMorph&&(e=this.emptySlot()));c=SnapActions.getFieldValue(this,d);void 0!==c?e.setContents(c):b||-1===d||(e instanceof MultiArgMorph?(e.setContents(this.defaults),e.defaults=this.defaults):isNil(this.defaults[d])||e.setContents(this.defaults[d]));(e.icon||e instanceof BooleanSlotMorph)&&e.fixLayout();this.replaceInput(a,e);e instanceof MultiArgMorph?e.refresh():e instanceof RingMorph&&e.fixBlockColor();this.cachedInputs=null};SyntaxElementMorph.prototype.isLocked=function(){return this.isStatic};SyntaxElementMorph.prototype.topBlock=function(){return this.parent&&this.parent.topBlock?this.parent.topBlock():this}; -SyntaxElementMorph.prototype.getVarNamesDict=function(){var a=this.parentThatIsA(BlockMorph),b=[],c=StageMorph.prototype.enableInheritance;if(!a)return{};var d=a.scriptTarget();a.allParents().forEach(f=>{f instanceof PrototypeHatBlockMorph?(b.push.apply(b,f.variableNames()),b.push.apply(b,f.inputs()[0].inputFragmentNames())):f instanceof BlockMorph&&f.inputs().forEach(g=>{g.allChildren().forEach(h=>{h instanceof TemplateSlotMorph?b.push(h.contents()):h instanceof MultiArgMorph&&h.children.forEach(m=> +SyntaxElementMorph.prototype.getVarNamesDict=function(){var a=this.parentThatIsA(BlockMorph),b=[],c=StageMorph.prototype.enableInheritance;if(!a)return{};var d=a.scriptTarget();a.allParents().forEach(f=>{f instanceof PrototypeHatBlockMorph?(b.push.apply(b,f.variableNames()),b.push.apply(b,f.inputs()[0].inputFragmentNames())):f instanceof BlockMorph&&f.inputs().forEach(g=>{g.allChildren().forEach(k=>{k instanceof TemplateSlotMorph?b.push(k.contents()):k instanceof MultiArgMorph&&k.children.forEach(m=> {m instanceof TemplateSlotMorph&&b.push(m.contents())})})})});if(d){var e=d.variables.allNamesDict();b.forEach(f=>e[f]=f);"doSetVar"===a.selector&&(e["~"]=null,e.my=[{anchor:["anchor"],name:["name"],"temporary?":["temporary?"],"dangling?":["dangling?"],"draggable?":["draggable?"],"rotation style":["rotation style"],"rotation x":["rotation x"],"rotation y":["rotation y"]}],c&&(e.my[0].parent=["parent"]),16===this.world().currentKey&&(e.my[0]["~"]=null,e.my[0]["microphone modifier"]=["microphone modifier"])); return e}return{}}; SyntaxElementMorph.prototype.refactorVarInStack=function(a,b,c){this instanceof RingMorph&&contains(this.inputNames(),a)||!c&&this.definesScriptVariable(a)||("reportGetVar"===this.selector&&this.blockSpec===a&&(this.setSpec(b),this.fullChanged(),this.fixLabelColor()),"getVarNamesDict"===this.choices&&this.contents().text===a&&this.setContents(b),this instanceof CustomCommandBlockMorph&&this.definition.body&&isNil(this.definition.declarations.get(a))&&!contains(this.definition.variableNames,a)&&this.definition.body.expression.refactorVarInStack(a, @@ -701,21 +701,21 @@ info.type+'"');}info.tags&&(info.tags.split(" ").forEach(e=>{if(e)switch(e){case !0;break;case "loop":c.isLoop=!0;c.add(this.labelPart("%loopArrow"));break;case "lambda":c.isLambda=!0;break;case "widget":c.canBeEmpty=!1;break;default:throw Error('unknown label part tag: "'+e+'"');}}),c.fixLayout());isNil(info.value)||c.setContents(info.value)}else"$"===a[0]&&1{u instanceof CSlotMorph||"%cs"===u.slotSpec?0this.labelWidth||u.isBlockLabelBreak)&&0{n&&(p=!0,n=!1);d=this.left()+k+this.edge+this.labelPadding;if(this instanceof RingMorph)d=this.left()+l;else if(this.isPredicate)d=this.left()+k+this.rounding;else if(this instanceof MultiArgMorph||this instanceof ArgLabelMorph)d=this.left();q+=e;e=0;u.forEach(v=>{v.isLoop&&(n=!0);v instanceof CSlotMorph? -(d-=this.labelPadding,this.isPredicate&&(d=this.left()+k+this.rounding),v.setColor(this.color),v.setPosition(new Point(d,q)),e=v.height()):v instanceof MultiArgMorph&&"%cs"===v.slotSpec?(this.isPredicate&&(d+=this.corner),v.setPosition(new Point(d,q)),e=v.height()):(v.setPosition(new Point(d,q)),v.isBlockLabelBreak||("%c"===v.slotSpec||"%loop"===v.slotSpec?d+=v.width():v.isVisible&&(d+=v.fullBounds().width()+l)),f=Math.max(f,d),e=Math.max(e,v instanceof StringMorph?v.rawHeight():v.height()))});p&& +SyntaxElementMorph.prototype.fixLayout=function(){var a,b=this.parts(),c=this.position(),d=0,e=0,f=0,g=this.minWidth,k=[],m=[],l=this.isPrototype?1:Math.floor(fontHeight(this.fontSize)/3),h=this instanceof BlockMorph&&this.hasLocationPin()?this.methodIconExtent().x+l:0,n=!1,p=!1;g=this instanceof MultiArgMorph&&"%cs"!==this.slotSpec?g+this.arrows().width():this instanceof ReporterBlockMorph?g+(2*this.rounding+2*this.edge):g+(4*this.corner+2*this.edge+3*this.inset+this.dent);this.nextBlock&&(a=this.nextBlock()); +b.forEach(u=>{u instanceof CSlotMorph||"%cs"===u.slotSpec?0this.labelWidth||u.isBlockLabelBreak)&&0{n&&(p=!0,n=!1);d=this.left()+h+this.edge+this.labelPadding;if(this instanceof RingMorph)d=this.left()+l;else if(this.isPredicate)d=this.left()+h+this.rounding;else if(this instanceof MultiArgMorph||this instanceof ArgLabelMorph)d=this.left();q+=e;e=0;u.forEach(v=>{v.isLoop&&(n=!0);v instanceof CSlotMorph? +(d-=this.labelPadding,this.isPredicate&&(d=this.left()+h+this.rounding),v.setColor(this.color),v.setPosition(new Point(d,q)),e=v.height()):v instanceof MultiArgMorph&&"%cs"===v.slotSpec?(this.isPredicate&&(d+=this.corner),v.setPosition(new Point(d,q)),e=v.height()):(v.setPosition(new Point(d,q)),v.isBlockLabelBreak||("%c"===v.slotSpec||"%loop"===v.slotSpec?d+=v.width():v.isVisible&&(d+=v.fullBounds().width()+l)),f=Math.max(f,d),e=Math.max(e,v instanceof StringMorph?v.rawHeight():v.height()))});p&& (d+=1.5*this.fontSize,f=Math.max(f,d),p=!1);u.forEach(v=>{v.moveBy(new Point(0,Math.floor((e-v.height())/2)))})});q+=e;if(this.children.some(u=>u instanceof CSlotMorph)){var r=this.bottomPadding;this instanceof ReporterBlockMorph&&!this.isPredicate&&(r=Math.max(this.bottomPadding,this.rounding-this.bottomPadding));q+=r}if(this instanceof CommandBlockMorph)var t=q-this.top()+2*this.corner;else if(this instanceof ReporterBlockMorph)t=q-this.top()+2*this.edge;else if(this instanceof MultiArgMorph||this instanceof ArgLabelMorph)t=q-this.top();this.isPredicate?g=Math.max(g,f-this.left()+this.rounding):this instanceof MultiArgMorph&&"%cs"!==this.slotSpec||this instanceof ArgLabelMorph?g=Math.max(g,f-this.left()-l):(g=Math.max(g,f-this.left()+this.labelPadding-this.edge),b[b.length-1]instanceof MultiArgMorph&&1===m.length&&(g-=l),this instanceof HatBlockMorph&&(g=Math.max(g,1.5*this.hatWidth)));this.bounds.setWidth(g);this.bounds.setHeight(t);this.holes=[];b.forEach(u=>{var v=0;if(u instanceof CSlotMorph||"%cs"=== -u.slotSpec)this.isPredicate?(u.bounds.setWidth(g-k-this.rounding-this.inset-this.corner),v=this.corner):(u.bounds.setWidth(g-this.edge-k),v=this.corner+this.edge),u.fixLoopLayout&&u.fixLoopLayout();"%cs"===u.slotSpec&&u.inputs().forEach(w=>w.bounds.setWidth(u.right()-w.left()-v));u.fixHolesLayout();this.holes.push.apply(this.holes,u.holes.map(w=>w.translateBy(u.position().subtract(c))))});a&&a.setPosition(new Point(this.left(),this.bottom()-this.corner));if(this instanceof BlockMorph&&this.parent&& +u.slotSpec)this.isPredicate?(u.bounds.setWidth(g-h-this.rounding-this.inset-this.corner),v=this.corner):(u.bounds.setWidth(g-this.edge-h),v=this.corner+this.edge),u.fixLoopLayout&&u.fixLoopLayout();"%cs"===u.slotSpec&&u.inputs().forEach(w=>w.bounds.setWidth(u.right()-w.left()-v));u.fixHolesLayout();this.holes.push.apply(this.holes,u.holes.map(w=>w.translateBy(u.position().subtract(c))))});a&&a.setPosition(new Point(this.left(),this.bottom()-this.corner));if(this instanceof BlockMorph&&this.parent&& this.parent.fixLayout&&(this.parent.fixLayout(),this.parent.changed(),this.parent instanceof SyntaxElementMorph))return;this.fixHighlight()};SyntaxElementMorph.prototype.fixHighlight=function(){var a=this.topBlock();a.getHighlight&&a.getHighlight()&&a.addHighlight(a.removeHighlight())};SyntaxElementMorph.prototype.methodIconExtent=function(){var a=1.2*this.fontSize;return this.hasLocationPin()?new Point(.66*a,a):new Point(0,0)};SyntaxElementMorph.prototype.evaluate=function(){return null}; SyntaxElementMorph.prototype.isEmptySlot=function(){return!1}; -SyntaxElementMorph.prototype.showBubble=function(a,b,c){var d=!1,e=this.parentThatIsA(IDE_Morph),f=this,g=this.rightCenter().add(new Point(2,0)),h=this.parentThatIsA(ScrollFrameMorph),m=this.world();if(void 0===a||!m)return null;if(a instanceof ListWatcherMorph){var l=a;l.update(!0);l.step=a.update;l.isDraggable=!1;l.expand(this.parentThatIsA(ScrollFrameMorph).extent());d=!0}else if(a instanceof TableFrameMorph)l=a,l.isDraggable=!1,l.expand(this.parentThatIsA(ScrollFrameMorph).extent()),d=!0;else if(a instanceof -Morph)if(isSnapObject(a)){var k=a.thumbnail(new Point(40,40));l=new Morph;l.isCachingImage=!0;l.bounds.setWidth(k.width);l.bounds.setHeight(k.height);l.cachedImage=k;l.version=a.version;l.step=function(){this.version!==a.version&&(this.cachedImage=k=a.thumbnail(new Point(40,40)),this.version=a.version,this.changed())}}else k=a.fullImage(),l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(k.width),l.bounds.setHeight(k.height),l.cachedImage=k;else a instanceof Costume?(k=a.thumbnail(new Point(40,40)), -l=new Morph,l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(k.width),l.bounds.setHeight(k.height),l.cachedImage=k):a instanceof Sound?l=new SymbolMorph("notes",30):a instanceof Context?(k=a.image(),l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(k.width),l.bounds.setHeight(k.height),l.cachedImage=k):"boolean"===typeof a?l=SpriteMorph.prototype.booleanMorph.call(null,a):isString(a)?(l=500!n.isTemporary)),f=detect(e.corral.frame.contents.children,n=>n.object===c)):c=e,g=f.center());l=new SpeechBubbleMorph(l,null,Math.max(this.rounding-2,6),0);l.popUp(m,g,d);b&&this.exportPictureWithResult(l);f instanceof SpriteIconMorph?l.keepWithin(e.corral):h&&l.keepWithin(h)}; +SyntaxElementMorph.prototype.showBubble=function(a,b,c){var d=!1,e=this.parentThatIsA(IDE_Morph),f=this,g=this.rightCenter().add(new Point(2,0)),k=this.parentThatIsA(ScrollFrameMorph),m=this.world();if(void 0===a||!m)return null;if(a instanceof ListWatcherMorph){var l=a;l.update(!0);l.step=a.update;l.isDraggable=!1;l.expand(this.parentThatIsA(ScrollFrameMorph).extent());d=!0}else if(a instanceof TableFrameMorph)l=a,l.isDraggable=!1,l.expand(this.parentThatIsA(ScrollFrameMorph).extent()),d=!0;else if(a instanceof +Morph)if(isSnapObject(a)){var h=a.thumbnail(new Point(40,40));l=new Morph;l.isCachingImage=!0;l.bounds.setWidth(h.width);l.bounds.setHeight(h.height);l.cachedImage=h;l.version=a.version;l.step=function(){this.version!==a.version&&(this.cachedImage=h=a.thumbnail(new Point(40,40)),this.version=a.version,this.changed())}}else h=a.fullImage(),l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(h.width),l.bounds.setHeight(h.height),l.cachedImage=h;else a instanceof Costume?(h=a.thumbnail(new Point(40,40)), +l=new Morph,l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(h.width),l.bounds.setHeight(h.height),l.cachedImage=h):a instanceof Sound?l=new SymbolMorph("notes",30):a instanceof Context?(h=a.image(),l=new Morph,l.isCachingImage=!0,l.bounds.setWidth(h.width),l.bounds.setHeight(h.height),l.cachedImage=h):"boolean"===typeof a?l=SpriteMorph.prototype.booleanMorph.call(null,a):isString(a)?(l=500!n.isTemporary)),f=detect(e.corral.frame.contents.children,n=>n.object===c)):c=e,g=f.center());l=new SpeechBubbleMorph(l,null,Math.max(this.rounding-2,6),0);l.popUp(m,g,d);b&&this.exportPictureWithResult(l);f instanceof SpriteIconMorph?l.keepWithin(e.corral):k&&l.keepWithin(k)}; SyntaxElementMorph.prototype.exportPictureWithResult=function(a){var b=this.parentThatIsA(IDE_Morph)||this.parentThatIsA(BlockEditorMorph).target.parentThatIsA(IDE_Morph),c=this.fullImage();a=a.fullImage();var d=newCanvas(new Point(c.width+a.width+2,c.height+Math.max(0,a.height-c.height))),e=d.getContext("2d");e.drawImage(c,0,d.height-c.height);e.drawImage(a,c.width+2,0);b.saveCanvasAs(d,(b.projectName||localize("untitled"))+" "+localize("script pic"))}; -SyntaxElementMorph.prototype.mappedCode=function(a){var b=this.evaluate();return b instanceof BlockMorph?b.mappedCode(a):b};BlockLabelMorph.prototype=new StringMorph;BlockLabelMorph.prototype.constructor=BlockLabelMorph;BlockLabelMorph.uber=StringMorph.prototype;function BlockLabelMorph(a,b,c,d,e,f,g,h,m,l){this.init(a,b,c,d,e,f,g,h,m,l)} +SyntaxElementMorph.prototype.mappedCode=function(a){var b=this.evaluate();return b instanceof BlockMorph?b.mappedCode(a):b};BlockLabelMorph.prototype=new StringMorph;BlockLabelMorph.prototype.constructor=BlockLabelMorph;BlockLabelMorph.uber=StringMorph.prototype;function BlockLabelMorph(a,b,c,d,e,f,g,k,m,l){this.init(a,b,c,d,e,f,g,k,m,l)} BlockLabelMorph.prototype.getRenderColor=function(){var a=this.parentThatIsA(BlockMorph);return MorphicPreferences.isFlat?.5e.destroy()),this.isPrototype&&this.add(this.placeHolder()),this.parseSpec(a).forEach((e,f,g)=>{"%"===e[0]&&"%br"!==e&&(d+=1);c=this.labelPart(e);isNil(c)||(this.add(c),c instanceof CommandSlotMorph||c instanceof StringMorph||(c.fixLayout(),c.rerender()),c instanceof RingMorph&&c.fixBlockColor(),(c instanceof MultiArgMorph||c.constructor===CommandSlotMorph||c.constructor===RingCommandSlotMorph)&&c.fixLayout(),this.isPrototype&& this.add(this.placeHolder()),c instanceof InputSlotMorph&&this.isCustomBlock&&c.setChoices.apply(c,(b||this.definition).inputOptionsOfIdx(d)))}),this.blockSpec=a,this.fixLayout(),this.rerender(),this.cachedInputs=null)};BlockMorph.prototype.userSetSpec=function(a){var b=this.topBlock();b.fullChanged();this.setSpec(a);b.fullChanged()};BlockMorph.prototype.rebuild=function(a){this.setSpec(this.blockSpec);a&&this.inputs().forEach(b=>{b instanceof ReporterBlockMorph&&(b.setColor(b.color.lighter(a)),b.setSpec(b.blockSpec))})}; BlockMorph.prototype.userMenu=function(){function a(p,q,r,t,u){c.addItem([r?new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize):new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize),localize(p)],q,r?t:u)}function b(){var p=e.fullCopy();p.addShadow();(new DialogBoxMorph(e,function(q){SnapActions.setBlockSpec(this,q)},e)).prompt("Variable name",e.blockSpec,d,p.doWithAlpha(1,()=>p.fullImage()),InputSlotMorph.prototype.getVarNamesDict.call(e))}var c=new MenuMorph(this),d=this.world(), -e=this,f=16===d.currentKey,g=this.activeProcess(),h=this.topBlock(),m=g&&g.context&&g.context.outerContext?g.context.outerContext.variables.names():[],l;c.addItem("help...","showHelp");if(this.isTemplate){if(this.parent instanceof SyntaxElementMorph)"reportGetVar"===this.selector&&(c.addLine(),c.addItem("rename...",()=>this.refactorThisVar(!0),"rename only\nthis reporter"),c.addItem("rename all...","refactorThisVar","rename all blocks that\naccess this variable"));else{if("reportGetVar"===this.selector){var k= -this.scriptTarget();this.isInheritedVariable(!1)?a("inherited",()=>k.toggleInheritedVariable(this.blockSpec),!0,"uncheck to\ndisinherit",null):(this.isInheritedVariable(!0)&&a("inherited",()=>k.toggleInheritedVariable(this.blockSpec),!1,null,localize("check to inherit\nfrom")+" "+k.exemplar.name),a("transient","toggleTransientVariable",this.isTransientVariable(),"uncheck to save contents\nin the project","check to prevent contents\nfrom being saved"),c.addLine(),c.addItem("rename...",()=>this.refactorThisVar(!0), -"rename only\nthis reporter"),c.addItem("rename all...","refactorThisVar","rename all blocks that\naccess this variable"))}else"evaluateCustomBlock"!==this.selector&&c.addItem("hide","hidePrimitive");StageMorph.prototype.enableInheritance&&(k=this.scriptTarget(),(l={xPosition:"x position",yPosition:"y position",direction:"direction",getScale:"size",getCostumeIdx:"costume #",getVolume:"volume",getPan:"balance",reportShown:"shown?",getPenDown:"pen down?"}[this.selector])&&k&&k.exemplar&&(c.addLine(), -a("inherited",()=>k.toggleInheritanceForAttribute(l),k.inheritsAttribute(l),"uncheck to\ndisinherit",localize("check to inherit\nfrom")+" "+k.exemplar.name)));StageMorph.prototype.enableCodeMapping&&(c.addLine(),c.addItem("header mapping...","mapToHeader"),c.addItem("code mapping...","mapToCode"))}NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,c);return c}c.addLine();if("reportGetVar"===this.selector)c.addItem("rename...",b,"rename only\nthis reporter");else if(SpriteMorph.prototype.blockAlternatives[this.selector])c.addItem("relabel...", +e=this,f=16===d.currentKey,g=this.activeProcess(),k=this.topBlock(),m=g&&g.context&&g.context.outerContext?g.context.outerContext.variables.names():[],l;c.addItem("help...","showHelp");if(this.isTemplate){if(this.parent instanceof SyntaxElementMorph)"reportGetVar"===this.selector&&(c.addLine(),c.addItem("rename...",()=>this.refactorThisVar(!0),"rename only\nthis reporter"),c.addItem("rename all...","refactorThisVar","rename all blocks that\naccess this variable"));else{if("reportGetVar"===this.selector){var h= +this.scriptTarget();this.isInheritedVariable(!1)?a("inherited",()=>h.toggleInheritedVariable(this.blockSpec),!0,"uncheck to\ndisinherit",null):(this.isInheritedVariable(!0)&&a("inherited",()=>h.toggleInheritedVariable(this.blockSpec),!1,null,localize("check to inherit\nfrom")+" "+h.exemplar.name),a("transient","toggleTransientVariable",this.isTransientVariable(),"uncheck to save contents\nin the project","check to prevent contents\nfrom being saved"),c.addLine(),c.addItem("rename...",()=>this.refactorThisVar(!0), +"rename only\nthis reporter"),c.addItem("rename all...","refactorThisVar","rename all blocks that\naccess this variable"))}else"evaluateCustomBlock"!==this.selector&&c.addItem("hide","hidePrimitive");StageMorph.prototype.enableInheritance&&(h=this.scriptTarget(),(l={xPosition:"x position",yPosition:"y position",direction:"direction",getScale:"size",getCostumeIdx:"costume #",getVolume:"volume",getPan:"balance",reportShown:"shown?",getPenDown:"pen down?"}[this.selector])&&h&&h.exemplar&&(c.addLine(), +a("inherited",()=>h.toggleInheritanceForAttribute(l),h.inheritsAttribute(l),"uncheck to\ndisinherit",localize("check to inherit\nfrom")+" "+h.exemplar.name)));StageMorph.prototype.enableCodeMapping&&(c.addLine(),c.addItem("header mapping...","mapToHeader"),c.addItem("code mapping...","mapToCode"))}NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,c);return c}c.addLine();if("reportGetVar"===this.selector)c.addItem("rename...",b,"rename only\nthis reporter");else if(SpriteMorph.prototype.blockAlternatives[this.selector])c.addItem("relabel...", ()=>this.relabel(SpriteMorph.prototype.blockAlternatives[this.selector]));else if(this.isCustomBlock&&this.alternatives){var n=this.alternatives();0this.relabel(n))}contains(["reportMap","reportKeep","reportFindFirst","reportCombine"],this.selector)?(n={reportMap:"reportAtomicMap",reportKeep:"reportAtomicKeep",reportFindFirst:"reportAtomicFindFirst",reportCombine:"reportAtomicCombine"},c.addItem("compile",()=>this.setSelector(n[this.selector]),"experimental!\nmake this reporter fast and uninterruptible\nCAUTION: Errors in the ring\ncan break your Snap! session!")): contains(["reportAtomicMap","reportAtomicKeep","reportAtomicFindFirst","reportAtomicCombine"],this.selector)?(n={reportAtomicMap:"reportMap",reportAtomicKeep:"reportKeep",reportAtomicFindFirst:"reportFindFirst",reportAtomicCombine:"reportCombine"},c.addItem("uncompile",()=>this.setSelector(n[this.selector]))):contains(["reportPenTrailsAsCostume","reportPentrailsAsSVG"],this.selector)&&(n={reportPenTrailsAsCostume:"reportPentrailsAsSVG",reportPentrailsAsSVG:"reportPenTrailsAsCostume"},c.addItem(localize(SpriteMorph.prototype.blocks[n[this.selector]].spec), ()=>{this.setSelector(n[this.selector]);this.changed()}));c.addItem("duplicate",()=>{var p=this.fullCopy(),q=this.parentThatIsA(IDE_Morph),r=this.parentThatIsA(BlockEditorMorph);p.id=null;p.pickUp(d);!q&&r&&(q=r.target.parentThatIsA(IDE_Morph));q&&(d.hand.grabOrigin={origin:q.palette,position:q.palette.center()})},"make a copy\nand pick it up");this instanceof CommandBlockMorph&&this.nextBlock()&&c.addItem((g?this.fullCopy():this).thumbnail(.5,60),()=>{var p=this.fullCopy(),q=p.nextBlock(),r=this.parentThatIsA(IDE_Morph), -t=this.parentThatIsA(BlockEditorMorph);q&&q.destroy();p.id=null;p.pickUp(d);!r&&t&&(r=t.target.parentThatIsA(IDE_Morph));r&&(d.hand.grabOrigin={origin:r.palette,position:r.palette.center()})},"only duplicate this block");c.addItem("delete",function(){this.id?SnapActions.removeBlock(this,!0):this.userDestroy()});c.addItem("script pic...",()=>{var p=this.parentThatIsA(IDE_Morph)||this.parentThatIsA(BlockEditorMorph).target.parentThatIsA(IDE_Morph);p.saveCanvasAs(h.scriptPic(),(p.projectName||localize("untitled"))+ -" "+localize("script pic"))},"save a picture\nof this script");h instanceof ReporterBlockMorph&&c.addItem("result pic...",()=>h.exportResultPic(),"save a picture of both\nthis script and its result");f&&c.addItem("download script",()=>{var p=this.parentThatIsA(IDE_Morph),q=this.parentThatIsA(BlockEditorMorph);!p&&q&&(p=q.target.parentThatIsA(IDE_Morph));p&&p.saveXMLAs(p.serializer.serialize(this),this.selector+" script",!1)},"download this script\nas an XML file",new Color(100,0,0));if(g)return m.length&& -(c.addLine(),m.forEach(p=>c.addItem(p+"...",()=>g.doShowVar(p)))),g.homeContext.variables.names().forEach(p=>{contains(m,p)||c.addItem(p+"...",()=>g.doShowVar(p))}),NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,c),c;if(this.parent.parentThatIsA(RingMorph))return c.addLine(),c.addItem("unringify",function(){SnapActions.unringify(this)}),h=this.topBlock(),!(this instanceof ReporterBlockMorph)&&h instanceof HatBlockMorph||c.addItem("ringify",function(){SnapActions.ringify(this)}),NetsBloxExtensions&& -NetsBloxExtensions.getUserMenu(this,c),c;contains("doBroadcast doSend doBroadcastAndWait receiveMessage receiveOnClone receiveGo".split(" "),this.selector)&&(c.addLine(),c.addItem(0===this.selector.indexOf("receive")?"senders...":"receivers...","showMessageUsers"));if(this.parent instanceof ReporterSlotMorph||this.parent instanceof CommandSlotMorph||this instanceof HatBlockMorph||this instanceof CommandBlockMorph&&h instanceof HatBlockMorph)return NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this, +t=this.parentThatIsA(BlockEditorMorph);q&&q.destroy();p.id=null;p.pickUp(d);!r&&t&&(r=t.target.parentThatIsA(IDE_Morph));r&&(d.hand.grabOrigin={origin:r.palette,position:r.palette.center()})},"only duplicate this block");c.addItem("delete",function(){this.id?SnapActions.removeBlock(this,!0):this.userDestroy()});c.addItem("script pic...",()=>{var p=this.parentThatIsA(IDE_Morph)||this.parentThatIsA(BlockEditorMorph).target.parentThatIsA(IDE_Morph);p.saveCanvasAs(k.scriptPic(),(p.projectName||localize("untitled"))+ +" "+localize("script pic"))},"save a picture\nof this script");k instanceof ReporterBlockMorph&&c.addItem("result pic...",()=>k.exportResultPic(),"save a picture of both\nthis script and its result");f&&c.addItem("download script",()=>{var p=this.parentThatIsA(IDE_Morph),q=this.parentThatIsA(BlockEditorMorph);!p&&q&&(p=q.target.parentThatIsA(IDE_Morph));p&&p.saveXMLAs(p.serializer.serialize(this),this.selector+" script",!1)},"download this script\nas an XML file",new Color(100,0,0));if(g)return m.length&& +(c.addLine(),m.forEach(p=>c.addItem(p+"...",()=>g.doShowVar(p)))),g.homeContext.variables.names().forEach(p=>{contains(m,p)||c.addItem(p+"...",()=>g.doShowVar(p))}),NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,c),c;if(this.parent.parentThatIsA(RingMorph))return c.addLine(),c.addItem("unringify",function(){SnapActions.unringify(this)}),k=this.topBlock(),!(this instanceof ReporterBlockMorph)&&k instanceof HatBlockMorph||c.addItem("ringify",function(){SnapActions.ringify(this)}),NetsBloxExtensions&& +NetsBloxExtensions.getUserMenu(this,c),c;contains("doBroadcast doSend doBroadcastAndWait receiveMessage receiveOnClone receiveGo".split(" "),this.selector)&&(c.addLine(),c.addItem(0===this.selector.indexOf("receive")?"senders...":"receivers...","showMessageUsers"));if(this.parent instanceof ReporterSlotMorph||this.parent instanceof CommandSlotMorph||this instanceof HatBlockMorph||this instanceof CommandBlockMorph&&k instanceof HatBlockMorph)return NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this, c),c;c.addLine();c.addItem("ringify",function(){SnapActions.ringify(this)});StageMorph.prototype.enableCodeMapping&&(c.addLine(),c.addItem("header mapping...","mapToHeader"),c.addItem("code mapping...","mapToCode"));NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,c);return c}; BlockMorph.prototype.showMessageUsers=function(){var a=this.parentThatIsA(IDE_Morph).corral,b=0===this.selector.indexOf("receive")?"allSendersOf":"allHatBlocksFor",c=this.inputs(),d;"receiveGo"===this.selector?d="__shout__go__":"receiveOnClone"===this.selector?d="__clone__init__":c[0]instanceof InputSlotMorph&&(d=c[0].evaluate());if("doSend"===this.selector&&c[1]instanceof InputSlotMorph)var e=this.inputs()[1].evaluate();else 0===this.selector.indexOf("receive")&&(e=this.scriptTarget().name);""!== d&&a.frame.contents.children.concat(a.stageIcon).forEach(f=>{f.object&&("doSend"!==this.selector||e===f.object.name)&&0(new DialogBoxMorph(this,function(b){SnapActions.setBlockSpec(this,b)},this)).prompt(a.title+"\nspec",this.blockSpec,this.world()));return a}; @@ -753,28 +753,28 @@ BlockMorph.prototype.relabel=function(a){var b=this.selectForEdit();if(b!==this) CommandBlockMorph?this.corner:0)))}; BlockMorph.prototype.setSelector=function(a,b=0){var c=this.inputs(),d=this.parentThatIsA(ScriptsMorph);var e=SpriteMorph.prototype.blocks[a];this.setCategory(e.category);this.selector=a;this.setSpec(localize(e.spec));this.defaults=e.defaults||[];a=this.inputs();if(a[0]instanceof MultiArgMorph)a[0].setContents(this.defaults),a[0].defaults=this.defaults;else for(e=0;e{f.moveBy(10);d.add(f)})}; -BlockMorph.prototype.restoreInputs=function(a,b=0){var c,d,e=this,f=this.inputs(),g=[];for(d=0;d{h=a[b];h instanceof ArgLabelMorph&&(h=h.argMorph());h instanceof RingMorph?h.contents()&&e.replaceInput(l,h.fullCopy()):h instanceof ReporterBlockMorph?l instanceof TemplateSlotMorph||l.isStatic?g.push(h):e.replaceInput(l,h.fullCopy()):h&&l instanceof InputSlotMorph?h.contents&&(l.setContents(h.contents().text),h.constant&& -(l.constant=h.constant)):h instanceof CSlotMorph&&l instanceof CSlotMorph?(c=h.nestedBlock())&&l.nestedBlock(c.fullCopy()):h instanceof MultiArgMorph&&l instanceof MultiArgMorph&&h.slotSpec===l.slotSpec&&h.infix===l.infix&&e.replaceInput(l,h.fullCopy());b+=1});for(b;b{k=a[b];k instanceof ArgLabelMorph&&(k=k.argMorph());k instanceof RingMorph?k.contents()&&e.replaceInput(l,k.fullCopy()):k instanceof ReporterBlockMorph?l instanceof TemplateSlotMorph||l.isStatic?g.push(k):e.replaceInput(l,k.fullCopy()):k&&l instanceof InputSlotMorph?k.contents&&(l.setContents(k.contents().text),k.constant&& +(l.constant=k.constant)):k instanceof CSlotMorph&&l instanceof CSlotMorph?(c=k.nestedBlock())&&l.nestedBlock(c.fullCopy()):k instanceof MultiArgMorph&&l instanceof MultiArgMorph&&k.slotSpec===l.slotSpec&&k.infix===l.infix&&e.replaceInput(l,k.fullCopy());b+=1});for(b;bm=m+"\n"+l);(new DialogBoxMorph).inform("Help",m.substr(1),a.world(),h.doWithAlpha(1,()=>{h.addShadow();return h.fullImage()}));return}d.src=b.resourceURL("help",g+".png")}; +(c=this.isGlobal?this.definition:this.scriptTarget().getMethod(this.blockSpec),e=c.comment)){var k=c.blockInstance();k.refreshDefaults(c);e=e.fullCopy();e.contents.parse();var m="";e.contents.lines.forEach(l=>m=m+"\n"+l);(new DialogBoxMorph).inform("Help",m.substr(1),a.world(),k.doWithAlpha(1,()=>{k.addShadow();return k.fullImage()}));return}d.src=b.resourceURL("help",g+".png")}; BlockMorph.prototype.mapToHeader=function(){var a="reify"===this.selector.substr(0,5)?"reify":this.selector,b=this.codeDefinitionHeader();b.addShadow(new Point(3,3));var c=b.doWithAlpha(1,()=>b.fullImage());var d=this.isCustomBlock?"Enter code that corresponds to the block's definition. Use the formal parameter\nnames as shown and to reference the definition body's generated text code.":"Enter code that corresponds to the block's definition. Choose your own\nformal parameter names (ignoring the ones shown)."; (new DialogBoxMorph(this,e=>{"evaluateCustomBlock"===a?this.definition.codeHeader=e:StageMorph.prototype.codeHeaders[a]=e},this)).promptCode("Header mapping","evaluateCustomBlock"===a?this.definition.codeHeader||"":StageMorph.prototype.codeHeaders[a]||"",this.world(),c,d)}; BlockMorph.prototype.mapToCode=function(){var a="reify"===this.selector.substr(0,5)?"reify":this.selector,b=this.codeMappingHeader();b.addShadow(new Point(3,3));var c=b.doWithAlpha(1,()=>b.fullImage());(new DialogBoxMorph(this,d=>{"evaluateCustomBlock"===a?this.definition.codeMapping=d:StageMorph.prototype.codeMappings[a]=d},this)).promptCode("Code mapping","evaluateCustomBlock"===a?this.definition.codeMapping||"":StageMorph.prototype.codeMappings[a]||"",this.world(),c,"Enter code that corresponds to the block's operation (usually a single\nfunction invocation). Use <#n> to reference actual arguments as shown.")}; BlockMorph.prototype.mapHeader=function(a,b){b=b||"reify"===this.selector.substr(0,5)?"reify":this.selector;a&&(this.isCustomBlock?this.definition.codeHeader=a:StageMorph.prototype.codeHeaders[b]=a)};BlockMorph.prototype.mapCode=function(a,b){b=b||"reify"===this.selector.substr(0,5)?"reify":this.selector;a&&(this.isCustomBlock?this.definition.codeMapping=a:StageMorph.prototype.codeMappings[b]=a)}; -BlockMorph.prototype.mappedCode=function(a){var b="reify"===this.selector.substr(0,5)?"reify":this.selector,c=1,d=this.isCustomBlock?this.definition.spec:b,e=a||{},f=[];var g="reportGetVar"===b?this.blockSpec:this.isCustomBlock?this.definition.codeMapping||"":StageMorph.prototype.codeMappings[b]||"";if("reportGetVar"!==b&&!e.hasOwnProperty(d))if(e[d]=null,this.isCustomBlock){b=this.definition.codeHeader||"";if(-1!==b.indexOf("{var r="";0===p.trimLeft().indexOf(""),m.join("\n"+r));l[q]=l[q].replace(RegExp("","g"),m.join("\n"))});b=l.join("\n")}e[d]=b}else e[d]=StageMorph.prototype.codeHeaders[d];var k=g.split("\n");this.inputs().forEach(p=>f.push(p.mappedCode(e).toString()));f.forEach(p=>{var q=p.split("\n"),r="<#"+c+">",t=new RegExp(r,"g");k.forEach((u,v)=>{var w="";0===u.trimLeft().indexOf(r)&& -(w=u.indexOf(r),w=u.slice(0,w));k[v]=u.replace(new RegExp(r),q.join("\n"+w));k[v]=k[v].replace(t,q.join("\n"))});c+=1});g=k.join("\n");this.nextBlock&&this.nextBlock()&&(g+="\n"+this.nextBlock().mappedCode(e));if(!a){var n=[];Object.keys(e).forEach(p=>{e[p]&&n.push(e[p])});if(n.length)return n.join("\n\n")+"\n\n"+g}return g}; +BlockMorph.prototype.mappedCode=function(a){var b="reify"===this.selector.substr(0,5)?"reify":this.selector,c=1,d=this.isCustomBlock?this.definition.spec:b,e=a||{},f=[];var g="reportGetVar"===b?this.blockSpec:this.isCustomBlock?this.definition.codeMapping||"":StageMorph.prototype.codeMappings[b]||"";if("reportGetVar"!==b&&!e.hasOwnProperty(d))if(e[d]=null,this.isCustomBlock){b=this.definition.codeHeader||"";if(-1!==b.indexOf("{var r="";0===p.trimLeft().indexOf(""),m.join("\n"+r));l[q]=l[q].replace(RegExp("","g"),m.join("\n"))});b=l.join("\n")}e[d]=b}else e[d]=StageMorph.prototype.codeHeaders[d];var h=g.split("\n");this.inputs().forEach(p=>f.push(p.mappedCode(e).toString()));f.forEach(p=>{var q=p.split("\n"),r="<#"+c+">",t=new RegExp(r,"g");h.forEach((u,v)=>{var w="";0===u.trimLeft().indexOf(r)&& +(w=u.indexOf(r),w=u.slice(0,w));h[v]=u.replace(new RegExp(r),q.join("\n"+w));h[v]=h[v].replace(t,q.join("\n"))});c+=1});g=h.join("\n");this.nextBlock&&this.nextBlock()&&(g+="\n"+this.nextBlock().mappedCode(e));if(!a){var n=[];Object.keys(e).forEach(p=>{e[p]&&n.push(e[p])});if(n.length)return n.join("\n\n")+"\n\n"+g}return g}; BlockMorph.prototype.codeDefinitionHeader=function(){var a=this.isCustomBlock?new PrototypeHatBlockMorph(this.definition):SpriteMorph.prototype.blockForSelector(this.selector),b=new HatBlockMorph,c=1;if(this.isCustomBlock)return a;a.inputs().forEach(d=>{var e=new TemplateSlotMorph("#"+c);a.replaceInput(d,e);c+=1});a.isPrototype=!0;b.setCategory("control");b.setSpec("%s");b.replaceInput(b.inputs()[0],a);"control"===this.category&&b.alternateBlockColor();return b}; BlockMorph.prototype.codeMappingHeader=function(){var a=this.isCustomBlock?this.definition.blockInstance():SpriteMorph.prototype.blockForSelector(this.selector),b=new HatBlockMorph,c=1;a.inputs().forEach(d=>{var e=new TemplateSlotMorph("<#"+c+">");a.replaceInput(d,e);c+=1});a.isPrototype=!0;b.setCategory("control");b.setSpec("%s");b.replaceInput(b.inputs()[0],a);"control"===this.category&&b.alternateBlockColor();return b}; BlockMorph.prototype.refactorThisVar=function(a){var b=this.scriptTarget(),c=this.instantiationSpec||this.blockSpec,d=this.fullCopy();d.addShadow();(new DialogBoxMorph(this,function(e){this.parent instanceof SyntaxElementMorph?this.parentThatIsA(BlockEditorMorph)?this.doRefactorBlockParameter(c,e,a):this.parentThatIsA(RingMorph)?this.doRefactorRingParameter(c,e,a):this.doRefactorScriptVar(c,e,a):b.hasSpriteVariable(c)?this.doRefactorSpriteVar(c,e,a):this.doRefactorGlobalVar(c,e,a)},this)).prompt("Variable name", c,this.world(),d.doWithAlpha(1,()=>d.fullImage()),InputSlotMorph.prototype.getVarNamesDict.call(this))};BlockMorph.prototype.varExistsError=function(a,b){a.inform("Variable exists","A variable with this name already exists "+(b||"in this context")+".")}; -BlockMorph.prototype.doRefactorBlockParameter=function(a,b,c){var d=this.parentThatIsA(BlockInputFragmentMorph),e=d.fragment.copy(),f=d.parent,g=this.parentThatIsA(BlockEditorMorph),h=g.body.contents;f.anyChild(m=>m.blockSpec===b)?this.varExistsError(g.target.parentThatIsA(IDE_Morph)):(e.labelString=b,d.updateBlockLabel(e),c||h.children.forEach(m=>m.refactorVarInStack(a,b)))}; +BlockMorph.prototype.doRefactorBlockParameter=function(a,b,c){var d=this.parentThatIsA(BlockInputFragmentMorph),e=d.fragment.copy(),f=d.parent,g=this.parentThatIsA(BlockEditorMorph),k=g.body.contents;f.anyChild(m=>m.blockSpec===b)?this.varExistsError(g.target.parentThatIsA(IDE_Morph)):(e.labelString=b,d.updateBlockLabel(e),c||k.children.forEach(m=>m.refactorVarInStack(a,b)))}; BlockMorph.prototype.doRefactorRingParameter=function(a,b,c){var d=this.parentThatIsA(RingMorph),e=d.contents(),f=this.topBlock();contains(d.inputNames(),b)?this.varExistsError(this.parentThatIsA(IDE_Morph)):(f.fullChanged(),this.setSpec(b),c||e&&e.refactorVarInStack(a,b),f.fullChanged())}; BlockMorph.prototype.doRefactorScriptVar=function(a,b,c){var d=this.parentThatIsA(CommandBlockMorph);d.definesScriptVariable(b)?(a=this.scriptTarget(),a=a.parentThatIsA(IDE_Morph),this.varExistsError(a)):(this.userSetSpec(b),c||d.refactorVarInStack(a,b,!0))}; -BlockMorph.prototype.doRefactorSpriteVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=d.findVariableWatcher(a);if(d.hasSpriteVariable(b))this.varExistsError(e);else if(isNil(e.globalVariables.vars[b])){var g=d.variables.getVar(a);d.deleteVariable(a);d.addVariable(b,!1);d.variables.setVar(b,g);f&&f.isVisible&&(g=d.toggleVariableWatcher(b,!1),g.setPosition(f.position()));c||(d.refactorVariableInstances(a,b,!1),d.customBlocks.forEach(h=>h.body.expression.refactorVarInStack(a, +BlockMorph.prototype.doRefactorSpriteVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=d.findVariableWatcher(a);if(d.hasSpriteVariable(b))this.varExistsError(e);else if(isNil(e.globalVariables.vars[b])){var g=d.variables.getVar(a);d.deleteVariable(a);d.addVariable(b,!1);d.variables.setVar(b,g);f&&f.isVisible&&(g=d.toggleVariableWatcher(b,!1),g.setPosition(f.position()));c||(d.refactorVariableInstances(a,b,!1),d.customBlocks.forEach(k=>k.body.expression.refactorVarInStack(a, b)));e.flushBlocksCache("variables");e.refreshPalette()}else this.varExistsError(e,"as a global variable")}; -BlockMorph.prototype.doRefactorGlobalVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=e?e.stage:null,g=d.findVariableWatcher(a);if(isNil(e.globalVariables.vars[b]))if(detect(f.children,m=>m instanceof SpriteMorph&&m.hasSpriteVariable(b)))this.varExistsError(e,"as a sprite local variable");else{var h=e.globalVariables.getVar(a);f.deleteVariable(a);f.addVariable(b,!0);e.globalVariables.setVar(b,h);g&&g.isVisible&&(d=d.toggleVariableWatcher(b,!0),d.setPosition(g.position())); +BlockMorph.prototype.doRefactorGlobalVar=function(a,b,c){var d=this.scriptTarget(),e=d.parentThatIsA(IDE_Morph),f=e?e.stage:null,g=d.findVariableWatcher(a);if(isNil(e.globalVariables.vars[b]))if(detect(f.children,m=>m instanceof SpriteMorph&&m.hasSpriteVariable(b)))this.varExistsError(e,"as a sprite local variable");else{var k=e.globalVariables.getVar(a);f.deleteVariable(a);f.addVariable(b,!0);e.globalVariables.setVar(b,k);g&&g.isVisible&&(d=d.toggleVariableWatcher(b,!0),d.setPosition(g.position())); c||(f.refactorVariableInstances(a,b,!0),f.globalBlocks.forEach(m=>{m.body&&m.body.expression.refactorVarInStack(a,b)}),f.forAllChildren(m=>{m instanceof SpriteMorph&&(m.refactorVariableInstances(a,b,!0),m.customBlocks.forEach(l=>l.body.expression.refactorVarInStack(a,b)))}));e.flushBlocksCache("variables");e.refreshPalette()}else this.varExistsError(e)}; BlockMorph.prototype.thumbnail=function(a,b){var c=this.nextBlock();c&&(c.isVisible=!1);var d=this.fullBounds().extent();var e=newCanvas(new Point(b?Math.min(d.x*a,b):d.x*a,d.y*a));var f=e.getContext("2d");f.scale(a,a);f.drawImage(this.fullImage(),0,0);b&&d.x*a>b&&(b=f.createLinearGradient(e.width/a-12,0,e.width/a,0),b.addColorStop(0,"transparent"),b.addColorStop(1,"black"),f.globalCompositeOperation="destination-out",f.fillStyle=b,f.fillRect(e.width/a-12,0,e.width/a,e.height/a));c&&(c.isVisible= !0);return e};BlockMorph.prototype.scriptPic=function(){var a=this.fullImage(),b=this.stackFullBounds(),c=newCanvas(b.extent()),d=c.getContext("2d");this.allComments().forEach(e=>d.drawImage(e.fullImage(),e.fullBounds().left()-b.left(),e.top()-b.top()));d.drawImage(a,0,0);return c}; @@ -811,17 +811,17 @@ CommandBlockMorph.prototype.topAttachPoint=function(){return new Point(this.dent CommandBlockMorph.prototype.dentCenter=function(){return this.dentLeft()+this.corner+.5*this.dent}; CommandBlockMorph.prototype.attachTargets=function(){var a=[];if(!(this instanceof HatBlockMorph)){var b=this.topAttachPoint();this.parent instanceof SyntaxElementMorph||a.push({point:b,element:this,loc:"top",type:"block"});!ScriptsMorph.prototype.enableNestedAutoWrapping&&this.parentThatIsA(CommandSlotMorph)||a.push({point:b,element:this,loc:"wrap",type:"block"})}this.isStop()||a.push({point:this.bottomAttachPoint(),element:this,loc:"bottom",type:"block"});return a}; CommandBlockMorph.prototype.allAttachTargets=function(a){var b=[];if(this instanceof HatBlockMorph&&a.rejectsHats)return b;(a||this.parent).children.filter(c=>c!==this&&c instanceof SyntaxElementMorph&&!c.isTemplate).forEach(c=>c.forAllChildren(d=>{d.attachTargets&&d.attachTargets().forEach(e=>b.push(e))}));return b}; -CommandBlockMorph.prototype.closestAttachTarget=function(a){a=a||this.parent;var b=this.bottomBlock(),c=null,d=Math.max(2*this.corner+this.dent,this.minSnapDistance),e,f=[],g=1E3,h;this instanceof HatBlockMorph||(f.push({point:this.topAttachPoint(),loc:"top"}),(h=this.wrapAttachPoint())&&f.push({point:h,loc:"wrap"}));b.isStop()||f.push({point:b.bottomAttachPoint(),loc:"bottom"});this.allAttachTargets(a).forEach(m=>f.forEach(l=>{if("wrap"===l.loc&&"wrap"===m.loc||l.loc!==m.loc&&"wrap"!==l.loc&&"wrap"!== +CommandBlockMorph.prototype.closestAttachTarget=function(a){a=a||this.parent;var b=this.bottomBlock(),c=null,d=Math.max(2*this.corner+this.dent,this.minSnapDistance),e,f=[],g=1E3,k;this instanceof HatBlockMorph||(f.push({point:this.topAttachPoint(),loc:"top"}),(k=this.wrapAttachPoint())&&f.push({point:k,loc:"wrap"}));b.isStop()||f.push({point:b.bottomAttachPoint(),loc:"bottom"});this.allAttachTargets(a).forEach(m=>f.forEach(l=>{if("wrap"===l.loc&&"wrap"===m.loc||l.loc!==m.loc&&"wrap"!==l.loc&&"wrap"!== m.loc)e=l.point.distanceTo(m.point),ed instanceof CSlotMorph);b=a.element.parent;this.moveBy(a.point.subtract(c.slotAttachPoint()));c.nestedBlock(a.element);b instanceof CommandBlockMorph?b.nextBlock(this):b instanceof CommandSlotMorph?b.nestedBlock(this):b instanceof RingReporterSlotMorph&&(b.add(this),b.fixLayout());a.element.blockSequence().forEach(d=> d.fixBlockColor())}this.fixBlockColor();CommandBlockMorph.uber.snap.call(this);this.snapSound&&this.snapSound.play()}};CommandBlockMorph.prototype.prepareToBeGrabbed=function(a){var b=this.position();this.parent instanceof RingReporterSlotMorph&&(this.parent.revertToDefaultInput(this),this.setPosition(b));CommandBlockMorph.uber.prepareToBeGrabbed.call(this,a)}; CommandBlockMorph.prototype.isStop=function(){if("doStopThis"===this.selector){const a=this.inputs()[0].evaluate();return a instanceof Array&&12>a[0].length}return!0===SpriteMorph.prototype.blocks[this.selector]?.terminal}; CommandBlockMorph.prototype.userDestroy=function(){var a=this.selectForEdit();if(a!==this)return this.userDestroy.call(a);if(this.nextBlock())this.userDestroyJustThis();else{a=this.parentThatIsA(IDE_Morph);var b=this.parentThatIsA(SyntaxElementMorph),c=this.parentThatIsA(CSlotMorph);this.prepareToBeGrabbed();a?a.removeBlock(this):this.destroy();c&&c.fixLayout();b&&b.reactToGrabOf(this)}}; -CommandBlockMorph.prototype.userDestroyJustThis=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.parentThatIsA(IDE_Morph),c=this.parentThatIsA(CommandSlotMorph,RingReporterSlotMorph),d,e=this.nextBlock(),f=this.parentThatIsA(SyntaxElementMorph),g=this.parentThatIsA(CSlotMorph,RingReporterSlotMorph);this.topBlock().fullChanged();this.parent&&(d=this.parent.parentThatIsA(CommandBlockMorph));if(d&&d.nextBlock()===this)var h=d;else c&&c.nestedBlock()===this&&(h=c,this.prepareToBeGrabbed());b? -b.removeBlock(this,!0):this.destroy(!0);e?h instanceof CommandSlotMorph||h instanceof RingReporterSlotMorph?h.nestedBlock(e):h instanceof CommandBlockMorph?h.nextBlock(e):a.add(e):g&&g.fixLayout();f&&f.reactToGrabOf(this)}; +CommandBlockMorph.prototype.userDestroyJustThis=function(){var a=this.parentThatIsA(ScriptsMorph),b=this.parentThatIsA(IDE_Morph),c=this.parentThatIsA(CommandSlotMorph,RingReporterSlotMorph),d,e=this.nextBlock(),f=this.parentThatIsA(SyntaxElementMorph),g=this.parentThatIsA(CSlotMorph,RingReporterSlotMorph);this.topBlock().fullChanged();this.parent&&(d=this.parent.parentThatIsA(CommandBlockMorph));if(d&&d.nextBlock()===this)var k=d;else c&&c.nestedBlock()===this&&(k=c,this.prepareToBeGrabbed());b? +b.removeBlock(this,!0):this.destroy(!0);e?k instanceof CommandSlotMorph||k instanceof RingReporterSlotMorph?k.nestedBlock(e):k instanceof CommandBlockMorph?k.nextBlock(e):a.add(e):g&&g.fixLayout();f&&f.reactToGrabOf(this)}; CommandBlockMorph.prototype.outlinePath=function(a,b){var c=2*this.corner+this.inset,d=this.height()-this.corner,e=this.height()-2*this.corner,f=Math.max(this.corner-b,0),g=this.position();a.arc(this.corner,this.corner,f,radians(-180),radians(-90),!1);a.lineTo(this.corner+this.inset,b);a.lineTo(c,this.corner+b);a.lineTo(c+this.dent,this.corner+b);a.lineTo(3*this.corner+this.inset+this.dent,b);a.lineTo(this.width()-this.corner,b);a.arc(this.width()-this.corner,this.corner,f,radians(-90),radians(-0), -!1);this.cSlots().forEach(h=>{h.outlinePath(a,b,h.position().subtract(g))});a.arc(this.width()-this.corner,e,f,radians(0),radians(90),!1);this.isStop()||(a.lineTo(this.width()-this.corner,d-b),a.lineTo(3*this.corner+this.inset+this.dent,d-b),a.lineTo(c+this.dent,d+this.corner-b),a.lineTo(c,d+this.corner-b),a.lineTo(this.corner+this.inset,d-b));a.arc(this.corner,e,f,radians(90),radians(180),!1)}; +!1);this.cSlots().forEach(k=>{k.outlinePath(a,b,k.position().subtract(g))});a.arc(this.width()-this.corner,e,f,radians(0),radians(90),!1);this.isStop()||(a.lineTo(this.width()-this.corner,d-b),a.lineTo(3*this.corner+this.inset+this.dent,d-b),a.lineTo(c+this.dent,d+this.corner-b),a.lineTo(c,d+this.corner-b),a.lineTo(this.corner+this.inset,d-b));a.arc(this.corner,e,f,radians(90),radians(180),!1)}; CommandBlockMorph.prototype.drawEdges=function(a){this.drawTopDentEdge(a,0,0);this.drawBottomDentEdge(a,0,this.height()-this.corner);this.drawLeftEdge(a);this.drawRightEdge(a);this.drawTopLeftEdge(a);this.drawBottomRightEdge(a)}; CommandBlockMorph.prototype.drawTopDentEdge=function(a,b,c){var d=.5*this.edge,e=b+2*this.corner+this.inset;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var f=a.createLinearGradient(0,c,0,c+this.edge);f.addColorStop(0,this.cachedClrBright);f.addColorStop(1,this.cachedClr);a.strokeStyle=f;a.beginPath();a.moveTo(this.corner,c+d);a.lineTo(b+this.corner+this.inset,c+d);a.stroke();a.strokeStyle=f;a.beginPath();a.moveTo(b+3*this.corner+this.inset+this.dent+d,c+d);a.lineTo(this.width()-this.corner, c+d);a.stroke();f=b+this.corner+this.inset;f=a.createLinearGradient(f-this.edge,c+this.edge,f,c);f.addColorStop(0,this.cachedClr);f.addColorStop(1,this.cachedClrBright);a.strokeStyle=f;a.beginPath();a.moveTo(b+this.corner+this.inset,c+d);a.lineTo(e,c+this.corner+d);a.stroke();b=a.createLinearGradient(0,c+this.corner,0,c+this.corner+this.edge);b.addColorStop(0,this.cachedClrBright);b.addColorStop(1,this.cachedClr);a.strokeStyle=b;a.beginPath();a.moveTo(e,c+this.corner+d);a.lineTo(e+this.dent,c+this.corner+ @@ -830,18 +830,18 @@ CommandBlockMorph.prototype.drawBottomDentEdge=function(a,b,c){var d=.5*this.edg this.corner-this.edge,0,c+this.corner);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.strokeStyle=g;a.beginPath();a.moveTo(e+d,c+this.corner-d);a.lineTo(e+this.dent,c+this.corner-d);a.stroke();g=a.createLinearGradient(b+e+this.dent-this.edge,c+this.corner-this.edge,b+e+this.dent,c+this.corner);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.strokeStyle=g;a.beginPath();a.moveTo(b+e+this.dent,c+this.corner-d);a.lineTo(b+3*this.corner+this.inset+this.dent, c-d);a.stroke();a.strokeStyle=f;a.beginPath();a.moveTo(b+3*this.corner+this.inset+this.dent,c-d);a.lineTo(this.width()-this.corner,c-d);a.stroke()};CommandBlockMorph.prototype.drawFlatBottomDentEdge=function(a){this.isStop()||(a.fillStyle=this.color.darker(this.contrast/2).toString(),a.beginPath(),this.drawDent(a,0,this.height()-this.corner),a.closePath(),a.fill())}; CommandBlockMorph.prototype.drawLeftEdge=function(a){var b=.5*this.edge,c=a.createLinearGradient(0,0,this.edge,0);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=c;a.beginPath();a.moveTo(b,this.corner);a.lineTo(b,this.height()-2*this.corner-b);a.stroke()}; -CommandBlockMorph.prototype.drawRightEdge=function(a){var b=.5*this.edge,c=this.cSlots(),d=this.top(),e=this.width(),f;var g=a.createLinearGradient(e-this.edge,0,e,0);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=g;c.length?(a.beginPath(),a.moveTo(e-b,this.corner+b),c.forEach(h=>{f=h.top()-d;a.lineTo(e-b,f);a.stroke();a.beginPath();a.moveTo(e-b,f+h.height())})):(a.beginPath(),a.moveTo(e-b,this.corner+ +CommandBlockMorph.prototype.drawRightEdge=function(a){var b=.5*this.edge,c=this.cSlots(),d=this.top(),e=this.width(),f;var g=a.createLinearGradient(e-this.edge,0,e,0);g.addColorStop(0,this.cachedClr);g.addColorStop(1,this.cachedClrDark);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=g;c.length?(a.beginPath(),a.moveTo(e-b,this.corner+b),c.forEach(k=>{f=k.top()-d;a.lineTo(e-b,f);a.stroke();a.beginPath();a.moveTo(e-b,f+k.height())})):(a.beginPath(),a.moveTo(e-b,this.corner+ b));a.lineTo(e-b,this.height()-2*this.corner);a.stroke()};CommandBlockMorph.prototype.drawTopLeftEdge=function(a){var b=.5*this.edge;var c=a.createRadialGradient(this.corner,this.corner,this.corner,this.corner,this.corner,this.corner-this.edge);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=c;a.beginPath();a.arc(this.corner,this.corner,this.corner-b,radians(-180),radians(-90),!1);a.stroke()}; CommandBlockMorph.prototype.drawBottomRightEdge=function(a){var b=.5*this.edge,c=this.width()-this.corner,d=this.height()-2*this.corner;var e=a.createRadialGradient(c,d,this.corner,c,d,this.corner-this.edge);e.addColorStop(0,this.cachedClrDark);e.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=e;a.beginPath();a.arc(c,d,this.corner-b,radians(90),radians(0),!0);a.stroke()};HatBlockMorph.prototype=new CommandBlockMorph; HatBlockMorph.prototype.constructor=HatBlockMorph;HatBlockMorph.uber=CommandBlockMorph.prototype;function HatBlockMorph(){this.init()}HatBlockMorph.prototype.init=function(){HatBlockMorph.uber.init.call(this);this.bounds.setExtent((new Point(120,36)).multiplyBy(this.scale));this.fixLayout();this.rerender()};HatBlockMorph.prototype.readout=function(){return detect(this.children,function(a){return a instanceof SpeechBubbleMorph})}; HatBlockMorph.prototype.clearMessages=function(){this.parentThatIsA(IDE_Morph).sockets.getMessageQueue(this).empty();this.updateReadout()}; HatBlockMorph.prototype.updateReadout=function(){var a=this,b=this.world(),c=new Color(242,119,68);if(b){var d=this.parentThatIsA(IDE_Morph);d&&(this.msgCount=(d=d.sockets.getMessageQueue(this))?d.contents.length:0,d=this.readout(),1>this.msgCount?d&&d.destroy():(d?(d.changed(),d.contents=this.msgCount.toString(),d.fixLayout(),d.rerender()):(d=new SpeechBubbleMorph(this.msgCount.toString(),c,null,null,c.darker(),null,1),d.mouseClickLeft=function(){var e=new DialogBoxMorph;e.askYesNo("Clear Message Queue", "Do you want to clear the message queue for this block?",b);e.ok=function(){a.clearMessages();this.destroy()}},this.add(d)),c=this.position().add(new Point(this.width(),0)).add(new Point(5,-10)),d.setPosition(c)))}};HatBlockMorph.prototype.blockSequence=function(){var a=HatBlockMorph.uber.blockSequence.call(this);a.shift();return a}; -HatBlockMorph.prototype.outlinePath=function(a,b){var c=2*this.corner+this.inset,d=this.height()-this.corner,e=this.height()-2*this.corner,f=Math.max(this.corner-b,0),g=this.hatWidth,h=this.hatHeight,m=(4*h*h+g*g)/(8*h),l=degrees(4*Math.atan(2*h/g))/2,k=Math.min(1.7*g,this.width()-this.corner);a.moveTo(b,h+this.corner);a.arc(g/2,m,m,radians(-l-90),radians(-90),!1);a.bezierCurveTo(g,0,g,h,k,h);a.arc(this.width()-this.corner,h+this.corner,f,radians(-90),radians(-0),!1);a.arc(this.width()-this.corner, +HatBlockMorph.prototype.outlinePath=function(a,b){var c=2*this.corner+this.inset,d=this.height()-this.corner,e=this.height()-2*this.corner,f=Math.max(this.corner-b,0),g=this.hatWidth,k=this.hatHeight,m=(4*k*k+g*g)/(8*k),l=degrees(4*Math.atan(2*k/g))/2,h=Math.min(1.7*g,this.width()-this.corner);a.moveTo(b,k+this.corner);a.arc(g/2,m,m,radians(-l-90),radians(-90),!1);a.bezierCurveTo(g,0,g,k,h,k);a.arc(this.width()-this.corner,k+this.corner,f,radians(-90),radians(-0),!1);a.arc(this.width()-this.corner, e,f,radians(0),radians(90),!1);this.isStop()||(a.lineTo(this.width()-this.corner,d-b),a.lineTo(3*this.corner+this.inset+this.dent,d-b),a.lineTo(c+this.dent,d+this.corner-b),a.lineTo(c,d+this.corner-b),a.lineTo(this.corner+this.inset,d-b));a.arc(this.corner,e,f,radians(90),radians(180),!1)}; HatBlockMorph.prototype.drawLeftEdge=function(a){var b=.5*this.edge,c=a.createLinearGradient(0,0,this.edge,0);c.addColorStop(0,this.cachedClrBright);c.addColorStop(1,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=c;a.beginPath();a.moveTo(b,this.hatHeight+b);a.lineTo(b,this.height()-2*this.corner-b);a.stroke()}; HatBlockMorph.prototype.drawRightEdge=function(a){var b=.5*this.edge,c=this.width();var d=a.createLinearGradient(c-this.edge,0,c,0);d.addColorStop(0,this.cachedClr);d.addColorStop(1,this.cachedClrDark);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=d;a.beginPath();a.moveTo(c-b,this.corner+this.hatHeight+b);a.lineTo(c-b,this.height()-2*this.corner);a.stroke()};HatBlockMorph.prototype.drawTopDentEdge=nop; -HatBlockMorph.prototype.drawTopLeftEdge=function(a){var b=.5*this.edge,c=this.hatWidth,d=this.hatHeight,e=(4*d*d+c*c)/(8*d),f=degrees(4*Math.atan(2*d/c))/2,g=Math.min(1.7*c,this.width()-this.corner);var h=a.createRadialGradient(c/2,e,e-this.edge,c/2,e,e);h.addColorStop(1,this.cachedClrBright);h.addColorStop(0,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=h;a.beginPath();a.arc(Math.round(c/2),e,e-b,radians(-f-90),radians(-90),!1);a.moveTo(c/2,b);a.bezierCurveTo(c, +HatBlockMorph.prototype.drawTopLeftEdge=function(a){var b=.5*this.edge,c=this.hatWidth,d=this.hatHeight,e=(4*d*d+c*c)/(8*d),f=degrees(4*Math.atan(2*d/c))/2,g=Math.min(1.7*c,this.width()-this.corner);var k=a.createRadialGradient(c/2,e,e-this.edge,c/2,e,e);k.addColorStop(1,this.cachedClrBright);k.addColorStop(0,this.cachedClr);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";a.strokeStyle=k;a.beginPath();a.arc(Math.round(c/2),e,e-b,radians(-f-90),radians(-90),!1);a.moveTo(c/2,b);a.bezierCurveTo(c, b,c,d+b,g,d+b);a.lineTo(this.width()-this.corner,d+b);a.stroke()};ReporterBlockMorph.prototype=new BlockMorph;ReporterBlockMorph.prototype.constructor=ReporterBlockMorph;ReporterBlockMorph.uber=BlockMorph.prototype;function ReporterBlockMorph(a){this.init(a)} ReporterBlockMorph.prototype.init=function(a){ReporterBlockMorph.uber.init.call(this);this.isPredicate=a||!1;this.bounds.setExtent((new Point(50,22)).multiplyBy(this.scale));this.fixLayout();this.rerender();this.isLocalVarTemplate=this.cachedSlotSpec=null};ReporterBlockMorph.prototype.snapTarget=function(a){return this.parent instanceof ScriptsMorph?this.parent.closestInput(this,a):null}; ReporterBlockMorph.prototype.snap=function(a){var b=this.parent,c;this.cachedSlotSpec=null;if(!(b instanceof ScriptsMorph))return null;null!==a&&(a instanceof CommandSlotMorph&&(c=a.nestedBlock())&&(c=c.fullCopy(),b.add(c),c.moveBy(c.extent()),c.fixBlockColor()),a.parent.replaceInput(a,this),this.snapSound&&this.snapSound.play());this.fixBlockColor();ReporterBlockMorph.uber.snap.call(this)}; @@ -851,15 +851,15 @@ ReporterBlockMorph.prototype.determineSlotSpec=function(){if(this.parent instanc ReporterBlockMorph.prototype.mouseClickLeft=function(a){if(this.parent instanceof BlockInputFragmentMorph)return this.parent.mouseClickLeft();if(this.parent instanceof TemplateSlotMorph){const b=this.parent.parent.parent;a=this.parent.parent&&this.parent.parent.parent&&this.parent.parent.parent instanceof RingMorph?"Input name":"%blockVars"===this.parent.parent.elementSpec?"Block variable name":"Script variable name";(new DialogBoxMorph(this,function(c){b.id?SnapActions.setBlockSpec(this,c):this.userSetSpec(c)}, this)).prompt(a,this.blockSpec,this.world())}else ReporterBlockMorph.uber.mouseClickLeft.call(this,a)};ReporterBlockMorph.prototype.exportResultPic=function(){var a=this.topBlock(),b=a.scriptTarget(),c;a===this&&b&&(c=b.parentThatIsA(StageMorph))&&(c.threads.stopProcess(a),c.threads.startProcess(a,b,!1,!0))}; ReporterBlockMorph.prototype.userDestroy=function(){var a=this.selectForEdit();if(a!==this)return this.userDestroy.call(a);a=this.world();if(a)var b=a.hand;this.topBlock().fullChanged();this.prepareToBeGrabbed(b);this.destroy()};ReporterBlockMorph.prototype.outlinePath=function(a,b){this.isPredicate?this.outlinePathDiamond(a,b):this.outlinePathOval(a,b)}; -ReporterBlockMorph.prototype.outlinePathOval=function(a,b){var c=this.height(),d=Math.min(this.rounding,c/2),e=Math.max(d-b,0),f=this.width(),g=this.position();a.arc(d,d,e,radians(-180),radians(-90),!1);a.arc(f-d,d,e,radians(-90),radians(-0),!1);this.cSlots().forEach(h=>{h.outlinePath(a,b,h.position().subtract(g))});a.arc(f-d,c-d,e,radians(0),radians(90),!1);a.arc(d,c-d,e,radians(90),radians(180),!1);a.lineTo(d-e,d)}; -ReporterBlockMorph.prototype.outlinePathDiamond=function(a,b){var c=this.width(),d=this.height(),e=Math.floor(d/2),f=this.rounding,g=c-f,h=this.position(),m=this.cSlots();a.moveTo(b,e);a.lineTo(f,b);a.lineTo(g-b,b);m.length?this.cSlots().forEach(l=>{l.outlinePath(a,b,l.position().subtract(h))}):a.lineTo(c-b,e);a.lineTo(g-b,d-b);a.lineTo(f,d-b)};ReporterBlockMorph.prototype.drawEdges=function(a){this.isPredicate?this.drawEdgesDiamond(a):this.drawEdgesOval(a)}; -ReporterBlockMorph.prototype.drawEdgesOval=function(a){var b=this.height(),c=Math.max(Math.min(this.rounding,b/2),this.edge),d=this.width(),e=this.edge/2,f,g=this.top(),h=this.cSlots();a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var m=a.createRadialGradient(c,b-c,c-this.edge,c,b-c,c+this.edge);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrBright);a.strokeStyle=m;a.beginPath();a.arc(c,b-c,c-e,radians(90),radians(180),!1);a.stroke();m=a.createRadialGradient(d-c,c,c- +ReporterBlockMorph.prototype.outlinePathOval=function(a,b){var c=this.height(),d=Math.min(this.rounding,c/2),e=Math.max(d-b,0),f=this.width(),g=this.position();a.arc(d,d,e,radians(-180),radians(-90),!1);a.arc(f-d,d,e,radians(-90),radians(-0),!1);this.cSlots().forEach(k=>{k.outlinePath(a,b,k.position().subtract(g))});a.arc(f-d,c-d,e,radians(0),radians(90),!1);a.arc(d,c-d,e,radians(90),radians(180),!1);a.lineTo(d-e,d)}; +ReporterBlockMorph.prototype.outlinePathDiamond=function(a,b){var c=this.width(),d=this.height(),e=Math.floor(d/2),f=this.rounding,g=c-f,k=this.position(),m=this.cSlots();a.moveTo(b,e);a.lineTo(f,b);a.lineTo(g-b,b);m.length?this.cSlots().forEach(l=>{l.outlinePath(a,b,l.position().subtract(k))}):a.lineTo(c-b,e);a.lineTo(g-b,d-b);a.lineTo(f,d-b)};ReporterBlockMorph.prototype.drawEdges=function(a){this.isPredicate?this.drawEdgesDiamond(a):this.drawEdgesOval(a)}; +ReporterBlockMorph.prototype.drawEdgesOval=function(a){var b=this.height(),c=Math.max(Math.min(this.rounding,b/2),this.edge),d=this.width(),e=this.edge/2,f,g=this.top(),k=this.cSlots();a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var m=a.createRadialGradient(c,b-c,c-this.edge,c,b-c,c+this.edge);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrBright);a.strokeStyle=m;a.beginPath();a.arc(c,b-c,c-e,radians(90),radians(180),!1);a.stroke();m=a.createRadialGradient(d-c,c,c- this.edge,d-c,c,c+this.edge);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrDark);a.strokeStyle=m;a.beginPath();a.arc(d-c,c,c-e,radians(-90),radians(0),!1);a.stroke();m=a.createLinearGradient(0,0,0,this.edge);m.addColorStop(0,this.cachedClrBright);m.addColorStop(1,this.cachedClr);a.strokeStyle=m;a.beginPath();a.moveTo(c-e,e);a.lineTo(d-c+e,e);a.stroke();m=a.createRadialGradient(c,c,c-this.edge,c,c,c);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrBright);a.strokeStyle= m;a.beginPath();a.arc(c,c,c-e,radians(180),radians(270),!1);a.stroke();m=a.createRadialGradient(d-c,b-c,c-this.edge,d-c,b-c,c);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrDark);a.strokeStyle=m;a.beginPath();a.arc(d-c,b-c,c-e,radians(0),radians(90),!1);a.stroke();m=a.createLinearGradient(0,b-this.edge,0,b);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrDark);a.strokeStyle=m;a.beginPath();a.moveTo(c-e,b-e);a.lineTo(d-c+e,b-e);a.stroke();m=a.createLinearGradient(0, -0,this.edge,0);m.addColorStop(0,this.cachedClrBright);m.addColorStop(1,this.cachedClr);a.strokeStyle=m;a.beginPath();a.moveTo(e,c);a.lineTo(e,b-c);a.stroke();m=a.createLinearGradient(d-this.edge,0,d,0);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrDark);a.strokeStyle=m;h.length?(a.beginPath(),a.moveTo(d-e,c+e),h.forEach(l=>{f=l.top()-g;a.lineTo(d-e,f);a.stroke();a.beginPath();a.moveTo(d-e,f+l.height())})):(a.beginPath(),a.moveTo(d-e,c+e));a.lineTo(d-e,b-c);a.stroke()}; -ReporterBlockMorph.prototype.drawEdgesDiamond=function(a){var b=this.width(),c=this.height(),d=Math.floor(c/2),e=this.rounding,f=this.edge/2,g=this.cSlots(),h=this.top(),m;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var l=a.createLinearGradient(-e,0,e,0);l.addColorStop(1,this.cachedClr);l.addColorStop(0,this.cachedClrBright);a.strokeStyle=l;a.beginPath();a.moveTo(f,d);a.lineTo(e,c-f);a.closePath();a.stroke();l=a.createLinearGradient(0,0,e,0);l.addColorStop(0,this.cachedClrBright);l.addColorStop(1, +0,this.edge,0);m.addColorStop(0,this.cachedClrBright);m.addColorStop(1,this.cachedClr);a.strokeStyle=m;a.beginPath();a.moveTo(e,c);a.lineTo(e,b-c);a.stroke();m=a.createLinearGradient(d-this.edge,0,d,0);m.addColorStop(0,this.cachedClr);m.addColorStop(1,this.cachedClrDark);a.strokeStyle=m;k.length?(a.beginPath(),a.moveTo(d-e,c+e),k.forEach(l=>{f=l.top()-g;a.lineTo(d-e,f);a.stroke();a.beginPath();a.moveTo(d-e,f+l.height())})):(a.beginPath(),a.moveTo(d-e,c+e));a.lineTo(d-e,b-c);a.stroke()}; +ReporterBlockMorph.prototype.drawEdgesDiamond=function(a){var b=this.width(),c=this.height(),d=Math.floor(c/2),e=this.rounding,f=this.edge/2,g=this.cSlots(),k=this.top(),m;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var l=a.createLinearGradient(-e,0,e,0);l.addColorStop(1,this.cachedClr);l.addColorStop(0,this.cachedClrBright);a.strokeStyle=l;a.beginPath();a.moveTo(f,d);a.lineTo(e,c-f);a.closePath();a.stroke();l=a.createLinearGradient(0,0,e,0);l.addColorStop(0,this.cachedClrBright);l.addColorStop(1, this.cachedClr);a.strokeStyle=l;a.beginPath();a.moveTo(f,d);a.lineTo(e,f);a.closePath();a.stroke();l=a.createLinearGradient(0,0,0,this.edge);l.addColorStop(0,this.cachedClrBright);l.addColorStop(1,this.cachedClr);a.strokeStyle=l;a.beginPath();a.moveTo(e,f);g.length?(a.lineTo(b-e-f,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e-this.edge,0,b-e,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark),a.lineWidth=this.edge,a.lineJoin="round",a.lineCap="round",a.strokeStyle= -l,a.beginPath(),a.moveTo(b-e-f,this.edge+f),g.forEach(k=>{m=k.top()-h;a.lineTo(b-e-f,m);a.stroke();a.beginPath();a.moveTo(b-e-f,m+k.height())}),a.lineTo(b-e-f,c-f)):(a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b+e,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark),a.strokeStyle=l,a.beginPath(),a.moveTo(b-f,d),a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark), +l,a.beginPath(),a.moveTo(b-e-f,this.edge+f),g.forEach(h=>{m=h.top()-k;a.lineTo(b-e-f,m);a.stroke();a.beginPath();a.moveTo(b-e-f,m+h.height())}),a.lineTo(b-e-f,c-f)):(a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b+e,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark),a.strokeStyle=l,a.beginPath(),a.moveTo(b-f,d),a.lineTo(b-e,f),a.closePath(),a.stroke(),l=a.createLinearGradient(b-e,0,b,0),l.addColorStop(0,this.cachedClr),l.addColorStop(1,this.cachedClrDark), a.strokeStyle=l,a.beginPath(),a.moveTo(b-e,c-f),a.lineTo(b-f,d),a.closePath());a.stroke();l=a.createLinearGradient(0,c-this.edge,0,c);l.addColorStop(0,this.cachedClr);l.addColorStop(1,this.cachedClrDark);a.strokeStyle=l;a.beginPath();a.moveTo(e+f,c-f);a.lineTo(b-e-f,c-f);a.closePath();a.stroke()};RingMorph.prototype=new ReporterBlockMorph;RingMorph.prototype.constructor=RingMorph;RingMorph.uber=ReporterBlockMorph.prototype;RingMorph.prototype.isCachingInputs=!1;function RingMorph(){this.init()} RingMorph.prototype.init=function(){RingMorph.uber.init.call(this);this.category="other";this.contrast=RingMorph.prototype.contrast;this.setExtent(new Point(200,80))}; RingMorph.prototype.render=function(a){var b=this.inputs()[0],c=this.position();this.cachedClr=this.color.toString();this.cachedClrBright=this.bright();this.cachedClrDark=this.dark();MorphicPreferences.isFlat?(a.fillStyle=this.cachedClrDark,a.beginPath(),this.outlinePath(a,0),b.outlinePath(a,b.position().subtract(c)),a.clip("evenodd"),a.fillRect(0,0,this.width(),this.height()),a.fillStyle=this.cachedClr,a.beginPath(),this.outlinePath(a,this.flatEdge),b.outlinePath(a,b.position().subtract(c)),a.clip("evenodd"), @@ -880,11 +880,11 @@ ScriptsMorph.prototype.showCommandDropFeedback=function(a){var b=a.closestAttach a=b.point.y,"bottom"===b.loc&&("block"===b.type?b.element.nextBlock()&&(a-=SyntaxElementMorph.prototype.corner):"slot"===b.type&&b.element.nestedBlock()&&(a-=SyntaxElementMorph.prototype.corner)),this.feedbackMorph.setPosition(new Point(b.element.left(),a)))}; ScriptsMorph.prototype.showCommentDropFeedback=function(a,b){b=this.closestBlock(a,b);if(!b)return null;this.feedbackMorph.bounds=b.bounds.expandBy(Math.max(2*BlockMorph.prototype.edge,BlockMorph.prototype.reporterDropFeedbackPadding));this.feedbackMorph.edge=SyntaxElementMorph.prototype.rounding;this.feedbackMorph.border=Math.max(SyntaxElementMorph.prototype.edge,3);this.add(this.feedbackMorph);this.feedbackMorph.color=a.color.copy();this.feedbackMorph.color.a=.25;this.feedbackMorph.borderColor= a.titleBar.color;this.feedbackMorph.rerender()};ScriptsMorph.prototype.showCSlotWrapFeedback=function(a,b){this.feedbackMorph.bounds=b.fullBounds().expandBy(BlockMorph.prototype.corner);this.feedbackMorph.edge=SyntaxElementMorph.prototype.corner;this.feedbackMorph.border=Math.max(SyntaxElementMorph.prototype.edge,3);this.add(this.feedbackMorph);a=a.color.lighter(40);this.feedbackMorph.color=a.copy();this.feedbackMorph.color.a=.1;this.feedbackMorph.borderColor=a;this.feedbackMorph.rerender()}; -ScriptsMorph.prototype.closestInput=function(a,b){function c(m,l){return m instanceof MultiArgMorph?l?m.arrows().bounds.containsPoint(l):m.arrows().bounds.intersects(d):!0}var d=a.fullBoundsNoShadow(),e=this.children.filter(m=>m instanceof BlockMorph&&m.fullBounds().intersects(d)),f=a.allInputs();var g=[];e.forEach(m=>g=g.concat(m.allInputs()));if(0===g.length)return null;if(this.isPreferringEmptySlots){if(b){var h=b.position();if(e=detect(g,m=>(m instanceof InputSlotMorph||m instanceof ArgMorph&& -!(m instanceof CommandSlotMorph)&&!(m instanceof MultiArgMorph)||m instanceof RingMorph&&!m.contents()||m.isEmptySlot())&&!m.isLocked()&&m.bounds.containsPoint(h)&&!contains(f,m)))return e}if(e=detect(g,m=>(m instanceof InputSlotMorph||m instanceof ArgMorph||m instanceof RingMorph&&!m.contents()||m.isEmptySlot())&&!m.isLocked()&&m.bounds.intersects(d)&&!contains(f,m)&&c(m,h)))return e}return b&&(h=b.position(),e=detect(g,m=>m!==a&&!m.isLocked()&&m.bounds.containsPoint(h)&&!(m.parent instanceof PrototypeHatBlockMorph)&& -!contains(f,m)&&c(m,h)))?e:detect(g,m=>m!==a&&!m.isLocked()&&m.fullBounds().intersects(d)&&!(m.parent instanceof PrototypeHatBlockMorph)&&!contains(f,m)&&c(m))}; +ScriptsMorph.prototype.closestInput=function(a,b){function c(m,l){return m instanceof MultiArgMorph?l?m.arrows().bounds.containsPoint(l):m.arrows().bounds.intersects(d):!0}var d=a.fullBoundsNoShadow(),e=this.children.filter(m=>m instanceof BlockMorph&&m.fullBounds().intersects(d)),f=a.allInputs();var g=[];e.forEach(m=>g=g.concat(m.allInputs()));if(0===g.length)return null;if(this.isPreferringEmptySlots){if(b){var k=b.position();if(e=detect(g,m=>(m instanceof InputSlotMorph||m instanceof ArgMorph&& +!(m instanceof CommandSlotMorph)&&!(m instanceof MultiArgMorph)||m instanceof RingMorph&&!m.contents()||m.isEmptySlot())&&!m.isLocked()&&m.bounds.containsPoint(k)&&!contains(f,m)))return e}if(e=detect(g,m=>(m instanceof InputSlotMorph||m instanceof ArgMorph||m instanceof RingMorph&&!m.contents()||m.isEmptySlot())&&!m.isLocked()&&m.bounds.intersects(d)&&!contains(f,m)&&c(m,k)))return e}return b&&(k=b.position(),e=detect(g,m=>m!==a&&!m.isLocked()&&m.bounds.containsPoint(k)&&!(m.parent instanceof PrototypeHatBlockMorph)&& +!contains(f,m)&&c(m,k)))?e:detect(g,m=>m!==a&&!m.isLocked()&&m.fullBounds().intersects(d)&&!(m.parent instanceof PrototypeHatBlockMorph)&&!contains(f,m)&&c(m))}; ScriptsMorph.prototype.closestBlock=function(a,b){var c=a.bounds;a=this.children.filter(f=>f instanceof BlockMorph&&f.fullBounds().intersects(c));var d=[];a.forEach(f=>{d=d.concat(f.allChildren().slice(0).reverse().filter(g=>g instanceof BlockMorph&&!g.isTemplate))});if(0===d.length)return null;if(b){var e=b.position();if(b=detect(d,f=>!f.comment&&!f.isPrototype&&f.bounds.containsPoint(e)))return b}return detect(d,f=>!f.comment&&!f.isPrototype&&f.bounds.intersects(c))}; -ScriptsMorph.prototype.userMenu=function(){function a(f,g,h,m,l){b.addItem([h?new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize):new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize),localize(f)],g,h?m:l)}var b=new MenuMorph(this),c=this.parentThatIsA(IDE_Morph),d,e=this.scriptTarget();c||(d=this.parentThatIsA(BlockEditorMorph))&&(c=d.target.parentThatIsA(IDE_Morph));SnapUndo.canUndo(e)&&b.addItem([new SymbolMorph("turnBack",MorphicPreferences.menuFontSize),localize("undo")], +ScriptsMorph.prototype.userMenu=function(){function a(f,g,k,m,l){b.addItem([k?new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize):new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize),localize(f)],g,k?m:l)}var b=new MenuMorph(this),c=this.parentThatIsA(IDE_Morph),d,e=this.scriptTarget();c||(d=this.parentThatIsA(BlockEditorMorph))&&(c=d.target.parentThatIsA(IDE_Morph));SnapUndo.canUndo(e)&&b.addItem([new SymbolMorph("turnBack",MorphicPreferences.menuFontSize),localize("undo")], function(){SnapUndo.undo(e)},localize("undo the last edit"));SnapUndo.canRedo(e)&&b.addItem([new SymbolMorph("turnForward",MorphicPreferences.menuFontSize),localize("redo")],function(){SnapUndo.redo(e)},localize("redo the last edit"));(SnapUndo.canUndo(e)||SnapUndo.canRedo(e))&&b.addLine();b.addItem("clean up","cleanUp","arrange scripts\nvertically");b.addItem("add comment","addComment");b.addItem("scripts pic...","exportScriptsPicture","save a picture\nof all scripts");c&&(b.addLine(),!d&&e.exemplar&& a("inherited",()=>e.toggleInheritanceForAttribute("scripts"),e.inheritsAttribute("scripts"),"uncheck to\ndisinherit",localize("check to inherit\nfrom")+" "+e.exemplar.name),b.addItem("make a block...",()=>(new BlockDialogMorph(null,f=>{""!==f.spec&&SnapActions.addCustomBlock(f,e).then(function(g){(new BlockEditorMorph(g,e)).popUp()})},this)).prompt("Make a block",null,this.world())));NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,b);return b}; ScriptsMorph.prototype.cleanUp=function(){var a=this.selectForEdit(),b=a.topLeft(),c=a.cleanUpMargin;a.children.sort((f,g)=>f instanceof PrototypeHatBlockMorph?0:f.top()-g.top());const d=this.children.map(function(f){return f.id}),e=this.children.map(function(f){if(!(f instanceof CommentMorph&&f.block))return point=b.add(new Point(a.cleanUpMargin,c)),c+=f.stackHeight()+a.cleanUpSpacing,point});SnapActions.setBlocksPositions(d,e);a.parent&&a.setPosition(a.parent.topLeft());a.adjustBounds()}; @@ -919,17 +919,17 @@ this.dent));this.parent&&this.parent.fixLayout&&this.parent.fixLayout()};Command CommandSlotMorph.prototype.render=function(a){this.cachedClr=this.color.toString();this.cachedClrBright=this.bright();this.cachedClrDark=this.dark();a.fillStyle=this.cachedClr;a.fillRect(0,0,this.width(),this.height());a.fillStyle=this.rfColor.toString();this.drawFlat(a);MorphicPreferences.isFlat||this.drawEdges(a)}; CommandSlotMorph.prototype.drawFlat=function(a){var b=null!==this.nestedBlock(),c=b?this.inset:this.inset/2,d=b?this.dent:this.dent/2,e=2*this.corner+c,f=this.edge;b=b?this.rfBorder:0;var g=this.height()-this.corner-f;a.beginPath();a.arc(this.corner+f,this.corner+f,this.corner,radians(-180),radians(-90),!1);a.lineTo(this.corner+c+f+2*b,f);a.lineTo(e+f+2*b,this.corner+f);a.lineTo(e+f+2*b+(d-2*b),this.corner+f);a.lineTo(e+f+2*b+(d-2*b)+this.corner,f);a.lineTo(this.width()-this.corner-f,f);a.arc(this.width()- this.corner-f,this.corner+f,this.corner,radians(-90),radians(-0),!1);a.arc(this.width()-this.corner-f,g,this.corner,radians(0),radians(90),!1);a.arc(this.corner+f,g,this.corner,radians(90),radians(180),!1);a.closePath();a.fill()}; -CommandSlotMorph.prototype.drawEdges=function(a){var b=null!==this.nestedBlock(),c=b?this.inset:this.inset/2,d=b?this.dent:this.dent/2,e=2*this.corner+c,f=this.edge;b=b?this.rfBorder:0;var g=.5*this.edge;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var h=a.createLinearGradient(0,this.height(),0,this.height()-this.edge);h.addColorStop(0,this.cachedClr);h.addColorStop(1,this.cachedClrBright);a.strokeStyle=h;a.beginPath();a.moveTo(this.corner+f,this.height()-g);a.lineTo(this.width()-this.corner- -f,this.height()-g);a.stroke();h=a.createRadialGradient(this.width()-(this.corner+f),this.height()-(this.corner+f),this.corner,this.width()-(this.corner+f),this.height()-(this.corner+f),this.corner+f);h.addColorStop(0,this.cachedClrBright);h.addColorStop(1,this.cachedClr);a.strokeStyle=h;a.beginPath();a.arc(this.width()-(this.corner+f),this.height()-(this.corner+f),this.corner+g,radians(0),radians(90),!1);a.stroke();h=a.createLinearGradient(this.width(),0,this.width()-this.edge,0);h.addColorStop(0, -this.cachedClr);h.addColorStop(1,this.cachedClrBright);a.strokeStyle=h;a.beginPath();a.moveTo(this.width()-g,this.height()-this.corner-this.edge);a.lineTo(this.width()-g,f+this.corner);a.stroke();a.shadowOffsetY=g;a.shadowBlur=this.edge;a.shadowColor=this.rfColor.darker(80).toString();h=a.createLinearGradient(0,0,f,0);h.addColorStop(0,this.cachedClr);h.addColorStop(1,this.cachedClrDark);a.strokeStyle=h;a.beginPath();a.moveTo(g,f+this.corner);a.lineTo(g,this.height()-f-this.corner);a.stroke();h=a.createRadialGradient(this.corner+ -f,this.corner+f,this.corner,this.corner+f,this.corner+f,this.corner+f);h.addColorStop(0,this.cachedClrDark);h.addColorStop(1,this.cachedClr);a.strokeStyle=h;a.beginPath();a.arc(this.corner+f,this.corner+f,this.corner+g,radians(-180),radians(-90),!1);a.stroke();h=a.createLinearGradient(0,0,0,this.edge);h.addColorStop(0,this.cachedClr);h.addColorStop(1,this.cachedClrDark);a.strokeStyle=h;a.beginPath();a.moveTo(this.corner+f,g);a.lineTo(this.corner+c+f+2*b-g,g);a.stroke();c=a.createLinearGradient(0, +CommandSlotMorph.prototype.drawEdges=function(a){var b=null!==this.nestedBlock(),c=b?this.inset:this.inset/2,d=b?this.dent:this.dent/2,e=2*this.corner+c,f=this.edge;b=b?this.rfBorder:0;var g=.5*this.edge;a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var k=a.createLinearGradient(0,this.height(),0,this.height()-this.edge);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrBright);a.strokeStyle=k;a.beginPath();a.moveTo(this.corner+f,this.height()-g);a.lineTo(this.width()-this.corner- +f,this.height()-g);a.stroke();k=a.createRadialGradient(this.width()-(this.corner+f),this.height()-(this.corner+f),this.corner,this.width()-(this.corner+f),this.height()-(this.corner+f),this.corner+f);k.addColorStop(0,this.cachedClrBright);k.addColorStop(1,this.cachedClr);a.strokeStyle=k;a.beginPath();a.arc(this.width()-(this.corner+f),this.height()-(this.corner+f),this.corner+g,radians(0),radians(90),!1);a.stroke();k=a.createLinearGradient(this.width(),0,this.width()-this.edge,0);k.addColorStop(0, +this.cachedClr);k.addColorStop(1,this.cachedClrBright);a.strokeStyle=k;a.beginPath();a.moveTo(this.width()-g,this.height()-this.corner-this.edge);a.lineTo(this.width()-g,f+this.corner);a.stroke();a.shadowOffsetY=g;a.shadowBlur=this.edge;a.shadowColor=this.rfColor.darker(80).toString();k=a.createLinearGradient(0,0,f,0);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;a.beginPath();a.moveTo(g,f+this.corner);a.lineTo(g,this.height()-f-this.corner);a.stroke();k=a.createRadialGradient(this.corner+ +f,this.corner+f,this.corner,this.corner+f,this.corner+f,this.corner+f);k.addColorStop(0,this.cachedClrDark);k.addColorStop(1,this.cachedClr);a.strokeStyle=k;a.beginPath();a.arc(this.corner+f,this.corner+f,this.corner+g,radians(-180),radians(-90),!1);a.stroke();k=a.createLinearGradient(0,0,0,this.edge);k.addColorStop(0,this.cachedClr);k.addColorStop(1,this.cachedClrDark);a.strokeStyle=k;a.beginPath();a.moveTo(this.corner+f,g);a.lineTo(this.corner+c+f+2*b-g,g);a.stroke();c=a.createLinearGradient(0, this.corner,0,this.corner+f);c.addColorStop(0,this.cachedClr);c.addColorStop(1,this.cachedClrDark);a.strokeStyle=c;a.beginPath();a.moveTo(e+f+2*b+g,this.corner+g);a.lineTo(e+f+2*b+(d-2*b),this.corner+g);a.stroke();c=a.createLinearGradient(e+f+2*b+(d-2*b)-g,this.corner,e+f+2*b+(d-2*b)+.7*g,this.corner+g+.7*g);c.addColorStop(0,this.cachedClr);c.addColorStop(1,this.cachedClrDark);a.strokeStyle=c;a.beginPath();a.moveTo(e+f+2*b+(d-2*b),this.corner+g);a.lineTo(e+f+2*b+(d-2*b)+this.corner,g);a.stroke(); -a.strokeStyle=h;a.beginPath();a.moveTo(e+f+2*b+(d-2*b)+this.corner,g);a.lineTo(this.width()-this.corner-f,g);a.stroke()};RingCommandSlotMorph.prototype=new CommandSlotMorph;RingCommandSlotMorph.prototype.constructor=RingCommandSlotMorph;RingCommandSlotMorph.uber=CommandSlotMorph.prototype;RingCommandSlotMorph.prototype.rfBorder=0;RingCommandSlotMorph.prototype.edge=RingMorph.prototype.edge;function RingCommandSlotMorph(){this.init()} +a.strokeStyle=k;a.beginPath();a.moveTo(e+f+2*b+(d-2*b)+this.corner,g);a.lineTo(this.width()-this.corner-f,g);a.stroke()};RingCommandSlotMorph.prototype=new CommandSlotMorph;RingCommandSlotMorph.prototype.constructor=RingCommandSlotMorph;RingCommandSlotMorph.uber=CommandSlotMorph.prototype;RingCommandSlotMorph.prototype.rfBorder=0;RingCommandSlotMorph.prototype.edge=RingMorph.prototype.edge;function RingCommandSlotMorph(){this.init()} RingCommandSlotMorph.prototype.init=function(){RingCommandSlotMorph.uber.init.call(this);this.color=new Color(0,17,173);this.contrast=RingMorph.prototype.contrast};RingCommandSlotMorph.prototype.getSpec=function(){return"%rc"};RingCommandSlotMorph.prototype.render=function(a){MorphicPreferences.isFlat||(this.cachedClr=this.color.toString(),this.cachedClrBright=this.bright(),this.cachedClrDark=this.dark(),a.fillStyle=this.cachedClr,this.drawEdges(a))}; -RingCommandSlotMorph.prototype.outlinePath=function(a,b){var c=b.x;b=b.y;var d=null!==this.nestedBlock(),e=d?this.inset:this.inset/2,f=d?this.dent:this.dent/2,g=2*this.corner+e,h=this.edge,m=this.width(),l=this.height();d=d?this.rfBorder:0;l=l-this.corner-h;a.arc(this.corner+h+c,this.corner+h+b,this.corner,radians(-180),radians(-90),!1);a.lineTo(this.corner+e+h+2*d+c,h+b);a.lineTo(g+h+2*d+c,this.corner+h+b);a.lineTo(g+h+2*d+(f-2*d)+c,this.corner+h+b);a.lineTo(g+h+2*d+(f-2*d)+this.corner+c,h+b);a.lineTo(this.width()- -this.corner-h+c,h+b);a.arc(m-this.corner-h+c,this.corner+h+b,this.corner,radians(-90),radians(-0),!1);a.arc(this.width()-this.corner-h+c,l+b,this.corner,radians(0),radians(90),!1);a.arc(this.corner+h+c,l+b,this.corner,radians(90),radians(180),!1);a.lineTo(this.corner+h+c-this.corner,this.corner+h+b)};CSlotMorph.prototype=new CommandSlotMorph;CSlotMorph.prototype.constructor=CSlotMorph;CSlotMorph.uber=CommandSlotMorph.prototype;function CSlotMorph(){this.init()} +RingCommandSlotMorph.prototype.outlinePath=function(a,b){var c=b.x;b=b.y;var d=null!==this.nestedBlock(),e=d?this.inset:this.inset/2,f=d?this.dent:this.dent/2,g=2*this.corner+e,k=this.edge,m=this.width(),l=this.height();d=d?this.rfBorder:0;l=l-this.corner-k;a.arc(this.corner+k+c,this.corner+k+b,this.corner,radians(-180),radians(-90),!1);a.lineTo(this.corner+e+k+2*d+c,k+b);a.lineTo(g+k+2*d+c,this.corner+k+b);a.lineTo(g+k+2*d+(f-2*d)+c,this.corner+k+b);a.lineTo(g+k+2*d+(f-2*d)+this.corner+c,k+b);a.lineTo(this.width()- +this.corner-k+c,k+b);a.arc(m-this.corner-k+c,this.corner+k+b,this.corner,radians(-90),radians(-0),!1);a.arc(this.width()-this.corner-k+c,l+b,this.corner,radians(0),radians(90),!1);a.arc(this.corner+k+c,l+b,this.corner,radians(90),radians(180),!1);a.lineTo(this.corner+k+c-this.corner,this.corner+k+b)};CSlotMorph.prototype=new CommandSlotMorph;CSlotMorph.prototype.constructor=CSlotMorph;CSlotMorph.uber=CommandSlotMorph.prototype;function CSlotMorph(){this.init()} CSlotMorph.prototype.init=function(){CommandSlotMorph.uber.init.call(this);this.isLoop=this.isLambda=!1;this.color=new Color(0,17,173);this.setExtent(new Point(230,4*this.corner+this.cSlotPadding))};CSlotMorph.prototype.getSpec=function(){return this.isLoop?"%loop":"%c"}; -CSlotMorph.prototype.mappedCode=function(a){var b=(StageMorph.prototype.codeMappings.reify||"<#1>").split("\n"),c=this.nestedBlock(),d=(c?c.mappedCode(a):"").toString().split("\n"),e=RegExp("<#1>","g");b.forEach((f,g)=>{var h="";0===f.trimLeft().indexOf("<#1>")&&(h=f.indexOf("<#1>"),h=f.slice(0,h));b[g]=f.replace(RegExp("<#1>"),d.join("\n"+h));b[g]=b[g].replace(e,d.join("\n"))});return b.join("\n")}; +CSlotMorph.prototype.mappedCode=function(a){var b=(StageMorph.prototype.codeMappings.reify||"<#1>").split("\n"),c=this.nestedBlock(),d=(c?c.mappedCode(a):"").toString().split("\n"),e=RegExp("<#1>","g");b.forEach((f,g)=>{var k="";0===f.trimLeft().indexOf("<#1>")&&(k=f.indexOf("<#1>"),k=f.slice(0,k));b[g]=f.replace(RegExp("<#1>"),d.join("\n"+k));b[g]=b[g].replace(e,d.join("\n"))});return b.join("\n")}; CSlotMorph.prototype.fixLayout=function(){var a=this.nestedBlock();a?(a.setPosition(new Point(this.left()+this.inset,this.top()+this.corner)),this.bounds.setHeight(a.fullBounds().height()+this.corner),this.bounds.setWidth(a.fullBounds().width()+2*this.cSlotPadding)):(this.bounds.setHeight(4*this.corner+this.cSlotPadding),this.bounds.setWidth(4*this.corner+2*this.inset+this.dent+2*this.cSlotPadding));this.parent&&this.parent.fixLayout&&this.parent.fixLayout()}; CSlotMorph.prototype.fixLoopLayout=function(){var a;this.isLoop&&(a=this.loop())&&(a.setRight(this.right()-this.corner),a.setBottom(this.bottom()+this.cSlotPadding+this.edge))};CSlotMorph.prototype.loop=function(){return this.isLoop?detect(this.children,a=>a instanceof SymbolMorph):null};CSlotMorph.prototype.fixHolesLayout=function(){this.holes=[new Rectangle(this.inset,this.corner,this.width(),this.height()-this.corner)]}; CSlotMorph.prototype.isLocked=function(){return this.isStatic||this.parent instanceof MultiArgMorph};CSlotMorph.prototype.render=function(a){MorphicPreferences.isFlat||(this.cachedClr=this.color.toString(),this.cachedClrBright=this.bright(),this.cachedClrDark=this.dark(),a.fillStyle=this.cachedClr,this.drawTopRightEdge(a),this.drawTopEdge(a,this.inset,this.corner),this.drawTopLeftEdge(a),this.drawBottomEdge(a),this.drawRightEdge(a))}; @@ -948,9 +948,9 @@ InputSlotMorph.prototype.init=function(a,b,c,d){var e=new InputSlotStringMorph(" !0;e.isDraggable=!1;e.enableSelecting();this.setContents(a)};InputSlotMorph.prototype.getSpec=function(){return this.isNumeric?"%n":"%s"};InputSlotMorph.prototype.contents=function(){return detect(this.children,a=>a instanceof StringMorph)};InputSlotMorph.prototype.arrow=function(){return detect(this.children,a=>a instanceof ArrowMorph)};InputSlotMorph.prototype.getConstantDisplayName=function(a){return"serviceNames"===this.choices?a.split("/").pop():a}; InputSlotMorph.prototype.setContents=function(a){var b=this.contents(),c=a,d=c instanceof Array;this.selectedBlock&&(this.selectedBlock=null);if(d)c=localize(this.getConstantDisplayName(c[0])),b.isItalic=!this.isReadOnly;else if(c instanceof BlockMorph)this.selectedBlock=c,c="";else if(b.isItalic=!1,!isNil(this.choices)&&this.choices[c]instanceof Array)return this.setContents(this.choices[c]);b.text=c;isNil(c)?b.text="":c.toString&&(b.text=c.toString());this.isReadOnly&&!MorphicPreferences.isFlat&& (b.shadowOffset=new Point(1,1));b.fixLayout();this.constant=d?a:null;this.lastValue=a;this.isReadOnly&&this.parent instanceof BlockMorph&&this.parent.fixLabelColor()};InputSlotMorph.prototype.userSetContents=function(a){this.selectForEdit().updateFieldValue(a)};InputSlotMorph.prototype.dropDownMenu=async function(a){var b=this.world().hand.position(),c=await this.menuFromDict(this.choices,null,a);c&&0m.fullImage()}var f,g=this,h=new MenuMorph(this.userSetContents,null,this,this.fontSize);if(a instanceof Function)a=await a.call(this);else if(isString(a)&&(a=await this[a](c),!a))return;b||h.addItem(" ",null);for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&("~"===f[0]?h.addLine():0===f.indexOf("\u00a7_def")?h.addItem(this.doWithAlpha(1,e(a[f])),a[f]):0=== -f.indexOf("\u00a7_dir")?(b=new DialMorph,b.rootForGrab=function(){return this},b.target=this,b.action=d,b.fillColor=this.parent.color,b.setRadius(3*this.fontSize),b.setValue(+this.evaluate(),!1,!0),h.addLine(),h.items.push(b),h.addLine()):0===f.indexOf("\u00a7_")?16===this.world().currentKey&&h.addItem(f.slice(2),a[f],null,null,null,!0,null,null,!(a[f]instanceof Array)&&"function"!==typeof a[f]):"__shout__go__"===f?(b=new SymbolMorph("flag"),b.size=1.5*this.fontSize,b.setColor(new Color(0,200,0)), -b.fixLayout(),h.addItem(b,["__shout__go__"])):a[f]instanceof Object&&!(a[f]instanceof Array)&&"function"!==typeof a[f]?h.addMenu(f,await this.menuFromDict(a[f],!0),null,!0):a[f]instanceof Array&&a[f][0]instanceof Object&&"function"!==typeof a[f][0]?h.addMenu(f,await this.menuFromDict(a[f][0],!0),null,!1):h.addItem(f,a[f],null,null,null,null,null,null,!(a[f]instanceof Array)&&"function"!==typeof a[f]));return h}; +InputSlotMorph.prototype.menuFromDict=async function(a,b,c){function d(m){g.setContents(m);g.reactToSliderEdit()}function e(m){return()=>m.fullImage()}var f,g=this,k=new MenuMorph(this.userSetContents,null,this,this.fontSize);if(a instanceof Function)a=await a.call(this);else if(isString(a)&&(a=await this[a](c),!a))return;b||k.addItem(" ",null);for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&("~"===f[0]?k.addLine():0===f.indexOf("\u00a7_def")?k.addItem(this.doWithAlpha(1,e(a[f])),a[f]):0=== +f.indexOf("\u00a7_dir")?(b=new DialMorph,b.rootForGrab=function(){return this},b.target=this,b.action=d,b.fillColor=this.parent.color,b.setRadius(3*this.fontSize),b.setValue(+this.evaluate(),!1,!0),k.addLine(),k.items.push(b),k.addLine()):0===f.indexOf("\u00a7_")?16===this.world().currentKey&&k.addItem(f.slice(2),a[f],null,null,null,!0,null,null,!(a[f]instanceof Array)&&"function"!==typeof a[f]):"__shout__go__"===f?(b=new SymbolMorph("flag"),b.size=1.5*this.fontSize,b.setColor(new Color(0,200,0)), +b.fixLayout(),k.addItem(b,["__shout__go__"])):a[f]instanceof Object&&!(a[f]instanceof Array)&&"function"!==typeof a[f]?k.addMenu(f,await this.menuFromDict(a[f],!0),null,!0):a[f]instanceof Array&&a[f][0]instanceof Object&&"function"!==typeof a[f][0]?k.addMenu(f,await this.menuFromDict(a[f][0],!0),null,!1):k.addItem(f,a[f],null,null,null,null,null,null,!(a[f]instanceof Array)&&"function"!==typeof a[f]));return k}; InputSlotMorph.prototype.messageTypesMenu=function(){for(var a=this.parentThatIsA(BlockMorph).scriptTarget().parentThatIsA(StageMorph).messageTypes.names(),b={},c=a.length;c--;)b[a[c]]=a[c];return b};InputSlotMorph.prototype.messageTypes=function(){for(var a=this.parentThatIsA(IDE_Morph).stage.messageTypes.names(),b={},c=a.length;c--;)b[a[c]]=a[c];return b}; InputSlotMorph.prototype.roleNames=function(){for(var a=this.root().children[0],b=a.room.getRoleNames(),c={},d=b.length;d--;)a.projectName!==b[d]&&(c[b[d]]=b[d]);c["others in room"]=["others in room"];c["everyone in room"]=["everyone in room"];return c};InputSlotMorph.prototype.getURL=function(a){try{return utils.getUrlSync(a)}catch(b){return""}}; InputSlotMorph.prototype.rpcActions=function(){var a=this.parent.inputs()[0],b={},c;a&&(c=a.evaluate());if(c)for(a=Object.keys(JSON.parse(this.getURL("/rpc/"+c))),c=a.length;c--;)b[a[c]]=a[c];return b}; @@ -991,8 +991,8 @@ this.edge,0,this.width(),0);c.addColorStop(0,this.cachedClrBright);c.addColorSto InputSlotMorph.prototype.drawRoundBorder=function(a){var b=.5*this.edge,c=Math.max((this.height()-2*this.edge)/2,0);a.lineWidth=this.edge;a.lineJoin="round";a.lineCap="round";var d=c+this.edge;var e=this.width()-c-this.edge;if(e>d){a.shadowOffsetX=b;a.shadowOffsetY=b;a.shadowBlur=this.edge;a.shadowColor=this.color.darker(80).toString();var f=a.createLinearGradient(0,0,0,this.edge);f.addColorStop(0,this.cachedClr);f.addColorStop(1,this.cachedClrDark);a.strokeStyle=f;a.beginPath();a.moveTo(d,b);a.lineTo(e, b);a.stroke();a.shadowOffsetX=0;a.shadowOffsetY=0;a.shadowBlur=0}f=a.createLinearGradient(0,this.height()-this.edge,0,this.height());f.addColorStop(0,this.cachedClrBright);f.addColorStop(1,this.cachedClr);a.strokeStyle=f;a.beginPath();a.moveTo(c+this.edge,this.height()-b);a.lineTo(this.width()-c-this.edge,this.height()-b);a.stroke();c=Math.max(this.height()/2,this.edge);a.shadowOffsetX=b;a.shadowOffsetY=b;a.shadowBlur=this.edge;a.shadowColor=this.color.darker(80).toString();f=a.createRadialGradient(c, c,c-this.edge,c,c,c);f.addColorStop(1,this.cachedClr);f.addColorStop(0,this.cachedClrDark);a.strokeStyle=f;a.beginPath();a.arc(c,c,c-b,radians(180),radians(270),!1);a.stroke();a.shadowOffsetX=0;a.shadowOffsetY=0;a.shadowBlur=0;f=a.createRadialGradient(this.width()-c,c,c-this.edge,this.width()-c,c,c);f.addColorStop(1,this.cachedClr);f.addColorStop(0,this.cachedClrBright);a.strokeStyle=f;a.beginPath();a.arc(this.width()-c,c,c-b,radians(0),radians(90),!1);a.stroke()};InputSlotStringMorph.prototype=new StringMorph; -InputSlotStringMorph.prototype.constructor=InputSlotStringMorph;InputSlotStringMorph.uber=StringMorph.prototype;function InputSlotStringMorph(a,b,c,d,e,f,g,h,m,l){this.init(a,b,c,d,e,f,g,h,m,l)}InputSlotStringMorph.prototype.getRenderColor=function(){return MorphicPreferences.isFlat?this.isEditable?this.color:.5this.progress||(this.isStatic?(b=this.textLabelExtent(),f=this.height()-(this.height()-b.y)/2,c=this.value?this.height()/2:this.width()-this.height()/2-b.x,a.save(),MorphicPreferences.isFlat||(a.shadowOffsetX=-e,a.shadowOffsetY=-e,a.shadowBlur=e,a.shadowColor=this.value?"rgb(0, 100, 0)":"rgb(100, 0, 0)"),a.font=(new StringMorph(null,this.fontSize, null,!0)).font(),a.textAlign="left",a.textBaseline="bottom",a.fillStyle="rgb(255, 255, 255",a.fillText(localize(this.value?"true":"false"),c,f),a.restore()):(c=c+2*this.edge+e,MorphicPreferences.isFlat||(a.shadowOffsetX=-e,a.shadowOffsetY=-e,a.shadowBlur=e,a.shadowColor="rgb(0, 100, 0)"),a.strokeStyle="white",a.lineWidth=this.edge+e,a.lineCap="round",a.lineJoin="miter",a.beginPath(),a.moveTo(c-d,f),a.lineTo(c,f+d),a.lineTo(c+d,d+this.edge),a.stroke(),c=b-f-2*this.edge,MorphicPreferences.isFlat||(a.shadowOffsetX= -e,a.shadowOffsetY=-e,a.shadowBlur=e,a.shadowColor="rgb(100, 0, 0)"),a.strokeStyle="white",a.lineWidth=this.edge,a.lineCap="butt",a.beginPath(),a.moveTo(c-d,f-d),a.lineTo(c+d,f+d),a.moveTo(c-d,f+d),a.lineTo(c+d,f-d),a.stroke()))}; -BooleanSlotMorph.prototype.drawKnob=function(a,b){var c=this.width(),d=this.height()/2,e=this.edge/2,f=(this.width()-this.height())/4*Math.max(0,b||0),g=PushButtonMorph.prototype.outline/2,h=PushButtonMorph.prototype.outlineColor,m=PushButtonMorph.prototype.color,l=PushButtonMorph.prototype.contrast,k=m.lighter(l);l=m.darker(l);switch(this.value){case !1:c=d+f;MorphicPreferences.isFlat||(a.shadowOffsetX=e,a.shadowOffsetY=0,a.shadowBlur=e,a.shadowColor="black");0>b&&(a.globalAlpha=.6);break;case !0:c= -c-d-f;MorphicPreferences.isFlat||(a.shadowOffsetX=0,a.shadowOffsetY=0,a.shadowBlur=0);break;default:if(!b)return;c=d;MorphicPreferences.isFlat||(a.shadowOffsetX=e,a.shadowOffsetY=0,a.shadowBlur=e,a.shadowColor="black");a.globalAlpha=.6}a.fillStyle=m.toString();a.beginPath();a.arc(c,d,d,radians(0),radians(360));a.closePath();a.fill();MorphicPreferences.isFlat||(a.shadowOffsetX=0,a.shadowBlur=0,a.shadowColor="black",a.lineWidth=g,a.strokeStyle=h.toString(),a.beginPath(),a.arc(c,d,d-g/2,radians(0),radians(360)), -a.stroke(),b=a.createRadialGradient(c,d,d-g-this.edge,c,d,d-g),b.addColorStop(1,k.toString()),b.addColorStop(0,m.toString()),a.strokeStyle=b,a.lineCap="round",a.lineWidth=this.edge,a.beginPath(),a.arc(c,d,d-g-this.edge/2,radians(180),radians(270),!1),a.stroke(),b=a.createRadialGradient(c,d,d-g-this.edge,c,d,d-g),b.addColorStop(1,l.toString()),b.addColorStop(0,m.toString()),a.strokeStyle=b,a.lineCap="round",a.lineWidth=this.edge,a.beginPath(),a.arc(c,d,d-g-this.edge/2,radians(0),radians(90),!1),a.stroke()); +BooleanSlotMorph.prototype.drawKnob=function(a,b){var c=this.width(),d=this.height()/2,e=this.edge/2,f=(this.width()-this.height())/4*Math.max(0,b||0),g=PushButtonMorph.prototype.outline/2,k=PushButtonMorph.prototype.outlineColor,m=PushButtonMorph.prototype.color,l=PushButtonMorph.prototype.contrast,h=m.lighter(l);l=m.darker(l);switch(this.value){case !1:c=d+f;MorphicPreferences.isFlat||(a.shadowOffsetX=e,a.shadowOffsetY=0,a.shadowBlur=e,a.shadowColor="black");0>b&&(a.globalAlpha=.6);break;case !0:c= +c-d-f;MorphicPreferences.isFlat||(a.shadowOffsetX=0,a.shadowOffsetY=0,a.shadowBlur=0);break;default:if(!b)return;c=d;MorphicPreferences.isFlat||(a.shadowOffsetX=e,a.shadowOffsetY=0,a.shadowBlur=e,a.shadowColor="black");a.globalAlpha=.6}a.fillStyle=m.toString();a.beginPath();a.arc(c,d,d,radians(0),radians(360));a.closePath();a.fill();MorphicPreferences.isFlat||(a.shadowOffsetX=0,a.shadowBlur=0,a.shadowColor="black",a.lineWidth=g,a.strokeStyle=k.toString(),a.beginPath(),a.arc(c,d,d-g/2,radians(0),radians(360)), +a.stroke(),b=a.createRadialGradient(c,d,d-g-this.edge,c,d,d-g),b.addColorStop(1,h.toString()),b.addColorStop(0,m.toString()),a.strokeStyle=b,a.lineCap="round",a.lineWidth=this.edge,a.beginPath(),a.arc(c,d,d-g-this.edge/2,radians(180),radians(270),!1),a.stroke(),b=a.createRadialGradient(c,d,d-g-this.edge,c,d,d-g),b.addColorStop(1,l.toString()),b.addColorStop(0,m.toString()),a.strokeStyle=b,a.lineCap="round",a.lineWidth=this.edge,a.beginPath(),a.arc(c,d,d-g-this.edge/2,radians(0),radians(90),!1),a.stroke()); a.globalAlpha=1};BooleanSlotMorph.prototype.textLabelExtent=function(){var a=new StringMorph(localize("true"),this.fontSize,null,!0);var b=new StringMorph(localize("false"),this.fontSize,null,!0);return new Point(Math.max(a.width(),b.width()),a.height())};ArrowMorph.prototype=new Morph;ArrowMorph.prototype.constructor=ArrowMorph;ArrowMorph.uber=Morph.prototype;function ArrowMorph(a,b,c,d,e){this.init(a,b,c,d,e)} ArrowMorph.prototype.init=function(a,b,c,d,e){this.direction=a||"down";this.size=b||(0===b?0:50);this.padding=c||0;this.isBlockLabel=e||!1;ArrowMorph.uber.init.call(this);this.color=d||BLACK;this.bounds.setWidth(this.size);this.bounds.setHeight(this.size);this.rerender()};ArrowMorph.prototype.setSize=function(a){var b=Math.max(a,1);this.size=a;this.changed();this.bounds.setWidth(b);this.bounds.setHeight(b);this.rerender()}; ArrowMorph.prototype.render=function(a){var b=this.padding,c=this.height(),d=Math.floor(c/2),e=this.width(),f=Math.floor(e/2);a.fillStyle=this.getRenderColor().toString();a.beginPath();"down"===this.direction?(a.moveTo(b,d),a.lineTo(e-b,d),a.lineTo(f,c-b)):"up"===this.direction?(a.moveTo(b,d),a.lineTo(e-b,d),a.lineTo(f,b)):("left"===this.direction?(a.moveTo(b,d),a.lineTo(f,b)):(a.moveTo(f,b),a.lineTo(e-b,d)),a.lineTo(f,c-b));a.closePath();a.fill()}; ArrowMorph.prototype.getRenderColor=function(){return this.isBlockLabel?MorphicPreferences.isFlat?this.color:.5a instanceof TextMorph)};TextSlotMorph.prototype.layoutChanged=function(){this.fixLayout()}; -SymbolMorph.prototype.drawSymbolQueue=function(a,b){var c=a.getContext("2d"),d=a.width/5,e=d/2,f=3*d,g=1*e+f/2,h=e;c.fillStyle=b.toString();var m=function(l){l+=d;var k=f/2;c.fillStyle=b.toString();c.beginPath();c.moveTo(l,g);c.lineTo(l+-1*d,g+k/2);c.lineTo(l+-1*d,g-k/2);c.fill()};m(h);h+=d+e;c.fillRect(h,e,d,f);h+=d+e;c.fillRect(h,e,d,f);m(h+(d+e));return a}; +SymbolMorph.prototype.drawSymbolQueue=function(a,b){var c=a.getContext("2d"),d=a.width/5,e=d/2,f=3*d,g=1*e+f/2,k=e;c.fillStyle=b.toString();var m=function(l){l+=d;var h=f/2;c.fillStyle=b.toString();c.beginPath();c.moveTo(l,g);c.lineTo(l+-1*d,g+h/2);c.lineTo(l+-1*d,g-h/2);c.fill()};m(k);k+=d+e;c.fillRect(k,e,d,f);k+=d+e;c.fillRect(k,e,d,f);m(k+(d+e));return a}; SymbolMorph.prototype.drawSymbolFootprints=function(a,b){var c=a.getContext("2d"),d=a.width,e=d/10,f=1.5*e;c.fillStyle=b.toString();c.beginPath();c.arc(f,f,f,radians(-200),radians(0),!1);c.lineTo(2*f,5.5*e);c.lineTo(e,6*e);c.closePath();c.fill();c.beginPath();c.arc(2.25*e,6.75*e,e,radians(-40),radians(-170),!1);c.closePath();c.fill();c.beginPath();c.arc(d-f,4.5*e,f,radians(-180),radians(20),!1);c.lineTo(d-e,8.5*e);c.lineTo(d-2*f,8*e);c.closePath();c.fill();c.beginPath();c.arc(d-2.25*e,9*e,e,radians(0), radians(-150),!1);c.closePath();c.fill();return a}; SymbolMorph.prototype.drawSymbolNetsBloxLogo=function(a,b){var c=a.getContext("2d"),d=a.width,e=a.height,f=d/14,g=d-2*f;c.beginPath();c.arc(d/2,e/2,2*f,radians(180),radians(270));c.strokeStyle=b.toString();c.beginPath();c.arc(d/2,e/2,f,0,radians(360));c.stroke();c.beginPath();c.arc(d/2,e/2,2*f,0,radians(90));c.stroke();c.beginPath();c.arc(d/2,e/2,3*f,0,radians(90));c.stroke();c.beginPath();c.arc(d/2,e/2,2*f,radians(180),radians(270));c.stroke();c.beginPath();c.arc(d/2,e/2,3*f,radians(180),radians(270)); -c.stroke();b=-60;let h=f;e/=2;g/=2;for(d=g-2*f-d/48;300>b;){var m=h,l=e,k=radians(b);const n=d*Math.cos(k),p=d*Math.sin(k),q=f*Math.cos(k)+m,r=f*Math.sin(k)+l;c.beginPath();c.arc(m,l,f,k,k+2*Math.PI);c.moveTo(q,r);c.lineTo(m+n,l+p);c.stroke();h+=g*Math.cos(radians(b));e+=g*Math.sin(radians(b));b+=60}return a};ColorSlotMorph.prototype=new ArgMorph;ColorSlotMorph.prototype.constructor=ColorSlotMorph;ColorSlotMorph.uber=ArgMorph.prototype;function ColorSlotMorph(a){this.init(a)} +c.stroke();b=-60;let k=f;e/=2;g/=2;for(d=g-2*f-d/48;300>b;){var m=k,l=e,h=radians(b);const n=d*Math.cos(h),p=d*Math.sin(h),q=f*Math.cos(h)+m,r=f*Math.sin(h)+l;c.beginPath();c.arc(m,l,f,h,h+2*Math.PI);c.moveTo(q,r);c.lineTo(m+n,l+p);c.stroke();k+=g*Math.cos(radians(b));e+=g*Math.sin(radians(b));b+=60}return a};ColorSlotMorph.prototype=new ArgMorph;ColorSlotMorph.prototype.constructor=ColorSlotMorph;ColorSlotMorph.uber=ArgMorph.prototype;function ColorSlotMorph(a){this.init(a)} ColorSlotMorph.prototype.init=function(a){ColorSlotMorph.uber.init.call(this);this.alpha=1;this.setColor(a||new Color(145,26,68))};ColorSlotMorph.prototype.getSpec=function(){return"%clr"}; -ColorSlotMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=this.color,e=getDocumentPositionOf(b.worldCanvas),f=c.processMouseMove,g=c.processMouseDown,h=c.processMouseUp,m=new ColorPaletteMorph(null,new Point(16*this.fontSize,10*this.fontSize));b.add(m);m.setPosition(this.bottomLeft().add(new Point(0,this.edge)));var l=Morph.prototype.fullImage.call(b).getContext("2d");c.processMouseMove=function(k){var n=c.position();n=l.getImageData(n.x,n.y,1,1).data;c.setPosition(new Point(k.pageX- -e.x,k.pageY-e.y));a.setColor(new Color(n[0],n[1],n[2]))};c.processMouseDown=nop;c.processMouseUp=function(){a.parentThatIsA(ScriptsMorph)?SnapActions.setColorField(a,a.color).catch(function(){a.setColor(d)}):a.setColor(a.color);m.destroy();c.processMouseMove=f;c.processMouseDown=g;c.processMouseUp=h}};ColorSlotMorph.prototype.mouseClickLeft=function(){this.selectForEdit().getUserColor()};ColorSlotMorph.prototype.evaluate=function(){return this.color}; +ColorSlotMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=this.color,e=getDocumentPositionOf(b.worldCanvas),f=c.processMouseMove,g=c.processMouseDown,k=c.processMouseUp,m=new ColorPaletteMorph(null,new Point(16*this.fontSize,10*this.fontSize));b.add(m);m.setPosition(this.bottomLeft().add(new Point(0,this.edge)));var l=Morph.prototype.fullImage.call(b).getContext("2d");c.processMouseMove=function(h){var n=c.position();n=l.getImageData(n.x,n.y,1,1).data;c.setPosition(new Point(h.pageX- +e.x,h.pageY-e.y));a.setColor(new Color(n[0],n[1],n[2]))};c.processMouseDown=nop;c.processMouseUp=function(){a.parentThatIsA(ScriptsMorph)?SnapActions.setColorField(a,a.color).catch(function(){a.setColor(d)}):a.setColor(a.color);m.destroy();c.processMouseMove=f;c.processMouseDown=g;c.processMouseUp=k}};ColorSlotMorph.prototype.mouseClickLeft=function(){this.selectForEdit().getUserColor()};ColorSlotMorph.prototype.evaluate=function(){return this.color}; ColorSlotMorph.prototype.fixLayout=function(){var a=this.fontSize+2*this.edge+2*this.typeInPadding;this.bounds.setWidth(a);this.bounds.setHeight(a)}; ColorSlotMorph.prototype.render=function(a){var b=this.parent?this.parent.color:new Color(120,120,120);a.fillStyle=this.color.toString();this.cachedClr=b.toString();this.cachedClrBright=b.lighter(this.contrast).toString();this.cachedClrDark=b.darker(this.contrast).toString();a.fillRect(this.edge,this.edge,this.width()-2*this.edge,this.height()-2*this.edge);MorphicPreferences.isFlat||this.drawRectBorder(a)};ColorSlotMorph.prototype.drawRectBorder=InputSlotMorph.prototype.drawRectBorder; BlockHighlightMorph.prototype=new Morph;BlockHighlightMorph.prototype.constructor=BlockHighlightMorph;BlockHighlightMorph.uber=Morph.prototype;function BlockHighlightMorph(){this.threadCount=0;this.init()}BlockHighlightMorph.prototype.init=function(){BlockHighlightMorph.uber.init.call(this);this.isCachingImage=!0};BlockHighlightMorph.prototype.readout=function(){return this.children.length?this.children[0]:null}; BlockHighlightMorph.prototype.updateReadout=function(){var a=this.readout(),b=useBlurredShadows&&!MorphicPreferences.isFlat?.4*SyntaxElementMorph.prototype.activeBlur:-2*SyntaxElementMorph.prototype.activeBorder;2>this.threadCount?a&&a.destroy():(a?(a.changed(),a.contents=this.threadCount.toString(),a.fixLayout(),a.rerender()):(a=new SpeechBubbleMorph(this.threadCount.toString(),this.color,null,null,this.color.darker(),null,1,!0),this.add(a)),a.setPosition(this.position().add(b)))}; -MultiArgMorph.prototype=new ArgMorph;MultiArgMorph.prototype.constructor=MultiArgMorph;MultiArgMorph.uber=ArgMorph.prototype;function MultiArgMorph(a,b,c,d,e,f,g,h,m,l,k){this.init(a,b,c,d,e,f,g,h,m,l,k)} -MultiArgMorph.prototype.init=function(a,b,c,d,e,f,g,h,m,l,k){var n=new FrameMorph;this.slotSpec=a||"%s";this.labelText=b instanceof Array?b.map(p=>localize(p||"")):localize(b||"");this.infix=l||"";this.collapse=k||"";this.minInputs=c||0;this.elementSpec=d||null;this.labelColor=f||null;this.shadowColor=g||null;this.shadowOffset=h||null;this.canBeEmpty=!0;MultiArgMorph.uber.init.call(this);this.alpha=!1===m?1:0;n.alpha=!1===m?1:0;if(this.labelText||"%cs"===this.slotSpec)a=this.labelPart(this.labelText instanceof +MultiArgMorph.prototype=new ArgMorph;MultiArgMorph.prototype.constructor=MultiArgMorph;MultiArgMorph.uber=ArgMorph.prototype;function MultiArgMorph(a,b,c,d,e,f,g,k,m,l,h){this.init(a,b,c,d,e,f,g,k,m,l,h)} +MultiArgMorph.prototype.init=function(a,b,c,d,e,f,g,k,m,l,h){var n=new FrameMorph;this.slotSpec=a||"%s";this.labelText=b instanceof Array?b.map(p=>localize(p||"")):localize(b||"");this.infix=l||"";this.collapse=h||"";this.minInputs=c||0;this.elementSpec=d||null;this.labelColor=f||null;this.shadowColor=g||null;this.shadowOffset=k||null;this.canBeEmpty=!0;MultiArgMorph.uber.init.call(this);this.alpha=!1===m?1:0;n.alpha=!1===m?1:0;if(this.labelText||"%cs"===this.slotSpec)a=this.labelPart(this.labelText instanceof Array?this.labelText[0]:this.labelText),this.add(a),a.hide();a=new ArrowMorph("left",this.fontSize,Math.max(Math.floor(this.fontSize/6),1),e,!0);e=new ArrowMorph("right",this.fontSize,Math.max(Math.floor(this.fontSize/6),1),e,!0);n.add(a);n.add(e);n.rerender();n.acceptsDrops=!1;this.add(n);for(n=0;na instanceof BlockLabelMorph)};MultiArgMorph.prototype.arrows=function(){return this.children[this.children.length-1]};MultiArgMorph.prototype.getSpec=function(){return"%mult"+this.slotSpec};MultiArgMorph.prototype.setContents=function(a){var b=this.inputs(),c;a instanceof Array||"%rcv"!==this.slotSpec||(a=[a]);for(c=0;cthis.mapCodeList(c));a.addItem("code item mapping...",()=>this.mapCodeItem(c));a.addItem("code delimiter mapping...",()=>this.mapCodeDelimiter(c));return a}; MultiArgMorph.prototype.mapCodeDelimiter=function(a){this.mapToCode(a+"delim","list item delimiter")};MultiArgMorph.prototype.mapCodeList=function(a){this.mapToCode(a+"list","list contents <#1>")};MultiArgMorph.prototype.mapCodeItem=function(a){this.mapToCode(a+"item","list item <#1>")};MultiArgMorph.prototype.mapToCode=function(a,b){(new DialogBoxMorph(this,c=>StageMorph.prototype.codeMappings[a]=c,this)).promptCode("Code mapping - "+b,StageMorph.prototype.codeMappings[a]||"",this.world())}; -MultiArgMorph.prototype.mappedCode=function(a){var b=this.parentThatIsA(BlockMorph),c="",d="",e=0,f=[];b&&(b instanceof RingMorph?c="parms_":"doDeclareVariables"===b.selector&&(c="tempvars_"));b=StageMorph.prototype.codeMappings[c+"list"]||"<#1>";var g=StageMorph.prototype.codeMappings[c+"item"]||"<#1>";var h=StageMorph.prototype.codeMappings[c+"delim"]||" ";this.inputs().forEach(m=>f.push(g.replace(/<#1>/g,m.mappedCode(a))));f.forEach(m=>{e&&(d+=h);d+=m;e+=1});return b=b.replace(/<#1>/g,d)}; +MultiArgMorph.prototype.mappedCode=function(a){var b=this.parentThatIsA(BlockMorph),c="",d="",e=0,f=[];b&&(b instanceof RingMorph?c="parms_":"doDeclareVariables"===b.selector&&(c="tempvars_"));b=StageMorph.prototype.codeMappings[c+"list"]||"<#1>";var g=StageMorph.prototype.codeMappings[c+"item"]||"<#1>";var k=StageMorph.prototype.codeMappings[c+"delim"]||" ";this.inputs().forEach(m=>f.push(g.replace(/<#1>/g,m.mappedCode(a))));f.forEach(m=>{e&&(d+=k);d+=m;e+=1});return b=b.replace(/<#1>/g,d)}; MultiArgMorph.prototype.evaluate=function(){var a=[];this.inputs().forEach(b=>a.push(b.evaluate()));return a};MultiArgMorph.prototype.isEmptySlot=function(){return this.canBeEmpty?0===this.inputs().length:!1};ArgLabelMorph.prototype=new ArgMorph;ArgLabelMorph.prototype.constructor=ArgLabelMorph;ArgLabelMorph.uber=ArgMorph.prototype;function ArgLabelMorph(a,b){this.init(a,b)} ArgLabelMorph.prototype.init=function(a,b){this.labelText=localize(b||"input list:");ArgLabelMorph.uber.init.call(this);this.isStatic=!0;this.alpha=0;b=this.labelPart(this.labelText);this.add(b);this.add(a)};ArgLabelMorph.prototype.label=function(){return this.children[0]};ArgLabelMorph.prototype.argMorph=function(){return this.children[1]}; ArgLabelMorph.prototype.fixLayout=function(){var a=this.label();if(this.parent){this.color=this.parent.color;var b=a.shadowOffset||ZERO;var c=0>b.x?this.parent.color.darker(this.labelContrast):this.parent.color.lighter(this.labelContrast);""===this.labelText||a.shadowColor.eq(c)||(a.shadowColor=c,a.shadowOffset=b,a.rerender())}ArgLabelMorph.uber.fixLayout.call(this);this.parent&&this.parent.fixLayout()};ArgLabelMorph.prototype.refresh=function(){this.inputs().forEach(a=>{a.fixLayout();a.rerender()})}; @@ -1112,8 +1112,8 @@ ScriptFocusMorph.prototype.deleteLastElement=function(){var a=this.element,b=thi b.editor.adjustBounds();b.fixLayout()});return}}else if(a instanceof CommandBlockMorph){if(this.atEnd){var d=a.parent;SnapActions.removeBlock(a,!0).then(function(){b.element=d;b.editor.adjustBounds();b.fixLayout()});return}a.parent instanceof CommandBlockMorph&&(c=SnapActions.removeBlock(a.parent,!0))}c&&c.then(function(){b.editor.adjustBounds();b.fixLayout()})}; ScriptFocusMorph.prototype.insertBlock=ScriptFocusMorph.prototype.fillInBlock=function(a){var b,c,d;a.isTemplate=!1;a.isDraggable=!0;if(this.element instanceof ScriptsMorph){if(a instanceof CommandBlockMorph)if(a.isStop())var e=this.topLeft();else{e=new Point(this.left(),this.top()-a.height());var f=!0}else e=new Point(this.left(),this.center().y+a.height()/2);a=SnapActions.addBlock(a,this.editor.scriptTarget(),e)}else if(this.element instanceof CommandBlockMorph){if(this.atEnd)var g={point:this.element.bottomAttachPoint(), element:this.element,loc:"bottom",type:"block"};else e=this.element.parent,e instanceof ScriptsMorph?g={point:this.element.topAttachPoint(),element:this.element,loc:"top",type:"block"}:e instanceof CommandSlotMorph?e.nestedBlock(a):e instanceof RingReporterSlotMorph?(a.nextBlock(e.nestedBlock()),e.add(a),e.fixLayout()):e instanceof CommandBlockMorph&&(g={point:e.bottomAttachPoint(),element:e,loc:"bottom",type:"block"});a=SnapActions.moveBlock(a,g)}else this.element instanceof CommandSlotMorph?(g= -{point:this.element.slotAttachPoint(),element:this.element,loc:"bottom",type:"slot"},f=!0,a=SnapActions.moveBlock(a,g)):(e=this.element.parent,e instanceof ScriptsMorph?a=SnapActions.replaceBlock(this.element,a):(f=!0,a=SnapActions.moveBlock(a,this.element)));a.then(h=>{f&&(this.atEnd=!0);"receiveCondition"===h.selector&&(d=this.editor.scriptTarget())&&(b=d.parentThatIsA(StageMorph))&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,(c=b.parentThatIsA(IDE_Morph))&&c.controlBar.stopButton.refresh()); -this.element=h;this.fixLayout();h.inputs&&h.inputs().length&&(this.element=h,this.atEnd=!1,this.nextElement())})}; +{point:this.element.slotAttachPoint(),element:this.element,loc:"bottom",type:"slot"},f=!0,a=SnapActions.moveBlock(a,g)):(e=this.element.parent,e instanceof ScriptsMorph?a=SnapActions.replaceBlock(this.element,a):(f=!0,a=SnapActions.moveBlock(a,this.element)));a.then(k=>{f&&(this.atEnd=!0);"receiveCondition"===k.selector&&(d=this.editor.scriptTarget())&&(b=d.parentThatIsA(StageMorph))&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,(c=b.parentThatIsA(IDE_Morph))&&c.controlBar.stopButton.refresh()); +this.element=k;this.fixLayout();k.inputs&&k.inputs().length&&(this.element=k,this.atEnd=!1,this.nextElement())})}; ScriptFocusMorph.prototype.insertVariableGetter=function(){var a=this.blockTypes(),b=new MenuMorph;a&&contains(a,"reporter")&&(a=InputSlotMorph.prototype.getVarNamesDict.call(this.element),Object.keys(a).forEach(c=>{var d=SpriteMorph.prototype.variableBlock(c);d.addShadow(new Point(3,3));b.addItem(d,()=>{d.removeShadow();this.insertBlock(d)})}),0b&&(b=a.length-1);this.element=a[b]}this.element instanceof CommandSlotMorph&&this.element.nestedBlock()?this.lastElement():this.element instanceof HatBlockMorph&&(1f.description))b+= `\n${e.name}: ${e.description} ${e.optional?"[optional]":""}`;b+=`\n\nDocumentation can be found at:\n${SERVER_URL}/docs/services/${a}/${d.categories&&d.categories.length?d.categories[0]:"index"}.html#${a}.${c}`}else b=d.description,b+=`\n\nDocumentation can be found at:\n${SERVER_URL}/docs/services/${a}/index.html`;b||="Description not available"}else{d=await d.getServicesMetadata();var e=d.slice(0,3).map(function(f){return f.name});b="Get information from different providers, save information and more. \nTo get more help select one of the services: "+ -e.join(", ")+" ..."}return this.showCustomHelp({msg:b,keptInputs:[0,1]})};BlockMorph.prototype.isServiceBlock=function(){return contains(["getJSFromRPCStruct","doRunRPC"],this.selector)};MultiHintArgMorph.prototype=new MultiArgMorph;MultiHintArgMorph.prototype.constructor=MultiHintArgMorph;MultiHintArgMorph.uber=MultiArgMorph.prototype;MultiHintArgMorph.prototype.executeOnSliderEdit=!1;function MultiHintArgMorph(a,b,c,d,e,f,g,h,m){this.init(a,b,c,d,e,f,g,h,m)} -MultiHintArgMorph.prototype.init=function(a,b,c,d,e,f,g,h,m){this.hintText=a||"";MultiHintArgMorph.uber.init.call(this,"%s",b,c,d,e,f,g,h,m);0===this.inputs().length&&this.addInput()};MultiHintArgMorph.prototype.addInput=function(){var a=this.labelPart("%hint"+this.hintText),b=this.children.length-1;a.parent=this;this.children.splice(b,0,a);a.rerender();this.fixLayout()}; +e.join(", ")+" ..."}return this.showCustomHelp({msg:b,keptInputs:[0,1]})};BlockMorph.prototype.isServiceBlock=function(){return contains(["getJSFromRPCStruct","doRunRPC"],this.selector)};MultiHintArgMorph.prototype=new MultiArgMorph;MultiHintArgMorph.prototype.constructor=MultiHintArgMorph;MultiHintArgMorph.uber=MultiArgMorph.prototype;MultiHintArgMorph.prototype.executeOnSliderEdit=!1;function MultiHintArgMorph(a,b,c,d,e,f,g,k,m){this.init(a,b,c,d,e,f,g,k,m)} +MultiHintArgMorph.prototype.init=function(a,b,c,d,e,f,g,k,m){this.hintText=a||"";MultiHintArgMorph.uber.init.call(this,"%s",b,c,d,e,f,g,k,m);0===this.inputs().length&&this.addInput()};MultiHintArgMorph.prototype.addInput=function(){var a=this.labelPart("%hint"+this.hintText),b=this.children.length-1;a.parent=this;this.children.splice(b,0,a);a.rerender();this.fixLayout()}; MultiHintArgMorph.prototype.mouseClickLeft=function(a){var b=this.selectForEdit(),c=b.arrows(),d=c.children[0];c=c.children[1];var e=16===b.world().currentKey?3:1;if(c.bounds.containsPoint(a))for(a=0;a{e=e.url;try{return utils.getUrlSyncCached(`${e}/input-types`,f=>JSON.parse(f),{ttl:5E3,cacheFailures:!0})}catch(f){return console.warn("No input types found for "+e),{}}});d=Object.assign(...d);for(c=c.type;c;c=d[c.name].baseType){if("Number"=== c.name)return new HintInputSlotMorph(b||"",a,!0,void 0,!1);if("Enum"===c.name){d={};for(const e of c.params)d[e]=e;return new HintInputSlotMorph(b||"",a,!1,d,!0)}}return new HintInputSlotMorph(b||"",a,!1,void 0,!1)}return b}; -InputSlotMorph.prototype.serviceNames=async function(){const a=this.parentThatIsA(IDE_Morph)??world?.children[0],b=await a.services.getServicesMetadata();let c={};for(let e=b.length;e--;){const {name:f,url:g,categories:h}=b[e];if(0===h.length)c[f]=g?[g+"/"+f]:f;else for(let m=h.length;m--;){const l=h[m];if(0===l.length){c[f]=g?[g+"/"+f]:f;continue}let k=c;for(const n of l)k[n]||(k[n]={}),k=k[n];k[f]=g?[g+"/"+f]:f}}c=sortDict(c);const d=a.cloud;if(d.username&&c.Community&&c.Community[d.username]){const e= +InputSlotMorph.prototype.serviceNames=async function(){const a=this.parentThatIsA(IDE_Morph)??world?.children[0],b=await a.services.getServicesMetadata();let c={};for(let e=b.length;e--;){const {name:f,url:g,categories:k}=b[e];if(0===k.length)c[f]=g?[g+"/"+f]:f;else for(let m=k.length;m--;){const l=k[m];if(0===l.length){c[f]=g?[g+"/"+f]:f;continue}let h=c;for(const n of l)h[n]||(h[n]={}),h=h[n];h[f]=g?[g+"/"+f]:f}}c=sortDict(c);const d=a.cloud;if(d.username&&c.Community&&c.Community[d.username]){const e= {};e[d.username]=c.Community[d.username];Object.keys(c.Community).forEach(function(f){f!==d.username&&(e[f]=c.Community[f])});c.Community=e}return c};RPCInputSlotMorph.prototype=new StructInputSlotMorph;RPCInputSlotMorph.prototype.constructor=RPCInputSlotMorph;RPCInputSlotMorph.uber=StructInputSlotMorph.prototype; function RPCInputSlotMorph(){const a=b=>{if(!b)return[];if(!this.fieldsFor||!this.fieldsFor[b])if(this.methodSignature(),!this.fieldsFor){this.fieldsFor={};var c='Service "'+this.getServiceName()+'" is not available';world.children[0].showMessage&&world.children[0].showMessage(c)}if(this.fieldsFor[b])return this.fieldsFor[b].args};StructInputSlotMorph.call(this,null,!1,"methodSignature",b=>{if(b=a(b))return b.map(c=>c.name)},!0,a)} RPCInputSlotMorph.prototype.getServiceInputSlot=function(){var a=this.parent.inputs();var b=a.indexOf(this);return a[b-1]};RPCInputSlotMorph.prototype.getServiceName=function(){var a=this.getServiceInputSlot();return a?a.constant?([a]=a.evaluate(),a.split("/").pop()):a.evaluate():null}; RPCInputSlotMorph.prototype.getServiceMetadata=function(){var a=this.getServiceInputSlot();a.evaluate();const b=(this.parentThatIsA(IDE_Morph)??world?.children[0]).services;a=a.constant?a.evaluate()[0]:b.defaultHost.url+"/"+a.evaluate();return b.getServiceMetadataFromURLSync(a)}; -RPCInputSlotMorph.prototype.methodSignature=function(){function a(f,g){g.reduce((h,m)=>{h[m]||(h[m]={});return h[m]},b)[f]=f}var b={};const c=this.getServiceName();if(c){try{var d=this.getServiceMetadata();this.fieldsFor=d.rpcs;var e=Object.keys(this.fieldsFor);this.isCurrentRPCSupported=!0}catch(f){this.isCurrentRPCSupported=!1,e=this.parentThatIsA(BlockMorph),e.showBubble(localize('Service "'+c+'" is not available')),e=[]}e.forEach(f=>{const {deprecated:g,categories:h=[]}=this.fieldsFor[f];g||(h.length? -h.forEach(m=>a(f,m)):a(f,[]))})}return sortDict(b)};RPCInputSlotMorph.prototype.evaluate=function(){if(!this.isCurrentRPCSupported){var a=InputSlotMorph.prototype.evaluate.call(this);a=this.getFieldNames(a);this.isCurrentRPCSupported&&(this.fields=a)}return RPCInputSlotMorph.uber.evaluate.call(this)};HintInputSlotMorph.prototype=new InputSlotMorph;HintInputSlotMorph.prototype.constructor=HintInputSlotMorph;HintInputSlotMorph.uber=InputSlotMorph.prototype; +RPCInputSlotMorph.prototype.methodSignature=function(){function a(f,g){g.reduce((k,m)=>{k[m]||(k[m]={});return k[m]},b)[f]=f}var b={};const c=this.getServiceName();if(c){try{var d=this.getServiceMetadata();this.fieldsFor=d.rpcs;var e=Object.keys(this.fieldsFor);this.isCurrentRPCSupported=!0}catch(f){this.isCurrentRPCSupported=!1,e=this.parentThatIsA(BlockMorph),e.showBubble(localize('Service "'+c+'" is not available')),e=[]}e.forEach(f=>{const {deprecated:g,categories:k=[]}=this.fieldsFor[f];g||(k.length? +k.forEach(m=>a(f,m)):a(f,[]))})}return sortDict(b)};RPCInputSlotMorph.prototype.evaluate=function(){if(!this.isCurrentRPCSupported){var a=InputSlotMorph.prototype.evaluate.call(this);a=this.getFieldNames(a);this.isCurrentRPCSupported&&(this.fields=a)}return RPCInputSlotMorph.uber.evaluate.call(this)};HintInputSlotMorph.prototype=new InputSlotMorph;HintInputSlotMorph.prototype.constructor=HintInputSlotMorph;HintInputSlotMorph.uber=InputSlotMorph.prototype; function HintInputSlotMorph(a,b,c,d,e){var f=this;this.hintText=b;this.empty=!0;InputSlotMorph.call(this,a,c,d,e);d||(this.contents().mouseClickLeft=function(){f.isEmptySlot()&&(this.text="");StringMorph.prototype.mouseClickLeft.apply(this,arguments)})}HintInputSlotMorph.prototype.evaluate=function(){return this.isEmptySlot()?"":InputSlotMorph.prototype.evaluate.call(this)};const WHITE_HINT=new Color(190,190,190),BLACK_HINT=new Color(100,100,100); HintInputSlotMorph.prototype.setContents=function(a){const b=this.contents();let c;InputSlotMorph.prototype.setContents.apply(this,arguments);this.overrideBlack=this.overrideWhite=null;this.empty=!a||""===a;this.isEmptySlot()?(b.text=this.hintText,this.isReadOnly&&(this.overrideWhite=WHITE_HINT,this.overrideBlack=BLACK_HINT),c=this.isReadOnly?WHITE_HINT:BLACK_HINT):c=this.isReadOnly?WHITE:BLACK;b.fixLayout();b.color=c;b.rerender()};HintInputSlotMorph.prototype.changed=function(){return InputSlotMorph.prototype.changed.call(this)}; HintInputSlotMorph.prototype.isEmptySlot=function(){return this.empty};HintInputSlotMorph.prototype.updateFieldValue=function(a){var b=this.parentThatIsA(BlockMorph);a=void 0!==a?a:this.contents().text;const c=a!==this.lastValue;if(b.id&&c)return this.setContents(this.lastValue),SnapActions.setField(this,a);this.setContents(a)}; var addStructReplaceSupport=function(a){return function(b){for(var c,d=-1,e=this.inputs(),f=e.indexOf(b),g=e.length;g--;)e[g]instanceof StructInputSlotMorph&&(d=g,c=e[g]);c&&d=f-d?(d=f-d-1,c=c.getFieldValue(c.fields[d],null,c.fieldsMeta&&d=a;a+=1)NONNUMBERS.push(String.fromCharCode(a));NONNUMBERS.push(String.fromCharCode(160))})(); function snapEquals(a,b){if(a instanceof List||b instanceof List)return a instanceof List&&b instanceof List?a.equalTo(b):!1;var c=+a,d=+b;if(isNaN(c)||isNaN(d)||[a,b].some(e=>contains(NONNUMBERS,e)||isString(e)&&-1d)throw Error(localize(e||"a synchronous Snap! script has timed out"));m.runStep(d)}return h?m.homeContext:m.homeContext.inputs[0]}function ThreadManager(){this.processes=[];this.wantsToPause=!1}ThreadManager.prototype.pauseCustomHatBlocks=!1; +function invoke(a,b,c,d,e,f,g,k){var m=new Process;d=d?Date.now()+d:null;if(a instanceof Context)c&&(a=m.reportContextFor(c)),m.initializeFor(a,b||new List);else if(a instanceof BlockMorph){m.topBlock=a;if(c)m.homeContext=new Context,m.homeContext.receiver=c,c.variables&&(m.homeContext.variables.parentFrame=c.variables);else throw Error("expecting a receiver but getting "+c);m.context=new Context(null,a.blockSequence(),m.homeContext)}else{if(a.evaluate)return a.evaluate();if(a instanceof Function)return a.apply(c, +b.asArray().concat(g));throw Error("expecting a block or ring but getting "+a);}f&&(m.isCatchingErrors=!1);for(;m.isRunning();){if(d&&Date.now()>d)throw Error(localize(e||"a synchronous Snap! script has timed out"));m.runStep(d)}return k?m.homeContext:m.homeContext.inputs[0]}function ThreadManager(){this.processes=[];this.wantsToPause=!1}ThreadManager.prototype.pauseCustomHatBlocks=!1; ThreadManager.prototype.toggleProcess=function(a,b){var c=this.findProcess(a,b);if(c)c.stop();else return this.startProcess(a,b,null,null,null,!0)}; -ThreadManager.prototype.startProcess=function(a,b,c,d,e,f,g,h,m){a=a.topBlock();var l=this.findProcess(a,b);if(l){if(c)return l;l.stop();l.canBroadcast=!0;this.removeTerminatedProcesses()}var k=new Process(a,b,e,f);k.exportResult=d;k.isClicked=f||!1;k.isAtomic=h||!1;m instanceof VariableFrame&&Object.keys(m.vars).forEach(n=>k.context.outerContext.variables.vars[n]=m.vars[n]);(b=a.getHighlight())?(b.threadCount=this.processesForBlock(a).length+1,b.updateReadout()):a.addHighlight();this.processes.push(k); -g&&k.runStep();return k};ThreadManager.prototype.stopAll=function(a){this.processes.forEach(b=>{b!==a&&b.stop()})};ThreadManager.prototype.stopAllForReceiver=function(a,b){this.processes.forEach(c=>{c.homeContext.receiver===a&&c!==b&&(c.stop(),a.isTemporary&&(c.isDead=!0))})};ThreadManager.prototype.stopAllForBlock=function(a){this.processesForBlock(a,!0).forEach(b=>b.stop())};ThreadManager.prototype.stopProcess=function(a,b){(a=this.findProcess(a,b))&&a.stop()}; +ThreadManager.prototype.startProcess=function(a,b,c,d,e,f,g,k,m){a=a.topBlock();var l=this.findProcess(a,b);if(l){if(c)return l;l.stop();l.canBroadcast=!0;this.removeTerminatedProcesses()}var h=new Process(a,b,e,f);h.exportResult=d;h.isClicked=f||!1;h.isAtomic=k||!1;m instanceof VariableFrame&&Object.keys(m.vars).forEach(n=>h.context.outerContext.variables.vars[n]=m.vars[n]);(b=a.getHighlight())?(b.threadCount=this.processesForBlock(a).length+1,b.updateReadout()):a.addHighlight();this.processes.push(h); +g&&h.runStep();return h};ThreadManager.prototype.stopAll=function(a){this.processes.forEach(b=>{b!==a&&b.stop()})};ThreadManager.prototype.stopAllForReceiver=function(a,b){this.processes.forEach(c=>{c.homeContext.receiver===a&&c!==b&&(c.stop(),a.isTemporary&&(c.isDead=!0))})};ThreadManager.prototype.stopAllForBlock=function(a){this.processesForBlock(a,!0).forEach(b=>b.stop())};ThreadManager.prototype.stopProcess=function(a,b){(a=this.findProcess(a,b))&&a.stop()}; ThreadManager.prototype.pauseAll=function(a){this.processes.forEach(b=>b.pause());a&&a.pauseAllActiveSounds()};ThreadManager.prototype.isPaused=function(){return null!==detect(this.processes,a=>a.isPaused)};ThreadManager.prototype.resumeAll=function(a){this.processes.forEach(b=>b.resume());a&&a.resumeAllActiveSounds()}; ThreadManager.prototype.step=function(){var a;if(Process.prototype.enableSingleStepping&&(this.processes.forEach(b=>{b.isInterrupted?(b.runStep(),a=!0):b.lastYield=Date.now()}),this.wantsToPause=.5{b.homeContext.receiver.isPickedUp()||b.isDead||b.runStep()});this.removeTerminatedProcesses()}; ThreadManager.prototype.removeTerminatedProcesses=function(){var a=[],b;this.processes.forEach(c=>{if(!c.isRunning()&&!c.errorFlag||c.isDead){if(c.topBlock instanceof BlockMorph)if(c.unflash(),b=this.processesForBlock(c.topBlock).length){var d=c.topBlock.getHighlight()||c.topBlock.addHighlight();d.threadCount=b;d.updateReadout()}else c.topBlock.removeHighlight();c.prompter&&(c.prompter.destroy(),c.homeContext.receiver.stopTalking&&c.homeContext.receiver.stopTalking());if(c.topBlock instanceof ReporterBlockMorph|| @@ -1193,15 +1193,15 @@ Process.prototype.reify=function(a,b,c){var d=new Context(null,null,this.context d.receiver=this.context?this.context.receiver:this.receiver;d.origin=d.receiver;return d};Process.prototype.reportScript=function(a,b){return this.reify(b,a)};Process.prototype.reifyScript=function(a,b){return this.reify(a,b)};Process.prototype.reifyReporter=function(a,b){return this.reify(a,b)};Process.prototype.reifyPredicate=function(a,b){return this.reify(a,b)};Process.prototype.reportJSFunction=function(a,b){return Function.apply(null,a.asArray().concat([b]))}; Process.prototype.doRun=function(a,b){return this.evaluate(a,b,!0)}; Process.prototype.evaluate=function(a,b,c){if(!a)return this.returnValueToParentContext(null);if(a instanceof Function)return a.apply(this.blockReceiver(),b.asArray().concat([this]));if(a.isContinuation)return this.runContinuation(a,b);if(!(a instanceof Context))throw Error("expecting a ring but getting "+a);var d=new Context(null,null,a.outerContext),e=this.context.parentContext,f=b.asArray();d.receiver||(d.receiver=a.receiver);var g=new Context(this.context.parentContext,a.expression,d,a.receiver); -g.isCustomCommand=c;this.context.parentContext=g;a.expression instanceof ReporterBlockMorph&&(this.readyToYield=Date.now()-this.lastYield>this.timeout);d.variables.addVar(Symbol.for("arguments"),b);if(0this.timeout);d.variables.addVar(Symbol.for("arguments"),b);if(0a);)"doStopWarping"===this.context.expression?this.doStopWarping():this.popContext();this.pushContext()};Process.prototype.doStopCustomBlock=function(){for(;this.context&&!this.context.isCustomBlock;)"doStopWarping"===this.context.expression?this.doStopWarping():this.popContext()}; Process.prototype.doCallCC=function(a,b){this.evaluate(a,new List([this.context.continuation(b)]),!b)};Process.prototype.reportCallCC=function(a){this.doCallCC(a,!0)};Process.prototype.runContinuation=function(a,b){b=b.asArray();"expectReport"===a.expression&&b.length?(this.stop(),this.homeContext.inputs[0]=b[0]):(this.context.parentContext=a.copyForContinuationCall(),1===b.length&&this.context.parentContext.outerContext.variables.addVar(1,b[0]))}; -Process.prototype.evaluateCustomBlock=function(){var a=this.context.parentContext,b=this.context.expression,c=b.isGlobal?b.definition:this.blockReceiver().getMethod(b.semanticSpec),d=c.body,e=c.declarations,f=(new List(this.context.inputs)).asArray(),g;if(!d)return null;this.procedureCount+=1;var h=new Context;h.receiver=this.context.receiver;h.variables.parentFrame=b.variables;c.variableNames.length?b.variables.parentFrame=h.receiver?h.receiver.variables:null:h.variables.parentFrame=h.receiver?h.receiver.variables: -null;b=new Context(this.context.parentContext,d.expression,h,h.receiver);b.isCustomBlock=!0;this.context.parentContext=b;if(0 +Process.prototype.evaluateCustomBlock=function(){var a=this.context.parentContext,b=this.context.expression,c=b.isGlobal?b.definition:this.blockReceiver().getMethod(b.semanticSpec),d=c.body,e=c.declarations,f=(new List(this.context.inputs)).asArray(),g;if(!d)return null;this.procedureCount+=1;var k=new Context;k.receiver=this.context.receiver;k.variables.parentFrame=b.variables;c.variableNames.length?b.variables.parentFrame=k.receiver?k.receiver.variables:null:k.variables.parentFrame=k.receiver?k.receiver.variables: +null;b=new Context(this.context.parentContext,d.expression,k,k.receiver);b.isCustomBlock=!0;this.context.parentContext=b;if(0 this.timeout):(b.expression.tagExitBlocks(this.procedureCount,!0),a&&!a.tag&&(a.tag=this.procedureCount),!this.isAtomic&&c.isDirectlyRecursive()&&(this.readyToYield=!0));b.expression=b.expression.blockSequence()};Process.prototype.doDeclareVariables=function(a){var b=this.context.outerContext.variables;a.asArray().forEach(c=>b.addVar(c))}; Process.prototype.doSetVar=function(a,b){var c=this.context.variables;a instanceof Context?"reportGetVar"===a.expression.selector?a.variables.setVar(a.expression.blockSpec,b,this.blockReceiver()):this.doSet(a,b):a instanceof Array?this.doSet(a,b):c.setVar(a,b,this.blockReceiver())}; Process.prototype.doChangeVar=function(a,b){var c=this.context.variables;a instanceof Context&&"reportGetVar"===a.expression.selector?a.variables.changeVar(a.expression.blockSpec,b,this.blockReceiver()):c.changeVar(a,b,this.blockReceiver())};Process.prototype.reportGetVar=function(){return this.context.variables.getVar(this.context.expression.blockSpec)}; @@ -1260,17 +1260,17 @@ Process.prototype.doSayFor=function(a,b){this.context.startTime||(this.context.s Process.prototype.doThinkFor=function(a,b){this.context.startTime||(this.context.startTime=Date.now(),this.blockReceiver().doThink(a));if(Date.now()-this.context.startTime>=1E3*b)return this.blockReceiver().stopTalking(),null;this.pushContext("doYield");this.pushContext()};Process.prototype.blockReceiver=function(){return this.context?this.context.receiver||this.homeContext.receiver:this.homeContext.receiver||this.receiver}; Process.prototype.playSound=function(a){return a instanceof List?this.doPlaySoundAtRate(a,44100):this.blockReceiver().doPlaySound(a)};Process.prototype.doPlaySoundUntilDone=function(a){null===this.context.activeAudio&&(this.context.activeAudio=this.playSound(a));if(null===a||this.context.activeAudio.ended||this.context.activeAudio.terminated)return null;this.pushContext("doYield");this.pushContext()}; Process.prototype.doStopAllSounds=function(){var a=this.homeContext.receiver.parentThatIsA(StageMorph);a&&(a.threads.processes.forEach(b=>{b.context&&(b.context.stopMusic(),b.context.activeAudio&&b.popContext())}),a.stopAllActiveSounds())}; -Process.prototype.doPlaySoundAtRate=function(a,b){if(a instanceof List)var c=a;else{c=a instanceof Sound?a:"number"===typeof a?this.blockReceiver().sounds.at(a):detect(this.blockReceiver().sounds.asArray(),m=>m.name===a.toString());if(!c.audioBuffer){this.decodeSound(c);return}c=this.reportGetSoundAttribute("samples",c)}var d=this.blockReceiver();var e=d.audioContext();var f=d.getGainNode();var g=d.getPannerNode();var h=this.encodeSound(c,b);d.setVolume(d.volume);h.connect(f);g?(f.connect(g),g.connect(e.destination), -d.setPan(d.pan)):f.connect(e.destination);h.pause=h.stop;h.ended=!1;h.onended=()=>h.ended=!0;h.start();d.parentThatIsA(StageMorph).activeSounds.push(h);return h}; +Process.prototype.doPlaySoundAtRate=function(a,b){if(a instanceof List)var c=a;else{c=a instanceof Sound?a:"number"===typeof a?this.blockReceiver().sounds.at(a):detect(this.blockReceiver().sounds.asArray(),m=>m.name===a.toString());if(!c.audioBuffer){this.decodeSound(c);return}c=this.reportGetSoundAttribute("samples",c)}var d=this.blockReceiver();var e=d.audioContext();var f=d.getGainNode();var g=d.getPannerNode();var k=this.encodeSound(c,b);d.setVolume(d.volume);k.connect(f);g?(f.connect(g),g.connect(e.destination), +d.setPan(d.pan)):f.connect(e.destination);k.pause=k.stop;k.ended=!1;k.onended=()=>k.ended=!0;k.start();d.parentThatIsA(StageMorph).activeSounds.push(k);return k}; Process.prototype.reportGetSoundAttribute=function(a,b){var c=b instanceof Sound?b:"number"===typeof b?this.blockReceiver().sounds.at(b):b instanceof List?this.encodeSound(b):detect(this.blockReceiver().sounds.asArray(),d=>d.name===b.toString());a=this.inputOption(a);if("name"===a)return c.name;if(c.audioBuffer)switch(a){case "samples":return c.cachedSamples||(c.cachedSamples=function(d,e){d=d.audioBuffer;var f;if(1{a.audioBuffer=f;a.isDecoding=!1},f=>{a.isDecoding=!1;this.handleError(f)})}this.pushContext("doYield");this.pushContext()}; -Process.prototype.encodeSound=function(a,b){var c=this.blockReceiver().audioContext(),d=a.at(1)instanceof List?a.length():1,e=1===d?a.length():a.at(1).length();b=c.createBuffer(d,e,+b||44100);var f;b.copyToChannel||(b.copyToChannel=function(g,h){h=this.getChannelData(h);for(f=0;f{c.src=d.result;this.context.accumulator.audio=c};d.readAsDataURL(a)}if(this.context.accumulator.audio)return new Sound(this.context.accumulator.audio,this.blockReceiver().newSoundName(localize("sound")));this.pushContext("doYield"); -this.pushContext()};Process.prototype.audioBufferToWav=function(a,b){var c=a.numberOfChannels,d=a.sampleRate;b=(b||{}).float32?3:1;var e=3===b?32:16;if(2===c){var f=a.getChannelData(0);a=a.getChannelData(1);for(var g=f.length+a.length,h=new Float32Array(g),m=0,l=0;mu?32768*u:32767*u,!0)}}function h(p,q,r){for(var t=0;tu?32768*u:32767*u,!0)}}function k(p,q,r){for(var t=0;ta.indexOf("//")||8this.getOtherObject(g,e,b));else return}else f=b.children.concat(b);""!==c&&(b.lastMessage=a,f.forEach(g=>{isSnapObject(g)&& -g.allHatBlocksFor(c).forEach(h=>{d.push(b.threads.startProcess(h,g,b.isThreadSafe))})}),(b.messageCallbacks[""]||[]).forEach(g=>g(c)),(b.messageCallbacks[c]||[]).forEach(g=>g()));return d}; +g.allHatBlocksFor(c).forEach(k=>{d.push(b.threads.startProcess(k,g,b.isThreadSafe))})}),(b.messageCallbacks[""]||[]).forEach(g=>g(c)),(b.messageCallbacks[c]||[]).forEach(g=>g()));return d}; Process.prototype.doBroadcastAndWait=function(a){this.context.activeSends||(this.context.activeSends=this.doBroadcast(a),this.isRunning()&&this.context.activeSends.forEach(b=>b.runStep()));this.context.activeSends=this.context.activeSends.filter(b=>b.isRunning());if(0===this.context.activeSends.length)return null;this.pushContext("doYield");this.pushContext()}; Process.prototype.getLastMessage=function(){var a;return this.homeContext.receiver&&(a=this.homeContext.receiver.parentThatIsA(StageMorph))?a.getLastMessage():""};Process.prototype.doSend=function(a,b){var c=this.homeContext.receiver.parentThatIsA(StageMorph);this.doBroadcast(new List([a,b instanceof List?b:b===c.name?new List([c]):new List([b])]))};Process.prototype.reportIsA=function(a,b){return this.reportTypeOf(a)===this.inputOption(b)}; Process.prototype.assertType=function(a,b){a=this.reportTypeOf(a);if(a===b||b instanceof Array&&contains(b,a))return!0;throw Error("expecting "+b+" but getting "+a);};Process.prototype.assertAlive=function(a){if(a&&a.isCorpse)throw Error("cannot operate on a deleted sprite");}; @@ -1305,7 +1305,7 @@ Process.prototype.reportUnicode=function(a){if(this.enableHyperOps){if(a instanc Process.prototype.reportUnicodeAsLetter=function(a){if(this.enableHyperOps&&a instanceof List)return a.map(b=>this.reportUnicodeAsLetter(b));a=+(a||0);return String.fromCodePoint?String.fromCodePoint(a):String.fromCharCode(a)};Process.prototype.reportTextSplit=function(a,b){return this.hyperDyadic((c,d)=>this.reportBasicTextSplit(c,d),a,b)}; Process.prototype.reportBasicTextSplit=function(a,b){var c=["text","number"],d=this.reportTypeOf(a),e=this.reportTypeOf(this.inputOption(b));if(!contains(c,d))throw Error("expecting text instead of a "+d);if(!contains(c,e))throw Error("expecting a text delimiter instead of a "+e);c=isNil(a)?"":a.toString();switch(this.inputOption(b)){case "line":a=/\r\n|[\n\v\f\r\x85\u2028\u2029]/;break;case "tab":a="\t";break;case "cr":a="\r";break;case "word":case "whitespace":c=c.trim();a=/\s+/;break;case "letter":a= "";break;case "csv":return this.parseCSV(a);case "json":return this.parseJSON(a);default:a=isNil(b)?"":b.toString()}return new List(c.split(a))};Process.prototype.parseCSV=function(a){return this.rawParseCSV(a,this.guessDelimiterCSV(a))};Process.prototype.guessDelimiterCSV=function(a){var b=[",",";","|","\t"],c=b.length;a=a.split("\n")[0];var d;for(d=0;dnew List(n)));return 1===e.length()?e.at(1):e}; +Process.prototype.rawParseCSV=function(a,b){var c="",d=[""],e=[d],f=0,g=0,k=!0,m=a.length,l;b=b||",";for(l=0;lnew List(n)));return 1===e.length()?e.at(1):e}; Process.prototype.parseJSON=function(a){function b(c){return c instanceof Array?new List(c.map(function(d){return b(d)})):c instanceof Object?new List(Object.keys(c).map(function(d){return new List([d,b(c[d])])})):c}return b(JSON.parse(a))};Process.prototype.alert=function(a){if(this.homeContext.receiver){var b=this.homeContext.receiver.world();b.isDevMode&&alert("Snap! "+a.asArray())}}; Process.prototype.log=function(a){if(this.homeContext.receiver){var b=this.homeContext.receiver.world();b.isDevMode&&console.log("Snap! "+a.asArray())}};Process.prototype.getOtherObject=function(a,b,c){if(isSnapObject(a))return a;if("myself"===this.inputOption(a))return b;b=isNil(c)?b.parentThatIsA(StageMorph):c;c=null;b&&((c=detect(b.children,d=>d.name===a))||(c=detect(b.world().hand.children,d=>d instanceof SpriteMorph&&d.name===a)));return c}; Process.prototype.getObjectsNamed=function(a,b,c){function d(e){return e instanceof SpriteMorph&&e.isTemporary?e.cloneOriginName===a:e.name===a}b=isNil(c)?b.parentThatIsA(StageMorph):c;c=[];b&&(c=b.children.filter(d),c.length||(c=b.world().hand.children.filter(d)));return c};Process.prototype.setHeading=function(a){var b=this.blockReceiver();b&&("random"===this.inputOption(a)&&(a=this.reportBasicRandom(1,36E3)/100),b.setHeading(a))}; @@ -1324,9 +1324,9 @@ Process.prototype.colorAtSprite=function(a){var b=a instanceof SpriteMorph?a.rot Process.prototype.colorBelowSprite=function(a){var b=a instanceof SpriteMorph?a.rotationCenter():a.center(),c=a.parentThatIsA(StageMorph),d=c,e=!1,f;if(!c)return BLACK;for(f=0;fc instanceof SpriteMorph&&c.isVisible&&c.bounds.containsPoint(a)&&!c.isTransparentAt(a)))};Process.prototype.reportRelationTo=function(a,b){if(this.enableHyperOps&&b instanceof List&&!this.isCoordinate(b))return b.map(d=>this.reportRelationTo(a,d));var c=this.inputOption(a);return"distance"===c?this.reportDistanceTo(b):"ray length"===c?this.reportRayLengthTo(b):"direction"===c?this.reportDirectionTo(b):0}; Process.prototype.reportDistanceTo=function(a){var b=this.blockReceiver(),c;if(b){var d=c=b.rotationCenter();if("mouse-pointer"===this.inputOption(a))d=b.world().hand.position();else{if("center"===this.inputOption(a))return(new Point(b.xPosition(),b.yPosition())).distanceTo(ZERO);if(a instanceof List)return(new Point(b.xPosition(),b.yPosition())).distanceTo(new Point(a.at(1),a.at(2)))}var e=b.parentThatIsA(StageMorph);(a=this.getOtherObject(a,b,e))&&(d=a.rotationCenter());return c.distanceTo(d)/e.scale}return 0}; -Process.prototype.reportRayLengthTo=function(a){var b=this.blockReceiver(),c=[],d,e,f,g;var h=x=>Math.round(1E7*x)/1E7;var m=x=>{var z=radians(p);e=k.y-x;d=e*Math.tan(z);f=k.x+d;(h(f)===h(k.x)&&(180===p&&k.yx)||f>k.x&&0<=p&&180>p||h(f)p)&&f>=u&&f<=v&&c.push(new Point(f,x))};var l=x=>{var z=radians(360-p-90);e=k.x-x;d=e*Math.tan(z);g=k.y+d;(h(g)===h(k.y)&&(90===p&&k.xx)||g>k.y&&90<=p&&270>p||gp))&&g>=r&&g<=t&&c.push(new Point(x, -g))};if(!b)return-1;var k=b.rotationCenter();var n=b.parentThatIsA(StageMorph);a=this.getOtherObject(a,b,n);if(!(a instanceof SpriteMorph))return-1;var p=b.heading;var q=a.bounds;var r=q.top();var t=q.bottom();var u=q.left();var v=q.right();if(q.containsPoint(k)){if(c.push(k),m(r),m(t),l(u),l(v),2>c.length)return-1}else{m(r);m(t);l(u);l(v);if(2>c.length)return-1;90===p||Math.sign(k.x-c[0].x)===Math.sign(c[0].x-c[1].x)&&Math.sign(k.y-c[0].y)===Math.sign(c[0].y-c[1].y)||(b=c[0],c[0]=c[1],c[1]=b)}c= -c.map(x=>x.subtract(q.origin).floorDivideBy(n.scale));var w=Math.floor(q.width()/n.scale);var y=a.getImageData();b=function(x,z,A,B,C){for(var F=Math.abs(B-z),K=zI&&(E+=I,z+=K);OMath.round(1E7*x)/1E7;var m=x=>{var z=radians(p);e=h.y-x;d=e*Math.tan(z);f=h.x+d;(k(f)===k(h.x)&&(180===p&&h.yx)||f>h.x&&0<=p&&180>p||k(f)p)&&f>=u&&f<=v&&c.push(new Point(f,x))};var l=x=>{var z=radians(360-p-90);e=h.x-x;d=e*Math.tan(z);g=h.y+d;(k(g)===k(h.y)&&(90===p&&h.xx)||g>h.y&&90<=p&&270>p||gp))&&g>=r&&g<=t&&c.push(new Point(x, +g))};if(!b)return-1;var h=b.rotationCenter();var n=b.parentThatIsA(StageMorph);a=this.getOtherObject(a,b,n);if(!(a instanceof SpriteMorph))return-1;var p=b.heading;var q=a.bounds;var r=q.top();var t=q.bottom();var u=q.left();var v=q.right();if(q.containsPoint(h)){if(c.push(h),m(r),m(t),l(u),l(v),2>c.length)return-1}else{m(r);m(t);l(u);l(v);if(2>c.length)return-1;90===p||Math.sign(h.x-c[0].x)===Math.sign(c[0].x-c[1].x)&&Math.sign(h.y-c[0].y)===Math.sign(c[0].y-c[1].y)||(b=c[0],c[0]=c[1],c[1]=b)}c= +c.map(x=>x.subtract(q.origin).floorDivideBy(n.scale));var w=Math.floor(q.width()/n.scale);var y=a.getImageData();b=function(x,z,A,B,C){for(var F=Math.abs(B-z),K=zI&&(E+=I,z+=K);Ob.name===a.toString())}; Process.prototype.reportNewCostume=function(a,b,c,d){var e;this.assertType(a,"list");if("current"===this.inputOption(b)){var f=this.blockReceiver();var g=f.parentThatIsA(StageMorph);b=f.costume?f.costume.width():g.dimensions.x}"current"===this.inputOption(c)&&(f=f||this.blockReceiver(),g=g||f.parentThatIsA(StageMorph),c=f.costume?f.costume.height():g.dimensions.y);b=Math.abs(Math.floor(+b));c=Math.abs(Math.floor(+c));if(0>=b||0>=c)return new Costume;if(!isFinite(b*c)||isNaN(b*c))throw Error("expecting a finite number\nbut getting Infinity or NaN"); -g=newCanvas(new Point(b,c),!0);var h=g.getContext("2d");a=a.asArray();b=h.createImageData(b,c);for(c=0;ce;e+=1)b.data[4*c+e]=m[e]}h.putImageData(b,0,0);return new Costume(g,d||(f||this.blockReceiver()).newCostumeName(localize("costume")))}; +g=newCanvas(new Point(b,c),!0);var k=g.getContext("2d");a=a.asArray();b=k.createImageData(b,c);for(c=0;ce;e+=1)b.data[4*c+e]=m[e]}k.putImageData(b,0,0);return new Costume(g,d||(f||this.blockReceiver()).newCostumeName(localize("costume")))}; Process.prototype.reportPentrailsAsSVG=function(){if(!this.context.accumulator){var a=this.homeContext.receiver.parentThatIsA(StageMorph);if(!a.trailsLog.length)throw Error(localize("there are currently no\nvectorizable pen trail segments"));a=a.trailsLogAsSVG();this.context.accumulator={img:new Image,rot:a.rot,ready:!1};var b=this.context.accumulator;b.img.onload=()=>b.ready=!0;b.img.src="data:image/svg+xml,"+a.src;b.img.rot=a.rotationShift}else if(this.context.accumulator.ready){var c=ZERO;a=this.blockReceiver(); a instanceof SpriteMorph&&(c=new Point(a.xPosition(),-a.yPosition()));this.returnValueToParentContext(new SVG_Costume(this.context.accumulator.img,this.blockReceiver().newCostumeName(localize("Costume")),this.context.accumulator.rot.translateBy(c)));return}this.pushContext()};Process.prototype.inputOption=function(a){return a instanceof Array?a[0]:a}; Process.prototype.pushContext=function(a,b){this.context=new Context(this.context,a,b||(this.context?this.context.outerContext:null),this.context?this.context.receiver:this.homeContext.receiver)};Process.prototype.popContext=function(){this.context&&this.context.stopMusic();this.context=this.context?this.context.parentContext:null};Process.prototype.returnValueToParentContext=function(a){void 0!==a&&(this.context?this.context.parentContext||this.homeContext:this.homeContext).addInput(a)}; @@ -1371,12 +1371,12 @@ Process.prototype.unflash=function(){this.flashingContext&&(this.flashingContext Process.prototype.capture=function(a){var b=new Process(this.topBlock,this.receiver),c=new Context(a.parentContext,a.expression,a.outerContext,a.receiver);c.variables=a.variables.fullCopy();c.variables.root().parentFrame=b.variables;b.context=c;return b}; Process.prototype.getVarNamed=function(a){var b=this.homeContext.variables.silentFind(a)||this.context.variables.silentFind(a);if(b)return a=b.vars[a].value,0===a?0:!1===a?!1:""===a?"":a||0;throw Error(localize("a variable of name '")+a+localize("'\ndoes not exist in this context"));}; Process.prototype.setVarNamed=function(a,b){var c=this.homeContext.variables.silentFind(a)||this.context.variables.silentFind(a);if(isNil(c))throw Error(localize("a variable of name '")+a+localize("'\ndoes not exist in this context"));c.vars[a].value=b};Process.prototype.incrementVarNamed=function(a,b){this.setVarNamed(a,this.getVarNamed(a)+ +b)}; -Process.prototype.reportAtomicMap=function(a,b){this.assertType(b,"list");var c=[],d=b.asArray(),e=d.length,f=a.inputs.length,g;try{var h=this.reportCompiled(a,1)}catch(l){console.log(l.message),h=a}for(g=0;ginvoke(c,new List([d,e]),null,null,null,null,this.capture(b))?-1:1))}; -Process.prototype.reportAtomicGroup=function(a,b){this.assertType(a,"list");var c=[],d=new Map,e=a.asArray(),f=e.length,g;try{var h=this.reportCompiled(b,1)}catch(m){console.log(m.message),h=b}for(g=0;gc.push(new List([l,m.length,new List(m)])));return new List(c)}; +Process.prototype.reportAtomicGroup=function(a,b){this.assertType(a,"list");var c=[],d=new Map,e=a.asArray(),f=e.length,g;try{var k=this.reportCompiled(b,1)}catch(m){console.log(m.message),k=b}for(g=0;gc.push(new List([l,m.length,new List(m)])));return new List(c)}; function Context(a,b,c,d){this.outerContext=c||null;this.parentContext=a||null;this.expression=b||null;this.receiver=d||null;this.origin=d||null;this.variables=new VariableFrame;this.outerContext&&(this.variables.parentFrame=this.outerContext.variables,this.receiver=this.outerContext.receiver);this.inputs=[];this.pc=0;this.isContinuation=!1;this.activeNote=this.activeAudio=this.activeSends=this.startTime=null;this.isCustomBlock=!1;this.isCustomCommand=null;this.emptySlots=0;this.tag=null;this.isFlashing= !1;this.accumulator=null}Context.prototype.toString=function(){var a=this.expression;a instanceof Array&&0> "+a+" "+this.variables}; Context.prototype.blockify=function(){var a=new RingMorph,b;if(this.expression instanceof Morph){var c=this.expression.fullCopy();this.isContinuation&&(b=detect(c.allInputs(),d=>1===d.bindingID))&&c.revertToDefaultInput(b,!0);a.embed(c,this.inputs);return a}if(this.expression instanceof Array){c=this.expression[this.pc].fullCopy();if(c instanceof RingMorph&&!c.contents())return c;a.embed(c,this.isContinuation?[]:this.inputs);return a}a.color=SpriteMorph.prototype.blockColor.other;a.setSpec("%rc %ringparms"); @@ -1391,7 +1391,7 @@ VariableFrame.prototype.changeVar=function(a,b,c){var d=this.find(a);if(d){var e VariableFrame.prototype.getVar=function(a){var b=this.silentFind(a);if(b)return a=b.vars[a].value,0===a?0:!1===a?!1:""===a?"":a||0;if("number"===typeof a)return"";throw Error(localize("a variable of name '")+a+localize("'\ndoes not exist in this context"));};VariableFrame.prototype.addVar=function(a,b){this.vars[a]=new Variable(0===b?0:!1===b?!1:""===b?"":b||0)};VariableFrame.prototype.deleteVar=function(a){var b=this.find(a);b&&delete b.vars[a]}; VariableFrame.prototype.names=function(){var a,b=[];for(a in this.vars)Object.prototype.hasOwnProperty.call(this.vars,a)&&b.push(a);return b};VariableFrame.prototype.allNamesDict=function(a){for(var b={},c=this;c&&c!==a;){var d=void 0,e=c.vars,f=b;for(d in e)Object.prototype.hasOwnProperty.call(e,d)&&(f[d]=d);c=c.parentFrame}return b};VariableFrame.prototype.allNames=function(a){var b=[],c;a=this.allNamesDict(a);for(c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}; function JSCompiler(a){this.process=a;this.paramCount=this.implicitParams=this.gensyms=this.source=null}JSCompiler.prototype.toString=function(){return"a JSCompiler"}; -JSCompiler.prototype.compileFunction=function(a,b){var c=a.expression,d=a.inputs,e=[],f=!1;this.source=a;this.implicitParams=b||1;f=!isNil(detect(c.allChildren(),g=>g.isEmptySlot&&g.isEmptySlot()));this.gensyms={};this.paramCount=0;if(d.length){if(f)throw Error("compiling does not yet support\nmixing explicit formal parameters\nwith empty input slots");d.forEach((g,h)=>{h="p"+h;e.push(h);this.gensyms[g]=h})}else if(f)if(1g.isEmptySlot&&g.isEmptySlot()));this.gensyms={};this.paramCount=0;if(d.length){if(f)throw Error("compiling does not yet support\nmixing explicit formal parameters\nwith empty input slots");d.forEach((g,k)=>{k="p"+k;e.push(k);this.gensyms[g]=k})}else if(f)if(1b.shadowVar(f,b.variables.getVar(f))),this return b};SpriteMorph.prototype.appearIn=function(a){this.isTemporary||(this.name=a.newSpriteName(this.name),a.corral.addSprite(this),a.sprites.add(this));a.stage.add(this);this.parts.forEach(b=>b.appearIn(a))};SpriteMorph.prototype.setName=function(a){this.name=a||this.name;this.version=Date.now()}; SpriteMorph.prototype.getImage=function(){if(this.shouldRerender||!this.cachedImage)this.cachedImage=newCanvas(this.costume?this.imageExtent:this.extent(),!isNil(this.costume),this.cachedImage),this.render(this.cachedImage.getContext("2d")),this.shouldRerender=!1;return this.cachedImage}; SpriteMorph.prototype.fixLayout=function(){var a=[];var b=this.center();a=this.costume&&"function"===typeof this.costume.loaded;var c=this.parent instanceof StageMorph?this.parent.scale:1;var d=this.rotationStyle?this.heading:90;if(2===this.rotationStyle&&(d=90,180this.heading||0>this.heading&&-180m.rotateBy(radians(d-90),this.costume.center()));var f=a[0];var g=a[0]; -a.forEach(m=>{f=f.min(m);g=g.max(m)});var h=f.corner(g).extent().multiplyBy(this.scale*c);this.imageOffset=ZERO.rotateBy(radians(-(d-90)),e.center()).subtract(f);1===this.rotationStyle?(a=Math.sqrt(Math.pow(e.width(),2)+Math.pow(e.height(),2))*this.scale*c,this.imageExtent=new Point(a,a)):this.imageExtent=h;this.bounds.setExtent(h);this.setCenter(b,!0);this.rotationOffset=this.imageOffset.translateBy(e.rotationCenter).rotateBy(radians(-(d-90)),this.imageOffset).scaleBy(this.scale*c)}else d=e?-90: +a.forEach(m=>{f=f.min(m);g=g.max(m)});var k=f.corner(g).extent().multiplyBy(this.scale*c);this.imageOffset=ZERO.rotateBy(radians(-(d-90)),e.center()).subtract(f);1===this.rotationStyle?(a=Math.sqrt(Math.pow(e.width(),2)+Math.pow(e.height(),2))*this.scale*c,this.imageExtent=new Point(a,a)):this.imageExtent=k;this.bounds.setExtent(k);this.setCenter(b,!0);this.rotationOffset=this.imageOffset.translateBy(e.rotationCenter).rotateBy(radians(-(d-90)),this.imageOffset).scaleBy(this.scale*c)}else d=e?-90: d,c=Math.min(Math.max(this.normalExtent.x*this.scale*c,5),1E3),this.bounds.setWidth(c),this.bounds.setHeight(c),this.setCenter(b,!0),this.rotationOffset=this.extent().divideBy(2)}; SpriteMorph.prototype.render=function(a){var b=this;var c=this.costume&&"function"===typeof this.costume.loaded;var d=this.parent instanceof StageMorph?this.parent.scale:1;var e=this.rotationStyle?this.heading:90;if(2===this.rotationStyle&&(e=90,180this.heading||0>this.heading&&-180u.trim()).filter(u=>!!u);r.messageTypes.getMsgType(t)?k.inform("that name is already in use"):SnapActions.addMessageType(t,q)}var l=[],k=this;a=a||"motion";var n=this.inheritedVariableNames();if("motion"===a)l.push(b("forward")),l.push(b("turn")),l.push(b("turnLeft")),l.push("-"),l.push(b("setHeading")),l.push(b("doFaceTowards")),l.push("-"),l.push(b("gotoXY")),l.push(b("doGotoObject")),l.push(b("doGlide")),l.push("-"), +SpriteMorph.prototype.blockTemplates=function(a){function b(q,r){if(StageMorph.prototype.hiddenPrimitives[q])return null;q=SpriteMorph.prototype.blockForSelector(q,!0);q.isTemplate=!0;r&&q.ghost();return q}function c(q,r){r=SpriteMorph.prototype.variableBlock(q,r);r.isDraggable=!1;r.isTemplate=!0;contains(n,q)&&r.ghost();return r}function d(q){if(StageMorph.prototype.hiddenPrimitives[q])return null;var r=SpriteMorph.prototype.blocks[q];return new ToggleMorph("checkbox",this,function(){h.toggleWatcher(q, +localize(r.spec),h.blockColor[r.category])},null,function(){return h.showingWatcher(q)},null)}function e(q){return new ToggleMorph("checkbox",this,function(){h.toggleVariableWatcher(q)},null,function(){return h.showingVariableWatcher(q)},null)}function f(){var q=new MenuMorph(this);q.addItem("help...","showHelp");return q}function g(q){q&&(h.isVariableNameInUse(q[0],q[1])?h.inform("that name is already in use"):SnapActions.addVariable(q[0],q[1]||h.id))}function k(q){SnapActions.deleteVariable(q,h.id)} +function m(q){const r=h.parentThatIsA(StageMorph),t=q.name.trim();q=q.fields.map(u=>u.trim()).filter(u=>!!u);r.messageTypes.getMsgType(t)?h.inform("that name is already in use"):SnapActions.addMessageType(t,q)}var l=[],h=this;a=a||"motion";var n=this.inheritedVariableNames();if("motion"===a)l.push(b("forward")),l.push(b("turn")),l.push(b("turnLeft")),l.push("-"),l.push(b("setHeading")),l.push(b("doFaceTowards")),l.push("-"),l.push(b("gotoXY")),l.push(b("doGotoObject")),l.push(b("doGlide")),l.push("-"), l.push(b("changeXPosition")),l.push(b("setXPosition")),l.push(b("changeYPosition")),l.push(b("setYPosition")),l.push("-"),l.push(b("bounceOffEdge")),l.push("-"),l.push(d("xPosition")),l.push(b("xPosition",this.inheritsAttribute("x position"))),l.push(d("yPosition")),l.push(b("yPosition",this.inheritsAttribute("y position"))),l.push(d("direction")),l.push(b("direction",this.inheritsAttribute("direction")));else if("looks"===a){if(l.push(b("doSwitchToCostume")),l.push(b("doWearNextCostume")),l.push(d("getCostumeIdx")), l.push(b("getCostumeIdx",this.inheritsAttribute("costume #"))),l.push("-"),l.push(b("doSayFor")),l.push(b("bubble")),l.push(b("doThinkFor")),l.push(b("doThink")),l.push("-"),l.push(b("reportGetImageAttribute")),l.push(b("reportNewCostumeStretched")),l.push(b("reportNewCostume")),l.push("-"),l.push(b("changeEffect")),l.push(b("setEffect")),l.push(b("clearEffects")),l.push(b("getEffect")),l.push("-"),l.push(b("changeScale")),l.push(b("setScale")),l.push(d("getScale")),l.push(b("getScale",this.inheritsAttribute("size"))), l.push("-"),l.push(b("show")),l.push(b("hide")),l.push(d("reportShown")),l.push(b("reportShown",this.inheritsAttribute("shown?"))),l.push("-"),l.push(b("goToLayer")),l.push(b("goBack")),this.world().isDevMode){l.push("-");var p=new TextMorph(localize("development mode \ndebugging primitives:"));p.fontSize=9;p.setColor(this.paletteTextColor);l.push(p);l.push("-");l.push(b("log"));l.push(b("alert"))}}else"sound"===a?(l.push(b("playSound")),l.push(b("doPlaySoundUntilDone")),l.push(b("doStopAllSounds")), l.push("-"),l.push(b("doPlaySoundAtRate")),l.push(b("reportGetSoundAttribute")),l.push(b("reportNewSoundFromSamples")),l.push("-"),l.push(b("doRest")),l.push(b("doPlayNote")),l.push(b("doSetInstrument")),l.push("-"),l.push(b("doChangeTempo")),l.push(b("doSetTempo")),l.push(d("getTempo")),l.push(b("getTempo")),l.push("-"),l.push(b("changeVolume")),l.push(b("setVolume")),l.push(d("getVolume")),l.push(b("getVolume",this.inheritsAttribute("volume"))),l.push("-"),l.push(b("changePan")),l.push(b("setPan")), l.push(d("getPan")),l.push(b("getPan",this.inheritsAttribute("balance"))),l.push("-"),l.push(b("playFreq")),l.push(b("stopFreq")),this.world().isDevMode&&(l.push("-"),p=new TextMorph(localize("development mode \ndebugging primitives:")),p.fontSize=9,p.setColor(this.paletteTextColor),l.push(p),l.push("-"),l.push(b("doPlayFrequency")))):"pen"===a?(l.push(b("clear")),l.push("-"),l.push(b("down")),l.push(b("up")),l.push(d("getPenDown")),l.push(b("getPenDown",this.inheritsAttribute("pen down?"))),l.push("-"), l.push(b("setColor")),l.push(b("changePenColorDimension")),l.push(b("setPenColorDimension")),l.push(b("getPenAttribute")),l.push("-"),l.push(b("changeSize")),l.push(b("setSize")),l.push("-"),l.push(b("doStamp")),l.push(b("floodFill")),l.push(b("write")),l.push("-"),l.push(b("reportPenTrailsAsCostume")),l.push("-"),l.push(b("doPasteOn"))):"network"===a?(l.push(b("receiveSocketMessage")),l.push(b("doSocketMessage")),l.push("-"),l.push(b("doSocketRequest")),l.push(b("doSocketResponse")),l.push("-"), -l.push(b("getJSFromRPCStruct")),l.push(b("doRunRPC")),l.push(d("reportRPCError")),l.push(b("reportRPCError")),l.push("-"),l.push(b("getProjectIds")),l.push(b("getProjectId")),p=new PushButtonMorph(null,function(){(new MessageCreatorMorph(k,m)).popUp()},"Make a message type"),l.push(p),0 -q.addItem(r,r,null,null,null,null,null,null,!0));q.popUpAtHand(k.world())},"Delete a variable"),p.userMenu=f,p.selector="deleteVariable",p.showHelp=BlockMorph.prototype.showHelp,l.push(p)),l.push("-"),p=this.reachableGlobalVariableNames(!0),0{l.push(e(q));l.push(c(q))}),l.push("-")),p=this.allLocalVariableNames(!0),0{l.push(e(q));l.push(c(q,!0))}),l.push("-")),l.push(b("doSetVar")),l.push(b("doChangeVar")),l.push(b("doShowVar")),l.push(b("doHideVar")), +p.fontSize=9,p.setColor(this.paletteTextColor),l.push(p),l.push("-"),l.push(b("reportTypeOf")),l.push(b("reportTextFunction")))):"variables"===a&&(p=new PushButtonMorph(null,function(){(new VariableDialogMorph(null,g,h)).prompt("Variable name",null,h.world())},"Make a variable"),p.userMenu=f,p.selector="addVariable",p.showHelp=BlockMorph.prototype.showHelp,l.push(p),0 +q.addItem(r,r,null,null,null,null,null,null,!0));q.popUpAtHand(h.world())},"Delete a variable"),p.userMenu=f,p.selector="deleteVariable",p.showHelp=BlockMorph.prototype.showHelp,l.push(p)),l.push("-"),p=this.reachableGlobalVariableNames(!0),0{l.push(e(q));l.push(c(q))}),l.push("-")),p=this.allLocalVariableNames(!0),0{l.push(e(q));l.push(c(q,!0))}),l.push("-")),l.push(b("doSetVar")),l.push(b("doChangeVar")),l.push(b("doShowVar")),l.push(b("doHideVar")), l.push(b("doDeclareVariables")),StageMorph.prototype.enableInheritance&&(l.push("-"),l.push(b("doDeleteAttr"))),l.push("="),l.push(b("reportNewList")),l.push(b("reportNumbers")),l.push("-"),l.push(b("reportCONS")),l.push(b("reportListItem")),l.push(b("reportCDR")),l.push("-"),l.push(b("reportListAttribute")),l.push(b("reportListIndex")),l.push(b("reportListContainsItem")),l.push(b("reportListIsEmpty")),l.push("-"),l.push(b("reportMap")),l.push(b("reportKeep")),l.push(b("reportFindFirst")),l.push(b("reportCombine")), l.push("-"),l.push(b("doForEach")),l.push("-"),l.push(b("doAddToList")),l.push(b("doDeleteFromList")),l.push(b("doInsertInList")),l.push(b("doReplaceInList")),l.push("-"),l.push(b("reportConcatenatedLists")),l.push(b("reportReshape")),l.push(b("reportCrossproduct")),this.world().isDevMode&&(l.push("-"),p=new TextMorph(localize("development mode \ndebugging primitives:")),p.fontSize=9,p.setColor(this.paletteTextColor),l.push(p),l.push("-"),l.push(b("doShowTable"))),StageMorph.prototype.enableCodeMapping&& (l.push("="),l.push(b("doMapCodeOrHeader")),l.push(b("doMapValueCode")),l.push(b("doMapListCode")),l.push("-"),l.push(b("reportMappedCode"))));if(p=this.parentThatIsA(IDE_Morph))p=p.extensions.getPaletteContents(this,a).flatMap(q=>{switch(q.type){case "block":return b(q.name);case "watcher":return[d(q.name),b(q.name)];case "space":return q.name}return q}),l.push(...p);l.push("=");l.push(this.makeBlockButton(a));return l}; SpriteMorph.prototype.makeBlockButton=function(a){a=new PushButtonMorph(this,"makeBlock","Make a block");a.userMenu=function(){var b=new MenuMorph(this);b.addItem("help...","showHelp");return b};a.selector="addCustomBlock";a.showHelp=BlockMorph.prototype.showHelp;return a}; SpriteMorph.prototype.makeBlock=function(){var a=this.parentThatIsA(IDE_Morph).currentCategory,b=SpriteMorph.prototype.blockColor[a];var c=new BlockDialogMorph(null,d=>{""!==d.spec&&SnapActions.addCustomBlock(d,this).then(e=>{(new BlockEditorMorph(e,this)).popUp()})},this);"variables"!==a&&(c.category=a,c.categories.children.forEach(d=>d.refresh()),c.types.children.forEach(d=>{d.setColor(b);d.refresh()}));c.prompt("Make a block",null,this.world())}; SpriteMorph.prototype.palette=function(a){this.paletteCache[a]||(this.paletteCache[a]=this.freshPalette(a));return this.paletteCache[a]}; -SpriteMorph.prototype.freshPalette=function(a){var b=new ScrollFrameMorph(null,null,this.sliderColor),c=SyntaxElementMorph.prototype.fontSize,d=0,e=5,f=0,g=!1,h=this.parentThatIsA(StageMorph);var m=new Color(140,140,140);b.owner=this;b.padding=c/2;b.color=this.paletteColor;b.growth=new Point(0,MorphicPreferences.scrollBarSize);b.toolBar=new AlignmentMorph("column");var l=new PushButtonMorph(this,"searchBlocks",new SymbolMorph("magnifierOutline",16));l.alpha=.2;l.padding=1;l.hint=localize("find blocks")+ -"...";l.labelShadowColor=m;l.edge=0;l.padding=3;l.fixLayout();b.toolBar.add(l);l=new PushButtonMorph(this,"makeBlock",new SymbolMorph("cross",16));l.alpha=.2;l.padding=1;l.hint=localize("Make a block")+"...";l.labelShadowColor=m;l.edge=0;l.padding=3;l.fixLayout();b.toolBar.add(l);b.toolBar.fixLayout();b.add(b.toolBar);b.userMenu=function(){var k=new MenuMorph,n=this.parentThatIsA(IDE_Morph),p={operators:["reifyScript","reifyReporter","reifyPredicate"],control:["doWarp"],variables:"doDeclareVariables reportNewList reportNumbers reportCONS reportListItem reportCDR reportListLength reportListIndex reportConcatenatedLists reportListContainsItem reportListIsEmpty doForEach reportMap reportKeep reportFindFirst reportCombine doAddToList doDeleteFromList doInsertInList doReplaceInList".split(" ")}; -k.addPair([new SymbolMorph("magnifyingGlass",MorphicPreferences.menuFontSize),localize("find blocks")+"..."],()=>this.searchBlocks(),"^F");(function(){return b.contents.children.some(r=>contains(Object.keys(SpriteMorph.prototype.blocks),r.selector))})()&&k.addItem("hide primitives",function(){var r=SpriteMorph.prototype.blocks;Object.keys(r).forEach(t=>{r[t].category===a&&(StageMorph.prototype.hiddenPrimitives[t]=!0)});(p[a]||[]).forEach(t=>StageMorph.prototype.hiddenPrimitives[t]=!0);n.flushBlocksCache(a); -n.refreshPalette()});(function(){var r=SpriteMorph.prototype.blocks;return Object.keys(StageMorph.prototype.hiddenPrimitives).some(t=>!isNil(r[t])&&(r[t].category===a||contains(p[a]||[],t)))})()&&k.addItem("show primitives",function(){var r=SpriteMorph.prototype.blocks;Object.keys(StageMorph.prototype.hiddenPrimitives).forEach(t=>{r[t]&&r[t].category===a&&delete StageMorph.prototype.hiddenPrimitives[t]});(p[a]||[]).forEach(t=>delete StageMorph.prototype.hiddenPrimitives[t]);n.flushBlocksCache(a); -n.refreshPalette()});if(SnapUndo.canUndo("palette")){var q=n.serializer.parse(SnapUndo.eventHistory.palette[SnapUndo.eventHistory.palette.length-1].args[2]);k.addItem('restore "'+q.attributes.s+'"',function(){SnapUndo.undo("palette")})}NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,k);return k};m=this.blocksCache[a];m||(m=this.blockTemplates(a),this.isCachingPrimitives&&(this.blocksCache[a]=m));m.forEach(k=>{null!==k&&("-"===k?g||(e+=.8*c,g=!0):"="===k?g||(e+=1.6*c,g=!0):"#"===k?(d=0,e=f): -(g=!1,0===d&&(e+=.3*c),k.setPosition(new Point(d,e)),b.addContents(k),k instanceof ToggleMorph||k instanceof RingMorph?(d=k.right()+c/2,f=k.bottom()):(d=0,e+=k.height())))});h&&(e+=1.6*c,h.globalBlocks.forEach(function(k){if("custom"===a||k.category===a)k=k.templateInstance(),e+=.3*c,k.setPosition(new Point(d,e)),b.addContents(k),d=0,e+=k.height()}));e+=1.6*c;this.customBlocks.forEach(function(k){if("custom"===a||k.category===a)k=k.templateInstance(),e+=.3*c,k.setPosition(new Point(d,e)),b.addContents(k), -d=0,e+=k.height()});this.exemplar&&this.inheritedBlocks(!0).forEach(k=>{if(k.category===a||"variables"===a&&contains(["lists","other"],k.category))k=k.templateInstance(),e+=.3*c,k.setPosition(new Point(d,e)),b.addContents(k),k.ghost(),d=0,e+=k.height()});b.scrollX(b.padding);b.scrollY(b.padding);return b}; -SpriteMorph.prototype.blocksMatching=function(a,b,c,d){function e(k){return BlockMorph.prototype.parseSpec(k).filter(n=>0!==n.indexOf("%")).join(" ")}function f(k,n){k=" "+k;n=k.indexOf(n);if(-1===n)return-1;k=" "===k.charAt(n-1);if(b&&!k)return-1;for(n=String(n);4>n.length;)n="0"+n;return(k?"1":"2")+n}var g=[],h=a.toLowerCase(),m=this.parentThatIsA(StageMorph);c&&c.length||(c=["hat","command","reporter","predicate","ring"]);d||=[];d.forEach(k=>{var n=f(e(k.toLowerCase()),h);-1!==n&&g.push([this.variableBlock(k), -n+"1"])});[this.customBlocks,m.globalBlocks].forEach(k=>k.forEach(n=>{if(contains(c,n.type)){var p=n.localizedSpec().toLowerCase();p=f(e(p),h);-1!==p&&g.push([n.templateInstance(),p+"2"])}}));var l=SpriteMorph.prototype.blocks;Object.keys(l).forEach(k=>{if(!StageMorph.prototype.hiddenPrimitives[k]&&contains(c,l[k].type)&&!l[k].deprecated){var n=l[k],p=localize(n.alias||n.spec).toLowerCase();p=f(e(p),h);-1===p||n.dev||n.only&&n.only!==this.constructor||(n=g.push,k=SpriteMorph.prototype.blockForSelector(k, -!0),k.isTemplate=!0,n.call(g,[k,p+"3"]))}});contains(c,"reporter")&&(a=this.reporterize(a))&&g.push([a,""]);g.sort((k,n)=>k[1]k[0])}; -SpriteMorph.prototype.searchBlocks=function(a,b,c,d){function e(){r&&r.destroy();q&&d&&(r=q.outline(MorphicPreferences.isFlat?new Color(150,200,255):WHITE,2),n.contents.add(r),r.scrollIntoView())}function f(t){var u=n.contents.left()+5,v=k.bottom()+h;p=t;q=null;t.length&&d&&(q=t[0]);n.contents.children=[n.contents.children[0]];t.forEach(w=>{w.setPosition(new Point(u,v));n.addContents(w);v+=w.height();v+=.3*h});e();n.changed()}var g=this,h=SyntaxElementMorph.prototype.fontSize,m=this.parentThatIsA(IDE_Morph), -l="",k=new InputFieldMorph(a||""),n=m.createPalette("forSearch"),p=[],q,r;n.mouseClickLeft=function(){16===world.currentKey&&m.prompt("Search for used blocks",function(t){if(t&&!(3>t.length)){t=t.toLowerCase();console.log("searching with query:",t);t=m.findBlocks({specs:[t]});console.log("found",t.length,"blocks");if(t.length){var u={};t.map(function(w){return m.blockAddress(w).join(" => ")}).forEach(function(w){u[w]=void 0===u[w]?1:u[w]+1});t="";for(var v in u)1t&&(t=p.length- -1);q=p[t];e();break;case 40:if(!d||!q)break;t=p.indexOf(q)+1;t>=p.length&&(t=0);q=p[t];e();break;default:nop()}};n.reactToInput=function(t){t=k.getValue();t!==l&&(l=t,f(g.blocksMatching(t,2>t.length,b,c)))};k.cancel=function(){m.refreshPalette();m.palette.adjustScrollBars()};m.fixLayout("refreshPalette");k.edit();a&&n.reactToKeystroke()}; -SpriteMorph.prototype.reporterize=function(a){function b(e,f,g){function h(p){return p instanceof Array||isNaN(+p)?p:+p}function m(){for(var p=1,q="";k":case "&":case "|":if(f||l[0].length)if(f){if(l[1].length)return b(e.slice(k), -n,[f,g,h(l[1])]);l[1]=n}else f=n,g=h(l[0]);else l[0]=n;break;default:l[f?1:0]+=n}return f?[f,g,h(l[1])]:h(l[0])}function c(e){var f=1,g={};var h={"+":"reportVariadicSum","-":"reportDifference","*":"reportVariadicProduct","/":"reportQuotient","%":"reportModulus","^":"reportPower","=":"reportEquals","<":"reportLessThan",">":"reportGreaterThan","&":"reportAnd","|":"reportOr",round:"reportRound",not:"reportNot"};var m="abs neg ceiling floor sqrt sin cos tan asin acos atan ln log lg id round not".split(" "); -m.concat(["true","false"]).forEach(k=>g[localize(k).toLowerCase()]=k);var l={ceil:"ceiling","!":"not"}[e[0]]||g[e[0].toLowerCase()]||e[0];contains(m,l)?(h=h[l])?(h=SpriteMorph.prototype.blockForSelector(h),m=h.inputs()):(h=SpriteMorph.prototype.blockForSelector("reportMonadic"),m=h.inputs(),m[0].setContents([l]),f=0):(h=SpriteMorph.prototype.blockForSelector(h[l]),m=h.inputs());for(l=1;lthis.searchBlocks(),"^F");(function(){return b.contents.children.some(r=>contains(Object.keys(SpriteMorph.prototype.blocks),r.selector))})()&&h.addItem("hide primitives",function(){var r=SpriteMorph.prototype.blocks;Object.keys(r).forEach(t=>{r[t].category===a&&(StageMorph.prototype.hiddenPrimitives[t]=!0)});(p[a]||[]).forEach(t=>StageMorph.prototype.hiddenPrimitives[t]=!0);n.flushBlocksCache(a); +n.refreshPalette()});(function(){var r=SpriteMorph.prototype.blocks;return Object.keys(StageMorph.prototype.hiddenPrimitives).some(t=>!isNil(r[t])&&(r[t].category===a||contains(p[a]||[],t)))})()&&h.addItem("show primitives",function(){var r=SpriteMorph.prototype.blocks;Object.keys(StageMorph.prototype.hiddenPrimitives).forEach(t=>{r[t]&&r[t].category===a&&delete StageMorph.prototype.hiddenPrimitives[t]});(p[a]||[]).forEach(t=>delete StageMorph.prototype.hiddenPrimitives[t]);n.flushBlocksCache(a); +n.refreshPalette()});if(SnapUndo.canUndo("palette")){var q=n.serializer.parse(SnapUndo.eventHistory.palette[SnapUndo.eventHistory.palette.length-1].args[2]);h.addItem('restore "'+q.attributes.s+'"',function(){SnapUndo.undo("palette")})}NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,h);return h};m=this.blocksCache[a];m||(m=this.blockTemplates(a),this.isCachingPrimitives&&(this.blocksCache[a]=m));m.forEach(h=>{null!==h&&("-"===h?g||(e+=.8*c,g=!0):"="===h?g||(e+=1.6*c,g=!0):"#"===h?(d=0,e=f): +(g=!1,0===d&&(e+=.3*c),h.setPosition(new Point(d,e)),b.addContents(h),h instanceof ToggleMorph||h instanceof RingMorph?(d=h.right()+c/2,f=h.bottom()):(d=0,e+=h.height())))});k&&(e+=1.6*c,k.globalBlocks.forEach(function(h){if("custom"===a||h.category===a)h=h.templateInstance(),e+=.3*c,h.setPosition(new Point(d,e)),b.addContents(h),d=0,e+=h.height()}));e+=1.6*c;this.customBlocks.forEach(function(h){if("custom"===a||h.category===a)h=h.templateInstance(),e+=.3*c,h.setPosition(new Point(d,e)),b.addContents(h), +d=0,e+=h.height()});this.exemplar&&this.inheritedBlocks(!0).forEach(h=>{if(h.category===a||"variables"===a&&contains(["lists","other"],h.category))h=h.templateInstance(),e+=.3*c,h.setPosition(new Point(d,e)),b.addContents(h),h.ghost(),d=0,e+=h.height()});b.scrollX(b.padding);b.scrollY(b.padding);return b}; +SpriteMorph.prototype.blocksMatching=function(a,b,c,d){function e(h){return BlockMorph.prototype.parseSpec(h).filter(n=>0!==n.indexOf("%")).join(" ")}function f(h,n){h=" "+h;n=h.indexOf(n);if(-1===n)return-1;h=" "===h.charAt(n-1);if(b&&!h)return-1;for(n=String(n);4>n.length;)n="0"+n;return(h?"1":"2")+n}var g=[],k=a.toLowerCase(),m=this.parentThatIsA(StageMorph);c&&c.length||(c=["hat","command","reporter","predicate","ring"]);d||=[];d.forEach(h=>{var n=f(e(h.toLowerCase()),k);-1!==n&&g.push([this.variableBlock(h), +n+"1"])});[this.customBlocks,m.globalBlocks].forEach(h=>h.forEach(n=>{if(contains(c,n.type)){var p=n.localizedSpec().toLowerCase();p=f(e(p),k);-1!==p&&g.push([n.templateInstance(),p+"2"])}}));var l=SpriteMorph.prototype.blocks;Object.keys(l).forEach(h=>{if(!StageMorph.prototype.hiddenPrimitives[h]&&contains(c,l[h].type)&&!l[h].deprecated){var n=l[h],p=localize(n.alias||n.spec).toLowerCase();p=f(e(p),k);-1===p||n.dev||n.only&&n.only!==this.constructor||(n=g.push,h=SpriteMorph.prototype.blockForSelector(h, +!0),h.isTemplate=!0,n.call(g,[h,p+"3"]))}});contains(c,"reporter")&&(a=this.reporterize(a))&&g.push([a,""]);g.sort((h,n)=>h[1]h[0])}; +SpriteMorph.prototype.searchBlocks=function(a,b,c,d){function e(){r&&r.destroy();q&&d&&(r=q.outline(MorphicPreferences.isFlat?new Color(150,200,255):WHITE,2),n.contents.add(r),r.scrollIntoView())}function f(t){var u=n.contents.left()+5,v=h.bottom()+k;p=t;q=null;t.length&&d&&(q=t[0]);n.contents.children=[n.contents.children[0]];t.forEach(w=>{w.setPosition(new Point(u,v));n.addContents(w);v+=w.height();v+=.3*k});e();n.changed()}var g=this,k=SyntaxElementMorph.prototype.fontSize,m=this.parentThatIsA(IDE_Morph), +l="",h=new InputFieldMorph(a||""),n=m.createPalette("forSearch"),p=[],q,r;n.mouseClickLeft=function(){16===world.currentKey&&m.prompt("Search for used blocks",function(t){if(t&&!(3>t.length)){t=t.toLowerCase();console.log("searching with query:",t);t=m.findBlocks({specs:[t]});console.log("found",t.length,"blocks");if(t.length){var u={};t.map(function(w){return m.blockAddress(w).join(" => ")}).forEach(function(w){u[w]=void 0===u[w]?1:u[w]+1});t="";for(var v in u)1t&&(t=p.length- +1);q=p[t];e();break;case 40:if(!d||!q)break;t=p.indexOf(q)+1;t>=p.length&&(t=0);q=p[t];e();break;default:nop()}};n.reactToInput=function(t){t=h.getValue();t!==l&&(l=t,f(g.blocksMatching(t,2>t.length,b,c)))};h.cancel=function(){m.refreshPalette();m.palette.adjustScrollBars()};m.fixLayout("refreshPalette");h.edit();a&&n.reactToKeystroke()}; +SpriteMorph.prototype.reporterize=function(a){function b(e,f,g){function k(p){return p instanceof Array||isNaN(+p)?p:+p}function m(){for(var p=1,q="";h":case "&":case "|":if(f||l[0].length)if(f){if(l[1].length)return b(e.slice(h), +n,[f,g,k(l[1])]);l[1]=n}else f=n,g=k(l[0]);else l[0]=n;break;default:l[f?1:0]+=n}return f?[f,g,k(l[1])]:k(l[0])}function c(e){var f=1,g={};var k={"+":"reportVariadicSum","-":"reportDifference","*":"reportVariadicProduct","/":"reportQuotient","%":"reportModulus","^":"reportPower","=":"reportEquals","<":"reportLessThan",">":"reportGreaterThan","&":"reportAnd","|":"reportOr",round:"reportRound",not:"reportNot"};var m="abs neg ceiling floor sqrt sin cos tan asin acos atan ln log lg id round not".split(" "); +m.concat(["true","false"]).forEach(h=>g[localize(h).toLowerCase()]=h);var l={ceil:"ceiling","!":"not"}[e[0]]||g[e[0].toLowerCase()]||e[0];contains(m,l)?(k=k[l])?(k=SpriteMorph.prototype.blockForSelector(k),m=k.inputs()):(k=SpriteMorph.prototype.blockForSelector("reportMonadic"),m=k.inputs(),m[0].setContents([l]),f=0):(k=SpriteMorph.prototype.blockForSelector(k[l]),m=k.inputs());for(l=1;l{f.cachedPropagation&&f.inheritsAttribute("costume #")&&(null===e?f.wearCostume(null, @@ -1523,8 +1523,8 @@ SpriteMorph.prototype.wearCostume=function(a,b){var c=this.xPosition?this.xPosit SpriteMorph.prototype.doWearPreviousCostume=function(){var a=this.costumes.asArray();if(1b&&(b=a.length-1),this.wearCostume(a[b]))}}; SpriteMorph.prototype.doSwitchToCostume=function(a,b){if(a instanceof List){if(this.costume){var c=this.costume.width();var d=this.costume.height()}else c=StageMorph.prototype.dimensions.x,d=StageMorph.prototype.dimensions.y;a=Process.prototype.reportNewCostume(a,c,d,this.newCostumeName(localize("snap")))}if(a instanceof Costume)this.wearCostume(a,b);else if(!(a instanceof Array&&"current"===a[0])){c=this.costumes.asArray();if(contains([localize("Turtle"),localize("Empty")],a instanceof Array?a[0]: null))d=null;else{if(-1===a){this.doWearPreviousCostume();return}d=detect(c,e=>e.name===a);null===d&&(d=parseFloat(a),d=0===d?null:c[d-1]||null)}this.wearCostume(d,b)}};SpriteMorph.prototype.reportCostumes=function(){return this.costumes};SpriteMorph.prototype.addSound=function(a){this.shadowAttribute("sounds");this.sounds.add(a);return a}; -SpriteMorph.prototype.doPlaySound=function(a){var b=this.parentThatIsA(StageMorph),c=a instanceof Sound?a:"number"===typeof a?this.sounds.at(a):detect(this.sounds.asArray(),h=>h.name===a.toString()),d=this.audioContext(),e=this.getGainNode(),f=this.getPannerNode();if(c){var g=document.createElement("audio");g.src=c.audio.src;d.resume();c=d.createMediaElementSource(g);c.connect(e);f?(e.connect(f),f.connect(d.destination),this.setPan(this.getPan())):e.connect(d.destination);this.setVolume(this.getVolume()); -g.play();b&&(b.activeSounds.push(g),b.activeSounds=b.activeSounds.filter(h=>!h.ended&&!h.terminated));return g}};SpriteMorph.prototype.reportSounds=function(){return this.sounds}; +SpriteMorph.prototype.doPlaySound=function(a){var b=this.parentThatIsA(StageMorph),c=a instanceof Sound?a:"number"===typeof a?this.sounds.at(a):detect(this.sounds.asArray(),k=>k.name===a.toString()),d=this.audioContext(),e=this.getGainNode(),f=this.getPannerNode();if(c){var g=document.createElement("audio");g.src=c.audio.src;d.resume();c=d.createMediaElementSource(g);c.connect(e);f?(e.connect(f),f.connect(d.destination),this.setPan(this.getPan())):e.connect(d.destination);this.setVolume(this.getVolume()); +g.play();b&&(b.activeSounds.push(g),b.activeSounds=b.activeSounds.filter(k=>!k.ended&&!k.terminated));return g}};SpriteMorph.prototype.reportSounds=function(){return this.sounds}; SpriteMorph.prototype.setVolume=function(a,b){this.volume=Math.max(Math.min(+a||0,100),0);this.getGainNode().gain.setValueAtTime(1/Math.pow(10,Math.log2(100/this.volume)),this.audioContext().currentTime);this instanceof StageMorph||(b||this.shadowAttribute("volume"),this.instances.forEach(c=>{c.cachedPropagation&&c.inheritsAttribute("volume")&&c.setVolume(a,!0)}))};SpriteMorph.prototype.changeVolume=function(a){this.setVolume(this.getVolume()+(+a||0))}; SpriteMorph.prototype.getVolume=function(){return this.inheritsAttribute("volume")?this.exemplar.getVolume():this.volume};SpriteMorph.prototype.getGainNode=function(){this.gainNode||(this.gainNode=this.audioContext().createGain());return this.gainNode};SpriteMorph.prototype.audioContext=function(){return Note.prototype.getAudioContext()}; SpriteMorph.prototype.setPan=function(a,b){var c=this.getPannerNode();c&&(this.pan=Math.max(Math.min(+a||0,100),-100),c.pan.setValueAtTime(this.pan/100,this.audioContext().currentTime),this instanceof StageMorph||(b||this.shadowAttribute("balance"),this.instances.forEach(d=>{d.cachedPropagation&&d.inheritsAttribute("balance")&&d.setPan(a,!0)})))};SpriteMorph.prototype.changePan=function(a){this.setPan(this.getPan()+(+a||0))}; @@ -1556,21 +1556,21 @@ SpriteMorph.prototype.overlappingPixels=function(a){var b=this.bounds.intersect( a.left(),b.top()-a.top(),b.width(),b.height()).data]};SpriteMorph.prototype.doStamp=function(){var a=this.parent,b=a.penTrails().getContext("2d"),c=this.getImage();1>c.width||1>c.height||(b.save(),b.scale(1/a.scale,1/a.scale),b.globalAlpha=this.alpha,b.drawImage(c,this.left()-a.left(),this.top()-a.top()),b.restore(),this.changed(),a.cachedPenTrailsMorph=null)};SpriteMorph.prototype.clear=function(){this.parent.clearPenTrails()}; SpriteMorph.prototype.write=function(a,b){if("string"!==typeof a&&"number"!==typeof a)throw Error("LABEL can only draw text or numbers, not a "+typeof a);var c=this.parentThatIsA(StageMorph),d=c.penTrails().getContext("2d"),e=radians(this.direction()-90),f=new Point(this.rotationCenter().x-c.left(),this.rotationCenter().y-c.top());d.save();d.font=b+"px monospace";d.textAlign="left";d.textBaseline="alphabetic";d.fillStyle=this.color.toString();b=d.measureText(a).width;f=f.multiplyBy(1/c.scale);d.translate(f.x, f.y);d.rotate(e);d.fillText(a,0,0);d.translate(-f.x,-f.y);d.restore();a=new Point(b*Math.sin(radians(this.direction())),b*Math.cos(radians(this.direction())));a=a.add(new Point(this.xPosition(),this.yPosition()));this.gotoXY(a.x,a.y,!1);this.changed();c.changed()};SpriteMorph.prototype.setSize=function(a){isNaN(a)||(this.size=Math.min(Math.max(+a,1E-4),1E3))};SpriteMorph.prototype.changeSize=function(a){this.setSize(this.size+(+a||0))}; -SpriteMorph.prototype.pasteOn=function(a){var b=1===this.rotationStyle?this.heading:90,c=1===a.rotationStyle?a.heading:90;if(this!==a&&this.costume&&a.costume){var d=this.costume;d instanceof SVG_Costume&&(d=d.rasterized());var e=a.costume instanceof SVG_Costume?a.costume.rasterized():a.costume.copy();if(a instanceof SpriteMorph)if(this instanceof SpriteMorph){var f=b-c;var g=this.scale/a.scale;c=this.parentThatIsA(StageMorph).scale;var h=a.center().distanceTo(this.center());var m=this.center().subtract(a.center()); -m=Math.atan2(m.y,m.x);var l=(new Point(d.width(),d.height())).multiplyBy(.5*this.scale*c);var k=l.distanceTo(ZERO);l=Math.atan2(l.y,l.x);var n=(new Point(a.costume.width(),a.costume.height())).multiplyBy(.5*a.scale*c).rotateBy(radians(f));b=n.distanceAngle(h,degrees(m)-b+180);b=b.distanceAngle(k,degrees(l)-90);b=b.divideBy(c).divideBy(g).divideBy(a.scale)}else f=90-c,g=1/a.scale,h=a.center().distanceTo(this.position()),m=this.position().subtract(a.center()),m=Math.atan2(m.y,m.x),l=(new Point(a.costume.width(), -a.costume.height())).multiplyBy(.5*a.scale).rotateBy(radians(90-c)),b=l.distanceAngle(h/this.scale,degrees(m)+90);else f=b-90,g=this.scale,l=this.center().subtract(a.position()).divideBy(this.scale*a.scale).rotateBy(radians(b-90)),b=l.subtract((new Point(d.width(),d.height())).multiplyBy(.5));c=e.contents.getContext("2d");c.rotate(radians(f));c.scale(g,g);c.globalCompositeOperation="source-atop";c.drawImage(d.contents,b.x,b.y);a.doSwitchToCostume(e)}};SpriteMorph.prototype.down=function(){this.setPenDown(!0)}; +SpriteMorph.prototype.pasteOn=function(a){var b=1===this.rotationStyle?this.heading:90,c=1===a.rotationStyle?a.heading:90;if(this!==a&&this.costume&&a.costume){var d=this.costume;d instanceof SVG_Costume&&(d=d.rasterized());var e=a.costume instanceof SVG_Costume?a.costume.rasterized():a.costume.copy();if(a instanceof SpriteMorph)if(this instanceof SpriteMorph){var f=b-c;var g=this.scale/a.scale;c=this.parentThatIsA(StageMorph).scale;var k=a.center().distanceTo(this.center());var m=this.center().subtract(a.center()); +m=Math.atan2(m.y,m.x);var l=(new Point(d.width(),d.height())).multiplyBy(.5*this.scale*c);var h=l.distanceTo(ZERO);l=Math.atan2(l.y,l.x);var n=(new Point(a.costume.width(),a.costume.height())).multiplyBy(.5*a.scale*c).rotateBy(radians(f));b=n.distanceAngle(k,degrees(m)-b+180);b=b.distanceAngle(h,degrees(l)-90);b=b.divideBy(c).divideBy(g).divideBy(a.scale)}else f=90-c,g=1/a.scale,k=a.center().distanceTo(this.position()),m=this.position().subtract(a.center()),m=Math.atan2(m.y,m.x),l=(new Point(a.costume.width(), +a.costume.height())).multiplyBy(.5*a.scale).rotateBy(radians(90-c)),b=l.distanceAngle(k/this.scale,degrees(m)+90);else f=b-90,g=this.scale,l=this.center().subtract(a.position()).divideBy(this.scale*a.scale).rotateBy(radians(b-90)),b=l.subtract((new Point(d.width(),d.height())).multiplyBy(.5));c=e.contents.getContext("2d");c.rotate(radians(f));c.scale(g,g);c.globalCompositeOperation="source-atop";c.drawImage(d.contents,b.x,b.y);a.doSwitchToCostume(e)}};SpriteMorph.prototype.down=function(){this.setPenDown(!0)}; SpriteMorph.prototype.up=function(){this.setPenDown(!1)};SpriteMorph.prototype.setPenDown=function(a,b){a?SpriteMorph.uber.down.call(this):SpriteMorph.uber.up.call(this);b||this.shadowAttribute("pen down?");this.instances.forEach(c=>{c.cachedPropagation&&c.inheritsAttribute("pen down?")&&c.setPenDown(a,!0)})};SpriteMorph.prototype.getPenDown=function(){return this.inheritsAttribute("pen down?")?this.exemplar.getPenDown():this.isDown}; SpriteMorph.prototype.getScale=function(){return this.inheritsAttribute("size")?this.exemplar.getScale():100*this.scale}; -SpriteMorph.prototype.setScale=function(a,b){var c=this.xPosition(),d=this.yPosition();var e=(+a||0)/100;var f=e/this.nestingScale;this.nestingScale=e;this.scale=Math.max(e,.01);this.changed();this.fixLayout();this.rerender();this.silentGotoXY(c,d,!0);this.positionTalkBubble();this.parts.forEach(g=>{var h=g.xPosition()-c,m=g.yPosition()-d;g.setScale(100*g.scale*f);g.silentGotoXY(c+h*f,d+m*f)});b||this.shadowAttribute("size");this.instances.forEach(g=>{g.cachedPropagation&&g.inheritsAttribute("size")&& +SpriteMorph.prototype.setScale=function(a,b){var c=this.xPosition(),d=this.yPosition();var e=(+a||0)/100;var f=e/this.nestingScale;this.nestingScale=e;this.scale=Math.max(e,.01);this.changed();this.fixLayout();this.rerender();this.silentGotoXY(c,d,!0);this.positionTalkBubble();this.parts.forEach(g=>{var k=g.xPosition()-c,m=g.yPosition()-d;g.setScale(100*g.scale*f);g.silentGotoXY(c+k*f,d+m*f)});b||this.shadowAttribute("size");this.instances.forEach(g=>{g.cachedPropagation&&g.inheritsAttribute("size")&& g.setScale(a,!0)})};SpriteMorph.prototype.changeScale=function(a){this.setScale(this.getScale()+(+a||0))};SpriteMorph.prototype.graphicsChanged=function(){return Object.keys(this.graphicsValues).some(a=>0>this.graphicsValues[a]||0=F?(C=Math.atan2(C,B),B=Math.floor(z+F*Math.cos(C)*z),C=Math.floor(A+F*Math.sin(C)*A)):(B=t,C=u);F=4*(u*v+t);B=4*(C*v+B);x[F]=q[B];x[F+1]=q[B+1];x[F+2]=q[B+2];x[F+3]=q[B+3]}return y}function c(q,r){var t; var u=q.width;var v=q.height;q=q.data;var w=p.createImageData(u,v);var y=w.data;var x=u/2;var z=v/2;var A=Math.min(x,z);if(uK&&(K+=360);B/=255;K=(K+360*r/200)%360; -x=Math.max(0,Math.min(x+t/100,1));B=Math.max(0,Math.min(B+u/100,1));z=Math.floor(K/60);F=K/60-z;A=B*(1-x);C=B*(1-x*F);x=B*(1-x*(1-F));if(0===z||6===z){var I=B;var D=x;var E=A}else 1===z?(I=C,D=B,E=A):2===z?(I=A,D=B,E=x):3===z?(I=A,D=C,E=B):4===z?(I=x,D=A,E=B):5===z&&(I=B,D=A,E=C);w[y]=255*I;w[y+1]=255*D;w[y+2]=255*E}return q}function h(q,r){var t;var u=q.data;var v=0;for(t=u.length;vw&&(u[v]-=r);u[v+1] -y&&(u[v+1]-=r);u[v+2]x&&(u[v+2]-=r)}return q}function m(q,r){var t;var u=q.data;var v=0;for(t=u.length;vw&&(u[v]-=r);u[v+1] +y&&(u[v+1]-=r);u[v+2]x&&(u[v+2]-=r)}return q}function m(q,r){var t;var u=q.data;var v=0;for(t=u.length;va ins SpriteMorph.prototype.positionTalkBubble=function(){var a=this.parentThatIsA(StageMorph),b=a?a.scale:1,c=this.talkBubble(),d=this.center().y;if(!c)return null;c.show();c.isPointingRight||(c.isPointingRight=!0,c.fixLayout(),c.rerender());c.setLeft(this.right());for(c.setBottom(this.top());!this.isTouching(c)&&c.bottom()a.right()&&(c.isPointingRight=!1,c.fixLayout(),c.rerender(),c.setRight(this.center().x));c.keepWithin(a)}; SpriteMorph.prototype.prepareToBeGrabbed=function(a){this.removeShadow();this.recordLayers();this.shadowAttribute("x position");this.shadowAttribute("y position");!this.bounds.containsPoint(a.position())&&this.isCorrectingOutsideDrag()&&this.setCenter(a.position());this.addShadow()};SpriteMorph.prototype.isCorrectingOutsideDrag=function(){return!this.parts.length}; SpriteMorph.prototype.justDropped=function(){var a=this.parentThatIsA(StageMorph);a&&(SnapActions.setSpritePosition(this),a.enableCustomHatBlocks=!0);this.exemplar&&this.inheritedAttributes.forEach(b=>{contains(["direction","size","costume #"],b)&&this.refreshInheritedAttribute(b)});this.restoreLayers();this.positionTalkBubble();this.receiveUserInteraction("dropped")}; -SpriteMorph.prototype.drawLine=function(a,b){var c=this.parent.bounds.origin,d=this.parent.scale,e=this.parent.penTrails().getContext("2d"),f=a.subtract(c).divideBy(d),g=b.subtract(c).divideBy(d),h=f.multiplyBy(d).add(c);c=g.multiplyBy(d).add(c);d=h.rectangle(c).expandBy(Math.max(this.size*d/2,1)).intersect(this.parent.visibleBounds()).spread();this.isDown&&(StageMorph.prototype.enablePenLogging&&this.parent.trailsLog.push([this.snapPoint(a),this.snapPoint(b),this.color.copy(),this.size,this.useFlatLineEnds? +SpriteMorph.prototype.drawLine=function(a,b){var c=this.parent.bounds.origin,d=this.parent.scale,e=this.parent.penTrails().getContext("2d"),f=a.subtract(c).divideBy(d),g=b.subtract(c).divideBy(d),k=f.multiplyBy(d).add(c);c=g.multiplyBy(d).add(c);d=k.rectangle(c).expandBy(Math.max(this.size*d/2,1)).intersect(this.parent.visibleBounds()).spread();this.isDown&&(StageMorph.prototype.enablePenLogging&&this.parent.trailsLog.push([this.snapPoint(a),this.snapPoint(b),this.color.copy(),this.size,this.useFlatLineEnds? "butt":"round"]),e.lineWidth=this.size,e.strokeStyle=this.color.toString(),this.useFlatLineEnds?(e.lineCap="butt",e.lineJoin="miter"):(e.lineCap="round",e.lineJoin="round"),e.beginPath(),e.moveTo(f.x,f.y),e.lineTo(g.x,g.y),e.stroke(),!1===this.isWarped&&this.world().broken.push(d),this.parent.cachedPenTrailsMorph=null)}; -SpriteMorph.prototype.floodFill=function(){function a(k){k*=4;return[g[k],g[k+1],g[k+2],g[k+3]]}function b(k){return k[0]===m[0]&&k[1]===m[1]&&k[2]===m[2]&&k[3]===m[3]}if(this.parent.bounds.containsPoint(this.rotationCenter())){this.parent.cachedPenTrailsMorph=null;1d.moveBy(a)),this.instances.forEach(d=>{if(d.cachedPropagation){var e=d.inheritsAttribute("x position"),f=d.inheritsAttribute("y position");e&&f?d.moveBy(a):e?d.moveBy(new Point(a.x,0)):f&&d.moveBy(new Point(0,a.y))}}))}; SpriteMorph.prototype.rootForGrab=function(){return this.anchor?this.anchor.rootForGrab():SpriteMorph.uber.rootForGrab.call(this)};SpriteMorph.prototype.setCenter=function(a,b){a=a.subtract(this.center());this.moveBy(a,b)};SpriteMorph.prototype.nestingBounds=function(){var a=this.bounds;!this.costume&&this.penBounds&&(a=this.penBounds.translateBy(this.position()));this.parts.forEach(b=>{b.isVisible&&(a=a.merge(b.nestingBounds()))});return a}; SpriteMorph.prototype.setPosition=function(a,b){a=a.subtract(this.topLeft());0===a.x&&0===a.y||this.moveBy(a,b)}; SpriteMorph.prototype.forward=function(a){a=a*this.parent.scale||0;0===a&&this.isDown?(this.isDown=!1,this.forward(-.05),this.isDown=!0,this.forward(.1),this.isDown=!1,this.forward(-.05),this.isDown=!0):(a=0<=a?this.position().distanceAngle(a,this.heading):this.position().distanceAngle(Math.abs(a),this.heading-180),this.shadowAttribute("x position"),this.shadowAttribute("y position"),this.setPosition(a),this.positionTalkBubble())}; -SpriteMorph.prototype.setHeading=function(a,b){var c=this.xPosition(),d=this.yPosition(),e=isFinite(a)?+a:0,f=e-this.heading;this.rotationStyle?(this.changed(),SpriteMorph.uber.setHeading.call(this,e),this.silentGotoXY(c,d,!0),this.positionTalkBubble()):this.heading=(+a%360+360)%360;this.parts.forEach(g=>{var h=(new Point(g.xPosition(),g.yPosition())).rotateBy(radians(f),new Point(c,d));g.rotatesWithAnchor&&g.turn(f);g.gotoXY(h.x,h.y)});b||this.shadowAttribute("direction");this.instances.forEach(g=> +SpriteMorph.prototype.setHeading=function(a,b){var c=this.xPosition(),d=this.yPosition(),e=isFinite(a)?+a:0,f=e-this.heading;this.rotationStyle?(this.changed(),SpriteMorph.uber.setHeading.call(this,e),this.silentGotoXY(c,d,!0),this.positionTalkBubble()):this.heading=(+a%360+360)%360;this.parts.forEach(g=>{var k=(new Point(g.xPosition(),g.yPosition())).rotateBy(radians(f),new Point(c,d));g.rotatesWithAnchor&&g.turn(f);g.gotoXY(k.x,k.y)});b||this.shadowAttribute("direction");this.instances.forEach(g=> {g.cachedPropagation&&g.inheritsAttribute("direction")&&g.setHeading(a,!0)})};SpriteMorph.prototype.faceToXY=function(a,b){this.setHeading(this.angleToXY(a,b))};SpriteMorph.prototype.angleToXY=function(a,b){a=(a-this.xPosition())*this.parent.scale;b=(b-this.yPosition())*this.parent.scale;return(.001>Math.abs(a)?0>b?90:270:Math.round((0<=a?0:180)-57.2957795131*Math.atan(b/a)))+90};SpriteMorph.prototype.turn=function(a){this.setHeading(this.heading+(+a||0))}; SpriteMorph.prototype.turnLeft=function(a){this.setHeading(this.heading-(+a||0))};SpriteMorph.prototype.xPosition=function(){if(this.inheritsAttribute("x position"))return this.exemplar.xPosition();var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(this.rotationCenter().x-a.center().x)/a.scale:this.rotationCenter().x}; SpriteMorph.prototype.yPosition=function(){if(this.inheritsAttribute("y position"))return this.exemplar.yPosition();var a=this.parentThatIsA(StageMorph);!a&&this.parent.grabOrigin&&(a=this.parent.grabOrigin.origin);return a?(a.center().y-this.rotationCenter().y)/a.scale:this.rotationCenter().y};SpriteMorph.prototype.direction=function(){return this.inheritsAttribute("direction")?this.exemplar.direction():this.heading};SpriteMorph.prototype.penSize=function(){return this.size}; @@ -1617,7 +1617,7 @@ SpriteMorph.prototype.deleteVariableWatcher=function(a){if(null===this.parentTha SpriteMorph.prototype.toggleWatcher=function(a,b,c){var d=this.parentThatIsA(StageMorph),e=this.parentThatIsA(IDE_Morph);if(d){var f=this.watcherFor(d,a);SnapActions.toggleWatcher(a,f&&f.isVisible);f?f.isVisible?f.hide():(f.show(),f.fixLayout(),f.keepWithin(d)):(f=new WatcherMorph(b,c,WatcherMorph.prototype.isGlobal(a)?d:this,a),f.setPosition(d.position().add(10)),b=d.watchers(f.left()),0c instanceof WatcherMorph&&c.getter===b&&c.target===(c.isGlobal(b)?a:this))}; SpriteMorph.prototype.deleteAllBlockInstances=function(a){(a.isGlobal?this.allBlockInstances(a):this.allIndependentInvocationsOf(a.blockSpec())).forEach(b=>b.deleteBlock());if(a.isGlobal){if(a=this.parentThatIsA(StageMorph))a.globalBlocks.forEach(b=>b.purgeCorpses()),a.children.concat(a).forEach(b=>{b.isSnapObject&&b.customBlocks.forEach(c=>c.purgeCorpses())})}else this.allSpecimens().concat(this).forEach(b=>b.customBlocks.forEach(c=>c.purgeCorpses()))}; -SpriteMorph.prototype.allBlockInstances=function(a){var b=[];if(a.isGlobal){var c=this.parentThatIsA(StageMorph);var d=c.children.filter(f=>f instanceof SpriteMorph);d.push(c);d.forEach(f=>b=b.concat(f.allLocalBlockInstances(a)));var e=[];c.globalBlocks.forEach(f=>{f.scripts.forEach(g=>g.allChildren().forEach(h=>{h.isCustomBlock&&h.definition===a&&e.push(h)}));f.body&&f.body.expression.allChildren().forEach(g=>{g.isCustomBlock&&g.definition===a&&e.push(g)})});return b.concat(e)}return this.allLocalBlockInstances(a)}; +SpriteMorph.prototype.allBlockInstances=function(a){var b=[];if(a.isGlobal){var c=this.parentThatIsA(StageMorph);var d=c.children.filter(f=>f instanceof SpriteMorph);d.push(c);d.forEach(f=>b=b.concat(f.allLocalBlockInstances(a)));var e=[];c.globalBlocks.forEach(f=>{f.scripts.forEach(g=>g.allChildren().forEach(k=>{k.isCustomBlock&&k.definition===a&&e.push(k)}));f.body&&f.body.expression.allChildren().forEach(g=>{g.isCustomBlock&&g.definition===a&&e.push(g)})});return b.concat(e)}return this.allLocalBlockInstances(a)}; SpriteMorph.prototype.allIndependentInvocationsOf=function(a){if(this.exemplar&&this.exemplar.getMethod(a))return[];var b=this.allInvocationsOf(a);this.instances.forEach(c=>c.addAllInvocationsOf(a,b));return b};SpriteMorph.prototype.allDependentInvocationsOf=function(a){var b=this.allInvocationsOf(a);this.instances.forEach(c=>c.addAllInvocationsOf(a,b));return b}; SpriteMorph.prototype.allInvocationsOf=function(a){var b=this.scripts.allChildren().filter(e=>e.isCustomBlock&&!e.isGlobal&&e.blockSpec===a);var c=[];this.customBlocks.forEach(e=>{e.scripts.forEach(f=>f.allChildren().forEach(g=>{g.isCustomBlock&&!g.isGlobal&&g.blockSpec===a&&c.push(g)}));e.body&&e.body.expression.allChildren().forEach(f=>{f.isCustomBlock&&!f.isGlobal&&f.blockSpec===a&&c.push(f)})});var d=this.allEditorBlockInstances(null,a);return b.concat(c).concat(d)}; SpriteMorph.prototype.addAllInvocationsOf=function(a,b){this.getLocalMethod(a)||(this.allInvocationsOf(a).forEach(c=>b.push(c)),this.instances.forEach(c=>c.addAllInvocationsOf(a,b)))}; @@ -1646,8 +1646,8 @@ SpriteMorph.prototype.hasSpriteVariable=function(a){return contains(this.variabl SpriteMorph.prototype.getMethod=function(a){return this.allBlocks()[a]};SpriteMorph.prototype.getLocalMethod=function(a){return this.ownBlocks()[a]};SpriteMorph.prototype.ownBlocks=function(){var a={};this.customBlocks.forEach(b=>a[b.blockSpec()]=b);return a};SpriteMorph.prototype.allBlocks=function(a){var b={};this.allExemplars().reverse().forEach(c=>c.customBlocks.forEach(d=>b[d.blockSpec()]=d));return a?Object.keys(b).map(c=>b[c]):b}; SpriteMorph.prototype.inheritedBlocks=function(a){var b={},c=Object.keys(this.ownBlocks()),d=this.allExemplars().reverse();d.pop();d.forEach(e=>e.customBlocks.forEach(f=>{var g=f.blockSpec();contains(c,g)||(b[g]=f)}));return a?Object.keys(b).map(e=>b[e]):b};SpriteMorph.prototype.shadowAllMethods=function(){var a;this.inheritedMethods().forEach(b=>this.customBlocks.push(b));!this.isTemporary&&(a=this.parentThatIsA(IDE_Morph))&&(a.flushPaletteCache(),a.refreshPalette())}; SpriteMorph.prototype.inheritedMethods=function(){return this.inheritedBlocks(!0).map(a=>a.copyAndBindTo(this,!0))}; -SpriteMorph.prototype.thumbnail=function(a,b){function c(n,p,q){var r=Math.min(a.x,a.y)/10;k.strokeStyle=n;k.globalAlpha=p;k.compositeOperation="lighter";k.lineWidth=q||1;k.moveTo(r,r);k.lineTo(l.width-r,l.height-r);k.moveTo(r,l.height-r);k.lineTo(l.width-r,r);k.stroke()}var d=this.getImage(),e=this.width(),f=this.height(),g=Math.min(a.x/e,a.y/f),h=(a.x-e*g)/2,m=(a.y-f*g)/2,l=newCanvas(a,!1,b),k=l.getContext("2d");k.save();this.isCorpse&&(k.globalAlpha=.3);e&&f&&d.width&&d.height&&(k.scale(g,g),k.drawImage(d, -Math.floor(h/g),Math.floor(m/g)));this.isCorpse&&(k.restore(),c("white",.8,6),c("black",.8,1));k.restore();return l};SpriteMorph.prototype.fullThumbnail=function(a,b){b=this.thumbnail(a,b);var c=b.getContext("2d"),d=a.divideBy(3),e;c.restore();this.anchor&&c.drawImage(this.anchor.thumbnail(d),0,0);for(e=0;3>e;e+=1)this.parts[e]&&c.drawImage(this.parts[e].thumbnail(d),e*d.x,a.y-d.y);return b};SpriteMorph.prototype.booleanMorph=function(a){a=new BooleanSlotMorph(a);a.isStatic=!0;a.fixLayout();return a}; +SpriteMorph.prototype.thumbnail=function(a,b){function c(n,p,q){var r=Math.min(a.x,a.y)/10;h.strokeStyle=n;h.globalAlpha=p;h.compositeOperation="lighter";h.lineWidth=q||1;h.moveTo(r,r);h.lineTo(l.width-r,l.height-r);h.moveTo(r,l.height-r);h.lineTo(l.width-r,r);h.stroke()}var d=this.getImage(),e=this.width(),f=this.height(),g=Math.min(a.x/e,a.y/f),k=(a.x-e*g)/2,m=(a.y-f*g)/2,l=newCanvas(a,!1,b),h=l.getContext("2d");h.save();this.isCorpse&&(h.globalAlpha=.3);e&&f&&d.width&&d.height&&(h.scale(g,g),h.drawImage(d, +Math.floor(k/g),Math.floor(m/g)));this.isCorpse&&(h.restore(),c("white",.8,6),c("black",.8,1));h.restore();return l};SpriteMorph.prototype.fullThumbnail=function(a,b){b=this.thumbnail(a,b);var c=b.getContext("2d"),d=a.divideBy(3),e;c.restore();this.anchor&&c.drawImage(this.anchor.thumbnail(d),0,0);for(e=0;3>e;e+=1)this.parts[e]&&c.drawImage(this.parts[e].thumbnail(d),e*d.x,a.y-d.y);return b};SpriteMorph.prototype.booleanMorph=function(a){a=new BooleanSlotMorph(a);a.isStatic=!0;a.fixLayout();return a}; SpriteMorph.prototype.attachTo=function(a){a.attachPart(this)};SpriteMorph.prototype.attachPart=function(a){var b=Date.now();a.anchor&&a.anchor.detachPart(a);this.parts.push(a);this.version=b;a.anchor=this;this.allParts().forEach(c=>c.nestingScale=c.scale);a.version=b};SpriteMorph.prototype.detachPart=function(a){var b=this.parts.indexOf(a);if(-1!==b){var c=Date.now();this.parts.splice(b,1);this.version=c;a.anchor=null;a.version=c}}; SpriteMorph.prototype.detachAllParts=function(){var a=Date.now();this.parts.forEach(b=>{b.anchor=null;b.version=a});this.parts=[];this.version=a};SpriteMorph.prototype.detachFromAnchor=function(){this.anchor&&this.anchor.detachPart(this)};SpriteMorph.prototype.allParts=function(){var a=[this];this.parts.forEach(b=>a=a.concat(b.allParts()));return a};SpriteMorph.prototype.allAnchors=function(){var a=[this];null!==this.anchor&&(a=a.concat(this.anchor.allAnchors()));return a}; SpriteMorph.prototype.recordLayers=function(){var a=this.parentThatIsA(StageMorph);a?(this.layers=this.allParts(),this.layers.forEach(b=>{(b=b.talkBubble())&&b.hide()}),this.layers.sort((b,c)=>a.children.indexOf(b){a.comeToFront();a.positionTalkBubble()});this.layers=null}; @@ -1698,33 +1698,33 @@ StageMorph.prototype.fireStopAllEvent=function(){var a=this.parentThatIsA(IDE_Mo StageMorph.prototype.runStopScripts=function(){this.receiveUserInteraction("stopped",!0,!0);this.children.forEach(b=>{b instanceof SpriteMorph&&b.receiveUserInteraction("stopped",!0,!0)});var a=this.parentThatIsA(IDE_Morph);if(a)a.extensions.onStopAllScripts()};StageMorph.prototype.removeAllClones=function(){this.children.filter(a=>a instanceof SpriteMorph&&a.isTemporary).forEach(a=>{this.threads.stopAllForReceiver(a);a.detachFromAnchor();a.corpsify();a.destroy()});this.cloneCount=0}; StageMorph.prototype.editScripts=function(){var a=this.parentThatIsA(IDE_Morph);if(!a.isAppMode&&ScriptsMorph.prototype.enableKeyboard){a=a.getActiveScripts().selectForEdit();a.edit(a.position());var b=a.focus.sortedScripts();b.length?(a.focus.element=b[0],a.focus.element instanceof HatBlockMorph&&a.focus.nextCommand()):a.focus.moveBy(new Point(50,50));a.focus.fixLayout()}}; StageMorph.prototype.blockTemplates=function(a){function b(n){if(l.hiddenPrimitives[n])return null;n=SpriteMorph.prototype.blockForSelector(n,!0);n.isTemplate=!0;return n}function c(n,p){n=SpriteMorph.prototype.variableBlock(n,p);n.isDraggable=!1;n.isTemplate=!0;return n}function d(n){if(l.hiddenPrimitives[n])return null;var p=SpriteMorph.prototype.blocks[n];return new ToggleMorph("checkbox",this,function(){l.toggleWatcher(n,localize(p.spec),l.blockColor[p.category])},null,function(){return l.showingWatcher(n)}, -null)}function e(n){return new ToggleMorph("checkbox",this,function(){l.toggleVariableWatcher(n)},null,function(){return l.showingVariableWatcher(n)},null)}function f(n){n&&(l.isVariableNameInUse(n[0])?l.inform("that name is already in use"):SnapActions.addVariable(n[0],n[1]||l.id))}function g(n){SnapActions.deleteVariable(n,l.id)}function h(n){const p=l.parentThatIsA(StageMorph),q=n.name.trim();n=n.fields.map(r=>r.trim()).filter(r=>!!r);p.messageTypes.getMsgType(q)?l.inform("that name is already in use"): -SnapActions.addMessageType(q,n)}var m=[],l=this;a=a||"motion";if("motion"===a){var k=new TextMorph(localize("Stage selected:\nno motion primitives"));k.fontSize=9;k.setColor(this.paletteTextColor);m.push(k)}else"looks"===a?(m.push(b("doSwitchToCostume")),m.push(b("doWearNextCostume")),m.push(d("getCostumeIdx")),m.push(b("getCostumeIdx")),m.push("-"),m.push(b("reportGetImageAttribute")),m.push(b("reportNewCostumeStretched")),m.push(b("reportNewCostume")),m.push("-"),m.push(b("changeEffect")),m.push(b("setEffect")), -m.push(b("clearEffects")),m.push(b("getEffect")),m.push("-"),m.push(b("show")),m.push(b("hide")),m.push(d("reportShown")),m.push(b("reportShown")),this.world().isDevMode&&(m.push("-"),k=new TextMorph(localize("development mode \ndebugging primitives:")),k.fontSize=9,k.setColor(this.paletteTextColor),m.push(k),m.push("-"),m.push(b("log")),m.push(b("alert")))):"sound"===a?(m.push(b("playSound")),m.push(b("doPlaySoundUntilDone")),m.push(b("doStopAllSounds")),m.push("-"),m.push(b("doPlaySoundAtRate")), +null)}function e(n){return new ToggleMorph("checkbox",this,function(){l.toggleVariableWatcher(n)},null,function(){return l.showingVariableWatcher(n)},null)}function f(n){n&&(l.isVariableNameInUse(n[0])?l.inform("that name is already in use"):SnapActions.addVariable(n[0],n[1]||l.id))}function g(n){SnapActions.deleteVariable(n,l.id)}function k(n){const p=l.parentThatIsA(StageMorph),q=n.name.trim();n=n.fields.map(r=>r.trim()).filter(r=>!!r);p.messageTypes.getMsgType(q)?l.inform("that name is already in use"): +SnapActions.addMessageType(q,n)}var m=[],l=this;a=a||"motion";if("motion"===a){var h=new TextMorph(localize("Stage selected:\nno motion primitives"));h.fontSize=9;h.setColor(this.paletteTextColor);m.push(h)}else"looks"===a?(m.push(b("doSwitchToCostume")),m.push(b("doWearNextCostume")),m.push(d("getCostumeIdx")),m.push(b("getCostumeIdx")),m.push("-"),m.push(b("reportGetImageAttribute")),m.push(b("reportNewCostumeStretched")),m.push(b("reportNewCostume")),m.push("-"),m.push(b("changeEffect")),m.push(b("setEffect")), +m.push(b("clearEffects")),m.push(b("getEffect")),m.push("-"),m.push(b("show")),m.push(b("hide")),m.push(d("reportShown")),m.push(b("reportShown")),this.world().isDevMode&&(m.push("-"),h=new TextMorph(localize("development mode \ndebugging primitives:")),h.fontSize=9,h.setColor(this.paletteTextColor),m.push(h),m.push("-"),m.push(b("log")),m.push(b("alert")))):"sound"===a?(m.push(b("playSound")),m.push(b("doPlaySoundUntilDone")),m.push(b("doStopAllSounds")),m.push("-"),m.push(b("doPlaySoundAtRate")), m.push(b("reportGetSoundAttribute")),m.push(b("reportNewSoundFromSamples")),m.push("-"),m.push(b("doRest")),m.push(b("doPlayNote")),m.push(b("doSetInstrument")),m.push("-"),m.push(b("doChangeTempo")),m.push(b("doSetTempo")),m.push(d("getTempo")),m.push(b("getTempo")),m.push("-"),m.push(b("changeVolume")),m.push(b("setVolume")),m.push(d("getVolume")),m.push(b("getVolume")),m.push("-"),m.push(b("changePan")),m.push(b("setPan")),m.push(d("getPan")),m.push(b("getPan")),m.push("-"),m.push(b("playFreq")), -m.push(b("stopFreq")),this.world().isDevMode&&(m.push("-"),k=new TextMorph(localize("development mode \ndebugging primitives:")),k.fontSize=9,k.setColor(this.paletteTextColor),m.push(k),m.push("-"),m.push(b("doPlayFrequency")))):"pen"===a?(m.push(b("clear")),m.push("-"),m.push(b("setBackgroundColor")),m.push(b("changeBackgroundColorDimension")),m.push(b("setBackgroundColorDimension")),m.push("-"),m.push(b("reportPenTrailsAsCostume")),m.push("-"),m.push(b("doPasteOn"))):"network"===a?(m.push(b("receiveSocketMessage")), -m.push(b("doSocketMessage")),m.push("-"),m.push(b("doSocketRequest")),m.push(b("doSocketResponse")),m.push("-"),m.push(b("getJSFromRPCStruct")),m.push(b("doRunRPC")),m.push(d("reportRPCError")),m.push(b("reportRPCError")),m.push("-"),m.push(b("getProjectIds")),m.push(b("getProjectId")),k=new PushButtonMorph(null,function(){(new MessageCreatorMorph(l,h)).popUp()},"Make a message type"),m.push(k),0n.addItem(p,p,null,null,null,null,null,null,!0));n.popUpAtHand(l.world())},"Delete a variable"),m.push(k)),m.push("-"), -k=this.reachableGlobalVariableNames(!0),0{m.push(e(n));m.push(c(n))}),m.push("-")),k=this.allLocalVariableNames(!0),0{m.push(e(n));m.push(c(n,!0))}),m.push("-")),m.push(b("doSetVar")),m.push(b("doChangeVar")),m.push(b("doShowVar")),m.push(b("doHideVar")),m.push(b("doDeclareVariables")),m.push("="),m.push(b("reportNewList")),m.push(b("reportNumbers")),m.push("-"),m.push(b("reportCONS")),m.push(b("reportListItem")),m.push(b("reportCDR")),m.push("-"), +m.push("-"),m.push(b("reportJoinWords")),m.push(b("reportTextSplit")),m.push(b("reportLetter")),m.push(b("reportStringSize")),m.push("-"),m.push(b("reportUnicode")),m.push(b("reportUnicodeAsLetter")),m.push("-"),m.push(b("reportIsA")),m.push(b("reportIsIdentical")),m.push("-"),m.push(b("reportJSFunction")),Process.prototype.enableCompiling&&m.push(b("reportCompiled")),this.world().isDevMode&&(m.push("-"),h=new TextMorph("development mode \ndebugging primitives:"),h.fontSize=9,h.setColor(this.paletteTextColor), +m.push(h),m.push("-"),m.push(b("reportTypeOf")),m.push(b("reportTextFunction")))):"variables"===a&&(h=new PushButtonMorph(null,function(){(new VariableDialogMorph(null,f,l)).prompt("Variable name",null,l.world())},"Make a variable"),m.push(h),0n.addItem(p,p,null,null,null,null,null,null,!0));n.popUpAtHand(l.world())},"Delete a variable"),m.push(h)),m.push("-"), +h=this.reachableGlobalVariableNames(!0),0{m.push(e(n));m.push(c(n))}),m.push("-")),h=this.allLocalVariableNames(!0),0{m.push(e(n));m.push(c(n,!0))}),m.push("-")),m.push(b("doSetVar")),m.push(b("doChangeVar")),m.push(b("doShowVar")),m.push(b("doHideVar")),m.push(b("doDeclareVariables")),m.push("="),m.push(b("reportNewList")),m.push(b("reportNumbers")),m.push("-"),m.push(b("reportCONS")),m.push(b("reportListItem")),m.push(b("reportCDR")),m.push("-"), m.push(b("reportListAttribute")),m.push(b("reportListIndex")),m.push(b("reportListContainsItem")),m.push(b("reportListIsEmpty")),m.push("-"),m.push(b("reportMap")),m.push(b("reportKeep")),m.push(b("reportFindFirst")),m.push(b("reportCombine")),m.push("-"),m.push(b("doForEach")),m.push("-"),m.push(b("doAddToList")),m.push(b("doDeleteFromList")),m.push(b("doInsertInList")),m.push(b("doReplaceInList")),m.push("-"),m.push(b("reportConcatenatedLists")),m.push(b("reportReshape")),m.push(b("reportCrossproduct")), -this.world().isDevMode&&(m.push("-"),k=new TextMorph(localize("development mode \ndebugging primitives:")),k.fontSize=9,k.setColor(this.paletteTextColor),m.push(k),m.push("-"),m.push(b("doShowTable"))),StageMorph.prototype.enableCodeMapping&&(m.push("="),m.push(b("doMapCodeOrHeader")),m.push(b("doMapValueCode")),m.push(b("doMapListCode")),m.push("-"),m.push(b("reportMappedCode"))));if(k=this.parentThatIsA(IDE_Morph))k=k.extensions.getPaletteContents(this,a).flatMap(n=>{switch(n.type){case "block":return b(n.name); -case "watcher":return[d(n.name),b(n.name)];case "space":return n.name}return n}),m.push(...k);m.push("=");m.push(this.makeBlockButton(a));return m};StageMorph.prototype.clear=function(){this.clearPenTrails()}; +this.world().isDevMode&&(m.push("-"),h=new TextMorph(localize("development mode \ndebugging primitives:")),h.fontSize=9,h.setColor(this.paletteTextColor),m.push(h),m.push("-"),m.push(b("doShowTable"))),StageMorph.prototype.enableCodeMapping&&(m.push("="),m.push(b("doMapCodeOrHeader")),m.push(b("doMapValueCode")),m.push(b("doMapListCode")),m.push("-"),m.push(b("reportMappedCode"))));if(h=this.parentThatIsA(IDE_Morph))h=h.extensions.getPaletteContents(this,a).flatMap(n=>{switch(n.type){case "block":return b(n.name); +case "watcher":return[d(n.name),b(n.name)];case "space":return n.name}return n}),m.push(...h);m.push("=");m.push(this.makeBlockButton(a));return m};StageMorph.prototype.clear=function(){this.clearPenTrails()}; StageMorph.prototype.userMenu=function(){var a=this.parentThatIsA(IDE_Morph),b=new MenuMorph(this);if(a&&a.isAppMode)return b;b.addItem("edit","edit");b.addItem("show all","showAll");b.addItem("pic...",()=>a.saveCanvasAs(this.fullImage(),this.name),"save a picture\nof the stage");b.addLine();b.addItem("pen trails",()=>{var c=a.currentSprite.reportPenTrailsAsCostume().copy();a.currentSprite.addCostume(c);a.currentSprite.wearCostume(c);a.hasChangedMedia=!0;a.spriteBar.tabBar.tabTo("costumes")},a.currentSprite instanceof SpriteMorph?"turn all pen trails and stamps\ninto a new costume for the\ncurrently selected sprite":"turn all pen trails and stamps\ninto a new background for the stage");this.trailsLog.length&&b.addItem("svg...","exportTrailsLogAsSVG","export pen trails\nline segments as SVG");NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,b);return b}; StageMorph.prototype.showAll=function(){this.children.forEach(a=>{a instanceof SpriteMorph?a.anchor||(a.show(),a.keepWithin(this)):(a.show(),a.keepWithin(this),a.fixLayout&&a.fixLayout())})};StageMorph.prototype.edit=SpriteMorph.prototype.edit;StageMorph.prototype.fullImage=Morph.prototype.fullImage; StageMorph.prototype.addSwitchToScriptsButton=function(){var a=this.parentThatIsA(IDE_Morph).currentSprite.scripts.parentThatIsA(ScrollFrameMorph),b=new PushButtonMorph(this,"switchToScripts",new SymbolMorph("turtle",12));this.switchToScriptsButton=b;b.alpha=.2;b.padding=4;b.edge=0;b.hint="toggle focus between stage\nand scripting area";b.labelShadowColor=a.toolBar.keyboardButton.labelShadowColor;b.fixLayout();this.add(b);b.setRight(this.right()-4);b.setTop(this.top()+4)}; StageMorph.prototype.switchToScripts=function(){var a=this.parentThatIsA(IDE_Morph).currentSprite.scripts.parentThatIsA(ScrollFrameMorph);this.switchToScriptsButton.destroy();a.show()};StageMorph.prototype.thumbnail=function(a,b){return this.fancyThumbnail(a,null,!1,b)}; -StageMorph.prototype.fancyThumbnail=function(a,b,c,d){var e=this.getImage(),f=Math.min(a.x/e.width,a.y/e.height);a=newCanvas(a,c,d);var g=a.getContext("2d"),h,m;g.save();g.scale(f,f);g.drawImage(e,0,0);g.drawImage(this.penTrails(),0,0,this.dimensions.x*this.scale,this.dimensions.y*this.scale);this.projectionSource&&(g.save(),g.globalAlpha=1-this.projectionTransparency/100,g.drawImage(this.projectionLayer(),0,0,this.dimensions.x*this.scale,this.dimensions.y*this.scale),g.restore());this.children.forEach(l=> -{l.isVisible&&l!==b&&(h=l.fullBounds(),m=l.fullImage(),m.width&&m.height&&g.drawImage(l.fullImage(),h.origin.x-this.bounds.origin.x,h.origin.y-this.bounds.origin.y))});g.restore();return a};StageMorph.prototype.exportTrailsLogAsSVG=function(){var a=this.parentThatIsA(IDE_Morph);a.saveFileAs(this.trailsLogAsSVG().src,"image/svg",a.projectName||this.name)}; -StageMorph.prototype.trailsLogAsSVG=function(){var a=this.trailsLog[0][0],b=a,c=this.trailsLog[0][3],d,e;this.trailsLog.forEach(m=>{a=a.min(m[0]);a=a.min(m[1]);b=b.max(m[0]);b=b.max(m[1]);c=Math.max(c,m[3])});var f=a.corner(b).expandBy(c/2);var g=(new Point(-a.x,b.y)).translateBy(c/2);var h='';h+="\x3c!-- Generated by Snap! - http://snap.berkeley.edu/ --\x3e"; -this.trailsLog.forEach(m=>{d=this.normalizePoint(m[0]).translateBy(g);e=this.normalizePoint(m[1]).translateBy(g);h+=''});h+="";return{src:h,rot:new Point(-f.origin.x,f.corner.y)}};StageMorph.prototype.normalizePoint=function(a){return new Point(a.x,-a.y)};StageMorph.prototype.hide=function(){this.isVisible=!1;this.changed()}; +StageMorph.prototype.fancyThumbnail=function(a,b,c,d){var e=this.getImage(),f=Math.min(a.x/e.width,a.y/e.height);a=newCanvas(a,c,d);var g=a.getContext("2d"),k,m;g.save();g.scale(f,f);g.drawImage(e,0,0);g.drawImage(this.penTrails(),0,0,this.dimensions.x*this.scale,this.dimensions.y*this.scale);this.projectionSource&&(g.save(),g.globalAlpha=1-this.projectionTransparency/100,g.drawImage(this.projectionLayer(),0,0,this.dimensions.x*this.scale,this.dimensions.y*this.scale),g.restore());this.children.forEach(l=> +{l.isVisible&&l!==b&&(k=l.fullBounds(),m=l.fullImage(),m.width&&m.height&&g.drawImage(l.fullImage(),k.origin.x-this.bounds.origin.x,k.origin.y-this.bounds.origin.y))});g.restore();return a};StageMorph.prototype.exportTrailsLogAsSVG=function(){var a=this.parentThatIsA(IDE_Morph);a.saveFileAs(this.trailsLogAsSVG().src,"image/svg",a.projectName||this.name)}; +StageMorph.prototype.trailsLogAsSVG=function(){var a=this.trailsLog[0][0],b=a,c=this.trailsLog[0][3],d,e;this.trailsLog.forEach(m=>{a=a.min(m[0]);a=a.min(m[1]);b=b.max(m[0]);b=b.max(m[1]);c=Math.max(c,m[3])});var f=a.corner(b).expandBy(c/2);var g=(new Point(-a.x,b.y)).translateBy(c/2);var k='';k+="\x3c!-- Generated by Snap! - http://snap.berkeley.edu/ --\x3e"; +this.trailsLog.forEach(m=>{d=this.normalizePoint(m[0]).translateBy(g);e=this.normalizePoint(m[1]).translateBy(g);k+=''});k+="";return{src:k,rot:new Point(-f.origin.x,f.corner.y)}};StageMorph.prototype.normalizePoint=function(a){return new Point(a.x,-a.y)};StageMorph.prototype.hide=function(){this.isVisible=!1;this.changed()}; StageMorph.prototype.show=function(){this.isVisible=!0;this.changed()};StageMorph.prototype.reportShown=SpriteMorph.prototype.reportShown;StageMorph.prototype.createClone=nop;StageMorph.prototype.newClone=nop;StageMorph.prototype.setColorDimension=function(a,b){b=+b;a=+a;if(!(0>a||3b||100b?100:0)+b%100}else b=Math.min(100,Math.max(0,b));3===a?this.color.a=1-b/100:(this.cachedHSV[a]=b/100,this.color.set_hsv.apply(this.color,this.cachedHSV));this.rerender()}}; StageMorph.prototype.getColorDimension=SpriteMorph.prototype.getColorDimension;StageMorph.prototype.changeColorDimension=SpriteMorph.prototype.changeColorDimension;StageMorph.prototype.setColorRGBA=SpriteMorph.prototype.setColorRGBA;StageMorph.prototype.changeColorRGBA=SpriteMorph.prototype.changeColorRGBA;StageMorph.prototype.setColor=function(a){this.color.eq(a,!0)||(this.color=a.copy(),this.rerender(),this.cachedHSV=this.color.hsv())};StageMorph.prototype.setBackgroundColor=StageMorph.prototype.setColor; StageMorph.prototype.getPenAttribute=SpriteMorph.prototype.getPenAttribute;StageMorph.prototype.pasteOn=SpriteMorph.prototype.pasteOn;StageMorph.prototype.categories=SpriteMorph.prototype.categories;StageMorph.prototype.blockColor=SpriteMorph.prototype.blockColor;StageMorph.prototype.paletteColor=SpriteMorph.prototype.paletteColor;StageMorph.prototype.setName=SpriteMorph.prototype.setName;StageMorph.prototype.makeBlockButton=SpriteMorph.prototype.makeBlockButton;StageMorph.prototype.makeBlock=SpriteMorph.prototype.makeBlock; @@ -1753,18 +1753,18 @@ SpriteBubbleMorph.prototype.fixLayout=function(){var a=SpriteMorph.prototype;thi this.edge+2*this.border+2*this.padding+2);this.contentsMorph.setPosition(this.position().add(new Point(this.padding||this.edge,this.border+this.padding+1)))};function Costume(a,b,c,d){this.contents=a?normalizeCanvas(a,!0):newCanvas(null,!0);d||this.shrinkToFit(this.maxExtent());this.name=b||null;this.rotationCenter=c||this.center();this.version=Date.now();this.loaded=null}Costume.prototype.maxExtent=function(){return StageMorph.prototype.dimensions}; Costume.prototype.toString=function(){return"a Costume("+this.name+")"};Costume.prototype.extent=function(){return new Point(this.contents.width,this.contents.height)};Costume.prototype.center=function(){return this.extent().divideBy(2)};Costume.prototype.width=function(){return this.contents.width};Costume.prototype.height=function(){return this.contents.height};Costume.prototype.bounds=function(){return new Rectangle(0,0,this.width(),this.height())}; Costume.prototype.shrinkWrap=function(){var a=this.boundingBox(),b=a.extent(),c=newCanvas(b,!0);c.getContext("2d").drawImage(this.contents,a.origin.x,a.origin.y,b.x,b.y,0,0,b.x,b.y);this.rotationCenter=this.rotationCenter.subtract(a.origin);this.contents=c;this.version=Date.now()}; -Costume.prototype.canvasBoundingBox=function(a){var b,c,d=a.width,e=a.height,f=a.getContext("2d").getImageData(0,0,d,e);a:{for(c=0;c<=d;c+=1)for(b=0;b<=e;b+=1)if(f.data[b*d*4+4*c+3]){a=c;break a}a=0}a:{for(b=0;b<=e;b+=1)for(c=0;c<=d;c+=1)if(f.data[b*d*4+4*c+3]){var g=b;break a}g=0}a:{for(c=d;0<=c;--c)for(b=e;0<=b;--b)if(f.data[b*d*4+4*c+3]){var h=Math.min(c+1,d);break a}h=d}a:{for(b=e;0<=b;--b)for(c=d;0<=c;--c)if(f.data[b*d*4+4*c+3]){d=Math.min(b+1,e);break a}d=e}return new Rectangle(a,g,h,d)}; +Costume.prototype.canvasBoundingBox=function(a){var b,c,d=a.width,e=a.height,f=a.getContext("2d").getImageData(0,0,d,e);a:{for(c=0;c<=d;c+=1)for(b=0;b<=e;b+=1)if(f.data[b*d*4+4*c+3]){a=c;break a}a=0}a:{for(b=0;b<=e;b+=1)for(c=0;c<=d;c+=1)if(f.data[b*d*4+4*c+3]){var g=b;break a}g=0}a:{for(c=d;0<=c;--c)for(b=e;0<=b;--b)if(f.data[b*d*4+4*c+3]){var k=Math.min(c+1,d);break a}k=d}a:{for(b=e;0<=b;--b)for(c=d;0<=c;--c)if(f.data[b*d*4+4*c+3]){d=Math.min(b+1,e);break a}d=e}return new Rectangle(a,g,k,d)}; Costume.prototype.boundingBox=function(){return this.canvasBoundingBox(this.contents)};Costume.prototype.copy=function(){var a=newCanvas(this.extent(),!0);a.getContext("2d").drawImage(this.contents,0,0);a=new Costume(a,this.name?copy(this.name):null);a.rotationCenter=this.rotationCenter.copy();return a}; Costume.prototype.flipped=function(){var a=newCanvas(this.extent(),!0),b=a.getContext("2d");b.translate(this.width(),0);b.scale(-1,1);b.drawImage(this.contents,0,0);return new Costume(a,this.name,new Point(this.width()-this.rotationCenter.x,this.rotationCenter.y))}; Costume.prototype.stretched=function(a,b){a=(Math.sign(a)||1)*Math.max(1,Math.abs(a));b=(Math.sign(b)||1)*Math.max(1,Math.abs(b));var c=newCanvas(new Point(Math.abs(a),Math.abs(b)),!0),d=c.getContext("2d"),e=a/this.width(),f=b/this.height(),g=this.rotationCenter.multiplyBy(new Point(e,f));0>e&&(g.x=c.width-Math.abs(g.x));0>f&&(g.y=c.height-Math.abs(g.y));d.translate(Math.abs(Math.min(a,0)),Math.abs(Math.min(b,0)));d.scale(e,f);d.drawImage(this.contents,0,0);return new Costume(c,this.name,g,!0)}; -Costume.prototype.edit=function(a,b,c,d,e){var f=new PaintEditorMorph;f.oncancel=d||nop;f.openIn(a,c?newCanvas(StageMorph.prototype.dimensions,!0):this.contents,c?null:this.rotationCenter,(g,h)=>{this.contents=g;this.rotationCenter=h;this.version=Date.now();a.changed();b&&(b.currentSprite instanceof SpriteMorph&&this.shrinkWrap(),b.currentSprite.wearCostume(this,!0),b.hasChangedMedia=!0);(e||nop)()},b)}; +Costume.prototype.edit=function(a,b,c,d,e){var f=new PaintEditorMorph;f.oncancel=d||nop;f.openIn(a,c?newCanvas(StageMorph.prototype.dimensions,!0):this.contents,c?null:this.rotationCenter,(g,k)=>{this.contents=g;this.rotationCenter=k;this.version=Date.now();a.changed();b&&(b.currentSprite instanceof SpriteMorph&&this.shrinkWrap(),b.currentSprite.wearCostume(this,!0),b.hasChangedMedia=!0);(e||nop)()},b)}; Costume.prototype.editRotationPointOnly=function(a,b){var c=new CostumeEditorMorph(this);c.fixLayout();var d=new DialogBoxMorph(this,()=>{c.accept();b&&b.call(this)});var e=new TextMorph(localize("click or drag crosshairs to move the rotation center"),d.fontSize,d.fontStyle,!0,!1,"center",null,null,new Point(1,1),WHITE);d.labelString="Costume Editor";d.createLabel();d.setPicture(c);d.addBody(e);d.addButton("ok","Ok");d.addButton("cancel","Cancel");d.fixLayout();d.popUp(a)}; Costume.prototype.shrinkToFit=function(a){if(a.xb.copy());return a};SVG_Costume.prototype.shrinkToFit=function(a){nop(a)}; SVG_Costume.prototype.parseShapes=function(){var a=new XML_Element,b=this.contents.src.replace(/^data:image\/.*?, */,"");-1window[c.attributes.prototype].fromSVG(c)))}; -SVG_Costume.prototype.edit=function(a,b,c,d,e){var f=new VectorPaintEditorMorph,g=this;f.oncancel=d||nop;f.openIn(a,c?newCanvas(StageMorph.prototype.dimensions):this.contents,c?new Point(240,180):this.rotationCenter,(h,m,l)=>{g.contents=h;g.rotationCenter=m;g.shapes=l;g.version=Date.now();a.changed();b&&(c&&b.currentSprite.addCostume(g),b.currentSprite.wearCostume(g),b.hasChangedMedia=!0);(e||nop)()},b,this.shapes||[])}; +SVG_Costume.prototype.edit=function(a,b,c,d,e){var f=new VectorPaintEditorMorph,g=this;f.oncancel=d||nop;f.openIn(a,c?newCanvas(StageMorph.prototype.dimensions):this.contents,c?new Point(240,180):this.rotationCenter,(k,m,l)=>{g.contents=k;g.rotationCenter=m;g.shapes=l;g.version=Date.now();a.changed();b&&(c&&b.currentSprite.addCostume(g),b.currentSprite.wearCostume(g),b.hasChangedMedia=!0);(e||nop)()},b,this.shapes||[])}; SVG_Costume.prototype.rasterized=function(){var a=newCanvas(this.extent(),!0);a.getContext("2d").drawImage(this.contents,0,0);return new Costume(a,this.name,this.rotationCenter.copy())};CostumeEditorMorph.prototype=new Morph;CostumeEditorMorph.prototype.constructor=CostumeEditorMorph;CostumeEditorMorph.uber=Morph.prototype;CostumeEditorMorph.prototype.size=Costume.prototype.maxExtent();function CostumeEditorMorph(a){this.init(a)} CostumeEditorMorph.prototype.init=function(a){this.costume=a||new Costume;this.rotationCenter=this.costume.rotationCenter.copy();this.margin=ZERO;CostumeEditorMorph.uber.init.call(this)};CostumeEditorMorph.prototype.accept=function(){this.costume.rotationCenter=this.rotationCenter.copy();this.costume.version=Date.now()};CostumeEditorMorph.prototype.fixLayout=function(){this.bounds.setExtent(this.size)}; CostumeEditorMorph.prototype.render=function(a){this.margin=this.size.subtract(this.costume.extent()).divideBy(2);var b=this.rotationCenter.add(this.margin);this.cachedTexture||(this.cachedTexture=this.createTexture());this.renderCachedTexture(a);a.drawImage(this.costume.contents,this.margin.x,this.margin.y);a.globalAlpha=.5;a.fillStyle="white";a.beginPath();a.arc(b.x,b.y,20,radians(0),radians(360),!1);a.closePath();a.fill();a.stroke();a.beginPath();a.arc(b.x,b.y,10,radians(0),radians(360),!1);a.stroke(); @@ -1785,8 +1785,8 @@ Microphone.prototype.createAnalyser=function(){this.analyser=this.audioContext.c Microphone.prototype.createProcessor=function(){var a=this;this.processor=this.audioContext.createScriptProcessor(this.binSizes[this.resolution-1]);this.processor.onaudioprocess=function(b){a.stepAudio(b)};this.processor.clipping=!1;this.processor.lastClip=0;this.processor.clipLevel=.98;this.processor.averaging=.95;this.processor.clipLag=750}; Microphone.prototype.stepAudio=function(a){var b;if(this.isAutoStop&&5E3=this.processor.clipLevel&&(this.processor.clipping=!0,this.processor.lastClip=window.performance.now());g+=n*n;if(this.modifier){this.wrapper.contents[0]=n;var p=invoke(this.compiledModifier,this.wrapper,null,null,null,null,this.compilerProcess);for(n=0;ng)return this.pitch;for(l=g=1;lthis.GOOD_ENOUGH_CORRELATION&&c>g)h=!0,c>f&&(f=c,e=l);else if(h)return a=(m[e+1]-m[e-1])/m[e],b/(e+8*a);g=c}return.01=this.processor.clipLevel&&(this.processor.clipping=!0,this.processor.lastClip=window.performance.now());g+=n*n;if(this.modifier){this.wrapper.contents[0]=n;var p=invoke(this.compiledModifier,this.wrapper,null,null,null,null,this.compilerProcess);for(n=0;ng)return this.pitch;for(l=g=1;lthis.GOOD_ENOUGH_CORRELATION&&c>g)k=!0,c>f&&(f=c,e=l);else if(k)return a=(m[e+1]-m[e-1])/m[e],b/(e+8*a);g=c}return.01=this.processor.clipLevel&&(this.processor.clipping=!0,this.processor.lastClip=window.performance.now());g+=n*n;if(this.modifier){this.wrapper.contents[0]=n;var p=invoke(this.compiledModifier,this.wrapper,null,null,null,null,this.compilerProcess);for(n=0;ng)return this.pitch;for(l=g=1;lthis.GOOD_ENOUGH_CORRELATION&&c>g)h=!0,c>f&&(f=c,e=l);else if(h)return a=(m[e+1]-m[e-1])/m[e],b/(e+8*a);g=c}return.01=this.processor.clipLevel&&(this.processor.clipping=!0,this.processor.lastClip=window.performance.now());g+=n*n;if(this.modifier){this.wrapper.contents[0]=n;var p=invoke(this.compiledModifier,this.wrapper,null,null,null,null,this.compilerProcess);for(n=0;ng)return this.pitch;for(l=g=1;lthis.GOOD_ENOUGH_CORRELATION&&c>g)k=!0,c>f&&(f=c,e=l);else if(k)return a=(m[e+1]-m[e-1])/m[e],b/(e+8*a);g=c}return.01k instanceof WatcherMorph&&k.target===h&&k.getter===f);if(null!==m)m.show();else{m=new WatcherMorph(f+" "+localize("(temporary)"),SpriteMorph.prototype.blockColor.variables,h,f);m.setPosition(g.position().add(10));var l=g.watchers(m.left());0h instanceof WatcherMorph&&h.target===k&&h.getter===f);if(null!==m)m.show();else{m=new WatcherMorph(f+" "+localize("(temporary)"),SpriteMorph.prototype.blockColor.variables,k,f);m.setPosition(g.position().add(10));var l=g.watchers(m.left());0this.importData(!0),"import without attempting to\nparse or format data"),d&&(this.currentValue instanceof List&&this.currentValue.canBeCSV()&&e.addItem("export as CSV...",()=>{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.asCSV(),"text/csv;charset=utf-8",this.getter)},null,new Color(100,0,0)),this.currentValue instanceof List&&this.currentValue.canBeJSON()&&e.addItem("export as JSON...",()=> {this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.asJSON(!0),"text/json;charset=utf-8",this.getter)},null,new Color(100,0,0))),isString(this.currentValue)||!isNaN(+this.currentValue)?(d&&e.addItem("parse","parseTxt","try to convert\nraw data into a list",new Color(100,0,0)),e.addItem("export...",()=>{this.parentThatIsA(IDE_Morph).saveFileAs(this.currentValue.toString(),"text/plain;charset=utf-8",this.getter)})):this.currentValue instanceof List&&this.currentValue.canBeCSV()?e.addItem("export...", @@ -1835,8 +1835,8 @@ this,c=this.parentThatIsA(IDE_Morph),d=16===this.world().currentKey,e=new MenuMo this.currentValue instanceof List&&this.currentValue.canBeJSON()?e.addItem("export...",function(){b.parentThatIsA(IDE_Morph).saveFileAs(b.currentValue.asJSON(!0),"text/json;charset=utf-8",b.getter)}):this.currentValue instanceof Context?(d=this.currentValue.outerContext.variables.names(),d.length&&(e.addLine(),d.forEach(f=>a(f)))):this.currentValue instanceof Sound&&e.addItem("export...",function(){var f=b.parentThatIsA(IDE_Morph);this.currentValue.audio.src.includes("data:")?f.saveFileAs(b.currentValue.audio.src, "audio/wav",b.getter):f.saveFileAs(b.currentValue.audioBuffer,"audio/wav",b.getter)}),this.currentValue.blockify&&e.addItem("blockify",()=>{var f=c.world();this.currentValue.blockify().pickUp(f);f.hand.grabOrigin={origin:c.palette,position:c.palette.center()}}),e.addItem("hide...",function(){const f=b.parentThatIsA(IDE_Morph),g=b.getter;b.isTemporary()?b.destroy():f.stage.toggleVariableWatcher(g)})),e}; WatcherMorph.prototype.importData=function(a){var b=document.createElement("input"),c=this.parentThatIsA(IDE_Morph),d=this;c.filePicker&&(document.body.removeChild(c.filePicker),c.filePicker=null);b.type="file";b.style.color="transparent";b.style.backgroundColor="transparent";b.style.border="none";b.style.outline="none";b.style.position="absolute";b.style.top="0px";b.style.left="0px";b.style.width="0px";b.style.height="0px";b.style.display="none";b.addEventListener("change",function(){function e(g, -h){c.confirm(localize('Snap! can only import "text" files.\nYou selected a file of type "'+g+'".')+"\n\n"+localize("Open anyway?"),"Unable to import",h)}function f(g){function h(k,n){return-1!==k.type.indexOf(n)||l===n}var m=new FileReader,l=g.name.split(".").pop().toLowerCase();m.onloadend=function(k){!a&&h(g,"csv")?d.target.setVar(d.getter,Process.prototype.parseCSV(k.target.result)):!a&&h(g,"json")?d.target.setVar(d.getter,Process.prototype.parseJSON(k.target.result)):d.target.setVar(d.getter, -k.target.result)};a||-1!==g.type.indexOf("text")||contains(["txt","csv","xml","json","tsv"],l)?m.readAsText(g):e(g.type,()=>m.readAsText(g))}document.body.removeChild(b);c.filePicker=null;0m.readAsText(g))}document.body.removeChild(b);c.filePicker=null;0=b)return setTimeout(this.update.bind(this),100)}else{d=this.actions[this.actionIndex];if(!d||d.time<=b)return setTimeout(this.update.bind(this),100);e=this.getInverseEvent(d)}"openProject"=== e.type&&!e.replayType&&2>e.args.length&&(b=this.parentThatIsA(IDE_Morph),b=b.serializer.serialize(b.stage),0===e.args.length&&e.args.push(null),e.args.push(b));this.isApplyingAction=!0;e.isReplay=!0;this.actionIndex+=c;this.actionTime=d.time;this.applyEvent(e,function(){a.isApplyingAction=!1;a.isShowingCaptions&&a.displayCaption(e,d);setTimeout(a.update.bind(a),10)},c)}else setTimeout(this.update.bind(this),100)}; -ReplayControls.prototype.applyEvent=function(a,b,c){if(a.isUserAction)return b();var d=this,e=this.parentThatIsA(IDE_Morph);if(a.owner){var f=a.owner.split("/");var g=f[0];f=f[1];if(g=SnapActions.getOwnerFromId(g))e.selectSprite(g),e.spriteBar.tabBar.tabTo(f)}return SnapActions.applyEvent(a).then(b).catch(function(h){d.onReplayError(h,a,c);b()})}; +ReplayControls.prototype.applyEvent=function(a,b,c){if(a.isUserAction)return b();var d=this,e=this.parentThatIsA(IDE_Morph);if(a.owner){var f=a.owner.split("/");var g=f[0];f=f[1];if(g=SnapActions.getOwnerFromId(g))e.selectSprite(g),e.spriteBar.tabBar.tabTo(f)}return SnapActions.applyEvent(a).then(b).catch(function(k){d.onReplayError(k,a,c);b()})}; ReplayControls.prototype.onReplayError=function(a,b,c){c=1===c?"apply":"revert";var d=".";b&&(d=" "+localize("when trying to ")+b.type);a&&(d+=":\n\n"+a.message);d=localize("Something went wrong")+d+"\n\n"+localize("The error has been reported. Reloading the page is recommended.");this.pause();(new DialogBoxMorph).inform(localize("Could not "+c+" action"),d,this.world());console.error("Could not apply event: "+JSON.stringify(b,null,2));console.error(a)}; ReplayControls.prototype.getInverseEvent=function(a){if(a.replayType)for(var b=0,c,d=this.actionIndex;d--;){if(c=this.actions[d],c.replayType=c.replayType||0,c.owner===a.owner){if(a.replayType===c.replayType+1&&0===b)return this.actions[d];c.replayType===a.replayType?b--:b++}}else return b=SnapUndo.getInverseEvent(a),b.replayType=UndoManager.UNDO,b.owner=a.owner,b}; function XmlNote(a){this.src=a;this.initPitch=function(){if(0{setTimeout(()=>{a.switchToVector()})}):a.switchToVector()}));this.edits.fixLayout()}; PaintEditorMorph.prototype.buildScaleBox=function(){var a=this.paper;this.scaleBox.add(this.pushButton(new SymbolMorph("grow",18),function(){a.scale(.05,.05)},"grow"));this.scaleBox.add(this.pushButton(new SymbolMorph("shrink",18),function(){a.scale(-.05,-.05)},"shrink"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipHorizontal",18),function(){a.scale(-2,0)},"flip horizontal"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipVertical",18),function(){a.scale(0,-2)},"flip vertical")); this.scaleBox.fixLayout()}; PaintEditorMorph.prototype.openIn=function(a,b,c,d,e){var f=this;this.oldim=b;this.callback=d||nop;this.ide=e;this.processKeyUp=function(){f.shift=!1;f.propertiesControls.constrain.refresh()};this.processKeyDown=function(){f.shift=16===f.world().currentKey;f.propertiesControls.constrain.refresh()};this.oldim&&(this.paper.automaticCrosshairs=isNil(c),this.paper.centermerge(this.oldim,this.paper.paper),this.paper.rotationCenter=(c||new Point(0,0)).add(new Point((this.paper.paper.width-this.oldim.width)/ 2,(this.paper.paper.height-this.oldim.height)/2)),this.paper.drawNew());this.key="paint";this.popUp(a)};PaintEditorMorph.prototype.fixLayout=function(){this.changed();this.paper&&(this.paper.buildContents(),this.paper.drawNew());this.controls&&this.controls.fixLayout();this.body&&this.body.fixLayout();PaintEditorMorph.uber.fixLayout.call(this);this.changed()};PaintEditorMorph.prototype.refreshToolButtons=function(){this.toolbox.children.forEach(function(a){a.refresh()})}; PaintEditorMorph.prototype.ok=function(){this.paper.updateAutomaticCenter();this.callback(this.paper.paper,this.paper.rotationCenter);this.destroy()};PaintEditorMorph.prototype.cancel=function(){if(this.oncancel)this.oncancel();this.destroy()};PaintEditorMorph.prototype.switchToVector=function(){this.object=new SVG_Costume(new Image,"",new Point(0,0));this.object.edit(this.world(),this.ide,!0)}; -PaintEditorMorph.prototype.populatePropertiesMenu=function(){var a=this.controls,b=this,c=this.propertiesControls,d=new AlignmentMorph("row",this.padding),e=new AlignmentMorph("column",3);e.alignment="left";c.primaryColorViewer=new Morph;c.primaryColorViewer.isCachingImage=!0;c.primaryColorViewer.render=function(f){var g=b.paper.settings.primarycolor,h;if("transparent"===g)for(g=0;180>g;g+=5)for(h=0;15>h;h+=5)f.fillStyle=0===(h+g)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",f.fillRect(g,h,5,5); +PaintEditorMorph.prototype.populatePropertiesMenu=function(){var a=this.controls,b=this,c=this.propertiesControls,d=new AlignmentMorph("row",this.padding),e=new AlignmentMorph("column",3);e.alignment="left";c.primaryColorViewer=new Morph;c.primaryColorViewer.isCachingImage=!0;c.primaryColorViewer.render=function(f){var g=b.paper.settings.primarycolor,k;if("transparent"===g)for(g=0;180>g;g+=5)for(k=0;15>k;k+=5)f.fillStyle=0===(k+g)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",f.fillRect(g,k,5,5); else f.fillStyle=g.toString(),f.fillRect(0,0,180,15);f.strokeStyle="black";f.lineWidth=Math.min(b.paper.settings.linewidth,20);f.beginPath();f.lineCap="round";f.moveTo(20,30);f.lineTo(160,30);f.stroke()};c.primaryColorViewer.setExtent(new Point(180,40));c.primaryColorViewer.color=new Color(0,0,0);c.colorpicker=new PaintColorPickerMorph(new Point(180,100),function(f){b.paper.settings.primarycolor=f;c.primaryColorViewer.rerender()});c.colorpicker.isCachingImage=!0;c.colorpicker.action(new Color(0,0, 0));c.penSizeSlider=new SliderMorph(0,20,5,5);c.penSizeSlider.orientation="horizontal";c.penSizeSlider.setHeight(15);c.penSizeSlider.setWidth(150);c.penSizeSlider.action=function(f){c.penSizeField&&c.penSizeField.setContents(f);b.paper.settings.linewidth=f;c.colorpicker.action(b.paper.settings.primarycolor)};c.penSizeField=new InputFieldMorph("5",!0,null,!1);c.penSizeField.contents().minWidth=20;c.penSizeField.setWidth(25);c.penSizeField.accept=function(){var f=parseFloat(c.penSizeField.getValue()); c.penSizeSlider.value=f;c.penSizeSlider.updateValue();this.setContents(f);b.paper.settings.linewidth=f;this.world().keyboardFocus=b;c.colorpicker.action(b.paper.settings.primarycolor)};d.add(c.penSizeSlider);d.add(c.penSizeField);d.color=b.color;d.fixLayout();c.penSizeField.fixLayout();c.constrain=new ToggleMorph("checkbox",this,function(){b.shift=!b.shift},"Constrain proportions of shapes?\n(you can also hold shift)",function(){return b.shift});c.constrain.label.isBold=!1;a.add(c.colorpicker);a.add(c.primaryColorViewer); e.add(new StringMorph(localize("Brush size")+":",10,null,!0));e.add(d);e.add(c.constrain);e.fixLayout();a.add(e)};PaintEditorMorph.prototype.toolButton=function(a,b){var c=this;var d=new ToggleButtonMorph(null,this,function(){c.paper.currentTool=a;c.paper.toolChanged(a);c.refreshToolButtons();"pipette"===a&&c.getUserColor()},new SymbolMorph(a,18),function(){return c.paper.currentTool===a});d.hint=b;return d}; PaintEditorMorph.prototype.pushButton=function(a,b,c){return new PushButtonMorph(this,b,a,null,c)}; -PaintEditorMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=getDocumentPositionOf(b.worldCanvas),e=c.processMouseMove,f=c.processMouseDown,g=c.processMouseUp;c.processMouseMove=function(h){c.setPosition(new Point(h.pageX-d.x,h.pageY-d.y));h=b.getGlobalPixelColor(c.position());h.a&&(h.a=1,a.propertiesControls.colorpicker.action(h))};c.processMouseDown=nop;c.processMouseUp=function(){a.paper.currentTool="brush";a.paper.toolChanged("brush");a.refreshToolButtons();c.processMouseMove= +PaintEditorMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=getDocumentPositionOf(b.worldCanvas),e=c.processMouseMove,f=c.processMouseDown,g=c.processMouseUp;c.processMouseMove=function(k){c.setPosition(new Point(k.pageX-d.x,k.pageY-d.y));k=b.getGlobalPixelColor(c.position());k.a&&(k.a=1,a.propertiesControls.colorpicker.action(k))};c.processMouseDown=nop;c.processMouseUp=function(){a.paper.currentTool="brush";a.paper.toolChanged("brush");a.refreshToolButtons();c.processMouseMove= e;c.processMouseDown=f;c.processMouseUp=g}};PaintColorPickerMorph.prototype=new Morph;PaintColorPickerMorph.prototype.constructor=PaintColorPickerMorph;PaintColorPickerMorph.uber=Morph.prototype;function PaintColorPickerMorph(a,b){this.init(a,b)}PaintColorPickerMorph.prototype.init=function(a,b){this.isCachingImage=!0;this.setExtent(a||new Point(200,100));this.action=b||nop}; PaintColorPickerMorph.prototype.render=function(a){var b,c;for(b=0;b2*this.width()/3&&a.subtract(this.position()).y>this.height()-10?this.action("transparent"):this.action(this.getPixelColor(a))};PaintColorPickerMorph.prototype.mouseMove=PaintColorPickerMorph.prototype.mouseDownLeft;PaintCanvasMorph.prototype=new Morph; @@ -1926,56 +1926,56 @@ PaintCanvasMorph.prototype.cacheUndo=function(){var a=newCanvas(this.extent(),!0 PaintCanvasMorph.prototype.centermerge=function(a,b){b.getContext("2d").drawImage(a,(b.width-a.width)/2,(b.height-a.height)/2)};PaintCanvasMorph.prototype.clearCanvas=function(){this.buildContents();this.drawNew();this.changed()};PaintCanvasMorph.prototype.toolChanged=function(a){this.mask=newCanvas(this.extent(),!0,this.mask);"crosshairs"===a&&(this.updateAutomaticCenter(),this.drawcrosshair());this.drawNew();this.changed()}; PaintCanvasMorph.prototype.drawcrosshair=function(a){a=a||this.mask.getContext("2d");var b=this.rotationCenter;a.save();a.lineWidth=1;a.strokeStyle="black";a.clearRect(0,0,this.mask.width,this.mask.height);a.globalAlpha=.5;a.fillStyle="white";a.beginPath();a.arc(b.x,b.y,20,radians(0),radians(360),!1);a.closePath();a.fill();a.stroke();a.beginPath();a.arc(b.x,b.y,10,radians(0),radians(360),!1);a.stroke();a.beginPath();a.moveTo(0,b.y);a.lineTo(this.mask.width,b.y);a.stroke();a.beginPath();a.moveTo(b.x, 0);a.lineTo(b.x,this.mask.height);a.stroke();a.restore();this.drawNew()}; -PaintCanvasMorph.prototype.floodfill=function(a){var b=this.paper.width,c=this.paper.height,d=this.paper.getContext("2d"),e=d.getImageData(0,0,b,c),f=e.data;a=[Math.round(Math.round(a.y)*b+a.x)];var g=function(k){k*=4;return[f[k],f[k+1],f[k+2],f[k+3]]};var h=g(a[0]);var m=function(k){return k[0]===h[0]&&k[1]===h[1]&&k[2]===h[2]&&k[3]===h[3]};if(0!==h[3]||"transparent"!==this.settings.primarycolor)if(h[0]!==this.settings.primarycolor.r||h[1]!==this.settings.primarycolor.g||h[2]!==this.settings.primarycolor.b|| -h[3]!==255*this.settings.primarycolor.a)if(0!==h[3]||0!==this.settings.primarycolor.a){for(;0Math.abs(l)?d.lineTo(f,m):d.lineTo(h,g):d.lineTo(h, -m);d.stroke();break;case "circle":case "circleSolid":d.beginPath();if(this.isShiftPressed())d.arc(f,g,(new Point(f,g)).distanceTo(new Point(h,m)),0,2*Math.PI,!1);else{for(e=0;eMath.abs(l)?d.lineTo(f,m):d.lineTo(k,g):d.lineTo(k, +m);d.stroke();break;case "circle":case "circleSolid":d.beginPath();if(this.isShiftPressed())d.arc(f,g,(new Point(f,g)).distanceTo(new Point(k,m)),0,2*Math.PI,!1);else{for(e=0;eq.startsWith("netsblox=")))&&(k=k.split("=").pop(),this.auth=new c(k));return p}async fetchJson(k,n){return await (await this.fetch(k,n)).json()}async fetchText(k,n){return await (await this.fetch(k,n)).text()}async post(k,n){const p={method:"post"};void 0!== -n&&(p.body=JSON.stringify(n));return await this.fetchJson(k,p)}}const e=k=>k,f="undefined"===typeof window;var g;(function(k){k.Created="Created";k.Saved="Saved";k.Transient="Transient";k.Broken="Broken"})(g||={});var h;(function(k){k.Private="Private";k.Public="Public";k.PendingApproval="PendingApproval";k.ApprovalDenied="ApprovalDenied"})(h||={});class m{constructor(k,n,p,q=e){this.clientId=n;this.username=p;this.roleId=this.projectId=null;this.url=k;this.token=null;this.localize=q;this.api=new d(this.url)}clear(){this.token= -this.username=null}hasProtocol(){return 0===this.url.toLowerCase().indexOf("http")}async resetPassword(k){return await (await this.fetch(`/users/${k}/password`,{method:"POST"})).text()}async login(k,n,p,q="NetsBlox"){p={};p[q]={username:k,password:n};k=await this.post("/users/login",{credentials:p,clientId:this.clientId});this.username=(await k.json()).username;if(f){k=k.headers.get("set-cookie");if(!k)throw new l("No cookie received");this.token=k.split("=")[1].split(";").shift()}return this.username}async getProjectList(){return await (await this.fetch(`/projects/user/${this.username}`)).json()}async getSharedProjectList(){return await (await this.fetch(`/projects/shared/${this.username}`)).json()}async changePassword(k, -n){k=JSON.stringify(n);return await (await this.fetch(`/users/${this.username}/password`,{method:"PATCH",body:k})).text()}parseResponse(k){var n=[];if(!k)return n;k.split(" ").forEach(function(p){var q={};p.split("&").forEach(function(r){var t=r.split("=");r=decodeURIComponent(t[0]);t=decodeURIComponent(t[1]);q[r]=t});n.push(q)});return n}parseDict(k){var n={};if(!k)return n;k.split("&").forEach(function(p){var q=p.split("=");p=decodeURIComponent(q[0]);q=decodeURIComponent(q[1]);n[p]=q});return n}encodeDict(k){var n= -"",p;if(!k)return null;for(p in k)if(k.hasOwnProperty(p)){var q=encodeURIComponent(p)+"="+encodeURIComponent(k[p]);0p.json()).then(async p=>{const [q]=Object.keys(p.roles);this.setClientState(p.id,q);n.newProjectRequest= -null;return p}).catch(function(p){n.resetLocalState();n.newProjectRequest=null;throw Error(p.responseText);}));return this.newProjectRequest}getClientState(){return{username:this.username,clientId:this.clientId,projectId:this.projectId,roleId:this.roleId}}async setClientState(k=this.projectId,n=this.roleId){var p=this.newProjectRequest||Promise.resolve();this.projectId=k;this.roleId=n;return p.then(async()=>{await this.post(`/network/${this.clientId}/state`,{state:{browser:{projectId:this.projectId, -roleId:this.roleId}}})})}setProjectName(k){return(this.newProjectRequest||Promise.resolve()).then(async()=>{await this.patch(`/projects/id/${this.projectId}`,{name:k,clientId:this.clientId})})}async importProject(k){k.clientId=this.clientId;return await (await this.post("/projects/",k)).json()}async linkAccount(k,n,p){await this.post(`/users/${this.username}/link/`,{Snap:{username:k,password:n}})}async unlinkAccount(k){await this.post(`/users/${this.username}/unlink`,k)}async getProjectData(k=this.projectId){return await (await this.fetch(`/projects/id/${k}/latest?clientId=${this.clientId}`)).json()}async exportRole(k= -this.projectId,n=this.roleId){return await (await this.fetch(`/projects/id/${k}/${n}/latest?clientId=${this.clientId}`)).text()}async viewUser(k=this.username){return await (await this.fetch(`/users/${k}`)).json()}async whoAmI(){return await (await this.get("/users/whoami")).text()}async getCommunityLibraryList(){return await (await this.get("/libraries/community/")).json()}async getLibraryList(){return await (await this.get(`/libraries/user/${this.username}/`)).json()}async saveLibrary(k,n,p){return await (await this.post(`/libraries/user/${this.username}/`, -{name:k,notes:p,blocks:n})).json()}async getLibrary(k,n){n=encodeURIComponent(n);return await (await this.get(`/libraries/user/${k}/${n}`)).text()}async deleteLibrary(k){k=encodeURIComponent(k);return await this.delete(`/libraries/user/${this.username}/${k}`)}async publishLibrary(k){k=encodeURIComponent(k);return await (await this.post(`/libraries/user/${this.username}/${k}/publish`)).json()}async unpublishLibrary(k){k=encodeURIComponent(k);await this.post(`/libraries/user/${this.username}/${k}/unpublish`)}message(k){alert(k)}async register(k, -n){return this.signup(k,void 0,n)}async checkLogin(){try{return await this.whoAmI(),!0}catch(k){return!1}}async getProfile(){return await this.viewUser()}}class l extends Error{constructor(k,n){super(n||k);this.label=k}}return m});modules.gui="2021-November-27";var SERVER_URL=SERVER_URL||window.location.origin,SERVER_ADDRESS=SERVER_URL.replace(/^.*\/\//,"");function ensureFullUrl(a){null===a.match(/^\w+:\/\//)&&(a="/"===a.substring(0,1)[0]?SERVER_URL+a:SERVER_URL+"/"+a);return a} +(function(a,b){"object"===typeof exports&&"undefined"!==typeof module?module.exports=b():"function"===typeof define&&define.amd?define(b):(a="undefined"!==typeof globalThis?globalThis:a||self,a.Cloud=b())})(this,function(){class a extends Error{static async from(h){var n=await h.text()||h.statusText||"An unknown error occurred. Please try again later.";n=new a(n);n.status=h.status;return n}}class b extends a{constructor(h){super(`Unable to connect to ${h}`)}}class c{constructor(h){this.token=h}inject(h){h.headers= +h.headers||{};h.headers.cookie=`netsblox=${this.token}`}}class d{constructor(h,n){this.baseUrl=h;this.auth=n}async listUsers(){return await this.fetchJson("/users/")}async createUser(h){return await this.post("/users/create",h)}async forgotUsername(h){h={method:"post",body:JSON.stringify(h)};await this.fetch("/users/forgot-username",h)}async login(h){return await this.post("/users/login",h)}async logout(h){let n="/users/logout";h&&(n+=`?clientId=${encodeURIComponent(h)}`);return await this.post(n)}async whoami(){return await this.fetchText("/users/whoami")}async banUser(h){return await this.post(`/users/${encodeURIComponent(h)}/ban`)}async unbanUser(h){return await this.post(`/users/${encodeURIComponent(h)}/unban`)}async deleteUser(h){return await this.post(`/users/${encodeURIComponent(h)}/delete`)}async resetPassword(h){await this.fetch(`/users/${encodeURIComponent(h)}/password`, +{method:"post"})}async setPassword(h,n){n={method:"PATCH",body:JSON.stringify(n)};return await this.fetchJson(`/users/${encodeURIComponent(h)}/password`,n)}async viewUser(h){return await this.fetchJson(`/users/${encodeURIComponent(h)}`)}async linkAccount(h,n){return await this.post(`/users/${encodeURIComponent(h)}/link`,n)}async unlinkAccount(h,n){return await this.post(`/users/${encodeURIComponent(h)}/unlink`,n)}async sendMagicLink(h){h={method:"post",body:JSON.stringify(h)};await this.fetch("/magic-links/", +h)}async listFriends(h){return await this.fetchJson(`/friends/${encodeURIComponent(h)}/`)}async listOnlineFriends(h){return await this.fetchJson(`/friends/${encodeURIComponent(h)}/online`)}async unfriend(h,n){return await this.post(`/friends/${encodeURIComponent(h)}/unfriend/${encodeURIComponent(n)}`)}async block(h,n){return await this.post(`/friends/${encodeURIComponent(h)}/block/${encodeURIComponent(n)}`)}async unblock(h,n){return await this.post(`/friends/${encodeURIComponent(h)}/unblock/${encodeURIComponent(n)}`)}async listFriendInvites(h){return await this.fetchJson(`/friends/${encodeURIComponent(h)}/invites/`)}async sendFriendInvite(h, +n){return await this.post(`/friends/${encodeURIComponent(h)}/invite/`,n)}async respondToFriendInvite(h,n,p){return await this.post(`/friends/${encodeURIComponent(h)}/invites/${encodeURIComponent(n)}`,p)}async listGroups(h){return await this.fetchJson(`/groups/user/${encodeURIComponent(h)}/`)}async createGroup(h,n){return await this.post(`/groups/user/${encodeURIComponent(h)}/`,n)}async updateGroup(h,n){n={method:"patch",body:JSON.stringify(n)};return await this.fetchJson(`/groups/id/${encodeURIComponent(h)}`, +n)}async viewGroup(h){return await this.fetchJson(`/groups/id/${encodeURIComponent(h)}`)}async deleteGroup(h){return await this.fetchJson(`/groups/id/${encodeURIComponent(h)}`,{method:"delete"})}async listMembers(h){return await this.fetchJson(`/groups/id/${encodeURIComponent(h)}/members`)}async createProject(h){h={method:"post",body:JSON.stringify(h)};return await this.fetchJson("/projects/",h)}async listSharedProjects(h){return await this.fetchJson(`/projects/shared/${h}`)}async listUserProjects(h){return await this.fetchJson(`/projects/user/${h}`)}async listPublicProjects(){return await this.fetchJson("/projects/public/")}async getProjectNamed(h, +n){return await this.fetchJson(`/projects/user/${h}/${n}`)}async getProjectNamedXml(h,n){return await this.fetchText(`/projects/user/${h}/${n}/xml`)}async getProjectThumbnail(h,n){h=this.getProjectThumbnailPath(h,n);return await this.fetch(h)}getProjectThumbnailPath(h,n){h=`/projects/id/${h}/thumbnail`;n&&(h+=`?aspectRatio=${n}`);return h}getProjectThumbnailUrl(h,n){return this.baseUrl+this.getProjectThumbnailPath(h,n)}async getProjectNamedMetadata(h,n){return await this.fetchJson(`/projects/user/${h}/${n}/metadata`)}async updateProject(h, +n){n={method:"patch",body:JSON.stringify(n)};return await this.fetchJson(`/projects/id/${h}`,n)}async deleteProject(h){return await this.fetchJson(`/projects/id/${h}`,{method:"delete"})}async getProject(h){return await this.fetchJson(`/projects/id/${h}`)}async getLatestProject(h){return await this.fetchJson(`/projects/id/${h}/latest`)}async getProjectMetadata(h){return await this.fetchJson(`/projects/id/${h}/metadata`)}async getProjectXml(h){return await this.fetchText(`/projects/id/${h}/xml`)}async publishProject(h){return await this.post(`/projects/id/${h}/publish`)}async unpublishProject(h){return await this.post(`/projects/id/${h}/unpublish`)}async listPendingProjects(){return await this.fetchJson("/projects/mod/pending/")}async setProjectState(h, +n){n={method:"post",body:JSON.stringify(n)};return await this.fetchJson(`/projects/mod/id/${h}`,n)}async createRole(h,n){n={method:"post",body:JSON.stringify(n)};return await this.fetchJson(`/projects/id/${h}/`,n)}async saveRole(h,n,p){p={method:"post",body:JSON.stringify(p)};return await this.fetchJson(`/projects/id/${h}/${n}`,p)}async renameRole(h,n,p){p={method:"patch",body:JSON.stringify(p)};return await this.fetchJson(`/projects/id/${h}/${n}`,p)}async getRole(h,n){return await this.fetchJson(`/projects/id/${h}/${n}`)}async getLatestRole(h, +n){return await this.fetchJson(`/projects/id/${h}/${n}/latest`)}async deleteRole(h,n){return await this.fetchJson(`/projects/id/${h}/${n}`,{method:"delete"})}async listCollaborationInvites(h){return await this.fetchJson(`/collaboration-invites/user/${h}/`)}async inviteCollaborator(h,n){return await this.fetchJson(`/collaboration-invites/${h}/invite/${n}`,{method:"post"})}async respondToCollaborationInvite(h,n){n={method:"post",body:JSON.stringify(n)};return await this.fetchJson(`/collaboration-invites/id/${h}`, +n)}async listCollaborators(h){return await this.fetchJson(`/projects/id/${h}/collaborators/`)}async removeCollaborator(h,n){return await this.fetchJson(`/projects/id/${h}/collaborators/${n}`,{method:"delete"})}async listCommunityLibraries(){return await this.fetchJson("/libraries/community/")}async listUserLibraries(h){return await this.fetchJson(`/libraries/user/${encodeURIComponent(h)}/`)}async getUserLibrary(h,n){return await this.fetchText(`/libraries/user/${encodeURIComponent(h)}/${encodeURIComponent(n)}`)}async saveUserLibrary(h, +n){return await this.post(`/libraries/user/${encodeURIComponent(h)}/`,n)}async deleteUserLibrary(h,n){return await this.fetchJson(`/libraries/user/${encodeURIComponent(h)}/${encodeURIComponent(n)}`,{method:"delete"})}async publishLibrary(h,n){return await this.post(`/libraries/user/${encodeURIComponent(h)}/${encodeURIComponent(n)}/publish`)}async unpublishLibrary(h,n){return await this.post(`/libraries/user/${encodeURIComponent(h)}/${encodeURIComponent(n)}/unpublish`)}async listPendingLibraries(){return await this.fetchJson("/libraries/mod/pending")}async setLibraryState(h, +n,p){return await this.post(`/libraries/mod/${encodeURIComponent(h)}/${encodeURIComponent(n)}`,p)}async setClientState(h,n){n={method:"post",body:JSON.stringify(n)};return await this.fetchText(`/network/${encodeURIComponent(h)}/state`,n)}async getClientState(h){return await this.fetchJson(`/network/${h}/state`)}async getRoomState(h){return await this.fetchJson(`/network/id/${h}`)}async getRooms(){return await this.fetchJson("/network/")}async getExternalClients(){return await this.fetchJson("/network/external")}async inviteOccupant(h, +n){return await this.post(`/network/id/${h}/occupants/invite`,n)}async evictOccupant(h){return await this.post(`/network/clients/${h}/evict`)}async startNetworkTrace(h){return await this.post(`/network/id/${h}/trace/`)}async stopNetworkTrace(h,n){return await this.post(`/network/id/${h}/trace/${n}/stop`)}async getNetworkTraceMetadata(h,n){return await this.fetchJson(`/network/id/${h}/trace/${n}`)}async getNetworkTrace(h,n){return await this.fetchJson(`/network/id/${h}/trace/${n}/messages`)}async deleteNetworkTrace(h, +n){return await this.fetchJson(`/network/id/${h}/trace/${n}`,{method:"delete"})}async sendMessage(h){await this.post("/network/messages/",h)}async listGroupHosts(h){return await this.fetchJson(`/services/hosts/group/${h}`)}async setGroupHosts(h,n){return await this.post(`/services/hosts/group/${h}`,n)}async listUserHosts(h){return await this.fetchJson(`/services/hosts/user/${h}`)}async setUserHosts(h,n){return await this.post(`/services/hosts/user/${h}`,n)}async listAllHosts(h){return await this.fetchJson(`/services/hosts/all/${h}`)}async getAuthorizedHosts(){return await this.fetchJson("/services/hosts/authorized/")}async authorizedHost(h){return await this.post("/services/hosts/authorized/", +h)}async unauthorizedHost(h){return await this.fetchJson(`/services/hosts/authorized/${h}`,{method:"delete"})}async listUserHostsWithSettings(h){return await this.fetchJson(`/services/settings/user/${h}/`)}async getUserSettings(h,n){return await this.fetchJson(`/services/settings/user/${h}/${n}`)}async setUserSettings(h,n,p){await this.fetch(`/services/settings/user/${h}/${n}`,{method:"post",body:p})}async deleteUserSettings(h,n){await this.fetch(`/services/settings/user/${h}/${n}`,{method:"delete"})}async listGroupHostsWithSettings(h){return await this.fetchJson(`/services/settings/group/${h}/`)}async getGroupSettings(h, +n){return await this.fetchJson(`/services/settings/group/${h}/${n}`)}async setGroupSettings(h,n,p){await this.fetch(`/services/settings/group/${h}/${n}`,{method:"post",body:p})}async deleteGroupSettings(h,n){await this.fetch(`/services/settings/group/${h}/${n}`,{method:"delete"})}async getAllSettings(h,n){return await this.fetchJson(`/services/settings/user/${h}/${n}/all`)}async fetch(h,n){n=n||{};h=this.baseUrl+h;n.credentials=n.credentials||"include";n.headers={"Content-Type":"application/json"}; +this.auth&&this.auth.inject(n);n.method=n.method?n.method.toUpperCase():"GET";let p;try{p=await fetch(h,n)}catch(q){throw new b(h);}if(!p.ok)throw await a.from(p);p.headers.get("set-cookie")&&(h=p.headers.get("set-cookie").split(";").find(q=>q.startsWith("netsblox=")))&&(h=h.split("=").pop(),this.auth=new c(h));return p}async fetchJson(h,n){return await (await this.fetch(h,n)).json()}async fetchText(h,n){return await (await this.fetch(h,n)).text()}async post(h,n){const p={method:"post"};void 0!== +n&&(p.body=JSON.stringify(n));return await this.fetchJson(h,p)}}const e=h=>h,f="undefined"===typeof window;var g;(function(h){h.Created="Created";h.Saved="Saved";h.Transient="Transient";h.Broken="Broken"})(g||={});var k;(function(h){h.Private="Private";h.Public="Public";h.PendingApproval="PendingApproval";h.ApprovalDenied="ApprovalDenied"})(k||={});class m{constructor(h,n,p,q=e){this.clientId=n;this.username=p;this.roleId=this.projectId=null;this.url=h;this.token=null;this.localize=q;this.api=new d(this.url)}clear(){this.token= +this.username=null}hasProtocol(){return 0===this.url.toLowerCase().indexOf("http")}async resetPassword(h){return await (await this.fetch(`/users/${h}/password`,{method:"POST"})).text()}async login(h,n,p,q="NetsBlox"){p={};p[q]={username:h,password:n};h=await this.post("/users/login",{credentials:p,clientId:this.clientId});this.username=(await h.json()).username;if(f){h=h.headers.get("set-cookie");if(!h)throw new l("No cookie received");this.token=h.split("=")[1].split(";").shift()}return this.username}async getProjectList(){return await (await this.fetch(`/projects/user/${this.username}`)).json()}async getSharedProjectList(){return await (await this.fetch(`/projects/shared/${this.username}`)).json()}async changePassword(h, +n){h=JSON.stringify(n);return await (await this.fetch(`/users/${this.username}/password`,{method:"PATCH",body:h})).text()}parseResponse(h){var n=[];if(!h)return n;h.split(" ").forEach(function(p){var q={};p.split("&").forEach(function(r){var t=r.split("=");r=decodeURIComponent(t[0]);t=decodeURIComponent(t[1]);q[r]=t});n.push(q)});return n}parseDict(h){var n={};if(!h)return n;h.split("&").forEach(function(p){var q=p.split("=");p=decodeURIComponent(q[0]);q=decodeURIComponent(q[1]);n[p]=q});return n}encodeDict(h){var n= +"",p;if(!h)return null;for(p in h)if(h.hasOwnProperty(p)){var q=encodeURIComponent(p)+"="+encodeURIComponent(h[p]);0p.json()).then(async p=>{const [q]=Object.keys(p.roles);this.setClientState(p.id,q);n.newProjectRequest= +null;return p}).catch(function(p){n.resetLocalState();n.newProjectRequest=null;throw Error(p.responseText);}));return this.newProjectRequest}getClientState(){return{username:this.username,clientId:this.clientId,projectId:this.projectId,roleId:this.roleId}}async setClientState(h=this.projectId,n=this.roleId){var p=this.newProjectRequest||Promise.resolve();this.projectId=h;this.roleId=n;return p.then(async()=>{await this.post(`/network/${this.clientId}/state`,{state:{browser:{projectId:this.projectId, +roleId:this.roleId}}})})}setProjectName(h){return(this.newProjectRequest||Promise.resolve()).then(async()=>{await this.patch(`/projects/id/${this.projectId}`,{name:h,clientId:this.clientId})})}async importProject(h){h.clientId=this.clientId;return await (await this.post("/projects/",h)).json()}async linkAccount(h,n,p){await this.post(`/users/${this.username}/link/`,{Snap:{username:h,password:n}})}async unlinkAccount(h){await this.post(`/users/${this.username}/unlink`,h)}async getProjectData(h=this.projectId){return await (await this.fetch(`/projects/id/${h}/latest?clientId=${this.clientId}`)).json()}async exportRole(h= +this.projectId,n=this.roleId){return await (await this.fetch(`/projects/id/${h}/${n}/latest?clientId=${this.clientId}`)).text()}async viewUser(h=this.username){return await (await this.fetch(`/users/${h}`)).json()}async whoAmI(){return await (await this.get("/users/whoami")).text()}async getCommunityLibraryList(){return await (await this.get("/libraries/community/")).json()}async getLibraryList(){return await (await this.get(`/libraries/user/${this.username}/`)).json()}async saveLibrary(h,n,p){return await (await this.post(`/libraries/user/${this.username}/`, +{name:h,notes:p,blocks:n})).json()}async getLibrary(h,n){n=encodeURIComponent(n);return await (await this.get(`/libraries/user/${h}/${n}`)).text()}async deleteLibrary(h){h=encodeURIComponent(h);return await this.delete(`/libraries/user/${this.username}/${h}`)}async publishLibrary(h){h=encodeURIComponent(h);return await (await this.post(`/libraries/user/${this.username}/${h}/publish`)).json()}async unpublishLibrary(h){h=encodeURIComponent(h);await this.post(`/libraries/user/${this.username}/${h}/unpublish`)}message(h){alert(h)}async register(h, +n){return this.signup(h,void 0,n)}async checkLogin(){try{return await this.whoAmI(),!0}catch(h){return!1}}async getProfile(){return await this.viewUser()}}class l extends Error{constructor(h,n){super(n||h);this.label=h}}return m});modules.gui="2021-November-27";var SERVER_URL=SERVER_URL||window.location.origin,SERVER_ADDRESS=SERVER_URL.replace(/^.*\/\//,"");function ensureFullUrl(a){null===a.match(/^\w+:\/\//)&&(a="/"===a.substring(0,1)[0]?SERVER_URL+a:SERVER_URL+"/"+a);return a} var SPEECH_RECOGNIZER=void 0,SPEECH_RECOGNIZER_REQUESTS=[],SPEECH_RECOGNIZER_RESULT="",SPEECH_RECOGNIZER_PROMPT=void 0;function getSpeechClass(){return window.SpeechRecognition||window.webkitSpeechRecognition} async function getSpeech(){const a=getSpeechClass();if(!a)throw Error("this browser does not support speech recognition");SPEECH_RECOGNIZER||(SPEECH_RECOGNIZER=new a,SPEECH_RECOGNIZER.continuous=!1,SPEECH_RECOGNIZER.lang="en-US",SPEECH_RECOGNIZER.interimResults=!1,SPEECH_RECOGNIZER.maxAlternatives=1,SPEECH_RECOGNIZER.onstart=b=>{SPEECH_RECOGNIZER_RESULT="";SPEECH_RECOGNIZER_PROMPT=world.children[0].showMessage("Listening for speech")},SPEECH_RECOGNIZER.onresult=b=>{SPEECH_RECOGNIZER_RESULT=((b.results|| [])[0]||[])[0]?.transcript||""},SPEECH_RECOGNIZER.onend=b=>{SPEECH_RECOGNIZER_PROMPT.destroy();b=SPEECH_RECOGNIZER_REQUESTS;SPEECH_RECOGNIZER_REQUESTS=[];for(const c of b)c(SPEECH_RECOGNIZER_RESULT)});return await new Promise((b,c)=>{SPEECH_RECOGNIZER_REQUESTS.push(b);try{SPEECH_RECOGNIZER.start()}catch(d){}})}IDE_Morph.prototype=new Morph;IDE_Morph.prototype.constructor=IDE_Morph;IDE_Morph.uber=Morph.prototype; @@ -2004,22 +2004,22 @@ IDE_Morph.prototype.createControlBar=function(){var a,b=MorphicPreferences.isFla 14),new SymbolMorph("normalStage",14)],()=>this.isSmallStage);d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=MorphicPreferences.isFlat?WHITE:this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var e=d;this.controlBar.add(e);this.controlBar.stageSizeButton=d;d=new ToggleButtonMorph(null,this,"toggleAppMode",[new SymbolMorph("fullScreen", 14),new SymbolMorph("normalScreen",14)],()=>this.isAppMode);d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var f=d;this.controlBar.add(f);this.controlBar.appModeButton=f;d=new ToggleButtonMorph(null,this,"toggleSingleStepping",[new SymbolMorph("footprints",16), new SymbolMorph("footprints",16)],()=>Process.prototype.enableSingleStepping);d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=new Color(153,255,213);d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.hint="Visible stepping";d.fixLayout();d.refresh();var g=d;this.controlBar.add(g);this.controlBar.steppingButton=g;this.performerMode&&(f.hide(),e.hide());d=new ToggleButtonMorph(null, -this,"stopAllScripts",[new SymbolMorph("octagon",14),new SymbolMorph("square",14)],()=>this.stage?c.stage.enableCustomHatBlocks&&c.stage.threads.pauseCustomHatBlocks:!0);d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=new Color(MorphicPreferences.isFlat?128:200,0,0);d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var h=d;this.controlBar.add(h);this.controlBar.stopButton= -h;d=new ToggleButtonMorph(null,this,"togglePauseResume",[new SymbolMorph("pause",12),new SymbolMorph("pointRight",14)],()=>this.isPaused());d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=MorphicPreferences.isFlat?new Color(220,185,0):new Color(255,220,0);d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var m=d;this.controlBar.add(m); -this.controlBar.pauseButton=m;d=new PushButtonMorph(this,"pressStart",new SymbolMorph("flag",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=new Color(0,MorphicPreferences.isFlat?100:200,0);d.contrast=this.buttonContrast;d.fixLayout();var l=d;this.controlBar.add(l);this.controlBar.startButton=l;var k=new SliderMorph(61,1,100*Process.prototype.flashTime+1,6, -"horizontal");k.action=t=>{Process.prototype.flashTime=(t-1)/100;this.controlBar.refreshResumeSymbol()};k.color=new Color(153,255,213);k.alpha=.3;k.setExtent(new Point(50,14));this.controlBar.add(k);this.controlBar.steppingSlider=k;d=new PushButtonMorph(this,function(){var t=c.projectMenu(),u=c.controlBar.projectButton.bottomLeft(),v=c.world();t.popup(v,u)},new SymbolMorph("file",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset= +this,"stopAllScripts",[new SymbolMorph("octagon",14),new SymbolMorph("square",14)],()=>this.stage?c.stage.enableCustomHatBlocks&&c.stage.threads.pauseCustomHatBlocks:!0);d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=new Color(MorphicPreferences.isFlat?128:200,0,0);d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var k=d;this.controlBar.add(k);this.controlBar.stopButton= +k;d=new ToggleButtonMorph(null,this,"togglePauseResume",[new SymbolMorph("pause",12),new SymbolMorph("pointRight",14)],()=>this.isPaused());d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=MorphicPreferences.isFlat?new Color(220,185,0):new Color(255,220,0);d.contrast=this.buttonContrast;d.fixLayout();d.refresh();var m=d;this.controlBar.add(m); +this.controlBar.pauseButton=m;d=new PushButtonMorph(this,"pressStart",new SymbolMorph("flag",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=new Color(0,MorphicPreferences.isFlat?100:200,0);d.contrast=this.buttonContrast;d.fixLayout();var l=d;this.controlBar.add(l);this.controlBar.startButton=l;var h=new SliderMorph(61,1,100*Process.prototype.flashTime+1,6, +"horizontal");h.action=t=>{Process.prototype.flashTime=(t-1)/100;this.controlBar.refreshResumeSymbol()};h.color=new Color(153,255,213);h.alpha=.3;h.setExtent(new Point(50,14));this.controlBar.add(h);this.controlBar.steppingSlider=h;d=new PushButtonMorph(this,function(){var t=c.projectMenu(),u=c.controlBar.projectButton.bottomLeft(),v=c.world();t.popup(v,u)},new SymbolMorph("file",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset= new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var n=d;this.controlBar.add(n);this.controlBar.projectButton=n;d=new PushButtonMorph(this,function(){var t=c.settingsMenu(),u=c.controlBar.settingsButton.bottomLeft();t.popup(c.world(),u)},new SymbolMorph("gears",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor= b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var p=d;this.controlBar.add(p);this.controlBar.settingsButton=p;d=new PushButtonMorph(this,function(){var t=c.extensionsMenu(),u=c.controlBar.extensionsButton.bottomLeft();t.popup(c.world(),u)},new SymbolMorph("puzzlePiece",14));d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[2];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor; -d.contrast=this.buttonContrast;d.fixLayout();const q=d;this.controlBar.add(q);this.controlBar.extensionsButton=q;this.controlBar.extensionsButton.hide();d=new ToggleButtonMorph(null,this,async()=>{var t=await this.cloudMenu(),u=this.controlBar.cloudButton.bottomLeft();t.popup(this.world(),u)},[new SymbolMorph("cloudOutline",11),new SymbolMorph("cloud",11)],()=>!isNil(this.cloud.username));d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36, -18);d.padding=0;d.labelShadowOffset=new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var r=d;this.controlBar.add(r);this.controlBar.cloudButton=r;this.controlBar.fixLayout=function(){a=this.right()-5;[h,m,l].forEach(t=>{t.setCenter(c.controlBar.center());t.setRight(a);a-=t.width();a-=5});a=Math.min(l.left()-(15+2*e.width()),c.right()-StageMorph.prototype.dimensions.x*(c.isSmallStage?c.stageRatio:1));[e,f].forEach(t=>{a+=5;t.setCenter(c.controlBar.center()); -t.setLeft(a);a+=t.width()});k.setCenter(c.controlBar.center());c.performerMode?k.setRight(l.left()-5):k.setRight(e.left()-5);g.setCenter(c.controlBar.center());g.setRight(k.left()-5);q.setCenter(c.controlBar.center());q.setRight(g.left()-5);p.setCenter(c.controlBar.center());p.setLeft(this.left());r.setCenter(c.controlBar.center());r.setRight(p.left()-5);n.setCenter(c.controlBar.center());n.setRight(r.left()-5);this.refreshSlider();this.updateLabel()};this.controlBar.refreshSlider=function(){Process.prototype.enableSingleStepping&& -!c.isAppMode?(k.fixLayout(),k.rerender(),k.show()):k.hide();this.refreshResumeSymbol()};this.controlBar.refreshResumeSymbol=function(){if(Process.prototype.enableSingleStepping&&.5{var t=await this.cloudMenu(),u=this.controlBar.cloudButton.bottomLeft();t.popup(this.world(),u)},[new SymbolMorph("cloudOutline",11),new SymbolMorph("cloud",11)],()=>!isNil(this.cloud.username));d.hasNeutralBackground=!0;d.corner=12;d.color=b[0];d.highlightColor=b[1];d.pressColor=b[0];d.labelMinExtent=new Point(36,18);d.padding=0;d.labelShadowOffset= +new Point(-1,-1);d.labelShadowColor=b[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.fixLayout();var r=d;this.controlBar.add(r);this.controlBar.cloudButton=r;this.controlBar.fixLayout=function(){a=this.right()-5;[k,m,l].forEach(t=>{t.setCenter(c.controlBar.center());t.setRight(a);a-=t.width();a-=5});a=Math.min(l.left()-(15+2*e.width()),c.right()-StageMorph.prototype.dimensions.x*(c.isSmallStage?c.stageRatio:1));[e,f].forEach(t=>{a+=5;t.setCenter(c.controlBar.center());t.setLeft(a); +a+=t.width()});h.setCenter(c.controlBar.center());c.performerMode?h.setRight(l.left()-5):h.setRight(e.left()-5);g.setCenter(c.controlBar.center());g.setRight(h.left()-5);q.setCenter(c.controlBar.center());q.setRight(g.left()-5);p.setCenter(c.controlBar.center());p.setLeft(this.left());r.setCenter(c.controlBar.center());r.setRight(p.left()-5);n.setCenter(c.controlBar.center());n.setRight(r.left()-5);this.refreshSlider();this.updateLabel()};this.controlBar.refreshSlider=function(){Process.prototype.enableSingleStepping&& +!c.isAppMode?(h.fixLayout(),h.rerender(),h.show()):h.hide();this.refreshResumeSymbol()};this.controlBar.refreshResumeSymbol=function(){if(Process.prototype.enableSingleStepping&&.5{b.currentCategory=c;b.categories.children.forEach(f=>f.refresh());b.refreshPalette(!0)},c[0].toUpperCase().concat(c.slice(1)),()=>b.currentCategory===c,null,null,75,!0);e.userMenu=function(){if(!(16!==world.currentKey||1>=b.categories.children.length)){var f=new MenuMorph(b);f.addItem("hide category", function(){this.hideCategory(c)},null,new Color(100,0,0));return f}};e.corner=8;e.padding=0;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=d[1];e.labelColor=b.buttonLabelColor;MorphicPreferences.isFlat&&(e.labelPressColor=WHITE);e.fixLayout();e.refresh();b.categories.add(e);return e}var b=this;this.categories&&this.categories.destroy();contains(this.hiddenCategories,this.currentCategory)&&(this.currentCategory=SpriteMorph.prototype.categories.find(function(c){return!contains(["lists","other"], c)&&!contains(b.hiddenCategories,c)}),this.createPalette());this.categories=new Morph;this.categories.color=this.groupColor;this.categories.bounds.setWidth(this.paletteWidth);this.categories.userMenu=function(){if(!(16!==world.currentKey||0>=b.hiddenCategories.length)){var c=new MenuMorph(b);c.addItem("show hidden categories","showHiddenCategories",null,new Color(100,0,0));return c}};SpriteMorph.prototype.categories.forEach(c=>{contains(["lists","other"],c)||contains(b.hiddenCategories,c)||a(c)}); -(function(){var c=b.categories.children[0].width(),d=b.categories.children[0].height(),e=Math.ceil(b.categories.children.length/2),f=(197-2*c)/3,g=b.categories.left(),h=b.categories.top(),m=0,l,k;b.categories.children.forEach(n=>{m+=1;l=Math.ceil(m/2);k=2-m%2;n.setPosition(new Point(g+(k*f+(k-1)*c),h+(2*l+(l-1)*d+3)))});b.categories.setHeight(2*(e+1)+e*d+6)})();this.add(this.categories)}; +(function(){var c=b.categories.children[0].width(),d=b.categories.children[0].height(),e=Math.ceil(b.categories.children.length/2),f=(197-2*c)/3,g=b.categories.left(),k=b.categories.top(),m=0,l,h;b.categories.children.forEach(n=>{m+=1;l=Math.ceil(m/2);h=2-m%2;n.setPosition(new Point(g+(h*f+(h-1)*c),k+(2*l+(l-1)*d+3)))});b.categories.setHeight(2*(e+1)+e*d+6)})();this.add(this.categories)}; IDE_Morph.prototype.hideCategory=function(a){this.hiddenCategories.push(a);this.createCategories();this.createPaletteHandle();this.fixLayout()};IDE_Morph.prototype.showHiddenCategories=function(){this.hiddenCategories.length=0;this.createCategories();this.createPaletteHandle();this.fixLayout()}; IDE_Morph.prototype.createPalette=function(a){this.palette&&this.palette.destroy();a?(this.palette=new ScrollFrameMorph(null,null,this.currentSprite.sliderColor),getSpeechClass()&&(this.palette.toolBar=new PushButtonMorph(this,async()=>{try{const c=await getSpeech();""!==c&&(world.children[0].currentSprite.searchBlocks(c),this.palette.accept&&this.palette.accept())}catch(c){console.error(c),alert("speech recognition is not supported in this browser")}},new SymbolMorph("speechBubbleOutline",16)),this.palette.toolBar.alpha= .2,this.palette.toolBar.padding=1,this.palette.toolBar.hint="Voice Search",this.palette.toolBar.labelShadowColor=new Color(140,140,140),this.palette.toolBar.fixLayout(),this.palette.add(this.palette.toolBar))):this.palette=this.currentSprite.palette(this.currentCategory);this.palette.isDraggable=!1;this.palette.acceptsDrops=!0;this.palette.enableAutoScrolling=!1;this.palette.contents.acceptsDrops=!1;const b=c=>{const d=world.hand.grabOrigin;c.justDropped&&c.justDropped();d.origin.reactToDropOf&&d.origin.reactToDropOf(c)}; @@ -2027,14 +2027,14 @@ this.palette.reactToDropOf=(c,d)=>{c instanceof DialogBoxMorph?this.world().add( this.palette.contents.reactToDropOf=c=>{c instanceof BlockMorph&&c.destroy()};this.palette.setWidth(this.logo.width());this.add(this.palette);this.isAppMode&&this.palette.hide();return this.palette};IDE_Morph.prototype.createPaletteHandle=function(){this.paletteHandle&&this.paletteHandle.destroy();this.paletteHandle=new PaletteHandleMorph(this.categories);this.add(this.paletteHandle);this.isAppMode&&this.paletteHandle.hide()}; IDE_Morph.prototype.createStage=function(){this.stage&&this.stage.destroy();StageMorph.prototype.frameRate=0;this.stage=new StageMorph(this.globalVariables);this.stage.setExtent(this.stage.dimensions);this.currentSprite instanceof SpriteMorph&&(this.currentSprite.setPosition(this.stage.center().subtract(this.currentSprite.extent().divideBy(2))),this.stage.add(this.currentSprite));this.add(this.stage)}; IDE_Morph.prototype.createStageHandle=function(){this.stageHandle&&this.stageHandle.destroy();this.performerMode||(this.stageHandle=new StageHandleMorph(this.stage),this.add(this.stageHandle))}; -IDE_Morph.prototype.createSpriteBar=function(){function a(n){var p=h.rotationStyleColors;var q=new ToggleButtonMorph(p,h,()=>{h.currentSprite instanceof SpriteMorph&&SnapActions.setRotationStyle(h.currentSprite,n)},f[n],()=>h.currentSprite instanceof SpriteMorph&&h.currentSprite.rotationStyle===n,null,localize(g[n]));q.corner=8;q.labelMinExtent=new Point(11,11);q.padding=0;q.labelShadowOffset=new Point(-1,-1);q.labelShadowColor=p[1];q.labelColor=h.buttonLabelColor;q.fixLayout();q.refresh();b.push(q); -q.setPosition(h.spriteBar.position().add(new Point(2,4)));q.setTop(q.top()+(b.length-1)*(q.height()+2));h.spriteBar.add(q);h.currentSprite instanceof StageMorph&&q.hide();return q}var b=[],c=new Point(45,45),d=this.tabColors,e=new AlignmentMorph("row",-30),f=[new SymbolMorph("arrowRightThin",10),new SymbolMorph("turnAround",10),new SymbolMorph("arrowLeftRightThin",10)],g=["don't rotate","can rotate","only face left/right"],h=this;this.spriteBar&&this.spriteBar.destroy();this.spriteBar=new Morph;this.spriteBar.color= -this.frameColor;this.add(this.spriteBar);a(1);a(2);a(0);this.rotationStyleButtons=b;var m=new Morph;m.isCachingImage=!0;m.bounds.setExtent(c);m.cachedImage=this.currentSprite.thumbnail(c);m.setPosition(b[0].topRight().add(new Point(5,3)));this.spriteBar.add(m);m.fps=3;m.step=function(){m.version!==h.currentSprite.version&&(m.cachedImage=h.currentSprite.thumbnail(c,m.cachedImage),m.changed(),m.version=h.currentSprite.version)};var l=new InputFieldMorph(this.currentSprite.name);l.setWidth(100);l.contrast= -90;l.setPosition(m.topRight().add(new Point(10,3)));this.spriteBar.add(l);this.spriteBar.nameField=l;l.fixLayout();l.accept=function(){var n=l.getValue(),p=h.currentSprite.name;n=h.newSpriteName(n,h.currentSprite);if(n!==p)return SnapActions.renameSprite(h.currentSprite,n);l.setContents(n)};this.spriteBar.nameField=l;this.spriteBar.reactToEdit=l.accept;var k=new ToggleMorph("checkbox",null,()=>SnapActions.toggleDraggable(h.currentSprite,!h.currentSprite.isDraggable),localize("draggable"),()=>this.currentSprite.isDraggable); -k.label.isBold=!1;k.label.setColor(this.buttonLabelColor);k.color=d[2];k.highlightColor=d[0];k.pressColor=d[1];k.tick.shadowOffset=MorphicPreferences.isFlat?ZERO:new Point(-1,-1);k.tick.shadowColor=BLACK;k.tick.color=this.buttonLabelColor;k.tick.isBold=!1;k.tick.fixLayout();k.setPosition(l.bottomLeft().add(2));k.fixLayout();this.spriteBar.add(k);this.spriteBar.padlock=k;this.currentSprite instanceof StageMorph&&k.hide();e.tabTo=function(n){var p;h.currentTab=n;this.children.forEach(q=>{q.refresh(); -q.state&&(p=q)});p.refresh();h.createSpriteEditor();h.fixLayout("tabEditor")};k=new TabMorph(d,null,()=>{SnapActions.selectTab("scripts");e.tabTo("scripts")},localize("Scripts"),()=>"scripts"===this.currentTab);k.padding=3;k.corner=15;k.edge=1;k.labelShadowOffset=new Point(-1,-1);k.labelShadowColor=d[1];k.labelColor=this.buttonLabelColor;k.getPressRenderColor=function(){return MorphicPreferences.isFlat||.85{SnapActions.selectTab("costumes");e.tabTo("costumes")},localize(this.currentSprite instanceof SpriteMorph?"Costumes":"Backgrounds"),()=>"costumes"===this.currentTab);k.padding=3;k.corner=15;k.edge=1;k.labelShadowOffset=new Point(-1,-1);k.labelShadowColor=d[1];k.labelColor=this.buttonLabelColor;k.fixLayout();e.add(k);k=new TabMorph(d,null,()=>{SnapActions.selectTab("sounds");e.tabTo("sounds")},localize("Sounds"), -()=>"sounds"===this.currentTab);k.padding=3;k.corner=15;k.edge=1;k.labelShadowOffset=new Point(-1,-1);k.labelShadowColor=d[1];k.labelColor=this.buttonLabelColor;k.fixLayout();e.add(k);e.fixLayout();e.children.forEach(n=>n.refresh());this.spriteBar.tabBar=e;this.spriteBar.add(this.spriteBar.tabBar);this.spriteBar.fixLayout=function(){this.tabBar.setLeft(this.left());this.tabBar.setBottom(this.bottom()+h.padding)};this.isAppMode&&this.spriteBar.hide()}; +IDE_Morph.prototype.createSpriteBar=function(){function a(n){var p=k.rotationStyleColors;var q=new ToggleButtonMorph(p,k,()=>{k.currentSprite instanceof SpriteMorph&&SnapActions.setRotationStyle(k.currentSprite,n)},f[n],()=>k.currentSprite instanceof SpriteMorph&&k.currentSprite.rotationStyle===n,null,localize(g[n]));q.corner=8;q.labelMinExtent=new Point(11,11);q.padding=0;q.labelShadowOffset=new Point(-1,-1);q.labelShadowColor=p[1];q.labelColor=k.buttonLabelColor;q.fixLayout();q.refresh();b.push(q); +q.setPosition(k.spriteBar.position().add(new Point(2,4)));q.setTop(q.top()+(b.length-1)*(q.height()+2));k.spriteBar.add(q);k.currentSprite instanceof StageMorph&&q.hide();return q}var b=[],c=new Point(45,45),d=this.tabColors,e=new AlignmentMorph("row",-30),f=[new SymbolMorph("arrowRightThin",10),new SymbolMorph("turnAround",10),new SymbolMorph("arrowLeftRightThin",10)],g=["don't rotate","can rotate","only face left/right"],k=this;this.spriteBar&&this.spriteBar.destroy();this.spriteBar=new Morph;this.spriteBar.color= +this.frameColor;this.add(this.spriteBar);a(1);a(2);a(0);this.rotationStyleButtons=b;var m=new Morph;m.isCachingImage=!0;m.bounds.setExtent(c);m.cachedImage=this.currentSprite.thumbnail(c);m.setPosition(b[0].topRight().add(new Point(5,3)));this.spriteBar.add(m);m.fps=3;m.step=function(){m.version!==k.currentSprite.version&&(m.cachedImage=k.currentSprite.thumbnail(c,m.cachedImage),m.changed(),m.version=k.currentSprite.version)};var l=new InputFieldMorph(this.currentSprite.name);l.setWidth(100);l.contrast= +90;l.setPosition(m.topRight().add(new Point(10,3)));this.spriteBar.add(l);this.spriteBar.nameField=l;l.fixLayout();l.accept=function(){var n=l.getValue(),p=k.currentSprite.name;n=k.newSpriteName(n,k.currentSprite);if(n!==p)return SnapActions.renameSprite(k.currentSprite,n);l.setContents(n)};this.spriteBar.nameField=l;this.spriteBar.reactToEdit=l.accept;var h=new ToggleMorph("checkbox",null,()=>SnapActions.toggleDraggable(k.currentSprite,!k.currentSprite.isDraggable),localize("draggable"),()=>this.currentSprite.isDraggable); +h.label.isBold=!1;h.label.setColor(this.buttonLabelColor);h.color=d[2];h.highlightColor=d[0];h.pressColor=d[1];h.tick.shadowOffset=MorphicPreferences.isFlat?ZERO:new Point(-1,-1);h.tick.shadowColor=BLACK;h.tick.color=this.buttonLabelColor;h.tick.isBold=!1;h.tick.fixLayout();h.setPosition(l.bottomLeft().add(2));h.fixLayout();this.spriteBar.add(h);this.spriteBar.padlock=h;this.currentSprite instanceof StageMorph&&h.hide();e.tabTo=function(n){var p;k.currentTab=n;this.children.forEach(q=>{q.refresh(); +q.state&&(p=q)});p.refresh();k.createSpriteEditor();k.fixLayout("tabEditor")};h=new TabMorph(d,null,()=>{SnapActions.selectTab("scripts");e.tabTo("scripts")},localize("Scripts"),()=>"scripts"===this.currentTab);h.padding=3;h.corner=15;h.edge=1;h.labelShadowOffset=new Point(-1,-1);h.labelShadowColor=d[1];h.labelColor=this.buttonLabelColor;h.getPressRenderColor=function(){return MorphicPreferences.isFlat||.85{SnapActions.selectTab("costumes");e.tabTo("costumes")},localize(this.currentSprite instanceof SpriteMorph?"Costumes":"Backgrounds"),()=>"costumes"===this.currentTab);h.padding=3;h.corner=15;h.edge=1;h.labelShadowOffset=new Point(-1,-1);h.labelShadowColor=d[1];h.labelColor=this.buttonLabelColor;h.fixLayout();e.add(h);h=new TabMorph(d,null,()=>{SnapActions.selectTab("sounds");e.tabTo("sounds")},localize("Sounds"), +()=>"sounds"===this.currentTab);h.padding=3;h.corner=15;h.edge=1;h.labelShadowOffset=new Point(-1,-1);h.labelShadowColor=d[1];h.labelColor=this.buttonLabelColor;h.fixLayout();e.add(h);e.fixLayout();e.children.forEach(n=>n.refresh());this.spriteBar.tabBar=e;this.spriteBar.add(this.spriteBar.tabBar);this.spriteBar.fixLayout=function(){this.tabBar.setLeft(this.left());this.tabBar.setBottom(this.bottom()+k.padding)};this.isAppMode&&this.spriteBar.hide()}; IDE_Morph.prototype.createSpriteEditor=function(){var a=this.currentSprite.scripts;this.spriteEditor&&this.spriteEditor.destroy();"scripts"===this.currentTab?(a.isDraggable=!1,this.performerMode?a.alpha=0:(a.color=this.groupColor,a.cachedTexture=this.scriptsPaneTexture),this.spriteEditor=new ScrollFrameMorph(a,null,this.sliderColor),this.performerMode?this.spriteEditor.alpha=0:this.spriteEditor.color=this.groupColor,this.spriteEditor.padding=10,this.spriteEditor.growth=50,this.spriteEditor.isDraggable= !1,this.spriteEditor.acceptsDrops=!1,this.spriteEditor.contents.acceptsDrops=!0,a.scrollFrame=this.spriteEditor,a.updateToolbar(),this.add(this.spriteEditor),this.spriteEditor.scrollX(this.spriteEditor.padding),this.spriteEditor.scrollY(this.spriteEditor.padding)):"costumes"===this.currentTab?(this.spriteEditor=new WardrobeMorph(this.currentSprite,this.sliderColor),this.spriteEditor.color=this.groupColor,this.add(this.spriteEditor),this.spriteEditor.updateSelection(),this.spriteEditor.acceptsDrops= !1,this.spriteEditor.contents.acceptsDrops=!1,this.spriteEditor.contents.mouseEnterDragging=b=>{b instanceof BlockMorph&&this.spriteBar.tabBar.tabTo("scripts")}):"sounds"===this.currentTab?(this.spriteEditor=new JukeboxMorph(this.currentSprite,this.sliderColor),this.spriteEditor.color=this.groupColor,this.add(this.spriteEditor),this.spriteEditor.updateSelection(),this.spriteEditor.acceptDrops=!1,this.spriteEditor.contents.acceptsDrops=!1,this.spriteEditor.contents.mouseEnterDragging=b=>{b instanceof @@ -2045,7 +2045,7 @@ IDE_Morph.prototype.createCorralBar=function(){var a=MorphicPreferences.isFlat?t -1);d.labelShadowColor=a[1];d.labelColor=this.buttonLabelColor;d.contrast=this.buttonContrast;d.hint="take a camera snapshot and\nimport it as a new sprite";d.fixLayout();d.setCenter(this.corralBar.center());d.setLeft(this.corralBar.left()+5+b.width()+5+c.width()+5);this.corralBar.add(d);document.addEventListener("cameraDisabled",e=>{d.disable();d.hint=CamSnapshotDialogMorph.prototype.notSupportedMessage})}}; IDE_Morph.prototype.createCorral=function(){var a=this;this.createStageHandle();this.createPaletteHandle();this.corral&&this.corral.destroy();this.corral=new Morph;this.corral.color=this.groupColor;this.corral.getRenderColor=ScriptsMorph.prototype.getRenderColor;this.add(this.corral);this.corral.stageIcon=new SpriteIconMorph(this.stage);this.corral.stageIcon.isDraggable=!1;this.corral.add(this.corral.stageIcon);var b=new ScrollFrameMorph(null,null,this.sliderColor);b.acceptsDrops=!1;b.contents.acceptsDrops= !1;b.contents.wantsDropOf=c=>c instanceof SpriteIconMorph;b.contents.reactToDropOf=c=>this.corral.reactToDropOf(c);b.alpha=0;this.sprites.asArray().forEach(c=>{c.isTemporary||b.contents.add(new SpriteIconMorph(c))});this.corral.frame=b;this.corral.add(b);this.corral.fixLayout=function(){this.stageIcon.setCenter(this.center());this.stageIcon.setLeft(this.left()+5);this.frame.setLeft(this.stageIcon.right()+5);this.frame.setExtent(new Point(this.right()-this.frame.left(),this.height()));this.arrangeIcons(); -this.refresh()};this.corral.arrangeIcons=function(){var c=this.frame.left(),d=this.frame.top(),e=this.frame.right(),f=this.frame.left();this.frame.contents.children.forEach(g=>{var h=g.width();c+h>e&&(c=f,d+=g.height());g.setPosition(new Point(c,d));c+=h});this.frame.contents.adjustBounds()};this.corral.addSprite=function(c){this.frame.contents.add(new SpriteIconMorph(c));this.fixLayout()};this.corral.refresh=function(){this.stageIcon.refresh();this.frame.contents.children.forEach(c=>c.refresh())}; +this.refresh()};this.corral.arrangeIcons=function(){var c=this.frame.left(),d=this.frame.top(),e=this.frame.right(),f=this.frame.left();this.frame.contents.children.forEach(g=>{var k=g.width();c+k>e&&(c=f,d+=g.height());g.setPosition(new Point(c,d));c+=k});this.frame.contents.adjustBounds()};this.corral.addSprite=function(c){this.frame.contents.add(new SpriteIconMorph(c));this.fixLayout()};this.corral.refresh=function(){this.stageIcon.refresh();this.frame.contents.children.forEach(c=>c.refresh())}; this.corral.wantsDropOf=c=>c instanceof SpriteIconMorph;this.corral.reactToDropOf=function(c){var d=1,e=c.position(),f=!!SnapActions.getOwnerFromId(c.object.id);c.destroy();f&&(this.frame.contents.children.forEach(function(g){if(e.gt(g.position())||e.y>g.bottom())d+=1}),a.sprites.add(c.object,d),a.createCorral(),a.fixLayout())};this.corral.userMenu=function(){var c=new MenuMorph(this);if(SnapUndo.canUndo("corral")){var d=SnapUndo.eventHistory.corral.length;d=SnapUndo.eventHistory.corral[d-1];d=a.serializer.parse(d.args[1]).childrenNamed("sprite")[0]; c.addItem("restore "+d.attributes.name,function(){SnapUndo.undo("corral")})}NetsBloxExtensions&&NetsBloxExtensions.getUserMenu(this,c);return c};this.isAppMode&&this.corral.hide()};IDE_Morph.prototype.createReplayControls=function(){this.replayControls=new ReplayControls(this);this.add(this.replayControls);this.replayControls.hide()}; IDE_Morph.prototype.fixLayout=function(a){var b=this.padding,c=this.config||{},d=c.border||0;"refreshPalette"!==a&&(this.controlBar.setPosition(this.logo.topRight()),this.controlBar.setWidth(this.right()-this.controlBar.left()),this.controlBar.fixLayout(),this.categories.setLeft(this.logo.left()),this.categories.setTop(this.logo.bottom()),this.categories.setWidth(this.paletteWidth));this.palette.setLeft(this.logo.left());this.palette.setTop(this.categories.bottom());this.palette.setHeight(this.bottom()- @@ -2068,7 +2068,7 @@ IDE_Morph.prototype.droppedText=async function(a,b,c){var d=b?b.split(".")[0]:"" if(0===a.indexOf("b instanceof BlockEditorMorph||b instanceof BlockDialogMorph))return this.currentSprite&&this.currentSprite.scripts.focus&&this.currentSprite.scripts.focus.stopEditing(),this.currentSprite=a,this.createPalette(),this.createSpriteBar(),this.createSpriteEditor(),this.corral.refresh(),this.fixLayout("selectSprite"),this.performerMode&&(this.fixLayout(),this.currentSprite.scripts.updateToolbar()),this.currentSprite.scripts.fixMultiArgs(), this.currentSprite};IDE_Morph.prototype.toggleRetina=function(){isRetinaEnabled()?disableRetinaSupport():enableRetinaSupport();this.world().fillPage();MorphicPreferences.isFlat||(IDE_Morph.prototype.scriptsPaneTexture=this.scriptsTexture());this.stage.clearPenTrails();this.refreshIDE()};IDE_Morph.prototype.defaultDesign=function(){this.setDefaultDesign();this.refreshIDE();this.removeSetting("design")}; -IDE_Morph.prototype.flatDesign=function(){this.setFlatDesign();this.refreshIDE();this.saveSetting("design","flat")}; -IDE_Morph.prototype.refreshIDE=function(){if(Process.prototype.isCatchingErrors)try{var a=this.serializer.serialize(this.stage)}catch(b){this.showMessage("Serialization failed: "+b)}else a=this.serializer.serialize(this.stage);SpriteMorph.prototype.initBlocks();this.buildPanes();this.fixLayout();this.loadNewProject?SnapActions.openProject():(SnapUndo.reset(),this.openProjectString(a));NetsBloxExtensions&&0this.selectSprite(c))}; IDE_Morph.prototype.paintNewSprite=function(){var a=new SpriteMorph(this.globalVariables),b=new Costume;b.edit(this.world(),null,!0,nop,()=>{b.shrinkWrap();a.parent=this.stage;a.addCostume(b);a.wearCostume(b);a.gotoXY(0,0);SnapActions.addSprite(a)})}; IDE_Morph.prototype.newCamSprite=function(){var a=new SpriteMorph(this.globalVariables);a.name=this.newSpriteName(a.name);a.setCenter(this.stage.center());a.parent=this.stage;var b=new CamSnapshotDialogMorph(this,a,nop,c=>{a.addCostume(c);a.wearCostume(c);b.close();SnapActions.addSprite(a).then(d=>this.selectSprite(d))});b.popUp(this.world())}; IDE_Morph.prototype.recordNewSound=function(){var a=new SoundRecorderDialogMorph(b=>{b&&(b=this.currentSprite.addSound(new Sound(b,this.newSoundName("recording"))),this.makeSureRecordingIsMono(b),this.spriteBar.tabBar.tabTo("sounds"),this.hasChangedMedia=!0)});a.key="microphone";a.popUp(this.world())}; -IDE_Morph.prototype.makeSureRecordingIsMono=function(a){function b(e,f){var g=Note.prototype.getAudioContext();f=g.createBuffer(1,e.length,+f||44100);var h;f.copyToChannel||(f.copyToChannel=function(m,l){l=this.getChannelData(l);for(h=0;hx?32768*x:32767*x,!0)}}function n(u,v,w){for(var y=0;y{e.audioBuffer=k;return f(e)},k=>{throw k;})})(a,function(e){if(1!==e.audioBuffer.numberOfChannels){var f= -e.audioBuffer.getChannelData(0);var g=new Audio;f=new Blob([c(b(f,44100).audioBuffer)],{type:"audio/wav"});var h=new FileReader;h.onload=()=>{g.src=h.result;e.audio=g;e.audioBuffer=null;e.cachedSamples=null;e.isDecoding=!1};h.readAsDataURL(f)}})};IDE_Morph.prototype.duplicateSprite=function(a){a=a.fullCopy();a.appearIn(this);return a}; +IDE_Morph.prototype.makeSureRecordingIsMono=function(a){function b(e,f){var g=Note.prototype.getAudioContext();f=g.createBuffer(1,e.length,+f||44100);var k;f.copyToChannel||(f.copyToChannel=function(m,l){l=this.getChannelData(l);for(k=0;kx?32768*x:32767*x,!0)}}function n(u,v,w){for(var y=0;y{e.audioBuffer=h;return f(e)},h=>{throw h;})})(a,function(e){if(1!==e.audioBuffer.numberOfChannels){var f= +e.audioBuffer.getChannelData(0);var g=new Audio;f=new Blob([c(b(f,44100).audioBuffer)],{type:"audio/wav"});var k=new FileReader;k.onload=()=>{g.src=k.result;e.audio=g;e.audioBuffer=null;e.cachedSamples=null;e.isDecoding=!1};k.readAsDataURL(f)}})};IDE_Morph.prototype.duplicateSprite=function(a){a=a.fullCopy();a.appearIn(this);return a}; IDE_Morph.prototype.instantiateSprite=function(a){var b=a.fullCopy(!0),c=b.allHatBlocksFor("__clone__init__");b.isDown=!1;b.appearIn(this);c.length?b.initClone(c):(b.setPosition(this.world().hand.position()),b.keepWithin(this.stage));b.isDown=a.isDown;this.selectSprite(b)}; IDE_Morph.prototype.removeSprite=function(a){a.parts.slice().forEach(c=>this.removeSprite(c));var b=this.sprites.asArray().indexOf(a)+1;this.stage.threads.stopAllForReceiver(a);a.corpsify();a.destroy();this.stage.watchers().forEach(c=>{c.object()===a&&c.destroy()});0c instanceof SpriteMorph&&!c.isTemporary)||this.stage;this.selectSprite(this.currentSprite)}; IDE_Morph.prototype.newSoundName=function(a){var b=this.currentSprite.sounds.at(this.currentSprite.sounds.length());return this.newName(a||b.name,this.currentSprite.sounds.asArray().map(c=>c.name))};IDE_Morph.prototype.newSpriteName=function(a,b){var c=this.sprites.asArray().concat(this.stage).filter(d=>d!==b).map(d=>d.name);return this.newName(a,c)};IDE_Morph.prototype.newName=function(a,b){var c=a.indexOf("(");a=0>c?a:a.substring(0,c);c=1;for(var d=a;contains(b,d);)c+=1,d=a+"("+c+")";return d}; @@ -2099,7 +2098,7 @@ b.currentKey&&c.addItem("Load reported bug","loadBugReport",void 0,new Color(100 IDE_Morph.prototype.cloudMenu=function(){var a=16===this.world().currentKey;if("file:"!==location.protocol||a){var b=new MenuMorph(this);this.cloud.username?(b.addItem(localize("Logout")+" "+this.cloud.username,"logout"),b.addItem("Change Password...","changeCloudPassword")):(b.addItem("Login...","initializeCloud"),b.addItem("Login with Snap!...","initializeCloudWithSnap"),b.addItem("Signup...","createCloudAccount"),b.addItem("Reset Password...","resetCloudPassword"));a&&(b.addLine(),b.addItem("export project media only...", ()=>{this.room.name?this.exportProjectMedia(this.room.name):this.prompt("Export Project As...",c=>this.exportProjectMedia(c),null,"exportProject")},null,this.hasChangedMedia?new Color(100,0,0):new Color(0,100,0)),b.addItem("export project without media...",()=>{this.room.name?this.exportProjectNoMedia(this.room.name):this.prompt("Export Project As...",c=>this.exportProjectNoMedia(c),null,"exportProject")},null,new Color(100,0,0)),b.addLine(),b.addItem("open shared project from cloud...",()=>{this.prompt("Author name\u2026", c=>{this.prompt("Project name...",async d=>{this.showMessage("Fetching project\nfrom the cloud...");try{const e=this.showMessage("Opening project..."),f=await this.cloud.getProjectByName(c,d),g=this.getXMLFromProjectData(f);Process.prototype.isCatchingErrors||window.open("data:text/xml,"+g);await this.droppedText(g);e.destroy()}catch(e){this.cloudError()(e.message)}},null,"project")},null,"project")},null,new Color(100,0,0)));return b}this.showMessage("cloud unavailable without a web server.")}; -IDE_Morph.prototype.settingsMenu=function(){function a(g,h,m,l,k,n){n&&!c||f.addItem([m?d:e,localize(g)],h,m?l:k,n?new Color(100,0,0):null)}var b=this.stage,c=16===this.world().currentKey,d=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),e=new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize);var f=new MenuMorph(this);f.addPair([new SymbolMorph("globe",MorphicPreferences.menuFontSize),localize("Language...")],"languageMenu");f.addItem("Zoom blocks...","userSetBlocksScale"); +IDE_Morph.prototype.settingsMenu=function(){function a(g,k,m,l,h,n){n&&!c||f.addItem([m?d:e,localize(g)],k,m?l:h,n?new Color(100,0,0):null)}var b=this.stage,c=16===this.world().currentKey,d=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),e=new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize);var f=new MenuMorph(this);f.addPair([new SymbolMorph("globe",MorphicPreferences.menuFontSize),localize("Language...")],"languageMenu");f.addItem("Zoom blocks...","userSetBlocksScale"); f.addItem("Fade blocks...","userFadeBlocks");this.performerMode||f.addItem("Stage size...","userSetStageSize");c&&f.addItem("Dragging threshold...","userSetDragThreshold","specify the distance the hand has to move\nbefore it picks up an object",new Color(100,0,0));f.addItem("Microphone resolution...","microphoneMenu");f.addLine();isRetinaSupported()&&a("Retina display support","toggleRetina",isRetinaEnabled(),"uncheck for lower resolution,\nsaves computing resources","check for higher resolution,\nuses more computing resources", !0);a("Input sliders","toggleInputSliders",MorphicPreferences.useSliderForInput,"uncheck to disable\ninput sliders for\nentry fields","check to enable\ninput sliders for\nentry fields");MorphicPreferences.useSliderForInput&&a("Execute on slider change","toggleSliderExecute",ArgMorph.prototype.executeOnSliderEdit,"uncheck to suppress\nrunning scripts\nwhen moving the slider","check to run\nthe edited script\nwhen moving the slider");a("Turbo mode","toggleFastTracking",this.stage.isFastTracked,"uncheck to run scripts\nat normal speed", "check to prioritize\nscript execution");a("Visible stepping","toggleSingleStepping",Process.prototype.enableSingleStepping,"uncheck to turn off\nvisible stepping","check to turn on\n visible stepping (slow)",!1);a("Log pen vectors",()=>StageMorph.prototype.enablePenLogging=!StageMorph.prototype.enablePenLogging,StageMorph.prototype.enablePenLogging,"uncheck to turn off\nlogging pen vectors","check to turn on\nlogging pen vectors",!1);a("Ternary Boolean slots",()=>BooleanSlotMorph.prototype.isTernary= @@ -2116,8 +2115,8 @@ this.currentSprite.scripts.updateToolbar();ScriptsMorph.prototype.enableKeyboard "EXPERIMENTAL! uncheck to disable live\ncustom control structures","EXPERIMENTAL! check to enable\n live custom control structures",!0);a("JIT compiler support",()=>{Process.prototype.enableCompiling=!Process.prototype.enableCompiling;this.currentSprite.blocksCache.operators=null;this.currentSprite.paletteCache.operators=null;this.refreshPalette()},Process.prototype.enableCompiling,"EXPERIMENTAL! uncheck to disable live\nsupport for compiling","EXPERIMENTAL! check to enable\nsupport for compiling", !0);a("Replay Mode",()=>{if(this.isReplayMode){if(this.isPreviousVersion()){this.confirm("Exiting replay mode now will revert the project to\nthe current point in history (losing any unapplied changes)\n\nAre you sure you want to exit replay mode?","Exit Replay Mode?",()=>this.exitReplayMode());return}return this.exitReplayMode()}if(2>SnapUndo.allEvents.length)return this.showMessage("Nothing to replay!",2);SnapActions.isCollaborating()?this.confirm("Cannot enter replay mode while collaborating. \nWould you like to disable collaboration and enter replay mode?", "Disable Collaboration?",()=>{this.replayEvents()}):this.replayEvents()},this.isReplayMode,"uncheck to disable replay mode","check to enable replay mode",!1);a("Save replay history",function(){SnapSerializer.prototype.isSavingHistory=!SnapSerializer.prototype.isSavingHistory},SnapSerializer.prototype.isSavingHistory,"uncheck to only save project","check to save replay with project",!1);a("Messaging while collaborating?",async()=>{if(this.allowMsgsWhileCollaborating)this.allowMsgsWhileCollaborating= -!this.allowMsgsWhileCollaborating;else{const g=localize("Send messages while collaborating?"),h=localize("By default, message sending is disabled when collaborating because it can make\ndebugging distributed applications difficult.\n\n")+localize("When multiple users collaborate, each collaborating user may send his/her own response\nto a received message. ")+localize('This is problematic when using the "send msg and wait"\nblock as well as for applications like turn-based games.\n\n')+localize("Would you like to enable message sending while collaborating?"); -await this.confirm(h,g)&&(this.allowMsgsWhileCollaborating=!this.allowMsgsWhileCollaborating)}},this.allowMsgsWhileCollaborating,"uncheck to block message sending while multiple users occupy a single role","check to allow message sending while multiple users occupy a single role",!1);a("Performer mode",()=>this.togglePerformerMode(),this.performerMode,"uncheck to go back to regular\nlayout","check to have the stage use up\nall space and go behind the\nscripting area");f.addLine();a("Thread safe scripts", +!this.allowMsgsWhileCollaborating;else{const g=localize("Send messages while collaborating?"),k=localize("By default, message sending is disabled when collaborating because it can make\ndebugging distributed applications difficult.\n\n")+localize("When multiple users collaborate, each collaborating user may send his/her own response\nto a received message. ")+localize('This is problematic when using the "send msg and wait"\nblock as well as for applications like turn-based games.\n\n')+localize("Would you like to enable message sending while collaborating?"); +await this.confirm(k,g)&&(this.allowMsgsWhileCollaborating=!this.allowMsgsWhileCollaborating)}},this.allowMsgsWhileCollaborating,"uncheck to block message sending while multiple users occupy a single role","check to allow message sending while multiple users occupy a single role",!1);a("Performer mode",()=>this.togglePerformerMode(),this.performerMode,"uncheck to go back to regular\nlayout","check to have the stage use up\nall space and go behind the\nscripting area");f.addLine();a("Thread safe scripts", ()=>b.isThreadSafe=!b.isThreadSafe,this.stage.isThreadSafe,"uncheck to allow\nscript reentrance","check to disallow\nscript reentrance");a("Prefer smooth animations","toggleVariableFrameRate",StageMorph.prototype.frameRate,"uncheck for greater speed\nat variable frame rates","check for smooth, predictable\nanimations across computers",!0);a("Flat line ends",()=>SpriteMorph.prototype.useFlatLineEnds=!SpriteMorph.prototype.useFlatLineEnds,SpriteMorph.prototype.useFlatLineEnds,"uncheck for round ends of lines", "check for flat ends of lines");a("Codification support",()=>{StageMorph.prototype.enableCodeMapping=!StageMorph.prototype.enableCodeMapping;this.currentSprite.blocksCache.variables=null;this.currentSprite.paletteCache.variables=null;this.refreshPalette()},StageMorph.prototype.enableCodeMapping,"uncheck to disable\nblock to text mapping features","check for block\nto text mapping features",!1);a("Hyper blocks support",()=>Process.prototype.enableHyperOps=!Process.prototype.enableHyperOps,Process.prototype.enableHyperOps, "uncheck to disable\nusing operators on lists and tables","check to enable\nusing operators on lists and tables",!1);a("Persist linked sublist IDs",()=>StageMorph.prototype.enableSublistIDs=!StageMorph.prototype.enableSublistIDs,StageMorph.prototype.enableSublistIDs,"uncheck to disable\nsaving linked sublist identities","check to enable\nsaving linked sublist identities",!0);a("Enable command drops in all rings",()=>RingReporterSlotMorph.prototype.enableCommandDrops=!RingReporterSlotMorph.prototype.enableCommandDrops, @@ -2138,17 +2137,17 @@ IDE_Morph.prototype.getMediaListFromURL=function(a,b){function c(d,e){return d.n IDE_Morph.prototype.parseResourceFile=function(a){var b,c=[];a.split("\n").map(d=>d.trim()).filter(d=>0{b=d.split("\t").map(e=>e.trim());2>b.length||c.push({fileName:b[0],name:b[1],description:2{document.body.removeChild(a);this.filePicker= null;b.hand.processDrop(a.files)},!1);document.body.appendChild(a);this.filePicker=a;a.click()};IDE_Morph.prototype.importMedia=function(a){var b=this.showMessage("Opening "+a+"...");this.getMediaList(a,c=>{b.destroy();this.popupMediaImportDialog(a,c)})}; -IDE_Morph.prototype.popupMediaImportDialog=function(a,b){var c=(new DialogBoxMorph).withKey("import"+a),d=new ScrollFrameMorph,e=null,f=new SymbolMorph("turtle",60),g=this,h=this.world();d.acceptsDrops=!1;d.contents.acceptsDrops=!1;d.color=g.groupColor;d.fixLayout=nop;c.labelString=a;c.createLabel();c.addBody(d);c.addButton("ok","Import");c.addButton("cancel","Close");c.ok=function(){e&&(e.object instanceof Sound?g.droppedAudio(e.object.copy().audio,e.labelString):e.object instanceof SVG_Costume? -g.droppedSVG(e.object.contents,e.labelString):g.droppedImage(e.object.contents,e.labelString))};c.fixLayout=function(){var m=fontHeight(this.titleFontSize)+2*this.titlePadding,l=0,k=0;this.buttons.fixLayout();this.body.setPosition(this.position().add(new Point(this.padding,m+this.padding)));this.body.setExtent(new Point(this.width()-2*this.padding,this.height()-3*this.padding-m-this.buttons.height()));var n=this.body.position();var p=this.body.width();d.contents.children.forEach(function(q){q.setPosition(n.add(new Point(l, -k)));l+=q.width();l+q.width()>p&&(l=0,k+=q.height())});d.contents.adjustBounds();this.label.setCenter(this.center());this.label.setTop(this.top()+(m-this.label.height())/2);this.buttons.setCenter(this.center());this.buttons.setBottom(this.bottom()-this.padding);this.removeShadow();this.addShadow()};b.forEach(m=>{var l=this.resourceURL(a,m.fileName),k=new Image,n=l.slice(l.lastIndexOf(".")+1).toLowerCase(),p="svg"===n&&!MorphicPreferences.rasterizeSVGs;n=contains(["wav","mp3"],n);var q=n?new SoundIconMorph(new Sound(new Audio, -m.name)):new CostumeIconMorph(new Costume(f.getImage(),m.name));q.isDraggable=!1;q.userMenu=nop;q.action=function(){if(e!==q){var r=e;e=q;r&&r.refresh()}};q.doubleClickAction=c.ok;q.query=function(){return q===e};d.addContents(q);n?(q.object.audio.onloadeddata=function(){q.createThumbnail();q.fixLayout();q.refresh()},q.object.audio.src=l,q.object.audio.load()):p?(k.onload=function(){q.object=new SVG_Costume(k,m.name);q.refresh()},this.getURL(l,r=>k.src="data:image/svg+xml;base64,"+window.btoa(r))): -(k.onload=function(){var r=newCanvas(new Point(k.width,k.height),!0);r.getContext("2d").drawImage(k,0,0);q.object=new Costume(r,m.name);q.refresh()},k.src=l)});c.popUp(h);c.setExtent(new Point(400,300));c.setCenter(h.center());new HandleMorph(c,300,280,c.corner,c.corner)}; -IDE_Morph.prototype.aboutSnap=function(){function a(r){r=new TextMorph(r,h.fontSize,h.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);var t=d.height()-10*h.titleFontSize;if(r.height()>t){var u=new ScrollFrameMorph;u.acceptsDrops=!1;u.contents.acceptsDrops=!1;u.bounds.setWidth(r.width());u.bounds.setHeight(t);u.addContents(r);u.color=new Color(0,0,0,0);return u}return r}var b="",c,d=this.world();var e=localize("License")+"\n\nSnap! is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the\nGNU Affero General Public License along with this program.\nIf not, see http://www.gnu.org/licenses/\n\nWant to use Snap! but scared by the open-source license?\nGet in touch with us, we'll make it work."; +IDE_Morph.prototype.popupMediaImportDialog=function(a,b){var c=(new DialogBoxMorph).withKey("import"+a),d=new ScrollFrameMorph,e=null,f=new SymbolMorph("turtle",60),g=this,k=this.world();d.acceptsDrops=!1;d.contents.acceptsDrops=!1;d.color=g.groupColor;d.fixLayout=nop;c.labelString=a;c.createLabel();c.addBody(d);c.addButton("ok","Import");c.addButton("cancel","Close");c.ok=function(){e&&(e.object instanceof Sound?g.droppedAudio(e.object.copy().audio,e.labelString):e.object instanceof SVG_Costume? +g.droppedSVG(e.object.contents,e.labelString):g.droppedImage(e.object.contents,e.labelString))};c.fixLayout=function(){var m=fontHeight(this.titleFontSize)+2*this.titlePadding,l=0,h=0;this.buttons.fixLayout();this.body.setPosition(this.position().add(new Point(this.padding,m+this.padding)));this.body.setExtent(new Point(this.width()-2*this.padding,this.height()-3*this.padding-m-this.buttons.height()));var n=this.body.position();var p=this.body.width();d.contents.children.forEach(function(q){q.setPosition(n.add(new Point(l, +h)));l+=q.width();l+q.width()>p&&(l=0,h+=q.height())});d.contents.adjustBounds();this.label.setCenter(this.center());this.label.setTop(this.top()+(m-this.label.height())/2);this.buttons.setCenter(this.center());this.buttons.setBottom(this.bottom()-this.padding);this.removeShadow();this.addShadow()};b.forEach(m=>{var l=this.resourceURL(a,m.fileName),h=new Image,n=l.slice(l.lastIndexOf(".")+1).toLowerCase(),p="svg"===n&&!MorphicPreferences.rasterizeSVGs;n=contains(["wav","mp3"],n);var q=n?new SoundIconMorph(new Sound(new Audio, +m.name)):new CostumeIconMorph(new Costume(f.getImage(),m.name));q.isDraggable=!1;q.userMenu=nop;q.action=function(){if(e!==q){var r=e;e=q;r&&r.refresh()}};q.doubleClickAction=c.ok;q.query=function(){return q===e};d.addContents(q);n?(q.object.audio.onloadeddata=function(){q.createThumbnail();q.fixLayout();q.refresh()},q.object.audio.src=l,q.object.audio.load()):p?(h.onload=function(){q.object=new SVG_Costume(h,m.name);q.refresh()},this.getURL(l,r=>h.src="data:image/svg+xml;base64,"+window.btoa(r))): +(h.onload=function(){var r=newCanvas(new Point(h.width,h.height),!0);r.getContext("2d").drawImage(h,0,0);q.object=new Costume(r,m.name);q.refresh()},h.src=l)});c.popUp(k);c.setExtent(new Point(400,300));c.setCenter(k.center());new HandleMorph(c,300,280,c.corner,c.corner)}; +IDE_Morph.prototype.aboutSnap=function(){function a(r){r=new TextMorph(r,k.fontSize,k.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1,1),WHITE);var t=d.height()-10*k.titleFontSize;if(r.height()>t){var u=new ScrollFrameMorph;u.acceptsDrops=!1;u.contents.acceptsDrops=!1;u.bounds.setWidth(r.width());u.bounds.setHeight(t);u.addContents(r);u.color=new Color(0,0,0,0);return u}return r}var b="",c,d=this.world();var e=localize("License")+"\n\nSnap! is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the\nGNU Affero General Public License along with this program.\nIf not, see http://www.gnu.org/licenses/\n\nWant to use Snap! but scared by the open-source license?\nGet in touch with us, we'll make it work."; var f=localize("Contributors")+'\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, \ncountless bugfixes and optimizations\nMichael Ball: Time/Date UI, Library Import Dialog,\ncountless bugfixes and optimizations\nBernat Romagosa: Countless contributions\nBartosz Leper: Retina Display Support\nZhenlei Jia and Dariusz Doro\u017calski: IME text editing\nKen Kahn: IME support and countless other contributions\nJosep Ferr\u00e0ndiz: Video Motion Detection\nJoan Guill\u00e9n: Countless contributions\nKartik Chandra: Paint Editor\nCarles Paredes: Initial Vector Paint Editor\n"Ava" Yuan Yuan, Dylan Servilla: Graphic Effects\nKyle Hotchkiss: Block search design\nBrian Broll: Many bugfixes and optimizations\nIan Reynolds: UI Design, Event Bindings, Sound primitives\nJadga H\u00fcgle: Icons and countless other contributions\nIvan Motyashov: Initial Squeak Porting\nLucas Karahadian: Piano Keyboard Design\nDavide Della Casa: Morphic Optimizations\nAchal Dave: Web Audio\nJoe Otto: Morphic Testing and Debugging'; -for(c in modules)Object.prototype.hasOwnProperty.call(modules,c)&&(b+="\n"+c+" ("+modules[c]+")");""!==b&&(b=localize("current module versions:")+" \n\nmorphic ("+morphicVersion+")"+b);var g=localize("Translations")+"\n"+SnapTranslator.credits();var h=new DialogBoxMorph;h.inform("About Snap","Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu", -d,this.logo.cachedTexture);var m=h.buttons.children[0];var l=h.addButton(()=>{h.addBody(a(g));h.body.fixLayout();m.show();k.show();p.hide();q.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"Translators...");var k=h.addButton(()=>{h.addBody(a("Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu")); -h.body.fixLayout();m.show();k.hide();p.show();q.show();n.show();l.hide();h.fixLayout();h.setCenter(d.center())},"Back...");k.hide();var n=h.addButton(()=>{h.addBody(a(e));h.body.fixLayout();m.show();k.show();p.hide();q.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"License...");var p=h.addButton(()=>{h.addBody(a(b));h.body.fixLayout();m.show();k.show();p.hide();q.hide();n.hide();l.hide();h.fixLayout();h.setCenter(d.center())},"Modules...");var q=h.addButton(()=>{h.addBody(a(f)); -h.body.fixLayout();m.show();k.show();l.show();p.hide();q.hide();n.hide();h.fixLayout();h.setCenter(d.center())},"Credits...");l.hide();h.fixLayout()}; +for(c in modules)Object.prototype.hasOwnProperty.call(modules,c)&&(b+="\n"+c+" ("+modules[c]+")");""!==b&&(b=localize("current module versions:")+" \n\nmorphic ("+morphicVersion+")"+b);var g=localize("Translations")+"\n"+SnapTranslator.credits();var k=new DialogBoxMorph;k.inform("About Snap","Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu", +d,this.logo.cachedTexture);var m=k.buttons.children[0];var l=k.addButton(()=>{k.addBody(a(g));k.body.fixLayout();m.show();h.show();p.hide();q.hide();n.hide();l.hide();k.fixLayout();k.setCenter(d.center())},"Translators...");var h=k.addButton(()=>{k.addBody(a("Snap! 6.2.0 - dev -\nBuild Your Own Blocks\n\nCopyright \u24b8 2008-2020 Jens M\u00f6nig and Brian Harvey\njens@moenig.org, bh@cs.berkeley.edu\n\n Snap! is developed by the University of California, Berkeley and SAP \nwith support from the National Science Foundation (NSF),\nMIOsoft and YC Research.\nThe design of Snap! is influenced and inspired by Scratch,\nfrom the Lifelong Kindergarten group at the MIT Media Lab\n\nfor more information see https://snap.berkeley.edu")); +k.body.fixLayout();m.show();h.hide();p.show();q.show();n.show();l.hide();k.fixLayout();k.setCenter(d.center())},"Back...");h.hide();var n=k.addButton(()=>{k.addBody(a(e));k.body.fixLayout();m.show();h.show();p.hide();q.hide();n.hide();l.hide();k.fixLayout();k.setCenter(d.center())},"License...");var p=k.addButton(()=>{k.addBody(a(b));k.body.fixLayout();m.show();h.show();p.hide();q.hide();n.hide();l.hide();k.fixLayout();k.setCenter(d.center())},"Modules...");var q=k.addButton(()=>{k.addBody(a(f)); +k.body.fixLayout();m.show();h.show();l.show();p.hide();q.hide();n.hide();k.fixLayout();k.setCenter(d.center())},"Credits...");l.hide();k.fixLayout()}; IDE_Morph.prototype.editProjectNotes=function(){var a=(new DialogBoxMorph).withKey("projectNotes"),b=new ScrollFrameMorph,c=new TextMorph(this.projectNotes||""),d=this.world();b.padding=6;b.setWidth(250);b.acceptsDrops=!1;b.contents.acceptsDrops=!1;c.setWidth(250-2*b.padding);c.setPosition(b.topLeft().add(b.padding));c.enableSelecting();c.isEditable=!0;b.setHeight(250);b.fixLayout=nop;b.edge=InputFieldMorph.prototype.edge;b.fontSize=InputFieldMorph.prototype.fontSize;b.typeInPadding=InputFieldMorph.prototype.typeInPadding; b.contrast=InputFieldMorph.prototype.contrast;b.render=InputFieldMorph.prototype.render;b.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;b.addContents(c);a.getInput=()=>c.text;a.target=this;a.action=e=>this.projectNotes=e;a.justDropped=()=>c.edit();a.labelString="Project Notes";a.createLabel();a.addBody(b);a.addButton("ok","OK");a.addButton("cancel","Cancel");a.fixLayout();a.popUp(d);a.setCenter(d.center());c.edit()}; IDE_Morph.prototype.newProject=function(){this.source=this.cloud.username?"cloud":null;this.stage&&this.stage.destroy();"#lang:"!==location.hash.substr(0,6)&&(location.hash="");this.globalVariables=new VariableFrame;this.currentSprite=new SpriteMorph(this.globalVariables);this.sprites=new List([this.currentSprite]);StageMorph.prototype.dimensions=new Point(480,360);StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping= @@ -2162,17 +2161,17 @@ IDE_Morph.prototype.exportGlobalBlocks=function(){0{const d=await this.promptLibraryNotes();(new LibraryDialogMorph(this,c,b,d)).popUp(this.world())});a.labelString="Save blocks / message types";a.createLabel();a.fixLayout();a.popUp(this.world())}else this.inform("Export blocks/msg types","this project doesn't have any\ncustom global blocks or message types yet")}; IDE_Morph.prototype.promptLibraryNotes=function(){const a=utils.defer();var b=(new DialogBoxMorph).withKey("libraryNotes"),c=new ScrollFrameMorph,d=new TextMorph(""),e=b.ok,f=this.world();c.padding=6;c.setWidth(250);c.acceptsDrops=!1;c.contents.acceptsDrops=!1;d.setWidth(250-2*c.padding);d.setPosition(c.topLeft().add(c.padding));d.enableSelecting();d.isEditable=!0;c.setHeight(250);c.fixLayout=nop;c.edge=InputFieldMorph.prototype.edge;c.fontSize=InputFieldMorph.prototype.fontSize;c.typeInPadding=InputFieldMorph.prototype.typeInPadding; c.contrast=InputFieldMorph.prototype.contrast;c.render=InputFieldMorph.prototype.render;c.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;c.addContents(d);b.ok=function(){a.resolve(d.text);e.call(this)};b.justDropped=()=>d.edit();b.labelString="Library Notes";b.createLabel();b.addBody(c);b.addButton("ok","OK");b.addButton("cancel","Cancel");b.fixLayout();b.popUp(f);b.setCenter(f.center());d.edit();return a.promise}; -IDE_Morph.prototype.removeUnusedBlocks=function(){function a(){return c.filter(g=>contains(d,g)?!1:b.every((h,m)=>!h.usesBlockInstance(g,!0,m,d)))}for(var b=this.sprites.asArray().concat([this.stage]),c=this.stage.globalBlocks,d=[],e=!1,f;!e;)f=a(),f.length?d=d.concat(f):e=!0;0contains(d,g)?!1:b.every((k,m)=>!k.usesBlockInstance(g,!0,m,d)))}for(var b=this.sprites.asArray().concat([this.stage]),c=this.stage.globalBlocks,d=[],e=!1,f;!e;)f=a(),f.length?d=d.concat(f):e=!0;0'+c+"";this.saveXMLAs(c,a.name)}; -IDE_Morph.prototype.exportScriptsPicture=function(){var a=[],b=0,c=0,d=0;this.sprites.asArray().forEach(g=>{a.push(g.getImage());a.push(g.scripts.scriptsPicture());g.customBlocks.forEach(h=>a.push(h.scriptsPicture()))});a.push(this.stage.getImage());a.push(this.stage.scripts.scriptsPicture());this.stage.customBlocks.forEach(g=>a.push(g.scriptsPicture()));this.stage.globalBlocks.forEach(g=>a.push(g.scriptsPicture()));a=a.filter(g=>!isNil(g));a.forEach(g=>{b=Math.max(b,g.width);c+=g.height;c+=20}); +IDE_Morph.prototype.exportScriptsPicture=function(){var a=[],b=0,c=0,d=0;this.sprites.asArray().forEach(g=>{a.push(g.getImage());a.push(g.scripts.scriptsPicture());g.customBlocks.forEach(k=>a.push(k.scriptsPicture()))});a.push(this.stage.getImage());a.push(this.stage.scripts.scriptsPicture());this.stage.customBlocks.forEach(g=>a.push(g.scriptsPicture()));this.stage.globalBlocks.forEach(g=>a.push(g.scriptsPicture()));a=a.filter(g=>!isNil(g));a.forEach(g=>{b=Math.max(b,g.width);c+=g.height;c+=20}); c-=20;var e=newCanvas(new Point(b,c));var f=e.getContext("2d");a.forEach(g=>{f.drawImage(g,0,d);d+=20;d+=g.height});this.saveCanvasAs(e,this.projectName||localize("Untitled"))}; -IDE_Morph.prototype.exportProjectSummary=function(a){function b(p,q,r){q||=k;return new XML_Element(p,r,q)}function c(p,q,r){q||="p";r||=k;return new XML_Element(q,p,r)}function d(p,q,r){q||=k;r=r?null:b("p",q);q=b("img",r||q);q.attributes.src=p.toDataURL();return q}function e(p){var q=p.names().sort(),r=!0,t;q.length&&(c(localize("Variables"),"h3"),q.forEach(u=>{r&&(t=b("ul"),r=!1);var v=b("li",t);u=new WatcherMorph(u,SpriteMorph.prototype.blockColor.variables,p,u);var w=u.cellMorph.contentsMorph; +IDE_Morph.prototype.exportProjectSummary=function(a){function b(p,q,r){q||=h;return new XML_Element(p,r,q)}function c(p,q,r){q||="p";r||=h;return new XML_Element(q,p,r)}function d(p,q,r){q||=h;r=r?null:b("p",q);q=b("img",r||q);q.attributes.src=p.toDataURL();return q}function e(p){var q=p.names().sort(),r=!0,t;q.length&&(c(localize("Variables"),"h3"),q.forEach(u=>{r&&(t=b("ul"),r=!1);var v=b("li",t);u=new WatcherMorph(u,SpriteMorph.prototype.blockColor.variables,p,u);var w=u.cellMorph.contentsMorph; w instanceof ListWatcherMorph&&w.expand();d(u.fullImage(),v).attributes.class="script"}))}function f(p){p.length&&(c(localize("Blocks"),"h3"),SpriteMorph.prototype.categories.forEach(q=>{var r=!0,t;p.forEach(u=>{if(u.category===q){r&&(c(localize(q[0].toUpperCase().concat(q.slice(1))),"h4"),t=b("ul"),r=!1);var v=b("li",t);var w=d(u.templateInstance().scriptPic(),v);w.attributes.class="script";u.sortedElements().forEach(y=>{d(y instanceof BlockMorph?y.scriptPic():y.fullImage(),v).attributes.class="script"})}})}))} -var g=this.stage;var h=this.projectName||localize("untitled");var m=new XML_Element("html");m.attributes.lang=SnapTranslator.language;var l=b("head",m);b("meta",l).attributes.charset="UTF-8";b("style",l,a?"img {vertical-align: top;filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-ms-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}":"img {vertical-align: top;}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}.sprite {border: 1px solid lightgray;}"); -c(h,"title",l);var k=b("body",m);c(h,"h1");location.search.includes("action=present")?(c(location.toString(),"a",k).attributes.href=location.toString(),d(g.thumbnail(g.dimensions)).attributes.class="sprite",c(this.serializer.app,"h4")):(c(this.serializer.app,"h4"),d(g.thumbnail(g.dimensions)).attributes.class="sprite");Process.prototype.reportTextSplit(this.projectNotes,"line").asArray().forEach(p=>c(p));c(localize("Contents"),"h4");var n=b("ul");this.sprites.asArray().concat([g]).forEach(p=>{var q= +var g=this.stage;var k=this.projectName||localize("untitled");var m=new XML_Element("html");m.attributes.lang=SnapTranslator.language;var l=b("head",m);b("meta",l).attributes.charset="UTF-8";b("style",l,a?"img {vertical-align: top;filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-webkit-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));-ms-filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.5));}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}":"img {vertical-align: top;}.toc {vertical-align: middle;padding: 2px 1em 2px 1em;}.sprite {border: 1px solid lightgray;}"); +c(k,"title",l);var h=b("body",m);c(k,"h1");location.search.includes("action=present")?(c(location.toString(),"a",h).attributes.href=location.toString(),d(g.thumbnail(g.dimensions)).attributes.class="sprite",c(this.serializer.app,"h4")):(c(this.serializer.app,"h4"),d(g.thumbnail(g.dimensions)).attributes.class="sprite");Process.prototype.reportTextSplit(this.projectNotes,"line").asArray().forEach(p=>c(p));c(localize("Contents"),"h4");var n=b("ul");this.sprites.asArray().concat([g]).forEach(p=>{var q= b("li",n),r=p.scripts.sortedElements(),t=p.costumes.length();b("hr");d(p.thumbnail(new Point(40,40)),q,!0).attributes.class="toc";c(p.name,"a",q).attributes.href="#"+p.name;c(p.name,"h2").attributes.id=p.name;d(p.thumbnail(p.extent().divideBy(g.scale))).attributes.class="sprite";if(p instanceof SpriteMorph&&(p.exemplar&&(d(p.exemplar.thumbnail(new Point(40,40)),c(localize("Kind of")+" "+p.exemplar.name),!0).attributes.class="toc"),p.anchor&&(d(p.anchor.thumbnail(new Point(40,40)),c(localize("Part of")+ " "+p.anchor.name),!0).attributes.class="toc"),p.parts.length)){c(localize("Parts"),"h3");var u=b("ul");p.parts.forEach(v=>{var w=b("li",u,v.name);d(v.thumbnail(new Point(40,40)),w,!0).attributes.class="toc"})}if(1{var w=b("li",u,v.name);d(v.thumbnail(new Point(40,40)),w,!0).attributes.class="toc"});p.sounds.length()&&(c(localize("Sounds"),"h3"),u=b("ol"),p.sounds.asArray().forEach(v=>c(v.name,"li",u))); -e(p.variables);r.length&&(c(localize("Scripts"),"h3"),r.forEach(v=>{d(v instanceof BlockMorph?v.scriptPic():v.fullImage()).attributes.class="script"}));f(p.customBlocks)});a=g.globalVariables();if(Object.keys(a.vars).length||g.globalBlocks.length)b("hr"),c(localize("For all Sprites"),"a",b("li",n)).attributes.href="#global",c(localize("For all Sprites"),"h2").attributes.id="global",e(a),f(g.globalBlocks);this.saveFileAs(""+m.toString(),"text/html;charset=utf-8",h)}; +e(p.variables);r.length&&(c(localize("Scripts"),"h3"),r.forEach(v=>{d(v instanceof BlockMorph?v.scriptPic():v.fullImage()).attributes.class="script"}));f(p.customBlocks)});a=g.globalVariables();if(Object.keys(a.vars).length||g.globalBlocks.length)b("hr"),c(localize("For all Sprites"),"a",b("li",n)).attributes.href="#global",c(localize("For all Sprites"),"h2").attributes.id="global",e(a),f(g.globalBlocks);this.saveFileAs(""+m.toString(),"text/html;charset=utf-8",k)}; IDE_Morph.prototype.openProjectString=function(a){var b;this.exitReplayMode();this.nextSteps([()=>b=this.showMessage("Opening project..."),()=>SnapActions.openProject(a).then(()=>b.destroy())])}; IDE_Morph.prototype.rawOpenProjectString=async function(a){this.toggleAppMode(!1);this.spriteBar.tabBar.tabTo("scripts");StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping=!1;StageMorph.prototype.enableInheritance=!0;StageMorph.prototype.enableSublistIDs=!1;StageMorph.prototype.enablePenLogging=!1;Process.prototype.enableLiveCoding=!1;if(Process.prototype.isCatchingErrors)try{var b=this.serializer.openProject(await this.serializer.load(a, this),this)}catch(c){this.showMessage("Load failed: "+c)}else b=this.serializer.openProject(await this.serializer.load(a,this),this);this.stopFastTracking();return b};IDE_Morph.prototype.openCloudDataString=function(a){const b=Math.round(a.length/1024);this.exitReplayMode();const c=this.showMessage("Opening project\n"+b+" KB...");return SnapActions.openProject(a).then(()=>c.destroy())}; @@ -2185,10 +2184,10 @@ IDE_Morph.prototype.rawOpenSpritesString=function(a){if(Process.prototype.isCatc IDE_Morph.prototype.openScriptString=function(a){var b;return new Promise(c=>{this.nextSteps([()=>b=this.showMessage("Opening script..."),()=>{const d=this.rawOpenScriptString(a);b.destroy();c(d)}])})}; IDE_Morph.prototype.rawOpenScriptString=function(a){if(Process.prototype.isCatchingErrors)try{var b=this.serializer.parse(a,this.currentSprite);var c=this.serializer.loadScript(b,this.currentSprite)}catch(d){this.showMessage("Load failed: "+d)}else b=this.serializer.loadScript(a,this.currentSprite),c=this.serializer.loadScript(b,this.currentSprite);return c}; IDE_Morph.prototype.openDataString=async function(a,b,c){const d=this.showMessage(localize("Opening data..."));await utils.sleep();await this.rawOpenDataString(a,b,c);d.destroy()}; -IDE_Morph.prototype.rawOpenDataString=function(a,b,c){var d,e=this.currentSprite.globalVariables();switch(c){case "csv":var f=Process.prototype.parseCSV(a);break;case "json":f=Process.prototype.parseJSON(a);break;default:f=a}var g=function(h){var m=e.names(),l=h.indexOf("(");h=0>l?h:h.substring(0,l);l=1;for(var k=h;contains(m,k);)l+=1,k=h+"("+l+")";return k}(b||"data");return SnapActions.addVariable(g,!0).then(()=>{e.setVar(g,f);this.currentSprite.toggleVariableWatcher(g,!0);this.flushBlocksCache("variables"); -this.currentCategory="variables";this.categories.children.forEach(function(h){h.refresh()});this.refreshPalette(!0);f instanceof List&&(d=new TableDialogMorph(f),d.labelString=localize(d.labelString)+": "+g,d.createLabel(),d.popUp(this.world()))})};IDE_Morph.prototype.openProject=function(a){a&&(this.performerMode=!1,this.showMessage("opening project\n"+a),this.setProjectName(a),a=localStorage["-snap-project-"+a],SnapUndo.reset(),this.openProjectString(a),this.setURL("#open:"+a))}; +IDE_Morph.prototype.rawOpenDataString=function(a,b,c){var d,e=this.currentSprite.globalVariables();switch(c){case "csv":var f=Process.prototype.parseCSV(a);break;case "json":f=Process.prototype.parseJSON(a);break;default:f=a}var g=function(k){var m=e.names(),l=k.indexOf("(");k=0>l?k:k.substring(0,l);l=1;for(var h=k;contains(m,h);)l+=1,h=k+"("+l+")";return h}(b||"data");return SnapActions.addVariable(g,!0).then(()=>{e.setVar(g,f);this.currentSprite.toggleVariableWatcher(g,!0);this.flushBlocksCache("variables"); +this.currentCategory="variables";this.categories.children.forEach(function(k){k.refresh()});this.refreshPalette(!0);f instanceof List&&(d=new TableDialogMorph(f),d.labelString=localize(d.labelString)+": "+g,d.createLabel(),d.popUp(this.world()))})};IDE_Morph.prototype.openProject=function(a){a&&(this.performerMode=!1,this.showMessage("opening project\n"+a),this.setProjectName(a),a=localStorage["-snap-project-"+a],SnapUndo.reset(),this.openProjectString(a),this.setURL("#open:"+a))}; IDE_Morph.prototype.setURL=function(a){location.hash=this.projectsInURLs?a:""}; -IDE_Morph.prototype.saveFileAs=function(a,b,c){var d=!1,e=this.world();var f=b.split("/")[1].split(";")[0];f="."+("plain"===f?"txt":f);try{d=!!new Blob}catch(h){}if(d){if(!(a instanceof Blob)){a=e=a;d=e.split(",");var g=0===e.indexOf("data:");if(g&&-1{b instanceof DialogBoxMorph?a.add(b):b.destroy()});this.flushBlocksCache();this.refreshPalette();a.reactToDropOf=b=>{b instanceof DialogBoxMorph||b instanceof MenuMorph||(a.hand.grabOrigin?b.slideBackTo(a.hand.grabOrigin):a.hand.grab(b))};this.showMessage("entering user mode", 1)};IDE_Morph.prototype.switchToDevMode=function(){var a=this.world();a.isDevMode=!0;Process.prototype.isCatchingErrors=!1;this.controlBar.updateLabel();this.isAutoFill=!1;this.isDraggable=!0;this.setExtent(a.extent().subtract(100));this.setPosition(a.position().add(20));this.flushBlocksCache();this.refreshPalette();delete a.reactToDropOf;this.showMessage("entering development mode.\n\nerror catching is turned off,\nuse the browser's web console\nto see error messages.")}; @@ -2205,11 +2204,11 @@ this.embedPlayButton.mouseClickLeft=function(){a.runScripts();a.embedOverlay.des IDE_Morph.prototype.toggleAppMode=function(a){var b=this.world(),c=[this.logo,this.controlBar.cloudButton,this.controlBar.projectButton,this.controlBar.settingsButton,this.controlBar.steppingButton,this.controlBar.stageSizeButton,this.paletteHandle,this.stageHandle,this.corral,this.corralBar,this.spriteEditor,this.spriteBar,this.palette,this.categories];(this.isAppMode=isNil(a)?!this.isAppMode:a)?((this.wasSingleStepping=Process.prototype.enableSingleStepping)&&this.toggleSingleStepping(),this.setColor(this.appModeColor), this.controlBar.setColor(this.color),this.controlBar.appModeButton.refresh(),c.forEach(d=>d.hide()),b.children.forEach(d=>{d instanceof DialogBoxMorph&&d.hide()}),b.keyboardFocus instanceof ScriptFocusMorph&&b.keyboardFocus.stopEditing()):(this.wasSingleStepping&&!Process.prototype.enableSingleStepping&&this.toggleSingleStepping(),this.setColor(this.backgroundColor),this.controlBar.setColor(this.frameColor),c.forEach(d=>d.show()),this.stage.setScale(1),b.children.forEach(d=>{d instanceof DialogBoxMorph&& d.show()}),b.allChildren().filter(d=>d instanceof ScrollFrameMorph).forEach(d=>d.adjustScrollBars()),this.currentSprite===this.stage&&this.spriteBar.children.forEach(d=>{d instanceof PushButtonMorph&&d.hide()}),this.currentSprite.scripts.updateToolbar());this.setExtent(this.world().extent());this.isMobileDevice()&&this.isAppMode&&this.mobileMode.init()}; -IDE_Morph.prototype.toggleStageSize=function(a,b){function c(){e.isSmallStage=isNil(a)?!e.isSmallStage:a}function d(m){e.isSmallStage=!0;g.animations.push(new Animation(l=>{e.stageRatio=l;e.setExtent(g.extent())},()=>e.stageRatio,m-e.stageRatio,f,null,()=>{e.isSmallStage=1!==m;e.controlBar.stageSizeButton.refresh()}))}var e=this;b=b||.5;var f=this.isAnimating?100:0,g=this.world(),h=18===g.currentKey;16===g.currentKey?(b=3*SpriteIconMorph.prototype.thumbSize.x/this.stage.dimensions.x,this.isSmallStage&& -b!==this.stageRatio||c()):h?(b=this.width()/2/this.stage.dimensions.x,this.isSmallStage&&b!==this.stageRatio||c()):c();this.isSmallStage?d(b):d(1)};IDE_Morph.prototype.setPaletteWidth=function(a){var b=this.isAnimating?100:0,c=this.world();c.animations.push(new Animation(d=>{this.paletteWidth=d;this.setExtent(c.extent())},()=>this.paletteWidth,a-this.paletteWidth,b))}; +IDE_Morph.prototype.toggleStageSize=function(a,b){function c(){e.isSmallStage=isNil(a)?!e.isSmallStage:a}function d(m){e.isSmallStage=!0;g.animations.push(new Animation(l=>{e.stageRatio=l;e.setExtent(g.extent())},()=>e.stageRatio,m-e.stageRatio,f,null,()=>{e.isSmallStage=1!==m;e.controlBar.stageSizeButton.refresh()}))}var e=this;b=b||.5;var f=this.isAnimating?100:0,g=this.world(),k=18===g.currentKey;16===g.currentKey?(b=3*SpriteIconMorph.prototype.thumbSize.x/this.stage.dimensions.x,this.isSmallStage&& +b!==this.stageRatio||c()):k?(b=this.width()/2/this.stage.dimensions.x,this.isSmallStage&&b!==this.stageRatio||c()):c();this.isSmallStage?d(b):d(1)};IDE_Morph.prototype.setPaletteWidth=function(a){var b=this.isAnimating?100:0,c=this.world();c.animations.push(new Animation(d=>{this.paletteWidth=d;this.setExtent(c.extent())},()=>this.paletteWidth,a-this.paletteWidth,b))}; IDE_Morph.prototype.createNewProject=function(){this.confirm("Replace the current project with a new one?","New Project",()=>{this.exitReplayMode();SnapUndo.reset();this.newProject()})};IDE_Morph.prototype.openProjectsBrowser=function(){"file:"===location.protocol?this.importLocalFile():(new ProjectDialogMorph(this,"open")).popUp(this.world())}; IDE_Morph.prototype.saveProjectsBrowser=function(){"file:"===location.protocol?this.prompt("Export Project As...",a=>this.exportProject(a,!1),null,"exportProject"):("examples"===this.source&&(this.source=null),(new ProjectDialogMorph(this,"save")).popUp(this.world()))}; -IDE_Morph.prototype.microphoneMenu=function(){var a=new MenuMorph(this),b=this.world(),c=this.controlBar.settingsButton.bottomLeft(),d=this.stage.microphone,e=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),f=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),g=e.fullCopy();g.render=nop;d.isReady&&(a.addItem([f,localize("Microphone")],()=>d.stop()),a.addLine());["low","normal","high","max"].forEach((h,m)=>{a.addItem([d.resolution===m+1?e:g,localize(h)],()=>d.setResolution(m+ +IDE_Morph.prototype.microphoneMenu=function(){var a=new MenuMorph(this),b=this.world(),c=this.controlBar.settingsButton.bottomLeft(),d=this.stage.microphone,e=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),f=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),g=e.fullCopy();g.render=nop;d.isReady&&(a.addItem([f,localize("Microphone")],()=>d.stop()),a.addLine());["low","normal","high","max"].forEach((k,m)=>{a.addItem([d.resolution===m+1?e:g,localize(k)],()=>d.setResolution(m+ 1))});a.popup(b,c)};IDE_Morph.prototype.languageMenu=function(){var a=new MenuMorph(this),b=this.world(),c=this.controlBar.settingsButton.bottomLeft(),d=new SymbolMorph("tick",.75*MorphicPreferences.menuFontSize),e=d.fullCopy();e.render=nop;SnapTranslator.languages().forEach(f=>a.addItem([SnapTranslator.language===f?d:e,SnapTranslator.languageName(f)],()=>{this.loadNewProject=!1;this.setLanguage(f)}));a.popup(b,c)}; IDE_Morph.prototype.setLanguage=function(a,b,c){var d=document.getElementById("language"),e=this.resourceURL("locale","lang-"+a+".js");SnapTranslator.unload();d&&document.head.removeChild(d);if("en"===a)return this.reflectLanguage("en",b,c);d=document.createElement("script");d.id="language";d.onload=()=>this.reflectLanguage(a,b,c);document.head.appendChild(d);d.src=e}; IDE_Morph.prototype.reflectLanguage=function(a,b,c){var d=location.hash;SnapTranslator.language=a;if(!this.loadNewProject)if(Process.prototype.isCatchingErrors)try{var e=this.serializer.serialize(this.stage)}catch(f){this.showMessage("Serialization failed: "+f)}else e=this.serializer.serialize(this.stage);SpriteMorph.prototype.initBlocks();this.spriteBar.tabBar.tabTo("scripts");this.createCategories();this.createCorralBar();this.fixLayout();this.loadNewProject?(this.newProject(),location.hash=d): @@ -2299,8 +2298,8 @@ ProjectsDialogSource.prototype.init=function(a,b,c,d){ProjectsDialogSource.uber. CloudProjectsSource.prototype.constructor=CloudProjectsSource;CloudProjectsSource.uber=ProjectsDialogSource.prototype;function CloudProjectsSource(a){this.init(a,"Cloud","cloud")}CloudProjectsSource.prototype.publish=async function(a,b=!1){const c=this.ide.cloud;a.state=b?await c.unpublishProject(a.id):await c.publishProject(a.id);a.id===c.projectId&&this.ide.updateUrlQueryString(a)}; CloudProjectsSource.prototype.open=async function(a){var b=a.id;const c=Object.keys(a.roles).shift();b=await this.ide.cloud.getRole(b,c);await this.ide.rawLoadCloudRole(a,b)};CloudProjectsSource.prototype.list=async function(){if(!this.ide.cloud.username)throw Error("Login Required.");const a=await this.ide.cloud.getProjectList();a.forEach(b=>{b.public="Public"===b.state||"PendingApproval"===b.state});return a}; CloudProjectsSource.prototype.getPreview=async function(a,b){const c=new Date(1E3*a.updated.secs_since_epoch);return{thumbnail:this.ide.cloud.api.getProjectThumbnailUrl(a.id,b),notes:a.notes||"",details:localize("last changed")+"\n"+c}}; -CloudProjectsSource.prototype.save=async function(a,b={}){var c=!1!==b.allowRetry,d=!0===b.overwrite;if(a.name!==this.ide.room.name){var e=await this.ide.cloud.getProjectData();await this.ide.cloud.renameProject(a.name);if("Saved"===e.saveState){var f=utils.pick(e,["owner","name","roles","saveState"]);f.roles=Object.values(f.roles);f=await this.ide.cloud.importProject(f);"Private"!==e.state&&await this.ide.cloud.publishProject(f.id)}}const g=this.ide.sockets.getSerializedProject();try{const h=await this.ide.callCloudSilently(m=> -m.saveRole(g));this.ide.updateUrlQueryString(h)}catch(h){if(c&&404===h.status)c=await this.ide.cloud.newProject(a.name),e=Object.keys(c.roles).shift(),this.ide.cloud.setLocalState(c.id,e),b.allowRetry=!1,await this.save(a,b);else throw this.ide.cloud.onerror(h),h;}b=this.ide.room.name!==a.name;d&&b&&(d=await this.ide.cloud.getProjectMetadataByName(this.ide.room.ownerId,a.name),await this.ide.cloud.deleteProject(d.id),await this.ide.cloud.renameProject(a.name))}; +CloudProjectsSource.prototype.save=async function(a,b={}){var c=!1!==b.allowRetry,d=!0===b.overwrite;if(a.name!==this.ide.room.name){var e=await this.ide.cloud.getProjectData();await this.ide.cloud.renameProject(a.name);if("Saved"===e.saveState){var f=utils.pick(e,["owner","name","roles","saveState"]);f.roles=Object.values(f.roles);f=await this.ide.cloud.importProject(f);"Private"!==e.state&&await this.ide.cloud.publishProject(f.id)}}const g=this.ide.sockets.getSerializedProject();try{const k=await this.ide.callCloudSilently(m=> +m.saveRole(g));this.ide.updateUrlQueryString(k)}catch(k){if(c&&404===k.status)c=await this.ide.cloud.newProject(a.name),e=Object.keys(c.roles).shift(),this.ide.cloud.setLocalState(c.id,e),b.allowRetry=!1,await this.save(a,b);else throw this.ide.cloud.onerror(k),k;}b=this.ide.room.name!==a.name;d&&b&&(d=await this.ide.cloud.getProjectMetadataByName(this.ide.room.ownerId,a.name),await this.ide.cloud.deleteProject(d.id),await this.ide.cloud.renameProject(a.name))}; CloudProjectsSource.prototype.delete=async function(a){await this.ide.cloud.deleteProject(a.id)};SharedCloudProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);SharedCloudProjectsSource.prototype.constructor=SharedCloudProjectsSource;SharedCloudProjectsSource.uber=ProjectsDialogSource.prototype;function SharedCloudProjectsSource(a){this.init(a,"Shared with me","cloud","cloud-shared")} SharedCloudProjectsSource.prototype.list=async function(){if(!this.ide.cloud.username)throw Error("Login Required.");return this.ide.cloud.getSharedProjectList()};SharedCloudProjectsSource.prototype.delete=function(a){this.ide.cloud.removeCollaborator(this.ide.cloud.username,a.id)};SharedCloudProjectsSource.prototype.open=CloudProjectsSource.prototype.open; SharedCloudProjectsSource.prototype.getPreview=function(a,b){const c=new Date(1E3*a.updated.secs_since_epoch);return{thumbnail:this.ide.cloud.api.getProjectThumbnailUrl(a.id,b),notes:a.notes||"",details:localize("last changed")+"\n"+c}};BrowserProjectsSource.prototype=Object.create(ProjectsDialogSource.prototype);BrowserProjectsSource.prototype.constructor=BrowserProjectsSource;BrowserProjectsSource.uber=ProjectsDialogSource.prototype; @@ -2377,7 +2376,7 @@ JukeboxMorph.prototype.step=function(){this.soundsVersion!==this.sprite.sounds.l JukeboxMorph.prototype.reactToDropOf=function(a){var b=0,c=a.object,d=a.top();a.destroy();this.contents.children.forEach(e=>{e instanceof SoundIconMorph&&e.top()g;g+=1)0g;g+=1)0g;g+=1)0g;g+=1)0{this.videoElement.srcObject=d;this.videoElement.play().catch(a);this.videoElement.stream=d}).catch(a);this.videoView.setExtent(c.dimensions);this.videoView.cachedImage=newCanvas(c.dimensions,!0,this.videoView.cachedImage);this.videoView.drawOn=function(d,e){var f=b.videoElement.videoWidth,g=b.videoElement.videoHeight;e=c.dimensions.x;var h=c.dimensions.y;if(f){d.save();d.translate(e,0);d.scale(-1,1);if(f/ -e>g/h){var m=g/h*e;f=g}else m=f,f=f/e*h;d.drawImage(b.videoElement,0,0,m,f,-1*this.left(),this.top(),e,h);d.restore()}};this.videoView.step=function(){this.changed()};this.addBody(new AlignmentMorph("column",this.padding/2));this.body.add(this.videoView);this.body.fixLayout();this.addButton("ok","Save");this.addButton("cancel","Cancel");this.fixLayout();this.rerender()};CamSnapshotDialogMorph.prototype.ok=function(){this.accept((new Costume(this.videoView.fullImage(),this.sprite.newCostumeName("camera"))).flipped())}; +navigator.mediaDevices.getUserMedia&&navigator.mediaDevices.getUserMedia({video:!0}).then(d=>{this.videoElement.srcObject=d;this.videoElement.play().catch(a);this.videoElement.stream=d}).catch(a);this.videoView.setExtent(c.dimensions);this.videoView.cachedImage=newCanvas(c.dimensions,!0,this.videoView.cachedImage);this.videoView.drawOn=function(d,e){var f=b.videoElement.videoWidth,g=b.videoElement.videoHeight;e=c.dimensions.x;var k=c.dimensions.y;if(f){d.save();d.translate(e,0);d.scale(-1,1);if(f/ +e>g/k){var m=g/k*e;f=g}else m=f,f=f/e*k;d.drawImage(b.videoElement,0,0,m,f,-1*this.left(),this.top(),e,k);d.restore()}};this.videoView.step=function(){this.changed()};this.addBody(new AlignmentMorph("column",this.padding/2));this.body.add(this.videoView);this.body.fixLayout();this.addButton("ok","Save");this.addButton("cancel","Cancel");this.fixLayout();this.rerender()};CamSnapshotDialogMorph.prototype.ok=function(){this.accept((new Costume(this.videoView.fullImage(),this.sprite.newCostumeName("camera"))).flipped())}; CamSnapshotDialogMorph.prototype.disable=function(){CamSnapshotDialogMorph.prototype.enabled=!1;document.dispatchEvent(new Event("cameraDisabled"))};CamSnapshotDialogMorph.prototype.destroy=function(){this.oncancel.call(this);this.close()};CamSnapshotDialogMorph.prototype.close=function(){this.videoElement&&this.videoElement.stream&&(this.videoElement.stream.getTracks()[0].stop(),this.videoElement.remove());CamSnapshotDialogMorph.uber.destroy.call(this)};SoundRecorderDialogMorph.prototype=new DialogBoxMorph; SoundRecorderDialogMorph.prototype.constructor=SoundRecorderDialogMorph;SoundRecorderDialogMorph.uber=DialogBoxMorph.prototype;function SoundRecorderDialogMorph(a){this.init(a)} SoundRecorderDialogMorph.prototype.init=function(a){var b=this;this.padding=10;this.accept=a;this.mediaRecorder=null;this.audioElement=document.createElement("audio");this.audioElement.hidden=!0;this.audioElement.onended=function(c){b.stop()};document.body.appendChild(this.audioElement);this.playButton=this.stopButton=this.recordButton=null;this.progressBar=new BoxMorph;SoundRecorderDialogMorph.uber.init.call(this);this.labelString="Sound Recorder";this.createLabel();this.buildContents()}; @@ -2405,20 +2404,20 @@ PaintEditorMorph.prototype.buildContents=function(){var a=this;this.paper=new Pa this.toolbox=new BoxMorph;this.toolbox.color=SpriteMorph.prototype.paletteColor.lighter(8);this.toolbox.borderColor=this.toolbox.color.lighter(40);MorphicPreferences.isFlat&&(this.toolbox.edge=0);this.buildToolbox();this.controls.add(this.toolbox);this.scaleBox=new AlignmentMorph("row",this.padding/2);this.buildScaleBox();this.controls.add(this.scaleBox);this.propertiesControls={colorpicker:null,penSizeSlider:null,penSizeField:null,primaryColorButton:null,primaryColorViewer:null,constrain:null};this.populatePropertiesMenu(); this.addButton("ok","OK");this.addButton("cancel","Cancel");this.refreshToolButtons();this.fixLayout()}; PaintEditorMorph.prototype.buildToolbox=function(){var a={brush:"Paintbrush tool\n(free draw)",rectangle:"Stroked Rectangle\n(shift: square)",circle:"Stroked Ellipse\n(shift: circle)",eraser:"Eraser tool",crosshairs:"Set the rotation center",line:"Line tool\n(shift: vertical/horizontal)",rectangleSolid:"Filled Rectangle\n(shift: square)",circleSolid:"Filled Ellipse\n(shift: circle)",paintbucket:"Fill a region",pipette:"Pipette tool\n(pick a color anywhere)"},b=this,c=this.toolbox.left(),d=this.toolbox.top(), -e=0,f=0;Object.keys(a).forEach(function(g){var h=b.toolButton(g,a[g]);h.setPosition(new Point(c+e,d+f));e+=h.width()+2;"crosshairs"===g&&(e=0,f+=h.height()+2,b.paper.drawcrosshair());b.toolbox[g]=h;b.toolbox.add(h)});this.toolbox.bounds=this.toolbox.fullBounds().expandBy(10)}; +e=0,f=0;Object.keys(a).forEach(function(g){var k=b.toolButton(g,a[g]);k.setPosition(new Point(c+e,d+f));e+=k.width()+2;"crosshairs"===g&&(e=0,f+=k.height()+2,b.paper.drawcrosshair());b.toolbox[g]=k;b.toolbox.add(k)});this.toolbox.bounds=this.toolbox.fullBounds().expandBy(10)}; PaintEditorMorph.prototype.buildEdits=function(){var a=this,b=this.paper;this.edits.add(this.pushButton("undo",function(){b.undo()}));this.edits.add(this.pushButton("clear",function(){b.clearCanvas()}));this.edits.add(this.pushButton("Vector",function(){0{setTimeout(()=>{a.switchToVector()})}):a.switchToVector()}));this.edits.fixLayout()}; PaintEditorMorph.prototype.buildScaleBox=function(){var a=this.paper;this.scaleBox.add(this.pushButton(new SymbolMorph("grow",18),function(){a.scale(.05,.05)},"grow"));this.scaleBox.add(this.pushButton(new SymbolMorph("shrink",18),function(){a.scale(-.05,-.05)},"shrink"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipHorizontal",18),function(){a.scale(-2,0)},"flip horizontal"));this.scaleBox.add(this.pushButton(new SymbolMorph("flipVertical",18),function(){a.scale(0,-2)},"flip vertical")); this.scaleBox.fixLayout()}; PaintEditorMorph.prototype.openIn=function(a,b,c,d,e){var f=this;this.oldim=b;this.callback=d||nop;this.ide=e;this.processKeyUp=function(){f.shift=!1;f.propertiesControls.constrain.refresh()};this.processKeyDown=function(){f.shift=16===f.world().currentKey;f.propertiesControls.constrain.refresh()};this.oldim&&(this.paper.automaticCrosshairs=isNil(c),this.paper.centermerge(this.oldim,this.paper.paper),this.paper.rotationCenter=(c||new Point(0,0)).add(new Point((this.paper.paper.width-this.oldim.width)/ 2,(this.paper.paper.height-this.oldim.height)/2)),this.paper.drawNew());this.key="paint";this.popUp(a)};PaintEditorMorph.prototype.fixLayout=function(){this.changed();this.paper&&(this.paper.buildContents(),this.paper.drawNew());this.controls&&this.controls.fixLayout();this.body&&this.body.fixLayout();PaintEditorMorph.uber.fixLayout.call(this);this.changed()};PaintEditorMorph.prototype.refreshToolButtons=function(){this.toolbox.children.forEach(function(a){a.refresh()})}; PaintEditorMorph.prototype.ok=function(){this.paper.updateAutomaticCenter();this.callback(this.paper.paper,this.paper.rotationCenter);this.destroy()};PaintEditorMorph.prototype.cancel=function(){if(this.oncancel)this.oncancel();this.destroy()};PaintEditorMorph.prototype.switchToVector=function(){this.object=new SVG_Costume(new Image,"",new Point(0,0));this.object.edit(this.world(),this.ide,!0)}; -PaintEditorMorph.prototype.populatePropertiesMenu=function(){var a=this.controls,b=this,c=this.propertiesControls,d=new AlignmentMorph("row",this.padding),e=new AlignmentMorph("column",3);e.alignment="left";c.primaryColorViewer=new Morph;c.primaryColorViewer.isCachingImage=!0;c.primaryColorViewer.render=function(f){var g=b.paper.settings.primarycolor,h;if("transparent"===g)for(g=0;180>g;g+=5)for(h=0;15>h;h+=5)f.fillStyle=0===(h+g)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",f.fillRect(g,h,5,5); +PaintEditorMorph.prototype.populatePropertiesMenu=function(){var a=this.controls,b=this,c=this.propertiesControls,d=new AlignmentMorph("row",this.padding),e=new AlignmentMorph("column",3);e.alignment="left";c.primaryColorViewer=new Morph;c.primaryColorViewer.isCachingImage=!0;c.primaryColorViewer.render=function(f){var g=b.paper.settings.primarycolor,k;if("transparent"===g)for(g=0;180>g;g+=5)for(k=0;15>k;k+=5)f.fillStyle=0===(k+g)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",f.fillRect(g,k,5,5); else f.fillStyle=g.toString(),f.fillRect(0,0,180,15);f.strokeStyle="black";f.lineWidth=Math.min(b.paper.settings.linewidth,20);f.beginPath();f.lineCap="round";f.moveTo(20,30);f.lineTo(160,30);f.stroke()};c.primaryColorViewer.setExtent(new Point(180,40));c.primaryColorViewer.color=new Color(0,0,0);c.colorpicker=new PaintColorPickerMorph(new Point(180,100),function(f){b.paper.settings.primarycolor=f;c.primaryColorViewer.rerender()});c.colorpicker.isCachingImage=!0;c.colorpicker.action(new Color(0,0, 0));c.penSizeSlider=new SliderMorph(0,20,5,5);c.penSizeSlider.orientation="horizontal";c.penSizeSlider.setHeight(15);c.penSizeSlider.setWidth(150);c.penSizeSlider.action=function(f){c.penSizeField&&c.penSizeField.setContents(f);b.paper.settings.linewidth=f;c.colorpicker.action(b.paper.settings.primarycolor)};c.penSizeField=new InputFieldMorph("5",!0,null,!1);c.penSizeField.contents().minWidth=20;c.penSizeField.setWidth(25);c.penSizeField.accept=function(){var f=parseFloat(c.penSizeField.getValue()); c.penSizeSlider.value=f;c.penSizeSlider.updateValue();this.setContents(f);b.paper.settings.linewidth=f;this.world().keyboardFocus=b;c.colorpicker.action(b.paper.settings.primarycolor)};d.add(c.penSizeSlider);d.add(c.penSizeField);d.color=b.color;d.fixLayout();c.penSizeField.fixLayout();c.constrain=new ToggleMorph("checkbox",this,function(){b.shift=!b.shift},"Constrain proportions of shapes?\n(you can also hold shift)",function(){return b.shift});c.constrain.label.isBold=!1;a.add(c.colorpicker);a.add(c.primaryColorViewer); e.add(new StringMorph(localize("Brush size")+":",10,null,!0));e.add(d);e.add(c.constrain);e.fixLayout();a.add(e)};PaintEditorMorph.prototype.toolButton=function(a,b){var c=this;var d=new ToggleButtonMorph(null,this,function(){c.paper.currentTool=a;c.paper.toolChanged(a);c.refreshToolButtons();"pipette"===a&&c.getUserColor()},new SymbolMorph(a,18),function(){return c.paper.currentTool===a});d.hint=b;return d}; PaintEditorMorph.prototype.pushButton=function(a,b,c){return new PushButtonMorph(this,b,a,null,c)}; -PaintEditorMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=getDocumentPositionOf(b.worldCanvas),e=c.processMouseMove,f=c.processMouseDown,g=c.processMouseUp;c.processMouseMove=function(h){c.setPosition(new Point(h.pageX-d.x,h.pageY-d.y));h=b.getGlobalPixelColor(c.position());h.a&&(h.a=1,a.propertiesControls.colorpicker.action(h))};c.processMouseDown=nop;c.processMouseUp=function(){a.paper.currentTool="brush";a.paper.toolChanged("brush");a.refreshToolButtons();c.processMouseMove= +PaintEditorMorph.prototype.getUserColor=function(){var a=this,b=this.world(),c=b.hand,d=getDocumentPositionOf(b.worldCanvas),e=c.processMouseMove,f=c.processMouseDown,g=c.processMouseUp;c.processMouseMove=function(k){c.setPosition(new Point(k.pageX-d.x,k.pageY-d.y));k=b.getGlobalPixelColor(c.position());k.a&&(k.a=1,a.propertiesControls.colorpicker.action(k))};c.processMouseDown=nop;c.processMouseUp=function(){a.paper.currentTool="brush";a.paper.toolChanged("brush");a.refreshToolButtons();c.processMouseMove= e;c.processMouseDown=f;c.processMouseUp=g}};PaintColorPickerMorph.prototype=new Morph;PaintColorPickerMorph.prototype.constructor=PaintColorPickerMorph;PaintColorPickerMorph.uber=Morph.prototype;function PaintColorPickerMorph(a,b){this.init(a,b)}PaintColorPickerMorph.prototype.init=function(a,b){this.isCachingImage=!0;this.setExtent(a||new Point(200,100));this.action=b||nop}; PaintColorPickerMorph.prototype.render=function(a){var b,c;for(b=0;b2*this.width()/3&&a.subtract(this.position()).y>this.height()-10?this.action("transparent"):this.action(this.getPixelColor(a))};PaintColorPickerMorph.prototype.mouseMove=PaintColorPickerMorph.prototype.mouseDownLeft;PaintCanvasMorph.prototype=new Morph; @@ -2430,14 +2429,14 @@ PaintCanvasMorph.prototype.cacheUndo=function(){var a=newCanvas(this.extent(),!0 PaintCanvasMorph.prototype.centermerge=function(a,b){b.getContext("2d").drawImage(a,(b.width-a.width)/2,(b.height-a.height)/2)};PaintCanvasMorph.prototype.clearCanvas=function(){this.buildContents();this.drawNew();this.changed()};PaintCanvasMorph.prototype.toolChanged=function(a){this.mask=newCanvas(this.extent(),!0,this.mask);"crosshairs"===a&&(this.updateAutomaticCenter(),this.drawcrosshair());this.drawNew();this.changed()}; PaintCanvasMorph.prototype.drawcrosshair=function(a){a=a||this.mask.getContext("2d");var b=this.rotationCenter;a.save();a.lineWidth=1;a.strokeStyle="black";a.clearRect(0,0,this.mask.width,this.mask.height);a.globalAlpha=.5;a.fillStyle="white";a.beginPath();a.arc(b.x,b.y,20,radians(0),radians(360),!1);a.closePath();a.fill();a.stroke();a.beginPath();a.arc(b.x,b.y,10,radians(0),radians(360),!1);a.stroke();a.beginPath();a.moveTo(0,b.y);a.lineTo(this.mask.width,b.y);a.stroke();a.beginPath();a.moveTo(b.x, 0);a.lineTo(b.x,this.mask.height);a.stroke();a.restore();this.drawNew()}; -PaintCanvasMorph.prototype.floodfill=function(a){var b=this.paper.width,c=this.paper.height,d=this.paper.getContext("2d"),e=d.getImageData(0,0,b,c),f=e.data;a=[Math.round(Math.round(a.y)*b+a.x)];var g=function(k){k*=4;return[f[k],f[k+1],f[k+2],f[k+3]]};var h=g(a[0]);var m=function(k){return k[0]===h[0]&&k[1]===h[1]&&k[2]===h[2]&&k[3]===h[3]};if(0!==h[3]||"transparent"!==this.settings.primarycolor)if(h[0]!==this.settings.primarycolor.r||h[1]!==this.settings.primarycolor.g||h[2]!==this.settings.primarycolor.b|| -h[3]!==255*this.settings.primarycolor.a)if(0!==h[3]||0!==this.settings.primarycolor.a){for(;0Math.abs(l)?d.lineTo(f,m):d.lineTo(h,g):d.lineTo(h, -m);d.stroke();break;case "circle":case "circleSolid":d.beginPath();if(this.isShiftPressed())d.arc(f,g,(new Point(f,g)).distanceTo(new Point(h,m)),0,2*Math.PI,!1);else{for(e=0;eMath.abs(l)?d.lineTo(f,m):d.lineTo(k,g):d.lineTo(k, +m);d.stroke();break;case "circle":case "circleSolid":d.beginPath();if(this.isShiftPressed())d.arc(f,g,(new Point(f,g)).distanceTo(new Point(k,m)),0,2*Math.PI,!1);else{for(e=0;ethis.threshold&&(this.motionDirection=((Math.atan2(b,a)*this.toDegree+270)%360-180).toFixed(2))}}; +VideoMotion.prototype.getStageMotion=function(){var a=0,b=0,c=0,d,e,f,g=2*this.winSize+1,k=this.width-this.winSize-1,m=this.height-this.winSize-1,l,h,n,p;if(!this.curr||!this.prev)this.motionAmount=this.motionDirection=-1;else if(this.lastAnalyzedFrame!==this.frameNumber){this.lastAnalyzedFrame=this.frameNumber;for(d=this.winSize+1;dthis.threshold&&(this.motionDirection=((Math.atan2(b,a)*this.toDegree+270)%360-180).toFixed(2))}}; VideoMotion.prototype.getMotionVector=function(a,b,c,d,e){var f=b*b-a*c;var g={u:0,v:0};f?(f=8/f,g.u=-(e*b-d*c)*f,g.v=-(b*d-a*e)*f):(f=(b+a)*(b+a)+(c+b)*(c+b))?(f=8/f,g.u=(b+a)*-(e+d)*f,g.v=(c+b)*-(e+d)*f):(g.u=0,g.v=0);return g}; -VideoMotion.prototype.getLocalMotion=function(a){var b=a.parentThatIsA(StageMorph),c=0,d=Math.floor(a.width()/b.scale),e=this.winSize,f=0,g=0,h=0,m=0,l=0,k=this.threshold/3,n=2E-4*this.amountScale,p=0,q;if(!this.curr||!this.prev)a.motionAmount=a.motionDirection=-1;else if(a.frameNumber!==this.frameNumber){var r=a.getImageData();var t=a.parentThatIsA(StageMorph);var u=t.scale;var v=q=0;var w=Math.floor(a.extent().x/u);var y=Math.floor(a.extent().y/u);a.left()t.right()&&(w=Math.max(Math.floor((t.right()-a.left())/u),0));a.top()t.bottom()&&(y=Math.max(Math.floor((t.bottom()-a.top())/u),0));t=Math.max(Math.floor((a.left()-b.left())/b.scale),0);var x=Math.max(Math.floor((a.top()-b.top())/b.scale),0);u=Math.min(w+t,b.dimensions.x);b=Math.min(y+x,b.dimensions.y-1);q=v*d+q;for(v=x;v>24&255)){var z=v*this.width+x;y=this.prev[z]-this.curr[z];var A=this.curr[z-1]-this.curr[z+1];z=this.curr[z-this.width]-this.curr[z+this.width];f+=A*A;g+=A*z;h+=z*z;l+=A*y;m+=z*y;p++}d=this.getMotionVector(f,g,h,l,m);p&&(c=p,p/=4*e*e,d.u/=p,d.v/=p);a.motionAmount=Math.round(n*c*Math.hypot(d.u,d.v));100k&&(a.motionDirection=((Math.atan2(d.v,d.u)*this.toDegree+270)%360-180).toFixed(2)); +u;x++,++q)if(0>24&255)){var z=v*this.width+x;y=this.prev[z]-this.curr[z];var A=this.curr[z-1]-this.curr[z+1];z=this.curr[z-this.width]-this.curr[z+this.width];f+=A*A;g+=A*z;k+=z*z;l+=A*y;m+=z*y;p++}d=this.getMotionVector(f,g,k,l,m);p&&(c=p,p/=4*e*e,d.u/=p,d.v/=p);a.motionAmount=Math.round(n*c*Math.hypot(d.u,d.v));100h&&(a.motionDirection=((Math.atan2(d.v,d.u)*this.toDegree+270)%360-180).toFixed(2)); a.frameNumber=this.frameNumber}};modules.sketch="2020-July-13";VectorShape.prototype={};VectorShape.prototype.constructor=VectorShape;VectorShape.uber=Object.prototype;function VectorShape(a,b,c){this.init(a,b,c)}VectorShape.prototype.init=function(a,b,c){this.borderWidth=b&&b.a?a:0;this.borderColor=b||new Color(0,0,0,0);this.fillColor=c||new Color(0,0,0,0);this.image=newCanvas();this.isCrosshair=this.isSelection=this.isPolygon=!1;this.origin=new Point;this.destination=new Point}; VectorShape.prototype.toString=function(){return"a "+(this.constructor.name||this.constructor.toString().split(" ")[1].split("(")[0])}; VectorShape.prototype.asSVG=function(a){a=new XML_Element(a);this.borderColor&&this.borderColor.a?(a.attributes.stroke=this.borderColor.toRGBstring(),a.attributes["stroke-linejoin"]="miter",a.attributes["stroke-width"]=this.borderWidth):a.attributes.stroke="none";a.attributes.fill=this.fillColor&&this.fillColor.a?this.fillColor.toRGBstring():"none";a.attributes.prototype=this.constructor.name;return a}; @@ -2487,7 +2486,7 @@ VectorPolygon.prototype.asSVG=function(){var a=VectorPolygon.uber.asSVG.call(thi VectorPolygon.prototype.drawOn=function(a){var b=this.points.map(function(d){return d.subtract(a.position())});this.image=newCanvas(a.extent());var c=this.image.getContext("2d");c.lineCap="round";c.lineJoin="round";c.beginPath();c.moveTo(b[0].x,b[0].y);b.slice(1).forEach(function(d){c.lineTo(d.x,d.y)});this.fillColor&&0a.distanceTo(c)?b:c})}; -VectorSelection.prototype.drawOn=function(a){function b(h,m){g.beginPath();g.arc(h-d.x,m-d.y,f,0,2*Math.PI);g.stroke()}var c=this.bounds(),d=a.position(),e=c.origin.subtract(d),f=this.threshold;this.image=newCanvas(a.extent());var g=this.image.getContext("2d");g.rect(e.x,e.y,this.width(),this.height());g.setLineDash([5]);g.stroke();g.setLineDash([]);b(c.left(),c.top());b(c.left(),c.bottom());b(c.right(),c.top());b(c.right(),c.bottom());a.redraw=!0};Crosshair.prototype=VectorShape; +VectorSelection.prototype.drawOn=function(a){function b(k,m){g.beginPath();g.arc(k-d.x,m-d.y,f,0,2*Math.PI);g.stroke()}var c=this.bounds(),d=a.position(),e=c.origin.subtract(d),f=this.threshold;this.image=newCanvas(a.extent());var g=this.image.getContext("2d");g.rect(e.x,e.y,this.width(),this.height());g.setLineDash([5]);g.stroke();g.setLineDash([]);b(c.left(),c.top());b(c.left(),c.bottom());b(c.right(),c.top());b(c.right(),c.bottom());a.redraw=!0};Crosshair.prototype=VectorShape; Crosshair.prototype.constructor=Crosshair;Crosshair.uber=VectorShape.prototype;function Crosshair(a,b){this.init(a,b)}Crosshair.prototype.init=function(a,b){this.center=a;this.paper=b;this.image=newCanvas();this.isCrosshair=!0};Crosshair.prototype.update=function(a){this.center=a.subtract(this.paper.position())};Crosshair.prototype.moveBy=function(a){this.center=this.center.add(a)}; Crosshair.prototype.drawOn=function(a){this.image=newCanvas(a.extent());a.rotationCenter=this.center.copy();a.drawcrosshair(this.image.getContext("2d"));a.redraw=!0};VectorPaintEditorMorph.prototype=new PaintEditorMorph;VectorPaintEditorMorph.prototype.constructor=VectorPaintEditorMorph;VectorPaintEditorMorph.uber=PaintEditorMorph.prototype;function VectorPaintEditorMorph(){this.init()} VectorPaintEditorMorph.prototype.init=function(){this.paper=null;this.shapes=[];this.selection=[];this.selecting=!1;this.originalSelection=null;this.resizing=this.moving=!1;this.lastDragPosition=null;this.history=[];this.clipboard=[];this.currentShape=null;VectorPaintEditorMorph.uber.init.call(this);this.labelString="Vector Paint Editor";this.createLabel();this.fixLayout()}; @@ -2495,17 +2494,17 @@ VectorPaintEditorMorph.prototype.buildEdits=function(){var a=this;this.edits.add a.convertToBitmap()}));this.edits.fixLayout()}; VectorPaintEditorMorph.prototype.convertToBitmap=function(){var a=newCanvas(StageMorph.prototype.dimensions),b=this;this.object=new Costume;this.shapes.forEach(function(c){a.getContext("2d").drawImage(c.image,0,0)});this.object.rotationCenter=this.paper.rotationCenter.copy();this.object.contents=a;this.object.edit(this.world(),this.ide,!1,null,()=>{b.ide.currentSprite.shadowAttribute("costumes");b.ide.currentSprite.addCostume(b.object);b.ide.spriteEditor.updateList();b.ide&&b.ide.currentSprite.wearCostume(b.object)})}; VectorPaintEditorMorph.prototype.buildScaleBox=function(){var a=this;["Top","Bottom","Up","Down"].forEach(function(b){a.scaleBox.add(a.pushButton(b,function(){a.changeSelectionLayer(b.toLowerCase())}))});this.scaleBox.fixLayout()}; -VectorPaintEditorMorph.prototype.openIn=function(a,b,c,d,e,f){var g=this;b=isNil(f)||0===f.length;VectorPaintEditorMorph.uber.openIn.call(this,a,null,c,d,e);this.ide=e;this.paper.drawNew();this.paper.changed();f.forEach(function(h){h.drawOn(g.paper)});this.shapes=f.map(function(h){return h.copy()});this.shapes.forEach(function(h){h.drawOn(g.paper)});c&&!b?(this.paper.automaticCrosshairs=!1,this.paper.rotationCenter=this.getBounds(this.shapes).origin.subtract(this.paper.bounds.origin).add(c)):this.paper.automaticCrosshairs= -!0;this.updateHistory();this.processKeyUp=function(){g.shift=!1;g.ctrl=!1;g.propertiesControls.constrain.refresh()};this.processKeyDown=function(h){g.shift=16===g.world().currentKey;g.ctrl=h.ctrlKey;switch(g.world().currentKey){case 46:case 8:g.sortSelection();g.selection.slice().reverse().forEach(function(m){g.shapes.splice(g.shapes.indexOf(m),1)});g.clearSelection();g.updateHistory();break;case 13:g.currentShape&&g.currentShape.isPolygon&&(g.currentShape.close(),g.currentShape.drawOn(g.paper),g.shapes.push(g.currentShape), -g.currentShape=null,g.updateHistory());break;case 33:g.changeSelectionLayer("up");break;case 34:g.changeSelectionLayer("down");break;case 35:g.changeSelectionLayer("bottom");break;case 36:g.changeSelectionLayer("top");break;case 90:g.ctrl&&g.undo();break;case 67:g.ctrl&&g.selection.length&&(g.clipboard=g.selection.map(function(m){return m.copy()}));break;case 86:h=g.world().hand.position();g.ctrl&&g.paper.bounds.containsPoint(h)&&(g.paper.pasteAt(h),g.updateHistory());break;case 65:g.ctrl&&(g.paper.currentTool= +VectorPaintEditorMorph.prototype.openIn=function(a,b,c,d,e,f){var g=this;b=isNil(f)||0===f.length;VectorPaintEditorMorph.uber.openIn.call(this,a,null,c,d,e);this.ide=e;this.paper.drawNew();this.paper.changed();f.forEach(function(k){k.drawOn(g.paper)});this.shapes=f.map(function(k){return k.copy()});this.shapes.forEach(function(k){k.drawOn(g.paper)});c&&!b?(this.paper.automaticCrosshairs=!1,this.paper.rotationCenter=this.getBounds(this.shapes).origin.subtract(this.paper.bounds.origin).add(c)):this.paper.automaticCrosshairs= +!0;this.updateHistory();this.processKeyUp=function(){g.shift=!1;g.ctrl=!1;g.propertiesControls.constrain.refresh()};this.processKeyDown=function(k){g.shift=16===g.world().currentKey;g.ctrl=k.ctrlKey;switch(g.world().currentKey){case 46:case 8:g.sortSelection();g.selection.slice().reverse().forEach(function(m){g.shapes.splice(g.shapes.indexOf(m),1)});g.clearSelection();g.updateHistory();break;case 13:g.currentShape&&g.currentShape.isPolygon&&(g.currentShape.close(),g.currentShape.drawOn(g.paper),g.shapes.push(g.currentShape), +g.currentShape=null,g.updateHistory());break;case 33:g.changeSelectionLayer("up");break;case 34:g.changeSelectionLayer("down");break;case 35:g.changeSelectionLayer("bottom");break;case 36:g.changeSelectionLayer("top");break;case 90:g.ctrl&&g.undo();break;case 67:g.ctrl&&g.selection.length&&(g.clipboard=g.selection.map(function(m){return m.copy()}));break;case 86:k=g.world().hand.position();g.ctrl&&g.paper.bounds.containsPoint(k)&&(g.paper.pasteAt(k),g.updateHistory());break;case 65:g.ctrl&&(g.paper.currentTool= "selection",g.paper.toolChanged("selection"),g.refreshToolButtons(),g.paper.selectShapes(g.shapes));break;case 27:g.clearSelection();break;case 37:g.moveSelectionBy(new Point(-1,0));g.updateHistory();break;case 38:g.moveSelectionBy(new Point(0,-1));g.updateHistory();break;case 39:g.moveSelectionBy(new Point(1,0));g.updateHistory();break;case 40:g.moveSelectionBy(new Point(0,1));g.updateHistory();break;default:nop()}g.propertiesControls.constrain.refresh()}}; VectorPaintEditorMorph.prototype.buildContents=function(){VectorPaintEditorMorph.uber.buildContents.call(this);this.paper.destroy();this.paper=new VectorPaintCanvasMorph(this.shift);this.paper.setExtent(StageMorph.prototype.dimensions);this.body.add(this.paper);this.refreshToolButtons();this.fixLayout()}; VectorPaintEditorMorph.prototype.buildToolbox=function(){var a={brush:"Paintbrush tool\n(free draw)",rectangle:"Rectangle\n(shift: square)",ellipse:"Ellipse\n(shift: circle)",selection:"Selection tool",crosshairs:"Set the rotation center",line:"Line tool\n(shift: constrain to 45\u00ba)",closedBrush:"Closed brush\n(free draw)",polygon:"Polygon",paintbucket:"Paint a shape\n(shift: edge color)",pipette:"Pipette tool\n(pick a color from anywhere\nshift: fill color)"},b=this,c=this.toolbox.left(),d=this.toolbox.top(), -e=0,f=0;Object.keys(a).forEach(function(g){var h=b.toolButton(g,a[g]);h.setPosition(new Point(c+e,d+f));e+=h.width()+2;"crosshairs"===g&&(e=0,f+=h.height()+2,b.paper.drawcrosshair());b.toolbox[g]=h;b.toolbox.add(h)});this.toolbox.bounds=this.toolbox.fullBounds().expandBy(10)}; -VectorPaintEditorMorph.prototype.populatePropertiesMenu=function(){var a=this.controls,b=this,c=this.propertiesControls,d=new AlignmentMorph("row",this.padding),e=new AlignmentMorph("row",this.padding),f=new AlignmentMorph("row",this.padding),g=new AlignmentMorph("column",3);g.alignment="left";c.primaryColorViewer=new Morph;c.primaryColorViewer.color=new Color(0,0,0);c.primaryColorViewer.setExtent(new Point(85,15));c.primaryColorViewer.render=function(h){b.renderColorSelection(h,b.paper.settings.primaryColor)}; -c.secondaryColorViewer=new Morph;c.secondaryColorViewer.color=new Color(0,0,0);c.secondaryColorViewer.setExtent(new Point(85,15));c.secondaryColorViewer.render=function(h){b.renderColorSelection(h,b.paper.settings.secondaryColor)};c.colorpicker=new PaintColorPickerMorph(new Point(180,100),function(h,m){b.selectColor(h,!m)});c.colorpicker.mouseDownRight=function(h){h.subtract(this.position()).x>2*this.width()/3&&h.subtract(this.position()).y>this.height()-10?this.action("transparent",!0):this.action(this.getPixelColor(h), -!0)};c.colorpicker.action(new Color(0,0,0));c.colorpicker.action("transparent",!0);c.penSizeSlider=new SliderMorph(0,20,5,5);c.penSizeSlider.orientation="horizontal";c.penSizeSlider.setHeight(15);c.penSizeSlider.setWidth(150);c.penSizeSlider.action=function(h){c.penSizeField&&c.penSizeField.setContents(h);b.paper.settings.lineWidth=h;b.selection.forEach(function(m){m.setBorderWidth(h);m.drawOn(b.paper);b.paper.updateSelection()});b.updateHistory()};c.penSizeField=new InputFieldMorph("3",!0,null,!1); -c.penSizeField.contents().minWidth=20;c.penSizeField.setWidth(25);c.penSizeField.accept=function(h){var m=parseFloat(c.penSizeField.getValue());c.penSizeSlider.value=m;c.penSizeSlider.updateValue();this.setContents(m);b.paper.settings.lineWidth=m;this.world().keyboardFocus=b;b.selection.forEach(function(l){l.setBorderWidth(h);l.drawOn(b.paper);b.paper.updateSelection()});b.updateHistory()};d.add(c.penSizeSlider);d.add(c.penSizeField);d.color=b.color;d.fixLayout();c.constrain=new ToggleMorph("checkbox", +e=0,f=0;Object.keys(a).forEach(function(g){var k=b.toolButton(g,a[g]);k.setPosition(new Point(c+e,d+f));e+=k.width()+2;"crosshairs"===g&&(e=0,f+=k.height()+2,b.paper.drawcrosshair());b.toolbox[g]=k;b.toolbox.add(k)});this.toolbox.bounds=this.toolbox.fullBounds().expandBy(10)}; +VectorPaintEditorMorph.prototype.populatePropertiesMenu=function(){var a=this.controls,b=this,c=this.propertiesControls,d=new AlignmentMorph("row",this.padding),e=new AlignmentMorph("row",this.padding),f=new AlignmentMorph("row",this.padding),g=new AlignmentMorph("column",3);g.alignment="left";c.primaryColorViewer=new Morph;c.primaryColorViewer.color=new Color(0,0,0);c.primaryColorViewer.setExtent(new Point(85,15));c.primaryColorViewer.render=function(k){b.renderColorSelection(k,b.paper.settings.primaryColor)}; +c.secondaryColorViewer=new Morph;c.secondaryColorViewer.color=new Color(0,0,0);c.secondaryColorViewer.setExtent(new Point(85,15));c.secondaryColorViewer.render=function(k){b.renderColorSelection(k,b.paper.settings.secondaryColor)};c.colorpicker=new PaintColorPickerMorph(new Point(180,100),function(k,m){b.selectColor(k,!m)});c.colorpicker.mouseDownRight=function(k){k.subtract(this.position()).x>2*this.width()/3&&k.subtract(this.position()).y>this.height()-10?this.action("transparent",!0):this.action(this.getPixelColor(k), +!0)};c.colorpicker.action(new Color(0,0,0));c.colorpicker.action("transparent",!0);c.penSizeSlider=new SliderMorph(0,20,5,5);c.penSizeSlider.orientation="horizontal";c.penSizeSlider.setHeight(15);c.penSizeSlider.setWidth(150);c.penSizeSlider.action=function(k){c.penSizeField&&c.penSizeField.setContents(k);b.paper.settings.lineWidth=k;b.selection.forEach(function(m){m.setBorderWidth(k);m.drawOn(b.paper);b.paper.updateSelection()});b.updateHistory()};c.penSizeField=new InputFieldMorph("3",!0,null,!1); +c.penSizeField.contents().minWidth=20;c.penSizeField.setWidth(25);c.penSizeField.accept=function(k){var m=parseFloat(c.penSizeField.getValue());c.penSizeSlider.value=m;c.penSizeSlider.updateValue();this.setContents(m);b.paper.settings.lineWidth=m;this.world().keyboardFocus=b;b.selection.forEach(function(l){l.setBorderWidth(k);l.drawOn(b.paper);b.paper.updateSelection()});b.updateHistory()};d.add(c.penSizeSlider);d.add(c.penSizeField);d.color=b.color;d.fixLayout();c.constrain=new ToggleMorph("checkbox", this,function(){b.shift=!b.shift},"Constrain proportions of shapes?\n(you can also hold shift)",function(){return b.shift});c.constrain.label.isBold=!1;e.add(c.secondaryColorViewer);e.add(c.primaryColorViewer);e.fixLayout();f.add(new TextMorph(localize("Edge color\n(left click)"),10,null,null,null,"center",85));f.add(new TextMorph(localize("Fill color\n(right click)"),10,null,null,null,"center",85));f.fixLayout();a.add(c.colorpicker);a.add(f);a.add(e);g.add(new StringMorph(localize("Brush size")+ ":",10,null,!0));g.add(d);g.add(c.constrain);g.fixLayout();a.add(g)};VectorPaintEditorMorph.prototype.selectColor=function(a,b){var c=this,d=this.paper.isShiftPressed()?!1:b;b=(d?"secondary":"primary")+"Color";this.paper.settings[b]=a;this.selection.length&&(this.selection.forEach(function(e){e.setColor(a,d);e.drawOn(c.paper)}),this.updateHistory());this.propertiesControls[b+"Viewer"].rerender()}; VectorPaintEditorMorph.prototype.renderColorSelection=function(a,b="transparent"){var c;if("transparent"===b||0===b.a)for(b=0;180>b;b+=5)for(c=0;15>c;c+=5)a.fillStyle=0===(c+b)/5%2?"rgba(0, 0, 0, 0.2)":"rgba(0, 0, 0, 0.5)",a.fillRect(b,c,5,5);else a.fillStyle=b.toString(),a.fillRect(0,0,180,15)}; @@ -2547,30 +2546,30 @@ List.prototype.cols=function(){var a=Math.min(10,this.length()),b=1,c;for(c=1;c< List.prototype.version=function(a,b,c,d){b=Math.min(a+b,this.length());var e=this.lastChanged,f;for(f=a;f<=b;f+=1)a=this.at(f),e=a instanceof Costume?Math.max(e,a.version):a instanceof List?Math.max(e,a.version(c,d)):Math.max(e,a.lastChanged?a.lastChanged:0);return e}; List.prototype.query=function(a){if(a.isEmpty())return this.map(c=>c);if(1===a.rank())return a.map(c=>this.at(c));var b=a.at(1);return(b instanceof List?b.isEmpty()?this.range(1,this.length()):b:new List([b])).map(c=>this.at(c)).map(c=>c instanceof List?c.query(a.cdr()):c)}; List.prototype.slice=function(a){if(a.isEmpty())return this.map(c=>c);if(1===a.rank())return this.rangify(a).map(c=>this.at(c));var b=a.at(1);return(b instanceof List?b.isEmpty()?this.range(1,this.length()):this.rangify(b):this.rangify(new List([b]))).map(c=>this.at(c)).map(c=>c instanceof List?c.slice(a.cdr()):c)}; -List.prototype.rangify=function(a){var b=[],c=this.length(),d=0,e,f;a.itemsArray().forEach(g=>{g=+g;0b.push(h))))});return new List(b)};List.prototype.range=function(a,b){return new List([...Array(Math.abs(b-a)+1)].map((c,d)=>a{g=+g;0b.push(k))))});return new List(b)};List.prototype.range=function(a,b){return new List([...Array(Math.abs(b-a)+1)].map((c,d)=>ae(g)):d.map(g=>e(f.at(g)))}}return b(this.rank(),a.cdr(),function(d){return function(e){return d.isEmpty()?e.map(f=>f):d.map(f=>e.at(f))}}(a.at(1)))(this)};List.prototype.size=function(){var a=0;this.deepMap(()=>a+=1);return a};List.prototype.ravel=function(){var a=[];this.deepMap(b=>a.push(b));return new List(a)}; List.prototype.rank=function(){var a=1,b=this.length(),c;for(c=1;c<=b;c+=1){var d=this.at(c);d instanceof List&&(a=Math.max(a,1+d.rank()))}return a};List.prototype.shape=function(){var a,b=this.rank(),c=new List([this.length()]),d;for(a=2;a<=b;a+=1){var e=0;var f=this.getDimension(a);var g=f.length();for(d=1;d<=g;d+=1)e=Math.max(e,f.at(d).length());c.add(e)}return c}; List.prototype.getDimension=function(a=0){return 1>a?new List:1===a?this.map(b=>b):2===a?new List(this.itemsArray().filter(b=>b instanceof List)):new List(this.getDimension(a-1).flatten().itemsArray().filter(b=>b instanceof List))};List.prototype.width=function(){var a,b=0,c=this.length();for(a=1;a<=c;a+=1){var d=this.at(a);b=Math.max(b,d instanceof List?d.length():0)}return b}; -List.prototype.flatten=function(){var a=[];this.itemsArray().forEach(b=>{b instanceof List?b.itemsArray().forEach(c=>a.push(c)):a.push(b)});return new List(a)};List.prototype.transpose=function(){return 2f instanceof List?f:new List(Array(b).fill(f)));var e=(f,g)=>f.map(h=>h.at(g));for(a=1;a<=b;a+=1)c.push(e(d,a));return new List(c)}; +List.prototype.flatten=function(){var a=[];this.itemsArray().forEach(b=>{b instanceof List?b.itemsArray().forEach(c=>a.push(c)):a.push(b)});return new List(a)};List.prototype.transpose=function(){return 2f instanceof List?f:new List(Array(b).fill(f)));var e=(f,g)=>f.map(k=>k.at(g));for(a=1;a<=b;a+=1)c.push(e(d,a));return new List(c)}; List.prototype.reshape=function(a){var b=this.ravel().itemsArray(),c=0;if(a.isEmpty())return b[0];var d=a.itemsArray().reduce((f,g)=>f*g);if(db.length&&2=b.length&&(c=0),e.push(b[c]),c+=1}return(new List(e)).folded(a)};List.prototype.folded=function(a){var b=a.length(),c=this;if(2>b)return this.map(d=>d);for(;1m.length()),d=c.itemsArray().reduce((m,l)=>m*l),e,f,g;if(1E6m.length()),d=c.itemsArray().reduce((m,l)=>m*l),e,f,g;if(1E6{e.push(f);'"'===f&&e.push(f)});e.push('"');return e.join("")}var b=this.itemsArray(),c=[];return b.some(d=>d instanceof List)?(b.forEach(d=>{d instanceof List?c.push(d.itemsArray().map(a).join(",")):c.push(a(d))}),c.join("\n")):b.map(a).join(",")}; -List.prototype.asJSON=function(a){function b(d,e){d=d.itemsArray();var f={};return c(d)?(d.forEach(g=>{var h=2===g.length()?g.at(2):void 0;f[g.at(1)]=h instanceof List?b(h,e):h}),f):d.map(g=>g instanceof List?b(g,e):g)}function c(d){if(d.every(f=>f instanceof List&&3>f.length())){var e=d.map(f=>f.at(1));return e.every(f=>{var g;if(g=isString(f))g=e.indexOf(f)===e.lastIndexOf(f);return g})}}return JSON.stringify(b(this,a))}; +List.prototype.asJSON=function(a){function b(d,e){d=d.itemsArray();var f={};return c(d)?(d.forEach(g=>{var k=2===g.length()?g.at(2):void 0;f[g.at(1)]=k instanceof List?b(k,e):k}),f):d.map(g=>g instanceof List?b(g,e):g)}function c(d){if(d.every(f=>f instanceof List&&3>f.length())){var e=d.map(f=>f.at(1));return e.every(f=>{var g;if(g=isString(f))g=e.indexOf(f)===e.lastIndexOf(f);return g})}}return JSON.stringify(b(this,a))}; List.prototype.canBeTXT=function(){return this.itemsArray().every(a=>isString(a)||"number"===typeof a)};List.prototype.asTXT=function(){return this.itemsArray().join("\n")}; List.prototype.equalTo=function(a){var b=this,c=a,d,e;if(!(a instanceof List))return!1;for(;b.isLinked&&c.isLinked;){if(!snapEquals(b.first,c.first))return!1;b=b.rest;c=c.rest}c.isLinked&&(a=c,c=b,b=a);for(d=0;b.isLinked;){if(!snapEquals(b.first,c.contents[d]))return!1;b=b.rest;d+=1}a=0;if(b.contents.length!==c.contents.length-d)return!1;for(e=b.contents.length;0!isNaN(+a)&&"boolean"!==typeof a||isString(a)||a instanceof List&&a.hasOnlyAtomicData())};List.prototype.canBeJSON=function(){return this.itemsArray().every(a=>!isNaN(+a)||isString(a)||!0===a||!1===a||a instanceof List&&a.canBeJSON())};List.prototype.hasOnlyAtomicData=function(){return this.itemsArray().every(a=>!isNaN(+a)&&"boolean"!==typeof a||isString(a))}; -List.prototype.blockify=function(a=500,b=[0]){var c=SpriteMorph.prototype.blockForSelector("reportNewList"),d=c.inputs()[0],e=this.length(),f;c.isDraggable=!0;d.removeInput();for(f=0;f{m instanceof CellMorph&&(m.contentsMorph instanceof ListWatcherMorph?m.contentsMorph.update():(isSnapObject(m.contents)||m.contents instanceof Costume)&&m.update())});if(this.lastUpdated===this.list.lastChanged&&!a)return null;this.updateLength(!0);this.start=Math.max(Math.min(this.start,Math.floor((this.list.length()-1)/this.range)*this.range+1),1);var b=Math.min(this.start+this.range-1,this.list.length());var c= -Math.min(3*(b-this.start+1),this.frame.contents.children.length);for(a=0;aa;)this.frame.contents.children[a].destroy(); -c=a;a=this.frame.contents.children.length;h=Date.now();if(c>a+1)for(a;aa;)this.frame.contents.children[a].destroy(); +c=a;a=this.frame.contents.children.length;k=Date.now();if(c>a+1)for(a;athis.setStartIndex(e),null,this);c.addItem("1...",1);for(a=1;a{d instanceof TemplateSlotMorph&&"\u2191"===d.contents()&&d.setContents(b.inputNames()[e])});this.isGlobal&&this.initializeVariables(this.variables.vars);this.forceNormalColoring();this.fixBlockColor(null,!0)}; CustomCommandBlockMorph.prototype.restoreInputs=function(a){var b=0,c;this.isPrototype||(this.cachedInputs=null,this.inputs().forEach(d=>{c=a[b];c instanceof ReporterBlockMorph&&!(d instanceof TemplateSlotMorph)?this.replaceInput(d,c.fullCopy()):c instanceof InputSlotMorph&&d instanceof InputSlotMorph?c.isEmptySlot()?d.setContents(""):d.setContents(c.evaluate()):c instanceof BooleanSlotMorph&&d instanceof BooleanSlotMorph?d.setContents(c.evaluate()):c instanceof TemplateSlotMorph&&d instanceof TemplateSlotMorph? d.setContents(c.evaluate()):c instanceof CSlotMorph&&d instanceof CSlotMorph&&d.nestedBlock(c.evaluate());b+=1}),this.cachedInputs=null)};CustomCommandBlockMorph.prototype.refreshDefaults=function(a){var b=0;this.inputs().forEach(c=>{(c instanceof InputSlotMorph||c instanceof BooleanSlotMorph)&&c.setContents((a||this.definition).defaultValueOfInputIdx(b));b+=1});this.cachedInputs=null}; -CustomCommandBlockMorph.prototype.refreshPrototype=function(){var a=[],b=this,c,d,e=0;if(!this.isPrototype)return null;var f=this.parentThatIsA(PrototypeHatBlockMorph);this.parts().forEach(h=>{h.fragment.isDeleted||(h.fragment.type?a.push(h.fragment):(c=b.definition.parseSpec(h.fragment.labelString),c.forEach(m=>{d=h.fragment.copy();d.labelString=m;a.push(d)})))});var g=this.specFromFragments()||this.blockSpec;this instanceof CustomCommandBlockMorph&&("reporter"===f.type||"predicate"===f.type)?(b= -new CustomReporterBlockMorph(this.definition,"predicate"===f.type,!0),f.replaceInput(this,b)):this instanceof CustomReporterBlockMorph&&("command"===f.type?(b=new CustomCommandBlockMorph(this.definition,!0),f.replaceInput(this,b)):(this.isPredicate="predicate"===f.type,this.fixLayout(),this.rerender()));b.setCategory(f.blockCategory||"other");f.fixBlockColor();b.setSpec(g);b.parts().forEach(h=>{h instanceof BlockLabelPlaceHolderMorph||(a[e]&&(h.fragment=a[e]),e+=1)});this.refreshPrototypeSlotTypes(); +CustomCommandBlockMorph.prototype.refreshPrototype=function(){var a=[],b=this,c,d,e=0;if(!this.isPrototype)return null;var f=this.parentThatIsA(PrototypeHatBlockMorph);this.parts().forEach(k=>{k.fragment.isDeleted||(k.fragment.type?a.push(k.fragment):(c=b.definition.parseSpec(k.fragment.labelString),c.forEach(m=>{d=k.fragment.copy();d.labelString=m;a.push(d)})))});var g=this.specFromFragments()||this.blockSpec;this instanceof CustomCommandBlockMorph&&("reporter"===f.type||"predicate"===f.type)?(b= +new CustomReporterBlockMorph(this.definition,"predicate"===f.type,!0),f.replaceInput(this,b)):this instanceof CustomReporterBlockMorph&&("command"===f.type?(b=new CustomCommandBlockMorph(this.definition,!0),f.replaceInput(this,b)):(this.isPredicate="predicate"===f.type,this.fixLayout(),this.rerender()));b.setCategory(f.blockCategory||"other");f.fixBlockColor();b.setSpec(g);b.parts().forEach(k=>{k instanceof BlockLabelPlaceHolderMorph||(a[e]&&(k.fragment=a[e]),e+=1)});this.refreshPrototypeSlotTypes(); f.fixLayout()};CustomCommandBlockMorph.prototype.refreshPrototypeSlotTypes=function(){this.parts().forEach(a=>{a instanceof BlockInputFragmentMorph&&(a.template().instantiationSpec=a.contents(),a.setContents(a.fragment.defTemplateSpecFragment()))});this.fixBlockColor(null,!0)};CustomCommandBlockMorph.prototype.inputFragmentNames=function(){var a=[];this.parts().forEach(b=>{!b.fragment.isDeleted&&b.fragment.type&&a.push(b.fragment.labelString)});return a}; CustomCommandBlockMorph.prototype.upvarFragmentNames=function(){var a=[];this.parts().forEach(b=>{b.fragment.isDeleted||"%upvar"!==b.fragment.type||a.push(b.fragment.labelString)});return a};CustomCommandBlockMorph.prototype.upvarFragmentName=function(a){return this.upvarFragmentNames()[a]||"\u2191"};CustomCommandBlockMorph.prototype.specFromFragments=function(){var a="";this.parts().forEach(b=>{b.fragment.isDeleted||(a=a+b.fragment.defSpecFragment()+" ")});return a.trim()}; CustomCommandBlockMorph.prototype.blockSpecFromFragments=function(){var a="";this.parts().forEach(b=>{b.fragment.isDeleted||(a=a+b.fragment.blockSpecFragment()+" ")});return a.trim()};CustomCommandBlockMorph.prototype.declarationsFromFragments=function(){var a=new Map;this.parts().forEach(b=>{b instanceof BlockInputFragmentMorph&&a.set(b.fragment.labelString,[b.fragment.type,b.fragment.defaultValue,b.fragment.options,b.fragment.isReadOnly])});return a}; @@ -2613,8 +2612,8 @@ this.blockSpec)){this.duplicateBlockDefinition();return}a=c.getMethod(this.seman CustomCommandBlockMorph.prototype.labelPart=function(a){if(!this.isPrototype)return CustomCommandBlockMorph.uber.labelPart.call(this,a);"%"===a[0]&&1d.usesBlockInstance(a,!1,e)):0c.inputs().length?f.addItem("block variables...",function(){c.enableBlockVars()},"experimental -\nunder construction"):f.addItem("remove block variables...",function(){c.enableBlockVars(!1)},"experimental -\nunder construction"))}else(f=this.constructor.uber.userMenu.call(this))?f.addLine():f=new MenuMorph(this),this.isTemplate?(this.isGlobal?f.addItem("delete block definition...","deleteBlockDefinition"):contains(Object.keys(d.inheritedBlocks()), this.blockSpec)?a("inherited",function(){var g=e.parentThatIsA(IDE_Morph);d.customBlocks.push(d.getMethod(e.blockSpec).copyAndBindTo(d));g&&(g.flushPaletteCache(),g.refreshPalette())},!0,"uncheck to\ndisinherit",null):d.exemplar&&d.exemplar.getMethod(this.blockSpec)?a("inherited","deleteBlockDefinition",!1,null,localize("check to inherit\nfrom")+" "+d.exemplar.name):f.addItem("delete block definition...","deleteBlockDefinition"),f.addItem("duplicate block definition...","duplicateBlockDefinition")): (this.isGlobal||contains(Object.keys(d.ownBlocks()),this.blockSpec))&&f.addItem("delete block definition...","deleteBlockDefinition"),this.variables.names().forEach(g=>b(g));f.addItem("edit...","edit");return f};CustomCommandBlockMorph.prototype.exportBlockDefinition=function(){var a=(new SnapSerializer).serialize(this.definition);this.parentThatIsA(IDE_Morph).saveXMLAs(a,this.spec)}; @@ -2630,17 +2629,17 @@ CustomReporterBlockMorph.prototype.declarationsFromFragments=CustomCommandBlockM CustomReporterBlockMorph.prototype.isInUse=CustomCommandBlockMorph.prototype.isInUse;CustomReporterBlockMorph.prototype.userMenu=CustomCommandBlockMorph.prototype.userMenu;CustomReporterBlockMorph.prototype.duplicateBlockDefinition=CustomCommandBlockMorph.prototype.duplicateBlockDefinition;CustomReporterBlockMorph.prototype.deleteBlockDefinition=CustomCommandBlockMorph.prototype.deleteBlockDefinition;CustomReporterBlockMorph.prototype.bubbleHelp=CustomCommandBlockMorph.prototype.bubbleHelp; CustomReporterBlockMorph.prototype.popUpbubbleHelp=CustomCommandBlockMorph.prototype.popUpbubbleHelp;CustomReporterBlockMorph.prototype.relabel=CustomCommandBlockMorph.prototype.relabel;CustomReporterBlockMorph.prototype.alternatives=CustomCommandBlockMorph.prototype.alternatives;JaggedBlockMorph.prototype=new ReporterBlockMorph;JaggedBlockMorph.prototype.constructor=JaggedBlockMorph;JaggedBlockMorph.uber=ReporterBlockMorph.prototype;function JaggedBlockMorph(a){this.init(a)} JaggedBlockMorph.prototype.init=function(a){JaggedBlockMorph.uber.init.call(this);a&&this.setSpec(a);if("%cs"===a||"%ca"===a)this.minWidth=25,this.fixLayout()}; -JaggedBlockMorph.prototype.outlinePath=function(a,b){var c=this.width(),d=this.position(),e=0;a.moveTo(b,b);a.lineTo(c-b,b);this.cSlots().forEach(m=>{m.outlinePath(a,b,m.position().subtract(d));e+=m.height()});var f=this.height()-e-b;var g=Math.round(f/this.jag);var h=f/g;for(f=0;f{m.outlinePath(a,b,m.position().subtract(d));e+=m.height()});var f=this.height()-e-b;var g=Math.round(f/this.jag);var k=f/g;for(f=0;fh.refresh());this.types.children.forEach(h=>{h.setColor(g);h.refresh()});this.labelString=a;this.createLabel();e&&this.setPicture(e);this.addButton("ok","OK");this.addButton("cancel","Cancel");f&&(this.types.destroy(),this.types=null);this.scopes.destroy();this.scopes=null;this.fixLayout();this.rerender(); +BlockDialogMorph.prototype.openForChange=function(a,b,c,d,e,f){var g=SpriteMorph.prototype.blockColor[b];this.key="changeABlock";this.category=b;this.blockType=c;this.categories.children.forEach(k=>k.refresh());this.types.children.forEach(k=>{k.setColor(g);k.refresh()});this.labelString=a;this.createLabel();e&&this.setPicture(e);this.addButton("ok","OK");this.addButton("cancel","Cancel");f&&(this.types.destroy(),this.types=null);this.scopes.destroy();this.scopes=null;this.fixLayout();this.rerender(); this.popUp(d)};BlockDialogMorph.prototype.createCategoryButtons=function(){SpriteMorph.prototype.categories.forEach(a=>this.addCategoryButton(a))}; BlockDialogMorph.prototype.addCategoryButton=function(a){var b=[IDE_Morph.prototype.frameColor,IDE_Morph.prototype.frameColor.darker(MorphicPreferences.isFlat?5:50),SpriteMorph.prototype.blockColor[a]];var c=new ToggleButtonMorph(b,this,()=>{this.category=a;this.categories.children.forEach(d=>d.refresh());this.types&&this.types.children.forEach(d=>d.setColor(b[2]));this.edit()},a[0].toUpperCase().concat(a.slice(1)),()=>this.category===a,null,null,75,!0);c.corner=8;c.padding=0;c.labelShadowOffset= new Point(-1,-1);c.labelShadowColor=b[1];c.labelColor=IDE_Morph.prototype.buttonLabelColor;MorphicPreferences.isFlat&&(c.labelPressColor=WHITE);c.contrast=this.buttonContrast;c.fixLayout();c.refresh();this.categories.add(c);return c}; -BlockDialogMorph.prototype.fixCategoriesLayout=function(){var a=this.categories.children[0].width(),b=this.categories.children[0].height(),c=Math.ceil(this.categories.children.length/2),d=this.categories.left(),e=this.categories.top(),f=0,g,h;this.categories.children.forEach(m=>{f+=1;g=Math.ceil(f/2);h=2-f%2;m.setPosition(new Point(d+(15*h+(h-1)*a),e+(2*g+(g-1)*b+10)))});MorphicPreferences.isFlat&&(this.categories.corner=0,this.categories.border=0,this.categories.edge=0);this.categories.setExtent(new Point(45+ +BlockDialogMorph.prototype.fixCategoriesLayout=function(){var a=this.categories.children[0].width(),b=this.categories.children[0].height(),c=Math.ceil(this.categories.children.length/2),d=this.categories.left(),e=this.categories.top(),f=0,g,k;this.categories.children.forEach(m=>{f+=1;g=Math.ceil(f/2);k=2-f%2;m.setPosition(new Point(d+(15*k+(k-1)*a),e+(2*g+(g-1)*b+10)))});MorphicPreferences.isFlat&&(this.categories.corner=0,this.categories.border=0,this.categories.edge=0);this.categories.setExtent(new Point(45+ 2*a,2*(c+1)+c*b+20))}; BlockDialogMorph.prototype.createTypeButtons=function(){var a=SpriteMorph.prototype.blockColor[this.category];var b=new CommandBlockMorph;b.setColor(a);b.setSpec(localize("Command"));this.addBlockTypeButton(()=>this.setType("command"),b,()=>"command"===this.blockType);b=new ReporterBlockMorph;b.setColor(a);b.setSpec(localize("Reporter"));this.addBlockTypeButton(()=>this.setType("reporter"),b,()=>"reporter"===this.blockType);b=new ReporterBlockMorph(!0);b.setColor(a);b.setSpec(localize("Predicate"));this.addBlockTypeButton(()=> this.setType("predicate"),b,()=>"predicate"===this.blockType)};BlockDialogMorph.prototype.addBlockTypeButton=function(a,b,c){a=new ToggleElementMorph(this,a,b,c,null,null,"rebuild");a.refresh();a.fixLayout();this.types.add(a);return a}; @@ -2654,7 +2653,7 @@ this.bounds.setHeight(this.height()+this.categories.height()+this.padding)));thi this.padding));this.scopes&&(this.scopes.fixLayout(),this.bounds.setHeight(this.height()+this.scopes.height()+this.padding/3),this.bounds.setWidth(Math.max(this.width(),this.scopes.width()+2*this.padding)),this.scopes.setCenter(this.center()),this.types&&this.scopes.setTop(this.types.bottom()+this.padding/3));this.buttons&&0this.updateDefinition(),b);this.key="editBlock"+a.spec;this.labelString=this.definition.isGlobal?"Block Editor":"Method Editor";this.createLabel();var d=new ScriptsMorph;d.rejectsHats=!0;d.isDraggable=!1;d.color=IDE_Morph.prototype.groupColor;d.cachedTexture= -IDE_Morph.prototype.scriptsPaneTexture;d.cleanUpMargin=10;var e=new PrototypeHatBlockMorph(this.definition);e.setPosition(d.position().add(10));null!==a.comment&&(b=a.comment.fullCopy(),e.comment=b,b.block=e);null!==a.body&&e.nextBlock(c?a.body.expression:a.body.expression.fullCopy());d.add(e);e.fixBlockColor(null,!0);this.definition.scripts.forEach(g=>{f=g.fullCopy();f.setPosition(d.position().add(g.position()));d.add(f);f instanceof BlockMorph&&f.allComments().forEach(h=>h.align(f))});e.allComments().forEach(g=> +IDE_Morph.prototype.scriptsPaneTexture;d.cleanUpMargin=10;var e=new PrototypeHatBlockMorph(this.definition);e.setPosition(d.position().add(10));null!==a.comment&&(b=a.comment.fullCopy(),e.comment=b,b.block=e);null!==a.body&&e.nextBlock(c?a.body.expression:a.body.expression.fullCopy());d.add(e);e.fixBlockColor(null,!0);this.definition.scripts.forEach(g=>{f=g.fullCopy();f.setPosition(d.position().add(g.position()));d.add(f);f instanceof BlockMorph&&f.allComments().forEach(k=>k.align(f))});e.allComments().forEach(g=> g.align(e));a=new ScrollFrameMorph(d);a.padding=10;a.growth=50;a.isDraggable=!1;a.acceptsDrops=!1;a.contents.acceptsDrops=!0;d.scrollFrame=a;d.updateToolbar();this.addBody(a);this.addButton("ok","Done");this.setExtent(new Point(375,300));this.fixLayout();d.fixMultiArgs();var f=e.parts()[0];f.forceNormalColoring();f.fixBlockColor(e,!0)};BlockEditorMorph.prototype.mouseClickLeft=function(){this.target.parentThatIsA(IDE_Morph).setActiveEditor(this)};BlockEditorMorph.prototype.onSetActive=function(){this.body.contents.updateToolbar()}; BlockEditorMorph.prototype.onUnsetActive=function(){this.body.contents.hideToolbar()};BlockEditorMorph.prototype.popUp=function(a){var b=this.target.world();if(b){BlockEditorMorph.uber.popUp.call(this,b);this.setInitialDimensions(a);this.handle=new HandleMorph(this,280,220,this.corner,this.corner);b.keyboardReceiver=null;var c=this.target.parentThatIsA(IDE_Morph);a||c.setActiveEditor(this);b.keyboardFocus=null}};BlockEditorMorph.prototype.justDropped=function(){nop()}; BlockEditorMorph.prototype.accept=function(a){if(!(a instanceof CursorMorph)){if(this.action)if("function"===typeof this.target)"function"===typeof this.action?this.target.call(this.environment,this.action.call()):this.target.call(this.environment,this.action);else if("function"===typeof this.action)this.action.call(this.target,this.getInput());else this.target[this.action](this.getInput());(a=this.target.parentThatIsA(IDE_Morph))&&a.activeEditor===this&&a.setActiveEditor();this.close()}}; @@ -2727,8 +2726,8 @@ VariableDialogMorph.prototype.fixLayout=function(){var a=fontHeight(this.titleFo this.padding),this.bounds.setWidth(Math.max(this.width(),this.types.width()+2*this.padding)),this.types.setCenter(this.center()),this.body?this.types.setTop(this.body.bottom()+this.padding):this.categories&&this.types.setTop(this.categories.bottom()+this.padding));this.buttons&&0this.exportBlocks(d),null);this.labelString="Export blocks / message types";this.createLabel();this.buildContents()}; -BlockExportDialogMorph.prototype.buildContents=function(){var a,b,c,d=this.target;var e=new ScrollFrameMorph(null,null,SpriteMorph.prototype.sliderColor);e.color=SpriteMorph.prototype.paletteColor;e.padding=4;e.isDraggable=!1;e.acceptsDrops=!1;e.contents.acceptsDrops=!1;var f=e.left()+4;var g=e.top()+4;SpriteMorph.prototype.categories.forEach(l=>{this.blocks.forEach(k=>{k.category===l&&(c&&l!==c&&(g+=4),c=l,a=k.templateInstance(),b=new ToggleMorph("checkbox",this,()=>{var n=this.blocks.indexOf(k); --1contains(this.blocks,k),null,null,a.fullImage()),b.setPosition(new Point(f,g+(b.top()-b.toggleElement.top()))),e.addContents(b),g+=b.fullBounds().height()+4)})});this.msgs=[];for(var h=0;h{b=new ToggleMorph("checkbox",this,()=>{this.msgs.includes(l)?this.msgs.splice(this.msgs.indexOf(l), +BlockExportDialogMorph.prototype.buildContents=function(){var a,b,c,d=this.target;var e=new ScrollFrameMorph(null,null,SpriteMorph.prototype.sliderColor);e.color=SpriteMorph.prototype.paletteColor;e.padding=4;e.isDraggable=!1;e.acceptsDrops=!1;e.contents.acceptsDrops=!1;var f=e.left()+4;var g=e.top()+4;SpriteMorph.prototype.categories.forEach(l=>{this.blocks.forEach(h=>{h.category===l&&(c&&l!==c&&(g+=4),c=l,a=h.templateInstance(),b=new ToggleMorph("checkbox",this,()=>{var n=this.blocks.indexOf(h); +-1contains(this.blocks,h),null,null,a.fullImage()),b.setPosition(new Point(f,g+(b.top()-b.toggleElement.top()))),e.addContents(b),g+=b.fullBounds().height()+4)})});this.msgs=[];for(var k=0;k{b=new ToggleMorph("checkbox",this,()=>{this.msgs.includes(l)?this.msgs.splice(this.msgs.indexOf(l), 1):this.msgs.push(l)},null,()=>this.msgs.includes(l),null,null,l.fullImage());b.setPosition(new Point(f,g+(b.top()-b.toggleElement.top())));e.addContents(b);g+=b.fullBounds().height()+4});e.scrollX(4);e.scrollY(4);this.addBody(e);this.addButton("ok","OK");this.addButton("cancel","Cancel");this.setExtent(new Point(220,300));this.fixLayout()}; BlockExportDialogMorph.prototype.popUp=function(a){if(a=a||this.target.world())BlockExportDialogMorph.uber.popUp.call(this,a),this.handle=new HandleMorph(this,200,220,this.corner,this.corner)};BlockExportDialogMorph.prototype.userMenu=function(){var a=new MenuMorph(this,"select");a.addItem("all","selectAll");a.addItem("none","selectNone");return a};BlockExportDialogMorph.prototype.selectAll=function(){this.body.contents.children.forEach(a=>{a.state||a.trigger()})}; BlockExportDialogMorph.prototype.selectNone=function(){this.blocks=[];this.body.contents.children.forEach(a=>{a.refresh()})}; @@ -2748,14 +2747,14 @@ Table.prototype.addCol=function(a,b){var c;if(a)for(c=0;c';this.media.forEach(c=>{c=c.toXML(this).replace("~",this.format('mediaID="@"',c[this.mediaIdProperty]));b+=c});return b+""};SnapSerializer.prototype.load=function(a,b){return this.loadProjectModel(this.parse(a),b)}; SnapSerializer.prototype.getPortableXML=function(a){var b=this.isSavingPortable,c=this.isSavingHistory;this.isSavingPortable=!0;this.isSavingHistory=!1;a.getPortableDependencies&&(this.dependencies=a.getPortableDependencies());a=this.store(a);this.isSavingPortable=b;this.isSavingHistory=c;this.dependencies=null;return a}; SnapSerializer.prototype.loadProjectModelSync=function(a,b,c){var d=a.attributes.app;d=d?d.split(" ")[0]:null;b&&d&&d!==this.app.split(" ")[0]&&b.inform(d+" Project","This project has been created by a different app:\n\n"+d+"\n\nand may be incompatible or fail to load here.");a=this.rawLoadProjectModel(a,c);this.objects={};return a}; -SnapSerializer.prototype.loadProjectModel=async function(a,b,c){function d(e,f){const g=e[f];if(g){var h=utils.defer();e[f]=function(){g(...arguments);h.resolve()};return h.promise}}a=this.loadProjectModelSync(a,b,c);a.pentrails&&await d(a.pentrails,"onload");return a}; +SnapSerializer.prototype.loadProjectModel=async function(a,b,c){function d(e,f){const g=e[f];if(g){var k=utils.defer();e[f]=function(){g(...arguments);k.resolve()};return k.promise}}a=this.loadProjectModelSync(a,b,c);a.pentrails&&await d(a.pentrails,"onload");return a}; SnapSerializer.prototype.rawLoadProjectModel=function(a,b){var c,d,e={sprites:{},undo:{allEvents:[],eventHistory:{},undoCount:{}}};this.project=e;var f=d=d=d=d=d=d=f=c=c=void 0;if(+a.attributes.version>this.version)throw"Project uses newer version of Serializer";this.objects={};e.name=a.attributes.name;if(!e.name){for(c=1;Object.prototype.hasOwnProperty.call(localStorage,"-snap-project-Untitled "+c);)c+=1;e.name="Untitled "+c}if(c=a.childNamed("notes"))e.notes=c.contents;c=a.childNamed("variables"); e.globalVariables=new VariableFrame;e.collabStartIndex=+(a.attributes.collabStartIndex||0);e.undo.allEvents=this.loadReplayHistory(a.childNamed("replay"));f=a.require("stage");StageMorph.prototype.frameRate=0;e.stage=new StageMorph(e.globalVariables);e.stage.remixID=b;Object.prototype.hasOwnProperty.call(f.attributes,"id")&&(this.objects[f.attributes.id]=e.stage);f.attributes.name&&(e.stage.name=f.attributes.name);f.attributes.color&&(e.stage.color=this.loadColor(f.attributes.color),e.stage.cachedHSV= e.stage.color.hsv());"true"===f.attributes.scheduled&&(e.stage.fps=30,StageMorph.prototype.frameRate=30);f.attributes.volume&&(e.stage.volume=+f.attributes.volume);f.attributes.pan&&(e.stage.pan=+f.attributes.pan);f.attributes.penlog&&(StageMorph.prototype.enablePenLogging="true"===f.attributes.penlog);if(d=f.childNamed("pentrails"))e.pentrails=new Image,e.pentrails.onload=function(){e.stage.trailsCanvas&&(normalizeCanvas(e.stage.trailsCanvas),e.stage.trailsCanvas.getContext("2d").drawImage(e.pentrails, 0,0),e.stage.changed())},e.pentrails.src=d.contents;e.stage.setTempo(f.attributes.tempo);StageMorph.prototype.dimensions=new Point(480,360);f.attributes.width&&(StageMorph.prototype.dimensions.x=Math.max(+f.attributes.width,240));f.attributes.height&&(StageMorph.prototype.dimensions.y=Math.max(+f.attributes.height,180));e.stage.id=f.attributes.collabId||null;e.stage.setExtent(StageMorph.prototype.dimensions);SpriteMorph.prototype.useFlatLineEnds="flat"===f.attributes.lines;BooleanSlotMorph.prototype.isTernary= "false"!==f.attributes.ternary;Process.prototype.enableHyperOps="false"!==f.attributes.hyperops;e.stage.isThreadSafe="true"===f.attributes.threadsafe;StageMorph.prototype.enableCodeMapping="true"===f.attributes.codify;StageMorph.prototype.enableInheritance="false"!==f.attributes.inheritance;StageMorph.prototype.enableSublistIDs="true"===f.attributes.sublistIDs;(d=a.childNamed("hidden"))&&d.contents.split(" ").forEach(g=>{g&&(StageMorph.prototype.hiddenPrimitives[g]=!0)});(d=a.childNamed("headers"))&& d.children.forEach(g=>StageMorph.prototype.codeHeaders[g.tag]=g.contents);(d=a.childNamed("code"))&&d.children.forEach(g=>StageMorph.prototype.codeMappings[g.tag]=g.contents);(d=f.childNamed("messageTypes"))&&d.children.forEach(this.loadMessageType.bind(this,e.stage));if(d=a.childNamed("blocks"))this.loadCustomBlocks(e.stage,d,!0),this.populateCustomBlocks(e.stage,d,!0);this.loadObject(e.stage,f);this.loadHistory(a.childNamed("history"));f=f.require("sprites");e.sprites[e.stage.name]=e.stage;f.childrenNamed("sprite").forEach(g=> -this.loadValue(g));this.project.stage.children.forEach(g=>{var h;g.inheritanceInfo&&((h=this.project.sprites[g.inheritanceInfo.exemplar])&&g.setExemplar(h),g.inheritedAttributes=g.inheritanceInfo.delegated||[],g.updatePropagationCache());g.nestingInfo&&((h=this.project.sprites[g.nestingInfo.anchor])&&h.attachPart(g),g.rotatesWithAnchor="true"===g.nestingInfo.synch)});this.project.stage.children.forEach(g=>{var h;g.nestingInfo&&(g.nestingScale=+(g.nestingInfo.scale||g.scale),delete g.nestingInfo); -["scripts","costumes","sounds"].forEach(m=>{g.inheritsAttribute(m)&&g.refreshInheritedAttribute(m)});g.inheritsAttribute("costumes")&&(h=g.inheritsAttribute("costume #")?g.exemplar.costume:g.costumes.asArray()[g.inheritanceInfo.costumeNumber-1])&&(h.loaded?g.wearCostume(h,!0):h.loaded=function(){this.loaded=!0;g.wearCostume(h,!0)});delete g.inheritanceInfo});c&&this.loadVariables(e.globalVariables,c);f.childrenNamed("watcher").forEach(g=>{var h=this.loadColor(g.attributes.color);var m=Object.prototype.hasOwnProperty.call(g.attributes, -"scope")?e.sprites[g.attributes.scope]:null;var l=Object.prototype.hasOwnProperty.call(g.attributes,"hidden")&&"false"!==g.attributes.hidden;h=Object.prototype.hasOwnProperty.call(g.attributes,"var")?new WatcherMorph(g.attributes["var"],h,isNil(m)?e.globalVariables:m.variables,g.attributes["var"],l):new WatcherMorph(localize(this.watcherLabels[g.attributes.s]),h,m,g.attributes.s,l);h.setStyle(g.attributes.style||"normal");"slider"===h.style&&(h.setSliderMin(g.attributes.min||"1",!0),h.setSliderMax(g.attributes.max|| -"100",!0));h.setPosition(e.stage.topLeft().add(new Point(+g.attributes.x||0,+g.attributes.y||0)));e.stage.add(h);h.onNextStep=function(){this.currentValue=null};h.currentValue instanceof List&&h.cellMorph.contentsMorph&&((m=g.attributes.extX)&&h.cellMorph.contentsMorph.setWidth(+m),(g=g.attributes.extY)&&h.cellMorph.contentsMorph.setHeight(+g),h.cellMorph.contentsMorph.handle.fixLayout())});this.project.stage.children.forEach(g=>g.inheritedMethodsCache=[]);this.objects={};return e}; +this.loadValue(g));this.project.stage.children.forEach(g=>{var k;g.inheritanceInfo&&((k=this.project.sprites[g.inheritanceInfo.exemplar])&&g.setExemplar(k),g.inheritedAttributes=g.inheritanceInfo.delegated||[],g.updatePropagationCache());g.nestingInfo&&((k=this.project.sprites[g.nestingInfo.anchor])&&k.attachPart(g),g.rotatesWithAnchor="true"===g.nestingInfo.synch)});this.project.stage.children.forEach(g=>{var k;g.nestingInfo&&(g.nestingScale=+(g.nestingInfo.scale||g.scale),delete g.nestingInfo); +["scripts","costumes","sounds"].forEach(m=>{g.inheritsAttribute(m)&&g.refreshInheritedAttribute(m)});g.inheritsAttribute("costumes")&&(k=g.inheritsAttribute("costume #")?g.exemplar.costume:g.costumes.asArray()[g.inheritanceInfo.costumeNumber-1])&&(k.loaded?g.wearCostume(k,!0):k.loaded=function(){this.loaded=!0;g.wearCostume(k,!0)});delete g.inheritanceInfo});c&&this.loadVariables(e.globalVariables,c);f.childrenNamed("watcher").forEach(g=>{var k=this.loadColor(g.attributes.color);var m=Object.prototype.hasOwnProperty.call(g.attributes, +"scope")?e.sprites[g.attributes.scope]:null;var l=Object.prototype.hasOwnProperty.call(g.attributes,"hidden")&&"false"!==g.attributes.hidden;k=Object.prototype.hasOwnProperty.call(g.attributes,"var")?new WatcherMorph(g.attributes["var"],k,isNil(m)?e.globalVariables:m.variables,g.attributes["var"],l):new WatcherMorph(localize(this.watcherLabels[g.attributes.s]),k,m,g.attributes.s,l);k.setStyle(g.attributes.style||"normal");"slider"===k.style&&(k.setSliderMin(g.attributes.min||"1",!0),k.setSliderMax(g.attributes.max|| +"100",!0));k.setPosition(e.stage.topLeft().add(new Point(+g.attributes.x||0,+g.attributes.y||0)));e.stage.add(k);k.onNextStep=function(){this.currentValue=null};k.currentValue instanceof List&&k.cellMorph.contentsMorph&&((m=g.attributes.extX)&&k.cellMorph.contentsMorph.setWidth(+m),(g=g.attributes.extY)&&k.cellMorph.contentsMorph.setHeight(+g),k.cellMorph.contentsMorph.handle.fixLayout())});this.project.stage.children.forEach(g=>g.inheritedMethodsCache=[]);this.objects={};return e}; SnapSerializer.prototype.loadReplayHistory=function(a){a=a?a.children:[];for(var b=[],c,d=a.length;d--;)c=this.parseEvent(null,a[d],!0),b.unshift(c);return b}; -SnapSerializer.prototype.loadHistory=function(a){a=a?a.children:[];for(var b,c=this.project.undo,d,e,f,g=a.length;g--;){e=a[g].attributes.id;f=c.allEvents.length-1;c.undoCount[e]=+a[g].attributes["undo-count"]||0;c.eventHistory[e]=[];b=a[g].children;for(var h=b.length;h--;){for(d=+b[h].attributes.id;0<=f&&c.allEvents[f].id!==d;)f--;0<=f?(d=c.allEvents[f],d.owner=e,c.eventHistory[e].unshift(d)):console.error("Could not load historical event from replay:",b[h])}}}; +SnapSerializer.prototype.loadHistory=function(a){a=a?a.children:[];for(var b,c=this.project.undo,d,e,f,g=a.length;g--;){e=a[g].attributes.id;f=c.allEvents.length-1;c.undoCount[e]=+a[g].attributes["undo-count"]||0;c.eventHistory[e]=[];b=a[g].children;for(var k=b.length;k--;){for(d=+b[k].attributes.id;0<=f&&c.allEvents[f].id!==d;)f--;0<=f?(d=c.allEvents[f],d.owner=e,c.eventHistory[e].unshift(d)):console.error("Could not load historical event from replay:",b[k])}}}; SnapSerializer.prototype.parseEvent=function(a,b){for(var c=[],d=b.children.length;d--;)c.unshift(this.loadEventArg(b.children[d]));return{id:+b.attributes.id,owner:a,type:b.attributes.type,replayType:+b.attributes.replayType,time:+b.attributes.time,user:b.attributes.user,username:b.attributes.username||void 0,isUserAction:"true"===b.attributes.isUserAction,args:c}}; SnapSerializer.prototype.loadBlocks=function(a,b){var c=new StageMorph;this.project={stage:c,sprites:{},targetStage:b};a=this.parse(a);if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";this.loadCustomBlocks(c,a,!0);this.populateCustomBlocks(c,a,!0);this.objects={};c.globalBlocks.forEach(d=>d.receiver=null);this.objects={};this.project={};this.mediaDict={};return c.globalBlocks}; SnapSerializer.prototype.loadSprites=function(a,b){var c=this.project={globalVariables:b.globalVariables,stage:b.stage,sprites:{}};c.sprites[c.stage.name]=c.stage;a=this.parse(a);if(+a.attributes.version>this.version)throw"Module uses newer version of Serializer";a.childrenNamed("sprite").forEach(d=>{var e=new SpriteMorph(c.globalVariables);d.attributes.id&&(this.objects[d.attributes.id]=e);d.attributes.name&&(e.name=b.newSpriteName(d.attributes.name),c.sprites[e.name]=e);d.attributes.color&&(e.color= @@ -2847,29 +2846,29 @@ SnapSerializer.prototype.loadScript=function(a,b){var c,d,e;this.project.stage|| SnapSerializer.prototype.loadComment=function(a){var b=new CommentMorph(a.contents),c=SyntaxElementMorph.prototype.scale;b.isCollapsed="true"===a.attributes.collapsed;b.setTextWidth(+a.attributes.w*c);b.id=a.attributes.collabId;return b}; SnapSerializer.prototype.loadBlock=function(a,b,c){var d,e=0;if("block"===a.tag){if(Object.prototype.hasOwnProperty.call(a.attributes,"var")){var f=SpriteMorph.prototype.variableBlock(a.attributes["var"]);f.id=a.attributes.collabId;return f}f=SpriteMorph.prototype.blockForSelector(a.attributes.s);if(d=SpriteMorph.prototype.blockMigrations[a.attributes.s])e=d.offset}else if("custom-block"===a.tag){var g=(d=a.attributes.scope?!1:!0)?this.project.stage:c;const n=a.childNamed("receiver");n&&n.children[0]&& "project"!==n.children[0].tag&&(g=this.loadValue(a.childNamed("receiver").children[0]));if(!g){if(d)return f=this.obsoleteBlock(b),f.id=a.attributes.collabId,f;g=this.project.stage}d?(d=detect(g.globalBlocks,p=>p.blockSpec()===a.attributes.s),!d&&this.project.targetStage&&(d=detect(this.project.targetStage.globalBlocks,p=>p.blockSpec()===a.attributes.s))):d=detect(g.customBlocks,p=>p.blockSpec()===a.attributes.s)||(g.inheritedMethodsCache?detect(g.inheritedMethodsCache,p=>p.blockSpec()===a.attributes.s): -null);if(!d||!contains(SpriteMorph.prototype.categories,d.category))return f=this.obsoleteBlock(b),f.id=a.attributes.collabId,f;f="command"===d.type?new CustomCommandBlockMorph(d,!1):new CustomReporterBlockMorph(d,"predicate"===d.type,!1)}null===f&&(f=this.obsoleteBlock(b));f.isDraggable=!0;f.id=a.attributes.collabId;var h=f.inputs();d=a.children.filter(n=>"comment"!==n.tag).length;g=h.length;if(g{"variables"===n.tag?this.loadVariables(f.variables,n,c):"comment"===n.tag?(f.comment=this.loadComment(n),f.comment.block=f):"receiver"===n.tag?nop():this.loadInput(n,h[p+e],f,c)});f.cachedInputs=null;m&&k&&(m instanceof MessageInputSlotMorph?(b=this.project.stage.messageTypes.getMsgType(k[0]), -m.setContents(k[0],k.slice(1),b)):m.setContents(k[0],k.slice(1)));return f};SnapSerializer.prototype.obsoleteBlock=function(a){a=a?new ReporterBlockMorph:new CommandBlockMorph;a.selector="errorObsolete";a.color=new Color(200,0,20);a.setSpec("Obsolete!");a.isDraggable=!0;return a}; +null);if(!d||!contains(SpriteMorph.prototype.categories,d.category))return f=this.obsoleteBlock(b),f.id=a.attributes.collabId,f;f="command"===d.type?new CustomCommandBlockMorph(d,!1):new CustomReporterBlockMorph(d,"predicate"===d.type,!1)}null===f&&(f=this.obsoleteBlock(b));f.isDraggable=!0;f.id=a.attributes.collabId;var k=f.inputs();d=a.children.filter(n=>"comment"!==n.tag).length;g=k.length;if(g{"variables"===n.tag?this.loadVariables(f.variables,n,c):"comment"===n.tag?(f.comment=this.loadComment(n),f.comment.block=f):"receiver"===n.tag?nop():this.loadInput(n,k[p+e],f,c)});f.cachedInputs=null;m&&h&&(m instanceof MessageInputSlotMorph?(b=this.project.stage.messageTypes.getMsgType(h[0]), +m.setContents(h[0],h.slice(1),b)):m.setContents(h[0],h.slice(1)));return f};SnapSerializer.prototype.obsoleteBlock=function(a){a=a?new ReporterBlockMorph:new CommandBlockMorph;a.selector="errorObsolete";a.color=new Color(200,0,20);a.setSpec("Obsolete!");a.isDraggable=!0;return a}; SnapSerializer.prototype.loadInput=function(a,b,c,d){if(!isNil(b))if("script"===a.tag){if(a=this.loadScript(a,d))"reifyReporter"===c.selector||"reifyPredicate"===c.selector?b.replaceInput(b.children[0],a):b.add(a),b.fixLayout()}else if("autolambda"===a.tag&&a.children[0]){if(a=this.loadBlock(a.children[0],!0,d))b.replaceInput(b.children[0],a),b.fixLayout()}else if("list"===a.tag){for(;0{b.addInput();this.loadInput(e,b.children[b.children.length- 2],b,d)});b.fixLayout()}else"block"===a.tag||"custom-block"===a.tag?c.replaceInput(b,this.loadBlock(a,!0,d)):"color"===a.tag?b.setColor(this.loadColor(a.contents)):(c=this.loadValue(a),isNil(c)||isNil(b)||!b.setContents||(b instanceof MessageInputSlotMorph?(a=this.loadValue(a),c=this.project.stage.messageTypes.getMsgType(a),b.setContents(a,null,c)):b.setContents(this.loadValue(a))))}; SnapSerializer.prototype.loadValue=function(a,b){function c(){Object.prototype.hasOwnProperty.call(a.attributes,"id")&&(f.objects[a.attributes.id]=g);Object.prototype.hasOwnProperty.call(a.attributes,"mediaID")&&(f.mediaDict[a.attributes.mediaID]=g)}var d,e,f=this;switch(a.tag){case "ref":if(Object.prototype.hasOwnProperty.call(a.attributes,"id"))return this.objects[a.attributes.id];if(Object.prototype.hasOwnProperty.call(a.attributes,"mediaID"))return this.mediaDict[a.attributes.mediaID];if(Object.prototype.hasOwnProperty.call(a.attributes, -"actionID"))return SnapActions.getOwnerFromId(a.attributes.actionID);throw Error("expecting a reference id");case "l":return(d=a.childNamed("option"))?[d.contents]:(e=a.childNamed("bool"))?this.loadValue(e):(d=a.childNamed("wish"))?this.loadValue(d):a.contents;case "bool":return"true"===a.contents;case "list":if(a.attributes.hasOwnProperty("linked")){if("atomic"===a.attributes.struct){var g=Process.prototype.parseCSV(a.contents);g.becomeLinked();c();return g}g=new List;g.isLinked=!0;c();d=g;var h= -a.childrenNamed("item");h.forEach((n,p)=>{n=n.children[0];g.first=n?this.loadValue(n,b):0;(n=a.childNamed("list")||a.childNamed("ref"))?g.rest=this.loadValue(n,b):p(n=n.children[0])?this.loadValue(n,b):0);return g;case "sprite":return g=new SpriteMorph(this.project.globalVariables),a.attributes.id&& +"actionID"))return SnapActions.getOwnerFromId(a.attributes.actionID);throw Error("expecting a reference id");case "l":return(d=a.childNamed("option"))?[d.contents]:(e=a.childNamed("bool"))?this.loadValue(e):(d=a.childNamed("wish"))?this.loadValue(d):a.contents;case "bool":return"true"===a.contents;case "list":if(a.attributes.hasOwnProperty("linked")){if("atomic"===a.attributes.struct){var g=Process.prototype.parseCSV(a.contents);g.becomeLinked();c();return g}g=new List;g.isLinked=!0;c();d=g;var k= +a.childrenNamed("item");k.forEach((n,p)=>{n=n.children[0];g.first=n?this.loadValue(n,b):0;(n=a.childNamed("list")||a.childNamed("ref"))?g.rest=this.loadValue(n,b):p(n=n.children[0])?this.loadValue(n,b):0);return g;case "sprite":return g=new SpriteMorph(this.project.globalVariables),a.attributes.id&& (this.objects[a.attributes.id]=g),a.attributes.name&&(g.name=a.attributes.name,this.project.sprites[a.attributes.name]=g),a.attributes.idx&&(g.idx=+a.attributes.idx),a.attributes.color&&(g.color=this.loadColor(a.attributes.color),g.cachedHSV=g.color.hsv()),a.attributes.pen&&(g.penPoint=a.attributes.pen),a.attributes.collabId&&(g.id=a.attributes.collabId),a.attributes.volume&&(g.volume=+a.attributes.volume),a.attributes.pan&&(g.pan=+a.attributes.pan),this.project.stage.add(g),g.scale=parseFloat(a.attributes.scale|| "1"),g.rotationStyle=parseFloat(a.attributes.rotation||"1"),g.isDraggable="false"!==a.attributes.draggable,g.isVisible="true"!==a.attributes.hidden,g.heading=parseFloat(a.attributes.heading)||0,g.gotoXY(+a.attributes.x||0,+a.attributes.y||0),this.loadObject(g,a),this.loadHistory(a.childNamed("history")),g.fixLayout(),(d=a.childNamed("messageTypes"))&&d.children.forEach(n=>this.loadMessageType(this.project.stage,n)),g;case "context":g=new Context(null);c();if(d=a.childNamed("origin"))if(d=d.childNamed("ref")|| d.childNamed("sprite"))g.origin=this.loadValue(d);if(d=a.childNamed("receiver"))if(d=d.childNamed("ref")||d.childNamed("sprite"))g.receiver=this.loadValue(d);var m=g.origin||g.receiver||b;if(d=a.childNamed("script"))g.expression=this.loadScript(d,m);else if(d=a.childNamed("block")||a.childNamed("custom-block"))g.expression=this.loadBlock(d,null,m);else if(d=a.childNamed("l"))e=d.childNamed("bool"),g.expression=e?new BooleanSlotMorph(this.loadValue(e)):new InputSlotMorph(d.contents);if(g.expression instanceof BlockMorph){var l=0;g.expression.allEmptySlots().forEach(n=>{l+=1;n.bindingID=n instanceof MultiArgMorph?["arguments"]:l});g.emptySlots=l}(d=a.childNamed("inputs"))&&d.children.forEach(n=>{"input"===n.tag&&g.inputs.push(n.contents)});(d=a.childNamed("variables"))&&this.loadVariables(g.variables,d,m);if(d=a.childNamed("context"))g.outerContext=this.loadValue(d,m);g.outerContext&&g.receiver&&!g.outerContext.variables.parentFrame&&(g.outerContext.variables.parentFrame=g.receiver.variables);return g; -case "costume":d=new Point;Object.prototype.hasOwnProperty.call(a.attributes,"center-x")&&(d.x=parseFloat(a.attributes["center-x"]));Object.prototype.hasOwnProperty.call(a.attributes,"center-y")&&(d.y=parseFloat(a.attributes["center-y"]));Object.prototype.hasOwnProperty.call(a.attributes,"name")&&(e=a.attributes.name);if(Object.prototype.hasOwnProperty.call(a.attributes,"image")){var k=new Image;0!==a.attributes.image.indexOf("data:image/svg+xml")||MorphicPreferences.rasterizeSVGs?(g=new Costume(null, -e,d),k.onload=function(){var n=newCanvas(new Point(k.width,k.height),!0);n.getContext("2d").drawImage(k,0,0);g.contents=n;g.imageSrc=null;g.version=+new Date;"function"===typeof g.loaded?g.loaded():g.loaded=!0}):(g=new SVG_Costume(null,e,d),k.onload=function(){g.contents=k;g.imageSrc=null;g.version=+new Date;"function"===typeof g.loaded?g.loaded():g.loaded=!0});k.src=a.attributes.image;g.imageSrc=a.attributes.image}g.id=a.attributes.collabId;c();return g;case "sound":return d=new Audio,d.src=a.attributes.sound, +case "costume":d=new Point;Object.prototype.hasOwnProperty.call(a.attributes,"center-x")&&(d.x=parseFloat(a.attributes["center-x"]));Object.prototype.hasOwnProperty.call(a.attributes,"center-y")&&(d.y=parseFloat(a.attributes["center-y"]));Object.prototype.hasOwnProperty.call(a.attributes,"name")&&(e=a.attributes.name);if(Object.prototype.hasOwnProperty.call(a.attributes,"image")){var h=new Image;0!==a.attributes.image.indexOf("data:image/svg+xml")||MorphicPreferences.rasterizeSVGs?(g=new Costume(null, +e,d),h.onload=function(){var n=newCanvas(new Point(h.width,h.height),!0);n.getContext("2d").drawImage(h,0,0);g.contents=n;g.imageSrc=null;g.version=+new Date;"function"===typeof g.loaded?g.loaded():g.loaded=!0}):(g=new SVG_Costume(null,e,d),h.onload=function(){g.contents=h;g.imageSrc=null;g.version=+new Date;"function"===typeof g.loaded?g.loaded():g.loaded=!0});h.src=a.attributes.image;g.imageSrc=a.attributes.image}g.id=a.attributes.collabId;c();return g;case "sound":return d=new Audio,d.src=a.attributes.sound, g=new Sound(d,a.attributes.name),Object.prototype.hasOwnProperty.call(a.attributes,"mediaID")&&(this.mediaDict[a.attributes.mediaID]=g),g.id=a.attributes.collabId,c(),g;case "wish":return d=new CustomBlockDefinition(a.attributes.s),d.type=a.attributes.type,d.category=a.attributes.category,d.storedSemanticSpec=a.attributes.s,d.updateTranslations(a.contents),d.blockInstance(!0)}}; SnapSerializer.prototype.loadColor=function(a){a=(a||"").split(",");return new Color(parseFloat(a[0]),parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3]))}; SnapSerializer.prototype.openProject=function(a,b){var c=b.stage,d=[];if(a&&a.stage)return b.siblings().forEach(e=>e.destroy()),b.projectName=a.name,b.projectNotes=a.notes||"",b.globalVariables&&(b.globalVariables=a.globalVariables),c&&c.destroy(),b.add(a.stage),b.stage=a.stage,d=b.stage.children.filter(e=>e instanceof SpriteMorph),d.sort((e,f)=>e.idx-f.idx),b.sprites=new List(d),c=d[0]||a.stage,0b+a.store(c),"")}; -StageMorph.prototype.toXML=function(a){function b(f){var g="";Object.keys(StageMorph.prototype[f]).forEach(h=>{g+="<"+h+">"+XML_Element.prototype.escape(StageMorph.prototype[f][h])+""});return g}var c=this.getCostumeIdx(),d=this.parentThatIsA(IDE_Morph);if(!a.isSavingPortable){const f=normalizeCanvas(this.thumbnail(SnapSerializer.prototype.thumbnailSize),!0);try{var e=f.toDataURL("image/png")}catch(g){e=null}}this.removeAllClones();return a.format('$$$%%%%%%%\x3c/scripts>%$%%%%%%', +StageMorph.prototype.toXML=function(a){function b(f){var g="";Object.keys(StageMorph.prototype[f]).forEach(k=>{g+="<"+k+">"+XML_Element.prototype.escape(StageMorph.prototype[f][k])+""});return g}var c=this.getCostumeIdx(),d=this.parentThatIsA(IDE_Morph);if(!a.isSavingPortable){const f=normalizeCanvas(this.thumbnail(SnapSerializer.prototype.thumbnailSize),!0);try{var e=f.toDataURL("image/png")}catch(g){e=null}}this.removeAllClones();return a.format('$$$%%%%%%%\x3c/scripts>%$%%%%%%', SnapActions.lastSeen,d&&d.projectName?d.projectName:localize("Untitled"),a.app,a.version,d&&d.projectNotes?d.projectNotes:"",e,this.name,d?.performerMode?480:this.dimensions.x,d?.performerMode?360:this.dimensions.y,this.id,c,this.color.r,this.color.g,this.color.b,this.color.a,this.getTempo(),this.isThreadSafe,this.enablePenLogging,this.instrument?' instrument="'+parseInt(this.instrument)+'" ':"",this.volume,this.pan,SpriteMorph.prototype.useFlatLineEnds?"flat":"round",BooleanSlotMorph.prototype.isTernary, !0===Process.prototype.enableHyperOps,this.enableCodeMapping,this.enableInheritance,this.enableSublistIDs,0!==StageMorph.prototype.frameRate,normalizeCanvas(this.trailsCanvas,!0).toDataURL("image/png"),!c&&this.costume?""+a.store(this.costume)+"":"",a.store(this.costumes,this.name+"_cst"),a.store(this.sounds,this.name+"_snd"),a.store(this.variables),a.store(this.customBlocks),a.store(this.messageTypes),a.store(this.scripts),a.store(this.children),Object.keys(StageMorph.prototype.hiddenPrimitives).reduce((f, g)=>f+" "+g,""),b("codeHeaders"),b("codeMappings"),a.store(this.globalBlocks),d&&d.globalVariables?a.store(d.globalVariables):"",a.isSavingHistory?a.historyXML(this.id):"",a.isSavingHistory?a.replayHistory():"")}; -StageMorph.prototype.toPortableXML=function(a,b){function c(f){var g="";Object.keys(StageMorph.prototype[f]).forEach(function(h){g+="<"+h+">"+XML_Element.prototype.escape(StageMorph.prototype[f][h])+""});return g}b=this.parentThatIsA(IDE_Morph);var d=this.customBlocks,e=this.globalBlocks;a.dependencies&&(d=d.filter(function(f){return a.dependencies.customBlocks.includes(f)}),e=e.filter(function(f){return a.dependencies.customBlocks.includes(f)}));this.removeAllClones();return a.format('$$$%%%%%%\x3c/scripts>%$%%%%%%', +StageMorph.prototype.toPortableXML=function(a,b){function c(f){var g="";Object.keys(StageMorph.prototype[f]).forEach(function(k){g+="<"+k+">"+XML_Element.prototype.escape(StageMorph.prototype[f][k])+""});return g}b=this.parentThatIsA(IDE_Morph);var d=this.customBlocks,e=this.globalBlocks;a.dependencies&&(d=d.filter(function(f){return a.dependencies.customBlocks.includes(f)}),e=e.filter(function(f){return a.dependencies.customBlocks.includes(f)}));this.removeAllClones();return a.format('$$$%%%%%%\x3c/scripts>%$%%%%%%', SnapActions.lastSeen,b&&b.projectName?b.projectName:localize("Untitled"),a.app,a.version,b&&b.projectNotes?b.projectNotes:"","",this.name,StageMorph.prototype.dimensions.x,StageMorph.prototype.dimensions.y,this.id,this.getCostumeIdx(),this.getTempo(),this.isThreadSafe,SpriteMorph.prototype.useFlatLineEnds?"flat":"round",this.enableCodeMapping,this.enableInheritance,this.enableSublistIDs,0!==StageMorph.prototype.frameRate,"",a.store(this.costumes,this.name+"_cst"),a.store(this.sounds,this.name+"_snd"), a.store(this.variables),a.store(d),a.store(this.messageTypes),a.dependencies?"":a.store(this.scripts),a.store(this.children),Object.keys(StageMorph.prototype.hiddenPrimitives).reduce(function(f,g){return f+" "+g},""),c("codeHeaders"),c("codeMappings"),a.store(e),b&&b.globalVariables?a.store(b.globalVariables):"","","")}; SpriteMorph.prototype.toXML=function(a){var b=this.parentThatIsA(StageMorph);b=(b=b?b.parentThatIsA(IDE_Morph):null)?b.sprites.asArray().indexOf(this)+1:0;var c=this.getCostumeIdx(),d=this.inheritsAttribute("costumes"),e=this.inheritsAttribute("sounds"),f=this.inheritsAttribute("scripts");return a.format('%%%'+(d?"%":"%")+ @@ -2901,28 +2900,28 @@ List.prototype.toXML=function(a,b){if(this.hasOnlyAtomicData()&&(!this.isLinked| a.format("$",d)));isNil(this.rest)||(c+=a.store(this.rest,b));return c+""}var e=this;do d=e.first,isNil(d)||(c+=a.format("%","object"===typeof d?isSnapObject(d)?"":a.store(d,b):"boolean"===typeof d?a.format("$",d):a.format("$",d))),e=e.rest;while(!isNil(e));return c+""}return a.format('%',this.id,this.contents.reduce((f,g)=>f+a.format("%","object"===typeof g?isSnapObject(g)?"":a.store(g,b):"boolean"===typeof g? a.format("$",g):a.format("$",g)),""))}; Context.prototype.toXML=function(a){return this.isContinuation?"":a.format("%%%%%%",this.inputs.reduce((b,c)=>b+a.format("$",c),""),this.variables?a.store(this.variables):"",this.expression?a.store(this.expression):"",this.receiver?a.store(this.receiver):"",this.receiver?a.store(this.origin):"",this.outerContext?a.store(this.outerContext):"")}; -Context.prototype.toPortableXML=function(a){var b=this,c=new VariableFrame,d,e;if(this.outerContext){var f=this.outerContext.variables;if(this.expression){var g=[];SnapActions.traverse(this.expression,function(h){d=h.blockSpec;"reportGetVar"!==h.selector||g.includes(d)||g.push(d)});c.vars=copy(this.outerContext.variables.vars);g.forEach(function(h){var m=[b.outerContext.variables];b.receiver&&m.push(b.receiver.variables);(e=m.reduce((l,k)=>l||k.silentFind(h),null))&&(c.vars[h]=e.vars[h])});this.outerContext.variables= +Context.prototype.toPortableXML=function(a){var b=this,c=new VariableFrame,d,e;if(this.outerContext){var f=this.outerContext.variables;if(this.expression){var g=[];SnapActions.traverse(this.expression,function(k){d=k.blockSpec;"reportGetVar"!==k.selector||g.includes(d)||g.push(d)});c.vars=copy(this.outerContext.variables.vars);g.forEach(function(k){var m=[b.outerContext.variables];b.receiver&&m.push(b.receiver.variables);(e=m.reduce((l,h)=>l||h.silentFind(k),null))&&(c.vars[k]=e.vars[k])});this.outerContext.variables= c}}a=this.toXML(a);this.outerContext&&(this.outerContext.variables=f||this.outerContext.variables);return a}; Context.prototype.getPortableDependencies=function(a,b){var c;var d={variables:[],customBlocks:[],messageTypes:[]};a||(a=this.expression);b||={};if(b[a.id])return d;b[a.id]=!0;if(a instanceof CustomCommandBlockMorph||a instanceof CustomReporterBlockMorph)d=this.getPortableDependencies(a.definition.body.expression,b);SnapActions.traverse(a,e=>{c=e.blockSpec;if("reportGetVar"===e.selector&&!d.variables.includes(c))d.variables.push(c);else if("evaluateCustomBlock"===e.selector&&!d.customBlocks.includes(e.definition)){d.customBlocks.push(e.definition); var f=this.getPortableDependencies(e.definition.body.expression,b);d.customBlocks.push(...f.customBlocks);d.variables.push(...f.variables)}else if("doSocketMessage"===e.selector||"doSocketRequest"===e.selector)({stage:f}=SnapActions.ide()),[e]=e.inputs()[0].evaluate(),f=f.messageTypes.getMsgType(e),d.messageTypes.push(f)});return d}; CommentMorph.prototype.toXML=function(a){var b=SyntaxElementMorph.prototype.scale;if(this.block)return a.format('%',this.id,this.textWidth()/b,this.isCollapsed,a.escape(this.text()));var c=this.parent?this.topLeft().subtract(this.parent.topLeft()):this.topLeft();return a.format('%',this.id,c.x/b,c.y/b,this.textWidth()/b,this.isCollapsed,a.escape(this.text()))}; -var hex_sha512=function(a){function a(c){for(var d=b,e=d.SHA512,f="",g=-1,h,m;++g=h&&56320<=m&&57343>=m&&(h=65536+((h&1023)<<10)+(m&1023),g++),127>=h?f+=String.fromCharCode(h):2047>=h?f+=String.fromCharCode(192|h>>>6&31,128|h&63):65535>=h?f+=String.fromCharCode(224|h>>>12&15,128|h>>>6&63,128|h&63):2097151>=h&&(f+=String.fromCharCode(240|h>>>18&7,128|h>>>12&63,128|h>>>6&63,128|h&63));return e.call(d,f).toString(b.enc.Hex)} -var b=b||function(c,d){var e={},f=e.lib={},g=f.Base=function(){function r(){}return{extend:function(t){r.prototype=this;var u=new r;t&&u.mixIn(t);u.$super=this;return u},create:function(){var t=this.extend();t.init.apply(t,arguments);return t},init:function(){},mixIn:function(t){for(var u in t)t.hasOwnProperty(u)&&(this[u]=t[u]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.$super.extend(this)}}}(),h=f.WordArray=g.extend({init:function(r,t){r=this.words=r|| +var hex_sha512=function(a){function a(c){for(var d=b,e=d.SHA512,f="",g=-1,k,m;++g=k&&56320<=m&&57343>=m&&(k=65536+((k&1023)<<10)+(m&1023),g++),127>=k?f+=String.fromCharCode(k):2047>=k?f+=String.fromCharCode(192|k>>>6&31,128|k&63):65535>=k?f+=String.fromCharCode(224|k>>>12&15,128|k>>>6&63,128|k&63):2097151>=k&&(f+=String.fromCharCode(240|k>>>18&7,128|k>>>12&63,128|k>>>6&63,128|k&63));return e.call(d,f).toString(b.enc.Hex)} +var b=b||function(c,d){var e={},f=e.lib={},g=f.Base=function(){function r(){}return{extend:function(t){r.prototype=this;var u=new r;t&&u.mixIn(t);u.$super=this;return u},create:function(){var t=this.extend();t.init.apply(t,arguments);return t},init:function(){},mixIn:function(t){for(var u in t)t.hasOwnProperty(u)&&(this[u]=t[u]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.$super.extend(this)}}}(),k=f.WordArray=g.extend({init:function(r,t){r=this.words=r|| [];this.sigBytes=t!=d?t:4*r.length},toString:function(r){return(r||l).stringify(this)},concat:function(r){var t=this.words,u=r.words,v=this.sigBytes;r=r.sigBytes;this.clamp();if(v%4)for(var w=0;w>>2]|=(u[w>>>2]>>>24-w%4*8&255)<<24-(v+w)%4*8;else if(65535>>2]=u[w>>>2];else t.push.apply(t,u);this.sigBytes+=r;return this},clamp:function(){var r=this.words,t=this.sigBytes;r[t>>>2]&=4294967295<<32-t%4*8;r.length=c.ceil(t/4)},clone:function(){var r=g.clone.call(this); -r.words=this.words.slice(0);return r},random:function(r){for(var t=[],u=0;u>>2]>>>24-v%4*8&255;u.push((w>>>4).toString(16));u.push((w&15).toString(16))}return u.join("")},parse:function(r){for(var t=r.length,u=[],v=0;v>>3]|=parseInt(r.substr(v,2),16)<<24-v%8*4;return h.create(u,t/2)}},k=m.Latin1={stringify:function(r){var t= -r.words;r=r.sigBytes;for(var u=[],v=0;v>>2]>>>24-v%4*8&255));return u.join("")},parse:function(r){for(var t=r.length,u=[],v=0;v>>2]|=(r.charCodeAt(v)&255)<<24-v%4*8;return h.create(u,t)}},n=m.Utf8={stringify:function(r){try{return decodeURIComponent(escape(k.stringify(r)))}catch(t){throw Error("Malformed UTF-8 data");}},parse:function(r){return k.parse(unescape(encodeURIComponent(r)))}},p=f.BufferedBlockAlgorithm=g.extend({reset:function(){this._data= -h.create();this._nDataBytes=0},_append:function(r){"string"==typeof r&&(r=n.parse(r));this._data.concat(r);this._nDataBytes+=r.sigBytes},_process:function(r){var t=this._data,u=t.words,v=t.sigBytes,w=this.blockSize,y=v/(4*w);y=r?c.ceil(y):c.max((y|0)-this._minBufferSize,0);r=y*w;v=c.min(4*r,v);if(r){for(var x=0;x>>2]>>>24-v%4*8&255;u.push((w>>>4).toString(16));u.push((w&15).toString(16))}return u.join("")},parse:function(r){for(var t=r.length,u=[],v=0;v>>3]|=parseInt(r.substr(v,2),16)<<24-v%8*4;return k.create(u,t/2)}},h=m.Latin1={stringify:function(r){var t= +r.words;r=r.sigBytes;for(var u=[],v=0;v>>2]>>>24-v%4*8&255));return u.join("")},parse:function(r){for(var t=r.length,u=[],v=0;v>>2]|=(r.charCodeAt(v)&255)<<24-v%4*8;return k.create(u,t)}},n=m.Utf8={stringify:function(r){try{return decodeURIComponent(escape(h.stringify(r)))}catch(t){throw Error("Malformed UTF-8 data");}},parse:function(r){return h.parse(unescape(encodeURIComponent(r)))}},p=f.BufferedBlockAlgorithm=g.extend({reset:function(){this._data= +k.create();this._nDataBytes=0},_append:function(r){"string"==typeof r&&(r=n.parse(r));this._data.concat(r);this._nDataBytes+=r.sigBytes},_process:function(r){var t=this._data,u=t.words,v=t.sigBytes,w=this.blockSize,y=v/(4*w);y=r?c.ceil(y):c.max((y|0)-this._minBufferSize,0);r=y*w;v=c.min(4*r,v);if(r){for(var x=0;xk;k++)l[k]=c()})();f=f.SHA512=e.extend({_doReset:function(){this._hash=h.create([c(1779033703,4089235720),c(3144134277,2227873595),c(1013904242,4271175723),c(2773480762,1595750129),c(1359893119,2917565137),c(2600822924,725511199),c(528734635,4215389547),c(1541459225,327033209)])},_doProcessBlock:function(k,n){var p=this._hash.words,q=p[0],r=p[1],t=p[2],u=p[3],v=p[4],w=p[5],y=p[6]; -p=p[7];for(var x=q.high,z=q.low,A=r.high,B=r.low,C=t.high,F=t.low,K=u.high,I=u.low,D=v.high,E=v.low,O=w.high,P=w.low,T=y.high,G=y.low,S=p.high,N=p.low,J=x,M=z,da=A,ba=B,ea=C,ca=F,ma=K,fa=I,U=D,Q=E,ka=O,ha=P,la=T,ia=G,na=S,ja=N,V=0;80>V;V++){var Y=l[V];if(16>V)var R=Y.high=k[n+2*V]|0,H=Y.low=k[n+2*V+1]|0;else{R=l[V-15];H=R.high;var W=R.low;R=(W<<31|H>>>1)^(W<<24|H>>>8)^H>>>7;W=(H<<31|W>>>1)^(H<<24|W>>>8)^(H<<25|W>>>7);var aa=l[V-2];H=aa.high;var L=aa.low;aa=(L<<13|H>>>19)^(H<<3|L>>>29)^H>>>6;L=(H<< +3409855158),c(1501505948,4234509866),c(1607167915,987167468),c(1816402316,1246189591)],l=[];(function(){for(var h=0;80>h;h++)l[h]=c()})();f=f.SHA512=e.extend({_doReset:function(){this._hash=k.create([c(1779033703,4089235720),c(3144134277,2227873595),c(1013904242,4271175723),c(2773480762,1595750129),c(1359893119,2917565137),c(2600822924,725511199),c(528734635,4215389547),c(1541459225,327033209)])},_doProcessBlock:function(h,n){var p=this._hash.words,q=p[0],r=p[1],t=p[2],u=p[3],v=p[4],w=p[5],y=p[6]; +p=p[7];for(var x=q.high,z=q.low,A=r.high,B=r.low,C=t.high,F=t.low,K=u.high,I=u.low,D=v.high,E=v.low,O=w.high,P=w.low,T=y.high,G=y.low,S=p.high,N=p.low,J=x,M=z,da=A,ba=B,ea=C,ca=F,ma=K,fa=I,U=D,Q=E,ka=O,ha=P,la=T,ia=G,na=S,ja=N,V=0;80>V;V++){var Y=l[V];if(16>V)var R=Y.high=h[n+2*V]|0,H=Y.low=h[n+2*V+1]|0;else{R=l[V-15];H=R.high;var W=R.low;R=(W<<31|H>>>1)^(W<<24|H>>>8)^H>>>7;W=(H<<31|W>>>1)^(H<<24|W>>>8)^(H<<25|W>>>7);var aa=l[V-2];H=aa.high;var L=aa.low;aa=(L<<13|H>>>19)^(H<<3|L>>>29)^H>>>6;L=(H<< 13|L>>>19)^(L<<3|H>>>29)^(H<<26|L>>>6);H=l[V-7];var oa=H.high,Z=l[V-16],X=Z.high;Z=Z.low;H=W+H.low;R=R+oa+(H>>>0>>0?1:0);H+=L;R=R+aa+(H>>>0>>0?1:0);H+=Z;R=R+X+(H>>>0>>0?1:0);Y.high=R;Y.low=H}oa=U&ka^~U&la;Z=Q&ha^~Q&ia;Y=J&da^J&ea^da&ea;var qa=M&ba^M&ca^ba&ca;W=(M<<4|J>>>28)^(J<<30|M>>>2)^(J<<25|M>>>7);aa=(J<<4|M>>>28)^(M<<30|J>>>2)^(M<<25|J>>>7);L=m[V];var ra=L.high,pa=L.low;L=ja+((U<<18|Q>>>14)^(U<<14|Q>>>18)^(Q<<23|U>>>9));X=na+((Q<<18|U>>>14)^(Q<<14|U>>>18)^(U<<23|Q>>>9))+(L>>>0>> 0?1:0);L+=Z;X=X+oa+(L>>>0>>0?1:0);L+=pa;X=X+ra+(L>>>0>>0?1:0);L+=H;X=X+R+(L>>>0>>0?1:0);H=aa+qa;Y=W+Y+(H>>>0>>0?1:0);na=la;ja=ia;la=ka;ia=ha;ka=U;ha=Q;Q=fa+L|0;U=ma+X+(Q>>>0>>0?1:0)|0;ma=ea;fa=ca;ea=da;ca=ba;da=J;ba=M;M=L+H|0;J=X+Y+(M>>>0>>0?1:0)|0}z=q.low=z+M|0;q.high=x+J+(z>>>0>>0?1:0)|0;B=r.low=B+ba|0;r.high=A+da+(B>>>0>>0?1:0)|0;F=t.low=F+ca|0;t.high=C+ea+(F>>>0>>0?1:0)|0;I=u.low=I+fa|0;u.high=K+ma+(I>>>0>>0?1:0)|0;E=v.low=E+Q|0;v.high=D+U+(E>>>0>>0?1:0)| -0;P=w.low=P+ha|0;w.high=O+ka+(P>>>0>>0?1:0)|0;G=y.low=G+ia|0;y.high=T+la+(G>>>0>>0?1:0)|0;N=p.low=N+ja|0;p.high=S+na+(N>>>0>>0?1:0)|0},_doFinalize:function(){var k=this._data,n=k.words,p=8*this._nDataBytes,q=8*k.sigBytes;n[q>>>5]|=128<<24-q%32;n[(q+128>>>10<<5)+31]=p;k.sigBytes=4*n.length;this._process();this._hash=this._hash.toX32()},blockSize:32});d.SHA512=e._createHelper(f);d.HmacSHA512=e._createHmacHelper(f)})();return a}({}),logger={log:console.log.bind(console),debug:console.info.bind(console), +0;P=w.low=P+ha|0;w.high=O+ka+(P>>>0>>0?1:0)|0;G=y.low=G+ia|0;y.high=T+la+(G>>>0>>0?1:0)|0;N=p.low=N+ja|0;p.high=S+na+(N>>>0>>0?1:0)|0},_doFinalize:function(){var h=this._data,n=h.words,p=8*this._nDataBytes,q=8*h.sigBytes;n[q>>>5]|=128<<24-q%32;n[(q+128>>>10<<5)+31]=p;h.sigBytes=4*n.length;this._process();this._hash=this._hash.toX32()},blockSize:32});d.SHA512=e._createHelper(f);d.HmacSHA512=e._createHmacHelper(f)})();return a}({}),logger={log:console.log.bind(console),debug:console.info.bind(console), info:console.info.bind(console),warn:console.warn.bind(console),error:console.error.bind(console)};function ActionManager(){this.rank=this.id=null;this.isLeader=!1;this._pendingLocalActions=[];this._attemptedLocalActions=[];this.listeners=[];this.initialize()}ActionManager.prototype.configure=function(a){this.__ide=a;this.id=a.cloud.clientId}; ActionManager.prototype.addActions=function(){var a=this;Array.prototype.slice.call(arguments).forEach(function(b){a[b]=async function(){var c=Array.prototype.slice.apply(arguments),d="_"+b;this.ide();this[d]&&(c=this[d].apply(this,c)||c);d={type:b,args:c};c=ActionManager.OwnerFor[b]?ActionManager.OwnerFor[b].apply(this,d.args):ActionManager.OwnerFor.apply(this,d.args);d.owner=c;return this.applyEvent(d)}})}; ActionManager.prototype.addUserActions=function(){var a=this;Array.prototype.slice.call(arguments).forEach(function(b){a[b]=function(){var c=Array.prototype.slice.apply(arguments),d="_"+b;this[d]&&(c=this[d].apply(this,c)||c);return this.applyEvent({isUserAction:!0,type:b,args:c})}})};ActionManager.prototype._selectTab=function(a){return[a,this.ide().currentTab]};ActionManager.prototype._selectSprite=function(a){return[a.id,this.ide().currentSprite.id]};ActionManager.prototype.isUserAction=function(a){return a.isUserAction}; @@ -2955,8 +2954,8 @@ ActionManager.prototype._setCustomBlockType=function(a,b,c){return[a.id,b,c,a.ca ActionManager.prototype._updateBlockLabel=function(a,b,c){var d=b.parent.children.indexOf(b);console.assert(-1";return[a.id,b]}; ActionManager.prototype._renameSprite=function(a,b){return[a.id,b,a.name]};ActionManager.prototype._duplicateSprite=function(a){var b=this.newId(),c='collabId="'+b+'"',d=a.copy(),e=this.ide();d.id=b;d.setName(e.newSpriteName(a.name));d.parent=e.stage;a=this.serialize(d);a=this.assignUniqueIds(a).toString();a=""+a.replace(/collabId="item_[0-9_]*"/,c)+"";return[a,null,b]}; ActionManager.prototype._importSprites=function(a){a=this.assignUniqueIds(a);var b=a.children.map(function(c){return c.attributes.collabId});a=a.toString();return[a,b]}; -ActionManager.prototype._onSetBlockPosition=function(a,b,c,d){var e=this,f=new Point(b,c),g=this.getBlockFromId(a),h=function(){e.disconnectBlock(g,k);g.justDropped&&g.justDropped();g.changed();g.removeShadow();e.updateCommentsPositions(g);e.__updateBlockDefinitions(g);e.__updateActiveEditor(g.id);d()};this.ensureNotDragging(g);if(this._targetFor[a]){f=Object.keys(this._targetFor[a]);for(var m=f.length;m--;){var l=this._targetFor[a][f[m]];"top"===l.loc&&this.__clearTarget(this.__targetId(l))}}this.__clearTarget(a); -console.assert(g,'Block "'+a+'" does not exist! Cannot set position');f=new Point(b,c);if(a=g.parentThatIsA(BlockEditorMorph))var k=a.body.contents;k=g.parentThatIsA(ScriptsMorph);f=this.getAdjustedPosition(f,k);this.canAnimate(this.getBlockOwnerId(g))?g.glideTo(f,null,null,function(){try{h()}catch(n){d(n)}}):(g.setPosition(f),h())}; +ActionManager.prototype._onSetBlockPosition=function(a,b,c,d){var e=this,f=new Point(b,c),g=this.getBlockFromId(a),k=function(){e.disconnectBlock(g,h);g.justDropped&&g.justDropped();g.changed();g.removeShadow();e.updateCommentsPositions(g);e.__updateBlockDefinitions(g);e.__updateActiveEditor(g.id);d()};this.ensureNotDragging(g);if(this._targetFor[a]){f=Object.keys(this._targetFor[a]);for(var m=f.length;m--;){var l=this._targetFor[a][f[m]];"top"===l.loc&&this.__clearTarget(this.__targetId(l))}}this.__clearTarget(a); +console.assert(g,'Block "'+a+'" does not exist! Cannot set position');f=new Point(b,c);if(a=g.parentThatIsA(BlockEditorMorph))var h=a.body.contents;h=g.parentThatIsA(ScriptsMorph);f=this.getAdjustedPosition(f,h);this.canAnimate(this.getBlockOwnerId(g))?g.glideTo(f,null,null,function(){try{k()}catch(n){d(n)}}):(g.setPosition(f),k())}; ActionManager.prototype.onSetBlocksPositions=function(a,b){for(var c=this,d=0,e=function(){d++;d===a.length&&c.completeAction()},f=a.length;f--;)this._onSetBlockPosition(a[f],b[f].x,b[f].y,e)};ActionManager.prototype.getLastGrabPosition=function(){var a=this.ide().root().hand;return a.grabOrigin&&a.grabOrigin.position};ActionManager.prototype.getStandardPosition=function(a,b){var c=a.parentThatIsA(ScriptsMorph);b=b||a.position();return this.convertToStandardPosition(c,b)}; ActionManager.prototype.convertToStandardPosition=function(a,b){var c=SyntaxElementMorph.prototype.scale;return b=b.subtract(a.topLeft()).divideBy(c)};ActionManager.prototype.getAdjustedPosition=function(a,b){return a=a.multiplyBy(SyntaxElementMorph.prototype.scale).add(b.topLeft())};ActionManager.prototype._idBlocks=function(a,b){var c=this,d=[];this.traverse(a,function(e){e.isDraggable=!0;e.isTemplate=!1;e.id=c.newId();d.push(e.id)});return b?d:a}; -ActionManager.prototype.registerBlocks=function(a,b,c){var d=this;this.traverse(a,function(e){d._registerBlockState(e,c);d._blockToOwnerId[e.id]=b});return a};ActionManager.prototype.onReplaceBlock=function(a,b){var c=this;a=this.deserializeBlock(a);var d=this._blockToOwnerId[a.id];var e=this.getStandardPosition(a);this._onRemoveBlock(a.id,!0,function(f){if(f)return c.completeAction(f);c._onAddBlock(b,d,e.x,e.y,function(g,h){c.completeAction(g,h)})})}; -ActionManager.prototype._onAddBlock=function(a,b,c,d,e){var f=this,g=this.ide(),h=this.getOwnerFromId(b);c=new Point(c,d);var m=function(){l.fixChildrensBlockColor&&l.fixChildrensBlockColor(!0);l.allComments&&l.allComments().forEach(function(k){k.align(l)});f.registerBlocks(l,h.id);f.__updateScriptsMorph(l);f.__updateActiveEditor(l.id);e(null,l)};var l=this.deserializeBlock(a,h);l.snapSound&&l.snapSound.play();this._customBlocks[b]?(a=this._getCustomBlockEditor(b),d=a.body.contents,c=this.getAdjustedPosition(c, -d),l.setPosition(c),d.add(l),a.updateDefinition(),h=this._customBlocks[b],m()):(c=this.getAdjustedPosition(c,h.scripts),this.canAnimate(h.id)?(b=g.palette,l.setPosition(b.position().add(new Point(b.left()-l.width(),b.height()/4))),b.add(l),l.glideTo(c,null,null,function(){try{h.scripts.add(l),m()}catch(k){e(k)}})):(l.setPosition(c),h.scripts.add(l),l.changed(),m()));"receiveCondition"===l.selector&&(b=g.stage)&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,g.controlBar.stopButton.refresh())}; +ActionManager.prototype.registerBlocks=function(a,b,c){var d=this;this.traverse(a,function(e){d._registerBlockState(e,c);d._blockToOwnerId[e.id]=b});return a};ActionManager.prototype.onReplaceBlock=function(a,b){var c=this;a=this.deserializeBlock(a);var d=this._blockToOwnerId[a.id];var e=this.getStandardPosition(a);this._onRemoveBlock(a.id,!0,function(f){if(f)return c.completeAction(f);c._onAddBlock(b,d,e.x,e.y,function(g,k){c.completeAction(g,k)})})}; +ActionManager.prototype._onAddBlock=function(a,b,c,d,e){var f=this,g=this.ide(),k=this.getOwnerFromId(b);c=new Point(c,d);var m=function(){l.fixChildrensBlockColor&&l.fixChildrensBlockColor(!0);l.allComments&&l.allComments().forEach(function(h){h.align(l)});f.registerBlocks(l,k.id);f.__updateScriptsMorph(l);f.__updateActiveEditor(l.id);e(null,l)};var l=this.deserializeBlock(a,k);l.snapSound&&l.snapSound.play();this._customBlocks[b]?(a=this._getCustomBlockEditor(b),d=a.body.contents,c=this.getAdjustedPosition(c, +d),l.setPosition(c),d.add(l),a.updateDefinition(),k=this._customBlocks[b],m()):(c=this.getAdjustedPosition(c,k.scripts),this.canAnimate(k.id)?(b=g.palette,l.setPosition(b.position().add(new Point(b.left()-l.width(),b.height()/4))),b.add(l),l.glideTo(c,null,null,function(){try{k.scripts.add(l),m()}catch(h){e(h)}})):(l.setPosition(c),k.scripts.add(l),l.changed(),m()));"receiveCondition"===l.selector&&(b=g.stage)&&(b.enableCustomHatBlocks=!0,b.threads.pauseCustomHatBlocks=!1,g.controlBar.stopButton.refresh())}; ActionManager.prototype.onAddBlock=function(a,b,c,d){var e=this;this._onAddBlock(a,b,c,d,function(f,g){e.completeAction(f,g)})};ActionManager.prototype.world=function(){var a=Object.keys(this._owners)[0];return(a=this._owners[a])?a.parentThatIsA(WorldMorph):null};ActionManager.prototype.isEditorOpen=function(a){var b=this.world()?this.world().children:[];return!!detect(b,function(c){return c instanceof BlockEditorMorph&&c.definition.id===a})}; ActionManager.prototype._getCustomBlockEditor=function(a,b){var c=this.world()?this.world().children:[],d=this._customBlockOwner[a],e=this._customBlocks[a];c=detect(c,function(f){return f instanceof BlockEditorMorph&&f.definition.id===a});!c&&e&&(b&&(c=b.parentThatIsA(BlockEditorMorph)),c||(c=new BlockEditorMorph(e,d),c.popUp(!0),c.setInitialDimensions(!0),c.destroy()));return c}; -ActionManager.prototype.getBlockFromId=function(a){a=a.split("/");var b=a.shift(),c=this._blocks[b],d;this._customBlocks[b]&&(c=this._getCustomBlockEditor(b).body.contents.children.find(function(h){return h instanceof PrototypeHatBlockMorph}));if(d=c.parentThatIsA(BlockEditorMorph)){var e=!1;var f=d.definition.id;f=this._getCustomBlockEditor(f);if(d!==f)for(d=f.body.contents.children.slice();!e&&d.length;){f=[];for(var g=d.length;g--;)if(d[g]){if(d[g].id===b){this._blocks[b]=d[g];c=this._blocks[b]; +ActionManager.prototype.getBlockFromId=function(a){a=a.split("/");var b=a.shift(),c=this._blocks[b],d;this._customBlocks[b]&&(c=this._getCustomBlockEditor(b).body.contents.children.find(function(k){return k instanceof PrototypeHatBlockMorph}));if(d=c.parentThatIsA(BlockEditorMorph)){var e=!1;var f=d.definition.id;f=this._getCustomBlockEditor(f);if(d!==f)for(d=f.body.contents.children.slice();!e&&d.length;){f=[];for(var g=d.length;g--;)if(d[g]){if(d[g].id===b){this._blocks[b]=d[g];c=this._blocks[b]; e=!0;break}d[g].inputs&&(f=f.concat(d[g].inputs()));d[g].nextBlock&&f.push(d[g].nextBlock())}d=f}}for(g=0;gd&&f.top(){const c=d=>this._blocks[d.id]=d;b instanceof PrototypeHatBlockMorph?(b=b.nextBlock())&&this.traverse(b,c):this.traverse(b,c)})};ActionManager.prototype.onSetBlockPosition=function(a,b,c){var d=this;this._onSetBlockPosition(a,b,c,function(){d.completeAction()})}; @@ -3006,7 +3005,7 @@ ActionManager.prototype._loadCostume=function(a,b){a=this.serializer.parse(a);va ActionManager.prototype.onAttachParts=function(a,b){var c=this,d=this.getOwnerFromId(a),e;b.forEach(function(f){e=c.getOwnerFromId(f);d.attachPart(e)});this.completeAction()};ActionManager.prototype.onDetachParts=function(a){var b=this,c;a.forEach(function(d){c=b.getOwnerFromId(d);c.detachFromAnchor()});this.completeAction()};ActionManager.prototype.onRemoveSprite=function(a){var b=this._owners[a];this.ide().removeSprite(b);this.__clearOwnerRecords(a);this.completeAction()}; ActionManager.prototype.onRenameSprite=function(a,b){var c=this._owners[a],d=this.ide();c.setName(b);d.currentSprite===c&&d.spriteBar.nameField.setContents(b);d.extensions.onRenameSprite(a,b);this.completeAction(null,b)};ActionManager.prototype.onToggleDraggable=function(a,b){a=this._owners[a];var c=this.ide();a.isDraggable=b;c.currentSprite===a&&c.spriteBar.padlock.refresh();this.completeAction()}; ActionManager.prototype._registerCostume=function(a,b){this._costumes[a.id]=a;this._costumeToOwner[a.id]=b};ActionManager.prototype.onAddCostume=function(a,b,c){var d=this.ide(),e=this._owners[b];this._loadCostume(a,f=>{e.addCostume(f);d.spriteEditor instanceof WardrobeMorph&&d.spriteEditor.updateList();d&&d.currentSprite===e&&d.currentSprite.wearCostume(f);this._registerCostume(f,e);c===this.id&&d.spriteBar.tabBar.tabTo("costumes");this.__updateActiveEditor();this.completeAction(null,f)})}; -ActionManager.prototype.onUpdateCostume=function(a,b){var c=this.ide(),d=this._costumeToOwner[a],e=this,f=c.parentThatIsA(WorldMorph);this._loadCostume(b,function(g){var h=e._costumes[a];h.rotationCenter=g.rotationCenter;h.contents=g.contents;h.version=Date.now();f.changed();c.currentSprite===d&&c.currentSprite.wearCostume(h);c.hasChangedMedia=!0});this.__updateActiveEditor(a);this.completeAction()}; +ActionManager.prototype.onUpdateCostume=function(a,b){var c=this.ide(),d=this._costumeToOwner[a],e=this,f=c.parentThatIsA(WorldMorph);this._loadCostume(b,function(g){var k=e._costumes[a];k.rotationCenter=g.rotationCenter;k.contents=g.contents;k.version=Date.now();f.changed();c.currentSprite===d&&c.currentSprite.wearCostume(k);c.hasChangedMedia=!0});this.__updateActiveEditor(a);this.completeAction()}; ActionManager.prototype.onRemoveCostume=function(a){var b=this._costumes[a],c=this._costumeToOwner[a],d=this.ide().spriteEditor,e=c.costumes.asArray().indexOf(b);const f=()=>this.world().hand.children.find(g=>g.id===a);-1f.set(h,g));return f}; +WatcherMorph.prototype.isGlobal=function(a){return"reportRPCError"===a||WatcherMorph.prototype._isGlobal.call(this,a)};IDE_Morph.prototype.UrlActionRegistry={};IDE_Morph.prototype.parseUrlAnchors=function(a,b){b=b.replace(/^#/,"");const [c,...d]=b.split(":");let e=b=d.join(":");0f.set(k,g));return f}; IDE_Morph.prototype.getUrlSettings=function(a,b){a=this.parseUrlAnchors(a,b);return new (this.UrlActionRegistry[a.get("action")]||NoMainParam)(a,b)};class UrlParamError extends Error{}class MissingParameterError extends UrlParamError{constructor(a,b){a=a.get("action");super(`"${b}" required for "${a}"`)}} class SearchParams extends URLSearchParams{normalizeKey(a){return a.toLowerCase()}has(a){return super.has(this.normalizeKey(a))}get(a){return super.get(this.normalizeKey(a))}set(a,b){return super.set(this.normalizeKey(a),b)}} class UrlParams{constructor(a){this.params=a}getRequiredParam(a){if(!this.params.has(a))throw new MissingParameterError(this.params,a);return this.params.get(a)}getParameterFlag(a){a=this.params.get(a);return![void 0,null,"0","false",!1].includes(a)}async applySettings(a){await this.applyInitialFlags(a);await this.apply(a);await this.applyFlags(a)}async apply(a){}async applyInitialFlags(a){const b=this.getParameterFlag("noDefaultExtensions")?[]:["https://extensions.netsblox.org/extensions/BeatBlox/index.js"]; @@ -3090,7 +3089,7 @@ class OpenExampleProject extends UrlParams{async apply(a){const b=this.params.ge IDE_Morph.prototype.UrlActionRegistry.example=OpenExampleProject; class OpenPrivateProject extends UrlParams{async apply(a){const b=this.params.get("data")||this.getRequiredParam("ProjectName");if(null===a.cloud.username)a.showMessage("You are not logged in. Cannot open "+b);else{var c=a.showMessage("Opening "+b+"...");try{const d=await a.cloud.getProjectMetadataByName(a.cloud.username,b);await (new CloudProjectsSource(a)).open(d);this.getParameterFlag("editMode")||this.params.set("appMode",!0);this.getParameterFlag("noRun")||this.params.set("run",!0)}catch(d){a.cloudError()(d.message)}c.destroy()}}} IDE_Morph.prototype.UrlActionRegistry.private=OpenPrivateProject;IDE_Morph.prototype._getURL=IDE_Morph.prototype.getURL;IDE_Morph.prototype.getURL=function(a,b,c){a=ensureFullUrl(a);return this._getURL(a,b,c)};IDE_Morph.prototype._rawOpenBlocksString=IDE_Morph.prototype.rawOpenBlocksString; -IDE_Morph.prototype.rawOpenBlocksString=function(a,b,c){var d=this;if(Process.prototype.isCatchingErrors)try{var e=this.serializer.parse(a).childrenNamed("messageType")}catch(f){this.showMessage("Load failed: "+f)}else e=this.serializer.parse(a).childrenNamed("messageType");c&&(e.forEach(function(f){var g=f.childNamed("name").contents;f=f.childNamed("fields").children.map(function(h){return h.contents});d.stage.addMessageType({name:g,fields:f})}),this.flushBlocksCache(),this.flushPaletteCache(),this.refreshPalette(), +IDE_Morph.prototype.rawOpenBlocksString=function(a,b,c){var d=this;if(Process.prototype.isCatchingErrors)try{var e=this.serializer.parse(a).childrenNamed("messageType")}catch(f){this.showMessage("Load failed: "+f)}else e=this.serializer.parse(a).childrenNamed("messageType");c&&(e.forEach(function(f){var g=f.childNamed("name").contents;f=f.childNamed("fields").children.map(function(k){return k.contents});d.stage.addMessageType({name:g,fields:f})}),this.flushBlocksCache(),this.flushPaletteCache(),this.refreshPalette(), this.showMessage("Imported Blocks / Message Types Module"+(b?": "+b:"")+".",2));return this._rawOpenBlocksString(a,b,c)};IDE_Morph.prototype.loadReplayFromXml=function(a){a=this.serializer.parse(a);"room"===a.tag&&(a=a.children[0].childNamed("project"));if("project"===a.tag){var b=this.serializer.getInitialStageSpriteIds(a),c=b[0];b=b[1];var d=this.sprites.at(1);SnapActions.registerOwner(this.stage,c);SnapActions.registerOwner(d,b);a=a.childNamed("replay")}return this.droppedText(a.toString())}; IDE_Morph.prototype.openReplayString=function(a){var b=this,c=this.serializer.parse(a);b.exitReplayMode();return SnapActions.openProject().then(function(){var d=b.serializer.loadReplayHistory(c);b.replayEvents(d,!1)})};IDE_Morph.prototype.isSupportedBrowser=function(){var a=window.chrome,b=window.navigator,c=b.vendor,d="undefined"!==typeof window.opr,e=-1=screen.width&&420>=screen.height;return(420>=screen.width&&800>=screen.height||a)&&-1!==navigator.userAgent.toLowerCase().indexOf("mobile")&&"undefined"!==typeof window.orientation};IDE_Morph.prototype.mobileMode={_stackMode:"",buttons:[],btnConfig:{idealSize:30,SBRatio:.5,GBRatio:.3,symbolSize:void 0,padding:void 0,size:void 0,gap:void 0},ideMorph:void 0}; @@ -3103,12 +3102,12 @@ c.width=Math.abs(c.topRight.x-c.bottomLeft.x);this._stackMode=c.height>c.width?" IDE_Morph.prototype.mobileMode.computeControlPos=function(a){var b=window.innerHeight,c=window.innerWidth,d=this.buttons.length,e=this.buttons[0].height(),f=this.buttons[0].width();if("v"===this._stackMode){var g={origin:{},height:d*e+(d-1)*this.btnConfig.gap,width:f};g.origin.y=(b-g.height)/2;g.origin.x=a.bottomLeft.x+(a.width-g.width)/2}else"h"===this._stackMode&&(g={origin:{},width:d*f+(d-1)*this.btnConfig.gap,height:e},g.origin.x=(c-g.width)/2,g.origin.y=(a.bottomLeft.y-g.height)/2);return g}; IDE_Morph.prototype.mobileMode.createButtons=function(){var a=this,b=[new Color(50,50,50),new Color(70,70,70),new Color(90,90,90)];this.buttons&&0!==this.buttons.length&&this.buttons.forEach(function(f){f.destroy()});var c=[],d=new ToggleButtonMorph(null,this.ideMorph,"stopAllScripts",[new SymbolMorph("octagon",a.btnConfig.symbolSize),new SymbolMorph("square",a.btnConfig.symbolSize)],function(){return a.ideMorph.stage?a.ideMorph.stage.enableCustomHatBlocks&&a.ideMorph.stage.threads.pauseCustomHatBlocks: !0});d.labelColor=new Color(200,0,0);var e=new PushButtonMorph(this.ideMorph,"pressStart",new SymbolMorph("flag",a.btnConfig.symbolSize));e.labelColor=new Color(0,200,0);c.push(e);c.push(d);c.forEach(function(f){f.hide();f.fixLayout();f.rerender();a.ideMorph.add(f);f.corner=12;f.color=b[0];f.highlightColor=b[1];f.pressColor=b[2];f.labelMinExtent=new Point(36,18);f.labelShadowOffset=new Point(-1,-1);f.labelShadowColor=b[1];f.contrast=this.buttonContrast;f.padding=a.btnConfig.padding;f.fixLayout(); -f.refresh&&f.refresh()});return c};IDE_Morph.prototype.mobileMode.positionButtons=function(a,b){var c=a[0].height(),d=this,e=a[0].width();a.forEach(function(f,g){if("v"===d._stackMode){var h=b.origin.x;var m=b.origin.y+g*c+g*d.btnConfig.gap}else"h"===d._stackMode&&(m=b.origin.y,h=b.origin.x+g*e+g*d.btnConfig.gap);f.setPosition(new Point(h,m));f.show()})}; +f.refresh&&f.refresh()});return c};IDE_Morph.prototype.mobileMode.positionButtons=function(a,b){var c=a[0].height(),d=this,e=a[0].width();a.forEach(function(f,g){if("v"===d._stackMode){var k=b.origin.x;var m=b.origin.y+g*c+g*d.btnConfig.gap}else"h"===d._stackMode&&(m=b.origin.y,k=b.origin.x+g*e+g*d.btnConfig.gap);f.setPosition(new Point(k,m));f.show()})}; IDE_Morph.prototype.initializeEmbeddedAPI=function(){var a={};window.externalVariables=a;window.addEventListener("message",async b=>{var c=b.data;console.log("received message",b.data);switch(c.type){case "import":this.droppedText(c.content,c.name,c.fileType);break;case "set-variable":a[c.key]=c.value;break;case "delete-variable":delete a[c.key];break;case "export-project":({id:c}=c);var d=await this.getProjectXML();b.source.postMessage({id:c,type:"reply",xml:d},b.origin);break;case "get-username":({id:c}= -c);({username:d}=this.cloud);b.source.postMessage({id:c,type:"reply",username:d},b.origin);break;case "add-listener":const {id:e,eventType:f,listenerId:g}=c,{source:h,origin:m}=b;this.events.addEventListener(f,g,p=>{h.postMessage({type:"event",eventType:p.type,detail:p.detail},m)});h.postMessage({id:e,type:"reply"},m);break;case "remove-listener":const {id:l,eventType:k,listenerId:n}=c;this.events.removeEventListener(k,n);b.source.postMessage({id:l,type:"reply"},b.origin);break;case "run-scripts":this.runScripts(); -break;case "stop-all-scripts":this.stopAllScripts()}},!1)}; -IDE_Morph.prototype.extensionsMenu=function(){const a={};this.extensions.registry.filter(f=>f.getMenu()).forEach(f=>{a[f.name||f.constructor.name]=f.getMenu()});const b=f=>{const g=new MenuMorph(this);Object.entries(f).forEach(h=>{const [m,l]=h;"object"===typeof l?(h=b(l),g.addMenu(m,h)):"~"===m?g.addLine():g.addItem(m,l)});return g};let c=b(a);const d=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),e=new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize);this.extensions.registry.filter(f=> -f.getSettings()).forEach(f=>{const g=f.name||f.constructor.name;let h=c.items.find(m=>m[0]==g);f=f.getSettings();if(h&&(h=h[1],void 0!==f.find(m=>!m.hide||16==world.currentKey))){let m=new MenuMorph(this);h.addMenu("Options",m);f.forEach(l=>{let k=l.test;l.hide&&16!=world.currentKey||m.addItem([k()?d:e,l.label],l.toggle,k()?l.onHint:l.offHint,l.hide?new Color(100,0,0):null)})}});return c}; +c);({username:d}=this.cloud);b.source.postMessage({id:c,type:"reply",username:d},b.origin);break;case "add-listener":const {id:e,eventType:f,listenerId:g}=c,{source:k,origin:m}=b;this.events.addEventListener(f,g,p=>{k.postMessage({type:"event",eventType:p.type,detail:p.detail},m)});k.postMessage({id:e,type:"reply"},m);break;case "remove-listener":const {id:l,eventType:h,listenerId:n}=c;this.events.removeEventListener(h,n);b.source.postMessage({id:l,type:"reply"},b.origin);break;case "run-scripts":this.runScripts(); +break;case "stop-all-scripts":this.stopAllScripts()}},!1)};let EXTENSIONS_META=[];(async()=>{EXTENSIONS_META=JSON.parse(await (await fetch("https://extensions.netsblox.org/index.json")).text())})();IDE_Morph.prototype.menuFromEntries=function(a){if(a instanceof MenuMorph)return a;const b=new MenuMorph(this);for(const [c,d]of a)"object"===typeof d?b.addMenu(c,this.menuFromEntries(d)):"-"===c?b.addLine():b.addItem(c,d);return b}; +IDE_Morph.prototype.extensionsMenu=function(){const a=new SymbolMorph("checkedBox",.75*MorphicPreferences.menuFontSize),b=new SymbolMorph("rectangle",.75*MorphicPreferences.menuFontSize),c=[];for(const d of this.extensions.registry){const e=d.name||d.constructor.name,f=Object.entries(d.getMenu()||{}),g=(d.getSettings()||[]).filter(m=>!m.hide||16===world.currentKey),k=new MenuMorph(this);for(const m of g){const l=m.test();k.addItem([l?a:b,m.label],m.toggle,l?m.onHint:m.offHint,m.hide?new Color(100, +0,0):null)}(f.length||g.length)&&c.push([e,[...f,...(g.length?[["Options",k]]:[])]])}c.length&&c.push(["-","-"]);c.push(["Import...",EXTENSIONS_META.map(d=>[d.name,()=>this.loadExtension(d.url)])]);return this.menuFromEntries(c)}; IDE_Morph.prototype.requestProjectReload=async function(a){if(await this.confirm(a+"\n\nWould you like to reload the current role?",localize("Project Reload Required"))){a=await this.cloud.exportRole();const b=this.showMessage(localize("Opening project..."));await this.openRoleString(a);b.destroy()}};IDE_Morph.prototype.openRoleString=async function(a,b=!1){b||(a=this.serializer.parse(a));a=["",a.childNamed("project").toString(),a.childNamed("media").toString(),""].join("");return SnapActions.openProject(a)}; IDE_Morph.prototype.manageFriends=async function(){(new UserDialogMorph(this)).popUp(this.world())};IDE_Morph.prototype.sendFriendRequest=async function(){this.prompt(localize("Send Friend Invitation to..."),async a=>{await this.cloud.sendFriendRequest(a);this.showMessage(localize("Friend request sent!"),2)})}; IDE_Morph.prototype.respondToFriendRequest=async function(a){function b(e,f){e=e.center().x-f.width()/2;f.setLeft(e)}const c=new DialogBoxMorph(this,()=>this.cloud.respondToFriendRequest(a.sender,"Approved"));c.labelString="Respond to Friend Request";c.key=`FriendRequestFrom${a.sender}`;var d=localize("Received friend request from ")+a.sender+".\n\n"+localize("What would you like to do?");d=new TextMorph(d,c.fontSize,c.fontStyle,!0,!1,"center",null,null,MorphicPreferences.isFlat?null:new Point(1, @@ -3139,14 +3138,14 @@ this.srcBar.setPosition(this.body.position()),c.setWidth(this.body.width()-this. this.magnifyingGlass.setLeft(this.listField.left())),this.notesField.setExtent(new Point(this.body.right()-this.listField.right()-b,100)),this.palette.setExtent(new Point(this.notesField.width(),this.listField.height()-this.notesField.height()-b)),this.palette.setRight(this.body.right()),this.palette.setTop(c.bottom()+this.padding),this.notesField.setPosition(this.palette.bottomLeft().add(new Point(0,b))),this.notesField.setTop(this.palette.bottom()+b),this.notesField.setLeft(this.palette.left())); this.label&&(this.label.setCenter(this.center()),this.label.setTop(this.top()+(a-this.label.height())/2));this.buttons&&0{e.forEach(m=>{m.category===h&&(h!==c&&(g+=4),c=h,b=m.templateInstance().fullImage(),d=new Morph,d.isCachingImage=!0,d.bounds.setWidth(b.width),d.bounds.setHeight(b.height),d.cachedImage=b,d.setPosition(new Point(f,g)),this.palette.addContents(d),g+=d.fullBounds().height()+4)})}); +LibraryDialogMorph.prototype.displayBlocks=function(a){var b,c,d,e=this.cachedLibrary(a);if(e.length){this.initializePalette();var f=this.palette.left()+4;var g=this.palette.top();SpriteMorph.prototype.categories.forEach(k=>{e.forEach(m=>{m.category===k&&(k!==c&&(g+=4),c=k,b=m.templateInstance().fullImage(),d=new Morph,d.isCachingImage=!0,d.bounds.setWidth(b.width),d.bounds.setHeight(b.height),d.cachedImage=b,d.setPosition(new Point(f,g)),this.palette.addContents(d),g+=d.fullBounds().height()+4)})}); this.palette.scrollX(4);this.palette.scrollY(4);this.fixLayout()}};LibraryDialogMorph.prototype.showMessage=function(a){(new MenuMorph(null,a)).popUpCenteredInWorld(this.palette.contents)};Process.prototype.resolveAddresses=function(a,b){return b.flatMap(c=>{if(c.includes("@"))return[c];let d=[c];"everyone in room"===c?d=a.room.getRoleNames():"others in room"===c&&(d=a.room.getRoleNames().filter(g=>g!==a.projectName));const e=a.room.ownerId,f=a.room.name;return d.map(g=>`${g}@${f}@${e}`)})}; Process.prototype.doSocketMessage=function(a){var b=this.homeContext.receiver.parentThatIsA(IDE_Morph),c=arguments[arguments.length-1],d=[b.projectName,b.room.name,b.room.ownerId].join("@"),e=a[0],f=a[1],g=Array.prototype.slice.call(arguments,1,f.length+1);if(SnapActions.isCollaborating()&&!b.allowMsgsWhileCollaborating)null===b.allowMsgsWhileCollaborating&&(c=localize("Message sending blocked while collaborating"),f=localize("By default, message sending is disabled when collaborating because it can make\ndebugging distributed applications difficult.\n\n")+ -localize("When multiple users collaborate, each collaborating user may send his/her own response\nto a received message. ")+localize('This is problematic when using the "send msg and wait"\nblock as well as for applications like turn-based games.\n\n')+localize("Would you like to enable message sending while collaborating?"),b.confirm(f,c).then(k=>b.allowMsgsWhileCollaborating=k)),this.topBlock.showBubble("Cannot send message when collaborating");else if(e){var h={};for(var m=f.length;m--;)h[f[m]]= -g[m]||"";c=(c instanceof List?c.asArray():[c]).flat();var l=this.resolveAddresses(b,c);c=function(){b.sockets.sendMessage({type:"message",dstId:l,srcId:d,msgType:e,content:h})};f=1E3/90;if(!this.reportIsFastTracking())return c();if(!this["asyncFn-sendMsg"])this["asyncFn-sendMsg"]={},this["asyncFn-sendMsg"].endTime=(new Date).getTime()+f,c(),this["asyncFn-sendMsg"].onerror=function(k){this["asyncFn-sendMsg"].error=k};else if((new Date).getTime()>this["asyncFn-sendMsg"].endTime){this["asyncFn-sendMsg"]= +localize("When multiple users collaborate, each collaborating user may send his/her own response\nto a received message. ")+localize('This is problematic when using the "send msg and wait"\nblock as well as for applications like turn-based games.\n\n')+localize("Would you like to enable message sending while collaborating?"),b.confirm(f,c).then(h=>b.allowMsgsWhileCollaborating=h)),this.topBlock.showBubble("Cannot send message when collaborating");else if(e){var k={};for(var m=f.length;m--;)k[f[m]]= +g[m]||"";c=(c instanceof List?c.asArray():[c]).flat();var l=this.resolveAddresses(b,c);c=function(){b.sockets.sendMessage({type:"message",dstId:l,srcId:d,msgType:e,content:k})};f=1E3/90;if(!this.reportIsFastTracking())return c();if(!this["asyncFn-sendMsg"])this["asyncFn-sendMsg"]={},this["asyncFn-sendMsg"].endTime=(new Date).getTime()+f,c(),this["asyncFn-sendMsg"].onerror=function(h){this["asyncFn-sendMsg"].error=h};else if((new Date).getTime()>this["asyncFn-sendMsg"].endTime){this["asyncFn-sendMsg"]= null;return}this.pushContext("doYield");this.pushContext()}};Process.prototype.MESSAGE_REPLY_TIMEOUT=1500; -Process.prototype.doSocketRequest=function(a){var b=this.homeContext.receiver.parentThatIsA(IDE_Morph),c=arguments[arguments.length-1],d=[b.projectName,b.room.name,b.room.ownerId].join("@"),e=a[0],f=a[1],g=Array.prototype.slice.call(arguments,1,f.length+1);if(SnapActions.isCollaborating()&&!SnapActions.isLeader)this.topBlock.showBubble("Cannot send message when collaborating");else if(e){if(this.requestId){if(this.reply){var h=this.requestId;b=this.reply;this.requestId===h&&(this.messageSentAt=this.reply= -this.requestId=null);return b.content.body}if(Date.now()-this.messageSentAt>this.MESSAGE_REPLY_TIMEOUT)return this.homeContext.receiver.parentThatIsA(StageMorph).rpcError="Timeout Exceeded",null}else{this.requestId=h="__REQ"+Date.now();var m={};for(var l=f.length;l--;)m[f[l]]=g[l]||"";c=(c instanceof List?c.asArray():[c]).flat();c=this.resolveAddresses(b,c);b.sockets.sendMessage({type:"message",dstId:c,srcId:d,msgType:e,requestId:h,content:m});this.messageSentAt=Date.now()}this.pushContext("doYield"); +Process.prototype.doSocketRequest=function(a){var b=this.homeContext.receiver.parentThatIsA(IDE_Morph),c=arguments[arguments.length-1],d=[b.projectName,b.room.name,b.room.ownerId].join("@"),e=a[0],f=a[1],g=Array.prototype.slice.call(arguments,1,f.length+1);if(SnapActions.isCollaborating()&&!SnapActions.isLeader)this.topBlock.showBubble("Cannot send message when collaborating");else if(e){if(this.requestId){if(this.reply){var k=this.requestId;b=this.reply;this.requestId===k&&(this.messageSentAt=this.reply= +this.requestId=null);return b.content.body}if(Date.now()-this.messageSentAt>this.MESSAGE_REPLY_TIMEOUT)return this.homeContext.receiver.parentThatIsA(StageMorph).rpcError="Timeout Exceeded",null}else{this.requestId=k="__REQ"+Date.now();var m={};for(var l=f.length;l--;)m[f[l]]=g[l]||"";c=(c instanceof List?c.asArray():[c]).flat();c=this.resolveAddresses(b,c);b.sockets.sendMessage({type:"message",dstId:c,srcId:d,msgType:e,requestId:k,content:m});this.messageSentAt=Date.now()}this.pushContext("doYield"); this.pushContext()}};Process.prototype.doSocketResponse=function(a){var b=this.homeContext.receiver.parentThatIsA(IDE_Morph);try{var c=this.context.variables.getVar("__requestId__");var d=this.context.variables.getVar("__srcId__")}catch(e){throw Error(localize("Cannot find message to which to respond!"));}b.sockets.sendMessage({type:"message",dstId:d,msgType:"__reply__",requestId:c,content:{body:a}})}; Process.prototype.receiveSocketMessage=function(a){var b=this.context.outerContext.variables;if(-1!==b.names().indexOf("__message__")){var c=this.context.variables.getVar("__message__");a.length||(a=Object.keys(c));for(var d=a.length;d--;)b.addVar(a[d],c[a[d]]);b.deleteVar("__message__")}};Process.prototype.createRPCUrl=function(a){var b=this.homeContext.receiver.parentThatIsA(IDE_Morph);({clientId:b}=b.cloud);return a+"?clientId="+b}; Process.prototype.callRPC=function(a,b,c){var d=this.createRPCUrl(a);c&&(d+="&t="+Date.now());"string"===typeof b&&(c=b.split("&").map(function(e){return e.split("=")}),b={},c.forEach(function(e){b[e[0]]=e[1]}));if(this.rpcRequest){if(4===this.rpcRequest.readyState){if(0===this.rpcRequest.status){d=this.homeContext.receiver.parentThatIsA(StageMorph);d.rpcError="Request too large";return}if(404===this.rpcRequest.status){const [e,f]=a.split("/").filter(g=>g).reverse();return this.errorRPCNotAvailable(f, @@ -3156,15 +3155,15 @@ Process.prototype.getCostumeFromRPC=function(a,b){if(!this.rpcRequest||4!==this. this.requestedImage=null,b=newCanvas(new Point(a.width,a.height),!0),b.getContext("2d").drawImage(a,0,0),new Costume(b);this.pushContext("doYield");this.pushContext()};Process.prototype.getJSFromRPC=function(a,b){if("string"===typeof b){var c=b;b={};c.split("&").forEach(function(d){var e=d.split("=");d=e[0];e=e[1];d&&(b[d]=e)})}if(a=this.callRPC(a,b,!0))try{a=JSON.parse(a)}catch(d){}return a=this.parseRPCResult(a)}; Process.prototype.parseRPCResult=function(a){return a instanceof Array?new List(a.map(this.parseRPCResult.bind(this))):"string"===typeof a&&"<"===a[0]?this.homeContext.receiver.parentThatIsA(IDE_Morph).sockets.deserializeData([a])[0]:a};function listToArray(a){if(!(a instanceof List))return a;var b=[];a=a.asArray();for(var c,d=0;d{const e=this.context.doTryCatchState.reset;this.context.doTryCatchState.reset=null;e&&e()};if(this.context.doTryCatchState)d();else{const e=this.isCatchingErrors,f=this.handleError,g=this.context;this.context.doTryCatchState={reset:()=>{this.isCatchingErrors=e;this.handleError=f}};this.isCatchingErrors=!0;this.handleError=(h,m)=>{for(;this.context!==g;)this.popContext();d();this.context.outerContext.variables.addVar(b);this.context.outerContext.variables.setVar(b, -(h.message||h).toString());this.pushContext();this.evaluate(c,new List([]),!0)};this.pushContext();this.evaluate(a,new List([]),!0)}};Process.prototype.doThrow=function(a){throw Error(a.toString());}; +Process.prototype.doTryCatch=function(a,b,c){const d=()=>{const e=this.context.doTryCatchState.reset;this.context.doTryCatchState.reset=null;e&&e()};if(this.context.doTryCatchState)d();else{const e=this.isCatchingErrors,f=this.handleError,g=this.context;this.context.doTryCatchState={reset:()=>{this.isCatchingErrors=e;this.handleError=f}};this.isCatchingErrors=!0;this.handleError=(k,m)=>{for(;this.context!==g;)this.popContext();d();this.context.outerContext.variables.addVar(b);this.context.outerContext.variables.setVar(b, +(k.message||k).toString());this.pushContext();this.evaluate(c,new List([]),!0)};this.pushContext();this.evaluate(a,new List([]),!0)}};Process.prototype.doThrow=function(a){throw Error(a.toString());}; Process.prototype.runAsyncFn=function(a,b){b=b||{};b={timeout:b.timeout||2E3,args:b.args||[]};var c="_asyncFunc"+a.name,d=this;if(!(c&&a instanceof Function))throw Error("id or asyncFn input missing");if(this[c]){if(d[c].complete){var e=d[c];d[c]=null;return e.response}if(d[c].error)throw e=d[c],d[c]=null,console.error(e.response),Error(e.response);}else this[c]={},this[c].startTime=(new Date).getTime(),e=new Promise(function(f,g){setTimeout(g,b.timeout,"timeout")}),a=a.apply(this,b.args),e=Promise.race([a, e]).then(function(f){d[c].complete=!0;d[c].response=f}).catch(function(f){d[c].error=!0;d[c].response=f}),d[c].onerror=function(f){d[c].error=f},d[c].promise=e;this.pushContext("doYield");this.pushContext()}; var WebSocketManager=function(a,b){this.ide=a;this.uuid=b.clientId;this.websocket=null;this.messages=[];this.msgHandlerQueues=[];this.url=b.cloudUrl.replace(/^http/,"ws")+`/network/${b.clientId}/connect`;this.lastSocketActivity=Date.now();this._connectWebSocket();this.version=Date.now();this.serverVersion=null;this.inActionRequest=this.connected=this.hasConnected=this.errored=!1;this._requests={};this._counter=1;this.serializer=new NetsBloxSerializer};WebSocketManager.HEARTBEAT_INTERVAL=25E3; @@ -3172,7 +3171,7 @@ class MessageHandler{constructor(){this._handlers={}}handle(a){if(this._handlers WebSocketManager.IDEMessageHandlers={"action-rejected":function(a){a.reason&&this.ide.showMessage(localize(a.reason))},"user-action":function(a,b){const c=this.ide.cloud;a.projectId===c.projectId&&a.roleId===c.roleId&&(a=SnapActions.onMessage(a.action))&&this.sendIDEMessage(a,b)},"request-actions":function(a,b){b=this.ide.cloud;if(a.projectId===b.projectId&&a.roleId===b.roleId){b=utils.takeWhile(SnapUndo.allEvents.reverse(),c=>c.id>a.actionId).reverse();if(utils.zip([{id:actionId}].concat(b),b).reduce((c, [d,e])=>c||1{const h=e.filter(m=>m!==this.uuid);this.sendIDEMessage({type:"close-dialog",id:d},...h)};a=await this.ide.cloud.getProjectMetadata(b);const g=(new DialogBoxMorph(null,()=>{f();this.ide.cloud.sendCollaborateRequest(b,c);g.destroy()})).withKey(d);g.askYesNo("Collaboration Request",c+localize(" would like to be made a collaborator on ")+a.name+"\n\n"+localize("Would you like to make ")+ +d.destroy()})}},"permission-elevation-request":async function(a){const {projectId:b,username:c,id:d,clients:e}=a,f=()=>{const k=e.filter(m=>m!==this.uuid);this.sendIDEMessage({type:"close-dialog",id:d},...k)};a=await this.ide.cloud.getProjectMetadata(b);const g=(new DialogBoxMorph(null,()=>{f();this.ide.cloud.sendCollaborateRequest(b,c);g.destroy()})).withKey(d);g.askYesNo("Collaboration Request",c+localize(" would like to be made a collaborator on ")+a.name+"\n\n"+localize("Would you like to make ")+ c+localize(" a collaborator?"),this.ide.world());g.cancel=()=>{f();g.destroy()}},"close-dialog":function(a){const b=this.ide.world().stamp;(a=DialogBoxMorph.prototype.instances[b][a.id])&&a.destroy()}}; WebSocketManager.MessageHandlers={"ide-message":function(a){const {data:b,sender:c}=a;let d,e;try{d=WebSocketManager.IDEMessageHandlers[b.type].call(this,b,c)}catch(f){e=f.message}a.reqID&&this.sendIDEMessage({type:"response",reqID,response:d,error:e})},response:function(a){const b=this._requests[a.reqID];b&&(a.error?b.reject(Error(a.error)):b.resolve(a.response),delete this._requests[a.reqID])},"request-actions-complete":function(){this.inActionRequest=!1},"reload-project":function(a){this.ide.requestProjectReload(a.message)}, "report-version":function(a){a=a.body;this.serverVersion||(this.serverVersion=a);this.serverVersion!==a&&this.ide.showUpdateNotification()},message:function(a){var b=a.msgType;if(this.ide.room.isReplayingTrace())this.ide.room.trace.notified||(this.ide.showMessage(localize("Ignoring messages received while\nviewing network trace")),this.ide.room.trace.notified=!0);else{var c=this.deserializeMessage(a);this.onMessageReceived(b,c,a)}},"room-roles":function(a){this.ide.room.onRoomStateUpdate(a)},"close-invite":function(a){(a= @@ -3185,12 +3184,12 @@ Date.now();this.connected=!0;this.onConnect(this.hasConnected);this.hasConnected WebSocketManager.prototype.onClose=function(){this.connected&&(this.version=Date.now(),this.connected=!1);if(!this.errored&&5E3{const c=this._requests[a.reqID];c&&(c.reject(Error("Timeout exceeded.")),delete this._requests[a.reqID])},5E3);return this.sendIDEMessage(a,...b)};WebSocketManager.prototype.serializeMessage=function(a){if(a.content){var b=Object.keys(a.content);this.serializer.flush();for(var c=b.length;c--;){var d=a.content[b[c]];isObject(d)&&(a.content[b[c]]=this.serializer.getPortableXML(d))}this.serializer.flush()}return JSON.stringify(a)}; -WebSocketManager.prototype.deserializeMessage=function(a){var b=a.content,c=Object.keys(b),d=c.map(function(e){return b[e]});this.deserializeData(d).forEach(function(e,f){a.content[c[f]]=e});return a.content}; -WebSocketManager.prototype.deserializeData=function(a){var b,c;SnapActions.serializer.project={stage:new StageMorph,sprites:{}};return a.map(function(d){if("<"===d[0])try{return console.log("Received serialized format:",d.length),c=SnapActions.serializer.parse(d),(b=c.allChildren().find(function(e){return"project"===e.tag}))&&SnapActions.serializer.rawLoadProjectModel(b),SnapActions.serializer.loadValue(c)}catch(e){console.error("Could not deserialize!",e)}return d})}; +WebSocketManager.prototype.deserializeMessage=function(a){var b=a.content,c=Object.keys(b),d=c.map(function(e){return b[e]});this.deserializeData(d).forEach(function(e,f){a.content[c[f]]=e});return a.content};function snapify(a){if(Array.isArray(a))return new List(a.map(b=>snapify(b)));if("object"===typeof a){const b=[];for(const c in a)b.push(new List([c,snapify(a[c])]));return new List(b)}return value} +WebSocketManager.prototype.deserializeData=function(a){var b,c;SnapActions.serializer.project={stage:new StageMorph,sprites:{}};return a.map(function(d){d=snapify(d);if("string"===typeof d&&"<"===d[0])try{return console.log("Received serialized format:",d.length),c=SnapActions.serializer.parse(d),(b=c.allChildren().find(function(e){return"project"===e.tag}))&&SnapActions.serializer.rawLoadProjectModel(b),SnapActions.serializer.loadValue(c)}catch(e){console.error("Could not deserialize!",e)}return d})}; WebSocketManager.prototype.onConnect=async function(a){this.sendMessage({type:"ping"});if(a){a=this.ide.cloud.onerror;this.ide.cloud.onerror=()=>{};try{await this.updateRoomInfo(),this.ide.cloud.onerror=a,this.ide.cloud.projectId&&SnapActions.requestMissingActions(!0)}catch(e){if(this.ide.cloud.onerror=a,e.message.includes("Project not found")){a=this.ide;var b=a.room.getRoleCount(),c=window.location.href,d=a.exportProjectXml(a.room.name,[a.getSerializedRole()]);await a.droppedText(d);this.messages= [];1{const c=await this.ide.cloud.newProject(this.ide.room.name),d=Object.keys(c.roles).shift();console.log("Project not found. Created new one on the server:",c.id);await this.ide.cloud.setClientState(c.id,d)};try{return this.ide.cloud.projectId||await b(),await this.ide.callCloudSilently(c=>c.setClientState())}catch(c){if(a&&404===c.status)await b();else throw c;}}; -WebSocketManager.prototype.onMessageReceived=function(a,b,c){var d=!this.msgHandlerQueues.length,e=this.ide.stage;b=b||[];if(""!==a){const f="__reply__"===a;e.threads.processes.forEach(function(g){f&&g.requestId===c.requestId&&(g.reply=c)});e.children.concat(e).forEach(g=>{isSnapObject(g)&&g.allHatBlocksForSocket(a).forEach(h=>{const m=new VariableFrame;m.addVar("__message__",b);m.addVar("__requestId__",c.requestId);m.addVar("__srcId__",c.srcId);this.addMsgToQueue(g,h,a,m)})});d&&setTimeout(this.tryStartQueuedMsgs.bind(this), +WebSocketManager.prototype.onMessageReceived=function(a,b,c){var d=!this.msgHandlerQueues.length,e=this.ide.stage;b=b||[];if(""!==a){const f="__reply__"===a;e.threads.processes.forEach(function(g){f&&g.requestId===c.requestId&&(g.reply=c)});e.children.concat(e).forEach(g=>{isSnapObject(g)&&g.allHatBlocksForSocket(a).forEach(k=>{const m=new VariableFrame;m.addVar("__message__",b);m.addVar("__requestId__",c.requestId);m.addVar("__srcId__",c.srcId);this.addMsgToQueue(g,k,a,m)})});d&&setTimeout(this.tryStartQueuedMsgs.bind(this), 50)}};WebSocketManager.prototype.addMsgToQueue=function(a,b,c,d){let e=this.getMessageQueue(b);e||(e=new MessageHandlerQueue(this.ide.stage,b,a),this.msgHandlerQueues.push(e));e.addMessage({variables:d,messageType:c})};WebSocketManager.prototype.getMessageQueue=function(a){return this.msgHandlerQueues.find(b=>b.handler===a)}; WebSocketManager.prototype.tryStartQueuedMsgs=function(){for(let a=0;athis.tryStartQueuedMsgs(),5)}; WebSocketManager.prototype.getSerializedProject=function(){var a=this.ide;a.serializer.flush();a.serializer.isCollectingMedia=!0;var b=a.serializer.serialize(a.stage);var c=a.serializer.mediaXML(a.projectName);a.serializer.isCollectingMedia=!1;a.serializer.flushMedia();try{a.serializer.parse(b)}catch(d){throw a.showMessage("Serialization of program data failed:\n"+d),Error("Serialization of program data failed:\n"+d);}if(null!==c)try{a.serializer.parse(c)}catch(d){throw a.showMessage("Serialization of media failed:\n"+ @@ -3219,8 +3218,8 @@ RoomMorph.prototype.getRoleNames=function(){return this.getRoles().map(function( RoomMorph.prototype.getRoleFromState=function(a){if(a.browser){var {roleId:b}=a.browser;if(this.projectId===this.ide.cloud.projectId)return this.getRoles().find(c=>c.id===b)}}; RoomMorph.prototype.updateRoles=function(a){var b=this,c=!1,d;this.getRoles().forEach(function(e){a[e.id]?(d=a[e.id].occupants,RoomMorph.sameOccupants(e.users,d)||e.setOccupants(d),e.setName(a[e.id].name),delete a[e.id]):(e.destroy(),c=!0)});Object.keys(a).forEach(function(e){e=new RoleMorph(e,a[e].name,a[e].occupants);b.add(e);c=!0});return c};RoomMorph.prototype.getInnerHeight=function(){return this.ownerLabel.top()-10-this.top()}; RoomMorph.prototype.getRadius=function(){var a=this.getInnerHeight();return Math.min(this.width(),a)/2};RoomMorph.prototype.getRoleSize=function(){var a=this.getRoles().length;a=2*Math.PI/a;var b=this.getRadius();var c=new Point(b/2,0);var d=(new Point(Math.cos(a),Math.sin(a))).multiplyBy(b/2);d=c.distanceTo(d)-10;b=c.distanceTo(new Point(0,b/2));athis.ide.cloud.renameRole(a,b)))};RoomMorph.prototype.evictUser=async function(a){await this.ide.cloud.evictOccupant(a.id);this.ide.showMessage("Evicted "+a.name+"!")}; RoomMorph.prototype.inviteUser=async function(a){var b=[];if(this.isOwner()||this.isCollaborator())try{b=await this.ide.cloud.getFriendList()}catch(c){this.ide.cloudError().call(null,c.message)}b.unshift("myself");b=this.world();a=new InviteOccupantDialogMorph(this.ide,a.id);a.popUp(b);a.setCenter(b.center());a.filterField.edit()}; -RoomMorph.prototype.promptShare=function(a){var b=this.getRoleNames(),c={},d=this.world(),e=this;b.splice(b.indexOf(this.ide.projectName),1);for(var f=0;f{const f=await this.ide.cloud.getProjectMetadata(a),g=await this.ide.cloud.getRole(a,b);await this.ide.rawLoadCloudRole(f,g)})).withKey("invite/"+a+"/"+b);e.askYesNo("Room Invitation",localize(d===this.ide.cloud.username?'Would you like to move to "'+c+'"?':d+' has invited you to join\nhim/her at "'+c+'"'),this.ide.world());setTimeout(()=>e.destroy(),15E3)}; RoomMorph.prototype.sendMessageToRole=function(a,b){a.roleId=b;a.from=this.ide.projectName;this.queuedRoleMsgs.push(a);return this.sendQueuedMessages().includes(a)};RoomMorph.prototype.sendQueuedMessages=function(){const [a,b]=utils.partition(this.queuedRoleMsgs,c=>{const d=this.getRoles().find(e=>e.id===c.roleId);return d?0{const e=this.getRoleFromState(c);d=this.getRoleFromState(d);e&&d&&this.showSentMsg(a,e,d,b)})}; @@ -3280,8 +3279,8 @@ RoomEditorMorph.prototype.enterRecordMode=function(){SnapActions.isCollaborating RoomEditorMorph.prototype.enterReplayMode=function(){SnapActions.isCollaborating()?this.room.ide.showMessage(localize("Cannot replay network actions while collaborating")):(this.replayControls.enable(),this.room.startTraceReplay(this.replayControls),this.updateRoomControls())};RoomEditorMorph.prototype.updateRoomControls=function(){this.room.rerender();this.room.isEditable()&&!this.isReplayMode()?this.addRoleBtn.show():this.addRoleBtn.hide()}; RoomEditorMorph.prototype.createMsgPalette=function(){var a=new ScrollFrameMorph;a.setColor(new Color(0,0,0,0));a.acceptsDrops=!1;a.contents.acceptsDrops=!1;return a}; RoomEditorMorph.prototype.updateMsgPalette=function(){var a=this.room.ide.stage,b=this.palette,c=a.deletableMessageNames();b.contents.children.forEach(function(m){b.contents.removeChild(m)});var d=new Point(b.bounds.origin.x+10,b.bounds.origin.y+10),e=new Rectangle;e.origin=b.bounds.origin.copy();e.setExtent(ZERO);for(var f=0;fm.left()).reduce((m,l)=>Math.min(l,m),Infinity)-this.left();d=this.room.height();b.bounds.setWidth(Math.min(e.width()+10,c));b.bounds.setHeight(Math.min(e.height()+10,d));e=b.contents.children.reduce((m,l)=>m.max(l.bounds.extent()),b.bounds.extent());b.contents.bounds.setExtent(e);b.contents.adjustBounds();b.fixLayout();b.rerender();b.version=a.messageTypes.version};UserDialogMorph.prototype=new DialogBoxMorph; +d.y+=g.height()+10;e.mergeWith(g.bounds);g.justDropped=function(){this.destroy()};g.mouseClickLeft=function(){const m=new SpeechBubbleMorph(0===a.messageTypes.msgTypes[this.blockSpec].fields.length?"This message type has no fields.":a.messageTypes.msgTypes[this.blockSpec].fields,null,null,2),l=(new Point(0,0)).add(this.bounds.corner);m.popUp(this.world(),l)};var k=new MenuMorph(this,null);k.addItem("Send to...",function(){this.room.promptShare(g.blockSpec)});g.children[0].customContextMenu=k;g.customContextMenu= +k;b.contents.add(g)}c=this.room.getRoles().map(m=>m.left()).reduce((m,l)=>Math.min(l,m),Infinity)-this.left();d=this.room.height();b.bounds.setWidth(Math.min(e.width()+10,c));b.bounds.setHeight(Math.min(e.height()+10,d));e=b.contents.children.reduce((m,l)=>m.max(l.bounds.extent()),b.bounds.extent());b.contents.bounds.setExtent(e);b.contents.adjustBounds();b.fixLayout();b.rerender();b.version=a.messageTypes.version};UserDialogMorph.prototype=new DialogBoxMorph; UserDialogMorph.prototype.constructor=UserDialogMorph;UserDialogMorph.uber=DialogBoxMorph.prototype;function UserDialogMorph(a,b="Friends"){this.init(a,b)}UserDialogMorph.prototype.init=function(a,b){UserDialogMorph.uber.init.call(this,a,nop,null);this.key=b;this.labelString=localize(b);this.userList=[];this.buildContents();this.refresh()}; UserDialogMorph.prototype.buildContents=function(){this.addBody(new Morph);this.body.color=this.color;this.buildFilterField();this.listField=new ListMorph(this.userList);this.fixListFieldItemColors();this.listField.fixLayout=nop;this.listField.edge=InputFieldMorph.prototype.edge;this.listField.fontSize=InputFieldMorph.prototype.fontSize;this.listField.typeInPadding=InputFieldMorph.prototype.typeInPadding;this.listField.contrast=InputFieldMorph.prototype.contrast;this.listField.render=InputFieldMorph.prototype.render; this.listField.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;this.body.add(this.listField);this.listField.action=a=>{void 0!==a&&(this.unfriendButton.show(),this.buttons.fixLayout(),this.fixLayout(),this.edit())};this.inviteFriendButton=this.addButton(()=>this.target.sendFriendRequest(),"Add Friend");this.inviteFriendButton.hint=localize("Send friend request to another user on NetsBlox. Only friends are shown in this window.");this.unfriendButton=this.addButton(async()=>{this.target.cloud.unfriend(this.listField.selected); @@ -3307,7 +3306,7 @@ NetsBloxMorph.prototype.init=function(a,b){NetsBloxMorph.uber.init.call(this,a,b NetsBloxMorph.prototype.onInvalidHosts=function(a){a=a.map(b=>{const c=b.categories[0];return c?c+" ("+b.url+")":b.url}).join("\n");this.inform("Invalid Services Hosts","The following have been registered to provide additional\nNetsBlox services but are unavailable:\n\n"+a,this.world())};NetsBloxMorph.prototype.buildPanes=function(){this.createRoom();NetsBloxMorph.uber.buildPanes.call(this)}; NetsBloxMorph.prototype.clearProject=function(){this.source=this.cloud.username?"cloud":"local";this.stage&&this.stage.destroy();"#lang:"!==location.hash.substr(0,6)&&(location.hash="");this.globalVariables=new VariableFrame;this.currentSprite=new SpriteMorph(this.globalVariables);this.sprites=new List([this.currentSprite]);StageMorph.prototype.dimensions=new Point(480,360);StageMorph.prototype.hiddenPrimitives={};StageMorph.prototype.codeMappings={};StageMorph.prototype.codeHeaders={};StageMorph.prototype.enableCodeMapping= !1;StageMorph.prototype.enableInheritance=!1;StageMorph.prototype.enableSublistIDs=!1;SpriteMorph.prototype.useFlatLineEnds=!1;Process.prototype.enableLiveCoding=!1;this.silentSetProjectName("");this.projectNotes="";this.createStage();this.add(this.stage);this.createCorral();this.selectSprite(this.stage.children[0]);this.fixLayout()}; -NetsBloxMorph.prototype.cloudMenu=async function(){var a=NetsBloxMorph.uber.cloudMenu.call(this),b=this.cloud.username;if(b){const [f,g,h]=await Promise.all([this.cloud.getUserData(),this.cloud.getFriendRequestList(),this.cloud.getCollaboratorRequestList()]);var c=f;var d=g;var e=h}b&&(0===c.linkedAccounts.length?a.addItem("Link to Snap! account...","linkAccount"):a.addItem(localize("Unlink Snap! account..."),()=>this.unlinkAccount(c.linkedAccounts[0])));if(b){a.addLine();this.room.isOwner()&&a.addItem("Collaborators...", +NetsBloxMorph.prototype.cloudMenu=async function(){var a=NetsBloxMorph.uber.cloudMenu.call(this),b=this.cloud.username;if(b){const [f,g,k]=await Promise.all([this.cloud.getUserData(),this.cloud.getFriendRequestList(),this.cloud.getCollaboratorRequestList()]);var c=f;var d=g;var e=k}b&&(0===c.linkedAccounts.length?a.addItem("Link to Snap! account...","linkAccount"):a.addItem(localize("Unlink Snap! account..."),()=>this.unlinkAccount(c.linkedAccounts[0])));if(b){a.addLine();this.room.isOwner()&&a.addItem("Collaborators...", "manageCollaborators");b=new MenuMorph(this);b.addItem("View Friends...","manageFriends");b.addItem("Send Friend Request...","sendFriendRequest");a.addMenu("Friends...",b);if(d.length){const f=new MenuMorph(this);d.forEach(g=>{f.addItem(`${g.sender}...`,()=>this.respondToFriendRequest(g))});a.addMenu("Friend Requests...",f)}if(e.length){const f=new MenuMorph(this);e.forEach(g=>{f.addItem(`${g.sender}...`,()=>this.respondToCollaborateRequest(g))});a.addMenu("Collaboration Requests...",f)}}return a}; NetsBloxMorph.prototype.settingsMenu=function(){var a=NetsBloxMorph.uber.settingsMenu.call(this);a.items=a.items.filter(function(b){return"toggleCollaborativeEditing"!==b[1].toString()});return a};NetsBloxMorph.prototype.newProject=async function(a){const b=await this.cloud.newProject(a);this.createRoom();this.room.silentSetRoomName(b.name);a||this.updateUrlQueryString(b);await SnapActions.openProject();[a]=Object.values(b.roles);this.silentSetProjectName(a.name);this.extensions.onNewProject()}; NetsBloxMorph.prototype.newRole=function(a){this.clearProject();a&&this.silentSetProjectName(a)};NetsBloxMorph.prototype.createRoom=function(){this.room=new RoomMorph(this)};NetsBloxMorph.prototype.createSpriteEditor=function(){"room"===this.currentTab?(this.spriteEditor&&this.spriteEditor.destroy(),this.spriteEditor=new RoomEditorMorph(this.room,this.sliderColor),this.spriteEditor.color=this.groupColor,this.add(this.spriteEditor)):NetsBloxMorph.uber.createSpriteEditor.call(this)}; @@ -3319,8 +3318,8 @@ NetsBloxMorph.prototype.createSpriteBar=function(){NetsBloxMorph.uber.createSpri 15;e.edge=1;e.labelShadowOffset=new Point(-1,-1);e.labelShadowColor=c[1];e.labelColor=this.buttonLabelColor;e.rerender();e.fixLayout();b.add(e);b.fixLayout();b.children.forEach(function(f){f.refresh()})}; NetsBloxMorph.prototype.projectMenu=function(){var a=this,b=NetsBloxMorph.uber.projectMenu.call(this),c=16===this.world().currentKey;c&&(b.items.splice(10,0,[localize("Export role..."),function(){a.projectName?a.exportRole(a.projectName,c):a.prompt("Export Project As...",function(f){a.exportRole(f,!1,!0)},null,"exportRole")},'save "'+a.projectName+'" as XML\nto your downloads folder',new Color(100,0,0)]),b.items.splice(10,0,[localize("Export to Snap! project..."),function(){var f=a.getSnapXml(),g= 1===this.room.getRoleCount()?this.room.name:this.projectName;a.saveXMLAs(f,g);a.showMessage("Exported!",1)},'export "'+a.projectName+'" as Snap!-compatible XML',new Color(100,0,0)]));this.stage.deletableMessageNames().length&&!this.stage.globalBlocks.length&&b.items.splice(10,0,["Export blocks/msgs...","exportGlobalBlocks","show global custom block definitions/message types as XML\nin a new browser window"]);var d=-1%',a.name,a.code+a.media)}; @@ -3341,20 +3340,20 @@ b,a)}; NetsBloxMorph.prototype.reportBug=function(){var a=(new DialogBoxMorph).withKey("bugReport"),b=new ScrollFrameMorph,c=new TextMorph(""),d=a.ok,e=this,f=this.world();b.padding=6;b.setWidth(250);b.acceptsDrops=!1;b.contents.acceptsDrops=!1;c.setWidth(250-2*b.padding);c.setPosition(b.topLeft().add(b.padding));c.enableSelecting();c.isEditable=!0;b.setHeight(250);b.fixLayout=nop;b.edge=InputFieldMorph.prototype.edge;b.fontSize=InputFieldMorph.prototype.fontSize;b.typeInPadding=InputFieldMorph.prototype.typeInPadding;b.contrast= InputFieldMorph.prototype.contrast;b.render=InputFieldMorph.prototype.render;b.drawRectBorder=InputFieldMorph.prototype.drawRectBorder;b.addContents(c);c.rerender();a.ok=function(){e.submitBugReport(c.text);d.call(this)};a.justDropped=function(){c.edit()};a.labelString=localize("What went wrong?");a.createLabel();a.addBody(b);a.addButton("ok","OK");a.addButton("cancel","Cancel");a.fixLayout();a.popUp(f);a.setCenter(f.center());c.edit()}; NetsBloxMorph.prototype.submitBugReport=function(a,b){var c=this,d=this.world().worldCanvas,e=!!b,f={};var g=NetsBloxSerializer.prototype.app.replace("NetsBlox ","").replace(/,.*$/,"");f.description=a;f.timestamp=new Date;f.userAgent=navigator.userAgent;f.version=g;f.clientUuid=this.sockets.uuid;try{f.screenshot=d.toDataURL("image/png")}catch(m){console.warn("Unable to capture screenshot for bug report",m)}f.project=this.serializer.serialize(this.stage);f.undoState=SnapUndo;f.user=this.cloud.username; -f.isAutoReport=!!b;a=window.location.origin+"/bugs/";f.isAutoReport&&(d=SnapActions.currentEvent,f.description=["## Auto-report\nError:",b.stack,"---\nFailing Event:",JSON.stringify(d,null,2)].join("\n"),f.error=b,f.event=d,a+="?auto=true");var h=new XMLHttpRequest;h.open("post",a);h.setRequestHeader("Content-Type","application/json; charset=UTF-8");h.onreadystatechange=function(){4!==h.readyState||e||(199h.status?c.showMessage(localize("Bug has been reported!"),2):c.cloudError()(localize("Bug could not be reported:")+ -"\n\n"+h.responseText))};h.send(JSON.stringify(f))};NetsBloxMorph.prototype.showBugReportScreenshot=function(a){var b=this,c=new Image;c.onload=function(){var d=b.extent().divideBy(1.5);d=Math.min(d.x/c.width,d.y/c.height);d=(new Point(c.width,c.height)).multiplyBy(d);var e=newCanvas(d);e.getContext("2d").drawImage(c,0,0,c.width,c.height,0,0,d.x,d.y);(new DialogBoxMorph).inform("Screenshot",null,b.world(),e)};c.src=a.screenshot}; +f.isAutoReport=!!b;a=window.location.origin+"/bugs/";f.isAutoReport&&(d=SnapActions.currentEvent,f.description=["## Auto-report\nError:",b.stack,"---\nFailing Event:",JSON.stringify(d,null,2)].join("\n"),f.error=b,f.event=d,a+="?auto=true");var k=new XMLHttpRequest;k.open("post",a);k.setRequestHeader("Content-Type","application/json; charset=UTF-8");k.onreadystatechange=function(){4!==k.readyState||e||(199k.status?c.showMessage(localize("Bug has been reported!"),2):c.cloudError()(localize("Bug could not be reported:")+ +"\n\n"+k.responseText))};k.send(JSON.stringify(f))};NetsBloxMorph.prototype.showBugReportScreenshot=function(a){var b=this,c=new Image;c.onload=function(){var d=b.extent().divideBy(1.5);d=Math.min(d.x/c.width,d.y/c.height);d=(new Point(c.width,c.height)).multiplyBy(d);var e=newCanvas(d);e.getContext("2d").drawImage(c,0,0,c.width,c.height,0,0,d.x,d.y);(new DialogBoxMorph).inform("Screenshot",null,b.world(),e)};c.src=a.screenshot}; NetsBloxMorph.prototype.loadBugReport=function(){var a=this,b=document.createElement("input");a.filePicker&&(document.body.removeChild(a.filePicker),a.filePicker=null);b.type="file";b.style.color="transparent";b.style.backgroundColor="transparent";b.style.border="none";b.style.outline="none";b.style.position="absolute";b.style.top="0px";b.style.left="0px";b.style.width="0px";b.style.height="0px";b.addEventListener("change",function(){var c=new FileReader;document.body.removeChild(b);a.filePicker= null;c.onloadend=function(d){var e=JSON.parse(d.target.result),f=e.undoState.allEvents,g=new DialogBoxMorph(null,nop);d={"Show Screenshot":function(){a.showBugReportScreenshot(e)},"Replay All Events":function(){f.push(e.event);a.replayEvents(f);g.destroy()},"Replay Some Events":function(){var m=new Point(0,f.length);(new DialogBoxMorph(a,function(l){a.replayEvents(f.slice(l.x,l.y))},a)).promptVector("Which events?",m,m,"Start (inclusive)","End (exclusive)",this.world(),null,null);g.destroy()},"Load Project":function(){a.droppedText(e.project); -setTimeout(function(){for(var m=Object.keys(e.undoState),l=m.length;l--;)SnapUndo[m[l]]=e.undoState[m[l]];a.confirm("Would you like to apply the failing event?","Apply Failing Event?",function(){SnapActions.applyEvent(e.event)});a.showMessage("Loaded bug report!")},100);g.destroy()}};var h=new Date(e.timestamp);h=["User: "+e.user,"Date: "+h.toDateString()+" "+h.toLocaleTimeString(),"Version: "+e.version,"Browser: "+e.userAgent,"Event Count: "+f.length,"Description:\n\n"+e.description].join("\n"); -d.Cancel="cancel";g.ask(localize("Bug Report"),h,a.world(),d)};c.readAsText(b.files[0])},!1);document.body.appendChild(b);a.filePicker=b;b.click()};NetsBloxMorph.prototype.simpleNotification=function(a,b){a=localize(a);a=new MenuMorph(null,a);var c=this.world();a.fixLayout();a.mouseClickLeft=b?nop:a.destroy;b=this.spriteBar.center().subtract(new Point(a.width()/2,a.height()/2));a.popup(c,b)}; -NetsBloxMorph.prototype.findBlocks=function(a){a=a||{};var b=this.stage.children.filter(function(g){return g instanceof SpriteMorph});b.push(this.stage);for(var c=function(g,h){g.upperLevel=h;return g},d=b.map(function(g){return g.scripts}).map(function(g,h){return g.children.map(function(m){return c(m,b[h])})}).reduce(function(g,h){return g.concat(h)}),e=[];0!==d.length;){var f=d.shift();SnapActions.traverse(f,function(g){if(g.definition){g!==f&&c(g,f);var h=g.definition.scriptsModel();h=h.children[0]; -1{try{await this.cloud.linkAccount(a.username.toLowerCase(),a.password,"Snap!"),this.showMessage(localize("Linked account!"),2)}catch(b){this.showMessage(localize("Unable to link account:")+" "+b.message,2)}})).withKey("cloudlogin").promptCredentials("Sign in with Snap!","login",null,null,null,null,"stay signed in on this computer\nuntil logging out",this.world(),this.cloudIcon(),this.cloudMsg)}; NetsBloxMorph.prototype.unlinkAccount=async function(a){const {username:b}=a;if(await this.confirm(localize("Are you sure you would like to unlink ")+b+"?",localize("Unlink Account?")))try{await this.cloud.unlinkAccount(a),this.showMessage(localize("Unlinked ")+b,2)}catch(c){this.showMessage(localize("Unable to unlink account: ")+c.responseText,2)}}; function loadWasmModule(a,b){console.log(`loading wasm module: ${a}`);const c=document.createElement("script");c.type="module";c.innerHTML=[`import init, {${b.join(",")}} from '/src/wasm/${a}/${a}.js';`,"await init();",`window.${a} = {};`,...b.map(d=>`window.${a}.${d} = ${d};`)].join("\n");document.body.appendChild(c)}window.addEventListener("DOMContentLoaded",()=>{loadWasmModule("amm_sdk_netsblox_wasm",["translate_musicxml","translate_midi"])});NetsBloxSerializer.prototype=new SnapSerializer; -NetsBloxSerializer.prototype.constructor=NetsBloxSerializer;NetsBloxSerializer.uber=SnapSerializer.prototype;SnapSerializer.prototype.isSavingHistory=!0;NetsBloxSerializer.prototype.appName="NetsBlox";NetsBloxSerializer.prototype.version="2.5.0";NetsBloxSerializer.prototype.app=NetsBloxSerializer.prototype.appName+" "+NetsBloxSerializer.prototype.version+", http://netsblox.org";function NetsBloxSerializer(){this.init()} +NetsBloxSerializer.prototype.constructor=NetsBloxSerializer;NetsBloxSerializer.uber=SnapSerializer.prototype;SnapSerializer.prototype.isSavingHistory=!0;NetsBloxSerializer.prototype.appName="NetsBlox";NetsBloxSerializer.prototype.version="2.5.1";NetsBloxSerializer.prototype.app=NetsBloxSerializer.prototype.appName+" "+NetsBloxSerializer.prototype.version+", http://netsblox.org";function NetsBloxSerializer(){this.init()} NetsBloxSerializer.prototype.loadMessageType=function(a,b){var c=b.childNamed("name").contents;b=b.childNamed("fields").children.map(function(d){return d.contents});a.addMessageType({name:c,fields:b})};NetsBloxSerializer.prototype.loadCustomBlock=function(a,b){"services"===a.attributes.category&&(a.attributes.category="network");return NetsBloxSerializer.uber.loadCustomBlock.call(this,a,b)}; SnapSerializer.prototype.getInitialStageSpriteIds=function(a){a=a.childNamed("stage").attributes.collabId;var b=a.split("_").slice(0,2).join("_");return[a,b]};MessageFrame.prototype.toXML=function(a){var b=this;return this.names().map(function(c){return b.getMsgType(c)}).map(function(c){return a.format("%",a.store(c))}).join("")}; MessageType.prototype.toXML=function(a){var b=this.fields.map(function(c){return a.format("%",a.escape(c))}).join("");return a.format("%%",a.escape(this.name),b)};HintInputSlotMorph.prototype.toXML=function(a){return this.empty?a.format("$",""):InputSlotMorph.prototype.toXML.call(this,a)};SnapActions.addActions("addMessageType","deleteMessageType");ActionManager.URL="ws://"+SERVER_ADDRESS+"/collaboration"; diff --git a/index.dot b/index.dot index d4ab0b5bb..9c9fcc3a7 100644 --- a/index.dot +++ b/index.dot @@ -80,7 +80,7 @@ {{ } else { }} - + {{ } }} diff --git a/src/store-ext.js b/src/store-ext.js index 36fb76918..8392b3999 100644 --- a/src/store-ext.js +++ b/src/store-ext.js @@ -8,7 +8,7 @@ NetsBloxSerializer.uber = SnapSerializer.prototype; SnapSerializer.prototype.isSavingHistory = true; NetsBloxSerializer.prototype.appName = 'NetsBlox'; -NetsBloxSerializer.prototype.version = '2.5.0'; +NetsBloxSerializer.prototype.version = '2.5.1'; NetsBloxSerializer.prototype.app = NetsBloxSerializer.prototype.appName + ' ' + NetsBloxSerializer.prototype.version + ', http://netsblox.org';