blockly 13.2.1 → 13.2.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/blockly.min.js CHANGED
@@ -11,9 +11,9 @@
11
11
  }
12
12
  }(this, function() {
13
13
  var $={};
14
- var ca,aa,ea,fa,da,k,ja,ka,la,na,oa,pa,qa,ta,wa,xa,ya,l,za,Aa,Ea,Ja,r,n,La,Ma,Na,Oa,Pa,Qa,Ta,Ua,Wa,Va,Ya,$a,ab,bb,db,fb,gb,hb,ib,lb,mb,nb,ob,rb,sb,tb,ub,vb,xb,Bb,A,Eb,Fb,Gb,Hb,Ib,Jb,Lb,Nb,w,Rb,Sb,Pb,Tb,Vb,Wb,u,Xb,Zb,$b,ac,bc,dc,fc,ec,kc,lc,mc,nc,oc,pc,xc,vc,Cc,Dc,Fc,Gc,Ac,Bc,zc,Kc,Lc,Nc,Oc,Pc,Rc,Sc,Uc,Tc,Vc,bd,cd,dd,Wc,Yc,kd,id,jd,nd,od,pd,rd,td,vd,ld,xd,yd,zd,Ad,Fd,Gd,Ed,Jd,Kd,Dd,Ld,Pd,Md,Qd,Sd,Td,Ud,Xd,Hd,Zd,ce,be,ee,de,fe,ge,ne,re,oe,se,ue,ve,Ce,De,ye,xe,ze,Ge,Fe,Ee,He,Ae,Je,Ke,Me,Le,Be,Ne,Oe,
14
+ var ca,aa,ea,fa,da,k,ja,ka,la,na,oa,pa,qa,ta,wa,xa,ya,l,za,Aa,Ea,Ja,r,n,La,Ma,Na,Oa,Pa,Qa,Ta,Ua,Wa,Va,Ya,$a,ab,bb,db,fb,gb,hb,jb,lb,mb,nb,ob,rb,sb,tb,ub,vb,xb,Bb,A,Eb,Fb,Gb,Hb,Ib,Jb,Lb,Nb,w,Rb,Sb,Pb,Tb,Vb,Wb,u,Xb,Zb,$b,ac,bc,dc,fc,ec,kc,lc,mc,nc,oc,pc,xc,vc,Cc,Dc,Fc,Gc,Ac,Bc,zc,Kc,Lc,Nc,Oc,Pc,Rc,Sc,Uc,Tc,Vc,bd,cd,dd,Wc,Yc,kd,id,jd,nd,od,pd,rd,td,vd,ld,xd,yd,zd,Ad,Fd,Gd,Ed,Jd,Kd,Dd,Ld,Pd,Md,Qd,Sd,Td,Ud,Xd,Hd,Zd,ce,be,ee,de,fe,ge,ne,re,oe,se,ue,ve,Ce,De,ye,xe,ze,Ge,Fe,Ee,He,Ae,Je,Ke,Me,Le,Be,Ne,Oe,
15
15
  Te,We,Xe,Ye,bf,cf,af,$e,ef,mf,nf,lf,pf,Ve,of,kf,sf,tf,uf,vf,xf,wf,Bf,Af,Df,Hf,If,Ef,Ff,Gf,Tf,Lf,Uf,Vf,Sf,Zf,Yf,$f,ag,bg,eg,fg,gg,hg,ig,lg,ng,ug,kg,vg,wg,xg,yg,zg,Hg,Cg,Eg,Mg,Gg,Bg,Lg,Qg,Sg,Tg,Ug,Vg,Yg,Wg,$g,ae,ah,Ng,bh,hh,ih,gh,jh,mh,uh,wh,rh,qh,vh,xh,H,Bh,Ch,Dh,Eh,Fh,I,Gh,Hh,Ih,Kh,Jh,Lh,Ph,Oh,Mh,Th,Rh,Sh,Uh,Xh,Wh,bi,di,ci,ei,fi,gi,hi,ji,ki,mi,ni,oi,pi,qi,ti,ui,vi,xi,yi,zi,Ai,Bi,Ci,Ei,Fi,Gi,Hi,Ii,Ji,Li,Ni,Oi,Pi,Qi,Ri,Si,Ti,Ui,Xi,Zi,$i,aj,bj,cj,dj,ej,fj,hj,gj,ij,nj,oj,qj,pj,rj,uj,vj,wj,xj,yj,zj,Aj,
16
- Bj,Dj,Ej,Ij,Fj,Hj,Lj,Mj,Nj,Oj,Pj,Qj,Rj,Sj,Tj,Uj,Vj,Xj,Zj,ak,ck,dk,ek,fk,gk,hk,ik,M;ca=function(a,b){aa();ba=setTimeout(function(){b&&b.handleRightClick(a)},750)};aa=function(){ba&&(clearTimeout(ba),ba=0)};ea=function(a){return!a.type.startsWith("pointer")||a instanceof PointerEvent&&da(a)};fa=function(a){return`${a.pointerId}`};da=function(a){var b=fa(a);return ha?ha===b:a.type==="pointerdown"?(ha=b,!0):!1};
16
+ Bj,Cj,Ej,Fj,Jj,Gj,Ij,Mj,Nj,Oj,Pj,Qj,Rj,Sj,Tj,Uj,Vj,Wj,Yj,ak,ck,dk,ek,fk,gk,hk,ik,jk,M;ca=function(a,b){aa();ba=setTimeout(function(){b&&b.handleRightClick(a)},750)};aa=function(){ba&&(clearTimeout(ba),ba=0)};ea=function(a){return!a.type.startsWith("pointer")||a instanceof PointerEvent&&da(a)};fa=function(a){return`${a.pointerId}`};da=function(a){var b=fa(a);return ha?ha===b:a.type==="pointerdown"?(ha=b,!0):!1};
17
17
  k=function(a,b,c,d,e,f){function g(m){if(e||ea(m))c?d.call(c,m):d(m)}var h=[];if(b in ia)for(let m=0;m<ia[b].length;m++){let z=ia[b][m];a.addEventListener(z,g,Object.assign({},{capture:!1},f));h.push([a,z,g])}else a.addEventListener(b,g,Object.assign({},{capture:!1},f)),h.push([a,b,g]);return h};
18
18
  ja=function(a,b,c,d,e){function f(h){c?d.call(c,h):d(h)}var g=[];if(b in ia)for(let h=0;h<ia[b].length;h++){let m=ia[b][h];a.addEventListener(m,f,Object.assign({},{capture:!1},e));g.push([a,m,f])}else a.addEventListener(b,f,Object.assign({},{capture:!1},e)),g.push([a,b,f]);return g};ka=function(a){for(var b=a[a.length-1][2];a.length;){let [c,d,e]=a.pop();c.removeEventListener(d,e,!1)}return b};
19
19
  la=function(a){if(a.target instanceof HTMLElement){if(a.target.isContentEditable||a.target.getAttribute("data-is-text-input")==="true")return!0;if(a.target instanceof HTMLInputElement)return a=a.target,a.type==="text"||a.type==="number"||a.type==="email"||a.type==="password"||a.type==="search"||a.type==="tel"||a.type==="url";if(a.target instanceof HTMLTextAreaElement)return!0}return!1};na=function(a){return a.ctrlKey&&ma?!0:a.button===2};
@@ -27,7 +27,7 @@ Ua=function(){Ra--;Ra||(Sa=null)};Wa=function(a){var b=a.textContent+"\n"+a.clas
27
27
  Va=function(a,b,c,d){var e=a.textContent;a=e+"\n"+a.className.baseVal;var f;if(Sa&&(f=Sa[a]))return f;Xa||(f=document.createElement("canvas"),f.className="blocklyComputeCanvas",document.body.appendChild(f),Xa=f.getContext("2d"));e&&Xa?(Xa.font=c+" "+b+" "+d,f=Xa.measureText(e).width):f=0;Sa&&(Sa[a]=f);return f};
28
28
  Ya=function(a,b,c,d){var e=document.createElement("span");e.style.font=c+" "+b+" "+d;e.textContent=a;a=document.createElement("div");a.style.width="1px";a.style.height="0";b=document.createElement("div");b.style.display="flex";b.style.position="fixed";b.style.top="0";b.style.left="0";b.appendChild(e);b.appendChild(a);document.body.appendChild(b);c={height:0,baseline:0};try{b.style.alignItems="baseline",c.baseline=a.offsetTop-e.offsetTop,b.style.alignItems="flex-end",c.height=a.offsetTop-e.offsetTop}finally{document.body.removeChild(b)}return c};
29
29
  $.t=function(){return Za.getFocusManager()};$a=function(a){return a&&typeof a.getFocusableElement==="function"&&typeof a.getFocusableTree==="function"&&typeof a.onNodeFocus==="function"&&typeof a.onNodeBlur==="function"&&typeof a.canBeFocused==="function"};ab=function(a){return $a(a)&&typeof a.id==="string"&&typeof a.workspace==="object"&&typeof a.select==="function"&&typeof a.unselect==="function"};
30
- bb=function(a,b){for(let c in b)b[c]!==null&&Array.isArray(b[c])?a[c]=bb(a[c]||[],b[c]):a[c]=b[c]!==null&&typeof b[c]==="object"?bb(a[c]||Object.create(null),b[c]):b[c];return a};db=function(a,b,c,d){a=a+" was deprecated in "+b+" and will be deleted in "+c+".";d&&(a+="\nUse "+d+" instead.");cb.has(a)||(cb.add(a),console.warn(a))};fb=function(a){return eb[a]||null};gb=function(){var a=[];for(let b in eb)a.push(eb[b]);return a};hb=function(a){eb[a.id]=a};ib=function(a){delete eb[a.id]};lb=function(){return kb};
30
+ bb=function(a,b){for(let c in b)b[c]!==null&&Array.isArray(b[c])?a[c]=bb(a[c]||[],b[c]):a[c]=b[c]!==null&&typeof b[c]==="object"?bb(a[c]||Object.create(null),b[c]):b[c];return a};db=function(a,b,c,d){a=a+" was deprecated in "+b+" and will be deleted in "+c+".";d&&(a+="\nUse "+d+" instead.");cb.has(a)||(cb.add(a),console.warn(a))};fb=function(a){return eb[a]||null};gb=function(){var a=[];for(let b in eb)a.push(eb[b]);return a};hb=function(a){eb[a.id]=a};jb=function(a){delete eb[a.id]};lb=function(){return kb};
31
31
  mb=function(a){kb=a;a.rendered&&$.t().setPopoverFocusRoot(a.getInjectionDiv())};nb=function(){var a=$.t().getFocusedNode();return a&&ab(a)?a:null};ob=function(a){var b=nb(),c,d,e,f,g=new (u(v.SELECTED))((c=b==null?void 0:b.id)!=null?c:null,(d=a==null?void 0:a.id)!=null?d:null,(f=(e=a==null?void 0:a.workspace.id)!=null?e:b==null?void 0:b.workspace.id)!=null?f:"");w(g)};rb=function(a=kb){return qb?qb:a&&a.rendered?a.getInjectionDiv():null};sb=function(a){qb=a};
32
32
  tb=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=a.getCachedParentSvgSize(),d=b.parentElement;if(d instanceof HTMLElement){var e=d.offsetWidth;d=d.offsetHeight;c.width!==e&&(b.setAttribute("width",e+"px"),a.setCachedParentSvgSize(e,null));c.height!==d&&(b.setAttribute("height",d+"px"),a.setCachedParentSvgSize(null,d));a.resize()}};
33
33
  ub=function(a,b){var c=Object.create(null),d=a.getDescendants(!0);b&&(a=a.getNextBlock())&&(a=d.indexOf(a),d.splice(a,d.length-a));for(let e=0,f;f=d[e];e++)c[f.type]?c[f.type]++:c[f.type]=1;return c};vb=function(a){return function(){this.jsonInit(a)}};xb=function(a){wb.defineBlocksWithJsonArrayInternal(a)};$.yb=function(a){var b={};for(let c=0;c<a.length;c++){let d=a[c];if(!d){console.warn(`Block definition #${c} in JSON array is ${d}. Skipping`);continue}let e=d.type;e?b[e]={init:vb(d)}:console.warn(`Block definition #${c} in JSON array is missing a type attribute. Skipping.`)}return b};
@@ -55,9 +55,10 @@ Lc=function(a,b){return{horizontal:b.toolboxMetrics.position===F.LEFT||a.horizon
55
55
  Pc=function(a,{addCoordinates:b=!1,saveIds:c=!0}={}){var d=a.workspace,e=Object.create(null);e.height=a.getSize().height;e.width=a.getSize().width;c&&(e.id=a.id);b&&(b=a.getRelativeToSurfaceXY(),e.x=d.RTL?d.getWidth()-b.x:b.x,e.y=b.y);a.getText()&&(e.text=a.getText());a.isCollapsed()&&(e.collapsed=!0);a.isOwnEditable()||(e.editable=!1);a.isOwnMovable()||(e.movable=!1);a.isOwnDeletable()||(e.deletable=!1);return e};
56
56
  Rc=function(a,b,{recordUndo:c=!1}={}){var d=$.Qc;$.Qc=c;c=b.newComment(a.id);a.text!==void 0&&c.setText(a.text);if(a.x!==void 0||a.y!==void 0){let f=c.getRelativeToSurfaceXY(),g,h=(g=a.x)!=null?g:f.x;h=b.RTL?b.getWidth()-h:h;var e;b=(e=a.y)!=null?e:f.y;c.moveTo(new D(h,b))}if(a.width!==void 0||a.height){e=c.getSize();let f,g;c.setSize(new hc((f=a.width)!=null?f:e.width,(g=a.height)!=null?g:e.height))}a.collapsed!==void 0&&c.setCollapsed(a.collapsed);a.editable!==void 0&&c.setEditable(a.editable);
57
57
  a.movable!==void 0&&c.setMovable(a.movable);a.deletable!==void 0&&c.setDeletable(a.deletable);$.Qc=d;return c};Sc=function(a,b){A(y.PASTER,a,b)};Uc=function(a){for(var b=a.workspace,c=a.getRelativeToSurfaceXY(),d=new D(0,0),e=b.getTopComments(!1).filter(f=>f.id!==a.id).map(f=>f.getRelativeToSurfaceXY());Tc(D.sum(c,d),e);)d.translate(b.RTL?-30:30,30);a.moveTo(D.sum(c,d))};Tc=function(a,b){return b.some(c=>Math.abs(c.x-a.x)<=1&&Math.abs(c.y-a.y)<=1)};
58
- Vc=function(a){return a&&typeof a.saveState==="function"&&typeof a.loadState==="function"};bd=function(a){Wc(a);if(Xc)return Yc(),Promise.resolve();Zc||(Zc=new Promise(b=>{$c=b;ad=window.requestAnimationFrame(()=>{Yc();b()})}));return Zc};cd=function(){return Zc?Zc:Promise.resolve()};dd=function(a){a||window.cancelAnimationFrame(ad);Yc(a);!a&&$c&&$c()};Wc=function(a){ed.add(a);fd.set(a,$.gd);var b=a.getParent();b?Wc(b):hd.add(a)};
59
- Yc=function(a){var b=a?new Set([a]):new Set([...hd].map(g=>g.workspace)),c=[...hd].filter(id).filter(g=>b.has(g.workspace));for(var d of c)jd(d);for(let g of b)g.resizeContents(),g.connectionDBList.forEach(h=>h==null?void 0:h.beginBulkUpdates());for(var e of c)d=e.getRelativeToSurfaceXY(),e.updateComponentLocations(d);for(var f of b)f.connectionDBList.forEach(g=>g==null?void 0:g.endBulkUpdates());for(let g of c)e=$.gd,(f=fd.get(g))&&$.B(f),g.bumpNeighbours(),$.B(e);for(let g of c)kd(g);a||(Zc=null)};
60
- kd=function(a){hd.delete(a);ed.delete(a);fd.delete(a);for(let b of a.getChildren(!1))kd(b)};id=function(a){return!a.isDisposed()&&!a.getParent()};jd=function(a){if(ed.has(a)&&a.initialized){for(let b of a.getChildren(!1))jd(b);a.renderEfficiently()}};nd=function(a,b){ld(md.ALERT,a,b,void 0)};od=function(a,b){ld(md.CONFIRM,a,b,void 0)};pd=function(a,b,c){ld(md.PROMPT,a,c,b)};rd=function(a,b){qd(a,b)};td=function(a,b){sd(a,b)};vd=function(a,b,c){ud(a,b,c)};
58
+ Vc=function(a){return a&&typeof a.saveState==="function"&&typeof a.loadState==="function"};bd=function(a){Wc(a);if(Xc)return Yc(),Promise.resolve();Zc||(Zc=new Promise(b=>{$c=b;ad=window.requestAnimationFrame(()=>{Yc();b()})}));return Zc};cd=function(){return Zc?Zc:Promise.resolve()};dd=function(a){a||window.cancelAnimationFrame(ad);Yc(a);!a&&$c&&$c()};Wc=function(a){ed.add(a);fd.set(a,{group:$.gd,recordUndo:$.Qc});var b=a.getParent();b?Wc(b):hd.add(a)};
59
+ Yc=function(a){var b=a?new Set([a]):new Set([...hd].map(g=>g.workspace)),c=[...hd].filter(id).filter(g=>b.has(g.workspace));for(var d of c)jd(d);for(let g of b)g.resizeContents(),g.connectionDBList.forEach(h=>h==null?void 0:h.beginBulkUpdates());for(var e of c)d=e.getRelativeToSurfaceXY(),e.updateComponentLocations(d);for(var f of b)f.connectionDBList.forEach(g=>g==null?void 0:g.endBulkUpdates());for(let g of c){e=$.gd;f=$.Qc;if(d=fd.get(g))d.group&&$.B(d.group),$.Qc=d.recordUndo;g.bumpNeighbours();
60
+ $.B(e);$.Qc=f}for(let g of c)kd(g);a||(Zc=null)};kd=function(a){hd.delete(a);ed.delete(a);fd.delete(a);for(let b of a.getChildren(!1))kd(b)};id=function(a){return!a.isDisposed()&&!a.getParent()};jd=function(a){if(ed.has(a)&&a.initialized){for(let b of a.getChildren(!1))jd(b);a.renderEfficiently()}};nd=function(a,b){ld(md.ALERT,a,b,void 0)};od=function(a,b){ld(md.CONFIRM,a,b,void 0)};pd=function(a,b,c){ld(md.PROMPT,a,c,b)};rd=function(a,b){qd(a,b)};td=function(a,b){sd(a,b)};
61
+ vd=function(a,b,c){ud(a,b,c)};
61
62
  ld=function(...[a,b,c,d]){var e=document.createElement("dialog"),f=document.createElement("form"),g=document.createElement("label"),h=document.createElement("input"),m=document.createElement("div"),z=document.createElement("button");e.className="blocklyDialog";f.className="blocklyDialogForm";g.className="blocklyDialogPrompt";m.className="blocklyDialogButtonRow";z.className="blocklyDialogConfirmButton";f.setAttribute("method","dialog");g.textContent=b;g.setAttribute("for","blockly-form-input");z.textContent=
62
63
  $.C.DIALOG_OK;z.value="ok";e.appendChild(f);f.appendChild(g);a===md.PROMPT&&(h.id="blockly-form-input",h.className="blocklyDialogInput",h.type="text",h.name="input",h.autofocus=!0,d&&(h.value=d),f.appendChild(h));m.appendChild(z);if(a===md.CONFIRM||a===md.PROMPT)b=document.createElement("button"),b.className="blocklyDialogCancelButton",b.textContent=$.C.DIALOG_CANCEL,b.value="cancel",m.appendChild(b);f.appendChild(m);var E;wd===0&&(E=$.t().ephemeralFocusTaken()?void 0:$.t().takeEphemeralFocus(e));
63
64
  wd++;e.addEventListener("close",()=>{wd--;if(!wd){let J;(J=E)==null||J()}e.remove();switch(a){case md.CONFIRM:c(e.returnValue==="ok");break;case md.PROMPT:c(e.returnValue==="ok"?h.value:null);break;case md.ALERT:c==null||c()}});document.body.appendChild(e);e.showModal()};xd=function(a){return typeof a.bubbleIsVisible==="function"&&typeof a.setBubbleVisible==="function"&&typeof a.getBubble==="function"};yd=function(a,b){return b.map(c=>a.getBlockById(c)).filter(c=>c&&c.isShadow()).length===b.length};
@@ -151,18 +152,18 @@ var g=f.bubbleIsVisible();f=f.getBubbleLocation();var h=$.rc("comment");h.append
151
152
  (f=d.connection.targetBlock(),d.type===$.je.VALUE?m=$.rc("value"):d.type===$.je.STATEMENT&&(m=$.rc("statement")),h=d.connection.getShadowDom(),!h||f&&f.isShadow()||m.appendChild($g(h,b)),f&&(f=Wg(f,b),f.nodeType===Xg.ELEMENT_NODE&&(m.appendChild(f),g=!1)),m.setAttribute("name",d.name),g||c.appendChild(m))}a.inputsInline!==void 0&&a.inputsInline!==a.inputsInlineDefault&&c.setAttribute("inline",String(a.inputsInline));a.isCollapsed()&&c.setAttribute("collapsed","true");a.isEnabled()||c.setAttribute("disabled-reasons",
152
153
  Array.from(a.getDisabledReasons()).map(encodeURIComponent).join(","));a.isOwnDeletable()||c.setAttribute("deletable","false");a.isOwnMovable()||c.setAttribute("movable","false");a.isOwnEditable()||c.setAttribute("editable","false");m=a.getNextBlock();if(m&&(e=Wg(m,b),e.nodeType===Xg.ELEMENT_NODE)){var z=$.rc("next");z.appendChild(e);c.appendChild(z)}a=a.nextConnection&&a.nextConnection.getShadowDom();!a||m&&m.isShadow()||z.appendChild($g(a,b));return c};
153
154
  $g=function(a,b){for(var c=a=a.cloneNode(!0),d;c;)if(b&&c.nodeName==="shadow"&&c.removeAttribute("id"),c.firstChild)c=c.firstChild;else{for(;c&&!c.nextSibling;){d=c;c=c.parentNode;let e;d.nodeType===Xg.TEXT_NODE&&d.data.trim()===""&&((e=c)==null?void 0:e.firstChild)!==d&&Oa(d)}c&&(d=c,c=c.nextSibling,d.nodeType===Xg.TEXT_NODE&&d.data.trim()===""&&Oa(d))}return a};ae=function(a){return xc(a).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")};
154
- $.ch=function(a,b){var c=0;b.RTL&&(c=b.getWidth());var d=[];Ta();var e=$.gd;e||$.B(!0);b.setResizesEnabled&&b.setResizesEnabled(!1);var f=!0;try{for(let g=0,h;h=a.childNodes[g];g++){let m=h.nodeName.toLowerCase(),z=h;if(m==="block"||m==="shadow"&&!$.Qc){let E=Ng(z,b);d.push(E.id);let J,T=parseInt((J=z.getAttribute("x"))!=null?J:"10",10),ra,jb=parseInt((ra=z.getAttribute("y"))!=null?ra:"10",10);isNaN(T)||isNaN(jb)||E.moveBy(b.RTL?c-T:T,jb,["create"]);f=!1}else{if(m==="shadow")throw TypeError("Shadow block cannot be a top-level block.");
155
+ $.ch=function(a,b){var c=0;b.RTL&&(c=b.getWidth());var d=[];Ta();var e=$.gd;e||$.B(!0);b.setResizesEnabled&&b.setResizesEnabled(!1);var f=!0;try{for(let g=0,h;h=a.childNodes[g];g++){let m=h.nodeName.toLowerCase(),z=h;if(m==="block"||m==="shadow"&&!$.Qc){let E=Ng(z,b);d.push(E.id);let J,T=parseInt((J=z.getAttribute("x"))!=null?J:"10",10),ra,ib=parseInt((ra=z.getAttribute("y"))!=null?ra:"10",10);isNaN(T)||isNaN(ib)||E.moveBy(b.RTL?c-T:T,ib,["create"]);f=!1}else{if(m==="shadow")throw TypeError("Shadow block cannot be a top-level block.");
155
156
  if(m==="comment")ah(z,b);else if(m==="variables"){if(f)bh(z,b);else throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");f=!1}}}}finally{$.B(e),b.setResizesEnabled&&b.setResizesEnabled(!0),b.rendered&&dd(),Ua()}w(new (u(v.FINISHED_LOADING))(b));return d};
156
157
  ah=function(a,b){var c,d=(c=a.getAttribute("id"))!=null?c:void 0;c=b.rendered?new dh(b,d):new eh(b,d);var e;c.setText((e=a.textContent)!=null?e:"");var f;e=parseInt((f=a.getAttribute("x"))!=null?f:"",10);var g;f=parseInt((g=a.getAttribute("y"))!=null?g:"",10);isNaN(e)||isNaN(f)||(e=b.RTL?b.getWidth()-e:e,c.moveTo(new D(e,f)));var h;b=parseInt((h=a.getAttribute("w"))!=null?h:"",10);var m;h=parseInt((m=a.getAttribute("h"))!=null?m:"",10);isNaN(b)||isNaN(h)||c.setSize(new hc(b,h));a.getAttribute("collapsed")===
157
158
  "true"&&c.setCollapsed(!0);a.getAttribute("editable")==="false"&&c.setEditable(!1);a.getAttribute("movable")==="false"&&c.setMovable(!1);a.getAttribute("deletable")==="false"&&c.setDeletable(!1);return c};$.fh=function(a,b){a=Ng(a,b);b.rendered&&dd();return a};
158
159
  Ng=function(a,b){$.Ub++;var c=b.getVariableMap().getAllVariables();try{var d=gh(a,b);if(b.rendered){let e=d,f=d.getDescendants(!1);e.setConnectionTracking(!1);for(let g=f.length-1;g>=0;g--)f[g].initSvg();for(let g=f.length-1;g>=0;g--)f[g].queueRender();setTimeout(function(){e.disposed||e.setConnectionTracking(!0)},1);b.resizeContents()}else{let e=d.getDescendants(!1);for(let f=e.length-1;f>=0;f--)e[f].initModel()}}finally{$.Ub--}if(Vb()){a=Xd(b,c);for(b=0;b<a.length;b++)c=a[b],w(new (u(v.VAR_CREATE))(c));
159
160
  w(new (u(v.BLOCK_CREATE))(d))}return d};bh=function(a,b){for(let d=0;d<a.children.length;d++){var c=a.children[d];let e=c.getAttribute("type"),f=c.getAttribute("id");c=c.textContent;if(!c)break;b.getVariableMap().createVariable(c,e!=null?e:void 0,f)}};
160
- hh=function(a,b){for(let c=0;c<a.length;c++){let d=a[c],e=d.textContent,f=d.getAttribute("pinned")==="true",g,h=parseInt((g=d.getAttribute("w"))!=null?g:"50",10),m,z=parseInt((m=d.getAttribute("h"))!=null?m:"50",10),E,J=parseInt((E=d.getAttribute("x"))!=null?E:"",10),T,ra=parseInt((T=d.getAttribute("y"))!=null?T:"",10);b.setCommentText(e);let jb=b.getIcon(Zg.COMMENT);isNaN(h)||isNaN(z)||jb.setBubbleSize(new hc(h,z));jb.setBubbleVisible(f);setTimeout(()=>{isNaN(J)||isNaN(ra)||(J=b.workspace.RTL?b.workspace.getWidth()-
161
- (J+h):J,jb.setBubbleLocation(new D(J,ra)));jb.setBubbleVisible(f)},1)}};ih=function(a){var b=null,c=null;for(let d=0;d<a.childNodes.length;d++){let e=a.childNodes[d];e.nodeType===Xg.ELEMENT_NODE&&(e.nodeName.toLowerCase()==="block"?b=e:e.nodeName.toLowerCase()==="shadow"&&(c=e))}return{childBlockElement:b,childShadowElement:c}};
161
+ hh=function(a,b){for(let c=0;c<a.length;c++){let d=a[c],e=d.textContent,f=d.getAttribute("pinned")==="true",g,h=parseInt((g=d.getAttribute("w"))!=null?g:"50",10),m,z=parseInt((m=d.getAttribute("h"))!=null?m:"50",10),E,J=parseInt((E=d.getAttribute("x"))!=null?E:"",10),T,ra=parseInt((T=d.getAttribute("y"))!=null?T:"",10);b.setCommentText(e);let ib=b.getIcon(Zg.COMMENT);isNaN(h)||isNaN(z)||ib.setBubbleSize(new hc(h,z));ib.setBubbleVisible(f);setTimeout(()=>{isNaN(J)||isNaN(ra)||(J=b.workspace.RTL?b.workspace.getWidth()-
162
+ (J+h):J,ib.setBubbleLocation(new D(J,ra)));ib.setBubbleVisible(f)},1)}};ih=function(a){var b=null,c=null;for(let d=0;d<a.childNodes.length;d++){let e=a.childNodes[d];e.nodeType===Xg.ELEMENT_NODE&&(e.nodeName.toLowerCase()==="block"?b=e:e.nodeName.toLowerCase()==="shadow"&&(c=e))}return{childBlockElement:b,childShadowElement:c}};
162
163
  gh=function(a,b,c,d){var e,f=a.getAttribute("type");if(!f)throw TypeError("Block type unspecified: "+a.outerHTML);var g=(e=a.getAttribute("id"))!=null?e:void 0;e=b.newBlock(f,g);var h=[],m=[],z=[],E=[],J=[];g=[];for(var T=0;T<a.children.length;T++){var ra=a.children[T];if(ra.nodeType!==Xg.TEXT_NODE)switch(ra.nodeName.toLowerCase()){case "mutation":h.push(ra);break;case "comment":m.push(ra);break;case "data":z.push(ra);break;case "title":case "field":E.push(ra);break;case "value":case "statement":J.push(ra);
163
164
  break;case "next":g.push(ra);break;default:console.warn("Ignoring unknown tag: "+ra.nodeName)}}T=!1;for(ra=0;ra<h.length;ra++){let Yi=h[ra];e.domToMutation&&(e.domToMutation(Yi),e.initSvg&&(T=!0))}h=T;hh(m,e);m=z;for(z=0;z<m.length;z++)e.data=m[z].textContent;if(c){if(d)if(e.previousConnection)d=e.previousConnection;else throw TypeError("Next block does not have previous statement.");else if(e.outputConnection)d=e.outputConnection;else if(e.previousConnection)d=e.previousConnection;else throw TypeError("Child block does not have output or previous statement.");
164
165
  if(!c.connect(d))throw a=e.workspace.connectionChecker,TypeError(a.getErrorMessage(a.canConnectWithReason(d,c,!1),d,c));}c=E;for(E=0;E<c.length;E++)m=c[E],(z=m.getAttribute("name"))?(d=e,(T=d.getField(z))?T.fromXml(m):console.warn("Ignoring non-existent field "+z+" in block "+d.type)):console.warn(`Ignoring unnamed field in block ${e.type}`);for(c=0;c<J.length;c++){E=J[c];d=(m=E.getAttribute("name"))?e.getInput(m):null;if(!d){console.warn("Ignoring non-existent input "+m+" in block "+f);break}E=ih(E);
165
- if(E.childBlockElement){if(!d.connection)throw TypeError("Input connection does not exist.");gh(E.childBlockElement,b,d.connection,!1)}if(E.childShadowElement){var jb=void 0;(jb=d.connection)==null||jb.setShadowDom(E.childShadowElement)}}f=g;for(jb=0;jb<f.length;jb++){g=ih(f[jb]);if(g.childBlockElement){if(!e.nextConnection)throw TypeError("Next statement does not exist.");if(e.nextConnection.isConnected())throw TypeError("Next statement is already connected.");gh(g.childBlockElement,b,e.nextConnection,
166
+ if(E.childBlockElement){if(!d.connection)throw TypeError("Input connection does not exist.");gh(E.childBlockElement,b,d.connection,!1)}if(E.childShadowElement){var ib=void 0;(ib=d.connection)==null||ib.setShadowDom(E.childShadowElement)}}f=g;for(ib=0;ib<f.length;ib++){g=ih(f[ib]);if(g.childBlockElement){if(!e.nextConnection)throw TypeError("Next statement does not exist.");if(e.nextConnection.isConnected())throw TypeError("Next statement is already connected.");gh(g.childBlockElement,b,e.nextConnection,
166
167
  !0)}g.childShadowElement&&e.nextConnection&&e.nextConnection.setShadowDom(g.childShadowElement)}h&&e.initSvg();(b=a.getAttribute("inline"))&&e.setInputsInline(b==="true");(b=a.getAttribute("disabled"))&&e.setDisabledReason(b==="true"||b==="disabled","MANUALLY_DISABLED");b=a.getAttribute("disabled-reasons");if(b!==null)for(var pb of b.split(","))e.setDisabledReason(!0,decodeURIComponent(pb));(pb=a.getAttribute("deletable"))&&e.setDeletable(pb==="true");(pb=a.getAttribute("movable"))&&e.setMovable(pb===
167
168
  "true");(pb=a.getAttribute("editable"))&&e.setEditable(pb==="true");(pb=a.getAttribute("collapsed"))&&e.setCollapsed(pb==="true");if(a.nodeName.toLowerCase()==="shadow"){a=e.getChildren(!1);for(pb=0;pb<a.length;pb++)if(!a[pb].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");e.setShadow(!0)}return e};jh=function(a,b){A(y.FIELD,a,b,!0)};$.lh=function(a){return kh.fromJsonInternal(a)};
168
169
  mh=function(a){return a&&typeof a==="object"&&"src"in a&&typeof a.src==="string"&&"alt"in a&&typeof a.alt==="string"&&"width"in a&&typeof a.width==="number"&&"height"in a&&typeof a.height==="number"};$.oh=function(a,b){if(typeof a!=="string"||a.trim()==="")throw Error('Error: Invalid extension name "'+a+'"');if(nh[a])throw Error('Error: Extension "'+a+'" is already registered.');if(typeof b!=="function")throw Error('Error: Extension "'+a+'" must be a function');nh[a]=b};
@@ -243,35 +244,35 @@ $.sj=function(a){var b=$.Qc,c=a.getProcedureDef()[0],d=a.mutationToDom(!0);a=rj(
243
244
  uj=function(a,b){A(y.RENDERER,a,b)};vj=function(a,b,c){a=new (Fb(y.RENDERER,a,void 0))(a);a.init(b,c);return a};wj=function(a){Dd(a.getTargetWorkspace(),void 0,"String")};xj=function(a){Dd(a.getTargetWorkspace(),void 0,"Number")};yj=function(a){Dd(a.getTargetWorkspace(),void 0,"Colour")};
244
245
  zj=function(a){zb.variables_set_dynamic||zb.variables_get_dynamic||console.warn("There are no dynamic variable blocks, but there is a dynamic variable category.");a.registerButtonCallback("CREATE_VARIABLE_STRING",wj);a.registerButtonCallback("CREATE_VARIABLE_NUMBER",xj);a.registerButtonCallback("CREATE_VARIABLE_COLOUR",yj);return[{kind:"button",text:$.C.NEW_STRING_VARIABLE,callbackkey:"CREATE_VARIABLE_STRING"},{kind:"button",text:$.C.NEW_NUMBER_VARIABLE,callbackkey:"CREATE_VARIABLE_NUMBER"},{kind:"button",
245
246
  text:$.C.NEW_COLOUR_VARIABLE,callbackkey:"CREATE_VARIABLE_COLOUR"},...Ed(a,a.getVariableMap().getAllVariables(),!1,"variables_get_dynamic","variables_set_dynamic")]};Aj=function(a){var b=a.saveState();if(!a.getParameters().length)return b;b.parameters=a.getParameters().map(c=>c.saveState());return b};Bj=function(a,b,c,d){a=a.loadState(c,d);if(!c.parameters)return a;for(let [e,f]of c.parameters.entries())a.insertParameter(b.loadState(f,d),e);return a};
246
- Dj=function(a,b){a.setAttribute("dir","LTR");wa(a,b.hasCss,b.pathToMedia);var c=r(q.SVG,{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},a),d=r(q.DEFS,{},c),e=String(Math.random()).substring(2);b.gridPattern=Cj.createDom(e,b.gridOptions,d,a);return c};
247
- Ej=function(a,b,c){c.parentWorkspace=null;c=new $h(c);var d=c.options;c.scale=d.zoomOptions.startScale;b.appendChild(c.createDom("blocklyMainBackground",a));var e=c.getRenderer().getClassName();e&&n(a,e);(e=c.getTheme().getClassName())&&n(a,e);!d.hasCategories&&d.languageTree&&(e=c.addFlyout(q.SVG),a.insertBefore(e,b));d.hasTrashcan&&c.addTrashcan();d.zoomOptions&&d.zoomOptions.controls&&c.addZoomControls();c.getThemeManager().subscribe(b,"workspaceBackgroundColour","background-color");c.translate(0,
247
+ Cj=function(a,b){if(a<=0)return 0;b=Math.min(Math.abs(b),a);return a-Math.sqrt(a*a-b*b)};Ej=function(a,b){a.setAttribute("dir","LTR");wa(a,b.hasCss,b.pathToMedia);var c=r(q.SVG,{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},a),d=r(q.DEFS,{},c),e=String(Math.random()).substring(2);b.gridPattern=Dj.createDom(e,b.gridOptions,d,a);return c};
248
+ Fj=function(a,b,c){c.parentWorkspace=null;c=new $h(c);var d=c.options;c.scale=d.zoomOptions.startScale;b.appendChild(c.createDom("blocklyMainBackground",a));var e=c.getRenderer().getClassName();e&&n(a,e);(e=c.getTheme().getClassName())&&n(a,e);!d.hasCategories&&d.languageTree&&(e=c.addFlyout(q.SVG),a.insertBefore(e,b));d.hasTrashcan&&c.addTrashcan();d.zoomOptions&&d.zoomOptions.controls&&c.addZoomControls();c.getThemeManager().subscribe(b,"workspaceBackgroundColour","background-color");c.translate(0,
248
249
  0);c.addChangeListener(Xh(c));tb(c);ng();Te();Df();return c};
249
- Ij=function(a){var b=a.options,c=a.getParentSvg();k(c.parentNode,"contextmenu",null,function(d){la(d)||d.preventDefault()});c=k(window,"resize",null,function(){Lf();a.hideComponents(!0);sf();zg();tb(a);Wh(a)});a.setResizeHandlerWrapper(c);Fj();if(b.languageTree){c=a.getToolbox();let d=a.getFlyout(!0);c?c.init():d&&(d.init(a),d.show(b.languageTree),typeof d.scrollToStart==="function"&&d.scrollToStart())}b.hasTrashcan&&a.trashcan.init();b.zoomOptions&&b.zoomOptions.controls&&a.zoomControls_.init();
250
- b.moveOptions&&b.moveOptions.scrollbars?(a.scrollbar=new Gj(a,b.moveOptions.scrollbars===!0||!!b.moveOptions.scrollbars.horizontal,b.moveOptions.scrollbars===!0||!!b.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),a.scrollbar.resize()):a.setMetrics({x:.5,y:.5});b.hasSounds&&Hj(b.pathToMedia,a)};
251
- Fj=function(){Jj||(k(document,"scroll",null,function(){var a=gb();for(let b=0,c;c=a[b];b++)c instanceof $h&&c.updateInverseScreenCTM()}),ja(document,"touchend",null,aa),ja(document,"touchcancel",null,aa),ja(document,"keydown",null,function(a){a.key==="Tab"&&Nd.setIsActive(!0)}));Jj=!0};Hj=function(a,b){b=b.getAudioManager();b.load([`${a}click.mp3`],"click");b.load([`${a}disconnect.mp3`],"disconnect");b.load([`${a}delete.mp3`],"delete");b.load([`${a}drop.mp3`],"drop")};
252
- Lj=function(){Kj.registry.register({displayText(){return $.C.UNDO},preconditionFn(a){return a.workspace.getUndoStack().length>0?"enabled":"disabled"},callback(a){a.workspace.undo()},scopeType:Kj.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1,associatedKeyboardShortcut:"undo"})};
253
- Mj=function(){Kj.registry.register({displayText(){return $.C.REDO},preconditionFn(a){return a.workspace.getRedoStack().length>0?"enabled":"disabled"},callback(a){a.workspace.redo()},scopeType:Kj.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2,associatedKeyboardShortcut:"redo"})};
254
- Nj=function(){Kj.registry.register({displayText(){return $.C.CLEAN_UP},preconditionFn(a){return a.workspace.isMovable()?a.workspace.getTopBlocks(!1).length>1?"enabled":"disabled":"hidden"},callback(a){a.workspace.cleanUp()},scopeType:Kj.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3,associatedKeyboardShortcut:"cleanup"})};
255
- Oj=function(a,b){function c(f){e--;f.setCollapsed(a);e===0&&$.B(!1)}var d=0,e=0;$.B(!0);for(let f=0;f<b.length;f++){let g=b[f];for(;g;)e++,setTimeout(c.bind(null,g),d),g=g.getNextBlock(),d+=10}};
256
- Pj=function(){Kj.registry.register({displayText(){return $.C.COLLAPSE_ALL},preconditionFn(a){if(a.workspace.options.collapse){a=a.workspace.getTopBlocks(!1);for(let b=0;b<a.length;b++){let c=a[b];for(;c;){if(!c.isCollapsed())return"enabled";c=c.getNextBlock()}}return"disabled"}return"hidden"},callback(a){Oj(!0,a.workspace.getTopBlocks(!0))},scopeType:Kj.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})};
257
- Qj=function(){Kj.registry.register({displayText(){return $.C.EXPAND_ALL},preconditionFn(a){if(a.workspace.options.collapse){a=a.workspace.getTopBlocks(!1);for(let b=0;b<a.length;b++){let c=a[b];for(;c;){if(c.isCollapsed())return"enabled";c=c.getNextBlock()}}return"disabled"}return"hidden"},callback(a){Oj(!1,a.workspace.getTopBlocks(!0))},scopeType:Kj.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})};
258
- Rj=function(a,b){if(a.isDeletable())Array.prototype.push.apply(b,a.getDescendants(!1));else{a=a.getChildren(!1);for(let c=0;c<a.length;c++)Rj(a[c],b)}};Sj=function(a){var b=[];a=a.getTopBlocks(!0);for(let c=0;c<a.length;c++)Rj(a[c],b);return b};Tj=function(a,b){b?$.B(b):($.B(!0),b=$.gd);var c=a.shift();c&&(c.isDeadOrDying()?Tj(a,b):(c.dispose(!1,!0),setTimeout(Tj,10,a,b)));$.B(!1)};
259
- Uj=function(){Kj.registry.register({displayText(a){if(!a.workspace)return"";a=Sj(a.workspace).length;return a===1?$.C.DELETE_BLOCK:$.C.DELETE_X_BLOCKS.replace("%1",`${a}`)},preconditionFn(a){return a.workspace?Sj(a.workspace).length>0?"enabled":"disabled":"disabled"},callback(a){if(a.workspace){a.workspace.cancelCurrentGesture();var b=Sj(a.workspace);b.length<2?Tj(b):td($.C.DELETE_ALL_BLOCKS.replace("%1",String(b.length)),function(c){c&&Tj(b)})}},scopeType:Kj.ScopeType.WORKSPACE,id:"workspaceDelete",
260
- weight:6})};Vj=function(){Kj.registry.register({displayText(){return $.C.DUPLICATE_BLOCK},preconditionFn(a){a=a.block;return!a.isInFlyout&&a.isDeletable()&&a.isMovable()?a.isDuplicatable()?"enabled":"disabled":"hidden"},callback(a){if(a.block){var b=a.block.toCopyData();b&&di(b,a.block.workspace)}},scopeType:Kj.ScopeType.BLOCK,id:"blockDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})};
261
- Xj=function(){Kj.registry.register({displayText(a){return a.block.hasIcon(Wj.TYPE)?$.C.REMOVE_COMMENT:$.C.ADD_COMMENT},preconditionFn(a){a=a.block;var b;if((b=a&&!a.isInFlyout&&a.workspace.options.comments&&!a.isCollapsed()&&a.isEditable())&&!(b=a.hasIcon(Wj.TYPE))){if(a&&a.isSimpleReporter()){var c;a=(c=a.getFields().next().value)==null?void 0:c.isFullBlockField()}else a=!1;b=!a}return b?"enabled":"hidden"},callback(a){(a=a.block)&&a.hasIcon(Wj.TYPE)?a.setCommentText(null):a.setCommentText("")},
262
- scopeType:Kj.ScopeType.BLOCK,id:"blockComment",weight:2})};
263
- Zj=function(){Kj.registry.register({displayText(a){return a.block.getInputsInline()?$.C.EXTERNAL_INPUTS:$.C.INLINE_INPUTS},preconditionFn(a){a=a.block;if(!a.isInFlyout&&a.isMovable()&&!a.isCollapsed())for(let b=1;b<a.inputList.length;b++)if(!(a.inputList[b-1]instanceof Yj||a.inputList[b]instanceof Yj))return"enabled";return"hidden"},callback(a){a.block.setInputsInline(!a.block.getInputsInline())},scopeType:Kj.ScopeType.BLOCK,id:"blockInline",weight:3})};
264
- ak=function(){Kj.registry.register({displayText(a){return a.block.isCollapsed()?$.C.EXPAND_BLOCK:$.C.COLLAPSE_BLOCK},preconditionFn(a){a=a.block;return!a.isInFlyout&&a.isMovable()&&a.workspace.options.collapse?"enabled":"hidden"},callback(a){a.block.setCollapsed(!a.block.isCollapsed())},scopeType:Kj.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})};
265
- ck=function(){Kj.registry.register({displayText(a){return a.block.hasDisabledReason("MANUALLY_DISABLED")?$.C.ENABLE_BLOCK:$.C.DISABLE_BLOCK},preconditionFn(a){a=a.block;if(!a.isInFlyout&&a.workspace.options.disable&&a.isEditable()){var b=a.getDisabledReasons();b=b.size>(b.has("MANUALLY_DISABLED")?1:0);return a.getInheritedDisabled()||b?"disabled":"enabled"}return"hidden"},callback(a){a=a.block;var b=$.gd;b||$.B(!0);a.setDisabledReason(!a.hasDisabledReason("MANUALLY_DISABLED"),"MANUALLY_DISABLED");
266
- $.B(b)},scopeType:Kj.ScopeType.BLOCK,id:"blockDisable",weight:5})};
267
- dk=function(){Kj.registry.register({displayText(a){var b=a.block;a=b.getDescendants(!1).length;(b=b.getNextBlock())&&(a-=b.getDescendants(!1).length);return a===1?$.C.DELETE_BLOCK:$.C.DELETE_X_BLOCKS.replace("%1",`${a}`)},preconditionFn(a){return!a.block.isInFlyout&&a.block.isDeletable()?"enabled":"hidden"},callback(a){a.block&&($.t().focusNode(a.block),a.block.checkAndDelete())},scopeType:Kj.ScopeType.BLOCK,id:"blockDelete",weight:6,associatedKeyboardShortcut:"delete"})};
268
- ek=function(){Kj.registry.register({displayText(){return $.C.HELP},preconditionFn(a){a=a.block;return(typeof a.helpUrl==="function"?a.helpUrl():a.helpUrl)?"enabled":"hidden"},callback(a){a.block.showHelp()},scopeType:Kj.ScopeType.BLOCK,id:"blockHelp",weight:7})};
269
- fk=function(){Kj.registry.register({displayText:()=>$.C.REMOVE_COMMENT,preconditionFn(a){var b;return((b=a.comment)==null?0:b.isDeletable())?"enabled":"hidden"},callback(a){$.B(!0);var b;(b=a.comment)==null||b.dispose();$.B(!1);var c;(c=a.comment)==null||c.workspace.getAudioManager().play("delete")},scopeType:Kj.ScopeType.COMMENT,id:"commentDelete",weight:6,associatedKeyboardShortcut:"delete"})};
270
- gk=function(){Kj.registry.register({displayText:()=>$.C.DUPLICATE_COMMENT,preconditionFn(a){var b;return((b=a.comment)==null?0:b.isMovable())?"enabled":"hidden"},callback(a){if(a.comment){var b=a.comment.toCopyData();b&&di(b,a.comment.workspace)}},scopeType:Kj.ScopeType.COMMENT,id:"commentDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})};
271
- hk=function(){Kj.registry.register({displayText:()=>$.C.ADD_COMMENT,preconditionFn:a=>{var b;return((b=a.workspace)==null?0:b.isMutator)?"hidden":"enabled"},callback:(a,b,c,d)=>{if(a=a.workspace)$.B(!0),b=new dh(a),b.moveTo(oc(a,new D(d.x,d.y))),$.t().focusNode(b),$.B(!1)},scopeType:Kj.ScopeType.WORKSPACE,id:"commentCreate",weight:8})};ik=function(){Lj();Mj();Nj();Pj();Qj();Uj();Vj();Xj();Zj();ak();ck();dk();ek()};M=M||{};M.scope={};M.ASSUME_ES2020=!1;M.ASSUME_ES6=M.ASSUME_ES2020;M.ASSUME_ES5=M.ASSUME_ES6;
250
+ Jj=function(a){var b=a.options,c=a.getParentSvg();k(c.parentNode,"contextmenu",null,function(d){la(d)||d.preventDefault()});c=k(window,"resize",null,function(){Lf();a.hideComponents(!0);sf();zg();tb(a);Wh(a)});a.setResizeHandlerWrapper(c);Gj();if(b.languageTree){c=a.getToolbox();let d=a.getFlyout(!0);c?c.init():d&&(d.init(a),d.show(b.languageTree),typeof d.scrollToStart==="function"&&d.scrollToStart())}b.hasTrashcan&&a.trashcan.init();b.zoomOptions&&b.zoomOptions.controls&&a.zoomControls_.init();
251
+ b.moveOptions&&b.moveOptions.scrollbars?(a.scrollbar=new Hj(a,b.moveOptions.scrollbars===!0||!!b.moveOptions.scrollbars.horizontal,b.moveOptions.scrollbars===!0||!!b.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),a.scrollbar.resize()):a.setMetrics({x:.5,y:.5});b.hasSounds&&Ij(b.pathToMedia,a)};
252
+ Gj=function(){Kj||(k(document,"scroll",null,function(){var a=gb();for(let b=0,c;c=a[b];b++)c instanceof $h&&c.updateInverseScreenCTM()}),ja(document,"touchend",null,aa),ja(document,"touchcancel",null,aa),ja(document,"keydown",null,function(a){a.key==="Tab"&&Nd.setIsActive(!0)}));Kj=!0};Ij=function(a,b){b=b.getAudioManager();b.load([`${a}click.mp3`],"click");b.load([`${a}disconnect.mp3`],"disconnect");b.load([`${a}delete.mp3`],"delete");b.load([`${a}drop.mp3`],"drop")};
253
+ Mj=function(){Lj.registry.register({displayText(){return $.C.UNDO},preconditionFn(a){return a.workspace.getUndoStack().length>0?"enabled":"disabled"},callback(a){a.workspace.undo()},scopeType:Lj.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1,associatedKeyboardShortcut:"undo"})};
254
+ Nj=function(){Lj.registry.register({displayText(){return $.C.REDO},preconditionFn(a){return a.workspace.getRedoStack().length>0?"enabled":"disabled"},callback(a){a.workspace.redo()},scopeType:Lj.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2,associatedKeyboardShortcut:"redo"})};
255
+ Oj=function(){Lj.registry.register({displayText(){return $.C.CLEAN_UP},preconditionFn(a){return a.workspace.isMovable()?a.workspace.getTopBlocks(!1).length>1?"enabled":"disabled":"hidden"},callback(a){a.workspace.cleanUp()},scopeType:Lj.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3,associatedKeyboardShortcut:"cleanup"})};
256
+ Pj=function(a,b){function c(f){e--;f.setCollapsed(a);e===0&&$.B(!1)}var d=0,e=0;$.B(!0);for(let f=0;f<b.length;f++){let g=b[f];for(;g;)e++,setTimeout(c.bind(null,g),d),g=g.getNextBlock(),d+=10}};
257
+ Qj=function(){Lj.registry.register({displayText(){return $.C.COLLAPSE_ALL},preconditionFn(a){if(a.workspace.options.collapse){a=a.workspace.getTopBlocks(!1);for(let b=0;b<a.length;b++){let c=a[b];for(;c;){if(!c.isCollapsed())return"enabled";c=c.getNextBlock()}}return"disabled"}return"hidden"},callback(a){Pj(!0,a.workspace.getTopBlocks(!0))},scopeType:Lj.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})};
258
+ Rj=function(){Lj.registry.register({displayText(){return $.C.EXPAND_ALL},preconditionFn(a){if(a.workspace.options.collapse){a=a.workspace.getTopBlocks(!1);for(let b=0;b<a.length;b++){let c=a[b];for(;c;){if(c.isCollapsed())return"enabled";c=c.getNextBlock()}}return"disabled"}return"hidden"},callback(a){Pj(!1,a.workspace.getTopBlocks(!0))},scopeType:Lj.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})};
259
+ Sj=function(a,b){if(a.isDeletable())Array.prototype.push.apply(b,a.getDescendants(!1));else{a=a.getChildren(!1);for(let c=0;c<a.length;c++)Sj(a[c],b)}};Tj=function(a){var b=[];a=a.getTopBlocks(!0);for(let c=0;c<a.length;c++)Sj(a[c],b);return b};Uj=function(a,b){b?$.B(b):($.B(!0),b=$.gd);var c=a.shift();c&&(c.isDeadOrDying()?Uj(a,b):(c.dispose(!1,!0),setTimeout(Uj,10,a,b)));$.B(!1)};
260
+ Vj=function(){Lj.registry.register({displayText(a){if(!a.workspace)return"";a=Tj(a.workspace).length;return a===1?$.C.DELETE_BLOCK:$.C.DELETE_X_BLOCKS.replace("%1",`${a}`)},preconditionFn(a){return a.workspace?Tj(a.workspace).length>0?"enabled":"disabled":"disabled"},callback(a){if(a.workspace){a.workspace.cancelCurrentGesture();var b=Tj(a.workspace);b.length<2?Uj(b):td($.C.DELETE_ALL_BLOCKS.replace("%1",String(b.length)),function(c){c&&Uj(b)})}},scopeType:Lj.ScopeType.WORKSPACE,id:"workspaceDelete",
261
+ weight:6})};Wj=function(){Lj.registry.register({displayText(){return $.C.DUPLICATE_BLOCK},preconditionFn(a){a=a.block;return!a.isInFlyout&&a.isDeletable()&&a.isMovable()?a.isDuplicatable()?"enabled":"disabled":"hidden"},callback(a){if(a.block){var b=a.block.toCopyData();b&&di(b,a.block.workspace)}},scopeType:Lj.ScopeType.BLOCK,id:"blockDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})};
262
+ Yj=function(){Lj.registry.register({displayText(a){return a.block.hasIcon(Xj.TYPE)?$.C.REMOVE_COMMENT:$.C.ADD_COMMENT},preconditionFn(a){a=a.block;var b;if((b=a&&!a.isInFlyout&&a.workspace.options.comments&&!a.isCollapsed()&&a.isEditable())&&!(b=a.hasIcon(Xj.TYPE))){if(a&&a.isSimpleReporter()){var c;a=(c=a.getFields().next().value)==null?void 0:c.isFullBlockField()}else a=!1;b=!a}return b?"enabled":"hidden"},callback(a){(a=a.block)&&a.hasIcon(Xj.TYPE)?a.setCommentText(null):a.setCommentText("")},
263
+ scopeType:Lj.ScopeType.BLOCK,id:"blockComment",weight:2})};
264
+ ak=function(){Lj.registry.register({displayText(a){return a.block.getInputsInline()?$.C.EXTERNAL_INPUTS:$.C.INLINE_INPUTS},preconditionFn(a){a=a.block;if(!a.isInFlyout&&a.isMovable()&&!a.isCollapsed())for(let b=1;b<a.inputList.length;b++)if(!(a.inputList[b-1]instanceof Zj||a.inputList[b]instanceof Zj))return"enabled";return"hidden"},callback(a){a.block.setInputsInline(!a.block.getInputsInline())},scopeType:Lj.ScopeType.BLOCK,id:"blockInline",weight:3})};
265
+ ck=function(){Lj.registry.register({displayText(a){return a.block.isCollapsed()?$.C.EXPAND_BLOCK:$.C.COLLAPSE_BLOCK},preconditionFn(a){a=a.block;return!a.isInFlyout&&a.isMovable()&&a.workspace.options.collapse?"enabled":"hidden"},callback(a){a.block.setCollapsed(!a.block.isCollapsed())},scopeType:Lj.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})};
266
+ dk=function(){Lj.registry.register({displayText(a){return a.block.hasDisabledReason("MANUALLY_DISABLED")?$.C.ENABLE_BLOCK:$.C.DISABLE_BLOCK},preconditionFn(a){a=a.block;if(!a.isInFlyout&&a.workspace.options.disable&&a.isEditable()){var b=a.getDisabledReasons();b=b.size>(b.has("MANUALLY_DISABLED")?1:0);return a.getInheritedDisabled()||b?"disabled":"enabled"}return"hidden"},callback(a){a=a.block;var b=$.gd;b||$.B(!0);a.setDisabledReason(!a.hasDisabledReason("MANUALLY_DISABLED"),"MANUALLY_DISABLED");
267
+ $.B(b)},scopeType:Lj.ScopeType.BLOCK,id:"blockDisable",weight:5})};
268
+ ek=function(){Lj.registry.register({displayText(a){var b=a.block;a=b.getDescendants(!1).length;(b=b.getNextBlock())&&(a-=b.getDescendants(!1).length);return a===1?$.C.DELETE_BLOCK:$.C.DELETE_X_BLOCKS.replace("%1",`${a}`)},preconditionFn(a){return!a.block.isInFlyout&&a.block.isDeletable()?"enabled":"hidden"},callback(a){a.block&&($.t().focusNode(a.block),a.block.checkAndDelete())},scopeType:Lj.ScopeType.BLOCK,id:"blockDelete",weight:6,associatedKeyboardShortcut:"delete"})};
269
+ fk=function(){Lj.registry.register({displayText(){return $.C.HELP},preconditionFn(a){a=a.block;return(typeof a.helpUrl==="function"?a.helpUrl():a.helpUrl)?"enabled":"hidden"},callback(a){a.block.showHelp()},scopeType:Lj.ScopeType.BLOCK,id:"blockHelp",weight:7})};
270
+ gk=function(){Lj.registry.register({displayText:()=>$.C.REMOVE_COMMENT,preconditionFn(a){var b;return((b=a.comment)==null?0:b.isDeletable())?"enabled":"hidden"},callback(a){$.B(!0);var b;(b=a.comment)==null||b.dispose();$.B(!1);var c;(c=a.comment)==null||c.workspace.getAudioManager().play("delete")},scopeType:Lj.ScopeType.COMMENT,id:"commentDelete",weight:6,associatedKeyboardShortcut:"delete"})};
271
+ hk=function(){Lj.registry.register({displayText:()=>$.C.DUPLICATE_COMMENT,preconditionFn(a){var b;return((b=a.comment)==null?0:b.isMovable())?"enabled":"hidden"},callback(a){if(a.comment){var b=a.comment.toCopyData();b&&di(b,a.comment.workspace)}},scopeType:Lj.ScopeType.COMMENT,id:"commentDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})};
272
+ ik=function(){Lj.registry.register({displayText:()=>$.C.ADD_COMMENT,preconditionFn:a=>{var b;return((b=a.workspace)==null?0:b.isMutator)?"hidden":"enabled"},callback:(a,b,c,d)=>{if(a=a.workspace)$.B(!0),b=new dh(a),b.moveTo(oc(a,new D(d.x,d.y))),$.t().focusNode(b),$.B(!1)},scopeType:Lj.ScopeType.WORKSPACE,id:"commentCreate",weight:8})};jk=function(){Mj();Nj();Oj();Qj();Rj();Vj();Wj();Yj();ak();ck();dk();ek();fk()};M=M||{};M.scope={};M.ASSUME_ES2020=!1;M.ASSUME_ES6=M.ASSUME_ES2020;M.ASSUME_ES5=M.ASSUME_ES6;
272
273
  M.ASSUME_NO_NATIVE_MAP=!1;M.ASSUME_NO_NATIVE_SET=!1;M.ISOLATE_POLYFILLS=!1;M.FORCE_POLYFILL_PROMISE=!1;M.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;M.INSTRUMENT_ASYNC_CONTEXT=!0;M.objectCreate=M.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(a){function b(){}b.prototype=a;return new b};M.defineProperty=M.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
273
274
  M.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};M.global=M.ASSUME_ES2020?globalThis:M.getGlobal(this);M.IS_SYMBOL_NATIVE=typeof Symbol==="function"&&typeof Symbol("x")==="symbol";M.TRUST_ES6_POLYFILLS=!M.ISOLATE_POLYFILLS||M.IS_SYMBOL_NATIVE;M.polyfills={};
274
- M.propertyToPolyfillSymbol={};M.POLYFILL_PREFIX="$jscp$";var jk="Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64".split(" ");M.global.BigInt64Array&&(jk.push("BigInt64"),jk.push("BigUint64"));M.TYPED_ARRAY_CLASSES=jk;M.polyfillTypedArrayMethod=function(a,b,c,d){if(b)for(var e=0;e<M.TYPED_ARRAY_CLASSES.length;e++){var f=M.TYPED_ARRAY_CLASSES[e]+"Array.prototype."+a;M.ISOLATE_POLYFILLS?M.polyfillIsolated(f,b,c,d):M.polyfillUnisolated(f,b,c,d)}};
275
+ M.propertyToPolyfillSymbol={};M.POLYFILL_PREFIX="$jscp$";var kk="Int8 Uint8 Uint8Clamped Int16 Uint16 Int32 Uint32 Float32 Float64".split(" ");M.global.BigInt64Array&&(kk.push("BigInt64"),kk.push("BigUint64"));M.TYPED_ARRAY_CLASSES=kk;M.polyfillTypedArrayMethod=function(a,b,c,d){if(b)for(var e=0;e<M.TYPED_ARRAY_CLASSES.length;e++){var f=M.TYPED_ARRAY_CLASSES[e]+"Array.prototype."+a;M.ISOLATE_POLYFILLS?M.polyfillIsolated(f,b,c,d):M.polyfillUnisolated(f,b,c,d)}};
275
276
  M.polyfill=function(a,b,c,d){b&&(M.ISOLATE_POLYFILLS?M.polyfillIsolated(a,b,c,d):M.polyfillUnisolated(a,b,c,d))};M.polyfillUnisolated=function(a,b){var c=M.global;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))return;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&b!=null&&M.defineProperty(c,a,{configurable:!0,writable:!0,value:b})};
276
277
  M.polyfillIsolated=function(a,b,c){var d=a.split(".");a=d.length===1;var e=d[0];e=!a&&e in M.polyfills?M.polyfills:M.global;for(var f=0;f<d.length-1;f++){var g=d[f];if(!(g in e))return;e=e[g]}d=d[d.length-1];c=M.IS_SYMBOL_NATIVE&&c==="es6"?e[d]:null;b=b(c);b!=null&&(a?M.defineProperty(M.polyfills,d,{configurable:!0,writable:!0,value:b}):b!==c&&(M.propertyToPolyfillSymbol[d]===void 0&&(a=Math.random()*1E9>>>0,M.propertyToPolyfillSymbol[d]=M.IS_SYMBOL_NATIVE?M.global.Symbol(d):M.POLYFILL_PREFIX+a+"$"+
277
278
  d),M.defineProperty(e,M.propertyToPolyfillSymbol[d],{configurable:!0,writable:!0,value:b})))};
@@ -303,14 +304,14 @@ M.getSmallerAndLargerSets=function(a,b){return a.size<=b.size?{smallerSetIterato
303
304
  M.iteratorFromArray=function(a,b){if(M.ASSUME_ES6)return a[Symbol.iterator]();a instanceof String&&(a+="");var c=0,d=!1,e={next:function(){if(!d&&c<a.length){var f=c++;return{value:b(f,a[f]),done:!1}}d=!0;return{done:!0,value:void 0}}};e[Symbol.iterator]=function(){return e};return e};M.polyfill("Array.prototype.values",function(a){return a?a:function(){return M.iteratorFromArray(this,function(b,c){return c})}},"es8","es3");
304
305
  M.polyfill("Array.prototype.flatMap",function(a){return a?a:function(b,c){var d=[];Array.prototype.forEach.call(this,function(e,f){e=b.call(c,e,f,this);Array.isArray(e)?d.push.apply(d,e):d.push(e)});return d}},"es9","es5");M.polyfill("Array.prototype.flat",function(a){return a?a:function(b){b=b===void 0?1:b;var c=[];Array.prototype.forEach.call(this,function(d){Array.isArray(d)&&b>0?(d=Array.prototype.flat.call(d,b-1),c.push.apply(c,d)):c.push(d)});return c}},"es9","es5");
305
306
  M.polyfill("Object.entries",function(a){return a?a:function(b){var c=[],d;for(d in b)M.owns(b,d)&&c.push([d,b[d]]);return c}},"es8","es3");
306
- var kk="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),ha=null,ia={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},ba=0,lk=
307
- {TOUCH_ENABLED:kk,TOUCH_MAP:ia};lk.checkTouchIdentifier=da;lk.clearTouchIdentifier=function(){ha=null};lk.getTouchIdentifierFromEvent=fa;lk.longStart=ca;lk.longStop=aa;lk.shouldHandleEvent=ea;var mk,nk,ok,pk,qk,rk,sk,tk,uk,vk;(function(a){function b(d){return c.includes(d.toUpperCase())}mk=a;var c=mk.toUpperCase();nk=b("JavaFX");ok=b("WebKit");pk=b("Gecko")&&!ok;qk=b("Android");a=globalThis.navigator&&globalThis.navigator.maxTouchPoints;rk=b("iPad")||b("Macintosh")&&a>0;sk=b("iPhone")&&!rk;tk=b("Macintosh");uk=rk||qk&&!b("Mobile")||b("Silk");vk=!uk&&(sk||qk)})(globalThis.navigator&&globalThis.navigator.userAgent||"");
308
- var Xc=nk,wk=pk,xk=qk,Vi=rk,Wi=sk,ma=tk,yk=vk,qe=ma||Vi||Wi,zk={ANDROID:xk,APPLE:qe,GECKO:wk,IPAD:Vi,IPHONE:Wi,JavaFx:Xc,MAC:ma,MOBILE:yk,raw:mk};var Ak={};Ak.bind=ja;Ak.conditionalBind=k;Ak.getScrollDeltaPixels=pa;Ak.isRightButton=na;Ak.isTargetInput=la;Ak.mouseToSvg=oa;Ak.unbind=ka;var Bk={};Bk.removeElem=qa;var Ck=class{constructor(a){this.name=a}toString(){return this.name}};Ck.POSITIONABLE=new Ck("positionable");Ck.DRAG_TARGET=new Ck("drag_target");Ck.DELETE_AREA=new Ck("delete_area");Ck.AUTOHIDEABLE=new Ck("autohideable");Ck.FOCUSABLE=new Ck("focusable");
309
- var Dk=class{constructor(){this.componentData=new Map;this.capabilityToComponentIds=new Map}addComponent(a,b){var c=a.component.id;if(!b&&this.componentData.has(c)){var d;throw Error('Plugin "'+c+'" with capabilities "'+((d=this.componentData.get(c))==null?void 0:d.capabilities)+'" already added.');}this.componentData.set(c,a);b=[];for(d=0;d<a.capabilities.length;d++){let e=String(a.capabilities[d]).toLowerCase();b.push(e);if(this.capabilityToComponentIds.has(e)){let f;(f=this.capabilityToComponentIds.get(e))==
307
+ var lk="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),ha=null,ia={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},ba=0,mk=
308
+ {TOUCH_ENABLED:lk,TOUCH_MAP:ia};mk.checkTouchIdentifier=da;mk.clearTouchIdentifier=function(){ha=null};mk.getTouchIdentifierFromEvent=fa;mk.longStart=ca;mk.longStop=aa;mk.shouldHandleEvent=ea;var nk,ok,pk,qk,rk,sk,tk,uk,vk,wk;(function(a){function b(d){return c.includes(d.toUpperCase())}nk=a;var c=nk.toUpperCase();ok=b("JavaFX");pk=b("WebKit");qk=b("Gecko")&&!pk;rk=b("Android");a=globalThis.navigator&&globalThis.navigator.maxTouchPoints;sk=b("iPad")||b("Macintosh")&&a>0;tk=b("iPhone")&&!sk;uk=b("Macintosh");vk=sk||rk&&!b("Mobile")||b("Silk");wk=!vk&&(tk||rk)})(globalThis.navigator&&globalThis.navigator.userAgent||"");
309
+ var Xc=ok,xk=qk,yk=rk,Vi=sk,Wi=tk,ma=uk,zk=wk,qe=ma||Vi||Wi,Ak={ANDROID:yk,APPLE:qe,GECKO:xk,IPAD:Vi,IPHONE:Wi,JavaFx:Xc,MAC:ma,MOBILE:zk,raw:nk};var Bk={};Bk.bind=ja;Bk.conditionalBind=k;Bk.getScrollDeltaPixels=pa;Bk.isRightButton=na;Bk.isTargetInput=la;Bk.mouseToSvg=oa;Bk.unbind=ka;var Ck={};Ck.removeElem=qa;var Dk=class{constructor(a){this.name=a}toString(){return this.name}};Dk.POSITIONABLE=new Dk("positionable");Dk.DRAG_TARGET=new Dk("drag_target");Dk.DELETE_AREA=new Dk("delete_area");Dk.AUTOHIDEABLE=new Dk("autohideable");Dk.FOCUSABLE=new Dk("focusable");
310
+ var Ek=class{constructor(){this.componentData=new Map;this.capabilityToComponentIds=new Map}addComponent(a,b){var c=a.component.id;if(!b&&this.componentData.has(c)){var d;throw Error('Plugin "'+c+'" with capabilities "'+((d=this.componentData.get(c))==null?void 0:d.capabilities)+'" already added.');}this.componentData.set(c,a);b=[];for(d=0;d<a.capabilities.length;d++){let e=String(a.capabilities[d]).toLowerCase();b.push(e);if(this.capabilityToComponentIds.has(e)){let f;(f=this.capabilityToComponentIds.get(e))==
310
311
  null||f.push(c)}else this.capabilityToComponentIds.set(e,[c])}this.componentData.get(c).capabilities=b}removeComponent(a){var b=this.componentData.get(a);if(b){for(let c=0;c<b.capabilities.length;c++){let d=String(b.capabilities[c]).toLowerCase();qa(this.capabilityToComponentIds.get(d),a)}this.componentData.delete(a)}}addCapability(a,b){if(!this.getComponent(a))throw Error('Cannot add capability, "'+b+'". Plugin "'+a+'" has not been added to the ComponentManager');if(this.hasCapability(a,b))console.warn('Plugin "'+
311
312
  a+'already has capability "'+b+'"');else{b=`${b}`.toLowerCase();var c;(c=this.componentData.get(a))==null||c.capabilities.push(b);var d;(d=this.capabilityToComponentIds.get(b))==null||d.push(a)}}removeCapability(a,b){if(!this.getComponent(a))throw Error('Cannot remove capability, "'+b+'". Plugin "'+a+'" has not been added to the ComponentManager');this.hasCapability(a,b)?(b=`${b}`.toLowerCase(),qa(this.componentData.get(a).capabilities,b),qa(this.capabilityToComponentIds.get(b),a)):console.warn('Plugin "'+
312
313
  a+"doesn't have capability \""+b+'" to remove')}hasCapability(a,b){b=`${b}`.toLowerCase();return this.componentData.has(a)&&this.componentData.get(a).capabilities.includes(b)}getComponent(a){var b;return(b=this.componentData.get(a))==null?void 0:b.component}getComponents(a,b){a=`${a}`.toLowerCase();a=this.capabilityToComponentIds.get(a);if(!a)return[];var c=[];if(b){let d=[];a.forEach(e=>{d.push(this.componentData.get(e))});d.sort(function(e,f){return e.weight-f.weight});d.forEach(function(e){c.push(e.component)})}else a.forEach(d=>
313
- {c.push(this.componentData.get(d).component)});return c}};Dk.Capability=Ck;var Ek=Dk||(Dk={}),Fk=Ek.ComponentWeight||(Ek.ComponentWeight={});Fk[Fk.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT";Fk[Fk.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT";Fk[Fk.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT";Fk[Fk.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT";var ua=new WeakSet,sa=[],va=`
314
+ {c.push(this.componentData.get(d).component)});return c}};Ek.Capability=Dk;var Fk=Ek||(Ek={}),Gk=Fk.ComponentWeight||(Fk.ComponentWeight={});Gk[Gk.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT";Gk[Gk.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT";Gk[Gk.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT";Gk[Gk.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT";var ua=new WeakSet,sa=[],va=`
314
315
  :is(
315
316
  .injectionDiv,
316
317
  .blocklyWidgetDiv,
@@ -947,39 +948,39 @@ input[type=number] {
947
948
  }
948
949
  .blocklyDialogButtonRow {
949
950
  display: flex;
950
- flex-direction: ${yk||qe?"row-reverse":"row"};
951
+ flex-direction: ${zk||qe?"row-reverse":"row"};
951
952
  column-gap: 8px;
952
953
  }
953
- `,Gk={};Gk.inject=wa;Gk.register=ta;var v,Hk=v||(v={});Hk.BLOCK_CREATE="create";Hk.BLOCK_DELETE="delete";Hk.BLOCK_CHANGE="change";Hk.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change";Hk.BLOCK_MOVE="move";Hk.VAR_CREATE="var_create";Hk.VAR_DELETE="var_delete";Hk.VAR_RENAME="var_rename";Hk.VAR_TYPE_CHANGE="var_type_change";Hk.UI="ui";Hk.BLOCK_DRAG="drag";Hk.SELECTED="selected";Hk.CLICK="click";Hk.MARKER_MOVE="marker_move";Hk.BUBBLE_OPEN="bubble_open";Hk.TRASHCAN_OPEN="trashcan_open";Hk.TOOLBOX_ITEM_SELECT="toolbox_item_select";
954
- Hk.THEME_CHANGE="theme_change";Hk.VIEWPORT_CHANGE="viewport_change";Hk.COMMENT_CREATE="comment_create";Hk.COMMENT_DELETE="comment_delete";Hk.COMMENT_CHANGE="comment_change";Hk.COMMENT_MOVE="comment_move";Hk.COMMENT_RESIZE="comment_resize";Hk.COMMENT_DRAG="comment_drag";Hk.COMMENT_COLLAPSE="comment_collapse";Hk.FINISHED_LOADING="finished_loading";var Vh=[v.BLOCK_CREATE,v.BLOCK_MOVE,v.COMMENT_CREATE,v.COMMENT_MOVE];var zb=Object.create(null);var Ca,Ik=Ca||(Ca={});Ik.ASSERTIVE="assertive";Ik.OFF="off";Ik.POLITE="polite";var Ga=Ca.OFF,Fa=[],Ka,Jk=Ka||(Ka={});Jk.APPLICATION="application";Jk.BUTTON="button";Jk.CHECKBOX="checkbox";Jk.DIALOG="dialog";Jk.FIGURE="figure";Jk.GENERIC="generic";Jk.GRID="grid";Jk.GRIDCELL="gridcell";Jk.GROUP="group";Jk.LIST="list";Jk.LISTBOX="listbox";Jk.LISTITEM="listitem";Jk.MENU="menu";Jk.MENUITEM="menuitem";Jk.NONE="none";Jk.OPTION="option";Jk.REGION="region";Jk.ROW="row";Jk.SEPARATOR="separator";Jk.STATUS="status";
955
- Jk.TEXTBOX="textbox";Jk.TREE="tree";Jk.TREEITEM="treeitem";var Da=Ka.STATUS,p,Kk=p||(p={});Kk.ACTIVEDESCENDANT="activedescendant";Kk.ATOMIC="atomic";Kk.CHECKED="checked";Kk.CONTROLS="controls";Kk.DISABLED="disabled";Kk.EXPANDED="expanded";Kk.HASPOPUP="haspopup";Kk.HIDDEN="hidden";Kk.INVALID="invalid";Kk.LABEL="label";Kk.LABELLEDBY="labelledby";Kk.LEVEL="level";Kk.LIVE="live";Kk.PRESSED="pressed";Kk.ROLEDESCRIPTION="roledescription";Kk.SELECTED="selected";Kk.VALUEMAX="valuemax";Kk.VALUEMIN="valuemin";
956
- Kk.OWNS="owns";var we,Lk=we||(we={});Lk[Lk.TERSE=0]="TERSE";Lk[Lk.STANDARD=1]="STANDARD";Lk[Lk.LOQUACIOUS=2]="LOQUACIOUS";var Ba=null,Ha,Ia=!1,Mk={};Mk.LiveRegionAssertiveness=Ca;Mk.Role=Ka;Mk.State=p;Mk.Verbosity=we;Mk.announceDynamicAriaState=Ja;Mk.clearState=za;Mk.getRole=function(a){return(a=a.getAttribute("role"))&&Object.values(Ka).includes(a)?a:null};Mk.getState=Aa;Mk.initializeGlobalAriaLiveRegion=Ea;Mk.removeRole=xa;Mk.setRole=ya;Mk.setState=l;var q=class{constructor(a){this.tagName=a}toString(){return this.tagName}};q.ANIMATE=new q("animate");q.CIRCLE=new q("circle");q.CLIPPATH=new q("clipPath");q.DEFS=new q("defs");q.FECOMPOSITE=new q("feComposite");q.FECOMPONENTTRANSFER=new q("feComponentTransfer");q.FEFLOOD=new q("feFlood");q.FEFUNCA=new q("feFuncA");q.FEGAUSSIANBLUR=new q("feGaussianBlur");q.FEPOINTLIGHT=new q("fePointLight");q.FESPECULARLIGHTING=new q("feSpecularLighting");q.FILTER=new q("filter");q.FOREIGNOBJECT=new q("foreignObject");
957
- q.G=new q("g");q.IMAGE=new q("image");q.LINE=new q("line");q.PATH=new q("path");q.PATTERN=new q("pattern");q.POLYGON=new q("polygon");q.RECT=new q("rect");q.SVG=new q("svg");q.TEXT=new q("text");q.TSPAN=new q("tspan");var Xg,Nk=Xg||(Xg={});Nk[Nk.ELEMENT_NODE=1]="ELEMENT_NODE";Nk[Nk.TEXT_NODE=3]="TEXT_NODE";Nk[Nk.COMMENT_NODE=8]="COMMENT_NODE";var Sa=null,Ra=0,Xa=null,Ok={HTML_NS:"http://www.w3.org/1999/xhtml"};Ok.NodeType=Xg;Ok.SVG_NS="http://www.w3.org/2000/svg";Ok.XLINK_NS="http://www.w3.org/1999/xlink";Ok.addClass=n;Ok.createSvgElement=r;Ok.getFastTextWidth=function(a,b,c,d){return Va(a,b+"pt",c,d)};Ok.getFastTextWidthWithSizeString=Va;Ok.getTextWidth=Wa;Ok.hasClass=Na;Ok.insertAfter=Pa;
958
- Ok.measureFontMetrics=Ya;Ok.removeClass=Ma;Ok.removeClasses=La;Ok.removeNode=Oa;Ok.setCssTransform=Qa;Ok.startTextWidthCache=Ta;Ok.stopTextWidthCache=Ua;var Pk=class{static findFocusedNode(a){var b=a.getRootFocusableNode();if(!b.canBeFocused())return null;var c=b.getFocusableElement();if(Na(c,Pk.ACTIVE_CLASS_NAME)||Na(c,Pk.PASSIVE_CSS_CLASS_NAME))return b;b=c.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR);if(b instanceof HTMLElement||b instanceof SVGElement)if(b=Pk.findFocusableNodeFor(b,a))return b;c=c.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR);if(c instanceof HTMLElement||c instanceof SVGElement)if(a=Pk.findFocusableNodeFor(c,a))return a;
959
- return null}static findFocusableNodeFor(a,b){if(!a.id||a.id==="null"||b.getNestedTrees().map(e=>Pk.findFocusableNodeFor(a,e)).findIndex(e=>!!e)!==-1)return null;var c=b.getRootFocusableNode();if(c.canBeFocused()&&a===c.getFocusableElement())return c;var d;if(c=(d=b.lookUpFocusableNode(a.id))!=null?d:null)return c;d=a.parentElement;return!c&&d?Pk.findFocusableNodeFor(d,b):null}};Pk.ACTIVE_CLASS_NAME="blocklyActiveFocus";Pk.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus";
960
- Pk.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${Pk.ACTIVE_CLASS_NAME}`;Pk.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${Pk.PASSIVE_CSS_CLASS_NAME}`;var Qk=class{constructor(a,b){this.tree=a;this.rootShouldBeAutoTabbable=b}},Za=class{constructor(a){this.previouslyFocusedNode=this.focusedNode=null;this.registeredTrees=[];this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1;this.popoverFocusLossHandlers=new Set;this.popoverFocusOutHandler=c=>{c=c.relatedTarget;var d;if(c===null||c instanceof Node&&((d=this.popoverFocusRoot)==null||!d.contains(c)))for(let e of this.popoverFocusLossHandlers)e()};
961
- var b=c=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!c;var d=null;if(c instanceof HTMLElement||c instanceof SVGElement)for(var e of this.registeredTrees)if(d=Pk.findFocusableNodeFor(c,e.tree))break;if(d&&d.canBeFocused()){c=d.getFocusableTree();let f;e=(f=this.focusedNode)==null?void 0:f.getFocusableTree();d===c.getRootFocusableNode()&&c!==e?this.focusTree(c):this.focusNode(d)}else this.defocusCurrentFocusedNode()}};a("focusin",c=>{c instanceof FocusEvent&&b(document.activeElement)});
962
- a("focusout",c=>{c instanceof FocusEvent&&b(c.relatedTarget)})}registerTree(a,b=!1){this.ensureManagerIsUnlocked();if(this.isRegistered(a))throw Error(`Attempted to re-register already registered tree: ${a}.`);this.registeredTrees.push(new Qk(a,b));var c=a.getRootFocusableNode().getFocusableElement();if(!c.id||c.id==="null")throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${a}.`);b&&(c.tabIndex=0)}isRegistered(a){return!!this.lookUpRegistration(a)}lookUpRegistration(a){var b;
963
- return(b=this.registeredTrees.find(c=>c.tree===a))!=null?b:null}unregisterTree(a){this.ensureManagerIsUnlocked();if(!this.isRegistered(a))throw Error(`Attempted to unregister not registered tree: ${a}.`);var b=this.registeredTrees.findIndex(e=>e.tree===a),c=this.registeredTrees[b];this.registeredTrees.splice(b,1);b=Pk.findFocusedNode(a);var d=a.getRootFocusableNode();b&&this.removeHighlight(b);this.focusedNode!==b&&this.focusedNode!==d||this.updateFocusedNode(null);this.removeHighlight(d);c.rootShouldBeAutoTabbable&&
964
- a.getRootFocusableNode().getFocusableElement().removeAttribute("tabindex")}getFocusedTree(){var a,b;return(b=(a=this.focusedNode)==null?void 0:a.getFocusableTree())!=null?b:null}getFocusedNode(){return this.focusedNode}focusTree(a){this.ensureManagerIsUnlocked();if(!this.isRegistered(a))throw Error(`Attempted to focus unregistered tree: ${a}.`);var b=Pk.findFocusedNode(a),c=a.getRestoredFocusableNode(b);a=a.getRootFocusableNode();var d;this.focusNode((d=c!=null?c:b)!=null?d:a)}focusNode(a){this.ensureManagerIsUnlocked();
965
- var b=!this.currentlyHoldsEphemeralFocus;b&&(this.isUpdatingFocusedNode=!0);var c,d=((c=this.focusedNode)==null?void 0:c.getFocusableElement())!==document.activeElement;if(this.focusedNode!==a||d)if(a.canBeFocused()){c=a.getFocusableTree();if(!this.isRegistered(c))throw Error(`Attempted to focus unregistered node: ${a}.`);d=a.getFocusableElement();d.id&&d.id!=="null"||console.warn("Trying to focus a node that has an invalid ID.");var e=Pk.findFocusableNodeFor(d,c);d=Pk.findFocusedNode(c);var f=a;
966
- if(e!==a){f=c.getRestoredFocusableNode(d);a=c.getRootFocusableNode();var g;f=(g=f!=null?f:d)!=null?g:a}a=this.focusedNode;g=a==null?void 0:a.getFocusableTree();a&&this.passivelyFocusNode(a,c);c=c.getRootFocusableNode();d&&this.removeHighlight(d);c!==f&&this.removeHighlight(c);this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(f,g!=null?g:null);this.updateFocusedNode(f)}else console.warn("Trying to focus a node that can't be focused.");b&&(this.isUpdatingFocusedNode=!1)}takeEphemeralFocus(a){this.ensureManagerIsUnlocked();
967
- if(this.currentlyHoldsEphemeralFocus)throw Error(`Attempted to take ephemeral focus when it's already held, with new element: ${a}.`);this.currentlyHoldsEphemeralFocus=!0;this.focusedNode&&this.passivelyFocusNode(this.focusedNode,null);a.focus({preventScroll:!0});var b=!1;return(c=!0)=>{if(b)throw Error(`Attempted to finish ephemeral focus twice for element: ${a}.`);b=!0;this.currentlyHoldsEphemeralFocus=!1;if(this.focusedNode&&c){this.activelyFocusNode(this.focusedNode,null);let d=this.focusedNode;
968
- setTimeout(()=>{!this.focusedNode&&this.previouslyFocusedNode===d&&this.recentlyLostAllFocus&&this.focusNode(d)},0)}}}ephemeralFocusTaken(){return this.currentlyHoldsEphemeralFocus}ensureManagerIsUnlocked(){if(this.lockFocusStateChanges)throw Error("FocusManager state changes cannot happen in a tree/node focus/blur callback.");}updateFocusedNode(a){this.previouslyFocusedNode=this.focusedNode;this.focusedNode=a}defocusCurrentFocusedNode(){this.focusedNode&&!this.currentlyHoldsEphemeralFocus&&(this.passivelyFocusNode(this.focusedNode,
969
- null),this.updateFocusedNode(null))}activelyFocusNode(a,b){this.lockFocusStateChanges=!0;var c=a.getFocusableTree(),d=a.getFocusableElement(),e,f=(e=this.lookUpRegistration(c))==null?void 0:e.rootShouldBeAutoTabbable;c!==b&&(c.onTreeFocus(a,b),f&&(c.getRootFocusableNode().getFocusableElement().tabIndex=-1));a.onNodeFocus();this.lockFocusStateChanges=!1;f&&a===c.getRootFocusableNode()||d.hasAttribute("tabindex")||(d.tabIndex=-1);this.setNodeToVisualActiveFocus(a);d.focus({preventScroll:!0})}passivelyFocusNode(a,
970
- b){this.lockFocusStateChanges=!0;var c=a.getFocusableTree();if(c!==b){c.onTreeBlur(b);let d;if((d=this.lookUpRegistration(c))==null?0:d.rootShouldBeAutoTabbable)c.getRootFocusableNode().getFocusableElement().tabIndex=0}a.onNodeBlur();this.lockFocusStateChanges=!1;c!==b&&this.setNodeToVisualPassiveFocus(a)}setNodeToVisualActiveFocus(a){a=a.getFocusableElement();n(a,Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);Ma(a,Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(a){a=a.getFocusableElement();
971
- Ma(a,Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);n(a,Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(a){a=a.getFocusableElement();Ma(a,Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);Ma(a,Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){Za.focusManager||(Za.focusManager=new Za(document.addEventListener));return Za.focusManager}setPopoverFocusRoot(a){var b;(b=this.popoverFocusRoot)==null||b.removeEventListener("focusout",this.popoverFocusOutHandler);this.popoverFocusRoot=a;this.popoverFocusRoot.addEventListener("focusout",
972
- this.popoverFocusOutHandler)}registerPopoverFocusLossHandler(a){this.popoverFocusLossHandlers.add(a)}unregisterPopoverFocusLossHandler(a){this.popoverFocusLossHandlers.delete(a)}};Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus";Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus";Za.focusManager=null;var Rk={};Rk.deepMerge=bb;var x=class{constructor(){this.shortcuts=new Map;this.keyMap=new Map;this.reset()}reset(){this.shortcuts.clear();this.keyMap.clear()}register(a,b){if(this.shortcuts.get(a.name)&&!b)throw Error(`Shortcut named "${a.name}" already exists.`);this.shortcuts.set(a.name,a);b=a.keyCodes;if(b==null?0:b.length)for(let c of b)this.addKeyMapping(c,a.name,!!a.allowCollision)}unregister(a){if(!this.shortcuts.get(a))return console.warn(`Keyboard shortcut named "${a}" not found.`),!1;this.removeAllKeyMappings(a);
954
+ `,Hk={};Hk.inject=wa;Hk.register=ta;var v,Ik=v||(v={});Ik.BLOCK_CREATE="create";Ik.BLOCK_DELETE="delete";Ik.BLOCK_CHANGE="change";Ik.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change";Ik.BLOCK_MOVE="move";Ik.VAR_CREATE="var_create";Ik.VAR_DELETE="var_delete";Ik.VAR_RENAME="var_rename";Ik.VAR_TYPE_CHANGE="var_type_change";Ik.UI="ui";Ik.BLOCK_DRAG="drag";Ik.SELECTED="selected";Ik.CLICK="click";Ik.MARKER_MOVE="marker_move";Ik.BUBBLE_OPEN="bubble_open";Ik.TRASHCAN_OPEN="trashcan_open";Ik.TOOLBOX_ITEM_SELECT="toolbox_item_select";
955
+ Ik.THEME_CHANGE="theme_change";Ik.VIEWPORT_CHANGE="viewport_change";Ik.COMMENT_CREATE="comment_create";Ik.COMMENT_DELETE="comment_delete";Ik.COMMENT_CHANGE="comment_change";Ik.COMMENT_MOVE="comment_move";Ik.COMMENT_RESIZE="comment_resize";Ik.COMMENT_DRAG="comment_drag";Ik.COMMENT_COLLAPSE="comment_collapse";Ik.FINISHED_LOADING="finished_loading";var Vh=[v.BLOCK_CREATE,v.BLOCK_MOVE,v.COMMENT_CREATE,v.COMMENT_MOVE];var zb=Object.create(null);var Ca,Jk=Ca||(Ca={});Jk.ASSERTIVE="assertive";Jk.OFF="off";Jk.POLITE="polite";var Ga=Ca.OFF,Fa=[],Ka,Kk=Ka||(Ka={});Kk.APPLICATION="application";Kk.BUTTON="button";Kk.CHECKBOX="checkbox";Kk.DIALOG="dialog";Kk.FIGURE="figure";Kk.GENERIC="generic";Kk.GRID="grid";Kk.GRIDCELL="gridcell";Kk.GROUP="group";Kk.LIST="list";Kk.LISTBOX="listbox";Kk.LISTITEM="listitem";Kk.MENU="menu";Kk.MENUITEM="menuitem";Kk.NONE="none";Kk.OPTION="option";Kk.REGION="region";Kk.ROW="row";Kk.SEPARATOR="separator";Kk.STATUS="status";
956
+ Kk.TEXTBOX="textbox";Kk.TREE="tree";Kk.TREEITEM="treeitem";var Da=Ka.STATUS,p,Lk=p||(p={});Lk.ACTIVEDESCENDANT="activedescendant";Lk.ATOMIC="atomic";Lk.CHECKED="checked";Lk.CONTROLS="controls";Lk.DISABLED="disabled";Lk.EXPANDED="expanded";Lk.HASPOPUP="haspopup";Lk.HIDDEN="hidden";Lk.INVALID="invalid";Lk.LABEL="label";Lk.LABELLEDBY="labelledby";Lk.LEVEL="level";Lk.LIVE="live";Lk.PRESSED="pressed";Lk.ROLEDESCRIPTION="roledescription";Lk.SELECTED="selected";Lk.VALUEMAX="valuemax";Lk.VALUEMIN="valuemin";
957
+ Lk.OWNS="owns";var we,Mk=we||(we={});Mk[Mk.TERSE=0]="TERSE";Mk[Mk.STANDARD=1]="STANDARD";Mk[Mk.LOQUACIOUS=2]="LOQUACIOUS";var Ba=null,Ha,Ia=!1,Nk={};Nk.LiveRegionAssertiveness=Ca;Nk.Role=Ka;Nk.State=p;Nk.Verbosity=we;Nk.announceDynamicAriaState=Ja;Nk.clearState=za;Nk.getRole=function(a){return(a=a.getAttribute("role"))&&Object.values(Ka).includes(a)?a:null};Nk.getState=Aa;Nk.initializeGlobalAriaLiveRegion=Ea;Nk.removeRole=xa;Nk.setRole=ya;Nk.setState=l;var q=class{constructor(a){this.tagName=a}toString(){return this.tagName}};q.ANIMATE=new q("animate");q.CIRCLE=new q("circle");q.CLIPPATH=new q("clipPath");q.DEFS=new q("defs");q.FECOMPOSITE=new q("feComposite");q.FECOMPONENTTRANSFER=new q("feComponentTransfer");q.FEFLOOD=new q("feFlood");q.FEFUNCA=new q("feFuncA");q.FEGAUSSIANBLUR=new q("feGaussianBlur");q.FEPOINTLIGHT=new q("fePointLight");q.FESPECULARLIGHTING=new q("feSpecularLighting");q.FILTER=new q("filter");q.FOREIGNOBJECT=new q("foreignObject");
958
+ q.G=new q("g");q.IMAGE=new q("image");q.LINE=new q("line");q.PATH=new q("path");q.PATTERN=new q("pattern");q.POLYGON=new q("polygon");q.RECT=new q("rect");q.SVG=new q("svg");q.TEXT=new q("text");q.TSPAN=new q("tspan");var Xg,Ok=Xg||(Xg={});Ok[Ok.ELEMENT_NODE=1]="ELEMENT_NODE";Ok[Ok.TEXT_NODE=3]="TEXT_NODE";Ok[Ok.COMMENT_NODE=8]="COMMENT_NODE";var Sa=null,Ra=0,Xa=null,Pk={HTML_NS:"http://www.w3.org/1999/xhtml"};Pk.NodeType=Xg;Pk.SVG_NS="http://www.w3.org/2000/svg";Pk.XLINK_NS="http://www.w3.org/1999/xlink";Pk.addClass=n;Pk.createSvgElement=r;Pk.getFastTextWidth=function(a,b,c,d){return Va(a,b+"pt",c,d)};Pk.getFastTextWidthWithSizeString=Va;Pk.getTextWidth=Wa;Pk.hasClass=Na;Pk.insertAfter=Pa;
959
+ Pk.measureFontMetrics=Ya;Pk.removeClass=Ma;Pk.removeClasses=La;Pk.removeNode=Oa;Pk.setCssTransform=Qa;Pk.startTextWidthCache=Ta;Pk.stopTextWidthCache=Ua;var Qk=class{static findFocusedNode(a){var b=a.getRootFocusableNode();if(!b.canBeFocused())return null;var c=b.getFocusableElement();if(Na(c,Qk.ACTIVE_CLASS_NAME)||Na(c,Qk.PASSIVE_CSS_CLASS_NAME))return b;b=c.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR);if(b instanceof HTMLElement||b instanceof SVGElement)if(b=Qk.findFocusableNodeFor(b,a))return b;c=c.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR);if(c instanceof HTMLElement||c instanceof SVGElement)if(a=Qk.findFocusableNodeFor(c,a))return a;
960
+ return null}static findFocusableNodeFor(a,b){if(!a.id||a.id==="null"||b.getNestedTrees().map(e=>Qk.findFocusableNodeFor(a,e)).findIndex(e=>!!e)!==-1)return null;var c=b.getRootFocusableNode();if(c.canBeFocused()&&a===c.getFocusableElement())return c;var d;if(c=(d=b.lookUpFocusableNode(a.id))!=null?d:null)return c;d=a.parentElement;return!c&&d?Qk.findFocusableNodeFor(d,b):null}};Qk.ACTIVE_CLASS_NAME="blocklyActiveFocus";Qk.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus";
961
+ Qk.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${Qk.ACTIVE_CLASS_NAME}`;Qk.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${Qk.PASSIVE_CSS_CLASS_NAME}`;var Rk=class{constructor(a,b){this.tree=a;this.rootShouldBeAutoTabbable=b}},Za=class{constructor(a){this.previouslyFocusedNode=this.focusedNode=null;this.registeredTrees=[];this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1;this.popoverFocusLossHandlers=new Set;this.popoverFocusOutHandler=c=>{c=c.relatedTarget;var d;if(c===null||c instanceof Node&&((d=this.popoverFocusRoot)==null||!d.contains(c)))for(let e of this.popoverFocusLossHandlers)e()};
962
+ var b=c=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!c;var d=null;if(c instanceof HTMLElement||c instanceof SVGElement)for(var e of this.registeredTrees)if(d=Qk.findFocusableNodeFor(c,e.tree))break;if(d&&d.canBeFocused()){c=d.getFocusableTree();let f;e=(f=this.focusedNode)==null?void 0:f.getFocusableTree();d===c.getRootFocusableNode()&&c!==e?this.focusTree(c):this.focusNode(d)}else this.defocusCurrentFocusedNode()}};a("focusin",c=>{c instanceof FocusEvent&&b(document.activeElement)});
963
+ a("focusout",c=>{c instanceof FocusEvent&&b(c.relatedTarget)})}registerTree(a,b=!1){this.ensureManagerIsUnlocked();if(this.isRegistered(a))throw Error(`Attempted to re-register already registered tree: ${a}.`);this.registeredTrees.push(new Rk(a,b));var c=a.getRootFocusableNode().getFocusableElement();if(!c.id||c.id==="null")throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${a}.`);b&&(c.tabIndex=0)}isRegistered(a){return!!this.lookUpRegistration(a)}lookUpRegistration(a){var b;
964
+ return(b=this.registeredTrees.find(c=>c.tree===a))!=null?b:null}unregisterTree(a){this.ensureManagerIsUnlocked();if(!this.isRegistered(a))throw Error(`Attempted to unregister not registered tree: ${a}.`);var b=this.registeredTrees.findIndex(e=>e.tree===a),c=this.registeredTrees[b];this.registeredTrees.splice(b,1);b=Qk.findFocusedNode(a);var d=a.getRootFocusableNode();b&&this.removeHighlight(b);this.focusedNode!==b&&this.focusedNode!==d||this.updateFocusedNode(null);this.removeHighlight(d);c.rootShouldBeAutoTabbable&&
965
+ a.getRootFocusableNode().getFocusableElement().removeAttribute("tabindex")}getFocusedTree(){var a,b;return(b=(a=this.focusedNode)==null?void 0:a.getFocusableTree())!=null?b:null}getFocusedNode(){return this.focusedNode}getPreviouslyFocusedNode(){return this.previouslyFocusedNode}focusTree(a){this.ensureManagerIsUnlocked();if(!this.isRegistered(a))throw Error(`Attempted to focus unregistered tree: ${a}.`);var b=Qk.findFocusedNode(a),c=a.getRestoredFocusableNode(b);a=a.getRootFocusableNode();var d;
966
+ this.focusNode((d=c!=null?c:b)!=null?d:a)}focusNode(a){this.ensureManagerIsUnlocked();var b=!this.currentlyHoldsEphemeralFocus;b&&(this.isUpdatingFocusedNode=!0);var c,d=((c=this.focusedNode)==null?void 0:c.getFocusableElement())!==document.activeElement;if(this.focusedNode!==a||d)if(a.canBeFocused()){c=a.getFocusableTree();if(!this.isRegistered(c))throw Error(`Attempted to focus unregistered node: ${a}.`);d=a.getFocusableElement();d.id&&d.id!=="null"||console.warn("Trying to focus a node that has an invalid ID.");
967
+ var e=Qk.findFocusableNodeFor(d,c);d=Qk.findFocusedNode(c);var f=a;if(e!==a){f=c.getRestoredFocusableNode(d);a=c.getRootFocusableNode();var g;f=(g=f!=null?f:d)!=null?g:a}a=this.focusedNode;g=a==null?void 0:a.getFocusableTree();a&&this.passivelyFocusNode(a,c);c=c.getRootFocusableNode();d&&this.removeHighlight(d);c!==f&&this.removeHighlight(c);this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(f,g!=null?g:null);this.updateFocusedNode(f)}else console.warn("Trying to focus a node that can't be focused.");
968
+ b&&(this.isUpdatingFocusedNode=!1)}takeEphemeralFocus(a){this.ensureManagerIsUnlocked();if(this.currentlyHoldsEphemeralFocus)throw Error(`Attempted to take ephemeral focus when it's already held, with new element: ${a}.`);this.currentlyHoldsEphemeralFocus=!0;this.focusedNode&&this.passivelyFocusNode(this.focusedNode,null);a.focus({preventScroll:!0});var b=!1;return(c=!0)=>{if(b)throw Error(`Attempted to finish ephemeral focus twice for element: ${a}.`);b=!0;this.currentlyHoldsEphemeralFocus=!1;if(this.focusedNode&&
969
+ c){this.activelyFocusNode(this.focusedNode,null);let d=this.focusedNode;setTimeout(()=>{!this.focusedNode&&this.previouslyFocusedNode===d&&this.recentlyLostAllFocus&&this.focusNode(d)},0)}}}ephemeralFocusTaken(){return this.currentlyHoldsEphemeralFocus}ensureManagerIsUnlocked(){if(this.lockFocusStateChanges)throw Error("FocusManager state changes cannot happen in a tree/node focus/blur callback.");}updateFocusedNode(a){this.previouslyFocusedNode=this.focusedNode;this.focusedNode=a}defocusCurrentFocusedNode(){this.focusedNode&&
970
+ !this.currentlyHoldsEphemeralFocus&&(this.passivelyFocusNode(this.focusedNode,null),this.updateFocusedNode(null))}activelyFocusNode(a,b){this.lockFocusStateChanges=!0;var c=a.getFocusableTree(),d=a.getFocusableElement(),e,f=(e=this.lookUpRegistration(c))==null?void 0:e.rootShouldBeAutoTabbable;c!==b&&(c.onTreeFocus(a,b),f&&(c.getRootFocusableNode().getFocusableElement().tabIndex=-1));a.onNodeFocus();this.lockFocusStateChanges=!1;f&&a===c.getRootFocusableNode()||d.hasAttribute("tabindex")||(d.tabIndex=
971
+ -1);this.setNodeToVisualActiveFocus(a);d.focus({preventScroll:!0})}passivelyFocusNode(a,b){this.lockFocusStateChanges=!0;var c=a.getFocusableTree();if(c!==b){c.onTreeBlur(b);let d;if((d=this.lookUpRegistration(c))==null?0:d.rootShouldBeAutoTabbable)c.getRootFocusableNode().getFocusableElement().tabIndex=0}a.onNodeBlur();this.lockFocusStateChanges=!1;c!==b&&this.setNodeToVisualPassiveFocus(a)}setNodeToVisualActiveFocus(a){a=a.getFocusableElement();n(a,Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);Ma(a,Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(a){a=
972
+ a.getFocusableElement();Ma(a,Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);n(a,Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(a){a=a.getFocusableElement();Ma(a,Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);Ma(a,Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){Za.focusManager||(Za.focusManager=new Za(document.addEventListener));return Za.focusManager}setPopoverFocusRoot(a){var b;(b=this.popoverFocusRoot)==null||b.removeEventListener("focusout",this.popoverFocusOutHandler);this.popoverFocusRoot=
973
+ a;this.popoverFocusRoot.addEventListener("focusout",this.popoverFocusOutHandler)}registerPopoverFocusLossHandler(a){this.popoverFocusLossHandlers.add(a)}unregisterPopoverFocusLossHandler(a){this.popoverFocusLossHandlers.delete(a)}};Za.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus";Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus";Za.focusManager=null;var Sk={};Sk.deepMerge=bb;var x=class{constructor(){this.shortcuts=new Map;this.keyMap=new Map;this.reset()}reset(){this.shortcuts.clear();this.keyMap.clear()}register(a,b){if(this.shortcuts.get(a.name)&&!b)throw Error(`Shortcut named "${a.name}" already exists.`);this.shortcuts.set(a.name,a);b=a.keyCodes;if(b==null?0:b.length)for(let c of b)this.addKeyMapping(c,a.name,!!a.allowCollision)}unregister(a){if(!this.shortcuts.get(a))return console.warn(`Keyboard shortcut named "${a}" not found.`),!1;this.removeAllKeyMappings(a);
973
974
  this.shortcuts.delete(a);return!0}addKeyMapping(a,b,c){a=`${a}`;var d=this.keyMap.get(a);if(d&&!c)throw Error(`Shortcut named "${b}" collides with shortcuts "${d}"`);d&&c?d.unshift(b):this.keyMap.set(a,[b])}removeKeyMapping(a,b,c){var d=this.keyMap.get(a);if(!d)return c||console.warn(`No keyboard shortcut named "${b}" registered with key code "${a}"`),!1;var e=d.indexOf(b);if(e>-1)return d.splice(e,1),d.length===0&&this.keyMap.delete(a),!0;c||console.warn(`No keyboard shortcut named "${b}" registered with key code "${a}"`);
974
975
  return!1}removeAllKeyMappings(a){for(let b of this.keyMap.keys())this.removeKeyMapping(b,a,!0)}setKeyMap(a){this.keyMap.clear();for(let b in a)this.keyMap.set(b,a[b])}getKeyMap(){var a=Object.create(null);for(let [b,c]of this.keyMap)a[b]=c;return a}getRegistry(){var a=Object.create(null);for(let [b,c]of this.shortcuts)a[b]=c;return bb(Object.create(null),a)}onKeyDown(a,b){var c=this.serializeKeyEvent(b);c=this.getShortcutNamesByKeyCode(c);if(!c)return!1;for(let d of c){c=this.shortcuts.get(d);let e;
975
976
  if(!c||c.preconditionFn&&!c.preconditionFn(a,{focusedNode:(e=$.t().getFocusedNode())!=null?e:void 0}))continue;let f,g;if((f=c.callback)==null?0:f.call(c,a,b,c,{focusedNode:(g=$.t().getFocusedNode())!=null?g:void 0}))return!0}return!1}getShortcutNamesByKeyCode(a){var b;return((b=this.keyMap.get(a))==null?void 0:b.slice())||[]}getKeyCodesByShortcutName(a){var b=[];for(let [c,d]of this.keyMap)d.indexOf(a)>-1&&b.push(c);return b}serializeKeyEvent(a){var b="";for(let c in x.modifierKeys)a.getModifierState(c)&&
976
- (b!==""&&(b+="+"),b+=c);b!==""&&a.keyCode?b+="+"+a.keyCode:a.keyCode&&(b=String(a.keyCode));return b}checkModifiers(a){for(let b of a)if(!(b in x.modifierKeys))throw Error(b+" is not a valid modifier key.");}createSerializedKey(a,b){var c="";if(b){this.checkModifiers(b);for(let d in x.modifierKeys)b.includes(x.modifierKeys[d])&&(c!==""&&(c+="+"),c+=d)}c!==""&&a?c+="+"+a:a&&(c=`${a}`);return c}};x.registry=new x;var Sk=x||(x={}),Tk=Sk.modifierKeys||(Sk.modifierKeys={});Tk[Tk.Shift=16]="Shift";
977
- Tk[Tk.Control=17]="Control";Tk[Tk.Alt=18]="Alt";Tk[Tk.Meta=91]="Meta";var cb=new Set,Uk={};Uk.warn=db;var eb=Object.create(null),kb,qb,Vk=[],wb={defineBlocksWithJsonArrayInternal:function(a){$.Ab($.yb(a))}},Wk={TEST_ONLY:wb};Wk.createBlockDefinitionsFromJsonArray=$.yb;Wk.defineBlocks=$.Ab;Wk.defineBlocksWithJsonArray=xb;Wk.draggingConnections=Vk;Wk.fireSelectedEvent=ob;Wk.getAllWorkspaces=gb;Wk.getBlockTypeCounts=ub;Wk.getMainWorkspace=lb;Wk.getParentContainer=rb;Wk.getSelected=nb;Wk.getWorkspaceById=fb;Wk.globalShortcutHandler=Bb;Wk.registerWorkspace=hb;Wk.setMainWorkspace=mb;
978
- Wk.setParentContainer=sb;Wk.setSelected=function(a){$.t().focusNode(a)};Wk.svgResize=tb;Wk.unregisterWorkpace=function(a){db("Blockly.common.unregisterWorkpace","v13","v14","Blockly.common.unregisterWorkspace");ib(a)};Wk.unregisterWorkspace=ib;var Cb=Object.create(null),Xk={typeMap:Cb},Db=Object.create(null),y=class{constructor(a){this.name=a}toString(){return this.name}};y.CONNECTION_CHECKER=new y("connectionChecker");y.CONNECTION_PREVIEWER=new y("connectionPreviewer");y.EVENT=new y("event");y.FIELD=new y("field");y.INPUT=new y("input");y.RENDERER=new y("renderer");y.TOOLBOX=new y("toolbox");y.THEME=new y("theme");y.TOOLBOX_ITEM=new y("toolboxItem");y.FLYOUTS_VERTICAL_TOOLBOX=new y("flyoutsVerticalToolbox");
979
- y.FLYOUTS_HORIZONTAL_TOOLBOX=new y("flyoutsHorizontalToolbox");y.FLYOUT_INFLATER=new y("flyoutInflater");y.METRICS_MANAGER=new y("metricsManager");y.BLOCK_DRAGGER=new y("blockDragger");y.SERIALIZER=new y("serializer");y.ICON=new y("icon");y.PASTER=new y("paster");y.VARIABLE_MODEL=new y("variableModel");y.VARIABLE_MAP=new y("variableMap");var Yk={DEFAULT:"default",TEST_ONLY:Xk};Yk.Type=y;Yk.getAllItems=Ib;Yk.getClass=Hb;Yk.getClassFromOptions=Jb;Yk.getObject=function(a,b,c){return Fb(a,b,c)};
980
- Yk.hasItem=Gb;Yk.register=A;Yk.unregister=Eb;var Mb={genUid:()=>{var a=[];for(let b=0;b<20;b++)a[b]="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.random()*88);return a.join("")}},Kb=0,Zk={TEST_ONLY:Mb};Zk.genUid=Nb;Zk.getNextUniqueId=Lb;var Qb,Ob;$.gd="";$.Qc=!0;$.Ub=0;Qb=[];Ob={FIRE_QUEUE:Qb,enqueueEvent:Sb,fireNow:Rb,fireInternal:function(a){if(Vb()){if(!Qb.length)try{requestAnimationFrame(()=>{setTimeout(Rb,0)})}catch(b){setTimeout(Rb,0)}Sb(a)}},setGroupInternal:function(a){$.gd=typeof a==="boolean"?a?Nb():"":a}};var $k;$.C=Object.create(null);$k={Msg:$.C,setLocale:Xb};var D=class{constructor(a,b){this.x=a;this.y=b}clone(){return new D(this.x,this.y)}scale(a){this.x*=a;this.y*=a;return this}translate(a,b){this.x+=a;this.y+=b;return this}static equals(a,b){return a===b?!0:a&&b?a.x===b.x&&a.y===b.y:!1}static distance(a,b){var c=a.x-b.x;a=a.y-b.y;return Math.sqrt(c*c+a*a)}static magnitude(a){return Math.sqrt(a.x*a.x+a.y*a.y)}static difference(a,b){return new D(a.x-b.x,a.y-b.y)}static sum(a,b){return new D(a.x+b.x,a.y+b.y)}};var cc=class{constructor(a,b,c,d){this.top=a;this.bottom=b;this.left=c;this.right=d}static from(a){return new cc(a.y,a.y+a.height,a.x,a.x+a.width)}clone(){return new cc(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new D(this.left,this.top)}contains(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom}intersects(a){return this.left<=a.right&&this.right>=a.left&&this.bottom>=a.top&&this.top<=
981
- a.bottom}static equals(a,b){return a===b?!0:a&&b?a.top===b.top&&a.bottom===b.bottom&&a.left===b.left&&a.right===b.right:!1}static createFromPoint(a,b,c){var d=a.x;a=a.y;return new cc(a,a+c,d,d+b)}};var hc=class{constructor(a,b){this.width=a;this.height=b}static equals(a,b){return a===b?!0:a&&b?a.width===b.width&&a.height===b.height:!1}static max(a,b){return new hc(Math.max(a.width,b.width),Math.max(a.height,b.height))}static min(a,b){return new hc(Math.min(a.width,b.width),Math.min(a.height,b.height))}};var Yb={getSizeInternal:function(a){if($b(a,"display")!=="none")return new hc(a.offsetWidth,a.offsetHeight);var b=a.style,c=b.display,d=b.visibility,e=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";var f=a.offsetWidth;a=a.offsetHeight;b.display=c;b.position=e;b.visibility=d;return new hc(f,a)}},al={TEST_ONLY:Yb};al.getBorderBox=dc;al.getComputedStyle=$b;al.getContainerOffsetToScrollInto=ec;al.getPageOffset=ac;al.getSize=Zb;al.getViewportPageOffset=bc;
982
- al.scrollIntoContainerView=fc;var ic=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,jc=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,bl={TEST_ONLY:{XY_REGEX:ic,XY_STYLE_REGEX:jc}};bl.getDocumentScroll=nc;bl.getInjectionDivXY=lc;bl.getRelativeXY=kc;bl.getViewportBBox=mc;bl.screenToWsCoordinates=oc;bl.wsToScreenCoordinates=pc;var Ic=class{constructor(a,b,c,d,e){this.workspace=a;this.horizontal=b;this.oldHostMetrics=null;this.ratio=1;this.origin=new D(0,0);this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0;this.containerVisible=this.isHandleVisible=!0;this.position=new D(0,0);this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null;this.pair=c||!1;this.margin=e!==void 0?e:Ic.DEFAULT_SCROLLBAR_MARGIN;a="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical");d&&(a+=" "+
977
+ (b!==""&&(b+="+"),b+=c);b!==""&&a.keyCode?b+="+"+a.keyCode:a.keyCode&&(b=String(a.keyCode));return b}checkModifiers(a){for(let b of a)if(!(b in x.modifierKeys))throw Error(b+" is not a valid modifier key.");}createSerializedKey(a,b){var c="";if(b){this.checkModifiers(b);for(let d in x.modifierKeys)b.includes(x.modifierKeys[d])&&(c!==""&&(c+="+"),c+=d)}c!==""&&a?c+="+"+a:a&&(c=`${a}`);return c}};x.registry=new x;var Tk=x||(x={}),Uk=Tk.modifierKeys||(Tk.modifierKeys={});Uk[Uk.Shift=16]="Shift";
978
+ Uk[Uk.Control=17]="Control";Uk[Uk.Alt=18]="Alt";Uk[Uk.Meta=91]="Meta";var cb=new Set,Vk={};Vk.warn=db;var eb=Object.create(null),kb,qb,Wk=[],wb={defineBlocksWithJsonArrayInternal:function(a){$.Ab($.yb(a))}},Xk={TEST_ONLY:wb};Xk.createBlockDefinitionsFromJsonArray=$.yb;Xk.defineBlocks=$.Ab;Xk.defineBlocksWithJsonArray=xb;Xk.draggingConnections=Wk;Xk.fireSelectedEvent=ob;Xk.getAllWorkspaces=gb;Xk.getBlockTypeCounts=ub;Xk.getMainWorkspace=lb;Xk.getParentContainer=rb;Xk.getSelected=nb;Xk.getWorkspaceById=fb;Xk.globalShortcutHandler=Bb;Xk.registerWorkspace=hb;Xk.setMainWorkspace=mb;
979
+ Xk.setParentContainer=sb;Xk.setSelected=function(a){$.t().focusNode(a)};Xk.svgResize=tb;Xk.unregisterWorkpace=function(a){db("Blockly.common.unregisterWorkpace","v13","v14","Blockly.common.unregisterWorkspace");jb(a)};Xk.unregisterWorkspace=jb;var Cb=Object.create(null),Yk={typeMap:Cb},Db=Object.create(null),y=class{constructor(a){this.name=a}toString(){return this.name}};y.CONNECTION_CHECKER=new y("connectionChecker");y.CONNECTION_PREVIEWER=new y("connectionPreviewer");y.EVENT=new y("event");y.FIELD=new y("field");y.INPUT=new y("input");y.RENDERER=new y("renderer");y.TOOLBOX=new y("toolbox");y.THEME=new y("theme");y.TOOLBOX_ITEM=new y("toolboxItem");y.FLYOUTS_VERTICAL_TOOLBOX=new y("flyoutsVerticalToolbox");
980
+ y.FLYOUTS_HORIZONTAL_TOOLBOX=new y("flyoutsHorizontalToolbox");y.FLYOUT_INFLATER=new y("flyoutInflater");y.METRICS_MANAGER=new y("metricsManager");y.BLOCK_DRAGGER=new y("blockDragger");y.SERIALIZER=new y("serializer");y.ICON=new y("icon");y.PASTER=new y("paster");y.VARIABLE_MODEL=new y("variableModel");y.VARIABLE_MAP=new y("variableMap");var Zk={DEFAULT:"default",TEST_ONLY:Yk};Zk.Type=y;Zk.getAllItems=Ib;Zk.getClass=Hb;Zk.getClassFromOptions=Jb;Zk.getObject=function(a,b,c){return Fb(a,b,c)};
981
+ Zk.hasItem=Gb;Zk.register=A;Zk.unregister=Eb;var Mb={genUid:()=>{var a=[];for(let b=0;b<20;b++)a[b]="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.random()*88);return a.join("")}},Kb=0,$k={TEST_ONLY:Mb};$k.genUid=Nb;$k.getNextUniqueId=Lb;var Qb,Ob;$.gd="";$.Qc=!0;$.Ub=0;Qb=[];Ob={FIRE_QUEUE:Qb,enqueueEvent:Sb,fireNow:Rb,fireInternal:function(a){if(Vb()){if(!Qb.length)try{requestAnimationFrame(()=>{setTimeout(Rb,0)})}catch(b){setTimeout(Rb,0)}Sb(a)}},setGroupInternal:function(a){$.gd=typeof a==="boolean"?a?Nb():"":a}};var al;$.C=Object.create(null);al={Msg:$.C,setLocale:Xb};var D=class{constructor(a,b){this.x=a;this.y=b}clone(){return new D(this.x,this.y)}scale(a){this.x*=a;this.y*=a;return this}translate(a,b){this.x+=a;this.y+=b;return this}static equals(a,b){return a===b?!0:a&&b?a.x===b.x&&a.y===b.y:!1}static distance(a,b){var c=a.x-b.x;a=a.y-b.y;return Math.sqrt(c*c+a*a)}static magnitude(a){return Math.sqrt(a.x*a.x+a.y*a.y)}static difference(a,b){return new D(a.x-b.x,a.y-b.y)}static sum(a,b){return new D(a.x+b.x,a.y+b.y)}};var cc=class{constructor(a,b,c,d){this.top=a;this.bottom=b;this.left=c;this.right=d}static from(a){return new cc(a.y,a.y+a.height,a.x,a.x+a.width)}clone(){return new cc(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new D(this.left,this.top)}contains(a,b){return a>=this.left&&a<=this.right&&b>=this.top&&b<=this.bottom}intersects(a){return this.left<=a.right&&this.right>=a.left&&this.bottom>=a.top&&this.top<=
982
+ a.bottom}static equals(a,b){return a===b?!0:a&&b?a.top===b.top&&a.bottom===b.bottom&&a.left===b.left&&a.right===b.right:!1}static createFromPoint(a,b,c){var d=a.x;a=a.y;return new cc(a,a+c,d,d+b)}};var hc=class{constructor(a,b){this.width=a;this.height=b}static equals(a,b){return a===b?!0:a&&b?a.width===b.width&&a.height===b.height:!1}static max(a,b){return new hc(Math.max(a.width,b.width),Math.max(a.height,b.height))}static min(a,b){return new hc(Math.min(a.width,b.width),Math.min(a.height,b.height))}};var Yb={getSizeInternal:function(a){if($b(a,"display")!=="none")return new hc(a.offsetWidth,a.offsetHeight);var b=a.style,c=b.display,d=b.visibility,e=b.position;b.visibility="hidden";b.position="absolute";b.display="inline";var f=a.offsetWidth;a=a.offsetHeight;b.display=c;b.position=e;b.visibility=d;return new hc(f,a)}},bl={TEST_ONLY:Yb};bl.getBorderBox=dc;bl.getComputedStyle=$b;bl.getContainerOffsetToScrollInto=ec;bl.getPageOffset=ac;bl.getSize=Zb;bl.getViewportPageOffset=bc;
983
+ bl.scrollIntoContainerView=fc;var ic=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,jc=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,cl={TEST_ONLY:{XY_REGEX:ic,XY_STYLE_REGEX:jc}};cl.getDocumentScroll=nc;cl.getInjectionDivXY=lc;cl.getRelativeXY=kc;cl.getViewportBBox=mc;cl.screenToWsCoordinates=oc;cl.wsToScreenCoordinates=pc;var Ic=class{constructor(a,b,c,d,e){this.workspace=a;this.horizontal=b;this.oldHostMetrics=null;this.ratio=1;this.origin=new D(0,0);this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0;this.containerVisible=this.isHandleVisible=!0;this.position=new D(0,0);this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null;this.pair=c||!1;this.margin=e!==void 0?e:Ic.DEFAULT_SCROLLBAR_MARGIN;a="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical");d&&(a+=" "+
983
984
  d);this.outerSvg=r(q.SVG,{"class":a});d=r(q.G,{},this.outerSvg);this.svgBackground=r(q.RECT,{"class":"blocklyScrollbarBackground"},d);a=Math.floor((Ic.scrollbarThickness-5)/2);this.svgHandle=r(q.RECT,{"class":"blocklyScrollbarHandle",rx:a,ry:a},d);this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill");this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity");Pa(this.outerSvg,this.workspace.getParentSvg());this.setInitialThickness();b?
984
985
  (this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y");this.onMouseDownBarWrapper_=k(this.svgBackground,"pointerdown",this,this.onMouseDownBar);this.onMouseDownHandleWrapper_=k(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){var a=Ic.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(a)),this.outerSvg.setAttribute("height",String(a)),this.svgHandle.setAttribute("height",
985
986
  String(a-5)),this.svgHandle.setAttribute("y","2.5")):(this.svgBackground.setAttribute("width",String(a)),this.outerSvg.setAttribute("width",String(a)),this.svgHandle.setAttribute("width",String(a-5)),this.svgHandle.setAttribute("x","2.5"))}dispose(){this.cleanUp();ka(this.onMouseDownBarWrapper_);ka(this.onMouseDownHandleWrapper_);Oa(this.outerSvg);this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(a){return a=a<=0||isNaN(a)?0:Math.min(a,this.scrollbarLength)}setHandleLength(a){this.handleLength=
@@ -993,17 +994,17 @@ a;b&&this.updateDisplay_()}setVisible(a){if(this.pair)throw Error("Unable to tog
993
994
  oa(a,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());b=this.horizontal?b.x:b.y;var c=lc(this.svgHandle);c=this.horizontal?c.x:c.y;var d=this.handlePosition,e=this.handleLength*.95;b<=c?d-=e:b>=c+this.handleLength&&(d+=e);this.setHandlePosition(this.constrainHandlePosition(d));this.updateMetrics();a.stopPropagation();a.preventDefault()}}onMouseDownHandle(a){this.workspace.markFocused();this.cleanUp();na(a)?a.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=
994
995
  this.horizontal?a.clientX:a.clientY,this.onMouseUpWrapper_=k(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=k(document,"pointermove",this,this.onMouseMoveHandle),a.stopPropagation(),a.preventDefault())}onMouseMoveHandle(a){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?a.clientX:a.clientY)-this.startDragMouse)));this.updateMetrics()}onMouseUpHandle(){ha=null;this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0);this.onMouseUpWrapper_&&
995
996
  (ka(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null);this.onMouseMoveWrapper_&&(ka(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){var a=this.handlePosition/(this.scrollbarLength-this.handleLength);isNaN(a)&&(a=0);return a}updateMetrics(){var a=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:a}):this.workspace.setMetrics({y:a})}set(a,b){this.setHandlePosition(this.constrainHandlePosition(a*this.ratio));(b||b===void 0)&&this.updateMetrics()}setOrigin(a,b){this.origin=
996
- new D(a,b)}static metricsAreEquivalent(a,b){return a.viewWidth===b.viewWidth&&a.viewHeight===b.viewHeight&&a.viewLeft===b.viewLeft&&a.viewTop===b.viewTop&&a.absoluteTop===b.absoluteTop&&a.absoluteLeft===b.absoluteLeft&&a.scrollWidth===b.scrollWidth&&a.scrollHeight===b.scrollHeight&&a.scrollLeft===b.scrollLeft&&a.scrollTop===b.scrollTop}};Ic.scrollbarThickness=kk?25:15;Ic.DEFAULT_SCROLLBAR_MARGIN=.5;var tc={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies");}},wc={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies");}},{document:qc,DOMParser:cl,XMLSerializer:dl}=globalThis;cl&&(tc=new cl);dl&&(wc=new dl);var yc=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,el={NAME_SPACE:"https://developers.google.com/blockly/xml"};
997
- el.createElement=$.rc;el.createTextNode=$.sc;el.domToText=xc;el.injectDependencies=function(a){({document:qc=qc,DOMParser:cl=cl,XMLSerializer:dl=dl}=a);tc=new cl;wc=new dl};el.textToDom=$.uc;var F,fl=F||(F={});fl[fl.TOP=0]="TOP";fl[fl.BOTTOM=1]="BOTTOM";fl[fl.LEFT=2]="LEFT";fl[fl.RIGHT=3]="RIGHT";var Ec={hasCategoriesInternal:function(a){if(!a)return!1;var b=a.kind;return b?b==="categoryToolbox":!!a.contents.filter(c=>c.kind.toUpperCase()==="CATEGORY").length}},gl={};gl.Position=F;gl.TEST_ONLY=Ec;gl.convertFlyoutDefToJsonArray=Dc;gl.convertToolboxDefToJson=Cc;gl.hasCategories=Fc;gl.isCategoryCollapsible=Gc;gl.parseToolboxTree=zc;var Jc,hl=Jc||(Jc={});hl[hl.TOP=0]="TOP";hl[hl.BOTTOM=1]="BOTTOM";var Hc,il=Hc||(Hc={});il[il.LEFT=0]="LEFT";il[il.RIGHT=1]="RIGHT";var Mc,jl=Mc||(Mc={});jl[jl.UP=0]="UP";jl[jl.DOWN=1]="DOWN";var kl={};kl.bumpDirection=Mc;kl.bumpPositionRect=Nc;kl.getCornerOppositeToolbox=Lc;kl.getStartPositionRect=Kc;kl.horizontalPosition=Hc;kl.verticalPosition=Jc;var ll={width:96,height:124,url:"sprites.svg"};var ml=class{constructor(a,b){this.workspace=a;this.group=b;this.pointerDownHandler=k(b,"pointerdown",null,this.performAction.bind(this));ya(b,Ka.BUTTON);this.id=Lb();this.group.id=this.id}zoom(a,b){this.workspace.markFocused();this.workspace.zoomCenter(a);this.fireZoomEvent();ha=null;b.stopPropagation();b.preventDefault()}fireZoomEvent(){var a=new (u(v.CLICK))(null,this.workspace.id,"zoom_controls");w(a)}getFocusableElement(){return this.group}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}dispose(){ka(this.pointerDownHandler)}},
998
- nl=class extends ml{constructor(a,b){var c=String(Math.random()).substring(2);b=r(q.G,{"class":"blocklyZoom blocklyZoomIn",tabindex:"0"},b);l(b,p.LABEL,$.C.ZOOM_IN);r(q.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=r(q.CLIPPATH,{id:"blocklyZoominClipPath"+c},b);r(q.RECT,{width:32,height:32},d);r(q.IMAGE,{width:ll.width,height:ll.height,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",
999
- a.options.pathToMedia+ll.url);super(a,b)}performAction(a){this.zoom(1,a)}},ol=class extends ml{constructor(a,b){var c=String(Math.random()).substring(2);b=r(q.G,{"class":"blocklyZoom blocklyZoomOut",tabindex:"0"},b);l(b,p.LABEL,$.C.ZOOM_OUT);r(q.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=r(q.CLIPPATH,{id:"blocklyZoomoutClipPath"+c},b);r(q.RECT,{width:32,height:32},d);r(q.IMAGE,{width:ll.width,height:ll.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+
1000
- c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+ll.url);super(a,b)}performAction(a){this.zoom(-1,a)}},pl=class extends ml{constructor(a,b){var c=String(Math.random()).substring(2);b=r(q.G,{"class":"blocklyZoom blocklyZoomReset",tabindex:"0"},b);l(b,p.LABEL,$.C.RESET_ZOOM);r(q.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=r(q.CLIPPATH,{id:"blocklyZoomresetClipPath"+c},b);r(q.RECT,{width:32,height:32},d);r(q.IMAGE,
1001
- {width:ll.width,height:ll.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+ll.url);super(a,b)}performAction(a){this.workspace.markFocused();var b=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition();this.workspace.zoomCenter(b);this.workspace.scrollCenter();setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),
1002
- 500);this.fireZoomEvent();ha=null;a.stopPropagation();a.preventDefault()}},ql=class{constructor(a){this.workspace=a;this.id="zoomControls";this.zoomResetControl=this.zoomOutControl=this.zoomInControl=null;this.HEIGHT=this.WIDTH=32;this.SMALL_SPACING=2;this.LARGE_SPACING=11;this.MARGIN_HORIZONTAL=this.MARGIN_VERTICAL=20;this.svgGroup=null;this.top=this.left=0;this.initialized=!1}createDom(){this.svgGroup=r(q.G,{});this.zoomOutControl=new ol(this.workspace,this.svgGroup);this.zoomInControl=new nl(this.workspace,
1003
- this.svgGroup);this.workspace.isMovable()&&(this.zoomResetControl=new pl(this.workspace,this.svgGroup));for(let a of[this.zoomOutControl,this.zoomInControl,this.zoomResetControl])a&&this.workspace.getComponentManager().addComponent({component:a,weight:Dk.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Dk.Capability.FOCUSABLE]});return this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:Dk.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Dk.Capability.POSITIONABLE]});
997
+ new D(a,b)}static metricsAreEquivalent(a,b){return a.viewWidth===b.viewWidth&&a.viewHeight===b.viewHeight&&a.viewLeft===b.viewLeft&&a.viewTop===b.viewTop&&a.absoluteTop===b.absoluteTop&&a.absoluteLeft===b.absoluteLeft&&a.scrollWidth===b.scrollWidth&&a.scrollHeight===b.scrollHeight&&a.scrollLeft===b.scrollLeft&&a.scrollTop===b.scrollTop}};Ic.scrollbarThickness=lk?25:15;Ic.DEFAULT_SCROLLBAR_MARGIN=.5;var tc={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies");}},wc={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies");}},{document:qc,DOMParser:dl,XMLSerializer:el}=globalThis;dl&&(tc=new dl);el&&(wc=new el);var yc=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,fl={NAME_SPACE:"https://developers.google.com/blockly/xml"};
998
+ fl.createElement=$.rc;fl.createTextNode=$.sc;fl.domToText=xc;fl.injectDependencies=function(a){({document:qc=qc,DOMParser:dl=dl,XMLSerializer:el=el}=a);tc=new dl;wc=new el};fl.textToDom=$.uc;var F,gl=F||(F={});gl[gl.TOP=0]="TOP";gl[gl.BOTTOM=1]="BOTTOM";gl[gl.LEFT=2]="LEFT";gl[gl.RIGHT=3]="RIGHT";var Ec={hasCategoriesInternal:function(a){if(!a)return!1;var b=a.kind;return b?b==="categoryToolbox":!!a.contents.filter(c=>c.kind.toUpperCase()==="CATEGORY").length}},hl={};hl.Position=F;hl.TEST_ONLY=Ec;hl.convertFlyoutDefToJsonArray=Dc;hl.convertToolboxDefToJson=Cc;hl.hasCategories=Fc;hl.isCategoryCollapsible=Gc;hl.parseToolboxTree=zc;var Jc,il=Jc||(Jc={});il[il.TOP=0]="TOP";il[il.BOTTOM=1]="BOTTOM";var Hc,jl=Hc||(Hc={});jl[jl.LEFT=0]="LEFT";jl[jl.RIGHT=1]="RIGHT";var Mc,kl=Mc||(Mc={});kl[kl.UP=0]="UP";kl[kl.DOWN=1]="DOWN";var ll={};ll.bumpDirection=Mc;ll.bumpPositionRect=Nc;ll.getCornerOppositeToolbox=Lc;ll.getStartPositionRect=Kc;ll.horizontalPosition=Hc;ll.verticalPosition=Jc;var ml={width:96,height:124,url:"sprites.svg"};var nl=class{constructor(a,b){this.workspace=a;this.group=b;this.pointerDownHandler=k(b,"pointerdown",null,this.performAction.bind(this));ya(b,Ka.BUTTON);this.id=Lb();this.group.id=this.id}zoom(a,b){this.workspace.markFocused();this.workspace.zoomCenter(a);this.fireZoomEvent();ha=null;b.stopPropagation();b.preventDefault()}fireZoomEvent(){var a=new (u(v.CLICK))(null,this.workspace.id,"zoom_controls");w(a)}getFocusableElement(){return this.group}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}dispose(){ka(this.pointerDownHandler)}},
999
+ ol=class extends nl{constructor(a,b){var c=String(Math.random()).substring(2);b=r(q.G,{"class":"blocklyZoom blocklyZoomIn",tabindex:"0"},b);l(b,p.LABEL,$.C.ZOOM_IN);r(q.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=r(q.CLIPPATH,{id:"blocklyZoominClipPath"+c},b);r(q.RECT,{width:32,height:32},d);r(q.IMAGE,{width:ml.width,height:ml.height,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",
1000
+ a.options.pathToMedia+ml.url);super(a,b)}performAction(a){this.zoom(1,a)}},pl=class extends nl{constructor(a,b){var c=String(Math.random()).substring(2);b=r(q.G,{"class":"blocklyZoom blocklyZoomOut",tabindex:"0"},b);l(b,p.LABEL,$.C.ZOOM_OUT);r(q.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=r(q.CLIPPATH,{id:"blocklyZoomoutClipPath"+c},b);r(q.RECT,{width:32,height:32},d);r(q.IMAGE,{width:ml.width,height:ml.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+
1001
+ c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+ml.url);super(a,b)}performAction(a){this.zoom(-1,a)}},ql=class extends nl{constructor(a,b){var c=String(Math.random()).substring(2);b=r(q.G,{"class":"blocklyZoom blocklyZoomReset",tabindex:"0"},b);l(b,p.LABEL,$.C.RESET_ZOOM);r(q.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=r(q.CLIPPATH,{id:"blocklyZoomresetClipPath"+c},b);r(q.RECT,{width:32,height:32},d);r(q.IMAGE,
1002
+ {width:ml.width,height:ml.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+ml.url);super(a,b)}performAction(a){this.workspace.markFocused();var b=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition();this.workspace.zoomCenter(b);this.workspace.scrollCenter();setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),
1003
+ 500);this.fireZoomEvent();ha=null;a.stopPropagation();a.preventDefault()}},rl=class{constructor(a){this.workspace=a;this.id="zoomControls";this.zoomResetControl=this.zoomOutControl=this.zoomInControl=null;this.HEIGHT=this.WIDTH=32;this.SMALL_SPACING=2;this.LARGE_SPACING=11;this.MARGIN_HORIZONTAL=this.MARGIN_VERTICAL=20;this.svgGroup=null;this.top=this.left=0;this.initialized=!1}createDom(){this.svgGroup=r(q.G,{});this.zoomOutControl=new pl(this.workspace,this.svgGroup);this.zoomInControl=new ol(this.workspace,
1004
+ this.svgGroup);this.workspace.isMovable()&&(this.zoomResetControl=new ql(this.workspace,this.svgGroup));for(let a of[this.zoomOutControl,this.zoomInControl,this.zoomResetControl])a&&this.workspace.getComponentManager().addComponent({component:a,weight:Ek.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Ek.Capability.FOCUSABLE]});return this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:Ek.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[Ek.Capability.POSITIONABLE]});
1004
1005
  this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls");this.svgGroup&&Oa(this.svgGroup);var a;(a=this.zoomInControl)==null||a.dispose();var b;(b=this.zoomOutControl)==null||b.dispose();var c;(c=this.zoomResetControl)==null||c.dispose()}getBoundingRectangle(){var a=this.SMALL_SPACING+2*this.HEIGHT;this.zoomResetControl&&(a+=this.LARGE_SPACING+this.HEIGHT);return new cc(this.top,this.top+a,this.left,this.left+this.WIDTH)}position(a,b){if(this.initialized){var c=
1005
1006
  Lc(this.workspace,a),d=this.SMALL_SPACING+2*this.HEIGHT;this.zoomResetControl&&(d+=this.LARGE_SPACING+this.HEIGHT);a=Kc(c,new hc(this.WIDTH,d),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,a,this.workspace);c=c.vertical;b=Nc(a,this.MARGIN_VERTICAL,c===Jc.TOP?Mc.DOWN:Mc.UP,b);if(c===Jc.TOP){var e=this.SMALL_SPACING+this.HEIGHT,f;(f=this.zoomInControl)==null||f.getFocusableElement().setAttribute("transform","translate(0, "+e+")");this.zoomResetControl&&(e=e+this.LARGE_SPACING+this.HEIGHT,this.zoomResetControl.getFocusableElement().setAttribute("transform",
1006
- "translate(0, "+e+")"))}else{f=this.zoomResetControl?this.LARGE_SPACING+this.HEIGHT:0;let h;(h=this.zoomInControl)==null||h.getFocusableElement().setAttribute("transform","translate(0, "+f+")");f=f+this.SMALL_SPACING+this.HEIGHT;(e=this.zoomOutControl)==null||e.getFocusableElement().setAttribute("transform","translate(0, "+f+")")}this.top=b.top;this.left=b.left;var g;(g=this.svgGroup)==null||g.setAttribute("transform","translate("+this.left+","+this.top+")")}}};ta("\n.blocklyZoom>image, .blocklyZoom>svg>image {\n opacity: .4;\n}\n\n.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover, .blocklyZoom:focus>image {\n opacity: .8;\n}\n\n.blocklyZoom>image:active, .blocklyZoom>svg>image:active {\n opacity: 1;\n}\n");var rl={};rl.register=Oc;rl.unregister=function(a){Eb(y.SERIALIZER,a)};var sl=class{constructor(){this.priority=25}save(a){var b=[];for(let c of a.getTopComments())(a=Pc(c,{addCoordinates:!0,saveIds:!0}))&&b.push(a);return b.length?b:null}load(a,b){for(let c of a)Rc(c,b,{recordUndo:$.Qc})}clear(a){for(let b of a.getTopComments())b.dispose()}};Oc("workspaceComments",new sl);var tl={};tl.WorkspaceCommentSerializer=sl;tl.append=Rc;tl.save=Pc;var ul={};ul.register=Sc;ul.unregister=function(a){Eb(y.PASTER,a)};var vl=class{paste(a,b,c){a=a.commentState;c&&(a.x=c.x,a.y=c.y);$.Ub++;try{var d=Rc(a,b);Uc(d)}finally{$.Ub--}if(!d)return null;Vb()&&w(new (u(v.COMMENT_CREATE))(d));$.t().focusNode(d);return d}};vl.TYPE="workspace-comment";Sc(vl.TYPE,new vl);$.Og={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250};var Kg=class{constructor(a,b,c){this.content=a;this.opt_value=b;this.ariaLabel=c;this.enabled=!0;this.element=null;this.rightToLeft=!1;this.roleName=null;this.highlight=this.checked=this.checkable=!1;this.actionHandler=null;this.id=Lb()}createDom(){var a=document.createElement("div");a.id=this.getId();this.element=a;a.className="blocklyMenuItem "+(this.enabled?"":"blocklyMenuItemDisabled ")+(this.checked?"blocklyMenuItemSelected ":"")+(this.highlight?"blocklyMenuItemHighlight ":"")+(this.rightToLeft?
1007
+ "translate(0, "+e+")"))}else{f=this.zoomResetControl?this.LARGE_SPACING+this.HEIGHT:0;let h;(h=this.zoomInControl)==null||h.getFocusableElement().setAttribute("transform","translate(0, "+f+")");f=f+this.SMALL_SPACING+this.HEIGHT;(e=this.zoomOutControl)==null||e.getFocusableElement().setAttribute("transform","translate(0, "+f+")")}this.top=b.top;this.left=b.left;var g;(g=this.svgGroup)==null||g.setAttribute("transform","translate("+this.left+","+this.top+")")}}};ta("\n.blocklyZoom>image, .blocklyZoom>svg>image {\n opacity: .4;\n}\n\n.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover, .blocklyZoom:focus>image {\n opacity: .8;\n}\n\n.blocklyZoom>image:active, .blocklyZoom>svg>image:active {\n opacity: 1;\n}\n");var sl={};sl.register=Oc;sl.unregister=function(a){Eb(y.SERIALIZER,a)};var tl=class{constructor(){this.priority=25}save(a){var b=[];for(let c of a.getTopComments())(a=Pc(c,{addCoordinates:!0,saveIds:!0}))&&b.push(a);return b.length?b:null}load(a,b){for(let c of a)Rc(c,b,{recordUndo:$.Qc})}clear(a){for(let b of a.getTopComments())b.dispose()}};Oc("workspaceComments",new tl);var ul={};ul.WorkspaceCommentSerializer=tl;ul.append=Rc;ul.save=Pc;var vl={};vl.register=Sc;vl.unregister=function(a){Eb(y.PASTER,a)};var wl=class{paste(a,b,c){a=a.commentState;c&&(a.x=c.x,a.y=c.y);$.Ub++;try{var d=Rc(a,b);Uc(d)}finally{$.Ub--}if(!d)return null;Vb()&&w(new (u(v.COMMENT_CREATE))(d));$.t().focusNode(d);return d}};wl.TYPE="workspace-comment";Sc(wl.TYPE,new wl);$.Og={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250};var Kg=class{constructor(a,b,c){this.content=a;this.opt_value=b;this.ariaLabel=c;this.enabled=!0;this.element=null;this.rightToLeft=!1;this.roleName=null;this.highlight=this.checked=this.checkable=!1;this.actionHandler=null;this.id=Lb()}createDom(){var a=document.createElement("div");a.id=this.getId();this.element=a;a.className="blocklyMenuItem "+(this.enabled?"":"blocklyMenuItemDisabled ")+(this.checked?"blocklyMenuItemSelected ":"")+(this.highlight?"blocklyMenuItemHighlight ":"")+(this.rightToLeft?
1007
1008
  "blocklyMenuItemRtl ":"");var b=document.createElement("div");l(a,p.LABEL,this.getAriaLabel());ya(b,Ka.NONE);b.className="blocklyMenuItemContent";var c=this.content;typeof this.content==="string"&&(c=document.createTextNode(this.content));b.appendChild(c);a.appendChild(b);this.checkable&&this.toggleHasCheckbox(!0);this.roleName&&ya(a,this.roleName);l(a,p.SELECTED,this.checkable&&this.checked||!1);l(a,p.DISABLED,!this.enabled);return a}getAriaLabel(){return this.ariaLabel||(typeof this.content==="string"?
1008
1009
  this.content:this.content.textContent)}dispose(){this.element=null}getElement(){return this.element}getId(){return this.id}getValue(){var a;return(a=this.opt_value)!=null?a:null}setRightToLeft(a){this.rightToLeft=a;var b;(b=this.getElement())==null||b.classList.toggle("blocklyMenuItemRtl",this.rightToLeft)}setRole(a){this.roleName=a}setCheckable(a){(this.checkable=a)||this.setChecked(!1);this.toggleHasCheckbox(a)}setChecked(a){if(!a||this.checkable)if(this.checked=a,a=this.getElement())a.classList.toggle("blocklyMenuItemSelected",
1009
1010
  this.checked),l(a,p.SELECTED,this.checked)}setHighlighted(a){this.highlight=a;if(this.isEnabled()){let b;(b=this.getElement())==null||b.classList.toggle("blocklyMenuItemHighlight",this.highlight)}}isEnabled(){return this.enabled}setEnabled(a){this.enabled=a;if(a=this.getElement())a.classList.toggle("blocklyMenuItemDisabled",!this.enabled),l(a,p.DISABLED,!this.enabled)}performAction(a){this.isEnabled()&&this.actionHandler&&this.actionHandler(this,a)}onAction(a,b){this.actionHandler=a.bind(b)}toggleHasCheckbox(a){if(a){let d;
@@ -1013,59 +1014,59 @@ a}dispose(){this.pointerMoveHandler&&(ka(this.pointerMoveHandler),this.pointerMo
1013
1014
  this.getElement();a&&a!==b;){if(a.classList.contains("blocklyMenuItem")){let c=this.getMenuItems();for(let d=0,e;e=c[d];d++)if(e.getElement()===a)return e}a=a.parentElement}return null}setHighlighted(a){var b=this.highlightedItem;b&&(b.setHighlighted(!1),this.highlightedItem=null);if(a){a.setHighlighted(!0);this.highlightedItem=a;b=this.getElement();let c=a.getElement();b&&c&&(fc(c,b),l(b,p.ACTIVEDESCENDANT,a.getId()))}}highlightNext(){var a=this.highlightedItem?this.getMenuItems().indexOf(this.highlightedItem):
1014
1015
  -1;this.highlightHelper(a,1)}highlightPrevious(){var a=this.highlightedItem?this.getMenuItems().indexOf(this.highlightedItem):-1;this.highlightHelper(a<0?this.menuItems.length:a,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(a,b){a+=b;for(var c,d=this.getMenuItems();c=d[a];){if(c.isEnabled()){this.setHighlighted(c);break}a+=b}}handlePointerMove(a){Math.max(Math.abs(a.movementX),Math.abs(a.movementY))!==0&&(a=this.getMenuItem(a.target))&&
1015
1016
  (a.isEnabled()?this.highlightedItem!==a&&this.setHighlighted(a):this.setHighlighted(null))}handleClick(a){var b=this.openingCoords;this.openingCoords=null;if(b&&typeof a.clientX==="number"){let c=new D(a.clientX,a.clientY);if(D.distance(b,c)<1)return}(b=this.getMenuItem(a.target))&&b.performAction(a)}handlePointerEnter(){this.focus()}handlePointerLeave(){this.getElement()&&this.setHighlighted(null)}handleKeyEvent(a){if(this.menuItems.length&&!(a.shiftKey||a.ctrlKey||a.metaKey||a.altKey)){var b=this.highlightedItem;
1016
- switch(a.key){case "Enter":case " ":b&&b.performAction(a);break;case "ArrowUp":this.highlightPrevious();break;case "ArrowDown":this.highlightNext();break;case "PageUp":case "Home":this.highlightFirst();break;case "PageDown":case "End":this.highlightLast();break;default:return}a.preventDefault();a.stopPropagation()}}getSize(){var a=this.getElement(),b=Zb(a);b.height=a.scrollHeight;return b}getMenuItems(){return this.menuItems.filter(a=>a instanceof Kg)}getId(){return this.id}};var Jg=class{constructor(){this.element=null}createDom(){this.element=document.createElement("hr");this.element.className="blocklyMenuSeparator";ya(this.element,Ka.SEPARATOR);return this.element}dispose(){var a;(a=this.element)==null||a.remove();this.element=null}};var wl;wl=$.je||($.je={});wl[wl.VALUE=1]="VALUE";wl[wl.STATEMENT=3]="STATEMENT";wl[wl.DUMMY=5]="DUMMY";wl[wl.CUSTOM=6]="CUSTOM";wl[wl.END_ROW=7]="END_ROW";var hd=new Set,ed=new WeakSet,fd=new WeakMap,Zc=null,$c=null,ad=0,xl={};xl.finishQueuedRenders=cd;xl.queueRender=bd;xl.triggerQueuedRenders=dd;var li=class{static show(a,b){if(b.oncePerSession&&b.id){if(this.shownIds.has(b.id))return;this.shownIds.add(b.id)}this.hide(a);var c=this.createDom(a,b);requestAnimationFrame(()=>{c.style.bottom="2rem"})}static createDom(a,b){var {message:c,duration:d=5,assertiveness:e=Ca.POLITE}=b,f=document.createElement("div");a.getInjectionDiv().appendChild(f);f.dataset.toastId=b.id;f.className="blocklyToast";b=f.appendChild(document.createElement("div"));b.className="blocklyToastMessage";b.innerText=c;b=f.appendChild(document.createElement("button"));
1017
- b.className="blocklyToastCloseButton";l(b,p.LABEL,$.C.CLOSE);var g=r(q.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},b);l(g,p.HIDDEN,!0);r(q.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},g);r(q.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:"rotate(-45, 2.80762, 4.22183)",fill:"black"},g);b.addEventListener("click",()=>{f.remove();a.markFocused()});var h;b=()=>{h=setTimeout(()=>f.remove(),d*1E3)};g=()=>clearTimeout(h);f.addEventListener("focusin",
1018
- g);f.addEventListener("focusout",b);f.addEventListener("mouseenter",g);f.addEventListener("mousemove",g);f.addEventListener("mouseleave",b);b();Ja(c,{assertiveness:e,role:Ka.STATUS});return f}static hide(a,b){a=a.getInjectionDiv().querySelector(".blocklyToast");a instanceof HTMLElement&&(!b||b===a.dataset.toastId)&&a.remove()}};li.shownIds=new Set;ta("\n.blocklyToast {\n font-size: 1.2rem;\n position: absolute;\n bottom: -10rem;\n right: 2rem;\n padding: 1rem;\n color: black;\n background-color: white;\n border: 2px solid black;\n border-radius: 0.4rem;\n z-index: 999;\n display: flex;\n align-items: center;\n gap: 0.8rem;\n line-height: 1.5;\n transition: bottom 0.3s ease-out;\n}\n\n.blocklyToast .blocklyToastMessage {\n maxWidth: 18rem;\n}\n\n.blocklyToast .blocklyToastCloseButton {\n margin: 0;\n padding: 0.2rem;\n background-color: transparent;\n color: black;\n border: none;\n cursor: pointer;\n}\n");var md,yl=md||(md={});yl[yl.ALERT=1]="ALERT";yl[yl.CONFIRM=2]="CONFIRM";yl[yl.PROMPT=3]="PROMPT";var wd=0,qd=nd,sd=od,ud=pd,zl=li.show.bind(li),Al=zl,Bl={};Bl.alert=rd;Bl.confirm=td;Bl.prompt=vd;Bl.setAlert=function(a=nd){qd=a};Bl.setConfirm=function(a=od){sd=a};Bl.setPrompt=function(a=pd){ud=a};Bl.setToast=function(a=zl){Al=a};Bl.toast=function(a,b){Al(a,b)};var Cl=class{constructor(){this.workspaceId=void 0;this.isUiEvent=!1;this.type="";this.group=$.gd;this.recordUndo=$.Qc}toJson(){return{type:this.type,group:this.group}}static fromJson(a,b,c){c.isBlank=!1;c.group=a.group||"";c.workspaceId=b.id;return c}isNull(){return!1}run(){}getEventWorkspace_(){var a;this.workspaceId&&(a=fb(this.workspaceId));if(!a)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return a}};var Dl=class extends Cl{constructor(a){super();this.isBlank=!0;this.isBlank=!a;a&&(this.blockId=a.id,this.workspaceId=a.workspace.id)}toJson(){var a=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");a.blockId=this.blockId;return a}static fromJson(a,b,c){b=Cl.fromJson(a,b,c!=null?c:new Dl);b.blockId=a.blockId;return b}};var Zg=class{constructor(a){this.name=a}toString(){return this.name}equals(a){return this.name===a.toString()}};Zg.MUTATOR=new Zg("mutator");Zg.WARNING=new Zg("warning");Zg.COMMENT=new Zg("comment");var El=class extends Dl{constructor(a,b,c,d,e){super(a);this.type=v.BLOCK_CHANGE;a&&(this.element=b,this.name=c||void 0,this.oldValue=d,this.newValue=e)}toJson(){var a=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");a.element=this.element;a.name=this.name;a.oldValue=this.oldValue;a.newValue=this.newValue;this.disabledReason&&(a.disabledReason=this.disabledReason);return a}static fromJson(a,b,c){b=Dl.fromJson(a,
1019
- b,c!=null?c:new El);b.element=a.element;b.name=a.name;b.oldValue=a.oldValue;b.newValue=a.newValue;a.disabledReason!==void 0&&(b.disabledReason=a.disabledReason);return b}setDisabledReason(a){if(this.element!=="disabled")throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=a}isNull(){return this.oldValue===this.newValue}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");
1017
+ switch(a.key){case "Enter":case " ":b&&b.performAction(a);break;case "ArrowUp":this.highlightPrevious();break;case "ArrowDown":this.highlightNext();break;case "PageUp":case "Home":this.highlightFirst();break;case "PageDown":case "End":this.highlightLast();break;default:return}a.preventDefault();a.stopPropagation()}}getSize(){var a=this.getElement(),b=Zb(a);b.height=a.scrollHeight;return b}getMenuItems(){return this.menuItems.filter(a=>a instanceof Kg)}getId(){return this.id}};var Jg=class{constructor(){this.element=null}createDom(){this.element=document.createElement("hr");this.element.className="blocklyMenuSeparator";ya(this.element,Ka.SEPARATOR);return this.element}dispose(){var a;(a=this.element)==null||a.remove();this.element=null}};var xl;xl=$.je||($.je={});xl[xl.VALUE=1]="VALUE";xl[xl.STATEMENT=3]="STATEMENT";xl[xl.DUMMY=5]="DUMMY";xl[xl.CUSTOM=6]="CUSTOM";xl[xl.END_ROW=7]="END_ROW";var hd=new Set,ed=new WeakSet,fd=new WeakMap,Zc=null,$c=null,ad=0,yl={};yl.finishQueuedRenders=cd;yl.queueRender=bd;yl.triggerQueuedRenders=dd;var li=class{static show(a,b){if(b.oncePerSession&&b.id){if(this.shownIds.has(b.id))return;this.shownIds.add(b.id)}this.hide(a);var c=this.createDom(a,b);requestAnimationFrame(()=>{c.style.bottom="2rem"})}static createDom(a,b){var {message:c,duration:d=5,assertiveness:e=Ca.POLITE}=b,f=document.createElement("div");a.getInjectionDiv().appendChild(f);f.dataset.toastId=b.id;f.className="blocklyToast";b=f.appendChild(document.createElement("div"));b.className="blocklyToastMessage";b.innerText=c;b=f.appendChild(document.createElement("button"));
1018
+ b.className="blocklyToastCloseButton";l(b,p.LABEL,$.C.CLOSE);var g=r(q.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},b);l(g,p.HIDDEN,!0);r(q.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},g);r(q.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:"rotate(-45, 2.80762, 4.22183)",fill:"black"},g);b.addEventListener("click",()=>{var m=$.t(),z=m.getPreviouslyFocusedNode();f.remove();(z==null?0:z.canBeFocused())?m.focusNode(z):m.focusTree(a)});
1019
+ var h;b=()=>{h=setTimeout(()=>f.remove(),d*1E3)};g=()=>clearTimeout(h);f.addEventListener("focusin",g);f.addEventListener("focusout",b);f.addEventListener("mouseenter",g);f.addEventListener("mousemove",g);f.addEventListener("mouseleave",b);b();Ja(c,{assertiveness:e,role:Ka.STATUS});return f}static hide(a,b){a=a.getInjectionDiv().querySelector(".blocklyToast");a instanceof HTMLElement&&(!b||b===a.dataset.toastId)&&a.remove()}};li.shownIds=new Set;ta("\n.blocklyToast {\n font-size: 1.2rem;\n position: absolute;\n bottom: -10rem;\n right: 2rem;\n padding: 1rem;\n color: black;\n background-color: white;\n border: 2px solid black;\n border-radius: 0.4rem;\n z-index: 999;\n display: flex;\n align-items: center;\n gap: 0.8rem;\n line-height: 1.5;\n transition: bottom 0.3s ease-out;\n}\n\n.blocklyToast .blocklyToastMessage {\n max-width: 18rem;\n}\n\n.blocklyToast .blocklyToastCloseButton {\n margin: 0;\n padding: 0.2rem;\n background-color: transparent;\n color: black;\n border: none;\n cursor: pointer;\n}\n");var md,zl=md||(md={});zl[zl.ALERT=1]="ALERT";zl[zl.CONFIRM=2]="CONFIRM";zl[zl.PROMPT=3]="PROMPT";var wd=0,qd=nd,sd=od,ud=pd,Al=li.show.bind(li),Bl=Al,Cl={};Cl.alert=rd;Cl.confirm=td;Cl.prompt=vd;Cl.setAlert=function(a=nd){qd=a};Cl.setConfirm=function(a=od){sd=a};Cl.setPrompt=function(a=pd){ud=a};Cl.setToast=function(a=Al){Bl=a};Cl.toast=function(a,b){Bl(a,b)};var Dl=class{constructor(){this.workspaceId=void 0;this.isUiEvent=!1;this.type="";this.group=$.gd;this.recordUndo=$.Qc}toJson(){return{type:this.type,group:this.group}}static fromJson(a,b,c){c.isBlank=!1;c.group=a.group||"";c.workspaceId=b.id;return c}isNull(){return!1}run(){}getEventWorkspace_(){var a;this.workspaceId&&(a=fb(this.workspaceId));if(!a)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return a}};var El=class extends Dl{constructor(a){super();this.isBlank=!0;this.isBlank=!a;a&&(this.blockId=a.id,this.workspaceId=a.workspace.id)}toJson(){var a=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");a.blockId=this.blockId;return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new El);b.blockId=a.blockId;return b}};var Zg=class{constructor(a){this.name=a}toString(){return this.name}equals(a){return this.name===a.toString()}};Zg.MUTATOR=new Zg("mutator");Zg.WARNING=new Zg("warning");Zg.COMMENT=new Zg("comment");var Fl=class extends El{constructor(a,b,c,d,e){super(a);this.type=v.BLOCK_CHANGE;a&&(this.element=b,this.name=c||void 0,this.oldValue=d,this.newValue=e)}toJson(){var a=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");a.element=this.element;a.name=this.name;a.oldValue=this.oldValue;a.newValue=this.newValue;this.disabledReason&&(a.disabledReason=this.disabledReason);return a}static fromJson(a,b,c){b=El.fromJson(a,
1020
+ b,c!=null?c:new Fl);b.element=a.element;b.name=a.name;b.oldValue=a.oldValue;b.newValue=a.newValue;a.disabledReason!==void 0&&(b.disabledReason=a.disabledReason);return b}setDisabledReason(a){if(this.element!=="disabled")throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=a}isNull(){return this.oldValue===this.newValue}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");
1020
1021
  b=b.getBlockById(this.blockId);if(!b)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");var c=b.getIcon(Zg.MUTATOR);c&&xd(c)&&c.bubbleIsVisible()&&c.setBubbleVisible(!1);a=a?this.newValue:this.oldValue;switch(this.element){case "field":(b=b.getField(this.name))?b.setValue(a):console.warn("Can't set non-existent field: "+this.name);break;case "comment":b.setCommentText(a!=null?a:null);break;case "collapsed":b.setCollapsed(!!a);break;case "disabled":var d;
1021
- b.setDisabledReason(!!a,(d=this.disabledReason)!=null?d:"MANUALLY_DISABLED");break;case "inline":b.setInputsInline(!!a);break;case "mutation":d=El.getExtraBlockState_(b);b.loadExtraState?b.loadExtraState(JSON.parse(a||"{}")):b.domToMutation&&b.domToMutation($.uc(a||"<mutation/>"));w(new El(b,"mutation",null,d,a));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(a){return a.saveExtraState?(a=a.saveExtraState(!0))?JSON.stringify(a):"":a.mutationToDom?(a=a.mutationToDom())?
1022
- ae(a):"":""}};A(y.EVENT,v.BLOCK_CHANGE,El);var Fl=class extends Dl{constructor(a){super(a);this.type=v.BLOCK_CREATE;a&&(a.isShadow()&&(this.recordUndo=!1),this.ids=Wb(a),this.json=ce(a,{addCoordinates:!0}))}toJson(){var a=super.toJson();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");a.ids=this.ids;a.json=this.json;this.recordUndo||(a.recordUndo=this.recordUndo);
1023
- return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new Fl);b.ids=a.ids;b.json=a.json;a.recordUndo!==void 0&&(b.recordUndo=a.recordUndo);return b}run(a){var b=this.getEventWorkspace_();if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!yd(b,this.ids))if(a)ee(this.json,b);else for(a=0;a<this.ids.length;a++){let c=
1024
- this.ids[a],d=b.getBlockById(c);d?d.dispose(!1):c===this.blockId&&console.warn("Can't uncreate non-existent block: "+c)}}};A(y.EVENT,v.BLOCK_CREATE,Fl);var Gl=class extends Dl{constructor(a){super(a);this.type=v.BLOCK_DELETE;if(a){if(a.getParent())throw Error("Connected blocks cannot be deleted.");a.isShadow()&&(this.recordUndo=!1);this.ids=Wb(a);this.wasShadow=a.isShadow();this.oldJson=ce(a,{addCoordinates:!0})}}toJson(){var a=super.toJson();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(this.wasShadow===void 0)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");
1025
- if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");a.ids=this.ids;a.wasShadow=this.wasShadow;a.oldJson=this.oldJson;this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new Gl);b.ids=a.ids;b.wasShadow=a.wasShadow;b.oldJson=a.oldJson;a.recordUndo!==void 0&&(b.recordUndo=a.recordUndo);return b}run(a){var b=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");
1026
- if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(a)for(a=0;a<this.ids.length;a++){let c=this.ids[a],d=b.getBlockById(c);d?d.dispose(!1):c===this.blockId&&console.warn("Can't delete non-existent block: "+c)}else ee(this.oldJson,b)}};A(y.EVENT,v.BLOCK_DELETE,Gl);var Hl=class extends Cl{constructor(a){super();this.isBlank=!0;this.recordUndo=!1;this.isUiEvent=!0;this.isBlank=typeof a==="undefined";this.workspaceId=a?a:""}};var Il=class extends Hl{constructor(a,b,c){super(a?a.workspace.id:void 0);this.type=v.BLOCK_DRAG;a&&(this.blockId=a.id,this.isStart=b,this.blocks=c)}toJson(){var a=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.blockId===void 0)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");a.isStart=this.isStart;a.blockId=this.blockId;
1027
- a.blocks=this.blocks;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new Il);b.isStart=a.isStart;b.blockId=a.blockId;b.blocks=a.blocks;return b}};A(y.EVENT,v.BLOCK_DRAG,Il);var Jl=class extends Dl{constructor(a,b,c,d){super(a);this.type=v.BLOCK_FIELD_INTERMEDIATE_CHANGE;this.recordUndo=!1;a&&(this.name=b,this.oldValue=c,this.newValue=d)}toJson(){var a=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");a.name=this.name;a.oldValue=this.oldValue;a.newValue=this.newValue;return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new Jl);b.name=a.name;b.oldValue=a.oldValue;b.newValue=
1022
+ b.setDisabledReason(!!a,(d=this.disabledReason)!=null?d:"MANUALLY_DISABLED");break;case "inline":b.setInputsInline(!!a);break;case "mutation":d=Fl.getExtraBlockState_(b);b.loadExtraState?b.loadExtraState(JSON.parse(a||"{}")):b.domToMutation&&b.domToMutation($.uc(a||"<mutation/>"));w(new Fl(b,"mutation",null,d,a));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(a){return a.saveExtraState?(a=a.saveExtraState(!0))?JSON.stringify(a):"":a.mutationToDom?(a=a.mutationToDom())?
1023
+ ae(a):"":""}};A(y.EVENT,v.BLOCK_CHANGE,Fl);var Gl=class extends El{constructor(a){super(a);this.type=v.BLOCK_CREATE;a&&(a.isShadow()&&(this.recordUndo=!1),this.ids=Wb(a),this.json=ce(a,{addCoordinates:!0}))}toJson(){var a=super.toJson();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");a.ids=this.ids;a.json=this.json;this.recordUndo||(a.recordUndo=this.recordUndo);
1024
+ return a}static fromJson(a,b,c){b=El.fromJson(a,b,c!=null?c:new Gl);b.ids=a.ids;b.json=a.json;a.recordUndo!==void 0&&(b.recordUndo=a.recordUndo);return b}run(a){var b=this.getEventWorkspace_();if(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!yd(b,this.ids))if(a)ee(this.json,b);else for(a=0;a<this.ids.length;a++){let c=
1025
+ this.ids[a],d=b.getBlockById(c);d?d.dispose(!1):c===this.blockId&&console.warn("Can't uncreate non-existent block: "+c)}}};A(y.EVENT,v.BLOCK_CREATE,Gl);var Hl=class extends El{constructor(a){super(a);this.type=v.BLOCK_DELETE;if(a){if(a.getParent())throw Error("Connected blocks cannot be deleted.");a.isShadow()&&(this.recordUndo=!1);this.ids=Wb(a);this.wasShadow=a.isShadow();this.oldJson=ce(a,{addCoordinates:!0})}}toJson(){var a=super.toJson();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(this.wasShadow===void 0)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");
1026
+ if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");a.ids=this.ids;a.wasShadow=this.wasShadow;a.oldJson=this.oldJson;this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,c){b=El.fromJson(a,b,c!=null?c:new Hl);b.ids=a.ids;b.wasShadow=a.wasShadow;b.oldJson=a.oldJson;a.recordUndo!==void 0&&(b.recordUndo=a.recordUndo);return b}run(a){var b=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");
1027
+ if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(a)for(a=0;a<this.ids.length;a++){let c=this.ids[a],d=b.getBlockById(c);d?d.dispose(!1):c===this.blockId&&console.warn("Can't delete non-existent block: "+c)}else ee(this.oldJson,b)}};A(y.EVENT,v.BLOCK_DELETE,Hl);var Il=class extends Dl{constructor(a){super();this.isBlank=!0;this.recordUndo=!1;this.isUiEvent=!0;this.isBlank=typeof a==="undefined";this.workspaceId=a?a:""}};var Jl=class extends Il{constructor(a,b,c){super(a?a.workspace.id:void 0);this.type=v.BLOCK_DRAG;a&&(this.blockId=a.id,this.isStart=b,this.blocks=c)}toJson(){var a=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.blockId===void 0)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");a.isStart=this.isStart;a.blockId=this.blockId;
1028
+ a.blocks=this.blocks;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new Jl);b.isStart=a.isStart;b.blockId=a.blockId;b.blocks=a.blocks;return b}};A(y.EVENT,v.BLOCK_DRAG,Jl);var Kl=class extends El{constructor(a,b,c,d){super(a);this.type=v.BLOCK_FIELD_INTERMEDIATE_CHANGE;this.recordUndo=!1;a&&(this.name=b,this.oldValue=c,this.newValue=d)}toJson(){var a=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");a.name=this.name;a.oldValue=this.oldValue;a.newValue=this.newValue;return a}static fromJson(a,b,c){b=El.fromJson(a,b,c!=null?c:new Kl);b.name=a.name;b.oldValue=a.oldValue;b.newValue=
1028
1029
  a.newValue;return b}isNull(){return this.oldValue===this.newValue}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");b=b.getBlockById(this.blockId);if(!b)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");a=a?this.newValue:this.oldValue;(b=b.getField(this.name))?b.setValue(a):console.warn("Can't set non-existent field: "+this.name)}};
1029
- A(y.EVENT,v.BLOCK_FIELD_INTERMEDIATE_CHANGE,Jl);var G,Kl=G||(G={});Kl[Kl.INPUT_VALUE=1]="INPUT_VALUE";Kl[Kl.OUTPUT_VALUE=2]="OUTPUT_VALUE";Kl[Kl.NEXT_STATEMENT=3]="NEXT_STATEMENT";Kl[Kl.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT";var Ll=class extends Dl{constructor(a){super(a);this.type=v.BLOCK_MOVE;a&&(a.isShadow()&&(this.recordUndo=!1),a=this.currentLocation(),this.oldParentId=a.parentId,this.oldInputName=a.inputName,this.oldCoordinate=a.coordinate)}toJson(){var a=super.toJson();a.oldParentId=this.oldParentId;a.oldInputName=this.oldInputName;this.oldCoordinate&&(a.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`);a.newParentId=this.newParentId;a.newInputName=this.newInputName;this.newCoordinate&&
1030
- (a.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`);this.reason&&(a.reason=this.reason);this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new Ll);b.oldParentId=a.oldParentId;b.oldInputName=a.oldInputName;a.oldCoordinate&&(c=a.oldCoordinate.split(","),b.oldCoordinate=new D(Number(c[0]),Number(c[1])));b.newParentId=a.newParentId;b.newInputName=a.newInputName;a.newCoordinate&&(c=a.newCoordinate.split(","),
1030
+ A(y.EVENT,v.BLOCK_FIELD_INTERMEDIATE_CHANGE,Kl);var G,Ll=G||(G={});Ll[Ll.INPUT_VALUE=1]="INPUT_VALUE";Ll[Ll.OUTPUT_VALUE=2]="OUTPUT_VALUE";Ll[Ll.NEXT_STATEMENT=3]="NEXT_STATEMENT";Ll[Ll.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT";var Ml=class extends El{constructor(a){super(a);this.type=v.BLOCK_MOVE;a&&(a.isShadow()&&(this.recordUndo=!1),a=this.currentLocation(),this.oldParentId=a.parentId,this.oldInputName=a.inputName,this.oldCoordinate=a.coordinate)}toJson(){var a=super.toJson();a.oldParentId=this.oldParentId;a.oldInputName=this.oldInputName;this.oldCoordinate&&(a.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`);a.newParentId=this.newParentId;a.newInputName=this.newInputName;this.newCoordinate&&
1031
+ (a.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`);this.reason&&(a.reason=this.reason);this.recordUndo||(a.recordUndo=this.recordUndo);return a}static fromJson(a,b,c){b=El.fromJson(a,b,c!=null?c:new Ml);b.oldParentId=a.oldParentId;b.oldInputName=a.oldInputName;a.oldCoordinate&&(c=a.oldCoordinate.split(","),b.oldCoordinate=new D(Number(c[0]),Number(c[1])));b.newParentId=a.newParentId;b.newInputName=a.newInputName;a.newCoordinate&&(c=a.newCoordinate.split(","),
1031
1032
  b.newCoordinate=new D(Number(c[0]),Number(c[1])));a.reason!==void 0&&(b.reason=a.reason);a.recordUndo!==void 0&&(b.recordUndo=a.recordUndo);return b}recordNew(){var a=this.currentLocation();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate}setReason(a){this.reason=a}currentLocation(){var a=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var b=a.getBlockById(this.blockId);
1032
1033
  if(!b)throw Error("The block associated with the block move event could not be found");a={};var c=b.getParent();if(c){if(a.parentId=c.id,b=c.getInputWithBlock(b))a.inputName=b.name}else a.coordinate=b.getRelativeToSurfaceXY();return a}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&D.equals(this.oldCoordinate,this.newCoordinate)}run(a){var b=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");
1033
1034
  var c=b.getBlockById(this.blockId);if(c){var d=a?this.newParentId:this.oldParentId,e=a?this.newInputName:this.oldInputName;a=a?this.newCoordinate:this.oldCoordinate;if(d){var f=b.getBlockById(d);if(!f){console.warn("Can't connect to non-existent block: "+d);return}}c.getParent()&&c.unplug();if(a)e=c.getRelativeToSurfaceXY(),c.moveBy(a.x-e.x,a.y-e.y,this.reason);else{b=c.outputConnection;if(!b||c.previousConnection&&c.previousConnection.isConnected())b=c.previousConnection;let g,h;c=(h=b)==null?void 0:
1034
- h.type;if(e){if(c=f.getInput(e))g=c.connection}else c===G.PREVIOUS_STATEMENT&&(g=f.nextConnection);g&&b?b.connect(g):console.warn("Can't connect to non-existent input: "+e)}}else console.warn("Can't move non-existent block: "+this.blockId)}};A(y.EVENT,v.BLOCK_MOVE,Ll);var Ml=class extends Hl{constructor(a,b,c){super(a?a.workspace.id:void 0);this.type=v.BUBBLE_OPEN;a&&(this.blockId=a.id,this.isOpen=b,this.bubbleType=c)}toJson(){var a=super.toJson();if(this.isOpen===void 0)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");a.isOpen=this.isOpen;a.bubbleType=
1035
- this.bubbleType;a.blockId=this.blockId||"";return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new Ml);b.isOpen=a.isOpen;b.bubbleType=a.bubbleType;b.blockId=a.blockId;return b}},Nl,Ol=Nl||(Nl={});Ol.MUTATOR="mutator";Ol.COMMENT="comment";Ol.WARNING="warning";A(y.EVENT,v.BUBBLE_OPEN,Ml);var Pl=class extends Hl{constructor(a,b,c){b=a?a.workspace.id:b;b===null&&(b=void 0);super(b);this.type=v.CLICK;this.blockId=a?a.id:void 0;this.targetType=c}toJson(){var a=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");a.targetType=this.targetType;a.blockId=this.blockId;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new Pl);b.targetType=a.targetType;b.blockId=a.blockId;return b}},Ql,Rl=Ql||
1036
- (Ql={});Rl.BLOCK="block";Rl.WORKSPACE="workspace";Rl.ZOOM_CONTROLS="zoom_controls";A(y.EVENT,v.CLICK,Pl);var Sl=class extends Cl{constructor(a){super();this.isBlank=!0;this.isBlank=!a;a&&(this.commentId=a.id,this.workspaceId=a.workspace.id,this.group=$.gd,this.recordUndo=$.Qc)}toJson(){var a=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a.commentId=this.commentId;return a}static fromJson(a,b,c){b=Cl.fromJson(a,b,c!=null?c:new Sl);b.commentId=a.commentId;return b}static CommentCreateDeleteHelper(a,b){var c=a.getEventWorkspace_();
1037
- if(b){if(!a.json)throw Error("Encountered a comment event without proper json");Rc(a.json,c)}else{if(!a.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(b=c.getCommentById(a.commentId))?b.dispose():console.warn("Can't delete non-existent comment: "+a.commentId)}}};var Tl=class extends Sl{constructor(a,b,c){super(a);this.type=v.COMMENT_CHANGE;a&&(this.oldContents_=typeof b==="undefined"?"":b,this.newContents_=typeof c==="undefined"?"":c)}toJson(){var a=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");a.oldContents=this.oldContents_;a.newContents=
1038
- this.newContents_;return a}static fromJson(a,b,c){b=Sl.fromJson(a,b,c!=null?c:new Tl);b.oldContents_=a.oldContents;b.newContents_=a.newContents;return b}isNull(){return this.oldContents_===this.newContents_}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){var c=a?this.newContents_:this.oldContents_;if(c===void 0){if(a)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");
1039
- throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");}b.setText(c)}else console.warn("Can't change non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_CHANGE,Tl);var Ul=class extends Sl{constructor(a,b){super(a);this.newCollapsed=b;this.type=v.COMMENT_COLLAPSE}toJson(){var a=super.toJson();if(this.newCollapsed===void 0)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");a.newCollapsed=this.newCollapsed;return a}static fromJson(a,b,c){b=Sl.fromJson(a,b,c!=null?c:new Ul);b.newCollapsed=a.newCollapsed;return b}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");
1040
- (b=b.getCommentById(this.commentId))?b.setCollapsed(a?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_COLLAPSE,Ul);var Vl=class extends Sl{constructor(a){super(a);this.type=v.COMMENT_CREATE;a&&(this.json=Pc(a,{addCoordinates:!0}))}toJson(){var a=super.toJson();if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");a.json=this.json;return a}static fromJson(a,b,c){b=Sl.fromJson(a,b,c!=null?c:new Vl);b.json=a.json;return b}run(a){Sl.CommentCreateDeleteHelper(this,a)}};A(y.EVENT,v.COMMENT_CREATE,Vl);var Wl=class extends Sl{constructor(a){super(a);this.type=v.COMMENT_DELETE;a&&(this.json=Pc(a,{addCoordinates:!0}))}run(a){Sl.CommentCreateDeleteHelper(this,!a)}toJson(){var a=super.toJson();if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");a.json=this.json;return a}static fromJson(a,b,c){b=Sl.fromJson(a,b,c!=null?c:new Wl);b.json=a.json;return b}};A(y.EVENT,v.COMMENT_DELETE,Wl);var Xl=class extends Hl{constructor(a,b){super(a?a.workspace.id:void 0);this.type=v.COMMENT_DRAG;a&&(this.commentId=a.id,this.isStart=b)}toJson(){var a=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.commentId===void 0)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a.isStart=this.isStart;a.commentId=this.commentId;
1041
- return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new Xl);b.isStart=a.isStart;b.commentId=a.commentId;return b}};A(y.EVENT,v.COMMENT_DRAG,Xl);var Yl=class extends Sl{constructor(a){super(a);this.type=v.COMMENT_MOVE;a&&(this.comment_=a,this.oldCoordinate_=a.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(a){this.reason=a}setOldCoordinate(a){this.oldCoordinate_=
1035
+ h.type;if(e){if(c=f.getInput(e))g=c.connection}else c===G.PREVIOUS_STATEMENT&&(g=f.nextConnection);g&&b?b.connect(g):console.warn("Can't connect to non-existent input: "+e)}}else console.warn("Can't move non-existent block: "+this.blockId)}};A(y.EVENT,v.BLOCK_MOVE,Ml);var Nl=class extends Il{constructor(a,b,c){super(a?a.workspace.id:void 0);this.type=v.BUBBLE_OPEN;a&&(this.blockId=a.id,this.isOpen=b,this.bubbleType=c)}toJson(){var a=super.toJson();if(this.isOpen===void 0)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");a.isOpen=this.isOpen;a.bubbleType=
1036
+ this.bubbleType;a.blockId=this.blockId||"";return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new Nl);b.isOpen=a.isOpen;b.bubbleType=a.bubbleType;b.blockId=a.blockId;return b}},Ol,Pl=Ol||(Ol={});Pl.MUTATOR="mutator";Pl.COMMENT="comment";Pl.WARNING="warning";A(y.EVENT,v.BUBBLE_OPEN,Nl);var Ql=class extends Il{constructor(a,b,c){b=a?a.workspace.id:b;b===null&&(b=void 0);super(b);this.type=v.CLICK;this.blockId=a?a.id:void 0;this.targetType=c}toJson(){var a=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");a.targetType=this.targetType;a.blockId=this.blockId;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new Ql);b.targetType=a.targetType;b.blockId=a.blockId;return b}},Rl,Sl=Rl||
1037
+ (Rl={});Sl.BLOCK="block";Sl.WORKSPACE="workspace";Sl.ZOOM_CONTROLS="zoom_controls";A(y.EVENT,v.CLICK,Ql);var Tl=class extends Dl{constructor(a){super();this.isBlank=!0;this.isBlank=!a;a&&(this.commentId=a.id,this.workspaceId=a.workspace.id,this.group=$.gd,this.recordUndo=$.Qc)}toJson(){var a=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a.commentId=this.commentId;return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new Tl);b.commentId=a.commentId;return b}static CommentCreateDeleteHelper(a,b){var c=a.getEventWorkspace_();
1038
+ if(b){if(!a.json)throw Error("Encountered a comment event without proper json");Rc(a.json,c)}else{if(!a.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(b=c.getCommentById(a.commentId))?b.dispose():console.warn("Can't delete non-existent comment: "+a.commentId)}}};var Ul=class extends Tl{constructor(a,b,c){super(a);this.type=v.COMMENT_CHANGE;a&&(this.oldContents_=typeof b==="undefined"?"":b,this.newContents_=typeof c==="undefined"?"":c)}toJson(){var a=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");a.oldContents=this.oldContents_;a.newContents=
1039
+ this.newContents_;return a}static fromJson(a,b,c){b=Tl.fromJson(a,b,c!=null?c:new Ul);b.oldContents_=a.oldContents;b.newContents_=a.newContents;return b}isNull(){return this.oldContents_===this.newContents_}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){var c=a?this.newContents_:this.oldContents_;if(c===void 0){if(a)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");
1040
+ throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");}b.setText(c)}else console.warn("Can't change non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_CHANGE,Ul);var Vl=class extends Tl{constructor(a,b){super(a);this.newCollapsed=b;this.type=v.COMMENT_COLLAPSE}toJson(){var a=super.toJson();if(this.newCollapsed===void 0)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");a.newCollapsed=this.newCollapsed;return a}static fromJson(a,b,c){b=Tl.fromJson(a,b,c!=null?c:new Vl);b.newCollapsed=a.newCollapsed;return b}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");
1041
+ (b=b.getCommentById(this.commentId))?b.setCollapsed(a?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_COLLAPSE,Vl);var Wl=class extends Tl{constructor(a){super(a);this.type=v.COMMENT_CREATE;a&&(this.json=Pc(a,{addCoordinates:!0}))}toJson(){var a=super.toJson();if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");a.json=this.json;return a}static fromJson(a,b,c){b=Tl.fromJson(a,b,c!=null?c:new Wl);b.json=a.json;return b}run(a){Tl.CommentCreateDeleteHelper(this,a)}};A(y.EVENT,v.COMMENT_CREATE,Wl);var Xl=class extends Tl{constructor(a){super(a);this.type=v.COMMENT_DELETE;a&&(this.json=Pc(a,{addCoordinates:!0}))}run(a){Tl.CommentCreateDeleteHelper(this,!a)}toJson(){var a=super.toJson();if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");a.json=this.json;return a}static fromJson(a,b,c){b=Tl.fromJson(a,b,c!=null?c:new Xl);b.json=a.json;return b}};A(y.EVENT,v.COMMENT_DELETE,Xl);var Yl=class extends Il{constructor(a,b){super(a?a.workspace.id:void 0);this.type=v.COMMENT_DRAG;a&&(this.commentId=a.id,this.isStart=b)}toJson(){var a=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.commentId===void 0)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a.isStart=this.isStart;a.commentId=this.commentId;
1042
+ return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new Yl);b.isStart=a.isStart;b.commentId=a.commentId;return b}};A(y.EVENT,v.COMMENT_DRAG,Yl);var Zl=class extends Tl{constructor(a){super(a);this.type=v.COMMENT_MOVE;a&&(this.comment_=a,this.oldCoordinate_=a.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(a){this.reason=a}setOldCoordinate(a){this.oldCoordinate_=
1042
1043
  a}toJson(){var a=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");a.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`;a.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y);return a}static fromJson(a,b,c){b=
1043
- Sl.fromJson(a,b,c!=null?c:new Yl);c=a.oldCoordinate.split(",");b.oldCoordinate_=new D(Number(c[0]),Number(c[1]));c=a.newCoordinate.split(",");b.newCoordinate_=new D(Number(c[0]),Number(c[1]));return b}isNull(){return D.equals(this.oldCoordinate_,this.newCoordinate_)}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){a=a?this.newCoordinate_:this.oldCoordinate_;
1044
- if(!a)throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");b.moveTo(a)}else console.warn("Can't move non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_MOVE,Yl);var Zl=class extends Sl{constructor(a){super(a);this.type=v.COMMENT_RESIZE;a&&(this.oldSize=a.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");var a=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a=a.getCommentById(this.commentId);if(!a)throw Error("The comment associated with the comment resize event could not be found");
1044
+ Tl.fromJson(a,b,c!=null?c:new Zl);c=a.oldCoordinate.split(",");b.oldCoordinate_=new D(Number(c[0]),Number(c[1]));c=a.newCoordinate.split(",");b.newCoordinate_=new D(Number(c[0]),Number(c[1]));return b}isNull(){return D.equals(this.oldCoordinate_,this.newCoordinate_)}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){a=a?this.newCoordinate_:this.oldCoordinate_;
1045
+ if(!a)throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");b.moveTo(a)}else console.warn("Can't move non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_MOVE,Zl);var $l=class extends Tl{constructor(a){super(a);this.type=v.COMMENT_RESIZE;a&&(this.oldSize=a.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");var a=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");a=a.getCommentById(this.commentId);if(!a)throw Error("The comment associated with the comment resize event could not be found");
1045
1046
  this.newSize=a.getSize()}toJson(){var a=super.toJson();if(!this.oldSize)throw Error("The old comment size is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newSize)throw Error("The new comment size is undefined. Either call recordCurrentSizeAsNewSize, or call fromJson");a.oldWidth=Math.round(this.oldSize.width);a.oldHeight=Math.round(this.oldSize.height);a.newWidth=Math.round(this.newSize.width);a.newHeight=Math.round(this.newSize.height);return a}static fromJson(a,
1046
- b,c){b=Sl.fromJson(a,b,c!=null?c:new Zl);b.oldSize=new hc(a.oldWidth,a.oldHeight);b.newSize=new hc(a.newWidth,a.newHeight);return b}isNull(){return hc.equals(this.oldSize,this.newSize)}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){a=a?this.newSize:this.oldSize;if(!a)throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");
1047
- b.setSize(a)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_RESIZE,Zl);var $l=class extends Hl{constructor(a,b,c){super(c);this.type=v.SELECTED;this.oldElementId=a!=null?a:void 0;this.newElementId=b!=null?b:void 0}toJson(){var a=super.toJson();a.oldElementId=this.oldElementId;a.newElementId=this.newElementId;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new $l);b.oldElementId=a.oldElementId;b.newElementId=a.newElementId;return b}};A(y.EVENT,v.SELECTED,$l);var am=class extends Hl{constructor(a,b){super(b);this.type=v.THEME_CHANGE;this.themeName=a}toJson(){var a=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");a.themeName=this.themeName;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new am);b.themeName=a.themeName;return b}};A(y.EVENT,v.THEME_CHANGE,am);var bm=class extends Hl{constructor(a,b,c){super(c);this.type=v.TOOLBOX_ITEM_SELECT;this.oldItem=a!=null?a:void 0;this.newItem=b!=null?b:void 0}toJson(){var a=super.toJson();a.oldItem=this.oldItem;a.newItem=this.newItem;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new bm);b.oldItem=a.oldItem;b.newItem=a.newItem;return b}};A(y.EVENT,v.TOOLBOX_ITEM_SELECT,bm);var cm=class extends Hl{constructor(a,b){super(b);this.type=v.TRASHCAN_OPEN;this.isOpen=a}toJson(){var a=super.toJson();if(this.isOpen===void 0)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");a.isOpen=this.isOpen;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new cm);b.isOpen=a.isOpen;return b}};A(y.EVENT,v.TRASHCAN_OPEN,cm);var dm=class extends Cl{constructor(a){super();this.isBlank=!0;this.isBlank=typeof a==="undefined";a&&(this.varId=a.getId(),this.workspaceId=a.getWorkspace().id)}toJson(){var a=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");a.varId=this.varId;return a}static fromJson(a,b,c){b=Cl.fromJson(a,b,c!=null?c:new dm);b.varId=a.varId;return b}};var em=class extends dm{constructor(a){super(a);this.type=v.VAR_CREATE;a&&(this.varType=a.getType(),this.varName=a.getName())}toJson(){var a=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a.varType=this.varType;a.varName=this.varName;return a}static fromJson(a,b,c){b=dm.fromJson(a,b,c!=
1048
- null?c:new em);b.varType=a.varType;b.varName=a.varName;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");b=b.getVariableMap();a?b.createVariable(this.varName,this.varType,this.varId):(a=b.getVariableById(this.varId))&&b.deleteVariable(a)}};A(y.EVENT,v.VAR_CREATE,em);var fm=class extends dm{constructor(a){super(a);this.type=v.VAR_DELETE;a&&(this.varType=a.getType(),this.varName=a.getName())}toJson(){var a=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a.varType=this.varType;a.varName=this.varName;return a}static fromJson(a,b,c){b=dm.fromJson(a,b,c!=
1049
- null?c:new fm);b.varType=a.varType;b.varName=a.varName;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");b=b.getVariableMap();a?(a=b.getVariableById(this.varId))&&b.deleteVariable(a):b.createVariable(this.varName,this.varType,this.varId)}};A(y.EVENT,v.VAR_DELETE,fm);var gm=class extends dm{constructor(a,b){super(a);this.type=v.VAR_RENAME;a&&(this.oldName=a.getName(),this.newName=typeof b==="undefined"?"":b)}toJson(){var a=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");a.oldName=this.oldName;a.newName=this.newName;return a}static fromJson(a,b,c){b=dm.fromJson(a,
1050
- b,c!=null?c:new gm);b.oldName=a.oldName;b.newName=a.newName;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");b=b.getVariableMap();var c=b.getVariableById(this.varId);
1051
- a?c&&b.renameVariable(c,this.newName):c&&b.renameVariable(c,this.oldName)}};A(y.EVENT,v.VAR_RENAME,gm);var hm=class extends dm{constructor(a,b,c){super(a);this.oldType=b;this.newType=c;this.type=v.VAR_TYPE_CHANGE}toJson(){var a=super.toJson();if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");a.oldType=this.oldType;a.newType=this.newType;return a}static fromJson(a,b,c){b=dm.fromJson(a,b,c!=null?c:new hm);b.oldType=a.oldType;b.newType=a.newType;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");
1052
- if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");var c=b.getVariableMap().getVariableById(this.varId);c&&(a?b.getVariableMap().changeVariableType(c,this.newType):b.getVariableMap().changeVariableType(c,this.oldType))}};A(y.EVENT,v.VAR_TYPE_CHANGE,hm);var im=class extends Hl{constructor(a,b,c,d,e){super(d);this.type=v.VIEWPORT_CHANGE;this.viewTop=a;this.viewLeft=b;this.scale=c;this.oldScale=e}toJson(){var a=super.toJson();if(this.viewTop===void 0)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(this.viewLeft===void 0)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(this.scale===void 0)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");
1053
- if(this.oldScale===void 0)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");a.viewTop=this.viewTop;a.viewLeft=this.viewLeft;a.scale=this.scale;a.oldScale=this.oldScale;return a}static fromJson(a,b,c){b=Hl.fromJson(a,b,c!=null?c:new im);b.viewTop=a.viewTop;b.viewLeft=a.viewLeft;b.scale=a.scale;b.oldScale=a.oldScale;return b}};A(y.EVENT,v.VIEWPORT_CHANGE,im);var jm=class extends Cl{constructor(a){super();this.isBlank=!0;this.recordUndo=!1;this.type=v.FINISHED_LOADING;this.isBlank=!!a;a&&(this.workspaceId=a.id)}};A(y.EVENT,v.FINISHED_LOADING,jm);var mm,om,pm,qm,rm,sm,tm,um,vm,wm,xm,ym,zm,Am,Bm,Cm,Dm,Em,Fm,Gm,Hm,Im,Jm,Km,N;$.km=v.BLOCK_CHANGE;$.Od=v.BLOCK_CREATE;$.lm=v.BLOCK_DELETE;mm=v.BLOCK_DRAG;$.nm=v.BLOCK_MOVE;om=v.BLOCK_FIELD_INTERMEDIATE_CHANGE;pm=v.BUBBLE_OPEN;qm=v.BLOCK_CHANGE;rm=v.CLICK;sm=v.COMMENT_CHANGE;tm=v.COMMENT_CREATE;um=v.COMMENT_DELETE;vm=v.COMMENT_MOVE;wm=v.COMMENT_RESIZE;xm=v.COMMENT_DRAG;ym=v.BLOCK_CREATE;zm=v.BLOCK_DELETE;Am=v.FINISHED_LOADING;Bm=v.BLOCK_MOVE;Cm=v.SELECTED;Dm=v.THEME_CHANGE;Em=v.TOOLBOX_ITEM_SELECT;
1054
- Fm=v.TRASHCAN_OPEN;Gm=v.UI;Hm=v.VAR_CREATE;Im=v.VAR_DELETE;Jm=v.VAR_RENAME;Km=v.VIEWPORT_CHANGE;N={};N.Abstract=Cl;N.BLOCK_CHANGE=$.km;N.BLOCK_CREATE=$.Od;N.BLOCK_DELETE=$.lm;N.BLOCK_DRAG=mm;N.BLOCK_FIELD_INTERMEDIATE_CHANGE=om;N.BLOCK_MOVE=$.nm;N.BUBBLE_OPEN=pm;N.BUMP_EVENTS=Vh;N.BlockBase=Dl;N.BlockChange=El;N.BlockCreate=Fl;N.BlockDelete=Gl;N.BlockDrag=Il;N.BlockFieldIntermediateChange=Jl;N.BlockMove=Ll;N.BubbleOpen=Ml;N.BubbleType=Nl;N.CHANGE=qm;N.CLICK=rm;N.COMMENT_CHANGE=sm;
1055
- N.COMMENT_CREATE=tm;N.COMMENT_DELETE=um;N.COMMENT_DRAG=xm;N.COMMENT_MOVE=vm;N.COMMENT_RESIZE=wm;N.CREATE=ym;N.Click=Pl;N.ClickTarget=Ql;N.CommentBase=Sl;N.CommentChange=Tl;N.CommentCollapse=Ul;N.CommentCreate=Vl;N.CommentDelete=Wl;N.CommentDrag=Xl;N.CommentMove=Yl;N.CommentResize=Zl;N.DELETE=zm;N.FINISHED_LOADING=Am;N.FinishedLoading=jm;N.MOVE=Bm;N.SELECTED=Cm;N.Selected=$l;N.THEME_CHANGE=Dm;N.TOOLBOX_ITEM_SELECT=Em;N.TRASHCAN_OPEN=Fm;N.ThemeChange=am;N.ToolboxItemSelect=bm;N.TrashcanOpen=cm;
1056
- N.UI=Gm;N.UiBase=Hl;N.VAR_CREATE=Hm;N.VAR_DELETE=Im;N.VAR_RENAME=Jm;N.VIEWPORT_CHANGE=Km;N.VarBase=dm;N.VarCreate=em;N.VarDelete=fm;N.VarRename=gm;N.VarTypeChange=hm;N.ViewportChange=im;N.clearPendingUndo=Tb;N.disable=function(){$.Ub++};
1047
+ b,c){b=Tl.fromJson(a,b,c!=null?c:new $l);b.oldSize=new hc(a.oldWidth,a.oldHeight);b.newSize=new hc(a.newWidth,a.newHeight);return b}isNull(){return hc.equals(this.oldSize,this.newSize)}run(a){var b=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(b=b.getCommentById(this.commentId)){a=a?this.newSize:this.oldSize;if(!a)throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");
1048
+ b.setSize(a)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};A(y.EVENT,v.COMMENT_RESIZE,$l);var am=class extends Il{constructor(a,b,c){super(c);this.type=v.SELECTED;this.oldElementId=a!=null?a:void 0;this.newElementId=b!=null?b:void 0}toJson(){var a=super.toJson();a.oldElementId=this.oldElementId;a.newElementId=this.newElementId;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new am);b.oldElementId=a.oldElementId;b.newElementId=a.newElementId;return b}};A(y.EVENT,v.SELECTED,am);var bm=class extends Il{constructor(a,b){super(b);this.type=v.THEME_CHANGE;this.themeName=a}toJson(){var a=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");a.themeName=this.themeName;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new bm);b.themeName=a.themeName;return b}};A(y.EVENT,v.THEME_CHANGE,bm);var cm=class extends Il{constructor(a,b,c){super(c);this.type=v.TOOLBOX_ITEM_SELECT;this.oldItem=a!=null?a:void 0;this.newItem=b!=null?b:void 0}toJson(){var a=super.toJson();a.oldItem=this.oldItem;a.newItem=this.newItem;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new cm);b.oldItem=a.oldItem;b.newItem=a.newItem;return b}};A(y.EVENT,v.TOOLBOX_ITEM_SELECT,cm);var dm=class extends Il{constructor(a,b){super(b);this.type=v.TRASHCAN_OPEN;this.isOpen=a}toJson(){var a=super.toJson();if(this.isOpen===void 0)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");a.isOpen=this.isOpen;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new dm);b.isOpen=a.isOpen;return b}};A(y.EVENT,v.TRASHCAN_OPEN,dm);var em=class extends Dl{constructor(a){super();this.isBlank=!0;this.isBlank=typeof a==="undefined";a&&(this.varId=a.getId(),this.workspaceId=a.getWorkspace().id)}toJson(){var a=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");a.varId=this.varId;return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new em);b.varId=a.varId;return b}};var fm=class extends em{constructor(a){super(a);this.type=v.VAR_CREATE;a&&(this.varType=a.getType(),this.varName=a.getName())}toJson(){var a=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a.varType=this.varType;a.varName=this.varName;return a}static fromJson(a,b,c){b=em.fromJson(a,b,c!=
1049
+ null?c:new fm);b.varType=a.varType;b.varName=a.varName;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");b=b.getVariableMap();a?b.createVariable(this.varName,this.varType,this.varId):(a=b.getVariableById(this.varId))&&b.deleteVariable(a)}};A(y.EVENT,v.VAR_CREATE,fm);var gm=class extends em{constructor(a){super(a);this.type=v.VAR_DELETE;a&&(this.varType=a.getType(),this.varName=a.getName())}toJson(){var a=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");a.varType=this.varType;a.varName=this.varName;return a}static fromJson(a,b,c){b=em.fromJson(a,b,c!=
1050
+ null?c:new gm);b.varType=a.varType;b.varName=a.varName;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");b=b.getVariableMap();a?(a=b.getVariableById(this.varId))&&b.deleteVariable(a):b.createVariable(this.varName,this.varType,this.varId)}};A(y.EVENT,v.VAR_DELETE,gm);var hm=class extends em{constructor(a,b){super(a);this.type=v.VAR_RENAME;a&&(this.oldName=a.getName(),this.newName=typeof b==="undefined"?"":b)}toJson(){var a=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");a.oldName=this.oldName;a.newName=this.newName;return a}static fromJson(a,b,c){b=em.fromJson(a,
1051
+ b,c!=null?c:new hm);b.oldName=a.oldName;b.newName=a.newName;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");b=b.getVariableMap();var c=b.getVariableById(this.varId);
1052
+ a?c&&b.renameVariable(c,this.newName):c&&b.renameVariable(c,this.oldName)}};A(y.EVENT,v.VAR_RENAME,hm);var im=class extends em{constructor(a,b,c){super(a);this.oldType=b;this.newType=c;this.type=v.VAR_TYPE_CHANGE}toJson(){var a=super.toJson();if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");a.oldType=this.oldType;a.newType=this.newType;return a}static fromJson(a,b,c){b=em.fromJson(a,b,c!=null?c:new im);b.oldType=a.oldType;b.newType=a.newType;return b}run(a){var b=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");
1053
+ if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");var c=b.getVariableMap().getVariableById(this.varId);c&&(a?b.getVariableMap().changeVariableType(c,this.newType):b.getVariableMap().changeVariableType(c,this.oldType))}};A(y.EVENT,v.VAR_TYPE_CHANGE,im);var jm=class extends Il{constructor(a,b,c,d,e){super(d);this.type=v.VIEWPORT_CHANGE;this.viewTop=a;this.viewLeft=b;this.scale=c;this.oldScale=e}toJson(){var a=super.toJson();if(this.viewTop===void 0)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(this.viewLeft===void 0)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(this.scale===void 0)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");
1054
+ if(this.oldScale===void 0)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");a.viewTop=this.viewTop;a.viewLeft=this.viewLeft;a.scale=this.scale;a.oldScale=this.oldScale;return a}static fromJson(a,b,c){b=Il.fromJson(a,b,c!=null?c:new jm);b.viewTop=a.viewTop;b.viewLeft=a.viewLeft;b.scale=a.scale;b.oldScale=a.oldScale;return b}};A(y.EVENT,v.VIEWPORT_CHANGE,jm);var km=class extends Dl{constructor(a){super();this.isBlank=!0;this.recordUndo=!1;this.type=v.FINISHED_LOADING;this.isBlank=!!a;a&&(this.workspaceId=a.id)}};A(y.EVENT,v.FINISHED_LOADING,km);var nm,pm,qm,rm,sm,tm,um,vm,wm,xm,ym,zm,Am,Bm,Cm,Dm,Em,Fm,Gm,Hm,Im,Jm,Km,Lm,N;$.lm=v.BLOCK_CHANGE;$.Od=v.BLOCK_CREATE;$.mm=v.BLOCK_DELETE;nm=v.BLOCK_DRAG;$.om=v.BLOCK_MOVE;pm=v.BLOCK_FIELD_INTERMEDIATE_CHANGE;qm=v.BUBBLE_OPEN;rm=v.BLOCK_CHANGE;sm=v.CLICK;tm=v.COMMENT_CHANGE;um=v.COMMENT_CREATE;vm=v.COMMENT_DELETE;wm=v.COMMENT_MOVE;xm=v.COMMENT_RESIZE;ym=v.COMMENT_DRAG;zm=v.BLOCK_CREATE;Am=v.BLOCK_DELETE;Bm=v.FINISHED_LOADING;Cm=v.BLOCK_MOVE;Dm=v.SELECTED;Em=v.THEME_CHANGE;Fm=v.TOOLBOX_ITEM_SELECT;
1055
+ Gm=v.TRASHCAN_OPEN;Hm=v.UI;Im=v.VAR_CREATE;Jm=v.VAR_DELETE;Km=v.VAR_RENAME;Lm=v.VIEWPORT_CHANGE;N={};N.Abstract=Dl;N.BLOCK_CHANGE=$.lm;N.BLOCK_CREATE=$.Od;N.BLOCK_DELETE=$.mm;N.BLOCK_DRAG=nm;N.BLOCK_FIELD_INTERMEDIATE_CHANGE=pm;N.BLOCK_MOVE=$.om;N.BUBBLE_OPEN=qm;N.BUMP_EVENTS=Vh;N.BlockBase=El;N.BlockChange=Fl;N.BlockCreate=Gl;N.BlockDelete=Hl;N.BlockDrag=Jl;N.BlockFieldIntermediateChange=Kl;N.BlockMove=Ml;N.BubbleOpen=Nl;N.BubbleType=Ol;N.CHANGE=rm;N.CLICK=sm;N.COMMENT_CHANGE=tm;
1056
+ N.COMMENT_CREATE=um;N.COMMENT_DELETE=vm;N.COMMENT_DRAG=ym;N.COMMENT_MOVE=wm;N.COMMENT_RESIZE=xm;N.CREATE=zm;N.Click=Ql;N.ClickTarget=Rl;N.CommentBase=Tl;N.CommentChange=Ul;N.CommentCollapse=Vl;N.CommentCreate=Wl;N.CommentDelete=Xl;N.CommentDrag=Yl;N.CommentMove=Zl;N.CommentResize=$l;N.DELETE=Am;N.FINISHED_LOADING=Bm;N.FinishedLoading=km;N.MOVE=Cm;N.SELECTED=Dm;N.Selected=am;N.THEME_CHANGE=Em;N.TOOLBOX_ITEM_SELECT=Fm;N.TRASHCAN_OPEN=Gm;N.ThemeChange=bm;N.ToolboxItemSelect=cm;N.TrashcanOpen=dm;
1057
+ N.UI=Hm;N.UiBase=Il;N.VAR_CREATE=Im;N.VAR_DELETE=Jm;N.VAR_RENAME=Km;N.VIEWPORT_CHANGE=Lm;N.VarBase=em;N.VarCreate=fm;N.VarDelete=gm;N.VarRename=hm;N.VarTypeChange=im;N.ViewportChange=jm;N.clearPendingUndo=Tb;N.disable=function(){$.Ub++};
1057
1058
  N.disableOrphans=function(a){if((a.type===v.BLOCK_MOVE||a.type===v.BLOCK_CREATE||a.type===v.BLOCK_DRAG&&!a.isStart)&&a.workspaceId){var b=fb(a.workspaceId);if(!a.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(a=b.getBlockById(a.blockId)){let c=$.Qc;try{$.Qc=!1;let d=a.getParent();if(d&&!d.hasDisabledReason("ORPHANED_BLOCK")){let e=a.getDescendants(!1);for(let f=0,g;g=e[f];f++)g.setDisabledReason(!1,"ORPHANED_BLOCK")}else if((a.outputConnection||a.previousConnection)&&
1058
- !b.isDragging()){do a.setDisabledReason(!0,"ORPHANED_BLOCK"),a=a.getNextBlock();while(a)}}finally{$.Qc=c}}}};N.enable=function(){$.Ub--};N.filter=Pb;N.fire=w;N.fromJson=function(a,b){var c=u(a.type);if(!c)throw Error("Unknown event type.");return c.fromJson(a,b)};N.get=u;N.getDescendantIds=Wb;N.getGroup=function(){return $.gd};N.getRecordUndo=function(){return $.Qc};N.isEnabled=Vb;N.setGroup=$.B;N.setRecordUndo=function(a){$.Qc=a};var Lm=class{constructor(){this.scopeChangeAudioCuesEnabled=this.isActive=!1;this.activeClassName="blocklyKeyboardNavigation"}setIsActive(a=!0){this.isActive=a;this.updateActiveVisualization()}getIsActive(){return this.isActive}setScopeChangeAudioCuesEnabled(a){this.scopeChangeAudioCuesEnabled=a}getScopeChangeAudioCuesEnabled(){return this.scopeChangeAudioCuesEnabled}updateActiveVisualization(){var a=kb.getInjectionDiv().parentElement;this.isActive?a==null||a.classList.add(this.activeClassName):a==
1059
- null||a.classList.remove(this.activeClassName)}},Nd=new Lm;var Yd=new Intl.Collator(void 0,{sensitivity:"base"}),Id={generateUniqueNameInternal:function(a){return Kd("i",a.getVariableMap().getAllVariables().map(b=>b.getName()))}},Mm={CATEGORY_NAME:"VARIABLE",TEST_ONLY:Id,VAR_LETTER_OPTIONS:"ijkmnopqrstuvwxyzabcdefgh"};Mm.allDeveloperVariables=$.Cd;Mm.allUsedVarModels=$.Bd;Mm.compareByName=Hd;Mm.createVariableButtonHandler=Dd;Mm.deleteVariable=$.$d;Mm.flyoutCategory=Fd;
1060
- Mm.flyoutCategoryBlocks=function(a){a=a.getVariableMap().getVariablesOfType("");var b=[];if(a.length>0){var c=a[a.length-1];if(zb.variables_set){var d=$.rc("block");d.setAttribute("type","variables_set");d.setAttribute("gap",zb.math_change?"8":"24");d.appendChild(Ud(c));b.push(d)}zb.math_change&&(d=$.rc("block"),d.setAttribute("type","math_change"),d.setAttribute("gap",zb.variables_get?"20":"8"),d.appendChild(Ud(c)),c=$.uc('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),
1061
- d.appendChild(c),b.push(d));if(zb.variables_get){a.sort(Hd);for(let e=0,f;f=a[e];e++)c=$.rc("block"),c.setAttribute("type","variables_get"),c.setAttribute("gap","8"),c.appendChild(Ud(f)),b.push(c)}}return b};Mm.generateUniqueName=Jd;Mm.generateUniqueNameFromOptions=Kd;Mm.generateVariableFieldDom=Ud;Mm.getAddedVariables=Xd;Mm.getOrCreateVariablePackage=$.Wd;Mm.getVariable=$.Vd;Mm.getVariableUsesById=Zd;Mm.jsonFlyoutCategoryBlocks=Ed;Mm.nameUsedWithAnyType=Md;Mm.nameUsedWithConflictingParam=Qd;
1062
- Mm.promptName=Ld;Mm.renameVariable=$.Rd;var Nm=class extends Error{},he=class extends Nm{constructor(a){super("Expected to find a 'type' property, defining the block type");this.state=a}},ke=class extends Nm{constructor(a,b,c){super(`The block ${b.toDevString()} is missing a(n) ${a}
1063
- connection`);this.block=b;this.state=c}},le=class extends Nm{constructor(a,b,c,d){super(`The block ${c.toDevString()} could not connect its
1064
- ${b} to its parent, because: ${a}`);this.childBlock=c;this.childState=d}},ie=class extends Nm{constructor(a){super("Encountered a real block which is defined as a child of a shadow\nblock. It is an invariant of Blockly that shadow blocks only have shadow\nchildren");this.state=a}},me=class extends Nm{constructor(a,b,c){super(`Cannot add an icon of type '${a}' to the block ${b.toDevString()}, because there is no icon registered with type '${a}'. Make sure that all of your icons have been registered.`);
1065
- this.block=b;this.state=c}},Om={};Om.BadConnectionCheck=le;Om.DeserializationError=Nm;Om.MissingBlockType=he;Om.MissingConnection=ke;Om.RealChildOfShadow=ie;Om.UnregisteredIcon=me;var Pm=class{constructor(){this.priority=50}save(a){var b=[];for(let c of a.getTopBlocks(!1))(a=ce(c,{addCoordinates:!0,doFullSerialization:!1}))&&b.push(a);return b.length?{languageVersion:0,blocks:b}:null}load(a,b){a=a.blocks;for(let c of a)ee(c,b,{recordUndo:$.Qc})}clear(a){for(let b of a.getTopBlocks(!1))b.dispose(!1)}};Oc("blocks",new Pm);var Qm={};Qm.BlockSerializer=Pm;Qm.append=ee;Qm.appendInternal=de;Qm.save=ce;var pe={Control:$.C.CONTROL_KEY,Meta:"\u2318",Alt:qe?"\u2325":$.C.ALT_KEY},te=["Meta","Control","Alt","Shift"];var Ie,Rm=Ie||(Ie={});Rm[Rm.UNKNOWN=0]="UNKNOWN";Rm[Rm.BEFORE=1]="BEFORE";Rm[Rm.AFTER=2]="AFTER";Rm[Rm.AROUND=3]="AROUND";Rm[Rm.INSIDE=4]="INSIDE";Rm[Rm.TO=5]="TO";var Sm={};Sm.clamp=Oe;Sm.toDegrees=function(a){return a*180/Math.PI};Sm.toRadians=Ne;var qf=null,gf=null,hf="",jf="",Pe,Qe,Se,df=null,ff=null,Ze=null,Ue=null,Re=null,rf={getBoundsInfo:function(){var a=ac(df),b=Zb(df);return{left:a.x,right:a.x+b.width,top:a.y,bottom:a.y+b.height,width:b.width,height:b.height}},getPositionMetrics:function(a,b,c,d){var e=rf.getBoundsInfo(),f=Zb(Pe);if(b+f.height<e.bottom)return mf(a,b,e,f);if(d-f.height>e.top)return nf(c,d,e,f);if(b+f.height<document.documentElement.clientHeight)return mf(a,b,e,f);if(d-f.height>document.documentElement.clientTop)return nf(c,
1066
- d,e,f);a=lf(a,e.left,e.right,f.width);return{initialX:a.divX,initialY:0,finalX:a.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}}},Tm={ANIMATION_TIME:.25,ARROW_HORIZONTAL_PADDING:12,ARROW_SIZE:16,BORDER_SIZE:1,PADDING_Y:16,TEST_ONLY:rf};Tm.clearContent=Xe;Tm.createDom=Te;Tm.getContentDiv=function(){return Qe};Tm.getOwner=function(){return ff};Tm.getPositionX=lf;Tm.hide=Ve;Tm.hideIfOwner=pf;Tm.hideWithoutAnimation=of;Tm.isVisible=function(){return!!ff};
1067
- Tm.repositionForWindowResize=sf;Tm.setBoundsElement=function(a){df=a};Tm.setColour=Ye;Tm.show=ef;Tm.showPositionedByBlock=function(a,b,c,d,e=!0){return $e(cf(b),a,e,c,d)};Tm.showPositionedByField=bf;var Um={};Um.commonWordPrefix=uf;Um.commonWordSuffix=vf;Um.isNumber=$.zf;Um.shortestStringLength=tf;Um.wrap=$.yf;var Wf=void 0,Pf=!1,Jf=!1,Nf=0,Of=0,Qf=0,Rf=0,Kf=null,Mf=null,Cf=null,Vm={HOVER_MS:750,LIMIT:50,MARGINS:5,OFFSET_X:0,OFFSET_Y:10,RADIUS_OK:10};Vm.bindMouseEvents=Hf;Vm.block=Vf;Vm.createDom=Df;Vm.display=Uf;Vm.dispose=Tf;Vm.getCustomTooltip=function(){return Wf};Vm.getDiv=function(){return Cf};Vm.getTooltipOfObject=Bf;Vm.hide=Lf;Vm.isVisible=function(){return Pf};Vm.setCustomTooltip=function(a){Wf=a};Vm.unbindMouseEvents=If;Vm.unblock=function(){Jf=!1};var cg=.45,dg=.65,Xf={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},Wm={};Wm.blend=bg;Wm.getHsvSaturation=function(){return cg};Wm.getHsvValue=function(){return dg};Wm.hexToRgb=$f;Wm.hsvToHex=ag;Wm.hueToHex=eg;Wm.names=Xf;Wm.parse=Zf;Wm.rgbToHex=Yf;Wm.setHsvSaturation=function(a){cg=a};
1068
- Wm.setHsvValue=function(a){dg=a};var Xm={checkMessageReferences:function(a){var b=!0,c=a.match(/%{BKY_[A-Z]\w*}/gi);if(c)for(let d=0;d<c.length;d++){let e=c[d].toUpperCase();$.C[e.slice(6,-1)]===void 0&&(console.warn("No message string for "+c[d]+" in "+a),b=!1)}return b}};Xm.parseBlockColour=ig;Xm.replaceMessageReferences=hg;Xm.tokenizeInterpolation=gg;var rg=class{get size_(){return this.size}set size_(a){this.size=a}constructor(a,b,c){this.DEFAULT_VALUE=null;this.name=void 0;this.tooltip=this.ariaTypeName=this.validator_=null;this.size=new hc(0,0);this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=null;this.disposed=!1;this.maxDisplayLength=50;this.sourceBlock_=null;this.enabled_=this.visible_=this.isDirty_=!0;this.suffixField=this.prefixField=this.clickTarget_=null;this.EDITABLE=!0;this.SERIALIZABLE=
1059
+ !b.isDragging()){do a.setDisabledReason(!0,"ORPHANED_BLOCK"),a=a.getNextBlock();while(a)}}finally{$.Qc=c}}}};N.enable=function(){$.Ub--};N.filter=Pb;N.fire=w;N.fromJson=function(a,b){var c=u(a.type);if(!c)throw Error("Unknown event type.");return c.fromJson(a,b)};N.get=u;N.getDescendantIds=Wb;N.getGroup=function(){return $.gd};N.getRecordUndo=function(){return $.Qc};N.isEnabled=Vb;N.setGroup=$.B;N.setRecordUndo=function(a){$.Qc=a};var Mm=class{constructor(){this.scopeChangeAudioCuesEnabled=this.isActive=!1;this.activeClassName="blocklyKeyboardNavigation"}setIsActive(a=!0){this.isActive=a;this.updateActiveVisualization()}getIsActive(){return this.isActive}setScopeChangeAudioCuesEnabled(a){this.scopeChangeAudioCuesEnabled=a}getScopeChangeAudioCuesEnabled(){return this.scopeChangeAudioCuesEnabled}updateActiveVisualization(){var a=kb.getInjectionDiv().parentElement;this.isActive?a==null||a.classList.add(this.activeClassName):a==
1060
+ null||a.classList.remove(this.activeClassName)}},Nd=new Mm;var Yd=new Intl.Collator(void 0,{sensitivity:"base"}),Id={generateUniqueNameInternal:function(a){return Kd("i",a.getVariableMap().getAllVariables().map(b=>b.getName()))}},Nm={CATEGORY_NAME:"VARIABLE",TEST_ONLY:Id,VAR_LETTER_OPTIONS:"ijkmnopqrstuvwxyzabcdefgh"};Nm.allDeveloperVariables=$.Cd;Nm.allUsedVarModels=$.Bd;Nm.compareByName=Hd;Nm.createVariableButtonHandler=Dd;Nm.deleteVariable=$.$d;Nm.flyoutCategory=Fd;
1061
+ Nm.flyoutCategoryBlocks=function(a){a=a.getVariableMap().getVariablesOfType("");var b=[];if(a.length>0){var c=a[a.length-1];if(zb.variables_set){var d=$.rc("block");d.setAttribute("type","variables_set");d.setAttribute("gap",zb.math_change?"8":"24");d.appendChild(Ud(c));b.push(d)}zb.math_change&&(d=$.rc("block"),d.setAttribute("type","math_change"),d.setAttribute("gap",zb.variables_get?"20":"8"),d.appendChild(Ud(c)),c=$.uc('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),
1062
+ d.appendChild(c),b.push(d));if(zb.variables_get){a.sort(Hd);for(let e=0,f;f=a[e];e++)c=$.rc("block"),c.setAttribute("type","variables_get"),c.setAttribute("gap","8"),c.appendChild(Ud(f)),b.push(c)}}return b};Nm.generateUniqueName=Jd;Nm.generateUniqueNameFromOptions=Kd;Nm.generateVariableFieldDom=Ud;Nm.getAddedVariables=Xd;Nm.getOrCreateVariablePackage=$.Wd;Nm.getVariable=$.Vd;Nm.getVariableUsesById=Zd;Nm.jsonFlyoutCategoryBlocks=Ed;Nm.nameUsedWithAnyType=Md;Nm.nameUsedWithConflictingParam=Qd;
1063
+ Nm.promptName=Ld;Nm.renameVariable=$.Rd;var Om=class extends Error{},he=class extends Om{constructor(a){super("Expected to find a 'type' property, defining the block type");this.state=a}},ke=class extends Om{constructor(a,b,c){super(`The block ${b.toDevString()} is missing a(n) ${a}
1064
+ connection`);this.block=b;this.state=c}},le=class extends Om{constructor(a,b,c,d){super(`The block ${c.toDevString()} could not connect its
1065
+ ${b} to its parent, because: ${a}`);this.childBlock=c;this.childState=d}},ie=class extends Om{constructor(a){super("Encountered a real block which is defined as a child of a shadow\nblock. It is an invariant of Blockly that shadow blocks only have shadow\nchildren");this.state=a}},me=class extends Om{constructor(a,b,c){super(`Cannot add an icon of type '${a}' to the block ${b.toDevString()}, because there is no icon registered with type '${a}'. Make sure that all of your icons have been registered.`);
1066
+ this.block=b;this.state=c}},Pm={};Pm.BadConnectionCheck=le;Pm.DeserializationError=Om;Pm.MissingBlockType=he;Pm.MissingConnection=ke;Pm.RealChildOfShadow=ie;Pm.UnregisteredIcon=me;var Qm=class{constructor(){this.priority=50}save(a){var b=[];for(let c of a.getTopBlocks(!1))(a=ce(c,{addCoordinates:!0,doFullSerialization:!1}))&&b.push(a);return b.length?{languageVersion:0,blocks:b}:null}load(a,b){a=a.blocks;for(let c of a)ee(c,b,{recordUndo:$.Qc})}clear(a){for(let b of a.getTopBlocks(!1))b.dispose(!1)}};Oc("blocks",new Qm);var Rm={};Rm.BlockSerializer=Qm;Rm.append=ee;Rm.appendInternal=de;Rm.save=ce;var pe={Control:$.C.CONTROL_KEY,Meta:"\u2318",Alt:qe?"\u2325":$.C.ALT_KEY},te=["Meta","Control","Alt","Shift"];var Ie,Sm=Ie||(Ie={});Sm[Sm.UNKNOWN=0]="UNKNOWN";Sm[Sm.BEFORE=1]="BEFORE";Sm[Sm.AFTER=2]="AFTER";Sm[Sm.AROUND=3]="AROUND";Sm[Sm.INSIDE=4]="INSIDE";Sm[Sm.TO=5]="TO";var Tm={};Tm.clamp=Oe;Tm.toDegrees=function(a){return a*180/Math.PI};Tm.toRadians=Ne;var qf=null,gf=null,hf="",jf="",Pe,Qe,Se,df=null,ff=null,Ze=null,Ue=null,Re=null,rf={getBoundsInfo:function(){var a=ac(df),b=Zb(df);return{left:a.x,right:a.x+b.width,top:a.y,bottom:a.y+b.height,width:b.width,height:b.height}},getPositionMetrics:function(a,b,c,d){var e=rf.getBoundsInfo(),f=Zb(Pe);if(b+f.height<e.bottom)return mf(a,b,e,f);if(d-f.height>e.top)return nf(c,d,e,f);if(b+f.height<document.documentElement.clientHeight)return mf(a,b,e,f);if(d-f.height>document.documentElement.clientTop)return nf(c,
1067
+ d,e,f);a=lf(a,e.left,e.right,f.width);return{initialX:a.divX,initialY:0,finalX:a.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}}},Um={ANIMATION_TIME:.25,ARROW_HORIZONTAL_PADDING:12,ARROW_SIZE:16,BORDER_SIZE:1,PADDING_Y:16,TEST_ONLY:rf};Um.clearContent=Xe;Um.createDom=Te;Um.getContentDiv=function(){return Qe};Um.getOwner=function(){return ff};Um.getPositionX=lf;Um.hide=Ve;Um.hideIfOwner=pf;Um.hideWithoutAnimation=of;Um.isVisible=function(){return!!ff};
1068
+ Um.repositionForWindowResize=sf;Um.setBoundsElement=function(a){df=a};Um.setColour=Ye;Um.show=ef;Um.showPositionedByBlock=function(a,b,c,d,e=!0){return $e(cf(b),a,e,c,d)};Um.showPositionedByField=bf;var Vm={};Vm.commonWordPrefix=uf;Vm.commonWordSuffix=vf;Vm.isNumber=$.zf;Vm.shortestStringLength=tf;Vm.wrap=$.yf;var Wf=void 0,Pf=!1,Jf=!1,Nf=0,Of=0,Qf=0,Rf=0,Kf=null,Mf=null,Cf=null,Wm={HOVER_MS:750,LIMIT:50,MARGINS:5,OFFSET_X:0,OFFSET_Y:10,RADIUS_OK:10};Wm.bindMouseEvents=Hf;Wm.block=Vf;Wm.createDom=Df;Wm.display=Uf;Wm.dispose=Tf;Wm.getCustomTooltip=function(){return Wf};Wm.getDiv=function(){return Cf};Wm.getTooltipOfObject=Bf;Wm.hide=Lf;Wm.isVisible=function(){return Pf};Wm.setCustomTooltip=function(a){Wf=a};Wm.unbindMouseEvents=If;Wm.unblock=function(){Jf=!1};var cg=.45,dg=.65,Xf={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00"},Xm={};Xm.blend=bg;Xm.getHsvSaturation=function(){return cg};Xm.getHsvValue=function(){return dg};Xm.hexToRgb=$f;Xm.hsvToHex=ag;Xm.hueToHex=eg;Xm.names=Xf;Xm.parse=Zf;Xm.rgbToHex=Yf;Xm.setHsvSaturation=function(a){cg=a};
1069
+ Xm.setHsvValue=function(a){dg=a};var Ym={checkMessageReferences:function(a){var b=!0,c=a.match(/%{BKY_[A-Z]\w*}/gi);if(c)for(let d=0;d<c.length;d++){let e=c[d].toUpperCase();$.C[e.slice(6,-1)]===void 0&&(console.warn("No message string for "+c[d]+" in "+a),b=!1)}return b}};Ym.parseBlockColour=ig;Ym.replaceMessageReferences=hg;Ym.tokenizeInterpolation=gg;var rg=class{get size_(){return this.size}set size_(a){this.size=a}constructor(a,b,c){this.DEFAULT_VALUE=null;this.name=void 0;this.tooltip=this.ariaTypeName=this.validator_=null;this.size=new hc(0,0);this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=null;this.disposed=!1;this.maxDisplayLength=50;this.sourceBlock_=null;this.enabled_=this.visible_=this.isDirty_=!0;this.suffixField=this.prefixField=this.clickTarget_=null;this.EDITABLE=!0;this.SERIALIZABLE=
1069
1070
  !1;this.id_=null;this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE;this.size_=new hc(0,0);a!==rg.SKIP_SETUP&&(c&&this.configure_(c),this.setValue(a),b&&this.setValidator(b))}configure_(a){a.tooltip&&this.setTooltip(hg(a.tooltip));a.ariaTypeName&&this.setAriaTypeName(a.ariaTypeName)}setSourceBlock(a){if(this.sourceBlock_)throw Error("Field already bound to a block");this.sourceBlock_=a;if(a.id.includes("_field"))throw Error(`Field ID indicator is contained in block ID. This may cause problems with focus: ${a.id}.`);
1070
1071
  }getConstants(){!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants());return this.constants_}getSourceBlock(){return this.sourceBlock_}getAriaTypeName(){return this.ariaTypeName||null}setAriaTypeName(a){this.ariaTypeName=hg(a)}getAriaValue(){return this.getValue()==null?null:this.getText()}computeAriaLabel(a=!0){a=a?this.getAriaTypeName():null;var b=this.getAriaValue();
1071
1072
  if(b===null||b==="")b=$.C.FIELD_LABEL_EMPTY;return a?`${a}: ${b}`:b}init(){if(!this.fieldGroup_){this.fieldGroup_=r(q.G,{});this.isVisible()||(this.fieldGroup_.style.display="none");var a=this.sourceBlock_;a.getSvgRoot().appendChild(this.fieldGroup_);this.initView();this.updateEditable();this.setTooltip(this.tooltip);this.bindEvents_();this.initModel();this.applyColour();this.isFullBlockField()?this.id_=Lb():this.id_=`${a.id}_field_${Lb()}`;this.fieldGroup_.setAttribute("id",this.id_)}}initView(){this.createBorderRect_();
@@ -1078,27 +1079,27 @@ a){this.visible_=a;var b=this.fieldGroup_;b&&(b.style.display=a?"block":"none")}
1078
1079
  return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_());this.updateSize_()}showEditor(a){this.isClickable()&&this.showEditor_(a)}showEditor_(){}repositionForWindowResize(){return!1}updateSize_(a){var b=this.getConstants();a=a!==void 0?a:this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;var c=a*2,d=b.FIELD_TEXT_HEIGHT,e=0;this.textElement_&&(e=Wa(this.textElement_),c+=e);this.borderRect_&&(d=Math.max(d,b.FIELD_BORDER_RECT_HEIGHT));
1079
1080
  this.size_=new hc(c,d);this.positionTextElement_(a,e);this.positionBorderRect_()}positionTextElement_(a,b){if(this.textElement_){var c=this.getConstants(),d=this.size_.height/2,e;this.textElement_.setAttribute("x",String(((e=this.getSourceBlock())==null?0:e.RTL)?this.size_.width-b-a:a));this.textElement_.setAttribute("y",String(c.FIELD_TEXT_BASELINE_CENTER?d:d-c.FIELD_TEXT_HEIGHT/2+c.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),
1080
1081
  this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){if(!this.isVisible())return new hc(0,0);this.isDirty_&&(this.render_(),this.isDirty_=!1);return this.size_}getScaledBBox(){var a=this.getSourceBlock();if(!a)throw new lj;if(this.borderRect_){var b=this.borderRect_.getBoundingClientRect();var c=ac(this.borderRect_);
1081
- a=b.width;b=b.height}else{b=this.sourceBlock_.getHeightWidth();let d=a.workspace.scale;c=this.getAbsoluteXY_();a=(b.width+1)*d;b=(b.height+1)*d;wk?(c.x+=1.5*d,c.y+=1.5*d):(c.x-=.5*d,c.y-=.5*d)}return new cc(c.y,c.y+b,c.x,c.x+a)}onLocationChange(){}getDisplayText_(){var a=this.getText();a.length>this.maxDisplayLength&&(a=a.substring(0,this.maxDisplayLength-2)+"\u2026");a=a.replace(/\s/g,rg.NBSP);this.sourceBlock_&&this.sourceBlock_.RTL&&(a+="\u200f");return a}getText(){var a=this.getText_();return a!==
1082
+ a=b.width;b=b.height}else{b=this.sourceBlock_.getHeightWidth();let d=a.workspace.scale;c=this.getAbsoluteXY_();a=(b.width+1)*d;b=(b.height+1)*d;xk?(c.x+=1.5*d,c.y+=1.5*d):(c.x-=.5*d,c.y-=.5*d)}return new cc(c.y,c.y+b,c.x,c.x+a)}onLocationChange(){}getDisplayText_(){var a=this.getText();a.length>this.maxDisplayLength&&(a=a.substring(0,this.maxDisplayLength-2)+"\u2026");a=a.replace(/\s/g,rg.NBSP);this.sourceBlock_&&this.sourceBlock_.RTL&&(a+="\u200f");return a}getText(){var a=this.getText_();return a!==
1082
1083
  null?String(a):String(this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0;this.constants_=null}forceRerender(){this.isDirty_=!0;this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(a,b=!0){if(a!==null){var c=$.gd;c||$.B(!0);try{let m=this.doClassValidation_(a),z=this.processValidation(a,m,b);if(!(z instanceof Error)){var d,e=(d=this.getValidator())==null?void 0:d.call(this,z),f=this.processValidation(z,e,b);if(!(f instanceof Error)){var g=this.sourceBlock_;
1083
1084
  if(!g||!g.disposed){var h=this.getValue();h===f?this.doValueUpdate_(f):(this.doValueUpdate_(f),b&&g&&Vb()&&w(new (u(v.BLOCK_CHANGE))(g,"field",this.name||null,h,f)),this.isDirty_&&this.forceRerender())}}}}finally{$.B(c)}}}processValidation(a,b,c){return b===null?(this.doValueInvalid_(a,c),this.isDirty_&&this.forceRerender(),Error()):b===void 0?a:b}getValue(){return this.value_}doClassValidation_(a){return a===null||a===void 0?null:a}doValueUpdate_(a){this.value_=a;this.isDirty_=!0}doValueInvalid_(){}onMouseDown_(a){this.sourceBlock_&&
1084
1085
  !this.sourceBlock_.isDeadOrDying()&&(a=this.sourceBlock_.workspace.getGesture(a))&&a.setStartField(this)}setTooltip(a){a||a===""||(a=this.sourceBlock_);var b=this.getClickTarget_();b?b.tooltip=a:this.tooltip=a}getTooltip(){var a=this.getClickTarget_();return a?Bf(a):Bf({tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return ac(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){var a=null,b=this.getSourceBlock();
1085
1086
  if(!b)throw new lj;var c=b.inputList;for(let d=0;d<b.inputList.length;d++){let e=c[d],f=e.fieldRow;for(let g=0;g<f.length;g++)if(f[g]===this){a=e;break}}return a}getFlipRtl(){return!1}onShortcut(){return!1}getFocusableElement(){if(!this.fieldGroup_)throw Error("This field currently has no representative DOM element.");return this.fieldGroup_}getFocusableTree(){var a=this.getSourceBlock();if(!a)throw new lj;return a.workspace}onNodeFocus(){var a=this.getSourceBlock();a.workspace.scrollBoundsIntoView(a.getBoundingRectangleWithoutChildren())}onNodeBlur(){}canBeFocused(){return!0}performAction(){this.showEditor()}recomputeAriaContext(){try{var a=
1086
1087
  this.getFocusableElement()}catch(d){return!1}if(!a)return!1;var b;if((b=this.getSourceBlock())==null?0:b.isInFlyout){let d,e;if((d=this.getSourceBlock())==null||!d.getFullBlockField()||((e=this.getSourceBlock())==null?0:e.getParent()))return l(a,p.HIDDEN,!0),!1;var c;b=((c=this.getSourceBlock())==null?void 0:c.getAriaRoleDescription())||$.C.BLOCK_LABEL_VALUE;l(a,p.ROLEDESCRIPTION,b)}za(a,p.HIDDEN);ya(a,Ka.BUTTON);c=this.computeAriaLabel(!0);this.isFullBlockField()&&(c=Ce(this.getSourceBlock(),we.STANDARD,
1087
- c));l(a,p.LABEL,c);return!0}static fromJson(){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.");}};rg.NBSP="\u00a0";rg.SKIP_SETUP=Symbol("SKIP_SETUP");var lj=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}};var og=null,qg=null,pg=null,sg="",tg="",mg,jg=null,Ym={};Ym.createDom=ng;Ym.getDiv=function(){return mg};Ym.hide=kg;Ym.hideIfOwner=vg;Ym.hideIfOwnerIsInWorkspace=wg;Ym.isVisible=function(){return!!og};Ym.positionWithAnchor=yg;Ym.repositionForWindowResize=zg;Ym.show=ug;Ym.testOnly_setDiv=function(a){mg=a;if(a===null){let b;(b=document.querySelector(".blocklyWidgetDiv"))==null||b.remove()}};var Fg=null,Ag={},Dg=null,Zm={};Zm.callbackFactory=$.Pg;Zm.dispose=Bg;Zm.getCurrentBlock=function(){return Fg};Zm.getMenu=function(){return Dg};Zm.hide=Gg;Zm.setCurrentBlock=function(a){Fg=a};Zm.show=Hg;var Kj=class{constructor(){this.registeredItems=new Map;this.reset()}reset(){this.registeredItems.clear()}register(a){if(this.registeredItems.has(a.id))throw Error('Menu item with ID "'+a.id+'" is already registered.');this.registeredItems.set(a.id,a)}unregister(a){if(!this.registeredItems.has(a))throw Error('Menu item with ID "'+a+'" not found.');this.registeredItems.delete(a)}getItem(a){var b;return(b=this.registeredItems.get(a))!=null?b:null}getContextMenuOptions(a,b){var c=[];for(let d of this.registeredItems.values()){if(d.scopeType){if(d.scopeType===
1088
- $m.BLOCK&&!a.block)continue;if(d.scopeType===$m.COMMENT&&!a.comment)continue;if(d.scopeType===$m.WORKSPACE&&!a.workspace)continue}let e;e={id:d.id,scope:a,weight:d.weight};let f,g,h=(g=(f=d).preconditionFn)==null?void 0:g.call(f,a,b);if(h!=="hidden"){if(d.separator)e=Object.assign({},e,{separator:!0});else{let m=typeof d.displayText==="function"?d.displayText(a):d.displayText;e=Object.assign({},e,{text:m,callback:d.callback,enabled:h==="enabled",associatedKeyboardShortcut:d.associatedKeyboardShortcut})}c.push(e)}}c.sort(function(d,
1089
- e){return d.weight-e.weight});return c}},an=Kj||(Kj={}),bn=an.ScopeType||(an.ScopeType={});bn.BLOCK="block";bn.WORKSPACE="workspace";bn.COMMENT="comment";an.registry=new an;var $m=Kj.ScopeType;var cn=class{constructor(a){this.comment=a;this.startLoc=null;this.workspace=a.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.isReadOnly()}startDrag(){this.fireDragStartEvent();this.startLoc=this.comment.getRelativeToSurfaceXY();this.workspace.setResizesEnabled(!1);var a;(a=this.workspace.getLayerManager())==null||a.moveToDragLayer(this.comment);this.comment.setDragging(!0);return this.comment}drag(a){this.comment.moveDuringDrag(a)}endDrag(){this.fireDragEndEvent();
1088
+ c));l(a,p.LABEL,c);return!0}static fromJson(){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.");}};rg.NBSP="\u00a0";rg.SKIP_SETUP=Symbol("SKIP_SETUP");var lj=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}};var og=null,qg=null,pg=null,sg="",tg="",mg,jg=null,Zm={};Zm.createDom=ng;Zm.getDiv=function(){return mg};Zm.hide=kg;Zm.hideIfOwner=vg;Zm.hideIfOwnerIsInWorkspace=wg;Zm.isVisible=function(){return!!og};Zm.positionWithAnchor=yg;Zm.repositionForWindowResize=zg;Zm.show=ug;Zm.testOnly_setDiv=function(a){mg=a;if(a===null){let b;(b=document.querySelector(".blocklyWidgetDiv"))==null||b.remove()}};var Fg=null,Ag={},Dg=null,$m={};$m.callbackFactory=$.Pg;$m.dispose=Bg;$m.getCurrentBlock=function(){return Fg};$m.getMenu=function(){return Dg};$m.hide=Gg;$m.setCurrentBlock=function(a){Fg=a};$m.show=Hg;var Lj=class{constructor(){this.registeredItems=new Map;this.reset()}reset(){this.registeredItems.clear()}register(a){if(this.registeredItems.has(a.id))throw Error('Menu item with ID "'+a.id+'" is already registered.');this.registeredItems.set(a.id,a)}unregister(a){if(!this.registeredItems.has(a))throw Error('Menu item with ID "'+a+'" not found.');this.registeredItems.delete(a)}getItem(a){var b;return(b=this.registeredItems.get(a))!=null?b:null}getContextMenuOptions(a,b){var c=[];for(let d of this.registeredItems.values()){if(d.scopeType){if(d.scopeType===
1089
+ an.BLOCK&&!a.block)continue;if(d.scopeType===an.COMMENT&&!a.comment)continue;if(d.scopeType===an.WORKSPACE&&!a.workspace)continue}let e;e={id:d.id,scope:a,weight:d.weight};let f,g,h=(g=(f=d).preconditionFn)==null?void 0:g.call(f,a,b);if(h!=="hidden"){if(d.separator)e=Object.assign({},e,{separator:!0});else{let m=typeof d.displayText==="function"?d.displayText(a):d.displayText;e=Object.assign({},e,{text:m,callback:d.callback,enabled:h==="enabled",associatedKeyboardShortcut:d.associatedKeyboardShortcut})}c.push(e)}}c.sort(function(d,
1090
+ e){return d.weight-e.weight});return c}},bn=Lj||(Lj={}),cn=bn.ScopeType||(bn.ScopeType={});cn.BLOCK="block";cn.WORKSPACE="workspace";cn.COMMENT="comment";bn.registry=new bn;var an=Lj.ScopeType;var dn=class{constructor(a){this.comment=a;this.startLoc=null;this.workspace=a.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.isReadOnly()}startDrag(){this.fireDragStartEvent();this.startLoc=this.comment.getRelativeToSurfaceXY();this.workspace.setResizesEnabled(!1);var a;(a=this.workspace.getLayerManager())==null||a.moveToDragLayer(this.comment);this.comment.setDragging(!0);return this.comment}drag(a){this.comment.moveDuringDrag(a)}endDrag(){this.fireDragEndEvent();
1090
1091
  this.fireMoveEvent();var a;(a=this.workspace.getLayerManager())==null||a.moveOffDragLayer(this.comment,50);this.workspace.getAudioManager().play("drop");this.comment.setDragging(!1);this.comment.snapToGrid();this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){var a=new (u(v.COMMENT_DRAG))(this.comment,!0);w(a)}fireDragEndEvent(){var a=new (u(v.COMMENT_DRAG))(this.comment,!1);w(a)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var a=new (u(v.COMMENT_MOVE))(this.comment);a.setReason(["drag"]);
1091
- a.oldCoordinate_=this.startLoc;a.recordNew();w(a)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}};var Rg=new WeakMap;var dn=class{constructor(a,b,c,d){this.id=a;this.workspace=b;this.container=c;this.commentView=d}isVisible(){return this.icon.checkVisibility()}getCommentView(){return this.commentView}getSize(a=!1){var b=this.icon.getBBox();b=cc.from(b);a&&(a=this.getMargin(),b.left-=a,b.top-=a,b.bottom+=a,b.right+=a);return b}getMargin(){return(this.container.getBBox().height-this.icon.getBBox().height)/2}getFocusableElement(){return this.icon}getFocusableTree(){return this.workspace}onNodeFocus(){var a=this.getCommentView(),
1092
- b=a.getRelativeToSurfaceXY(),c=a.getSize();b=new cc(b.y,b.y+c.height,b.x,b.x+c.width);a.workspace.scrollBoundsIntoView(b)}onNodeBlur(){}canBeFocused(){return this.isVisible()}recomputeAriaContext(){if(this.icon){ya(this.icon,Ka.BUTTON);var a=this.getAriaLabel();l(this.icon,p.LABEL,a||$.C.ARIA_LABEL_BUTTON)}}getAriaLabel(){return null}};var en=class extends dn{constructor(a,b,c,d){super(a,b,c,d);this.id=a;this.workspace=b;this.container=c;this.commentView=d;this.icon=r(q.IMAGE,{"class":"blocklyFoldoutIcon",href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}_collapse_bar_button`},this.container);this.recomputeAriaContext();this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){ka(this.bindId)}reposition(){var a=this.getMargin();this.icon.setAttribute("y",`${a}`);this.icon.setAttribute("x",
1093
- `${a}`)}performAction(a){ha=null;this.getCommentView().bringToFront();a&&a instanceof PointerEvent&&na(a)?a.stopPropagation():(this.getCommentView().setCollapsed(!this.getCommentView().isCollapsed()),this.recomputeAriaContext(),this.workspace.hideChaff(),a==null||a.stopPropagation())}getAriaLabel(){return this.getCommentView().isCollapsed()?$.C.ARIA_LABEL_COMMENT_EXPAND:$.C.ARIA_LABEL_COMMENT_COLLAPSE}};var fn=class{constructor(a,b,c){this.workspace=a;this.onFinishEditing=c;this.textChangeListeners=[];this.text="";this.foreignObject=r(q.FOREIGNOBJECT,{"class":"blocklyCommentForeignObject"});a=document.createElementNS("http://www.w3.org/1999/xhtml","body");a.setAttribute("xmlns","http://www.w3.org/1999/xhtml");a.className="blocklyMinimalBody";this.textArea=document.createElementNS("http://www.w3.org/1999/xhtml","textarea");this.textArea.setAttribute("tabindex","-1");this.textArea.setAttribute("dir",
1092
+ a.oldCoordinate_=this.startLoc;a.recordNew();w(a)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}};var Rg=new WeakMap;var en=class{constructor(a,b,c,d){this.id=a;this.workspace=b;this.container=c;this.commentView=d}isVisible(){return this.icon.checkVisibility()}getCommentView(){return this.commentView}getSize(a=!1){var b=this.icon.getBBox();b=cc.from(b);a&&(a=this.getMargin(),b.left-=a,b.top-=a,b.bottom+=a,b.right+=a);return b}getMargin(){return(this.container.getBBox().height-this.icon.getBBox().height)/2}getFocusableElement(){return this.icon}getFocusableTree(){return this.workspace}onNodeFocus(){var a=this.getCommentView(),
1093
+ b=a.getRelativeToSurfaceXY(),c=a.getSize();b=new cc(b.y,b.y+c.height,b.x,b.x+c.width);a.workspace.scrollBoundsIntoView(b)}onNodeBlur(){}canBeFocused(){return this.isVisible()}recomputeAriaContext(){if(this.icon){ya(this.icon,Ka.BUTTON);var a=this.getAriaLabel();l(this.icon,p.LABEL,a||$.C.ARIA_LABEL_BUTTON)}}getAriaLabel(){return null}};var fn=class extends en{constructor(a,b,c,d){super(a,b,c,d);this.id=a;this.workspace=b;this.container=c;this.commentView=d;this.icon=r(q.IMAGE,{"class":"blocklyFoldoutIcon",href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}_collapse_bar_button`},this.container);this.recomputeAriaContext();this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){ka(this.bindId)}reposition(){var a=this.getMargin();this.icon.setAttribute("y",`${a}`);this.icon.setAttribute("x",
1094
+ `${a}`)}performAction(a){ha=null;this.getCommentView().bringToFront();a&&a instanceof PointerEvent&&na(a)?a.stopPropagation():(this.getCommentView().setCollapsed(!this.getCommentView().isCollapsed()),this.recomputeAriaContext(),this.workspace.hideChaff(),a==null||a.stopPropagation())}getAriaLabel(){return this.getCommentView().isCollapsed()?$.C.ARIA_LABEL_COMMENT_EXPAND:$.C.ARIA_LABEL_COMMENT_COLLAPSE}};var gn=class{constructor(a,b,c){this.workspace=a;this.onFinishEditing=c;this.textChangeListeners=[];this.text="";this.foreignObject=r(q.FOREIGNOBJECT,{"class":"blocklyCommentForeignObject"});a=document.createElementNS("http://www.w3.org/1999/xhtml","body");a.setAttribute("xmlns","http://www.w3.org/1999/xhtml");a.className="blocklyMinimalBody";this.textArea=document.createElementNS("http://www.w3.org/1999/xhtml","textarea");this.textArea.setAttribute("tabindex","-1");this.textArea.setAttribute("dir",
1094
1095
  this.workspace.RTL?"RTL":"LTR");ya(this.textArea,Ka.TEXTBOX);this.textArea.setAttribute("placeholder",$.C.WORKSPACE_COMMENT_DEFAULT_TEXT);n(this.textArea,"blocklyCommentText");n(this.textArea,"blocklyTextarea");n(this.textArea,"blocklyText");a.appendChild(this.textArea);this.foreignObject.appendChild(a);this.id=b+"_comment_textarea_";this.textArea.setAttribute("id",this.id);k(this.textArea,"change",this,this.onTextChange);k(this.textArea,"pointerdown",this,d=>{d.stopPropagation();$.t().focusNode(this);
1095
1096
  ha=null});k(this.textArea,"wheel",this,d=>{d.stopPropagation()},!1,{passive:!0});k(this.textArea,"keydown",this,this.handleKeyDown)}getDom(){return this.foreignObject}getText(){return this.text}setText(a){this.textArea.value=a;this.onTextChange()}setParent(a){this.parent=a}getParent(){return this.parent}onTextChange(){var a=this.text;this.text=this.textArea.value;for(let b=this.textChangeListeners.length-1;b>=0;b--)this.textChangeListeners[b](a,this.text)}handleKeyDown(a){if(a.key==="Escape"||a.key===
1096
1097
  "Enter"&&(a.ctrlKey||a.metaKey)){if(this.onFinishEditing)this.onFinishEditing();a.stopPropagation()}}addTextChangeListener(a){this.textChangeListeners.push(a)}removeTextChangeListener(a){this.textChangeListeners.splice(this.textChangeListeners.indexOf(a),1)}setPlaceholderText(a){this.textArea.placeholder=a}setEditable(a){a?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","true")}updateSize(a,b){this.foreignObject.setAttribute("height",`${a.height-b.height}`);this.foreignObject.setAttribute("width",
1097
- `${a.width}`);this.foreignObject.setAttribute("y",`${b.height}`);this.workspace.RTL&&this.foreignObject.setAttribute("x",`${-a.width}`)}getFocusableElement(){return this.textArea}getFocusableTree(){return this.workspace}onNodeFocus(){var a=cc.from(this.foreignObject.getBoundingClientRect());this.workspace.scrollBoundsIntoView(cc.createFromPoint(oc(this.workspace,a.getOrigin()),a.getWidth(),a.getHeight()))}onNodeBlur(){}canBeFocused(){return this.id?!0:!1}};var gn=class extends dn{constructor(a,b,c,d){super(a,b,c,d);this.id=a;this.workspace=b;this.container=c;this.commentView=d;this.icon=r(q.IMAGE,{"class":"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}_delete_bar_button`},c);this.recomputeAriaContext();this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){ka(this.bindId)}reposition(){var a=this.getMargin();this.icon.setAttribute("x","0");var b=this.container.getBBox();this.icon.setAttribute("y",
1098
- `${a}`);this.icon.setAttribute("x",`${b.width-this.getSize(!0).getWidth()}`)}performAction(a){ha=null;a&&a instanceof PointerEvent&&na(a)?a.stopPropagation():(this.getCommentView().dispose(),a==null||a.stopPropagation(),$.t().focusNode(this.workspace),this.workspace.getAudioManager().play("delete"))}getAriaLabel(){return $.C.REMOVE_COMMENT}};var hn=class{constructor(a,b){this.workspace=a;this.commentId=b;this.collapsed=!1;this.editable=!0;this.location=new D(0,0);this.sizeChangeListeners=[];this.disposeListeners=[];this.collapseChangeListeners=[];this.resizePointerMoveListener=this.resizePointerUpListener=null;this.disposed=this.disposing=!1;this.svgRoot=r(q.G,{"class":"blocklyComment blocklyEditable blocklyDraggable"});ya(this.svgRoot,Ka.BUTTON);l(this.svgRoot,p.ROLEDESCRIPTION,$.C.ARIA_LABEL_COMMENT);this.highlightRect=this.createHighlightRect(this.svgRoot);
1099
- ({topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteButton:this.deleteButton,foldoutButton:this.foldoutButton,textPreview:this.textPreview,textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot));this.commentEditor=this.createTextArea();l(this.svgRoot,p.LABELLEDBY,this.commentEditor.getFocusableElement().id);this.resizeHandle=this.createResizeHandle(this.svgRoot,a);var c;(c=a.getLayerManager())==null||c.append(this,50);this.size=hn.defaultCommentSize;this.setSizeWithoutFiringEvents(this.size);
1100
- this.moveTo(new D(0,0))}createHighlightRect(a){return r(q.RECT,{"class":"blocklyCommentHighlight"},a)}createTopBar(a){a=r(q.G,{"class":"blocklyCommentTopbar"},a);var b=r(q.RECT,{"class":"blocklyCommentTopbarBackground"},a),c=new gn(this.commentId,this.workspace,a,this),d=new en(this.commentId,this.workspace,a,this);this.addDisposeListener(()=>{c.dispose();d.dispose()});var e=r(q.TEXT,{"class":"blocklyCommentPreview blocklyCommentText blocklyText"},a),f=document.createTextNode("");e.appendChild(f);
1101
- return{topBarGroup:a,topBarBackground:b,deleteButton:c,foldoutButton:d,textPreview:e,textPreviewNode:f}}createTextArea(){var a=new fn(this.workspace,this.commentId,()=>this.svgRoot.focus());this.svgRoot.appendChild(a.getDom());a.addTextChangeListener((b,c)=>{this.updateTextPreview(c);this.setSize(this.size)});return a}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(a,b){a=r(q.IMAGE,{"class":"blocklyResizeHandle",href:`${b.options.pathToMedia}resize-handle.svg`},a);k(a,"pointerdown",
1098
+ `${a.width}`);this.foreignObject.setAttribute("y",`${b.height}`);this.workspace.RTL&&this.foreignObject.setAttribute("x",`${-a.width}`)}getFocusableElement(){return this.textArea}getFocusableTree(){return this.workspace}onNodeFocus(){var a=cc.from(this.foreignObject.getBoundingClientRect());this.workspace.scrollBoundsIntoView(cc.createFromPoint(oc(this.workspace,a.getOrigin()),a.getWidth(),a.getHeight()))}onNodeBlur(){}canBeFocused(){return this.id?!0:!1}};var hn=class extends en{constructor(a,b,c,d){super(a,b,c,d);this.id=a;this.workspace=b;this.container=c;this.commentView=d;this.icon=r(q.IMAGE,{"class":"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}_delete_bar_button`},c);this.recomputeAriaContext();this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){ka(this.bindId)}reposition(){var a=this.getMargin();this.icon.setAttribute("x","0");var b=this.container.getBBox();this.icon.setAttribute("y",
1099
+ `${a}`);this.icon.setAttribute("x",`${b.width-this.getSize(!0).getWidth()}`)}performAction(a){ha=null;a&&a instanceof PointerEvent&&na(a)?a.stopPropagation():(this.getCommentView().dispose(),a==null||a.stopPropagation(),$.t().focusNode(this.workspace),this.workspace.getAudioManager().play("delete"))}getAriaLabel(){return $.C.REMOVE_COMMENT}};var jn=class{constructor(a,b){this.workspace=a;this.commentId=b;this.collapsed=!1;this.editable=!0;this.location=new D(0,0);this.sizeChangeListeners=[];this.disposeListeners=[];this.collapseChangeListeners=[];this.resizePointerMoveListener=this.resizePointerUpListener=null;this.disposed=this.disposing=!1;this.svgRoot=r(q.G,{"class":"blocklyComment blocklyEditable blocklyDraggable"});ya(this.svgRoot,Ka.BUTTON);l(this.svgRoot,p.ROLEDESCRIPTION,$.C.ARIA_LABEL_COMMENT);this.highlightRect=this.createHighlightRect(this.svgRoot);
1100
+ ({topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteButton:this.deleteButton,foldoutButton:this.foldoutButton,textPreview:this.textPreview,textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot));this.commentEditor=this.createTextArea();l(this.svgRoot,p.LABELLEDBY,this.commentEditor.getFocusableElement().id);this.resizeHandle=this.createResizeHandle(this.svgRoot,a);var c;(c=a.getLayerManager())==null||c.append(this,50);this.size=jn.defaultCommentSize;this.setSizeWithoutFiringEvents(this.size);
1101
+ this.moveTo(new D(0,0))}createHighlightRect(a){return r(q.RECT,{"class":"blocklyCommentHighlight"},a)}createTopBar(a){a=r(q.G,{"class":"blocklyCommentTopbar"},a);var b=r(q.RECT,{"class":"blocklyCommentTopbarBackground"},a),c=new hn(this.commentId,this.workspace,a,this),d=new fn(this.commentId,this.workspace,a,this);this.addDisposeListener(()=>{c.dispose();d.dispose()});var e=r(q.TEXT,{"class":"blocklyCommentPreview blocklyCommentText blocklyText"},a),f=document.createTextNode("");e.appendChild(f);
1102
+ return{topBarGroup:a,topBarBackground:b,deleteButton:c,foldoutButton:d,textPreview:e,textPreviewNode:f}}createTextArea(){var a=new gn(this.workspace,this.commentId,()=>this.svgRoot.focus());this.svgRoot.appendChild(a.getDom());a.addTextChangeListener((b,c)=>{this.updateTextPreview(c);this.setSize(this.size)});return a}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(a,b){a=r(q.IMAGE,{"class":"blocklyResizeHandle",href:`${b.options.pathToMedia}resize-handle.svg`},a);k(a,"pointerdown",
1102
1103
  this,this.onResizePointerDown);return a}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(a){var b=this.topBarBackground.getBBox(),c=this.textPreview.getBBox(),d=this.resizeHandle.getBBox();this.size=a=hc.max(a,this.calcMinSize(b));this.svgRoot.setAttribute("height",`${a.height}`);this.svgRoot.setAttribute("width",`${a.width}`);this.updateHighlightRect(a);this.updateTopBarSize(a);this.commentEditor.updateSize(a,b);
1103
1104
  this.deleteButton.reposition();this.foldoutButton.reposition();this.updateTextPreviewSize(a,b,c);this.updateResizeHandlePosition(a,d)}setSize(a){var b=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(a);this.onSizeChange(b,this.size)}calcMinSize(a){var b;this.updateTextPreview((b=this.commentEditor.getText())!=null?b:"");var c=b=Wa(this.textPreview);this.foldoutButton.isVisible()?c+=this.foldoutButton.getSize(!0).getWidth():b&&(c+=4);this.deleteButton.isVisible()?c+=this.deleteButton.getSize(!0).getWidth():
1104
1105
  b&&(c+=4);return new hc(c,a.height+20)}updateHighlightRect(a){this.highlightRect.setAttribute("height",`${a.height}`);this.highlightRect.setAttribute("width",`${a.width}`);this.workspace.RTL&&this.highlightRect.setAttribute("x",`${-a.width}`)}updateTopBarSize(a){this.topBarBackground.setAttribute("width",`${a.width}`)}updateTextPreviewSize(a,b,c){b=(b.height-c.height)/2;var d=this.foldoutButton.getSize(!0),e=this.deleteButton.getSize(!0);a=a.width-d.getWidth()-e.getWidth();this.textPreview.setAttribute("x",
@@ -1108,19 +1109,19 @@ this.resizePointerUpListener=null);this.resizePointerMoveListener&&(ka(this.resi
1108
1109
  this.collapseChangeListeners.length-1;a>=0;a--)this.collapseChangeListeners[a](this.collapsed)}addOnCollapseListener(a){this.collapseChangeListeners.push(a)}removeOnCollapseListener(a){this.collapseChangeListeners.splice(this.collapseChangeListeners.indexOf(a),1)}isEditable(){return this.editable}setEditable(a){(this.editable=a)?(n(this.svgRoot,"blocklyEditable"),Ma(this.svgRoot,"blocklyReadonly")):(Ma(this.svgRoot,"blocklyEditable"),n(this.svgRoot,"blocklyReadonly"));this.commentEditor.setEditable(a)}getRelativeToSurfaceXY(){return this.location}moveTo(a){this.location=
1109
1110
  a;this.svgRoot.setAttribute("transform",`translate(${a.x}, ${a.y})`)}getText(){return this.commentEditor.getText()}setText(a){this.commentEditor.setText(a)}setPlaceholderText(a){this.commentEditor.setPlaceholderText(a)}addTextChangeListener(a){this.commentEditor.addTextChangeListener(a)}removeTextChangeListener(a){this.commentEditor.removeTextChangeListener(a)}updateTextPreview(a){this.textPreviewNode.textContent=this.truncateText(a)}truncateText(a){return a.length>=12?`${a.substring(0,9)}...`:a}bringToFront(){var a=
1110
1111
  this.svgRoot.parentNode,b=a.childNodes;b[b.length-1]!==this.svgRoot&&a.appendChild(this.svgRoot)}onDeleteDown(a){ha=null;na(a)||this.dispose();a.stopPropagation()}dispose(){this.disposing=!0;Oa(this.svgRoot);for(let a=this.disposeListeners.length-1;a>=0;a--)this.disposeListeners[a]();this.disposeListeners.length=0;this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}addDisposeListener(a){this.disposeListeners.push(a)}removeDisposeListener(a){this.disposeListeners.splice(this.disposeListeners.indexOf(a),
1111
- 1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};hn.defaultCommentSize=new hc(120,100);ta("\n.injectionDiv {\n --commentFillColour: #FFFCC7;\n --commentBorderColour: #F2E49B;\n}\n\n.blocklyComment .blocklyTextarea {\n background-color: var(--commentFillColour);\n border: 1px solid var(--commentBorderColour);\n box-sizing: border-box;\n display: block;\n outline: 0;\n padding: 5px;\n resize: none;\n width: 100%;\n height: 100%;\n}\n\n.blocklyReadonly.blocklyComment .blocklyTextarea {\n cursor: inherit;\n}\n\n.blocklyDeleteIcon {\n width: 20px;\n height: 20px;\n display: none;\n cursor: pointer;\n}\n\n.blocklyFoldoutIcon {\n width: 20px;\n height: 20px;\n transform-origin: 12px 12px;\n cursor: pointer;\n}\n.blocklyResizeHandle {\n width: 12px;\n height: 12px;\n cursor: se-resize;\n}\n.blocklyReadonly.blocklyComment .blocklyResizeHandle {\n cursor: inherit;\n}\n\n.blocklyCommentTopbarBackground {\n fill: var(--commentBorderColour);\n height: 24px;\n}\n\n.blocklyComment .blocklyCommentPreview.blocklyText {\n fill: #000;\n dominant-baseline: middle;\n visibility: hidden;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentPreview {\n visibility: visible;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentForeignObject,\n.blocklyCollapsed.blocklyComment .blocklyResizeHandle {\n display: none;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyFoldoutIcon {\n transform: rotate(-90deg);\n}\n\n.blocklyRTL .blocklyCommentTopbar {\n transform: scale(-1, 1);\n}\n\n.blocklyRTL .blocklyCommentForeignObject {\n direction: rtl;\n}\n\n.blocklyRTL .blocklyCommentPreview {\n /* Revert the scale and control RTL using direction instead. */\n transform: scale(-1, 1);\n direction: rtl;\n}\n\n.blocklyRTL .blocklyResizeHandle {\n transform: scale(-1, 1);\n cursor: sw-resize;\n}\n\n.blocklyCommentHighlight {\n fill: none;\n}\n\n.blocklyCommentText.blocklyActiveFocus {\n border-color: #fc3;\n border-width: 2px;\n}\n\n.blocklySelected .blocklyCommentHighlight {\n stroke: #fc3;\n stroke-width: 3px;\n}\n\n.blocklyCollapsed.blocklySelected .blocklyCommentHighlight {\n stroke: none;\n}\n\n.blocklyCollapsed.blocklySelected .blocklyCommentTopbarBackground {\n stroke: #fc3;\n stroke-width: 3px;\n}\n");var eh=class{constructor(a,b){this.workspace=a;this.text="";this.collapsed=!1;this.deletable=this.movable=this.editable=!0;this.location=new D(0,0);this.disposing=this.disposed=!1;this.id=b&&!a.getCommentById(b)?b:Nb();this.size=hn.defaultCommentSize;a.addTopComment(this);this.fireCreateEvent()}fireCreateEvent(){Vb()&&w(new (u(v.COMMENT_CREATE))(this))}fireDeleteEvent(){Vb()&&w(new (u(v.COMMENT_DELETE))(this))}fireChangeEvent(a,b){Vb()&&w(new (u(v.COMMENT_CHANGE))(this,a,b))}fireCollapseEvent(a){Vb()&&
1112
+ 1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};jn.defaultCommentSize=new hc(120,100);ta("\n.injectionDiv {\n --commentFillColour: #FFFCC7;\n --commentBorderColour: #F2E49B;\n}\n\n.blocklyComment .blocklyTextarea {\n background-color: var(--commentFillColour);\n border: 1px solid var(--commentBorderColour);\n box-sizing: border-box;\n display: block;\n outline: 0;\n padding: 5px;\n resize: none;\n width: 100%;\n height: 100%;\n}\n\n.blocklyReadonly.blocklyComment .blocklyTextarea {\n cursor: inherit;\n}\n\n.blocklyDeleteIcon {\n width: 20px;\n height: 20px;\n display: none;\n cursor: pointer;\n}\n\n.blocklyFoldoutIcon {\n width: 20px;\n height: 20px;\n transform-origin: 12px 12px;\n cursor: pointer;\n}\n.blocklyResizeHandle {\n width: 12px;\n height: 12px;\n cursor: se-resize;\n}\n.blocklyReadonly.blocklyComment .blocklyResizeHandle {\n cursor: inherit;\n}\n\n.blocklyCommentTopbarBackground {\n fill: var(--commentBorderColour);\n height: 24px;\n}\n\n.blocklyComment .blocklyCommentPreview.blocklyText {\n fill: #000;\n dominant-baseline: middle;\n visibility: hidden;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentPreview {\n visibility: visible;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyCommentForeignObject,\n.blocklyCollapsed.blocklyComment .blocklyResizeHandle {\n display: none;\n}\n\n.blocklyCollapsed.blocklyComment .blocklyFoldoutIcon {\n transform: rotate(-90deg);\n}\n\n.blocklyRTL .blocklyCommentTopbar {\n transform: scale(-1, 1);\n}\n\n.blocklyRTL .blocklyCommentForeignObject {\n direction: rtl;\n}\n\n.blocklyRTL .blocklyCommentPreview {\n /* Revert the scale and control RTL using direction instead. */\n transform: scale(-1, 1);\n direction: rtl;\n}\n\n.blocklyRTL .blocklyResizeHandle {\n transform: scale(-1, 1);\n cursor: sw-resize;\n}\n\n.blocklyCommentHighlight {\n fill: none;\n}\n\n.blocklyCommentText.blocklyActiveFocus {\n border-color: #fc3;\n border-width: 2px;\n}\n\n.blocklySelected .blocklyCommentHighlight {\n stroke: #fc3;\n stroke-width: 3px;\n}\n\n.blocklyCollapsed.blocklySelected .blocklyCommentHighlight {\n stroke: none;\n}\n\n.blocklyCollapsed.blocklySelected .blocklyCommentTopbarBackground {\n stroke: #fc3;\n stroke-width: 3px;\n}\n");var eh=class{constructor(a,b){this.workspace=a;this.text="";this.collapsed=!1;this.deletable=this.movable=this.editable=!0;this.location=new D(0,0);this.disposing=this.disposed=!1;this.id=b&&!a.getCommentById(b)?b:Nb();this.size=jn.defaultCommentSize;a.addTopComment(this);this.fireCreateEvent()}fireCreateEvent(){Vb()&&w(new (u(v.COMMENT_CREATE))(this))}fireDeleteEvent(){Vb()&&w(new (u(v.COMMENT_DELETE))(this))}fireChangeEvent(a,b){Vb()&&w(new (u(v.COMMENT_CHANGE))(this,a,b))}fireCollapseEvent(a){Vb()&&
1112
1113
  w(new (u(v.COMMENT_COLLAPSE))(this,a))}setText(a){var b=this.text;this.text=a;this.fireChangeEvent(b,a)}getText(){return this.text}setSize(a){var b=new (u(v.COMMENT_RESIZE))(this);this.size=a;b.recordCurrentSizeAsNewSize();w(b)}getSize(){return this.size}setCollapsed(a){this.collapsed=a;this.fireCollapseEvent(a)}isCollapsed(){return this.collapsed}setEditable(a){this.editable=a}isEditable(){return this.isOwnEditable()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setMovable(a){this.movable=
1113
1114
  a}isMovable(){return this.isOwnMovable()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnMovable(){return this.movable}setDeletable(a){this.deletable=a}isDeletable(){return this.isOwnDeletable()&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnDeletable(){return this.deletable}moveTo(a,b){var c=new (u(v.COMMENT_MOVE))(this);b&&c.setReason(b);this.location=a;c.recordNew();w(c)}getRelativeToSurfaceXY(){return this.location.clone()}dispose(){this.disposing=
1114
- !0;this.fireDeleteEvent();this.workspace.removeTopComment(this);this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}};var dh=class extends eh{constructor(a,b){super(a,b);this.dragStrategy=new cn(this);this.workspace=a;this.view=new hn(a,this.id);this.view.getEditorFocusableNode().setParent(this);this.view.setSize(this.getSize());this.view.setEditable(this.isEditable());this.view.getSvgRoot().setAttribute("data-id",this.id);this.view.getSvgRoot().setAttribute("id",this.id);this.addModelUpdateBindings();k(this.view.getSvgRoot(),"pointerdown",this,this.startGesture)}addModelUpdateBindings(){this.view.addTextChangeListener((a,
1115
+ !0;this.fireDeleteEvent();this.workspace.removeTopComment(this);this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}};var dh=class extends eh{constructor(a,b){super(a,b);this.dragStrategy=new dn(this);this.workspace=a;this.view=new jn(a,this.id);this.view.getEditorFocusableNode().setParent(this);this.view.setSize(this.getSize());this.view.setEditable(this.isEditable());this.view.getSvgRoot().setAttribute("data-id",this.id);this.view.getSvgRoot().setAttribute("id",this.id);this.addModelUpdateBindings();k(this.view.getSvgRoot(),"pointerdown",this,this.startGesture)}addModelUpdateBindings(){this.view.addTextChangeListener((a,
1115
1116
  b)=>void super.setText(b));this.view.addSizeChangeListener((a,b)=>void super.setSize(b));this.view.addOnCollapseListener(()=>void super.setCollapsed(this.view.isCollapsed()));this.view.addDisposeListener(()=>{this.isDeadOrDying()||this.dispose()})}setText(a){this.view.setText(a)}setPlaceholderText(a){this.view.setPlaceholderText(a)}setSize(a){this.view.setSize(a)}setCollapsed(a){this.view.setCollapsed(a)}setEditable(a){super.setEditable(a);this.view.setEditable(this.isEditable())}getSvgRoot(){return this.view.getSvgRoot()}getSize(){return super.getSize()}getBoundingRectangle(){var a=
1116
1117
  this.getRelativeToSurfaceXY(),b,c,d=(c=(b=this.view)==null?void 0:b.getSize())!=null?c:this.getSize();this.workspace.RTL?(b=a.x-d.width,c=a.x):(b=a.x,c=a.x+d.width);return new cc(a.y,a.y+d.height,b,c)}moveBy(a,b,c){var d=this.getRelativeToSurfaceXY();a=new D(d.x+a,d.y+b);this.moveTo(a,c)}moveTo(a,b){super.moveTo(a,b);this.view.moveTo(a)}moveDuringDrag(a){this.location=a;this.view.moveTo(a)}setDragging(a){a?n(this.getSvgRoot(),"blocklyDragging"):Ma(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing=
1117
1118
  !0;var a=$.t();a.getFocusedNode()===this&&setTimeout(()=>{a.isRegistered(this.workspace)&&a.focusTree(this.workspace)},0);this.view.isDeadOrDying()||this.view.dispose();super.dispose()}startGesture(a){var b=this.workspace.getGesture(a);b&&(b.handleCommentStart(a,this),$.t().focusNode(this))}setDeleteStyle(a){a?n(this.getSvgRoot(),"blocklyDraggingDelete"):Ma(this.getSvgRoot(),"blocklyDraggingDelete")}isCopyable(){return this.isOwnMovable()&&this.isOwnDeletable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(){return this.dragStrategy.startDrag()}drag(a){this.dragStrategy.drag(a)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){n(this.getSvgRoot(),
1118
- "blocklySelected");ob(this)}unselect(){Ma(this.getSvgRoot(),"blocklySelected");ob(null)}toCopyData(){return{paster:vl.TYPE,commentState:Pc(this,{addCoordinates:!0,saveIds:!1})}}showContextMenu(a){var b=Kj.registry.getContextMenuOptions({comment:this,focusedNode:this},a);var c=a instanceof PointerEvent?new D(a.clientX,a.clientY):pc(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10);Hg(a,b,this.workspace.RTL,this.workspace,c)}snapToGrid(){if(!this.isDeadOrDying()){var a=this.workspace.getGrid();
1119
+ "blocklySelected");ob(this)}unselect(){Ma(this.getSvgRoot(),"blocklySelected");ob(null)}toCopyData(){return{paster:wl.TYPE,commentState:Pc(this,{addCoordinates:!0,saveIds:!1})}}showContextMenu(a){var b=Lj.registry.getContextMenuOptions({comment:this,focusedNode:this},a);var c=a instanceof PointerEvent?new D(a.clientX,a.clientY):pc(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10);Hg(a,b,this.workspace.RTL,this.workspace,c)}snapToGrid(){if(!this.isDeadOrDying()){var a=this.workspace.getGrid();
1119
1120
  if(a!=null&&a.shouldSnap()){var b=this.getRelativeToSurfaceXY();a=a.alignXY(b);a!==b&&this.moveTo(a,["snap"])}}}getEditorFocusableNode(){return this.view.getEditorFocusableNode()}getFocusableElement(){return this.getSvgRoot()}getFocusableTree(){return this.workspace}onNodeFocus(){this.select();var a;(a=this.getSvgRoot().parentElement)==null||a.appendChild(this.getSvgRoot());this.workspace.scrollBoundsIntoView(this.getBoundingRectangle())}onNodeBlur(){this.unselect()}canBeFocused(){return!0}performAction(){this.setCollapsed(!1);
1120
- $.t().focusNode(this.getEditorFocusableNode())}};var jn={appendDomToWorkspace:function(a,b){if(!b.getBlocksBoundingBox)return $.ch(a,b);var c=b.getBlocksBoundingBox();a=$.ch(a,b);if(c&&c.top!==c.bottom){var d=c.bottom;c=b.RTL?c.right:c.left;var e=Infinity;let f=-Infinity,g=Infinity;for(let h=0;h<a.length;h++){let m=b.getBlockById(a[h]).getRelativeToSurfaceXY();m.y<g&&(g=m.y);m.x<e&&(e=m.x);m.x>f&&(f=m.x)}d=d-g+10;c=b.RTL?c-f:c-e;for(e=0;e<a.length;e++)b.getBlockById(a[e]).moveBy(c,d,["create"])}return a}};jn.blockToDom=Wg;jn.blockToDomWithXY=Yg;
1121
- jn.clearWorkspaceAndLoadFromXml=function(a,b){b.setResizesEnabled(!1);b.clear();a=$.ch(a,b);b.setResizesEnabled(!0);return a};jn.deleteNext=function(a){for(let b=0;b<a.childNodes.length;b++){let c=a.childNodes[b];if(c.nodeName.toLowerCase()==="next"){a.removeChild(c);break}}};jn.domToBlock=$.fh;jn.domToBlockInternal=Ng;
1122
- jn.domToPrettyText=function(a){a=ae(a).split("<");var b="";for(let c=1;c<a.length;c++){let d=a[c];d[0]==="/"&&(b=b.substring(2));a[c]=b+"<"+d;d[0]!=="/"&&d.slice(-2)!=="/>"&&(b+=" ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>");return a.replace(/^\n/,"")};jn.domToText=ae;jn.domToVariables=bh;jn.domToWorkspace=$.ch;jn.loadWorkspaceComment=ah;jn.saveWorkspaceComment=Ug;jn.variablesToDom=Vg;
1123
- jn.workspaceToDom=function(a,b=!1){var c=$.rc("xml"),d=Vg($.Bd(a));d.hasChildNodes()&&c.appendChild(d);for(let e of a.getTopComments())c.appendChild(Ug(e,b));a=a.getTopBlocks(!0);for(d=0;d<a.length;d++)c.appendChild(Yg(a[d],b));return c};var kh={fromJsonInternal:function(a){var b=Fb(y.FIELD,a.type,void 0);return b?b.fromJson(a):(console.warn("Blockly could not create a field of type "+a.type+". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached."),null)}},kn={TEST_ONLY:kh};kn.fromJson=$.lh;kn.register=jh;kn.unregister=function(a){Eb(y.FIELD,a)};var zh=class extends rg{constructor(a,b,c){super(rg.SKIP_SETUP);this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null;this.SERIALIZABLE=!0;this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null;this.isInitialized=!1;a!==rg.SKIP_SETUP&&(this.setOptions(a),c&&this.configure_(c),b&&this.setValidator(b))}fromXml(a){this.isOptionListDynamic()&&this.getOptions(!1);this.setValue(a.textContent)}loadState(a){this.loadLegacyState(zh,a)||(this.isOptionListDynamic()&&
1121
+ $.t().focusNode(this.getEditorFocusableNode())}};var kn={appendDomToWorkspace:function(a,b){if(!b.getBlocksBoundingBox)return $.ch(a,b);var c=b.getBlocksBoundingBox();a=$.ch(a,b);if(c&&c.top!==c.bottom){var d=c.bottom;c=b.RTL?c.right:c.left;var e=Infinity;let f=-Infinity,g=Infinity;for(let h=0;h<a.length;h++){let m=b.getBlockById(a[h]).getRelativeToSurfaceXY();m.y<g&&(g=m.y);m.x<e&&(e=m.x);m.x>f&&(f=m.x)}d=d-g+10;c=b.RTL?c-f:c-e;for(e=0;e<a.length;e++)b.getBlockById(a[e]).moveBy(c,d,["create"])}return a}};kn.blockToDom=Wg;kn.blockToDomWithXY=Yg;
1122
+ kn.clearWorkspaceAndLoadFromXml=function(a,b){b.setResizesEnabled(!1);b.clear();a=$.ch(a,b);b.setResizesEnabled(!0);return a};kn.deleteNext=function(a){for(let b=0;b<a.childNodes.length;b++){let c=a.childNodes[b];if(c.nodeName.toLowerCase()==="next"){a.removeChild(c);break}}};kn.domToBlock=$.fh;kn.domToBlockInternal=Ng;
1123
+ kn.domToPrettyText=function(a){a=ae(a).split("<");var b="";for(let c=1;c<a.length;c++){let d=a[c];d[0]==="/"&&(b=b.substring(2));a[c]=b+"<"+d;d[0]!=="/"&&d.slice(-2)!=="/>"&&(b+=" ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>");return a.replace(/^\n/,"")};kn.domToText=ae;kn.domToVariables=bh;kn.domToWorkspace=$.ch;kn.loadWorkspaceComment=ah;kn.saveWorkspaceComment=Ug;kn.variablesToDom=Vg;
1124
+ kn.workspaceToDom=function(a,b=!1){var c=$.rc("xml"),d=Vg($.Bd(a));d.hasChildNodes()&&c.appendChild(d);for(let e of a.getTopComments())c.appendChild(Ug(e,b));a=a.getTopBlocks(!0);for(d=0;d<a.length;d++)c.appendChild(Yg(a[d],b));return c};var kh={fromJsonInternal:function(a){var b=Fb(y.FIELD,a.type,void 0);return b?b.fromJson(a):(console.warn("Blockly could not create a field of type "+a.type+". The field is probably not being registered. This could be because the file is not loaded, the field does not register itself (Issue #1584), or the registration is not being reached."),null)}},ln={TEST_ONLY:kh};ln.fromJson=$.lh;ln.register=jh;ln.unregister=function(a){Eb(y.FIELD,a)};var zh=class extends rg{constructor(a,b,c){super(rg.SKIP_SETUP);this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null;this.SERIALIZABLE=!0;this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null;this.isInitialized=!1;a!==rg.SKIP_SETUP&&(this.setOptions(a),c&&this.configure_(c),b&&this.setValidator(b))}fromXml(a){this.isOptionListDynamic()&&this.getOptions(!1);this.setValue(a.textContent)}loadState(a){this.loadLegacyState(zh,a)||(this.isOptionListDynamic()&&
1124
1125
  this.getOptions(!1),this.setValue(a))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot();this.createTextElement_();this.imageElement=r(q.IMAGE,{},this.fieldGroup_);this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_();this.borderRect_&&n(this.borderRect_,"blocklyDropdownRect");this.fieldGroup_&&(n(this.fieldGroup_,"blocklyField"),n(this.fieldGroup_,"blocklyDropdownField"));this.recomputeAriaContext();
1125
1126
  this.isInitialized=!0}isFullBlockField(){var a;return!this.shouldAddBorderRect_()&&!((a=this.getSourceBlock())==null||!a.isSimpleReporter())}shouldAddBorderRect_(){var a;return!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW&&!((a=this.getSourceBlock())==null?0:a.isShadow())}createTextArrow_(){this.arrow=r(q.TSPAN,{},this.textElement_);var a;this.arrow.appendChild(document.createTextNode(((a=this.getSourceBlock())==null?0:a.RTL)?zh.ARROW_CHAR+
1126
1127
  " ":" "+zh.ARROW_CHAR));this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.arrow.setAttribute("dominant-baseline","central");var b;((b=this.getSourceBlock())==null?0:b.RTL)?this.getTextElement().insertBefore(this.arrow,this.textContent_):this.getTextElement().appendChild(this.arrow)}createSVGArrow_(){this.svgArrow=r(q.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_);this.svgArrow.setAttributeNS("http://www.w3.org/1999/xlink",
@@ -1147,65 +1148,65 @@ O[O.DOWN=40]="DOWN";O[O.PLUS_SIGN=43]="PLUS_SIGN";O[O.PRINT_SCREEN=44]="PRINT_SC
1147
1148
  O[O.AT_SIGN=64]="AT_SIGN";O[O.A=65]="A";O[O.B=66]="B";O[O.C=67]="C";O[O.D=68]="D";O[O.E=69]="E";O[O.F=70]="F";O[O.G=71]="G";O[O.H=72]="H";O[O.I=73]="I";O[O.J=74]="J";O[O.K=75]="K";O[O.L=76]="L";O[O.M=77]="M";O[O.N=78]="N";O[O.O=79]="O";O[O.P=80]="P";O[O.Q=81]="Q";O[O.R=82]="R";O[O.S=83]="S";O[O.T=84]="T";O[O.U=85]="U";O[O.V=86]="V";O[O.W=87]="W";O[O.X=88]="X";O[O.Y=89]="Y";O[O.Z=90]="Z";O[O.META=91]="META";O[O.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT";O[O.CONTEXT_MENU=93]="CONTEXT_MENU";
1148
1149
  O[O.NUM_ZERO=96]="NUM_ZERO";O[O.NUM_ONE=97]="NUM_ONE";O[O.NUM_TWO=98]="NUM_TWO";O[O.NUM_THREE=99]="NUM_THREE";O[O.NUM_FOUR=100]="NUM_FOUR";O[O.NUM_FIVE=101]="NUM_FIVE";O[O.NUM_SIX=102]="NUM_SIX";O[O.NUM_SEVEN=103]="NUM_SEVEN";O[O.NUM_EIGHT=104]="NUM_EIGHT";O[O.NUM_NINE=105]="NUM_NINE";O[O.NUM_MULTIPLY=106]="NUM_MULTIPLY";O[O.NUM_PLUS=107]="NUM_PLUS";O[O.NUM_MINUS=109]="NUM_MINUS";O[O.NUM_PERIOD=110]="NUM_PERIOD";O[O.NUM_DIVISION=111]="NUM_DIVISION";O[O.F1=112]="F1";O[O.F2=113]="F2";O[O.F3=114]="F3";
1149
1150
  O[O.F4=115]="F4";O[O.F5=116]="F5";O[O.F6=117]="F6";O[O.F7=118]="F7";O[O.F8=119]="F8";O[O.F9=120]="F9";O[O.F10=121]="F10";O[O.F11=122]="F11";O[O.F12=123]="F12";O[O.NUMLOCK=144]="NUMLOCK";O[O.SCROLL_LOCK=145]="SCROLL_LOCK";O[O.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY";O[O.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY";O[O.SEMICOLON=186]="SEMICOLON";O[O.DASH=189]="DASH";O[O.EQUALS=187]="EQUALS";O[O.COMMA=188]="COMMA";O[O.PERIOD=190]="PERIOD";O[O.SLASH=191]="SLASH";O[O.APOSTROPHE=192]="APOSTROPHE";
1150
- O[O.TILDE=192]="TILDE";O[O.SINGLE_QUOTE=222]="SINGLE_QUOTE";O[O.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET";O[O.BACKSLASH=220]="BACKSLASH";O[O.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET";O[O.WIN_KEY=224]="WIN_KEY";O[O.MAC_FF_META=224]="MAC_FF_META";O[O.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT";O[O.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT";O[O.WIN_IME=229]="WIN_IME";O[O.VK_NONAME=252]="VK_NONAME";O[O.PHANTOM=255]="PHANTOM";O[O.CTRL_CMD=ma||Wi||Vi?O.MAC_WK_CMD_LEFT:O.CTRL]="CTRL_CMD";var ln=class{constructor(a){this.workspace=a;var b,c,d;this.svgRoot=r(q.G,{},(d=(b=a.getLayerManager())==null?void 0:b.getDragLayer())!=null?d:(c=a.getLayerManager())==null?void 0:c.getBlockLayer());this.svgRoot.classList.add("blocklyMoveIndicator");a=a.RTL;r(q.CIRCLE,{fill:"white","fill-opacity":"0.8",stroke:"grey","stroke-width":"1",r:20,cx:20*(a?-1:1),cy:20},this.svgRoot);r(q.PATH,{fill:"none",stroke:"black","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6",
1151
- transform:`translate(${(a?-4:1)*8} 8)`},this.svgRoot)}moveTo(a,b){this.svgRoot.setAttribute("transform",`translate(${a+(this.workspace.RTL?20:-20)}, ${b-20})`)}dispose(){Oa(this.svgRoot)}};var si,mn=si||(si={});mn[mn.NONE=0]="NONE";mn[mn.UP=1]="UP";mn[mn.DOWN=2]="DOWN";mn[mn.LEFT=3]="LEFT";mn[mn.RIGHT=4]="RIGHT";
1151
+ O[O.TILDE=192]="TILDE";O[O.SINGLE_QUOTE=222]="SINGLE_QUOTE";O[O.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET";O[O.BACKSLASH=220]="BACKSLASH";O[O.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET";O[O.WIN_KEY=224]="WIN_KEY";O[O.MAC_FF_META=224]="MAC_FF_META";O[O.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT";O[O.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT";O[O.WIN_IME=229]="WIN_IME";O[O.VK_NONAME=252]="VK_NONAME";O[O.PHANTOM=255]="PHANTOM";O[O.CTRL_CMD=ma||Wi||Vi?O.MAC_WK_CMD_LEFT:O.CTRL]="CTRL_CMD";var mn=class{constructor(a){this.workspace=a;var b,c,d;this.svgRoot=r(q.G,{},(d=(b=a.getLayerManager())==null?void 0:b.getDragLayer())!=null?d:(c=a.getLayerManager())==null?void 0:c.getBlockLayer());this.svgRoot.classList.add("blocklyMoveIndicator");a=a.RTL;r(q.CIRCLE,{fill:"white","fill-opacity":"0.8",stroke:"grey","stroke-width":"1",r:20,cx:20*(a?-1:1),cy:20},this.svgRoot);r(q.PATH,{fill:"none",stroke:"black","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m18 9l3 3l-3 3m-3-3h6M6 9l-3 3l3 3m-3-3h6m0 6l3 3l3-3m-3-3v6m3-15l-3-3l-3 3m3-3v6",
1152
+ transform:`translate(${(a?-4:1)*8} 8)`},this.svgRoot)}moveTo(a,b){this.svgRoot.setAttribute("transform",`translate(${a+(this.workspace.RTL?20:-20)}, ${b-20})`)}dispose(){Oa(this.svgRoot)}};var si,nn=si||(si={});nn[nn.NONE=0]="NONE";nn[nn.UP=1]="UP";nn[nn.DOWN=2]="DOWN";nn[nn.LEFT=3]="LEFT";nn[nn.RIGHT=4]="RIGHT";
1152
1153
  var ri=class{constructor(){this.totalDelta=new D(0,0);this.stepDistance=20;this.allowedShortcuts=[];this.blurListener=()=>{this.abortMove()}}canMove(a){return!a.workspace.isReadOnly()&&a.isMovable()}isMoving(){return!!this.draggable}startMove(a,b){if(!this.canMove(a)||this.isMoving())return!1;var c=Jb(y.BLOCK_DRAGGER,a.workspace.options,!0);if(!c)throw Error("no Dragger registered");this.dragger=new c(a,a.workspace);this.draggable=this.dragger.onDragStart(b);this.startLocation=this.draggable.getRelativeToSurfaceXY();
1153
1154
  this.updateTotalDelta();this.draggable.getFocusableElement().addEventListener("blur",this.blurListener);a=Object.values(x.registry.getRegistry()).flatMap(d=>d.keyCodes).filter(d=>d&&![L.RIGHT,L.LEFT,L.UP,L.DOWN,L.ENTER,L.SPACE,L.ESC,L.M].includes(typeof d==="number"?d:parseInt(`${d.split("+").pop()}`))).filter(d=>!!d);x.registry.register({name:"commitMove",preconditionFn:()=>this.isMoving(),callback:()=>{this.finishMove();return!1},keyCodes:a,allowCollision:!0},!0);this.scrollCurrentElementIntoView();
1154
- this.moveIndicator=new ln(this.draggable.workspace);this.repositionMoveIndicator();return!0}move(a,b){switch(a){case si.UP:this.totalDelta.y-=this.stepDistance;break;case si.DOWN:this.totalDelta.y+=this.stepDistance;break;case si.LEFT:this.totalDelta.x-=this.stepDistance;break;case si.RIGHT:this.totalDelta.x+=this.stepDistance}var c;(c=this.dragger)==null||c.onDrag(b,this.totalPixelDelta());this.updateTotalDelta();this.scrollCurrentElementIntoView();this.repositionMoveIndicator();return!0}finishMove(a){this.preDragEndCleanup();
1155
+ this.moveIndicator=new mn(this.draggable.workspace);this.repositionMoveIndicator();return!0}move(a,b){switch(a){case si.UP:this.totalDelta.y-=this.stepDistance;break;case si.DOWN:this.totalDelta.y+=this.stepDistance;break;case si.LEFT:this.totalDelta.x-=this.stepDistance;break;case si.RIGHT:this.totalDelta.x+=this.stepDistance}var c;(c=this.dragger)==null||c.onDrag(b,this.totalPixelDelta());this.updateTotalDelta();this.scrollCurrentElementIntoView();this.repositionMoveIndicator();return!0}finishMove(a){this.preDragEndCleanup();
1155
1156
  var b;(b=this.dragger)==null||b.onDragEnd(a,this.totalPixelDelta());this.postDragEndCleanup();return!0}abortMove(a){this.preDragEndCleanup();var b;(b=this.dragger)==null||b.onDragRevert(a,this.totalPixelDelta());this.postDragEndCleanup();return!0}setMoveDistance(a){this.stepDistance=a}getAllowedShortcuts(){return this.allowedShortcuts}setAllowedShortcuts(a){this.allowedShortcuts=a}repositionMoveIndicator(){cd().then(()=>{var a,b=(a=this.draggable)==null?void 0:a.getBoundingRectangle();this.draggable&&
1156
1157
  "getBoundingRectangleWithoutChildren"in this.draggable&&(b=this.positionForBlockMoveIndicator(this.draggable));if(b){var c,d;(d=this.moveIndicator)==null||d.moveTo(((c=this.draggable)==null?0:c.workspace.RTL)?b.left:b.right,b.top)}})}positionForBlockMoveIndicator(a){for(var b=a.workspace.getNavigator(),c=a,d;d=b.getInNode(c);)c=d;b=b.getSourceBlockFromNode(c);c=a.getBoundingRectangleWithoutChildren().getOrigin().y;for(var e;((e=b)==null?void 0:e.getBoundingRectangleWithoutChildren().getOrigin().y)!==
1157
1158
  c;){let h,m;b=(m=(h=b)==null?void 0:h.getParent())!=null?m:null}var f,g;return(g=(f=b)==null?void 0:f.getBoundingRectangleWithoutChildren())!=null?g:a.getBoundingRectangleWithoutChildren()}preDragEndCleanup(){x.registry.unregister("commitMove");var a;(a=this.draggable)==null||a.getFocusableElement().removeEventListener("blur",this.blurListener)}postDragEndCleanup(){var a;(a=this.moveIndicator)==null||a.dispose();this.startLocation=this.dragger=this.draggable=this.moveIndicator=void 0;this.totalDelta=
1158
1159
  new D(0,0)}totalPixelDelta(){var a,b,c=(b=(a=this.draggable)==null?void 0:a.workspace.scale)!=null?b:1;return new D(this.totalDelta.x*c,this.totalDelta.y*c)}scrollCurrentElementIntoView(){if(this.draggable){var a=this.draggable.getBoundingRectangle();this.draggable.workspace.scrollBoundsIntoView(a)}}updateTotalDelta(){this.draggable&&this.startLocation&&(this.totalDelta=new D(this.draggable.getRelativeToSurfaceXY().x-this.startLocation.x,this.draggable.getRelativeToSurfaceXY().y-this.startLocation.y))}};
1159
- ri.mover=new ri;var nn=class{constructor(a,b,c,d){this.name=a;this.startHats=!1;this.blockStyles=b||Object.create(null);this.categoryStyles=c||Object.create(null);this.componentStyles=d||Object.create(null);this.fontStyle=Object.create(null);A(y.THEME,a,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(a,b){this.blockStyles[a]=b}setCategoryStyle(a,b){this.categoryStyles[a]=b}getComponentStyle(a){a=this.componentStyles[a];if(!a)return null;if(typeof a==="string"){let b=this.getComponentStyle(a);if(b)return b}return`${a}`}setComponentStyle(a,
1160
- b){this.componentStyles[a]=b}setFontStyle(a){this.fontStyle=a}setStartHats(a){this.startHats=a}static defineTheme(a,b){a=a.toLowerCase();var c=new nn(a),d=b.base;if(d){if(typeof d==="string"){let e;d=(e=Fb(y.THEME,d,void 0))!=null?e:void 0}d instanceof nn&&(bb(c,d),c.name=a)}bb(c.blockStyles,b.blockStyles);bb(c.categoryStyles,b.categoryStyles);bb(c.componentStyles,b.componentStyles);bb(c.fontStyle,b.fontStyle);b.startHats!==null&&(c.startHats=b.startHats);return c}};var on=new nn("classic",{colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}},{colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},
1161
- math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}});var pn=class{constructor(a){this.gridPattern=null;this.getMetrics=this.setMetrics=void 0;var b=null,c=!1,d=!1,e=!1,f=!1,g=!1,h=!1,m=!!a.readOnly;if(!m){var z;b=Cc((z=a.toolbox)!=null?z:null);c=Fc(b);d=a.trashcan;d=d===void 0?c:d;e=a.collapse;e=e===void 0?c:e;f=a.comments;f=f===void 0?c:f;g=a.disable;g=g===void 0?c:g;h=a.sounds;h=h===void 0?!0:h}z=a.maxTrashcanContents;d?z===void 0&&(z=32):z=0;var E=!!a.rtl,J=a.horizontalLayout;J===void 0&&(J=!1);var T=a.toolboxPosition!=="end";T=J?T?F.TOP:F.BOTTOM:
1162
- T===E?F.RIGHT:F.LEFT;var ra=a.css;ra===void 0&&(ra=!0);var jb="https://static.blockly.com/media/";a.media&&(jb=a.media.endsWith("/")?a.media:a.media+"/");var pb=a.oneBasedIndex,Yi=a.renderer||"thrasos",ys=a.plugins||{},bk=a.modalInputs;bk===void 0&&(bk=!0);this.RTL=E;this.oneBasedIndex=pb===void 0?!0:pb;this.collapse=e;this.comments=f;this.disable=g;this.readOnly=m;this.maxBlocks=a.maxBlocks||Infinity;var Uo;this.maxInstances=(Uo=a.maxInstances)!=null?Uo:null;this.modalInputs=bk;this.pathToMedia=
1163
- jb;this.hasCategories=c;this.moveOptions=pn.parseMoveOptions(a,c);this.hasScrollbars=!!this.moveOptions.scrollbars;this.hasTrashcan=d;this.maxTrashcanContents=z;this.hasSounds=h;this.hasCss=ra;this.horizontalLayout=J;this.languageTree=b;this.gridOptions=pn.parseGridOptions(a);this.zoomOptions=pn.parseZoomOptions(a);this.toolboxPosition=T;this.theme=pn.parseThemeOptions(a);this.renderer=Yi;var Vo;this.rendererOverrides=(Vo=a.rendererOverrides)!=null?Vo:null;var Wo;this.parentWorkspace=(Wo=a.parentWorkspace)!=
1164
- null?Wo:null;this.plugins=ys}static parseMoveOptions(a,b){var c=a.move||{},d={};c.scrollbars===void 0&&a.scrollbars===void 0?d.scrollbars=b:typeof c.scrollbars==="object"?(d.scrollbars={horizontal:!!c.scrollbars.horizontal,vertical:!!c.scrollbars.vertical},d.scrollbars.horizontal&&d.scrollbars.vertical?d.scrollbars=!0:d.scrollbars.horizontal||d.scrollbars.vertical||(d.scrollbars=!1)):d.scrollbars=!!c.scrollbars||!!a.scrollbars;d.wheel=d.scrollbars&&c.wheel!==void 0?!!c.wheel:typeof d.scrollbars===
1160
+ ri.mover=new ri;var on=class{constructor(a,b,c,d){this.name=a;this.startHats=!1;this.blockStyles=b||Object.create(null);this.categoryStyles=c||Object.create(null);this.componentStyles=d||Object.create(null);this.fontStyle=Object.create(null);A(y.THEME,a,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(a,b){this.blockStyles[a]=b}setCategoryStyle(a,b){this.categoryStyles[a]=b}getComponentStyle(a){a=this.componentStyles[a];if(!a)return null;if(typeof a==="string"){let b=this.getComponentStyle(a);if(b)return b}return`${a}`}setComponentStyle(a,
1161
+ b){this.componentStyles[a]=b}setFontStyle(a){this.fontStyle=a}setStartHats(a){this.startHats=a}static defineTheme(a,b){a=a.toLowerCase();var c=new on(a),d=b.base;if(d){if(typeof d==="string"){let e;d=(e=Fb(y.THEME,d,void 0))!=null?e:void 0}d instanceof on&&(bb(c,d),c.name=a)}bb(c.blockStyles,b.blockStyles);bb(c.categoryStyles,b.categoryStyles);bb(c.componentStyles,b.componentStyles);bb(c.fontStyle,b.fontStyle);b.startHats!==null&&(c.startHats=b.startHats);return c}};var pn=new on("classic",{colour_blocks:{colourPrimary:"20"},list_blocks:{colourPrimary:"260"},logic_blocks:{colourPrimary:"210"},loop_blocks:{colourPrimary:"120"},math_blocks:{colourPrimary:"230"},procedure_blocks:{colourPrimary:"290"},text_blocks:{colourPrimary:"160"},variable_blocks:{colourPrimary:"330"},variable_dynamic_blocks:{colourPrimary:"310"},hat_blocks:{colourPrimary:"330",hat:"cap"}},{colour_category:{colour:"20"},list_category:{colour:"260"},logic_category:{colour:"210"},loop_category:{colour:"120"},
1162
+ math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}});var qn=class{constructor(a){this.gridPattern=null;this.getMetrics=this.setMetrics=void 0;var b=null,c=!1,d=!1,e=!1,f=!1,g=!1,h=!1,m=!!a.readOnly;if(!m){var z;b=Cc((z=a.toolbox)!=null?z:null);c=Fc(b);d=a.trashcan;d=d===void 0?c:d;e=a.collapse;e=e===void 0?c:e;f=a.comments;f=f===void 0?c:f;g=a.disable;g=g===void 0?c:g;h=a.sounds;h=h===void 0?!0:h}z=a.maxTrashcanContents;d?z===void 0&&(z=32):z=0;var E=!!a.rtl,J=a.horizontalLayout;J===void 0&&(J=!1);var T=a.toolboxPosition!=="end";T=J?T?F.TOP:F.BOTTOM:
1163
+ T===E?F.RIGHT:F.LEFT;var ra=a.css;ra===void 0&&(ra=!0);var ib="https://static.blockly.com/media/";a.media&&(ib=a.media.endsWith("/")?a.media:a.media+"/");var pb=a.oneBasedIndex,Yi=a.renderer||"thrasos",zs=a.plugins||{},bk=a.modalInputs;bk===void 0&&(bk=!0);this.RTL=E;this.oneBasedIndex=pb===void 0?!0:pb;this.collapse=e;this.comments=f;this.disable=g;this.readOnly=m;this.maxBlocks=a.maxBlocks||Infinity;var Vo;this.maxInstances=(Vo=a.maxInstances)!=null?Vo:null;this.modalInputs=bk;this.pathToMedia=
1164
+ ib;this.hasCategories=c;this.moveOptions=qn.parseMoveOptions(a,c);this.hasScrollbars=!!this.moveOptions.scrollbars;this.hasTrashcan=d;this.maxTrashcanContents=z;this.hasSounds=h;this.hasCss=ra;this.horizontalLayout=J;this.languageTree=b;this.gridOptions=qn.parseGridOptions(a);this.zoomOptions=qn.parseZoomOptions(a);this.toolboxPosition=T;this.theme=qn.parseThemeOptions(a);this.renderer=Yi;var Wo;this.rendererOverrides=(Wo=a.rendererOverrides)!=null?Wo:null;var Xo;this.parentWorkspace=(Xo=a.parentWorkspace)!=
1165
+ null?Xo:null;this.plugins=zs}static parseMoveOptions(a,b){var c=a.move||{},d={};c.scrollbars===void 0&&a.scrollbars===void 0?d.scrollbars=b:typeof c.scrollbars==="object"?(d.scrollbars={horizontal:!!c.scrollbars.horizontal,vertical:!!c.scrollbars.vertical},d.scrollbars.horizontal&&d.scrollbars.vertical?d.scrollbars=!0:d.scrollbars.horizontal||d.scrollbars.vertical||(d.scrollbars=!1)):d.scrollbars=!!c.scrollbars||!!a.scrollbars;d.wheel=d.scrollbars&&c.wheel!==void 0?!!c.wheel:typeof d.scrollbars===
1165
1166
  "object";d.drag=d.scrollbars?c.drag===void 0?!0:!!c.drag:!1;return d}static parseZoomOptions(a){a=a.zoom||{};var b={};b.controls=a.controls===void 0?!1:!!a.controls;b.wheel=a.wheel===void 0?!1:!!a.wheel;b.startScale=a.startScale===void 0?1:Number(a.startScale);b.maxScale=a.maxScale===void 0?3:Number(a.maxScale);b.minScale=a.minScale===void 0?.3:Number(a.minScale);b.scaleSpeed=a.scaleSpeed===void 0?1.2:Number(a.scaleSpeed);b.pinch=a.pinch===void 0?b.wheel||b.controls:!!a.pinch;return b}static parseGridOptions(a){a=
1166
- a.grid||{};var b={};b.spacing=Number(a.spacing)||0;b.colour=a.colour||"#888";b.length=a.length===void 0?1:Number(a.length);b.snap=b.spacing>0&&!!a.snap;return b}static parseThemeOptions(a){a=a.theme||on;return typeof a==="string"?Fb(y.THEME,a,void 0):a instanceof nn?a:nn.defineTheme(a.name||"builtin"+Lb(),a)}};var qn=class{constructor(a,b){this.bubble=a;this.workspace=b;this.startLoc=null}isMovable(){return!0}startDrag(){this.startLoc=this.bubble.getRelativeToSurfaceXY();this.workspace.setResizesEnabled(!1);var a;(a=this.workspace.getLayerManager())==null||a.moveToDragLayer(this.bubble);this.bubble.setDragging&&this.bubble.setDragging(!0);return this.bubble}drag(a){this.bubble.moveDuringDrag(a)}endDrag(){this.workspace.setResizesEnabled(!0);var a;(a=this.workspace.getLayerManager())==null||a.moveOffDragLayer(this.bubble,
1167
- 100);this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}};var rn,sn=class{constructor(a,b,c,d,e){this.workspace=a;this.anchor=b;this.ownerRect=c;this.owner=e;this.size=new hc(0,0);this.colour="#ffffff";this.disposed=!1;this.relativeLeft=this.relativeTop=0;this.dragStrategy=new qn(this,this.workspace);this.ariaLabelProvider=null;this.id=Lb();this.svgRoot=r(q.G,{"class":"blocklyBubble"},a.getBubbleCanvas());a=r(q.G,{"class":"blocklyEmboss"},this.svgRoot);this.tail=r(q.PATH,{"class":"blocklyBubbleTail"},a);this.background=r(q.RECT,{"class":"blocklyDraggable",
1168
- x:0,y:0,rx:rn.BORDER_WIDTH,ry:rn.BORDER_WIDTH},a);this.contentContainer=r(q.G,{},this.svgRoot);this.focusableElement=d!=null?d:this.svgRoot;this.focusableElement.setAttribute("id",this.id);k(this.background,"pointerdown",this,this.onMouseDown);k(this.focusableElement,"keydown",this,this.onKeyDown);this.recomputeAriaContext()}dispose(){Oa(this.svgRoot);this.disposed=!0}setAnchorLocation(a,b=!1){this.anchor=a;b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}setPositionRelativeToAnchor(a,
1169
- b){this.relativeLeft=a;this.relativeTop=b;this.positionRelativeToAnchor();this.renderTail()}getSize(){return this.size}setSize(a,b=!1){a.width=Math.max(a.width,rn.MIN_SIZE);a.height=Math.max(a.height,rn.MIN_SIZE);this.size=a;this.background.setAttribute("width",`${a.width}`);this.background.setAttribute("height",`${a.height}`);b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}getColour(){return this.colour}setColour(a){this.colour=a;this.tail.setAttribute("fill",
1167
+ a.grid||{};var b={};b.spacing=Number(a.spacing)||0;b.colour=a.colour||"#888";b.length=a.length===void 0?1:Number(a.length);b.snap=b.spacing>0&&!!a.snap;return b}static parseThemeOptions(a){a=a.theme||pn;return typeof a==="string"?Fb(y.THEME,a,void 0):a instanceof on?a:on.defineTheme(a.name||"builtin"+Lb(),a)}};var rn=class{constructor(a,b){this.bubble=a;this.workspace=b;this.startLoc=null}isMovable(){return!0}startDrag(){this.startLoc=this.bubble.getRelativeToSurfaceXY();this.workspace.setResizesEnabled(!1);var a;(a=this.workspace.getLayerManager())==null||a.moveToDragLayer(this.bubble);this.bubble.setDragging&&this.bubble.setDragging(!0);return this.bubble}drag(a){this.bubble.moveDuringDrag(a)}endDrag(){this.workspace.setResizesEnabled(!0);var a;(a=this.workspace.getLayerManager())==null||a.moveOffDragLayer(this.bubble,
1168
+ 100);this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}};var sn,tn=class{constructor(a,b,c,d,e){this.workspace=a;this.anchor=b;this.ownerRect=c;this.owner=e;this.size=new hc(0,0);this.colour="#ffffff";this.disposed=!1;this.relativeLeft=this.relativeTop=0;this.dragStrategy=new rn(this,this.workspace);this.ariaLabelProvider=null;this.id=Lb();this.svgRoot=r(q.G,{"class":"blocklyBubble"},a.getBubbleCanvas());a=r(q.G,{"class":"blocklyEmboss"},this.svgRoot);this.tail=r(q.PATH,{"class":"blocklyBubbleTail"},a);this.background=r(q.RECT,{"class":"blocklyDraggable",
1169
+ x:0,y:0,rx:sn.BORDER_WIDTH,ry:sn.BORDER_WIDTH},a);this.contentContainer=r(q.G,{},this.svgRoot);this.focusableElement=d!=null?d:this.svgRoot;this.focusableElement.setAttribute("id",this.id);k(this.background,"pointerdown",this,this.onMouseDown);k(this.focusableElement,"keydown",this,this.onKeyDown);this.recomputeAriaContext()}dispose(){Oa(this.svgRoot);this.disposed=!0}setAnchorLocation(a,b=!1){this.anchor=a;b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}setPositionRelativeToAnchor(a,
1170
+ b){this.relativeLeft=a;this.relativeTop=b;this.positionRelativeToAnchor();this.renderTail()}getSize(){return this.size}setSize(a,b=!1){a.width=Math.max(a.width,sn.MIN_SIZE);a.height=Math.max(a.height,sn.MIN_SIZE);this.size=a;this.background.setAttribute("width",`${a.width}`);this.background.setAttribute("height",`${a.height}`);b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}getColour(){return this.colour}setColour(a){this.colour=a;this.tail.setAttribute("fill",
1170
1171
  a);this.background.setAttribute("fill",a)}onMouseDown(a){var b;(b=this.workspace.getGesture(a))==null||b.handleBubbleStart(a,this);$.t().focusNode(this)}onKeyDown(a){a.key==="Escape"&&this.owner&&(this.owner.setBubbleVisible(!1),$.t().focusNode(this.owner))}positionRelativeToAnchor(){var a=this.anchor.x;a=this.workspace.RTL?a-(this.relativeLeft+this.size.width):a+this.relativeLeft;this.moveTo(a,this.relativeTop+this.anchor.y)}moveTo(a,b){this.svgRoot.setAttribute("transform",`translate(${a}, ${b})`)}moveBy(a,
1171
1172
  b){var c=this.getRelativeToSurfaceXY();this.moveTo(c.x+a,c.y+b)}positionByRect(a=new cc(0,0,0,0)){var b=this.workspace.getMetricsManager().getViewMetrics(!0),c=this.getOptimalRelativeLeft(b),d=this.getOptimalRelativeTop(b),e={x:c,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},f={x:-this.size.width-30,y:d};d={x:a.getWidth(),y:d};var g={x:c,y:a.getHeight()};c=a.getWidth()<a.getHeight()?d:g;a=a.getWidth()<a.getHeight()?g:d;d=this.getOverlap(e,b);g=this.getOverlap(f,
1172
1173
  b);var h=this.getOverlap(c,b);b=this.getOverlap(a,b);b=Math.max(d,g,h,b);d===b?(this.relativeLeft=e.x,this.relativeTop=e.y):g===b?(this.relativeLeft=f.x,this.relativeTop=f.y):h===b?(this.relativeLeft=c.x,this.relativeTop=c.y):(this.relativeLeft=a.x,this.relativeTop=a.y);this.positionRelativeToAnchor()}getOverlap(a,b){var c=this.workspace.RTL?this.anchor.x-a.x-this.size.width:a.x+this.anchor.x;a=a.y+this.anchor.y;return Math.max(0,Math.min(1,(Math.min(c+this.size.width,b.left+b.width)-Math.max(c,b.left))*
1173
1174
  (Math.min(a+this.size.height,b.top+b.height)-Math.max(a,b.top))/(this.size.width*this.size.height)))}getOptimalRelativeLeft(a){var b=-this.size.width/4;if(this.size.width>a.width)return b;a=this.getWorkspaceViewRect(a);if(this.workspace.RTL){var c=this.anchor.x-b;c-this.size.width<a.left?b=-(a.left-this.anchor.x+this.size.width):c>a.right&&(b=-(a.right-this.anchor.x))}else{c=b+this.anchor.x;let d=c+this.size.width;c<a.left?b=a.left-this.anchor.x:d>a.right&&(b=a.right-this.anchor.x-this.size.width)}return b}getOptimalRelativeTop(a){var b=
1174
1175
  -this.size.height/4;if(this.size.height>a.height)return b;var c=this.anchor.y+b,d=c+this.size.height;a=this.getWorkspaceViewRect(a);c<a.top?b=a.top-this.anchor.y:d>a.bottom&&(b=a.bottom-this.anchor.y-this.size.height);return b}getWorkspaceViewRect(a){var b=a.top,c=a.top+a.height,d=a.left;a=a.left+a.width;c-=this.getScrollbarThickness();this.workspace.RTL?d-=this.getScrollbarThickness():a-=this.getScrollbarThickness();return new cc(b,c,d,a)}getScrollbarThickness(){return Ic.scrollbarThickness/this.workspace.scale}renderTail(){var a=
1175
- [],b=this.size.width/2,c=this.size.height/2,d=-this.relativeLeft,e=-this.relativeTop;if(b===d&&c===e)a.push("M "+b+","+c);else{e-=c;d-=b;this.workspace.RTL&&(d*=-1);var f=Math.sqrt(e*e+d*d),g=Math.acos(d/f);e<0&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>Math.PI*2&&(h-=Math.PI*2);var m=Math.sin(h);let E=Math.cos(h),J=(this.size.width+this.size.height)/rn.TAIL_THICKNESS;J=Math.min(J,this.size.width,this.size.height)/4;h=1-rn.ANCHOR_RADIUS/f;d=b+h*d;e=c+h*e;h=b+J*E;let T=c+J*m;b-=J*E;c-=J*m;m=Ne(this.workspace.RTL?
1176
- -rn.TAIL_ANGLE:rn.TAIL_ANGLE);m=g+m;m>Math.PI*2&&(m-=Math.PI*2);g=Math.sin(m)*f/rn.TAIL_BEND;f=Math.cos(m)*f/rn.TAIL_BEND;a.push("M"+h+","+T);a.push("C"+(h+f)+","+(T+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");var z;(z=this.tail)==null||z.setAttribute("d",a.join(" "))}bringToFront(){var a,b=(a=this.svgRoot)==null?void 0:a.parentNode;return this.svgRoot&&(b==null?void 0:b.lastChild)!==this.svgRoot?(b==null||b.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new D(this.workspace.RTL?
1176
+ [],b=this.size.width/2,c=this.size.height/2,d=-this.relativeLeft,e=-this.relativeTop;if(b===d&&c===e)a.push("M "+b+","+c);else{e-=c;d-=b;this.workspace.RTL&&(d*=-1);var f=Math.sqrt(e*e+d*d),g=Math.acos(d/f);e<0&&(g=2*Math.PI-g);var h=g+Math.PI/2;h>Math.PI*2&&(h-=Math.PI*2);var m=Math.sin(h);let E=Math.cos(h),J=(this.size.width+this.size.height)/sn.TAIL_THICKNESS;J=Math.min(J,this.size.width,this.size.height)/4;h=1-sn.ANCHOR_RADIUS/f;d=b+h*d;e=c+h*e;h=b+J*E;let T=c+J*m;b-=J*E;c-=J*m;m=Ne(this.workspace.RTL?
1177
+ -sn.TAIL_ANGLE:sn.TAIL_ANGLE);m=g+m;m>Math.PI*2&&(m-=Math.PI*2);g=Math.sin(m)*f/sn.TAIL_BEND;f=Math.cos(m)*f/sn.TAIL_BEND;a.push("M"+h+","+T);a.push("C"+(h+f)+","+(T+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");var z;(z=this.tail)==null||z.setAttribute("d",a.join(" "))}bringToFront(){var a,b=(a=this.svgRoot)==null?void 0:a.parentNode;return this.svgRoot&&(b==null?void 0:b.lastChild)!==this.svgRoot?(b==null||b.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new D(this.workspace.RTL?
1177
1178
  -this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getBoundingRectangle(){var a=this.getRelativeToSurfaceXY();return new cc(a.y,a.y+this.size.height,a.x,a.x+this.size.width)}getSvgRoot(){return this.svgRoot}moveDuringDrag(a){this.moveTo(a.x,a.y);this.relativeLeft=this.workspace.RTL?this.anchor.x-a.x-this.size.width:a.x-this.anchor.x;this.relativeTop=a.y-this.anchor.y;this.renderTail()}setDragging(){}setDeleteStyle(){}isDeletable(){return!1}showContextMenu(){}isMovable(){return!0}startDrag(){return this.dragStrategy.startDrag()}drag(a){this.dragStrategy.drag(a)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){ob(this)}unselect(){ob(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select();
1178
1179
  this.bringToFront();var a=this.getRelativeToSurfaceXY(),b=this.getSize();a=new cc(a.y,a.y+b.height,a.x,a.x+b.width);this.workspace.scrollBoundsIntoView(a)}onNodeBlur(){this.unselect()}canBeFocused(){return!0}getOwner(){return this.owner}recomputeAriaContext(){var a=this.getFocusableElement();if(a){ya(a,Ka.GROUP);var b,c=(b=this.getAriaLabel())==null?void 0:b.trim();l(a,p.LABEL,c?c:$.C.BUBBLE_LABEL_DEFAULT)}}setAriaLabelProvider(a){this.ariaLabelProvider=a;this.recomputeAriaContext()}getAriaLabel(){if(this.ariaLabelProvider){if(typeof this.ariaLabelProvider===
1179
- "string")return this.ariaLabelProvider;if(typeof this.ariaLabelProvider==="function")return this.ariaLabelProvider(this)}return null}};rn=sn;sn.BORDER_WIDTH=6;sn.DOUBLE_BORDER=rn.BORDER_WIDTH*2;sn.MIN_SIZE=rn.DOUBLE_BORDER;sn.TAIL_THICKNESS=1;sn.TAIL_ANGLE=20;sn.TAIL_BEND=4;sn.ANCHOR_RADIUS=8;var tn=class extends sn{constructor(a,b,c,d,e){super(b,c,d,void 0,e);this.workspace=b;this.anchor=c;this.ownerRect=d;this.owner=e;this.autoLayout=!0;b=new pn(a);this.validateWorkspaceOptions(b);this.svgDialog=r(q.SVG,{x:sn.BORDER_WIDTH,y:sn.BORDER_WIDTH},this.contentContainer);a.parentWorkspace=this.workspace;this.miniWorkspace=this.newWorkspaceSvg(new pn(a));this.miniWorkspace.internalIsMutator=!0;a=this.miniWorkspace.createDom("blocklyMutatorBackground");this.svgDialog.appendChild(a);b.languageTree&&
1180
+ "string")return this.ariaLabelProvider;if(typeof this.ariaLabelProvider==="function")return this.ariaLabelProvider(this)}return null}};sn=tn;tn.BORDER_WIDTH=6;tn.DOUBLE_BORDER=sn.BORDER_WIDTH*2;tn.MIN_SIZE=sn.DOUBLE_BORDER;tn.TAIL_THICKNESS=1;tn.TAIL_ANGLE=20;tn.TAIL_BEND=4;tn.ANCHOR_RADIUS=8;var un=class extends tn{constructor(a,b,c,d,e){super(b,c,d,void 0,e);this.workspace=b;this.anchor=c;this.ownerRect=d;this.owner=e;this.autoLayout=!0;b=new qn(a);this.validateWorkspaceOptions(b);this.svgDialog=r(q.SVG,{x:tn.BORDER_WIDTH,y:tn.BORDER_WIDTH},this.contentContainer);a.parentWorkspace=this.workspace;this.miniWorkspace=this.newWorkspaceSvg(new qn(a));this.miniWorkspace.internalIsMutator=!0;a=this.miniWorkspace.createDom("blocklyMutatorBackground");this.svgDialog.appendChild(a);b.languageTree&&
1180
1181
  (a.insertBefore(this.miniWorkspace.addFlyout(q.G),this.miniWorkspace.getCanvas()),a=this.miniWorkspace.getFlyout(),a==null||a.init(this.miniWorkspace),a==null||a.show(b.languageTree));n(this.svgRoot,"blocklyMiniWorkspaceBubble");this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this));var f,g;(f=this.miniWorkspace.getFlyout())==null||(g=f.getWorkspace())==null||g.addChangeListener(this.onWorkspaceChange.bind(this));this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose();super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(a){this.miniWorkspace.addChangeListener(a)}validateWorkspaceOptions(a){if(a.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");
1181
1182
  if(a.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(a.zoomOptions.controls||a.zoomOptions.wheel||a.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(a.moveOptions.scrollbars||a.moveOptions.wheel||a.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(a.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts");}onWorkspaceChange(){this.bumpBlocksIntoBounds();
1182
1183
  this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging()||ri.mover.isMoving())for(let a of this.miniWorkspace.getTopBlocks(!1)){let b=a.getRelativeToSurfaceXY();b.y<20&&a.moveBy(0,20-b.y);if(a.RTL){let c=-20,d=this.miniWorkspace.getFlyout();d&&(c-=d.getWidth());b.x>c&&a.moveBy(c-b.x,0)}else b.x<20&&a.moveBy(20-b.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()||ri.mover.isMoving()){this.autoLayout&&(this.autoLayout=!ri.mover.isMoving());var a=this.getSize(),b=
1183
- this.calculateWorkspaceSize();Math.abs(a.width-b.width)<tn.MINIMUM_VIEW_CHANGE&&Math.abs(a.height-b.height)<tn.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${b.width}px`),this.svgDialog.setAttribute("height",`${b.height}px`),this.miniWorkspace.setCachedParentSvgSize(b.width,b.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${b.width}, 0)`),this.setSize(new hc(b.width+sn.DOUBLE_BORDER,b.height+sn.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),
1184
- this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var a=this.miniWorkspace.getCanvas().getBBox(),b=a.width+tn.MARGIN;a=a.height+tn.MARGIN;var c=this.miniWorkspace.getFlyout();if(c){let d=c.getWorkspace().getMetricsManager().getScrollMetrics();a=Math.max(a,d.height+20);b+=c.getWidth()}return new hc(b,a)}updateBlockStyles(){for(var a of this.miniWorkspace.getAllBlocks(!1))a.setStyle(a.getStyleName());var b;if(a=(b=this.miniWorkspace.getFlyout())==null?void 0:b.getWorkspace())for(let c of a.getAllBlocks(!1))c.setStyle(c.getStyleName())}moveDuringDrag(a){super.moveDuringDrag(a);
1185
- this.autoLayout=!1}moveTo(a,b){super.moveTo(a,b);this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts");}performAction(){$.t().focusTree(this.getWorkspace())}};tn.MINIMUM_VIEW_CHANGE=10;tn.MARGIN=sn.DOUBLE_BORDER*3;var un=class{constructor(a){this.sourceBlock=a;this.offsetInBlock=new D(0,0);this.workspaceLocation=new D(0,0);this.svgRoot=null;this.tooltip=a;this.id=Lb()}getType(){throw Error("Icons must implement getType");}initView(a){if(!this.svgRoot){var b=this.sourceBlock;this.svgRoot=r(q.G,{"class":"blocklyIconGroup",id:this.id});b.getSvgRoot().appendChild(this.svgRoot);this.updateSvgRootOffset();k(this.svgRoot,"pointerdown",this,a);this.svgRoot.tooltip=this;Hf(this.svgRoot);this.recomputeAriaContext()}}dispose(){this.svgRoot&&
1184
+ this.calculateWorkspaceSize();Math.abs(a.width-b.width)<un.MINIMUM_VIEW_CHANGE&&Math.abs(a.height-b.height)<un.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${b.width}px`),this.svgDialog.setAttribute("height",`${b.height}px`),this.miniWorkspace.setCachedParentSvgSize(b.width,b.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${b.width}, 0)`),this.setSize(new hc(b.width+tn.DOUBLE_BORDER,b.height+tn.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),
1185
+ this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var a=this.miniWorkspace.getCanvas().getBBox(),b=a.width+un.MARGIN;a=a.height+un.MARGIN;var c=this.miniWorkspace.getFlyout();if(c){let d=c.getWorkspace().getMetricsManager().getScrollMetrics();a=Math.max(a,d.height+20);b+=c.getWidth()}return new hc(b,a)}updateBlockStyles(){for(var a of this.miniWorkspace.getAllBlocks(!1))a.setStyle(a.getStyleName());var b;if(a=(b=this.miniWorkspace.getFlyout())==null?void 0:b.getWorkspace())for(let c of a.getAllBlocks(!1))c.setStyle(c.getStyleName())}moveDuringDrag(a){super.moveDuringDrag(a);
1186
+ this.autoLayout=!1}moveTo(a,b){super.moveTo(a,b);this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts");}performAction(){$.t().focusTree(this.getWorkspace())}};un.MINIMUM_VIEW_CHANGE=10;un.MARGIN=tn.DOUBLE_BORDER*3;var vn=class{constructor(a){this.sourceBlock=a;this.offsetInBlock=new D(0,0);this.workspaceLocation=new D(0,0);this.svgRoot=null;this.tooltip=a;this.id=Lb()}getType(){throw Error("Icons must implement getType");}initView(a){if(!this.svgRoot){var b=this.sourceBlock;this.svgRoot=r(q.G,{"class":"blocklyIconGroup",id:this.id});b.getSvgRoot().appendChild(this.svgRoot);this.updateSvgRootOffset();k(this.svgRoot,"pointerdown",this,a);this.svgRoot.tooltip=this;Hf(this.svgRoot);this.recomputeAriaContext()}}dispose(){this.svgRoot&&
1186
1187
  (If(this.svgRoot),delete this.svgRoot.tooltip,Oa(this.svgRoot));this.tooltip=""}getWeight(){return-1}getSize(){return new hc(0,0)}setTooltip(a){this.tooltip=a!=null?a:this.sourceBlock}getTooltip(){return this.tooltip}applyColour(){}updateEditable(){}updateCollapsed(){this.svgRoot&&(this.sourceBlock.isCollapsed()?this.svgRoot.style.display="none":this.svgRoot.style.display="block",xd(this)&&this.setBubbleVisible(!1))}hideForInsertionMarker(){this.svgRoot&&(this.svgRoot.style.display="none")}isShownWhenCollapsed(){return!1}setOffsetInBlock(a){this.offsetInBlock=
1187
1188
  a;this.updateSvgRootOffset()}updateSvgRootOffset(){var a;(a=this.svgRoot)==null||a.setAttribute("transform",`translate(${this.offsetInBlock.x}, ${this.offsetInBlock.y})`)}onLocationChange(a){this.workspaceLocation=D.sum(a,this.offsetInBlock)}onClick(){}isClickableInFlyout(){return!0}getFocusableElement(){var a=this.svgRoot;if(!a)throw Error("Attempting to focus uninitialized icon.");return a}getFocusableTree(){return this.sourceBlock.workspace}onNodeFocus(){var a=this.sourceBlock.getBoundingRectangle();
1188
1189
  a=new cc(a.top+this.offsetInBlock.y,a.top+this.offsetInBlock.y+this.getSize().height,a.left+this.offsetInBlock.x,a.left+this.offsetInBlock.x+this.getSize().width);this.sourceBlock.workspace.scrollBoundsIntoView(a)}onNodeBlur(){}canBeFocused(){return!0}performAction(){this.onClick();cd().then(()=>{if(xd(this)&&this.bubbleIsVisible()){let a=this.getBubble();a&&$.t().focusNode(a)}})}getSourceBlock(){return this.sourceBlock}showContextMenu(a){this.getSourceBlock().showContextMenu(a)}recomputeAriaContext(){var a=
1189
- this.getFocusableElement();if(a){var b,c=(b=this.sourceBlock.workspace.targetWorkspace)==null?void 0:b.getFlyout();if(c&&!this.isClickableInFlyout(c.autoClose))l(a,p.HIDDEN,!0);else{za(a,p.HIDDEN);ya(a,Ka.BUTTON);var d;b=(d=this.getAriaLabel())!=null?d:$.C.ICON_LABEL_DEFAULT;l(a,p.LABEL,b)}}}getAriaLabel(){return null}};$.sh=class extends un{constructor(a,b){super(b);this.flyoutBlockTypes=a;this.sourceBlock=b;this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return $.sh.TYPE}initView(a){this.svgRoot||(super.initView(a),r(q.RECT,{"class":"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),r(q.PATH,{"class":"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},
1190
+ this.getFocusableElement();if(a){var b,c=(b=this.sourceBlock.workspace.targetWorkspace)==null?void 0:b.getFlyout();if(c&&!this.isClickableInFlyout(c.autoClose))l(a,p.HIDDEN,!0);else{za(a,p.HIDDEN);ya(a,Ka.BUTTON);var d;b=(d=this.getAriaLabel())!=null?d:$.C.ICON_LABEL_DEFAULT;l(a,p.LABEL,b)}}}getAriaLabel(){return null}};$.sh=class extends vn{constructor(a,b){super(b);this.flyoutBlockTypes=a;this.sourceBlock=b;this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return $.sh.TYPE}initView(a){this.svgRoot||(super.initView(a),r(q.RECT,{"class":"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),r(q.PATH,{"class":"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},
1190
1191
  this.svgRoot),r(q.CIRCLE,{"class":"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),n(this.svgRoot,"blocklyMutatorIcon"))}dispose(){super.dispose();var a;(a=this.miniWorkspaceBubble)==null||a.dispose()}getWeight(){return $.sh.WEIGHT}getSize(){return new hc(17,17)}applyColour(){super.applyColour();var a;(a=this.miniWorkspaceBubble)==null||a.setColour(this.sourceBlock.getColour());var b;(b=this.miniWorkspaceBubble)==null||b.updateBlockStyles()}updateCollapsed(){super.updateCollapsed();this.sourceBlock.isCollapsed()&&
1191
1192
  this.setBubbleVisible(!1)}onLocationChange(a){super.onLocationChange(a);var b;(b=this.miniWorkspaceBubble)==null||b.setAnchorLocation(this.getAnchorLocation())}onClick(){super.onClick();this.sourceBlock.isEditable()&&this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.miniWorkspaceBubble}setBubbleVisible(a){var b=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(b.bubbleIsVisible()!==a){yield cd();if(a){b.miniWorkspaceBubble=
1192
- new tn(b.getMiniWorkspaceConfig(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect(),b);b.applyColour();b.createRootBlock();b.addSaveConnectionsListener();let c;(c=b.miniWorkspaceBubble)==null||c.addWorkspaceChangeListener(b.createMiniWorkspaceChangeListener());b.miniWorkspaceBubble.setAriaLabelProvider($.C.WORKSPACE_LABEL_MUTATOR_WORKSPACE)}else{let c;(c=b.miniWorkspaceBubble)==null||c.dispose();b.miniWorkspaceBubble=null;b.saveConnectionsListener&&b.sourceBlock.workspace.removeChangeListener(b.saveConnectionsListener);
1193
+ new un(b.getMiniWorkspaceConfig(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect(),b);b.applyColour();b.createRootBlock();b.addSaveConnectionsListener();let c;(c=b.miniWorkspaceBubble)==null||c.addWorkspaceChangeListener(b.createMiniWorkspaceChangeListener());b.miniWorkspaceBubble.setAriaLabelProvider($.C.WORKSPACE_LABEL_MUTATOR_WORKSPACE)}else{let c;(c=b.miniWorkspaceBubble)==null||c.dispose();b.miniWorkspaceBubble=null;b.saveConnectionsListener&&b.sourceBlock.workspace.removeChangeListener(b.saveConnectionsListener);
1193
1194
  b.saveConnectionsListener=null}w(new (u(v.BUBBLE_OPEN))(b.sourceBlock,a,"mutator"));b.recomputeAriaContext()}})}getBubble(){return this.miniWorkspaceBubble}getMiniWorkspaceConfig(){var a,b={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:(a=this.sourceBlock.workspace.options.rendererOverrides)!=null?a:void 0};this.flyoutBlockTypes.length&&(b.toolbox={kind:"flyoutToolbox",contents:this.flyoutBlockTypes.map(c=>
1194
1195
  ({kind:"block",type:c}))});return b}getAnchorLocation(){return D.sum(this.workspaceLocation,new D(8.5,8.5))}getBubbleOwnerRect(){var a=this.sourceBlock.getSvgRoot().getBBox();return new cc(a.y,a.y+a.height,a.x,a.x+a.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace());for(var a of this.rootBlock.getDescendants(!1))a.queueRender();this.rootBlock.setMovable(!1);
1195
1196
  this.rootBlock.setDeletable(!1);var b,c,d,e;a=(e=(b=this.miniWorkspaceBubble)==null?void 0:(c=b.getWorkspace())==null?void 0:(d=c.getFlyout())==null?void 0:d.getWidth())!=null?e:0;this.rootBlock.moveBy(this.rootBlock.RTL?-(a+16):16,16)}addSaveConnectionsListener(){this.sourceBlock.saveConnections&&this.rootBlock&&(this.saveConnectionsListener=()=>{this.sourceBlock.saveConnections&&this.rootBlock&&this.sourceBlock.saveConnections(this.rootBlock)},this.saveConnectionsListener(),this.sourceBlock.workspace.addChangeListener(this.saveConnectionsListener))}createMiniWorkspaceChangeListener(){return a=>
1196
- {$.sh.isIgnorableMutatorEvent(a)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null;this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(a){return a.isUiEvent||a.type===v.BLOCK_CREATE||a.type===v.BLOCK_CHANGE&&a.element==="disabled"}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var a=$.gd;a||$.B(!0);var b=El.getExtraBlockState_(this.sourceBlock);
1197
- this.sourceBlock.compose(this.rootBlock);var c=El.getExtraBlockState_(this.sourceBlock);b!==c&&w(new (u(v.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,b,c));$.B(a)}}getWorkspace(){var a;return(a=this.miniWorkspaceBubble)==null?void 0:a.getWorkspace()}getAriaLabel(){return this.bubbleIsVisible()?$.C.ICON_LABEL_MUTATOR_OPEN:$.C.ICON_LABEL_MUTATOR_CLOSED}};$.sh.TYPE=Zg.MUTATOR;$.sh.WEIGHT=1;var nh=Object.create(null),vn={allExtensions:nh};$.oh("parent_tooltip_when_inline",function(){var a=this.tooltip;this.setTooltip(function(){var b=this.getParent();return b&&b.getInputsInline()&&b.tooltip||a}.bind(this))});var wn={TEST_ONLY:vn};wn.apply=wh;wn.buildTooltipForDropdown=$.yh;wn.buildTooltipWithFieldText=$.Ah;wn.isRegistered=uh;wn.register=$.oh;wn.registerMixin=$.ph;wn.registerMutator=$.th;
1198
- wn.runAfterPageLoad=function(a){if(typeof document!=="object")throw Error("runAfterPageLoad() requires browser document.");if(document.readyState==="complete")a();else{let b=setInterval(function(){document.readyState==="complete"&&(clearInterval(b),a())},10)}};wn.unregister=function(a){uh(a)?delete nh[a]:console.warn('No extension mapping for name "'+a+'" found to unregister')};var xn={};xn.arc=Gh;xn.curve=Bh;xn.line=Fh;xn.lineOnAxis=I;xn.lineTo=Eh;xn.moveBy=Dh;xn.moveTo=Ch;xn.point=H;var yn={};yn.Coordinate=D;yn.KeyCodes=L;yn.Rect=cc;yn.Size=hc;yn.Svg=q;yn.aria=Mk;yn.array=Bk;yn.browserEvents=Ak;yn.colour=Wm;yn.deprecation=Uk;yn.dom=Ok;yn.extensions=wn;yn.idGenerator=Zk;yn.math=Sm;yn.object=Rk;yn.parsing=Xm;yn.string=Um;yn.style=al;yn.svgMath=bl;yn.svgPaths=xn;yn.toolbox=gl;yn.userAgent=zk;yn.xml=el;var zn=class extends sn{constructor(a,b,c,d){super(a,b,c,void 0,d);this.workspace=a;this.anchor=b;this.ownerRect=c;this.owner=d;this.resizePointerMoveListener=this.resizePointerUpListener=null;this.sizeChangeListeners=[];this.locationChangeListeners=[];this.DEFAULT_SIZE=new hc(160+sn.DOUBLE_BORDER,80+sn.DOUBLE_BORDER);this.MIN_SIZE=new hc(45+sn.DOUBLE_BORDER,20+sn.DOUBLE_BORDER);this.editable=!0;this.textChangeListener=()=>{this.recomputeAriaContext()};n(this.svgRoot,"blocklyTextInputBubble");this.editor=
1199
- new fn(a,this.id,()=>{$.t().focusNode(this)});this.contentContainer.appendChild(this.editor.getDom());this.resizeGroup=this.createResizeHandle(this.svgRoot,a);this.setSize(this.DEFAULT_SIZE,!0);this.addTextChangeListener(this.textChangeListener)}getText(){return this.editor.getText()}setText(a){this.editor.setText(a)}setEditable(a){this.editable=a;this.editor.setEditable(a)}isEditable(){return this.editable}addTextChangeListener(a){this.editor.addTextChangeListener(a)}addSizeChangeListener(a){this.sizeChangeListeners.push(a)}addLocationChangeListener(a){this.locationChangeListeners.push(a)}createResizeHandle(a,
1200
- b){a=r(q.IMAGE,{"class":"blocklyResizeHandle",href:`${b.options.pathToMedia}resize-handle.svg`},a);k(a,"pointerdown",this,this.onResizePointerDown);return a}setSize(a,b=!1){a.width=Math.max(a.width,this.MIN_SIZE.width);a.height=Math.max(a.height,this.MIN_SIZE.height);var c=a.width-sn.DOUBLE_BORDER,d=a.height-sn.DOUBLE_BORDER;this.editor.updateSize(new hc(c,d),new hc(0,0));this.editor.getDom().setAttribute("x",`${sn.DOUBLE_BORDER/2}`);this.editor.getDom().setAttribute("y",`${sn.DOUBLE_BORDER/2}`);
1201
- this.resizeGroup.setAttribute("y",`${d}`);this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-sn.DOUBLE_BORDER}`):this.resizeGroup.setAttribute("x",`${c}`);super.setSize(a,b);this.onSizeChange()}getSize(){return super.getSize()}moveDuringDrag(a){super.moveDuringDrag(a);this.onLocationChange()}setPositionRelativeToAnchor(a,b){super.setPositionRelativeToAnchor(a,b);this.onLocationChange()}positionByRect(a=new cc(0,0,0,0)){super.positionByRect(a);this.onLocationChange()}onResizePointerDown(a){this.bringToFront();
1197
+ {$.sh.isIgnorableMutatorEvent(a)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null;this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(a){return a.isUiEvent||a.type===v.BLOCK_CREATE||a.type===v.BLOCK_CHANGE&&a.element==="disabled"}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var a=$.gd;a||$.B(!0);var b=Fl.getExtraBlockState_(this.sourceBlock);
1198
+ this.sourceBlock.compose(this.rootBlock);var c=Fl.getExtraBlockState_(this.sourceBlock);b!==c&&w(new (u(v.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,b,c));$.B(a)}}getWorkspace(){var a;return(a=this.miniWorkspaceBubble)==null?void 0:a.getWorkspace()}getAriaLabel(){return this.bubbleIsVisible()?$.C.ICON_LABEL_MUTATOR_OPEN:$.C.ICON_LABEL_MUTATOR_CLOSED}};$.sh.TYPE=Zg.MUTATOR;$.sh.WEIGHT=1;var nh=Object.create(null),wn={allExtensions:nh};$.oh("parent_tooltip_when_inline",function(){var a=this.tooltip;this.setTooltip(function(){var b=this.getParent();return b&&b.getInputsInline()&&b.tooltip||a}.bind(this))});var xn={TEST_ONLY:wn};xn.apply=wh;xn.buildTooltipForDropdown=$.yh;xn.buildTooltipWithFieldText=$.Ah;xn.isRegistered=uh;xn.register=$.oh;xn.registerMixin=$.ph;xn.registerMutator=$.th;
1199
+ xn.runAfterPageLoad=function(a){if(typeof document!=="object")throw Error("runAfterPageLoad() requires browser document.");if(document.readyState==="complete")a();else{let b=setInterval(function(){document.readyState==="complete"&&(clearInterval(b),a())},10)}};xn.unregister=function(a){uh(a)?delete nh[a]:console.warn('No extension mapping for name "'+a+'" found to unregister')};var yn={};yn.arc=Gh;yn.curve=Bh;yn.line=Fh;yn.lineOnAxis=I;yn.lineTo=Eh;yn.moveBy=Dh;yn.moveTo=Ch;yn.point=H;var zn={};zn.Coordinate=D;zn.KeyCodes=L;zn.Rect=cc;zn.Size=hc;zn.Svg=q;zn.aria=Nk;zn.array=Ck;zn.browserEvents=Bk;zn.colour=Xm;zn.deprecation=Vk;zn.dom=Pk;zn.extensions=xn;zn.idGenerator=$k;zn.math=Tm;zn.object=Sk;zn.parsing=Ym;zn.string=Vm;zn.style=bl;zn.svgMath=cl;zn.svgPaths=yn;zn.toolbox=hl;zn.userAgent=Ak;zn.xml=fl;var An=class extends tn{constructor(a,b,c,d){super(a,b,c,void 0,d);this.workspace=a;this.anchor=b;this.ownerRect=c;this.owner=d;this.resizePointerMoveListener=this.resizePointerUpListener=null;this.sizeChangeListeners=[];this.locationChangeListeners=[];this.DEFAULT_SIZE=new hc(160+tn.DOUBLE_BORDER,80+tn.DOUBLE_BORDER);this.MIN_SIZE=new hc(45+tn.DOUBLE_BORDER,20+tn.DOUBLE_BORDER);this.editable=!0;this.textChangeListener=()=>{this.recomputeAriaContext()};n(this.svgRoot,"blocklyTextInputBubble");this.editor=
1200
+ new gn(a,this.id,()=>{$.t().focusNode(this)});this.contentContainer.appendChild(this.editor.getDom());this.resizeGroup=this.createResizeHandle(this.svgRoot,a);this.setSize(this.DEFAULT_SIZE,!0);this.addTextChangeListener(this.textChangeListener)}getText(){return this.editor.getText()}setText(a){this.editor.setText(a)}setEditable(a){this.editable=a;this.editor.setEditable(a)}isEditable(){return this.editable}addTextChangeListener(a){this.editor.addTextChangeListener(a)}addSizeChangeListener(a){this.sizeChangeListeners.push(a)}addLocationChangeListener(a){this.locationChangeListeners.push(a)}createResizeHandle(a,
1201
+ b){a=r(q.IMAGE,{"class":"blocklyResizeHandle",href:`${b.options.pathToMedia}resize-handle.svg`},a);k(a,"pointerdown",this,this.onResizePointerDown);return a}setSize(a,b=!1){a.width=Math.max(a.width,this.MIN_SIZE.width);a.height=Math.max(a.height,this.MIN_SIZE.height);var c=a.width-tn.DOUBLE_BORDER,d=a.height-tn.DOUBLE_BORDER;this.editor.updateSize(new hc(c,d),new hc(0,0));this.editor.getDom().setAttribute("x",`${tn.DOUBLE_BORDER/2}`);this.editor.getDom().setAttribute("y",`${tn.DOUBLE_BORDER/2}`);
1202
+ this.resizeGroup.setAttribute("y",`${d}`);this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-tn.DOUBLE_BORDER}`):this.resizeGroup.setAttribute("x",`${c}`);super.setSize(a,b);this.onSizeChange()}getSize(){return super.getSize()}moveDuringDrag(a){super.moveDuringDrag(a);this.onLocationChange()}setPositionRelativeToAnchor(a,b){super.setPositionRelativeToAnchor(a,b);this.onLocationChange()}positionByRect(a=new cc(0,0,0,0)){super.positionByRect(a);this.onLocationChange()}onResizePointerDown(a){this.bringToFront();
1202
1203
  na(a)||(Sg(this.workspace,a,new D(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=k(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=k(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff());a.stopPropagation()}onResizePointerUp(){ha=null;this.resizePointerUpListener&&(ka(this.resizePointerUpListener),this.resizePointerUpListener=null);this.resizePointerMoveListener&&(ka(this.resizePointerMoveListener),
1203
- this.resizePointerMoveListener=null)}onResizePointerMove(a){a=Tg(this.workspace,a);this.setSize(new hc(this.workspace.RTL?-a.x:a.x,a.y),!1);this.onSizeChange()}onSizeChange(){for(let a of this.sizeChangeListeners)a()}onLocationChange(){for(let a of this.locationChangeListeners)a()}getEditor(){return this.editor}performAction(){$.t().focusNode(this.getEditor())}dispose(){super.dispose();this.editor.removeTextChangeListener(this.textChangeListener)}};ta("\n.blocklyTextInputBubble .blocklyTextarea {\n background-color: var(--commentFillColour);\n border: 0;\n box-sizing: border-box;\n display: block;\n outline: 0;\n padding: 5px;\n resize: none;\n width: 100%;\n height: 100%;\n}\n");var An=class{constructor(a){this.connectionChecker=a;this.connections=[];this.bulkCounter=0}addConnection(a,b){b=this.calculateIndexForYPos(b);this.connections.splice(b,0,a)}findIndexOfConnection(a,b){if(!this.connections.length)return-1;var c=this.calculateIndexForYPos(b);if(c>=this.connections.length)return-1;b=a.y;for(var d=c;d>=0&&this.connections[d].y===b;){if(this.connections[d]===a)return d;d--}for(d=c;d<this.connections.length&&this.connections[d].y===b;){if(this.connections[d]===a)return d;
1204
+ this.resizePointerMoveListener=null)}onResizePointerMove(a){a=Tg(this.workspace,a);this.setSize(new hc(this.workspace.RTL?-a.x:a.x,a.y),!1);this.onSizeChange()}onSizeChange(){for(let a of this.sizeChangeListeners)a()}onLocationChange(){for(let a of this.locationChangeListeners)a()}getEditor(){return this.editor}performAction(){$.t().focusNode(this.getEditor())}dispose(){super.dispose();this.editor.removeTextChangeListener(this.textChangeListener)}};ta("\n.blocklyTextInputBubble .blocklyTextarea {\n background-color: var(--commentFillColour);\n border: 0;\n box-sizing: border-box;\n display: block;\n outline: 0;\n padding: 5px;\n resize: none;\n width: 100%;\n height: 100%;\n}\n");var Bn=class{constructor(a){this.connectionChecker=a;this.connections=[];this.bulkCounter=0}addConnection(a,b){b=this.calculateIndexForYPos(b);this.connections.splice(b,0,a)}findIndexOfConnection(a,b){if(!this.connections.length)return-1;var c=this.calculateIndexForYPos(b);if(c>=this.connections.length)return-1;b=a.y;for(var d=c;d>=0&&this.connections[d].y===b;){if(this.connections[d]===a)return d;d--}for(d=c;d<this.connections.length&&this.connections[d].y===b;){if(this.connections[d]===a)return d;
1204
1205
  d++}return-1}calculateIndexForYPos(a){if(!this.connections.length)return 0;for(var b=0,c=this.connections.length;b<c;){let d=Math.floor((b+c)/2);if(this.connections[d].y<a)b=d+1;else if(this.connections[d].y>a)c=d;else{b=d;break}}return b}removeConnection(a,b){a=this.findIndexOfConnection(a,b);if(a===-1)throw Error("Unable to find connection in connectionDB.");this.connections.splice(a,1)}reorderConnection(a,b){this.bulkCounter===0&&(this.removeConnection(a,a.y),this.addConnection(a,b))}getNeighbours(a,
1205
1206
  b){function c(z){var E=e-d[z].x,J=f-d[z].y;Math.sqrt(E*E+J*J)<=b&&m.push(d[z]);return J<b}var d=this.connections,e=a.x,f=a.y;a=0;for(var g=d.length-2,h=g;a<h;)d[h].y<f?a=h:g=h,h=Math.floor((a+g)/2);var m=[];g=a=h;if(d.length){for(;a>=0&&c(a);)a--;do g++;while(g<d.length&&c(g))}return m}isInYRange(a,b,c){return Math.abs(this.connections[a].y-b)<=c}searchForClosest(a,b,c){if(!this.connections.length)return{connection:null,radius:b};var d=a.y,e=a.x;a.x=e+c.x;a.y=d+c.y;var f=this.calculateIndexForYPos(a.y);
1206
1207
  c=null;for(var g=b,h,m=f-1;m>=0&&this.isInYRange(m,a.y,b);)h=this.connections[m],this.connectionChecker.canConnect(a,h,!0,g)&&(c=h,g=h.distanceFrom(a)),m--;for(;f<this.connections.length&&this.isInYRange(f,a.y,b);)h=this.connections[f],this.connectionChecker.canConnect(a,h,!0,g)&&(c=h,g=h.distanceFrom(a)),f++;a.x=e;a.y=d;return{connection:c,radius:g}}beginBulkUpdates(){this.bulkCounter++}endBulkUpdates(){if(this.bulkCounter===0)throw Error("Bulk updates are already ended.");this.bulkCounter--;this.bulkCounter===
1207
- 0&&this.reorderConnections()}reorderConnections(){this.connections.sort((a,b)=>a.y-b.y)}static init(a){var b=[];b[G.INPUT_VALUE]=new An(a);b[G.OUTPUT_VALUE]=new An(a);b[G.NEXT_STATEMENT]=new An(a);b[G.PREVIOUS_STATEMENT]=new An(a);return b}};var Bn=class{constructor(a,b){this.type=b;this.targetConnection=null;this.disposed=!1;this.shadowDom=this.check=null;this.y=this.x=0;this.shadowState=null;this.sourceBlock_=a;if(a.id.includes("_connection"))throw Error(`Connection ID indicator is contained in block ID. This will cause problems with focus: ${a.id}.`);this.id=`${a.id}_connection_${Lb()}`}connect_(a){var b=G.INPUT_VALUE,c=this.getSourceBlock(),d=a.getSourceBlock();a.isConnected()&&a.disconnectInternal(!1);if(this.isConnected()){let g=
1208
- this.stashShadowState(),h=this.targetBlock();if(h.isShadow())h.dispose(!1);else{this.disconnectInternal();var e=h}this.applyShadowState(g)}if(Vb()){var f=new (u(v.BLOCK_MOVE))(d);f.setReason(["connect"])}if(!this||!a)throw Error("Cannot connect null connections.");this.targetConnection=a;a.targetConnection=this;d.setParent(c);f&&(f.recordNew(),w(f));if(e&&(a=this.type===b?e.outputConnection:e.previousConnection))if(d=Bn.getConnectionForOrphanedConnection(d,a))a.connect(d);else a.onFailedConnect(this)}dispose(){if(this.isConnected()){this.isSuperior()&&
1208
+ 0&&this.reorderConnections()}reorderConnections(){this.connections.sort((a,b)=>a.y-b.y)}static init(a){var b=[];b[G.INPUT_VALUE]=new Bn(a);b[G.OUTPUT_VALUE]=new Bn(a);b[G.NEXT_STATEMENT]=new Bn(a);b[G.PREVIOUS_STATEMENT]=new Bn(a);return b}};var Cn=class{constructor(a,b){this.type=b;this.targetConnection=null;this.disposed=!1;this.shadowDom=this.check=null;this.y=this.x=0;this.shadowState=null;this.sourceBlock_=a;if(a.id.includes("_connection"))throw Error(`Connection ID indicator is contained in block ID. This will cause problems with focus: ${a.id}.`);this.id=`${a.id}_connection_${Lb()}`}connect_(a){var b=G.INPUT_VALUE,c=this.getSourceBlock(),d=a.getSourceBlock();a.isConnected()&&a.disconnectInternal(!1);if(this.isConnected()){let g=
1209
+ this.stashShadowState(),h=this.targetBlock();if(h.isShadow())h.dispose(!1);else{this.disconnectInternal();var e=h}this.applyShadowState(g)}if(Vb()){var f=new (u(v.BLOCK_MOVE))(d);f.setReason(["connect"])}if(!this||!a)throw Error("Cannot connect null connections.");this.targetConnection=a;a.targetConnection=this;d.setParent(c);f&&(f.recordNew(),w(f));if(e&&(a=this.type===b?e.outputConnection:e.previousConnection))if(d=Cn.getConnectionForOrphanedConnection(d,a))a.connect(d);else a.onFailedConnect(this)}dispose(){if(this.isConnected()){this.isSuperior()&&
1209
1210
  this.setShadowStateInternal();let a=this.targetBlock();a&&!a.isDeadOrDying()&&a.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===G.INPUT_VALUE||this.type===G.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(){}connect(a){if(this.targetConnection===a)return!0;if(this.getConnectionChecker().canConnect(this,a,!1)){let b=$.gd;b||$.B(!0);this.isSuperior()?
1210
1211
  this.connect_(a):a.connect_(this);$.B(b)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(a=!0){var {parentConnection:b,childConnection:c}=this.getParentAndChildConnections();if(!b||!c)throw Error("Source connection not connected.");var d=$.gd;d||$.B(!0);if(Vb()){var e=new (u(v.BLOCK_MOVE))(c.getSourceBlock());e.setReason(["disconnect"])}var f=this.targetConnection;f&&(f.targetConnection=null);this.targetConnection=null;a&&c.getSourceBlock().setParent(null);e&&(e.recordNew(),
1211
1212
  w(e));c.getSourceBlock().isShadow()||b.respawnShadow_();$.B(d)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock(!0)}reconnect(a,b){if(this.getSourceBlock().isDeadOrDying())return!1;var c;b=(c=a.getInput(b))==null?void 0:c.connection;c=this.targetBlock();return c&&c!==a||!b||b.targetConnection===this?!1:(b.isConnected()&&
@@ -1215,7 +1216,7 @@ this.targetBlock().isShadow()?Wg(this.targetBlock()):this.shadowDom}setShadowSta
1215
1216
  return{shadowDom:a,shadowState:b}}applyShadowState({shadowDom:a,shadowState:b}){this.shadowDom=a;this.shadowState=b}setShadowStateInternal({shadowDom:a=null,shadowState:b=null}={}){this.shadowDom=a;this.shadowState=b;this.getSourceBlock().isDeadOrDying()||((a=this.targetBlock())?a.isShadow()?(a.dispose(!1),this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())):(a=this.createShadowBlock(!1),this.serializeShadow(a),a&&a.dispose(!1)):(this.respawnShadow_(),
1216
1217
  this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())))}createShadowBlock(a){var b=this.getSourceBlock(),c=this.getShadowState(),d=this.getShadowDom();if(b.isDeadOrDying()||!c&&!d)return null;if(c)return b=de(c,b.workspace,{parentConnection:a?this:void 0,isShadow:!0,recordUndo:!1});if(d){b=Ng(d,b.workspace);if(a)if(this.type===G.INPUT_VALUE){if(!b.outputConnection)throw Error("Shadow block is missing an output connection");if(!this.connect(b.outputConnection))throw Error("Could not connect shadow block to connection");
1217
1218
  }else if(this.type===G.NEXT_STATEMENT){if(!b.previousConnection)throw Error("Shadow block is missing previous connection");if(!this.connect(b.previousConnection))throw Error("Could not connect shadow block to connection");}else throw Error("Cannot connect a shadow block to a previous/output connection");return b}return null}serializeShadow(a){a&&(this.shadowDom=Wg(a),this.shadowState=ce(a))}static getConnectionForOrphanedConnection(a,b){if(b.type===G.OUTPUT_VALUE){a:{b=b.getSourceBlock();for(var c;c=
1218
- Hh(a,b);)if(a=c.targetBlock(),!a||a.isShadow()){b=c;break a}b=null}return b}a=a.lastConnectionInStack(!0);c=b.getConnectionChecker();return a&&c.canConnect(b,a,!1)?a:null}};Bn.CAN_CONNECT=0;Bn.REASON_SELF_CONNECTION=1;Bn.REASON_WRONG_TYPE=2;Bn.REASON_TARGET_NULL=3;Bn.REASON_CHECKS_FAILED=4;Bn.REASON_DIFFERENT_WORKSPACES=5;Bn.REASON_SHADOW_PARENT=6;Bn.REASON_DRAG_CHECKS_FAILED=7;Bn.REASON_PREVIOUS_AND_OUTPUT=8;var Cn=class extends Error{constructor(a){super(`Tried to append an icon of type ${a.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`);this.icon=a}},Dn={};Dn.DuplicateIconType=Cn;var Fn;Fn=$.En||($.En={});Fn[Fn.LEFT=-1]="LEFT";Fn[Fn.CENTRE=0]="CENTRE";Fn[Fn.RIGHT=1]="RIGHT";var Gn=[];Gn[G.INPUT_VALUE]=G.OUTPUT_VALUE;Gn[G.OUTPUT_VALUE]=G.INPUT_VALUE;Gn[G.NEXT_STATEMENT]=G.PREVIOUS_STATEMENT;Gn[G.PREVIOUS_STATEMENT]=G.NEXT_STATEMENT;var Mi=class extends Bn{constructor(a,b){super(a,b);this.highlighted=!1;this.targetConnection=null;this.db=a.workspace.connectionDBList[b];this.dbOpposite=a.workspace.connectionDBList[Gn[b]];this.offsetInBlock=new D(0,0);this.trackedState=Mi.TrackedState.WILL_TRACK}dispose(){super.dispose();this.trackedState===Mi.TrackedState.TRACKED&&this.db.removeConnection(this,this.y);var a,b;(b=(a=this.sourceBlock_.pathObject).removeConnectionHighlight)==null||b.call(a,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(a){var b=
1219
+ Hh(a,b);)if(a=c.targetBlock(),!a||a.isShadow()){b=c;break a}b=null}return b}a=a.lastConnectionInStack(!0);c=b.getConnectionChecker();return a&&c.canConnect(b,a,!1)?a:null}};Cn.CAN_CONNECT=0;Cn.REASON_SELF_CONNECTION=1;Cn.REASON_WRONG_TYPE=2;Cn.REASON_TARGET_NULL=3;Cn.REASON_CHECKS_FAILED=4;Cn.REASON_DIFFERENT_WORKSPACES=5;Cn.REASON_SHADOW_PARENT=6;Cn.REASON_DRAG_CHECKS_FAILED=7;Cn.REASON_PREVIOUS_AND_OUTPUT=8;var Dn=class extends Error{constructor(a){super(`Tried to append an icon of type ${a.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`);this.icon=a}},En={};En.DuplicateIconType=Dn;var Gn;Gn=$.Fn||($.Fn={});Gn[Gn.LEFT=-1]="LEFT";Gn[Gn.CENTRE=0]="CENTRE";Gn[Gn.RIGHT=1]="RIGHT";var Hn=[];Hn[G.INPUT_VALUE]=G.OUTPUT_VALUE;Hn[G.OUTPUT_VALUE]=G.INPUT_VALUE;Hn[G.NEXT_STATEMENT]=G.PREVIOUS_STATEMENT;Hn[G.PREVIOUS_STATEMENT]=G.NEXT_STATEMENT;var Mi=class extends Cn{constructor(a,b){super(a,b);this.highlighted=!1;this.targetConnection=null;this.db=a.workspace.connectionDBList[b];this.dbOpposite=a.workspace.connectionDBList[Hn[b]];this.offsetInBlock=new D(0,0);this.trackedState=Mi.TrackedState.WILL_TRACK}dispose(){super.dispose();this.trackedState===Mi.TrackedState.TRACKED&&this.db.removeConnection(this,this.y);var a,b;(b=(a=this.sourceBlock_.pathObject).removeConnectionHighlight)==null||b.call(a,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(a){var b=
1219
1220
  this.x-a.x;a=this.y-a.y;return Math.sqrt(b*b+a*a)}bumpAwayFrom(a,b=!1){if(!this.sourceBlock_.workspace.isDragging()){var c=$.Og.snapRadius+Math.floor(Math.random()*10),d=$.Og.snapRadius+Math.floor(Math.random()*10),e=a.sourceBlock_.getRootBlock(),f=this.sourceBlock_.getRootBlock();if(!e.isInFlyout&&!f.isInFlyout){var g=!0;if(f.isMovable())e.isMovable()&&b&&(d=-d);else if(e.isMovable())g=!1,c=-c,d=-d;else return;b=g?a:this;a=g?this:a;e=g?f:e;e.RTL&&(c=-c);e.moveBy(b.x+c-a.x,b.y+d-a.y,["bump"])}}}moveTo(a,
1220
1221
  b){var c=this.x!==a||this.y!==b,d=!1;this.trackedState===Mi.TrackedState.WILL_TRACK?(this.db.addConnection(this,b),this.trackedState=Mi.TrackedState.TRACKED,d=!0):this.trackedState===Mi.TrackedState.TRACKED&&c&&(this.db.reorderConnection(this,b),d=!0);this.x=a;this.y=b;return d}moveBy(a,b){return this.moveTo(this.x+a,this.y+b)}moveToOffset(a){return this.moveTo(a.x+this.offsetInBlock.x,a.y+this.offsetInBlock.y)}setOffsetInBlock(a,b){this.offsetInBlock.x=a;this.offsetInBlock.y=b}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var a=
1221
1222
  this.targetConnection,b=this.targetBlock();a&&b&&(a=D.difference(this.offsetInBlock,a.offsetInBlock),this.insertionMarker&&(this.type===G.INPUT_VALUE?a.x+=this.insertionMarker.getHeightWidth().width:a.y+=this.insertionMarker.getHeightWidth().height),b.translate(a.x,a.y))}closest(a,b){return this.dbOpposite.searchForClosest(this,a,b)}setAriaRole(a){var b=this.type===G.INPUT_VALUE?$.C.INPUT_LABEL_VALUE:$.C.INPUT_LABEL_STATEMENT;ya(a,Ka.FIGURE);l(a,p.ROLEDESCRIPTION,b)}recomputeAriaContext(a){this.setAriaRole(a);
@@ -1224,17 +1225,17 @@ requestAnimationFrame(()=>{var b=a.parentElement;if(b)for(;a.nextSibling;)b.inse
1224
1225
  (this.trackedState===Mi.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=Mi.TrackedState.UNTRACKED))}stopTrackingAll(){this.setTracking(!1);if(this.targetConnection){let a=this.targetBlock().getDescendants(!1);for(let b=0;b<a.length;b++){let c=a[b],d=c.getConnections_(!0);for(let e=0;e<d.length;e++)d[e].setTracking(!1);for(let e of c.getIcons())xd(e)&&e.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);var a=[];if(this.type!==G.INPUT_VALUE&&this.type!==G.NEXT_STATEMENT)return a;
1225
1226
  var b=this.targetBlock();if(b){let c;b.isCollapsed()?(c=[],b.outputConnection&&c.push(b.outputConnection),b.nextConnection&&c.push(b.nextConnection),b.previousConnection&&c.push(b.previousConnection)):c=b.getConnections_(!0);for(let d=0;d<c.length;d++)a.push(...c[d].startTrackingAll());a.length||(a=[b])}return a}onFailedConnect(a){var b=this.getSourceBlock();if($.Qc){let c=$.gd;setTimeout(function(){b.isDisposed()||b.getParent()||($.B(c),this.bumpAwayFrom(a),$.B(!1))}.bind(this),$.Og.bumpDelay)}}disconnectInternal(a=
1226
1227
  !0){var {parentConnection:b,childConnection:c}=this.getParentAndChildConnections();if(b&&c){var d=$.gd;d||$.B(!0);var e=b.getSourceBlock(),f=c.getSourceBlock();super.disconnectInternal(a);e.queueRender();f.updateDisabled();f.queueRender();f.getSvgRoot().style.display="block";$.B(d)}}respawnShadow_(){super.respawnShadow_();var a=this.targetBlock();a&&(a.initSvg(),a.queueRender())}neighbours(a){return this.dbOpposite.getNeighbours(this,a)}connect_(a){super.connect_(a);var b=this.getSourceBlock();a=
1227
- a.getSourceBlock();b.updateDisabled();a.updateDisabled();a.queueRender();if(b=b.getInputWithBlock(a))b=b.isVisible(),a.getSvgRoot().style.display=b?"block":"none"}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(a){super.setCheck(a);this.sourceBlock_.queueRender();return this}showContextMenu(a){var b=Kj.registry.getContextMenuOptions({focusedNode:this},
1228
+ a.getSourceBlock();b.updateDisabled();a.updateDisabled();a.queueRender();if(b=b.getInputWithBlock(a))b=b.isVisible(),a.getSvgRoot().style.display=b?"block":"none"}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(a){super.setCheck(a);this.sourceBlock_.queueRender();return this}showContextMenu(a){var b=Lj.registry.getContextMenuOptions({focusedNode:this},
1228
1229
  a);if(b.length){var c=this.getSourceBlock(),d=c.workspace;if(a instanceof PointerEvent)var e=new D(a.clientX,a.clientY);else e=new D(this.x,this.y),e=pc(d,e).translate(c.RTL?-5:5,5);Hg(a,b,c.RTL,d,e)}}getFocusableElement(){var a=this.findHighlightSvg();if(a)return a;throw Error("No highlight SVG found corresponding to this connection.");}getFocusableTree(){return this.getSourceBlock().workspace}onNodeFocus(){this.highlight();var a=this.getSourceBlock();a.workspace.isFlyout||a.moveSvgRootToFront();
1229
- a.workspace.scrollBoundsIntoView(a.getBoundingRectangleWithoutChildren())}onNodeBlur(){this.unhighlight()}canBeFocused(){return this.findHighlightSvg()!==null}findHighlightSvg(){return this.getSourceBlock().getSvgRoot().getRootNode().getElementById(this.id)}attachInsertionMarker(a){this.insertionMarker=a}detachInsertionMarker(){this.insertionMarker=void 0}getInsertionMarker(){return this.insertionMarker}},Hn=Mi||(Mi={}),In=Hn.TrackedState||(Hn.TrackedState={});In[In.WILL_TRACK=-1]="WILL_TRACK";
1230
- In[In.UNTRACKED=0]="UNTRACKED";In[In.TRACKED=1]="TRACKED";var Jn=class{constructor(a,b){this.name=a;this.sourceBlock=b;this.fieldRow=[];this.align=$.En.LEFT;this.visible=!0;this.ariaLabelProvider=null;this.type=$.je.CUSTOM;this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(a,b){this.insertFieldAt(this.fieldRow.length,a,b);return this}insertFieldAt(a,b,c){if(a<0||a>this.fieldRow.length)throw Error("index "+a+" out of bounds.");if(!(b||b===""&&c))return a;typeof b==="string"&&(b=$.lh({type:"field_label",text:b}));b.setSourceBlock(this.sourceBlock);
1230
+ a.workspace.scrollBoundsIntoView(a.getBoundingRectangleWithoutChildren())}onNodeBlur(){this.unhighlight()}canBeFocused(){return this.findHighlightSvg()!==null}findHighlightSvg(){return this.getSourceBlock().getSvgRoot().getRootNode().getElementById(this.id)}attachInsertionMarker(a){this.insertionMarker=a}detachInsertionMarker(){this.insertionMarker=void 0}getInsertionMarker(){return this.insertionMarker}},In=Mi||(Mi={}),Jn=In.TrackedState||(In.TrackedState={});Jn[Jn.WILL_TRACK=-1]="WILL_TRACK";
1231
+ Jn[Jn.UNTRACKED=0]="UNTRACKED";Jn[Jn.TRACKED=1]="TRACKED";var Kn=class{constructor(a,b){this.name=a;this.sourceBlock=b;this.fieldRow=[];this.align=$.Fn.LEFT;this.visible=!0;this.ariaLabelProvider=null;this.type=$.je.CUSTOM;this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(a,b){this.insertFieldAt(this.fieldRow.length,a,b);return this}insertFieldAt(a,b,c){if(a<0||a>this.fieldRow.length)throw Error("index "+a+" out of bounds.");if(!(b||b===""&&c))return a;typeof b==="string"&&(b=$.lh({type:"field_label",text:b}));b.setSourceBlock(this.sourceBlock);
1231
1232
  this.sourceBlock.initialized&&this.initField(b);b.name=c;b.setVisible(this.isVisible());b.prefixField&&(a=this.insertFieldAt(a,b.prefixField));this.fieldRow.splice(a,0,b);a++;b.suffixField&&(a=this.insertFieldAt(a,b.suffixField));this.sourceBlock.rendered&&this.sourceBlock.queueRender();return a}removeField(a,b){for(let c=0,d;d=this.fieldRow[c];c++)if(d.name===a)return d.dispose(),this.fieldRow.splice(c,1),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),!0;if(b)return!1;throw Error('Field "'+
1232
1233
  a+'" not found.');}isVisible(){return this.visible}setVisible(a){var b=[];if(this.visible===a)return b;this.visible=a;for(let c=0,d;d=this.fieldRow[c];c++)d.setVisible(a);if(this.connection&&this.connection instanceof Mi){a?b=this.connection.startTrackingAll():this.connection.stopTrackingAll();let c=this.connection.targetBlock();c&&(c.getSvgRoot().style.display=a?"block":"none")}return b}markDirty(){for(let a=0,b;b=this.fieldRow[a];a++)b.markDirty()}setCheck(a){if(!this.connection)throw Error("This input does not have a connection.");
1233
1234
  this.connection.setCheck(a);return this}setAlign(a){this.align=a;this.sourceBlock.rendered&&this.sourceBlock.queueRender();return this}setShadowDom(a){if(!this.connection)throw Error("This input does not have a connection.");this.connection.setShadowDom(a);return this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){for(let a of this.fieldRow)a.init()}setAriaLabelProvider(a){this.ariaLabelProvider=a;return this}getAriaLabelText(){return this.ariaLabelProvider?
1234
1235
  typeof this.ariaLabelProvider==="string"?hg(this.ariaLabelProvider):this.ariaLabelProvider(this):null}initModel(){for(let a of this.fieldRow)a.initModel()}initField(a){this.sourceBlock.rendered?a.init():a.initModel()}dispose(){for(let a=0,b;b=this.fieldRow[a];a++)b.dispose();this.connection&&this.connection.dispose()}makeConnection(a){return this.sourceBlock.makeConnection_(a)}getRowId(){var a=this.getSourceBlock().inputList;if(this===a.find(f=>f.isVisible())||this===a[0])return this.getSourceBlock().getRowId();
1235
1236
  var b=a.indexOf(this),c,d=((c=a[b-1].connection)==null?void 0:c.type)===G.NEXT_STATEMENT,e;return((e=this.connection)==null?void 0:e.type)===G.NEXT_STATEMENT||d?`${this.getSourceBlock().id}-input${b}`:a[b-1].getRowId()}getLabel(a=we.STANDARD,b=!0){if(!this.isVisible())return"";var c=De(this,!1,a),d;b&&((d=this.connection)==null?void 0:d.type)===G.INPUT_VALUE&&(b=this.connection.targetBlock())&&!b.isInsertionMarker()&&c.push(ze(b,a).join(", "));return c.join(", ")}getIndex(){var a=[$.je.DUMMY,$.je.END_ROW];
1236
- return this.getSourceBlock().inputList.filter(b=>!a.includes(b.type)).indexOf(this)}};var Kn=class extends Jn{constructor(a,b){super(a,b);this.name=a;this.type=$.je.DUMMY}};var Ln=class extends Jn{constructor(a,b){super(a,b);this.name=a;this.type=$.je.END_ROW}};var Mn=class extends Jn{constructor(a,b){if(!a)throw Error("Statement inputs must have a non-empty name");super(a,b);this.name=a;this.type=$.je.STATEMENT;this.connection=this.makeConnection(G.NEXT_STATEMENT)}};$.Nn=class extends Jn{constructor(a,b){if(!a)throw Error("Value inputs must have a non-empty name");super(a,b);this.name=a;this.type=$.je.VALUE;this.connection=this.makeConnection(G.INPUT_VALUE)}};var On=class{constructor(a,b,c){this.data=null;this.disposed=!1;this.hue=null;this.colour_="#000000";this.styleName_="";this.suppressPrefixSuffix=!1;this.previousConnection=this.nextConnection=this.outputConnection=null;this.inputList=[];this.icons=[];this.disabledReasons=new Set;this.tooltip="";this.contextMenu=!0;this.parentBlock_=null;this.childBlocks_=[];this.editable=this.movable=this.deletable=!0;this.collapsed_=this.shadow=!1;this.outputShape_=null;this.rendered=this.isInsertionMarker_=this.initialized=
1237
- this.disposing=!1;this.onchangeWrapper=this.helpUrl=null;this.statementInputCount=0;this.workspace=a;this.id=c&&!a.getBlockById(c)?c:Nb();a.setBlockById(this.id,this);this.xy=new D(0,0);this.isInFlyout=a.isFlyout;this.isInMutator=a.isMutator;this.RTL=a.RTL;if(b){this.type=b;c=zb[b];if(!c||typeof c!=="object")throw TypeError("Invalid block definition for type: "+b);Object.assign(this,c)}a.addTopBlock(this);a.addTypedBlock(this);new.target===On&&this.doInit_()}doInit_(){var a=$.gd;a||$.B(!0);var b=
1237
+ return this.getSourceBlock().inputList.filter(b=>!a.includes(b.type)).indexOf(this)}};var Ln=class extends Kn{constructor(a,b){super(a,b);this.name=a;this.type=$.je.DUMMY}};var Mn=class extends Kn{constructor(a,b){super(a,b);this.name=a;this.type=$.je.END_ROW}};var Nn=class extends Kn{constructor(a,b){if(!a)throw Error("Statement inputs must have a non-empty name");super(a,b);this.name=a;this.type=$.je.STATEMENT;this.connection=this.makeConnection(G.NEXT_STATEMENT)}};$.On=class extends Kn{constructor(a,b){if(!a)throw Error("Value inputs must have a non-empty name");super(a,b);this.name=a;this.type=$.je.VALUE;this.connection=this.makeConnection(G.INPUT_VALUE)}};var Pn=class{constructor(a,b,c){this.data=null;this.disposed=!1;this.hue=null;this.colour_="#000000";this.styleName_="";this.suppressPrefixSuffix=!1;this.previousConnection=this.nextConnection=this.outputConnection=null;this.inputList=[];this.icons=[];this.disabledReasons=new Set;this.tooltip="";this.contextMenu=!0;this.parentBlock_=null;this.childBlocks_=[];this.editable=this.movable=this.deletable=!0;this.collapsed_=this.shadow=!1;this.outputShape_=null;this.rendered=this.isInsertionMarker_=this.initialized=
1238
+ this.disposing=!1;this.onchangeWrapper=this.helpUrl=null;this.statementInputCount=0;this.workspace=a;this.id=c&&!a.getBlockById(c)?c:Nb();a.setBlockById(this.id,this);this.xy=new D(0,0);this.isInFlyout=a.isFlyout;this.isInMutator=a.isMutator;this.RTL=a.RTL;if(b){this.type=b;c=zb[b];if(!c||typeof c!=="object")throw TypeError("Invalid block definition for type: "+b);Object.assign(this,c)}a.addTopBlock(this);a.addTypedBlock(this);new.target===Pn&&this.doInit_()}doInit_(){var a=$.gd;a||$.B(!0);var b=
1238
1239
  $.Qc;try{typeof this.init==="function"&&($.Qc=!1,this.init(),$.Qc=b),Vb()&&w(new (u(v.BLOCK_CREATE))(this))}finally{$.B(a),$.Qc=b}this.inputsInlineDefault=this.inputsInline;typeof this.onchange==="function"&&this.setOnChange(this.onchange)}dispose(a=!1){this.disposing=!0;this.tooltip="";this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper);this.unplug(a);Vb()&&w(new (u(v.BLOCK_DELETE))(this));this.workspace.removeTopBlock(this);this.disposeInternal()}disposeInternal(){this.disposing=
1239
1240
  !0;this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper);this.workspace.removeTypedBlock(this);this.workspace.removeBlockById(this.id);typeof this.destroy==="function"&&this.destroy();this.childBlocks_.forEach(a=>a.disposeInternal());this.inputList.forEach(a=>a.dispose());this.inputList.length=0;this.getConnections_(!0).forEach(a=>a.dispose());this.disposed=!0}isDeadOrDying(){return this.disposing||this.disposed}initModel(){if(!this.initialized){for(let a of this.inputList)a.initModel();
1240
1241
  this.initialized=!0}}unplug(a){this.outputConnection&&this.unplugFromRow(a);this.previousConnection&&this.unplugFromStack(a)}unplugFromRow(a){var b=null,c;if((c=this.outputConnection)==null?0:c.isConnected())b=this.outputConnection.targetConnection,this.outputConnection.disconnect();b&&a&&(a=this.getOnlyValueConnection())&&a.isConnected()&&!a.targetBlock().isShadow()&&(a=a.targetConnection,a==null||a.disconnect(),this.workspace.connectionChecker.canConnect(a,b,!1)?b.connect(a):a==null||a.onFailedConnect(b))}getOnlyValueConnection(){var a=
@@ -1251,39 +1252,39 @@ a}getTooltip(){return Bf(this)}getColour(){return this.colour_}getStyleName(){re
1251
1252
  a.getId()===b.getValue()&&b.refreshVariableName()}renameVarById(a,b){for(let c of this.getFields())c.referencesVariables()&&a===c.getValue()&&c.setValue(b)}getFieldValue(a){return(a=this.getField(a))?a.getValue():null}setFieldValue(a,b){var c=this.getField(b);if(!c)throw Error('Field "'+b+'" not found.');c.setValue(a)}setPreviousStatement(a,b){if(a)b===void 0&&(b=null),this.previousConnection||(this.previousConnection=this.makeConnection_(G.PREVIOUS_STATEMENT)),this.previousConnection.setCheck(b);
1252
1253
  else if(this.previousConnection){if(this.previousConnection.isConnected())throw Error("Must disconnect previous statement before removing connection.");this.previousConnection.dispose();this.previousConnection=null}}setNextStatement(a,b){if(a)b===void 0&&(b=null),this.nextConnection||(this.nextConnection=this.makeConnection_(G.NEXT_STATEMENT)),this.nextConnection.setCheck(b);else if(this.nextConnection){if(this.nextConnection.isConnected())throw Error("Must disconnect next statement before removing connection.");
1253
1254
  this.nextConnection.dispose();this.nextConnection=null}}setOutput(a,b){if(a)b===void 0&&(b=null),this.outputConnection||(this.outputConnection=this.makeConnection_(G.OUTPUT_VALUE)),this.outputConnection.setCheck(b);else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose();this.outputConnection=null}}setInputsInline(a){this.inputsInline!==a&&(w(new (u(v.BLOCK_CHANGE))(this,"inline",null,
1254
- this.inputsInline,a)),this.inputsInline=a)}getInputsInline(){if(this.inputsInline!==void 0)return this.inputsInline;for(var a=1;a<this.inputList.length;a++)if(this.inputList[a-1]instanceof Kn&&this.inputList[a]instanceof Kn)return!1;for(a=1;a<this.inputList.length;a++)if(this.inputList[a-1]instanceof $.Nn&&this.inputList[a]instanceof Kn)return!0;for(a=0;a<this.inputList.length;a++)if(this.inputList[a]instanceof Ln)return!0;return!1}setOutputShape(a){this.outputShape_=a}getOutputShape(){return this.outputShape_}isEnabled(){return this.disabledReasons.size===
1255
+ this.inputsInline,a)),this.inputsInline=a)}getInputsInline(){if(this.inputsInline!==void 0)return this.inputsInline;for(var a=1;a<this.inputList.length;a++)if(this.inputList[a-1]instanceof Ln&&this.inputList[a]instanceof Ln)return!1;for(a=1;a<this.inputList.length;a++)if(this.inputList[a-1]instanceof $.On&&this.inputList[a]instanceof Ln)return!0;for(a=0;a<this.inputList.length;a++)if(this.inputList[a]instanceof Mn)return!0;return!1}setOutputShape(a){this.outputShape_=a}getOutputShape(){return this.outputShape_}isEnabled(){return this.disabledReasons.size===
1255
1256
  0}setDisabledReason(a,b){a||this.workspace.options.disable||!this.hasDisabledReason("MANUALLY_DISABLED")||b=="MANUALLY_DISABLED"||this.setDisabledReason(!1,"MANUALLY_DISABLED");this.disabledReasons.has(b)!==a&&(a?this.disabledReasons.add(b):this.disabledReasons.delete(b),a=new (u(v.BLOCK_CHANGE))(this,"disabled",null,!a,a),a.setDisabledReason(b),w(a))}getInheritedDisabled(){for(var a=this.getSurroundParent();a;){if(!a.isEnabled())return!0;a=a.getSurroundParent()}return!1}hasDisabledReason(a){return this.disabledReasons.has(a)}getDisabledReasons(){return this.disabledReasons}isCollapsed(){return this.collapsed_}setCollapsed(a){this.collapsed_!==
1256
1257
  a&&(w(new (u(v.BLOCK_CHANGE))(this,"collapsed",null,this.collapsed_,a)),this.collapsed_=a)}setAriaRoleDescriptionProvider(a){this.ariaRoleDescriptionProvider=a}getAriaRoleDescription(){return this.ariaRoleDescriptionProvider?typeof this.ariaRoleDescriptionProvider==="function"?this.ariaRoleDescriptionProvider():hg(this.ariaRoleDescriptionProvider):this.statementInputCount?$.C.BLOCK_LABEL_CONTAINER:this.outputConnection?$.C.BLOCK_LABEL_VALUE:$.C.BLOCK_LABEL_STATEMENT}toString(a,b){b=this.toTokens(b);
1257
1258
  for(let d=2;d<b.length;d++)b[d-2]==="("&&b[d]===")"&&(b[d-2]=b[d-1],b.splice(d-1,2));var c="";b=b.reduce((d,e)=>{d=d+(c==="("||e===")"?"":" ")+e;c=e[e.length-1];return d},"");b=b.trim()||"???";a&&b.length>a&&(b=b.substring(0,a-3)+"...");return b}toTokens(a="?"){var b=[];for(let d of this.inputList)if(d.name!="_TEMP_COLLAPSED_INPUT"){for(let e of d.fieldRow)b.push(e.getText());if(d.connection){let e=d.connection.targetBlock();if(e){var c=d.connection;let f=c.getCheck();!f&&c.targetConnection&&(f=c.targetConnection.getCheck());
1258
- (c=!!f&&(f.includes("Boolean")||f.includes("Number")))&&b.push("(");b.push(...e.toTokens(a));c&&b.push(")")}else b.push(a)}}return b}appendValueInput(a){return this.appendInput(new $.Nn(a,this))}appendStatementInput(a){this.statementInputCount++;return this.appendInput(new Mn(a,this))}appendDummyInput(a=""){return this.appendInput(new Kn(a,this))}appendEndRowInput(a=""){return this.appendInput(new Ln(a,this))}appendInput(a){this.inputList.push(a);return a}appendInputFromRegistry(a,b){return(a=Fb(y.INPUT,
1259
+ (c=!!f&&(f.includes("Boolean")||f.includes("Number")))&&b.push("(");b.push(...e.toTokens(a));c&&b.push(")")}else b.push(a)}}return b}appendValueInput(a){return this.appendInput(new $.On(a,this))}appendStatementInput(a){this.statementInputCount++;return this.appendInput(new Nn(a,this))}appendDummyInput(a=""){return this.appendInput(new Ln(a,this))}appendEndRowInput(a=""){return this.appendInput(new Mn(a,this))}appendInput(a){this.inputList.push(a);return a}appendInputFromRegistry(a,b){return(a=Fb(y.INPUT,
1259
1260
  a,!1))?this.appendInput(new a(b,this)):null}jsonInit(a){var b=a.type?'Block "'+a.type+'": ':"";if(a.output&&a.previousStatement)throw Error(b+"Must not have both an output and a previousStatement.");for(var c=0;a[`args${c}`];){if(a[`message${c}`]===void 0)throw Error(b+`args${c} must have a corresponding message (message${c}).`);c++}a.style&&typeof a.style==="object"&&(this.hat=a.style.hat,a.style=null);if(a.style&&a.colour)throw Error(b+"Must not have both a colour and a style.");a.style?this.jsonInitStyle(a,
1260
1261
  b):this.jsonInitColour(a,b);for(c=0;a[`message${c}`]!==void 0;)this.interpolate(a[`message${c}`]||"",a[`args${c}`]||[],a[`implicitAlign${c}`]||a[`lastDummyAlign${c}`],b),c++;a.inputsInline!==void 0&&($.Ub++,this.setInputsInline(a.inputsInline),$.Ub--);a.output!==void 0&&this.setOutput(!0,a.output);a.outputShape!==void 0&&this.setOutputShape(a.outputShape);a.previousStatement!==void 0&&this.setPreviousStatement(!0,a.previousStatement);a.nextStatement!==void 0&&this.setNextStatement(!0,a.nextStatement);
1261
1262
  a.tooltip!==void 0&&(c=hg(a.tooltip),this.setTooltip(c));a.enableContextMenu!==void 0&&(this.contextMenu=!!a.enableContextMenu);a.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!a.suppressPrefixSuffix);a.helpUrl!==void 0&&(c=hg(a.helpUrl),this.setHelpUrl(c));a.ariaRoleDescription!==void 0&&this.setAriaRoleDescriptionProvider(a.ariaRoleDescription);typeof a.extensions==="string"&&(console.warn(b+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+
1262
1263
  a.type+"' block."),a.extensions=[a.extensions]);a.mutator!==void 0&&wh(a.mutator,this,!0);a=a.extensions;if(Array.isArray(a))for(b=0;b<a.length;b++)wh(a[b],this,!1)}jsonInitColour(a,b){if("colour"in a)if(a.colour===void 0)console.warn(b+"Undefined colour value.");else{a=a.colour;try{this.setColour(a)}catch(c){console.warn(b+"Illegal colour value: ",a)}}}jsonInitStyle(a,b){a=a.style;try{this.setStyle(a)}catch(c){console.warn(b+"Style does not exist: ",a)}}mixin(a,b){if(b!==void 0&&typeof b!=="boolean")throw Error("opt_disableCheck must be a boolean if provided");
1263
1264
  if(!b){b=[];for(let c in a)this[c]!==void 0&&b.push(c);if(b.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(b));}Object.assign(this,a)}interpolate(a,b,c,d){a=gg(a);this.validateTokens(a,b.length);b=this.interpolateArguments(a,b,c);c=[];for(let e=0,f;f=b[e];e++)if(this.isInputKeyword(f.type)){if(a=this.inputFromJson(f,d)){for(let g=0,h;h=c[g];g++)a.appendField(h[0],h[1]);c.length=0}}else(a=this.fieldFromJson(f))&&c.push([a,f.name])}validateTokens(a,b){var c=[],d=0;for(let e=
1264
1265
  0;e<a.length;e++){let f=a[e];if(typeof f==="number"){if(f<1||f>b)throw Error('Block "'+this.type+'": Message index %'+f+" out of range.");if(c[f])throw Error('Block "'+this.type+'": Message index %'+f+" duplicated.");c[f]=!0;d++}}if(d!==b)throw Error('Block "'+this.type+'": Message does not reference all '+b+" arg(s).");}interpolateArguments(a,b,c){var d=[];for(let f=0;f<a.length;f++){var e=a[f];typeof e==="number"&&(e=b[e-1]);if(typeof e==="string")if(e==="\n")e={type:"input_end_row"},c&&(e.align=
1265
- c);else if(e=this.stringToFieldJson(e),!e)continue;d.push(e)}(a=d.length)&&!this.isInputKeyword(d[a-1].type)&&(a={type:"input_dummy"},c&&(a.align=c),d.push(a));return d}fieldFromJson(a){var b=$.lh(a);return!b&&a.alt?typeof a.alt==="string"?(a=this.stringToFieldJson(a.alt))?this.fieldFromJson(a):null:this.fieldFromJson(a.alt):b}inputFromJson(a,b){var c={LEFT:$.En.LEFT,RIGHT:$.En.RIGHT,CENTRE:$.En.CENTRE,CENTER:$.En.CENTRE};switch(a.type){case "input_value":var d=this.appendValueInput(a.name);break;
1266
+ c);else if(e=this.stringToFieldJson(e),!e)continue;d.push(e)}(a=d.length)&&!this.isInputKeyword(d[a-1].type)&&(a={type:"input_dummy"},c&&(a.align=c),d.push(a));return d}fieldFromJson(a){var b=$.lh(a);return!b&&a.alt?typeof a.alt==="string"?(a=this.stringToFieldJson(a.alt))?this.fieldFromJson(a):null:this.fieldFromJson(a.alt):b}inputFromJson(a,b){var c={LEFT:$.Fn.LEFT,RIGHT:$.Fn.RIGHT,CENTRE:$.Fn.CENTRE,CENTER:$.Fn.CENTRE};switch(a.type){case "input_value":var d=this.appendValueInput(a.name);break;
1266
1267
  case "input_statement":d=this.appendStatementInput(a.name);break;case "input_dummy":d=this.appendDummyInput(a.name);break;case "input_end_row":d=this.appendEndRowInput(a.name);break;default:d=this.appendInputFromRegistry(a.type,a.name)}if(!d)return null;a.check&&d.setCheck(a.check);a.align&&(c=c[a.align.toUpperCase()],c===void 0?console.warn(b+"Illegal align value: ",a.align):d.setAlign(c));a.ariaLabelText&&d.setAriaLabelProvider(a.ariaLabelText);return d}isInputKeyword(a){return a==="input_value"||
1267
1268
  a==="input_statement"||a==="input_dummy"||a==="input_end_row"||Gb(y.INPUT,a)}stringToFieldJson(a){return(a=a.trim())?{type:"field_label",text:a}:null}moveInputBefore(a,b){if(a!==b){var c=-1,d=b?-1:this.inputList.length;for(let e=0,f;f=this.inputList[e];e++)if(f.name===a){if(c=e,d!==-1)break}else if(b&&f.name===b&&(d=e,c!==-1))break;if(c===-1)throw Error('Named input "'+a+'" not found.');if(d===-1)throw Error('Reference input "'+b+'" not found.');this.moveNumberedInputBefore(c,d)}}moveNumberedInputBefore(a,
1268
- b){if(a===b)throw Error("Can't move input to itself.");if(a>=this.inputList.length)throw RangeError("Input index "+a+" out of bounds.");if(b>this.inputList.length)throw RangeError("Reference input "+b+" out of bounds.");var c=this.inputList[a];this.inputList.splice(a,1);a<b&&b--;this.inputList.splice(b,0,c)}removeInput(a,b){for(let c=0,d;d=this.inputList[c];c++)if(d.name===a)return d instanceof Mn&&this.statementInputCount--,d.dispose(),this.inputList.splice(c,1),!0;if(b)return!1;throw Error("Input not found: "+
1269
+ b){if(a===b)throw Error("Can't move input to itself.");if(a>=this.inputList.length)throw RangeError("Input index "+a+" out of bounds.");if(b>this.inputList.length)throw RangeError("Reference input "+b+" out of bounds.");var c=this.inputList[a];this.inputList.splice(a,1);a<b&&b--;this.inputList.splice(b,0,c)}removeInput(a,b){for(let c=0,d;d=this.inputList[c];c++)if(d.name===a)return d instanceof Nn&&this.statementInputCount--,d.dispose(),this.inputList.splice(c,1),!0;if(b)return!1;throw Error("Input not found: "+
1269
1270
  a);}getInput(a){for(let b=0,c;c=this.inputList[b];b++)if(c.name===a)return c;return null}getInputTargetBlock(a){return(a=this.getInput(a))&&a.connection&&a.connection.targetBlock()}getCommentText(){var a,b;return(b=(a=this.getIcon(Zg.COMMENT))==null?void 0:a.getText())!=null?b:null}setCommentText(a){var b,c,d=(c=(b=this.getIcon(Zg.COMMENT))==null?void 0:b.getText())!=null?c:null;if(d!==a){if(a!==null){b=this.getIcon(Zg.COMMENT);if(!b){b=Fb(y.ICON,Zg.COMMENT.toString(),!1);if(!b)throw Error("No comment icon class is registered, so a comment cannot be set");
1270
1271
  b=new b(this);if(!(Ih(b)&&xd(b)&&Vc(b)&&typeof b.setText==="function"&&typeof b.getText==="function"&&typeof b.setBubbleSize==="function"&&typeof b.getBubbleSize==="function"&&typeof b.setBubbleLocation==="function"&&typeof b.getBubbleLocation==="function"&&b.getType()===Zg.COMMENT))throw Error("The class registered as a comment icon does not conform to the ICommentIcon interface");b=this.addIcon(b)}$.Ub++;b.setText(a);$.Ub--}else this.removeIcon(Zg.COMMENT);w(new (u(v.BLOCK_CHANGE))(this,"comment",
1271
- null,d,a))}}setWarningText(){}setMutator(){}addIcon(a){if(this.hasIcon(a.getType()))throw new Cn(a);this.icons.push(a);this.icons.sort((b,c)=>b.getWeight()-c.getWeight());return a}removeIcon(a){if(!this.hasIcon(a))return!1;var b;(b=this.getIcon(a))==null||b.dispose();this.icons=this.icons.filter(c=>!c.getType().equals(a));return!0}hasIcon(a){return this.icons.some(b=>b.getType().equals(a))}getIcon(a){return a instanceof Zg?this.icons.find(b=>b.getType().equals(a)):this.icons.find(b=>b.getType().toString()===
1272
- a)}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy.clone()}moveBy(a,b,c){if(this.parentBlock_)throw Error("Block has parent");var d=new (u(v.BLOCK_MOVE))(this);c&&d.setReason(c);this.xy.translate(a,b);d.recordNew();w(d)}makeConnection_(a){return new Bn(this,a)}allInputsFilled(a){a===void 0&&(a=!0);if(!a&&this.isShadow())return!1;for(let c=0,d;d=this.inputList[c];c++){if(!d.connection)continue;var b=d.connection.targetBlock();if(!b||!b.allInputsFilled(a))return!1}return(b=
1273
- this.getNextBlock())?b.allInputsFilled(a):!0}toDevString(){var a=this.type?'"'+this.type+'" block':"Block";this.id&&(a+=' (id="'+this.id+'")');return a}};On.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";On.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";var Qh=null,Nh=null,Pn={};Pn.connectionUiEffect=Lh;Pn.disconnectUiEffect=Ph;Pn.disconnectUiStop=Mh;Pn.disposeUiEffect=Kh;var Qn=class{paste(a,b,c){if(!b.isCapacityAvailable(a.typeCounts))return null;c&&(a.blockState.x=c.x,a.blockState.y=c.y);c=c!=null?c:new D(a.blockState.x||0,a.blockState.y||0);$.Ub++;try{var d=ee(a.blockState,b);Th(d,c)}finally{$.Ub--}if(!d)return d;Vb()&&!d.isShadow()&&w(new (u(v.BLOCK_CREATE))(d));var e=d;cd().then(()=>$.t().focusNode(e));return d}};Qn.TYPE="block";Sc(Qn.TYPE,new Qn);var Rn={};Rn.bumpIntoBounds=Uh;Rn.bumpIntoBoundsHandler=Xh;Rn.bumpTopObjectsIntoBounds=Wh;var Yh=null,Zh=null,ai=void 0,Sn={};Sn.BlockPaster=Qn;Sn.copy=bi;Sn.getLastCopiedData=function(){return Yh};Sn.getLastCopiedLocation=function(){return ai};Sn.getLastCopiedWorkspace=function(){return Zh};Sn.paste=di;Sn.registry=ul;Sn.setLastCopiedData=function(a){Yh=a};Sn.setLastCopiedLocation=function(a){ai=a};Sn.setLastCopiedWorkspace=function(a){Zh=a};var Tn={};Tn.CollapseCommentBarButton=en;Tn.CommentBarButton=dn;Tn.CommentEditor=fn;Tn.CommentView=hn;Tn.DeleteCommentBarButton=gn;Tn.RenderedWorkspaceComment=dh;Tn.WorkspaceComment=eh;var Di=class{constructor(a,b,c,d){this.workspace=a;this.targetWorkspace=b;this.isFlyoutLabel=d;this.height=this.width=0;this.cursorSvg=this.svgText=null;this.text=c.text;this.position=new D(0,0);this.callbackKey=c.callbackKey||c.callbackkey;this.cssClass=c["web-class"]||null;this.info=c;a=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton";this.cssClass&&(a+=" "+this.cssClass);this.id=Lb();this.svgGroup=r(q.G,{id:this.id,"class":a},this.workspace.getCanvas());if(!this.isFlyoutLabel){var e=
1272
+ null,d,a))}}setWarningText(){}setMutator(){}addIcon(a){if(this.hasIcon(a.getType()))throw new Dn(a);this.icons.push(a);this.icons.sort((b,c)=>b.getWeight()-c.getWeight());return a}removeIcon(a){if(!this.hasIcon(a))return!1;var b;(b=this.getIcon(a))==null||b.dispose();this.icons=this.icons.filter(c=>!c.getType().equals(a));return!0}hasIcon(a){return this.icons.some(b=>b.getType().equals(a))}getIcon(a){return a instanceof Zg?this.icons.find(b=>b.getType().equals(a)):this.icons.find(b=>b.getType().toString()===
1273
+ a)}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy.clone()}moveBy(a,b,c){if(this.parentBlock_)throw Error("Block has parent");var d=new (u(v.BLOCK_MOVE))(this);c&&d.setReason(c);this.xy.translate(a,b);d.recordNew();w(d)}makeConnection_(a){return new Cn(this,a)}allInputsFilled(a){a===void 0&&(a=!0);if(!a&&this.isShadow())return!1;for(let c=0,d;d=this.inputList[c];c++){if(!d.connection)continue;var b=d.connection.targetBlock();if(!b||!b.allInputsFilled(a))return!1}return(b=
1274
+ this.getNextBlock())?b.allInputsFilled(a):!0}toDevString(){var a=this.type?'"'+this.type+'" block':"Block";this.id&&(a+=' (id="'+this.id+'")');return a}};Pn.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";Pn.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";var Qh=null,Nh=null,Qn={};Qn.connectionUiEffect=Lh;Qn.disconnectUiEffect=Ph;Qn.disconnectUiStop=Mh;Qn.disposeUiEffect=Kh;var Rn=class{paste(a,b,c){if(!b.isCapacityAvailable(a.typeCounts))return null;c&&(a.blockState.x=c.x,a.blockState.y=c.y);c=c!=null?c:new D(a.blockState.x||0,a.blockState.y||0);$.Ub++;try{var d=ee(a.blockState,b);Th(d,c)}finally{$.Ub--}if(!d)return d;Vb()&&!d.isShadow()&&w(new (u(v.BLOCK_CREATE))(d));var e=d;cd().then(()=>$.t().focusNode(e));return d}};Rn.TYPE="block";Sc(Rn.TYPE,new Rn);var Sn={};Sn.bumpIntoBounds=Uh;Sn.bumpIntoBoundsHandler=Xh;Sn.bumpTopObjectsIntoBounds=Wh;var Yh=null,Zh=null,ai=void 0,Tn={};Tn.BlockPaster=Rn;Tn.copy=bi;Tn.getLastCopiedData=function(){return Yh};Tn.getLastCopiedLocation=function(){return ai};Tn.getLastCopiedWorkspace=function(){return Zh};Tn.paste=di;Tn.registry=vl;Tn.setLastCopiedData=function(a){Yh=a};Tn.setLastCopiedLocation=function(a){ai=a};Tn.setLastCopiedWorkspace=function(a){Zh=a};var Un={};Un.CollapseCommentBarButton=fn;Un.CommentBarButton=en;Un.CommentEditor=gn;Un.CommentView=jn;Un.DeleteCommentBarButton=hn;Un.RenderedWorkspaceComment=dh;Un.WorkspaceComment=eh;var Di=class{constructor(a,b,c,d){this.workspace=a;this.targetWorkspace=b;this.isFlyoutLabel=d;this.height=this.width=0;this.cursorSvg=this.svgText=null;this.text=c.text;this.position=new D(0,0);this.callbackKey=c.callbackKey||c.callbackkey;this.cssClass=c["web-class"]||null;this.info=c;a=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton";this.cssClass&&(a+=" "+this.cssClass);this.id=Lb();this.svgGroup=r(q.G,{id:this.id,"class":a},this.workspace.getCanvas());if(!this.isFlyoutLabel){var e=
1274
1275
  r(q.RECT,{"class":"blocklyFlyoutButtonShadow",rx:Di.BORDER_RADIUS,ry:Di.BORDER_RADIUS,x:1,y:1},this.svgGroup);ya(e,Ka.NONE)}a=r(q.RECT,{"class":this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:Di.BORDER_RADIUS,ry:Di.BORDER_RADIUS},this.svgGroup);ya(a,Ka.NONE);b=r(q.TEXT,{"class":this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup);c=hg(this.text);this.workspace.RTL&&(c+="\u200f");b.textContent=c;this.isFlyoutLabel&&
1275
1276
  (this.svgText=b,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill"));ya(b,Ka.NONE);d=`${c}, ${this.isFlyoutLabel?$.C.ARIA_LABEL_HEADING:$.C.ARIA_LABEL_BUTTON}`;l(this.getFocusableElement(),p.LABEL,d);ya(this.getFocusableElement(),Ka.OPTION);d=$b(b,"fontSize");var f=$b(b,"fontWeight"),g=$b(b,"fontFamily");this.width=Va(b,d,f,g);c=Ya(c,d,f,g);this.height=this.height||c.height;if(!this.isFlyoutLabel){this.width+=2*Di.TEXT_MARGIN_X;this.height+=2*Di.TEXT_MARGIN_Y;
1276
1277
  let h;(h=e)==null||h.setAttribute("width",String(this.width));let m;(m=e)==null||m.setAttribute("height",String(this.height))}a.setAttribute("width",String(this.width));a.setAttribute("height",String(this.height));b.setAttribute("x",String(this.width/2));b.setAttribute("y",String(this.height/2-c.height/2+c.baseline));this.updateTransform();this.onMouseDownWrapper=k(this.svgGroup,"pointerdown",this,this.onMouseDown);this.onMouseUpWrapper=k(this.svgGroup,"pointerup",this,this.onMouseUp)}createDom(){return this.svgGroup}show(){this.updateTransform();
1277
1278
  this.svgGroup.setAttribute("display","block")}updateTransform(){this.svgGroup.setAttribute("transform","translate("+this.position.x+","+this.position.y+")")}moveTo(a,b){this.position.x=a;this.position.y=b;this.updateTransform()}moveBy(a,b){this.moveTo(this.position.x+a,this.position.y+b)}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getBoundingRectangle(){return new cc(this.position.y,this.position.y+this.height,this.position.x,this.position.x+this.width)}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}getWorkspace(){return this.workspace}dispose(){ka(this.onMouseDownWrapper);
1278
1279
  ka(this.onMouseUpWrapper);this.svgGroup&&Oa(this.svgGroup);this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}setCursorSvg(a){a?this.svgGroup&&(this.svgGroup.appendChild(a),this.cursorSvg=a):this.cursorSvg=null}onMouseUp(a){(a=this.targetWorkspace.getGesture(a))&&a.cancel();this.isFlyoutLabel&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isFlyoutLabel||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?
1279
1280
  this.isFlyoutLabel||(a=this.targetWorkspace.getButtonCallback(this.callbackKey))&&a(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}onMouseDown(a){var b=this.targetWorkspace.getGesture(a),c=this.targetWorkspace.getFlyout();b&&c&&b.handleFlyoutStart(a,c)}getSvgRoot(){return this.svgGroup}getFocusableElement(){return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){var a=this.getPosition();a=new cc(a.y,a.y+this.height,a.x,a.x+this.width);this.workspace.scrollBoundsIntoView(a)}onNodeBlur(){}canBeFocused(){return!0}getId(){return this.id}performAction(){if(this.isFlyoutLabel){var a=
1280
- this.targetWorkspace;let b=$.C.KEYBOARD_NAV_FLYOUT_LABEL_HINT.replace("%1",re(K.NEXT_HEADING));li.show(a,{message:b,id:"flyoutLabelHint"})}else(a=this.targetWorkspace.getButtonCallback(this.callbackKey))&&a(this)}};Di.TEXT_MARGIN_X=5;Di.TEXT_MARGIN_Y=2;Di.BORDER_RADIUS=4;ta("\n.blocklyFlyoutButton {\n fill: #888;\n cursor: default;\n}\n\n.blocklyFlyoutButtonShadow {\n fill: #666;\n}\n\n@media (hover: hover) {\n .blocklyFlyoutButton:hover {\n fill: #aaa;\n }\n}\n\n.blocklyFlyoutButton:active {\n fill: #aaa;\n}\n\n.blocklyFlyoutLabel {\n cursor: default;\n}\n\n.blocklyFlyoutLabelBackground {\n opacity: 0;\n}\n");var Un,Vn=Un||(Un={});Vn[Vn.COMMIT=1]="COMMIT";Vn[Vn.DELETE=2]="DELETE";Vn[Vn.REVERT=3]="REVERT";var K,Wn=K||(K={});Wn.ESCAPE="escape";Wn.DELETE="delete";Wn.COPY="copy";Wn.CUT="cut";Wn.PASTE="paste";Wn.UNDO="undo";Wn.REDO="redo";Wn.MENU="menu";Wn.FOCUS_WORKSPACE="focus_workspace";Wn.FOCUS_TOOLBOX="focus_toolbox";Wn.START_MOVE="start_move";Wn.START_MOVE_STACK="start_move_stack";Wn.FINISH_MOVE="finish_move";Wn.ABORT_MOVE="abort_move";Wn.MOVE_UP="move_up";Wn.MOVE_DOWN="move_down";Wn.MOVE_LEFT="move_left";Wn.MOVE_RIGHT="move_right";Wn.NAVIGATE_RIGHT="right";Wn.NAVIGATE_LEFT="left";
1281
- Wn.NAVIGATE_UP="up";Wn.NAVIGATE_DOWN="down";Wn.DISCONNECT="disconnect";Wn.NEXT_STACK="next_stack";Wn.PREVIOUS_STACK="previous_stack";Wn.INFORMATION="information";Wn.EXTENDED_INFORMATION="extended_information";Wn.PERFORM_ACTION="perform_action";Wn.DUPLICATE="duplicate";Wn.CLEANUP="cleanup";Wn.SHOW_TOOLTIP="show_tooltip";Wn.NEXT_HEADING="next_heading";Wn.PREVIOUS_HEADING="previous_heading";Wn.TOGGLE_SCREENREADER="toggle_screenreader";Wn.JUMP_TOP_STACK="jump_to_top_of_stack";Wn.JUMP_BOTTOM_STACK="jump_to_bottom_of_stack";
1282
- Wn.JUMP_BLOCK_START="jump_to_block_start";Wn.JUMP_BLOCK_END="jump_to_block_end";Wn.JUMP_FIRST_BLOCK="jump_to_first_block";Wn.JUMP_LAST_BLOCK="jump_to_last_block";var wi=a=>{if(a.isFlyout){let c=a.targetWorkspace;if(c)return wi(c)}var b;return(b=a.getRootWorkspace())!=null?b:a},Ki=(a,b)=>!a.isFlyout&&!!b.focusedNode&&!a.isDragging()&&!$.t().ephemeralFocusTaken()&&!!a.getNavigator().getSourceBlockFromNode(b.focusedNode);Si();Ti();Ui();var Xn={};Xn.names=K;Xn.registerArrowNavigation=vi;
1283
- Xn.registerCleanup=Hi;Xn.registerCopy=mi;Xn.registerCut=ni;Xn.registerDefaultShortcuts=Si;Xn.registerDelete=ji;Xn.registerDisconnectBlock=Bi;Xn.registerDuplicate=Gi;Xn.registerEscape=hi;Xn.registerFocusToolbox=yi;Xn.registerFocusWorkspace=xi;Xn.registerHeadingNavigation=Ei;Xn.registerJumpBlockEnd=Ni;Xn.registerJumpBlockStart=Li;Xn.registerJumpBottomStack=Pi;Xn.registerJumpFirstBlock=Qi;Xn.registerJumpLastBlock=Ri;Xn.registerJumpTopStack=Oi;Xn.registerKeyboardNavigationShortcuts=Ti;
1284
- Xn.registerMovementShortcuts=ti;Xn.registerNavigationShortcuts=function(){Li();Ni();Oi();Pi();Qi();Ri()};Xn.registerPaste=oi;Xn.registerPerformAction=Fi;Xn.registerReadExtendedInformation=Ai;Xn.registerReadInformation=zi;Xn.registerRedo=qi;Xn.registerScreenReaderShortcuts=Ui;Xn.registerShowContextMenu=ui;Xn.registerShowTooltip=Ii;Xn.registerStackNavigation=Ci;Xn.registerToggleScreenreaderMode=Ji;Xn.registerUndo=pi;var Yn,Zn=Yn||(Yn={});Zn[Zn.CONSTRAINED=1]="CONSTRAINED";Zn[Zn.UNCONSTRAINED=2]="UNCONSTRAINED";
1285
- var $n=class{constructor(a){this.block=a;this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null;this.dragging=!1;this.allConnectionPairs=[];this.moveMode=Yn.UNCONSTRAINED;this.originalEventGroup="";this.lastBlockDisabledReasons=new Map;this.WORKSPACE_MARGIN=this.BLOCK_CONNECTION_OFFSET=10;this.workspace=a.workspace}isMovable(){var a;return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&!this.workspace.isReadOnly()&&(!this.block.isInFlyout||
1286
- this.block.isEnabled()&&!((a=this.block.workspace.targetWorkspace)==null?0:a.isReadOnly()))}positionNewBlock(a,b){a=pc(a.workspace,a.getRelativeToSurfaceXY());a=oc(b.workspace,a);b.moveDuringDrag(a);if(this.moveMode===Yn.CONSTRAINED){var c=b.workspace,d=this.WORKSPACE_MARGIN;a=this.WORKSPACE_MARGIN;var e=Math.max($.Og.connectingSnapRadius,$.Og.snapRadius)+2,f=c.getTopBlocks(!0).filter(T=>T.id!==b.id).map(T=>{T=T.getBoundingRectangle();return new cc(T.top-e,T.bottom+e,T.left-e,T.right+e)}),g,h=(g=
1281
+ this.targetWorkspace;let b=$.C.KEYBOARD_NAV_FLYOUT_LABEL_HINT.replace("%1",re(K.NEXT_HEADING));li.show(a,{message:b,id:"flyoutLabelHint"})}else(a=this.targetWorkspace.getButtonCallback(this.callbackKey))&&a(this)}};Di.TEXT_MARGIN_X=5;Di.TEXT_MARGIN_Y=2;Di.BORDER_RADIUS=4;ta("\n.blocklyFlyoutButton {\n fill: #888;\n cursor: default;\n}\n\n.blocklyFlyoutButtonShadow {\n fill: #666;\n}\n\n@media (hover: hover) {\n .blocklyFlyoutButton:hover {\n fill: #aaa;\n }\n}\n\n.blocklyFlyoutButton:active {\n fill: #aaa;\n}\n\n.blocklyFlyoutLabel {\n cursor: default;\n}\n\n.blocklyFlyoutLabelBackground {\n opacity: 0;\n}\n");var Vn,Wn=Vn||(Vn={});Wn[Wn.COMMIT=1]="COMMIT";Wn[Wn.DELETE=2]="DELETE";Wn[Wn.REVERT=3]="REVERT";var K,Xn=K||(K={});Xn.ESCAPE="escape";Xn.DELETE="delete";Xn.COPY="copy";Xn.CUT="cut";Xn.PASTE="paste";Xn.UNDO="undo";Xn.REDO="redo";Xn.MENU="menu";Xn.FOCUS_WORKSPACE="focus_workspace";Xn.FOCUS_TOOLBOX="focus_toolbox";Xn.START_MOVE="start_move";Xn.START_MOVE_STACK="start_move_stack";Xn.FINISH_MOVE="finish_move";Xn.ABORT_MOVE="abort_move";Xn.MOVE_UP="move_up";Xn.MOVE_DOWN="move_down";Xn.MOVE_LEFT="move_left";Xn.MOVE_RIGHT="move_right";Xn.NAVIGATE_RIGHT="right";Xn.NAVIGATE_LEFT="left";
1282
+ Xn.NAVIGATE_UP="up";Xn.NAVIGATE_DOWN="down";Xn.DISCONNECT="disconnect";Xn.NEXT_STACK="next_stack";Xn.PREVIOUS_STACK="previous_stack";Xn.INFORMATION="information";Xn.EXTENDED_INFORMATION="extended_information";Xn.PERFORM_ACTION="perform_action";Xn.DUPLICATE="duplicate";Xn.CLEANUP="cleanup";Xn.SHOW_TOOLTIP="show_tooltip";Xn.NEXT_HEADING="next_heading";Xn.PREVIOUS_HEADING="previous_heading";Xn.TOGGLE_SCREENREADER="toggle_screenreader";Xn.JUMP_TOP_STACK="jump_to_top_of_stack";Xn.JUMP_BOTTOM_STACK="jump_to_bottom_of_stack";
1283
+ Xn.JUMP_BLOCK_START="jump_to_block_start";Xn.JUMP_BLOCK_END="jump_to_block_end";Xn.JUMP_FIRST_BLOCK="jump_to_first_block";Xn.JUMP_LAST_BLOCK="jump_to_last_block";var wi=a=>{if(a.isFlyout){let c=a.targetWorkspace;if(c)return wi(c)}var b;return(b=a.getRootWorkspace())!=null?b:a},Ki=(a,b)=>!a.isFlyout&&!!b.focusedNode&&!a.isDragging()&&!$.t().ephemeralFocusTaken()&&!!a.getNavigator().getSourceBlockFromNode(b.focusedNode);Si();Ti();Ui();var Yn={};Yn.names=K;Yn.registerArrowNavigation=vi;
1284
+ Yn.registerCleanup=Hi;Yn.registerCopy=mi;Yn.registerCut=ni;Yn.registerDefaultShortcuts=Si;Yn.registerDelete=ji;Yn.registerDisconnectBlock=Bi;Yn.registerDuplicate=Gi;Yn.registerEscape=hi;Yn.registerFocusToolbox=yi;Yn.registerFocusWorkspace=xi;Yn.registerHeadingNavigation=Ei;Yn.registerJumpBlockEnd=Ni;Yn.registerJumpBlockStart=Li;Yn.registerJumpBottomStack=Pi;Yn.registerJumpFirstBlock=Qi;Yn.registerJumpLastBlock=Ri;Yn.registerJumpTopStack=Oi;Yn.registerKeyboardNavigationShortcuts=Ti;
1285
+ Yn.registerMovementShortcuts=ti;Yn.registerNavigationShortcuts=function(){Li();Ni();Oi();Pi();Qi();Ri()};Yn.registerPaste=oi;Yn.registerPerformAction=Fi;Yn.registerReadExtendedInformation=Ai;Yn.registerReadInformation=zi;Yn.registerRedo=qi;Yn.registerScreenReaderShortcuts=Ui;Yn.registerShowContextMenu=ui;Yn.registerShowTooltip=Ii;Yn.registerStackNavigation=Ci;Yn.registerToggleScreenreaderMode=Ji;Yn.registerUndo=pi;var Zn,$n=Zn||(Zn={});$n[$n.CONSTRAINED=1]="CONSTRAINED";$n[$n.UNCONSTRAINED=2]="UNCONSTRAINED";
1286
+ var ao=class{constructor(a){this.block=a;this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null;this.dragging=!1;this.allConnectionPairs=[];this.moveMode=Zn.UNCONSTRAINED;this.originalEventGroup="";this.lastBlockDisabledReasons=new Map;this.WORKSPACE_MARGIN=this.BLOCK_CONNECTION_OFFSET=10;this.workspace=a.workspace}isMovable(){var a;return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&!this.workspace.isReadOnly()&&(!this.block.isInFlyout||
1287
+ this.block.isEnabled()&&!((a=this.block.workspace.targetWorkspace)==null?0:a.isReadOnly()))}positionNewBlock(a,b){a=pc(a.workspace,a.getRelativeToSurfaceXY());a=oc(b.workspace,a);b.moveDuringDrag(a);if(this.moveMode===Zn.CONSTRAINED){var c=b.workspace,d=this.WORKSPACE_MARGIN;a=this.WORKSPACE_MARGIN;var e=Math.max($.Og.connectingSnapRadius,$.Og.snapRadius)+2,f=c.getTopBlocks(!0).filter(T=>T.id!==b.id).map(T=>{T=T.getBoundingRectangle();return new cc(T.top-e,T.bottom+e,T.left-e,T.right+e)}),g,h=(g=
1287
1288
  c.getToolbox())==null?void 0:g.getWidth();g=c.getParentSvg().clientWidth-(h!=null?h:0);c.getParentSvg();({width:h}=b.getHeightWidth());var m=function(T){for(let ra of f)if(T.intersects(ra))return ra;return null},z=a;c=c.getRenderer().getConstants().MIN_BLOCK_HEIGHT;var E=b.getBoundingRectangle();b.moveBy(z-E.left,d-E.top,["cleanup"]);E=b.getBoundingRectangle();for(var J=m(E);J!=null;)z=J.left+J.getWidth()+80,J=J.top+J.getHeight()+c,z+h<=g||(d=J,z=a),b.moveBy(z-E.left,d-E.top,["cleanup"]),E=b.getBoundingRectangle(),
1288
1289
  J=m(E)}}getTargetBlock(){if(this.block.isShadow()){var a=this.block.getParent();if(a)return a}else if(this.block.isInFlyout&&this.block.workspace.targetWorkspace&&(a=this.block.getRootBlock(),a=ce(a)))return a=de(a,this.block.workspace.targetWorkspace,{recordUndo:!0}),$.Qc=!1,a.render(),this.positionNewBlock(this.block,a),$.Qc=!0,a;return this.block}announceMove(a=!1){if(this.connectionCandidate)a=Me(this.connectionCandidate.local,this.connectionCandidate.neighbour,this.hasMultipleCompatibleConnections.bind(this),
1289
1290
  a);else{let b=a?this.block.getStackBlocksCountLabel():"";a=$.C.ANNOUNCE_MOVE_WORKSPACE;a=a.replace("%1",b)}Ja(a.replace(/\s+/g," "))}hasMultipleCompatibleConnections(a=!0){var b=this.connectionCandidate;if(!b)return!1;var c=a?"local":"neighbour",d=a?"neighbour":"local";return this.allConnectionPairs.filter(e=>e[d]===b[d]&&e[c]!==b[c].getSourceBlock().nextConnection&&e[c].getSourceBlock().id===b[c].getSourceBlock().id).length>1}startDrag(a){this.updateMoveMode(a);var b=this.getTargetBlock();if(b!==
@@ -1293,14 +1294,14 @@ null||e.moveToDragLayer(d,!1)});this.announceMove(!0);return this.block}cacheAll
1293
1294
  b.getIcons()).filter(b=>xd(b)&&b.bubbleIsVisible()).map(b=>b.getBubble()).filter(b=>!!b).sort((b,c)=>{b=b.getSvgRoot().compareDocumentPosition(c.getSvgRoot());return b&Node.DOCUMENT_POSITION_PRECEDING?1:b&Node.DOCUMENT_POSITION_FOLLOWING?-1:0})}shouldHealStack(a){return a instanceof PointerEvent?a.ctrlKey||a.metaKey:a instanceof KeyboardEvent?!(a.shiftKey||!this.block.previousConnection):!1}shouldDisconnect(a){return!!(this.block.getParent()||a&&this.block.nextConnection&&this.block.nextConnection.targetBlock())}disconnectBlock(a){this.block.unplug(a);
1294
1295
  Ph(this.block)}storeInitialConnections(a){var b=this.startChildConn=this.startParentConn=null,c=null,d;if((d=this.block.outputConnection)==null?0:d.isConnected())b=this.block.outputConnection,c=this.block.outputConnection.targetConnection;else{let e;if((e=this.block.previousConnection)==null?0:e.isConnected())b=this.block.previousConnection,c=this.block.previousConnection.targetConnection}this.startParentConn=c;b&&c?this.connectionCandidate={local:b,neighbour:c,distance:0}:a&&(a=this.block.nextConnection,
1295
1296
  b=a==null?void 0:a.targetConnection,a&&b&&(this.connectionCandidate={local:a,neighbour:b,distance:0}),this.startChildConn=b!=null?b:null)}fireDragStartEvent(){var a=new (u(v.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));w(a)}fireDragEndEvent(){var a=new (u(v.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));w(a)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var a=new (u(v.BLOCK_MOVE))(this.block);a.setReason(["drag"]);a.oldCoordinate=this.startLoc;a.recordNew();w(a)}}drag(a,
1296
- b){this.updateMoveMode(b);this.moveMode===Yn.UNCONSTRAINED&&this.block.moveDuringDrag(a);b=!!this.connectionCandidate;this.updateConnectionPreview(this.block,D.difference(a,this.startLoc));if(this.connectionCandidate)this.moveMode===Yn.CONSTRAINED&&this.block.moveDuringDrag(this.determineConnectionOffset());else if(this.moveMode===Yn.CONSTRAINED&&(this.allConnectionPairs.length||Xi(this.workspace,!0),!b)){this.workspace.getAudioManager().playErrorBeep();return}this.announceMove()}determineConnectionOffset(){var {local:a,
1297
+ b){this.updateMoveMode(b);this.moveMode===Zn.UNCONSTRAINED&&this.block.moveDuringDrag(a);b=!!this.connectionCandidate;this.updateConnectionPreview(this.block,D.difference(a,this.startLoc));if(this.connectionCandidate)this.moveMode===Zn.CONSTRAINED&&this.block.moveDuringDrag(this.determineConnectionOffset());else if(this.moveMode===Zn.CONSTRAINED&&(this.allConnectionPairs.length||Xi(this.workspace,!0),!b)){this.workspace.getAudioManager().playErrorBeep();return}this.announceMove()}determineConnectionOffset(){var {local:a,
1297
1298
  neighbour:b}=this.connectionCandidate,c=a.getOffsetInBlock(),d=b.x-c.x;c=b.y-c.y;var e=this.BLOCK_CONNECTION_OFFSET;a.type===G.PREVIOUS_STATEMENT||a.type===G.OUTPUT_VALUE?(d+=e,c+=e):(d-=e,c-=e);return new D(d,c)}updateConnectionPreview(a,b,c){var d=this.connectionCandidate;c=c!=null?c:this.getConnectionCandidate(b);this.connectionCandidate=null;if(c){var e=d&&this.currCandidateIsBetter(d,b,c)?d:c;this.connectionCandidate=e;var {local:f,neighbour:g}=e;e=f.type===G.OUTPUT_VALUE||f.type===G.PREVIOUS_STATEMENT;
1298
- var h;b=g.isConnected()&&!((h=g.targetBlock())==null?0:h.isInsertionMarker());if(e&&b&&!this.orphanCanConnectAtEnd(a,g.targetBlock(),f.type)){var m;(m=this.connectionPreviewer)==null||m.previewReplacement(f,g,g.targetBlock())}else{let E;(E=this.connectionPreviewer)==null||E.previewConnection(f,g)}return g}if(this.moveMode===Yn.CONSTRAINED){let E;h=(E=d==null?void 0:d.neighbour.getSourceBlock())!=null?E:null;let J;m=(J=h==null?void 0:h.getRootBlock())!=null?J:h;m===a&&(m=h);if(!m){let T;(T=this.connectionPreviewer)==
1299
+ var h;b=g.isConnected()&&!((h=g.targetBlock())==null?0:h.isInsertionMarker());if(e&&b&&!this.orphanCanConnectAtEnd(a,g.targetBlock(),f.type)){var m;(m=this.connectionPreviewer)==null||m.previewReplacement(f,g,g.targetBlock())}else{let E;(E=this.connectionPreviewer)==null||E.previewConnection(f,g)}return g}if(this.moveMode===Zn.CONSTRAINED){let E;h=(E=d==null?void 0:d.neighbour.getSourceBlock())!=null?E:null;let J;m=(J=h==null?void 0:h.getRootBlock())!=null?J:h;m===a&&(m=h);if(!m){let T;(T=this.connectionPreviewer)==
1299
1300
  null||T.hidePreview();return}h=a.workspace.getTopBlocks().filter(T=>T!==a.getRootBlock()).map(T=>T.getBoundingRectangle());if(!h.length){let T;(T=this.connectionPreviewer)==null||T.hidePreview();return}var z;d=(z=d==null?void 0:d.neighbour.x)!=null?z:a.getRelativeToSurfaceXY().x;z=this.BLOCK_CONNECTION_OFFSET*2;switch(this.getDirectionToNewLocation(D.sum(this.startLoc,b))){case si.LEFT:case si.UP:b=Math.min(...h.map(T=>T.top))-z-a.getHeightWidth().height;break;default:b=Math.max(...h.map(T=>T.bottom))+
1300
- z}a.moveDuringDrag(new D(d,b))}(e=this.connectionPreviewer)==null||e.hidePreview()}orphanCanConnectAtEnd(a,b,c){return!!Bn.getConnectionForOrphanedConnection(a,c===G.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}currCandidateIsBetter(a,b,c){if(this.moveMode===Yn.CONSTRAINED)return!1;var {local:d,neighbour:e}=a;a=new D(d.x,d.y);var f=new D(e.x,e.y);b=D.distance(D.sum(a,b),f);return c.distance>b-$.Og.currentConnectionPreference}getConnectionCandidate(a){return this.moveMode===Yn.CONSTRAINED?
1301
- this.findTraversalCandidate(a):this.getClosestCandidate(this.block,a)}getClosestCandidate(a,b){var c=this.getSearchRadius();a=this.getLocalConnections(a);var d=null;for(let e of a){let {connection:f,radius:g}=e.closest(c,b);f&&(d={local:e,neighbour:f,distance:g},c=g)}return d}getSearchRadius(){return this.moveMode===Yn.CONSTRAINED?Infinity:this.connectionCandidate?$.Og.connectingSnapRadius:$.Og.snapRadius}getLocalConnections(a){var b=a.getConnections_(!1),c=a.lastConnectionInStack(!0);c&&c!==a.nextConnection&&
1302
- b.push(c);a=[a.outputConnection,a.previousConnection,a.nextConnection].filter(d=>!!d);c=[];for(let d of b)a.includes(d)||c.push(d);c.reverse();return[...a,...c]}endDrag(a,b){b===Un.DELETE&&Kh(this.block);this.originalEventGroup=$.gd;this.fireDragEndEvent();this.fireMoveEvent();Ua();Mh();var c;(c=this.connectionPreviewer)==null||c.hidePreview();if(!this.block.isDeadOrDying()&&this.dragging){let d;(d=this.workspace.getLayerManager())==null||d.moveOffDragLayer(this.block,50);this.getVisibleBubbles(this.block).forEach(e=>
1303
- {var f;return(f=this.workspace.getLayerManager())==null?void 0:f.moveOffDragLayer(e,100,!1)});this.block.setDragging(!1);this.redisableAllDraggedBlocks(this.block)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):(b!==Un.DELETE&&this.workspace.getAudioManager().play("drop"),this.block.queueRender().then(()=>this.disposeStep()));this.allConnectionPairs=[];this.connectionCandidate=this.startChildConn=this.startParentConn=null;this.dragging=!1}disposeStep(){var a=
1301
+ z}a.moveDuringDrag(new D(d,b))}(e=this.connectionPreviewer)==null||e.hidePreview()}orphanCanConnectAtEnd(a,b,c){return!!Cn.getConnectionForOrphanedConnection(a,c===G.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}currCandidateIsBetter(a,b,c){if(this.moveMode===Zn.CONSTRAINED)return!1;var {local:d,neighbour:e}=a;a=new D(d.x,d.y);var f=new D(e.x,e.y);b=D.distance(D.sum(a,b),f);return c.distance>b-$.Og.currentConnectionPreference}getConnectionCandidate(a){return this.moveMode===Zn.CONSTRAINED?
1302
+ this.findTraversalCandidate(a):this.getClosestCandidate(this.block,a)}getClosestCandidate(a,b){var c=this.getSearchRadius();a=this.getLocalConnections(a);var d=null;for(let e of a){let {connection:f,radius:g}=e.closest(c,b);f&&(d={local:e,neighbour:f,distance:g},c=g)}return d}getSearchRadius(){return this.moveMode===Zn.CONSTRAINED?Infinity:this.connectionCandidate?$.Og.connectingSnapRadius:$.Og.snapRadius}getLocalConnections(a){var b=a.getConnections_(!1),c=a.lastConnectionInStack(!0);c&&c!==a.nextConnection&&
1303
+ b.push(c);a=[a.outputConnection,a.previousConnection,a.nextConnection].filter(d=>!!d);c=[];for(let d of b)a.includes(d)||c.push(d);c.reverse();return[...a,...c]}endDrag(a,b){b===Vn.DELETE&&Kh(this.block);this.originalEventGroup=$.gd;this.fireDragEndEvent();this.fireMoveEvent();Ua();Mh();var c;(c=this.connectionPreviewer)==null||c.hidePreview();if(!this.block.isDeadOrDying()&&this.dragging){let d;(d=this.workspace.getLayerManager())==null||d.moveOffDragLayer(this.block,50);this.getVisibleBubbles(this.block).forEach(e=>
1304
+ {var f;return(f=this.workspace.getLayerManager())==null?void 0:f.moveOffDragLayer(e,100,!1)});this.block.setDragging(!1);this.redisableAllDraggedBlocks(this.block)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):(b!==Vn.DELETE&&this.workspace.getAudioManager().play("drop"),this.block.queueRender().then(()=>this.disposeStep()));this.allConnectionPairs=[];this.connectionCandidate=this.startChildConn=this.startParentConn=null;this.dragging=!1}disposeStep(){var a=
1304
1305
  $.gd;$.B(this.originalEventGroup);this.block.snapToGrid();var b;(b=this.connectionPreviewer)==null||b.dispose();this.workspace.setResizesEnabled(!0);$.B(a)}applyConnections(a){var {local:b,neighbour:c}=a;b.connect(c);var d=b.isSuperior()?c:b,e=this.block.getRootBlock();cd().then(()=>{Lh(d.getSourceBlock());setTimeout(()=>{e.bringToFront()},0)})}revertDrag(){var a;(a=this.connectionPreviewer)==null||a.hidePreview();this.connectionCandidate=null;if(this.block.nextConnection){let b;(b=this.startChildConn)==
1305
1306
  null||b.connect(this.block.nextConnection)}if(this.startParentConn)switch(this.startParentConn.type){case G.INPUT_VALUE:this.block.outputConnection&&this.startParentConn.connect(this.block.outputConnection);break;case G.NEXT_STATEMENT:this.block.previousConnection&&this.startParentConn.connect(this.block.previousConnection)}else{this.block.moveDuringDrag(this.startLoc);let b;(b=this.workspace.getLayerManager())==null||b.moveOffDragLayer(this.block,50);this.getVisibleBubbles(this.block).forEach(c=>
1306
1307
  {var d;return(d=this.workspace.getLayerManager())==null?void 0:d.moveOffDragLayer(c,100,!1)});Uh(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null;this.block.setDragging(!1);this.redisableAllDraggedBlocks(this.block);this.dragging=!1;Ja($.C.ANNOUNCE_MOVE_CANCELED)}findTraversalCandidate(a){var b=this.getDirectionToNewLocation(D.sum(this.startLoc,a)),c=this.allConnectionPairs;if(b===si.NONE||!c.length)return this.connectionCandidate;
@@ -1309,33 +1310,33 @@ this.pairToCandidate(c[c.length-1]):null:this.getClosestCandidate(this.block,a):
1309
1310
  m,!0,Infinity))return!1}return!0}pairToCandidate(a){return Object.assign({},a,{distance:0})}getDirectionToNewLocation(a){var b=this.block.getRelativeToSurfaceXY();a=D.difference(a,b);var {x:c,y:d}=a;return Math.abs(c)>Math.abs(d)?c<0?si.LEFT:si.RIGHT:Math.abs(d)>0?d<0?si.UP:si.DOWN:si.NONE}getAllConnections(a){if(a.isShadow())return[];var b=[];a.outputConnection&&b.push(a.outputConnection);a.previousConnection&&b.push(a.previousConnection);if(!a.isCollapsed())for(let c of a.inputList)if(c.connection&&
1310
1311
  c.isVisible()){b.push(c.connection);let d=c.connection.targetBlock();d&&b.push(...this.getAllConnections(d))}a.nextConnection&&(b.push(a.nextConnection),(a=a.nextConnection.targetBlock())&&b.push(...this.getAllConnections(a)));return b}getInitialCandidate(){var a=this.workspace.getSvgGroup().querySelector(`.${Za.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME}`);if(!a||!a.id||a===this.block.getFocusableElement())return null;a=this.workspace.lookUpFocusableNode(a.id);if(!a)return null;var b=this.workspace.getNavigator().getSourceBlockFromNode(a);
1311
1312
  if(!b)return null;var c=null;if(b.getConnections_(!1).includes(a)){c=a;let g=this.block.workspace.connectionChecker;if(a=this.block.getConnections_(!1).find(h=>g.canConnect(h,c,!0,Infinity)))return{local:a,neighbour:c,distance:0}}if(a=this.allConnectionPairs.find(g=>g.neighbour.getSourceBlock()===b))return this.pairToCandidate(a);var d,e=(d=b.outputConnection)==null?void 0:d.targetConnection;if(d=this.allConnectionPairs.find(g=>g.neighbour===e))return this.pairToCandidate(d);for(var f=b.getSurroundParent();f;){if(d=
1312
- this.allConnectionPairs.find(g=>g.neighbour.getSourceBlock()===f))return this.pairToCandidate(d);f=f.getSurroundParent()}return null}updateMoveMode(a){this.moveMode=a instanceof KeyboardEvent&&!a.ctrlKey&&!a.metaKey?Yn.CONSTRAINED:Yn.UNCONSTRAINED}enableAllDraggedBlocks(a){var b=$.Qc;$.Qc=!1;this.lastBlockDisabledReasons.clear();a.getDescendants(!1).forEach(c=>{var d=new Set(c.getDisabledReasons());this.lastBlockDisabledReasons.set(c.id,d);d.forEach(e=>c.setDisabledReason(!1,e))});$.Qc=b}redisableAllDraggedBlocks(a){var b=
1313
- $.Qc;$.Qc=!1;a.getDescendants(!1).forEach(c=>{var d;(d=this.lastBlockDisabledReasons.get(c.id))==null||d.forEach(e=>{c.setDisabledReason(!0,e)})});$.Qc=b}};var ao=class extends rg{isLabelField(){return!0}constructor(a,b,c){super(rg.SKIP_SETUP);this.class=null;this.EDITABLE=!1;this.maxDisplayLength=Infinity;a!==rg.SKIP_SETUP&&(c?this.configure_(c):this.class=b||null,this.setValue(a))}configure_(a){super.configure_(a);a.class&&(this.class=a.class)}initView(){this.createTextElement_();this.class&&n(this.getTextElement(),this.class);this.fieldGroup_&&(n(this.fieldGroup_,"blocklyLabelField"),l(this.fieldGroup_,p.HIDDEN,!0))}computeAriaLabel(a=!0){a=a?this.getAriaTypeName():
1314
- null;var b,c=(b=this.getAriaValue())!=null?b:"";return a?`${a}: ${c}`:c}doClassValidation_(a){return a===null||a===void 0?null:`${a}`}setClass(a){this.textElement_&&(this.class&&Ma(this.textElement_,this.class),a&&n(this.textElement_,a));this.class=a}static fromJson(a){return new this(hg(a.text),void 0,a)}};jh("field_label",ao);ao.prototype.DEFAULT_VALUE="";var bo=class extends sn{constructor(a,b,c,d,e){super(b,c,d,void 0,e);this.text=a;this.workspace=b;this.anchor=c;this.ownerRect=d;this.owner=e;this.paragraph=this.stringToSvg(a,this.contentContainer);this.updateBubbleSize();n(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(a){this.text=a;Oa(this.paragraph);this.paragraph=this.stringToSvg(a,this.contentContainer);this.updateBubbleSize()}stringToSvg(a,b){b=this.createParagraph(b);a=this.createTextFragments(b,a);this.workspace.RTL&&
1315
- this.rightAlignTextFragments(b.getBBox().width,a);return b}createParagraph(a){return r(q.G,{"class":"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${sn.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},a)}createTextFragments(a,b){var c=1;return b.split("\n").map(d=>{var e=r(q.TEXT,{y:`${c}em`,x:sn.BORDER_WIDTH},a);d=document.createTextNode(d);e.appendChild(d);c+=1;return e})}rightAlignTextFragments(a,b){for(let c of b)c.setAttribute("text-anchor",
1316
- "start"),c.setAttribute("x",`${a+sn.BORDER_WIDTH}`)}updateBubbleSize(){var a=this.paragraph.getBBox();this.setSize(new hc(a.width+sn.BORDER_WIDTH*2,a.height+sn.BORDER_WIDTH*2),!0)}};var co=class extends un{constructor(a){super(a);this.sourceBlock=a;this.textMap=new Map;this.textBubble=null}getType(){return co.TYPE}initView(a){this.svgRoot||(super.initView(a),r(q.PATH,{"class":"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},this.svgRoot),r(q.PATH,{"class":"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),r(q.RECT,{"class":"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),n(this.svgRoot,"blocklyWarningIcon"))}dispose(){super.dispose();
1317
- var a;(a=this.textBubble)==null||a.dispose()}getWeight(){return co.WEIGHT}getSize(){return new hc(17,17)}applyColour(){super.applyColour();var a;(a=this.textBubble)==null||a.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(a){super.onLocationChange(a);var b;(b=this.textBubble)==null||b.setAnchorLocation(this.getAnchorLocation())}addMessage(a,b){if(this.textMap.get(b)===a)return this;a?this.textMap.set(b,a):this.textMap.delete(b);var c;(c=
1318
- this.textBubble)==null||c.setText(this.getText());return this}getText(){return[...this.textMap.values()].join("\n")}onClick(){super.onClick();this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(a){var b=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(b.bubbleIsVisible()!==a){yield cd();if(a)b.textBubble=new bo(b.getText(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect(),b),
1313
+ this.allConnectionPairs.find(g=>g.neighbour.getSourceBlock()===f))return this.pairToCandidate(d);f=f.getSurroundParent()}return null}updateMoveMode(a){this.moveMode=a instanceof KeyboardEvent&&!a.ctrlKey&&!a.metaKey?Zn.CONSTRAINED:Zn.UNCONSTRAINED}enableAllDraggedBlocks(a){var b=$.Qc;$.Qc=!1;this.lastBlockDisabledReasons.clear();a.getDescendants(!1).forEach(c=>{var d=new Set(c.getDisabledReasons());this.lastBlockDisabledReasons.set(c.id,d);d.forEach(e=>c.setDisabledReason(!1,e))});$.Qc=b}redisableAllDraggedBlocks(a){var b=
1314
+ $.Qc;$.Qc=!1;a.getDescendants(!1).forEach(c=>{var d;(d=this.lastBlockDisabledReasons.get(c.id))==null||d.forEach(e=>{c.setDisabledReason(!0,e)})});$.Qc=b}};var bo=class extends rg{isLabelField(){return!0}constructor(a,b,c){super(rg.SKIP_SETUP);this.class=null;this.EDITABLE=!1;this.maxDisplayLength=Infinity;a!==rg.SKIP_SETUP&&(c?this.configure_(c):this.class=b||null,this.setValue(a))}configure_(a){super.configure_(a);a.class&&(this.class=a.class)}initView(){this.createTextElement_();this.class&&n(this.getTextElement(),this.class);this.fieldGroup_&&(n(this.fieldGroup_,"blocklyLabelField"),l(this.fieldGroup_,p.HIDDEN,!0))}computeAriaLabel(a=!0){a=a?this.getAriaTypeName():
1315
+ null;var b,c=(b=this.getAriaValue())!=null?b:"";return a?`${a}: ${c}`:c}doClassValidation_(a){return a===null||a===void 0?null:`${a}`}setClass(a){this.textElement_&&(this.class&&Ma(this.textElement_,this.class),a&&n(this.textElement_,a));this.class=a}static fromJson(a){return new this(hg(a.text),void 0,a)}};jh("field_label",bo);bo.prototype.DEFAULT_VALUE="";var co=class extends tn{constructor(a,b,c,d,e){super(b,c,d,void 0,e);this.text=a;this.workspace=b;this.anchor=c;this.ownerRect=d;this.owner=e;this.paragraph=this.stringToSvg(a,this.contentContainer);this.updateBubbleSize();n(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(a){this.text=a;Oa(this.paragraph);this.paragraph=this.stringToSvg(a,this.contentContainer);this.updateBubbleSize()}stringToSvg(a,b){b=this.createParagraph(b);a=this.createTextFragments(b,a);this.workspace.RTL&&
1316
+ this.rightAlignTextFragments(b.getBBox().width,a);return b}createParagraph(a){return r(q.G,{"class":"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${tn.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},a)}createTextFragments(a,b){var c=1;return b.split("\n").map(d=>{var e=r(q.TEXT,{y:`${c}em`,x:tn.BORDER_WIDTH},a);d=document.createTextNode(d);e.appendChild(d);c+=1;return e})}rightAlignTextFragments(a,b){for(let c of b)c.setAttribute("text-anchor",
1317
+ "start"),c.setAttribute("x",`${a+tn.BORDER_WIDTH}`)}updateBubbleSize(){var a=this.paragraph.getBBox();this.setSize(new hc(a.width+tn.BORDER_WIDTH*2,a.height+tn.BORDER_WIDTH*2),!0)}};var eo=class extends vn{constructor(a){super(a);this.sourceBlock=a;this.textMap=new Map;this.textBubble=null}getType(){return eo.TYPE}initView(a){this.svgRoot||(super.initView(a),r(q.PATH,{"class":"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},this.svgRoot),r(q.PATH,{"class":"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),r(q.RECT,{"class":"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),n(this.svgRoot,"blocklyWarningIcon"))}dispose(){super.dispose();
1318
+ var a;(a=this.textBubble)==null||a.dispose()}getWeight(){return eo.WEIGHT}getSize(){return new hc(17,17)}applyColour(){super.applyColour();var a;(a=this.textBubble)==null||a.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(a){super.onLocationChange(a);var b;(b=this.textBubble)==null||b.setAnchorLocation(this.getAnchorLocation())}addMessage(a,b){if(this.textMap.get(b)===a)return this;a?this.textMap.set(b,a):this.textMap.delete(b);var c;(c=
1319
+ this.textBubble)==null||c.setText(this.getText());return this}getText(){return[...this.textMap.values()].join("\n")}onClick(){super.onClick();this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(a){var b=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(b.bubbleIsVisible()!==a){yield cd();if(a)b.textBubble=new co(b.getText(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect(),b),
1319
1320
  b.applyColour(),b.textBubble.setAriaLabelProvider(()=>$.C.BUBBLE_LABEL_WARNING.replace("%1",b.getText()));else{let c;(c=b.textBubble)==null||c.dispose();b.textBubble=null}w(new (u(v.BUBBLE_OPEN))(b.sourceBlock,a,"warning"));b.recomputeAriaContext()}})}getBubble(){return this.textBubble}getAnchorLocation(){return D.sum(this.workspaceLocation,new D(8.5,8.5))}getBubbleOwnerRect(){var a=this.sourceBlock.getSvgRoot().getBBox();return new cc(a.y,a.y+a.height,a.x,a.x+a.width)}getAriaLabel(){return this.bubbleIsVisible()?
1320
- $.C.ICON_LABEL_WARNING_OPEN:$.C.ICON_LABEL_WARNING_CLOSED}};co.TYPE=Zg.WARNING;co.WEIGHT=2;var ii=class extends On{constructor(a,b,c){super(a,b,c);this.childlessWidth=this.width=this.height=0;this.warningTextDb=new Map;this.mutator=null;this.rendered=!0;this.visuallyDisabled=!1;this.previousConnection=this.nextConnection=this.outputConnection=null;this.translation="";this.dragging=!1;this.relativeCoords=new D(0,0);this.dragStrategy=new $n(this);if(!a.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=a;this.svgGroup=r(q.G,{});b&&n(this.svgGroup,
1321
+ $.C.ICON_LABEL_WARNING_OPEN:$.C.ICON_LABEL_WARNING_CLOSED}};eo.TYPE=Zg.WARNING;eo.WEIGHT=2;var ii=class extends Pn{constructor(a,b,c){super(a,b,c);this.childlessWidth=this.width=this.height=0;this.warningTextDb=new Map;this.mutator=null;this.rendered=!0;this.visuallyDisabled=!1;this.previousConnection=this.nextConnection=this.outputConnection=null;this.translation="";this.dragging=!1;this.relativeCoords=new D(0,0);this.dragStrategy=new ao(this);if(!a.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=a;this.svgGroup=r(q.G,{});b&&n(this.svgGroup,
1321
1322
  b);this.style=a.getRenderer().getConstants().getBlockStyle(null);this.pathObject=a.getRenderer().makePathObject(this.svgGroup,this.style);a=this.pathObject.svgPath;a.tooltip=this;Hf(a);this.svgGroup.setAttribute("data-id",this.id);a.id=Lb();this.doInit_()}initSvg(){if(!this.initialized){for(var a of this.inputList)a.init();for(let b of this.getIcons())b.initView(this.createIconPointerDownListener(b)),b.updateEditable();this.applyColour();this.pathObject.updateMovable(this.isMovable()||this.isInFlyout);
1322
- (a=this.getSvgRoot())&&k(a,"pointerdown",this,this.onMouseDown);a.parentNode||this.workspace.getCanvas().appendChild(a);this.recomputeAriaContext();this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){this.addSelect();ob(this)}unselect(){this.removeSelect();ob(null)}setParent(a){var b=this.parentBlock_;if(a!==b){Ta();super.setParent(a);Ua();var c=this.getSvgRoot();if(!this.workspace.isClearing&&c){var d=this.getRelativeToSurfaceXY(),
1323
- e=$.t().getFocusedNode(),f,g=this.getSvgRoot().contains((f=e==null?void 0:e.getFocusableElement())!=null?f:null);a?(a.getSvgRoot().appendChild(c),g&&e&&$.t().focusNode(e)):b&&(a=this.workspace.getCanvas().querySelector(".blocklyDragging"),b=a==null?void 0:a.parentElement,f=this.workspace.getCanvas(),b===f?f.insertBefore(c,a):(f.appendChild(c),g&&e&&$.t().focusNode(e)),this.translate(d.x,d.y));this.applyColour();this.recomputeAriaContext()}}}moveBy(a,b,c){if(this.parentBlock_)throw Error("Block has parent");
1324
- var d=Vb(),e=null;d&&(e=new (u(v.BLOCK_MOVE))(this),c&&e.setReason(c));a=new D(a,b);b=this.getRelativeToSurfaceXY();a=D.sum(b,a);this.translate(a.x,a.y);this.workspace.connectionDBList.forEach(f=>f==null?void 0:f.beginBulkUpdates());this.updateComponentLocations(a);this.workspace.connectionDBList.forEach(f=>f==null?void 0:f.endBulkUpdates());d&&e&&(e.recordNew(),w(e));this.workspace.resizeContents()}translate(a,b){this.translation=`translate(${a}, ${b})`;this.relativeCoords=new D(a,b);this.getSvgRoot().setAttribute("transform",
1325
- this.getTranslation())}getTranslation(){return this.translation}moveTo(a,b){var c=this.getRelativeToSurfaceXY();this.moveBy(a.x-c.x,a.y-c.y,b)}moveDuringDrag(a){this.translate(a.x,a.y);this.getSvgRoot().setAttribute("transform",this.getTranslation());this.updateComponentLocations(a)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var a=this.workspace.getGrid();if(a!=null&&a.shouldSnap()){var b=this.getRelativeToSurfaceXY();a=a.alignXY(b);a!==b&&this.moveTo(a,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,
1323
+ (a=this.getSvgRoot())&&k(a,"pointerdown",this,this.onMouseDown);a.parentNode||this.workspace.getCanvas().appendChild(a);this.recomputeAriaContext();this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){this.addSelect();ob(this)}unselect(){this.removeSelect();ob(null)}setParent(a){var b=this.parentBlock_;if(a!==b){Ta();super.setParent(a);Ua();var c=this.getSvgRoot();if(!this.workspace.isClearing&&c){var d=$.t().getFocusedNode(),
1324
+ e,f=this.getSvgRoot().contains((e=d==null?void 0:d.getFocusableElement())!=null?e:null);a?(a.getSvgRoot().appendChild(c),f&&d&&$.t().focusNode(d)):b&&(a=this.getRelativeToSurfaceXY(),this.workspace.getCanvas().appendChild(c),this.translate(a.x,a.y));f&&d&&$.t().focusNode(d);this.applyColour();this.recomputeAriaContext()}}}moveBy(a,b,c){if(this.parentBlock_)throw Error("Block has parent");var d=Vb(),e=null;d&&(e=new (u(v.BLOCK_MOVE))(this),c&&e.setReason(c));a=new D(a,b);b=this.getRelativeToSurfaceXY();
1325
+ a=D.sum(b,a);this.translate(a.x,a.y);this.workspace.connectionDBList.forEach(f=>f==null?void 0:f.beginBulkUpdates());this.updateComponentLocations(a);this.workspace.connectionDBList.forEach(f=>f==null?void 0:f.endBulkUpdates());d&&e&&(e.recordNew(),w(e));this.workspace.resizeContents()}translate(a,b){this.translation=`translate(${a}, ${b})`;this.relativeCoords=new D(a,b);this.getSvgRoot().setAttribute("transform",this.getTranslation())}getTranslation(){return this.translation}moveTo(a,b){var c=this.getRelativeToSurfaceXY();
1326
+ this.moveBy(a.x-c.x,a.y-c.y,b)}moveDuringDrag(a){this.translate(a.x,a.y);this.updateComponentLocations(a)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var a=this.workspace.getGrid();if(a!=null&&a.shouldSnap()){var b=this.getRelativeToSurfaceXY();a=a.alignXY(b);a!==b&&this.moveTo(a,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,
1326
1327
  width:this.childlessWidth})}getBoundingRectangleWithDimensions(a){var b=this.getRelativeToSurfaceXY();if(this.RTL){var c=b.x-a.width;var d=b.x}else c=b.x,d=b.x+a.width;return new cc(b.y,b.y+a.height,c,d)}markDirty(){this.pathObject.constants=this.workspace.getRenderer().getConstants();for(let a=0,b;b=this.inputList[a];a++)b.markDirty()}setCollapsed(a){this.collapsed_!==a&&(super.setCollapsed(a),this.updateCollapsed())}childHasWarning(){var a=this.getNextBlock();a=a?new Set(a.getDescendants(!1)):null;
1327
- var b=this.getDescendants(!1);for(let c of b)if(c!==this&&(a==null||!a.has(c))&&c.getIcon(co.TYPE))return!0;return!1}updateCollapsed(){var a=this.isCollapsed();for(let c=0,d;d=this.inputList[c];c++)d.name!=="_TEMP_COLLAPSED_INPUT"&&d.setVisible(!a);for(var b of this.getIcons())b.updateCollapsed();a?(n(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText($.C.COLLAPSED_WARNINGS_WARNING,ii.COLLAPSED_WARNING_ID),a=this.toString(30),(b=this.getField("_TEMP_COLLAPSED_FIELD"))?b.setValue(a):
1328
- ((this.getInput("_TEMP_COLLAPSED_INPUT")||this.appendDummyInput("_TEMP_COLLAPSED_INPUT")).appendField(new ao(a),"_TEMP_COLLAPSED_FIELD"),this.recomputeAriaContext())):(this.updateDisabled(),this.removeInput("_TEMP_COLLAPSED_INPUT"),Ma(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,ii.COLLAPSED_WARNING_ID))}onMouseDown(a){if(!this.workspace.isReadOnly()){var b=this.workspace.getGesture(a);b&&b.handleBlockStart(a,this)}}showHelp(){var a=typeof this.helpUrl==="function"?this.helpUrl():this.helpUrl;
1329
- a&&window.open(a)}generateContextMenu(a){if(this.workspace.isReadOnly()||!this.contextMenu)return null;a=Kj.registry.getContextMenuOptions({block:this,focusedNode:this},a);this.customContextMenu&&this.customContextMenu(a);return a}calculateContextMenuLocation(a){if(a instanceof PointerEvent)return new D(a.clientX,a.clientY);a=pc(this.workspace,this.getRelativeToSurfaceXY());var b,c,d=(b=this.inputList.filter(e=>e.isVisible()).flatMap(e=>e.fieldRow).find(e=>e.isVisible()))==null?void 0:(c=b.getSvgRoot())==
1328
+ var b=this.getDescendants(!1);for(let c of b)if(c!==this&&(a==null||!a.has(c))&&c.getIcon(eo.TYPE))return!0;return!1}updateCollapsed(){var a=this.isCollapsed();for(let c=0,d;d=this.inputList[c];c++)d.name!=="_TEMP_COLLAPSED_INPUT"&&d.setVisible(!a);for(var b of this.getIcons())b.updateCollapsed();a?(n(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText($.C.COLLAPSED_WARNINGS_WARNING,ii.COLLAPSED_WARNING_ID),a=this.toString(30),(b=this.getField("_TEMP_COLLAPSED_FIELD"))?b.setValue(a):
1329
+ ((this.getInput("_TEMP_COLLAPSED_INPUT")||this.appendDummyInput("_TEMP_COLLAPSED_INPUT")).appendField(new bo(a),"_TEMP_COLLAPSED_FIELD"),this.recomputeAriaContext())):(this.updateDisabled(),this.removeInput("_TEMP_COLLAPSED_INPUT"),Ma(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,ii.COLLAPSED_WARNING_ID))}onMouseDown(a){if(!this.workspace.isReadOnly()){var b=this.workspace.getGesture(a);b&&b.handleBlockStart(a,this)}}showHelp(){var a=typeof this.helpUrl==="function"?this.helpUrl():this.helpUrl;
1330
+ a&&window.open(a)}generateContextMenu(a){if(this.workspace.isReadOnly()||!this.contextMenu)return null;a=Lj.registry.getContextMenuOptions({block:this,focusedNode:this},a);this.customContextMenu&&this.customContextMenu(a);return a}calculateContextMenuLocation(a){if(a instanceof PointerEvent)return new D(a.clientX,a.clientY);a=pc(this.workspace,this.getRelativeToSurfaceXY());var b,c,d=(b=this.inputList.filter(e=>e.isVisible()).flatMap(e=>e.fieldRow).find(e=>e.isVisible()))==null?void 0:(c=b.getSvgRoot())==
1330
1331
  null?void 0:c.getBoundingClientRect();return new D(this.RTL?a.x-5:a.x+5,(d&&d.height?d.y+d.height:a.y+this.height)+5)}showContextMenu(a){if(this.isShadow()){for(var b=this.getParent();b&&b.isShadow();)b=b.getParent();b&&($.t().focusNode(b),b.showContextMenu(a))}else{b=this.generateContextMenu(a);var c=this.calculateContextMenuLocation(a);b&&b.length&&(Hg(a,b,this.RTL,this.workspace,c),Fg=this)}}updateComponentLocations(a){this.xy.x=a.x;this.xy.y=a.y;this.dragging||this.updateConnectionLocations(a);
1331
1332
  this.updateIconLocations(a);this.updateFieldLocations(a);for(let b of this.getChildren(!1))b.updateComponentLocations(D.sum(a,b.relativeCoords))}updateConnectionLocations(a){for(let b of this.getConnections_(!1))b.moveToOffset(a)}updateIconLocations(a){for(let b of this.getIcons())b.onLocationChange(a)}updateFieldLocations(a){for(let b of this.inputList)for(let c of b.fieldRow)c.onLocationChange(a)}addClass(a){n(this.svgGroup,a)}removeClass(a){Ma(this.svgGroup,a)}setDragging(a){(this.dragging=a)?
1332
- (this.translation="",Vk.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(Vk.length=0,this.removeClass("blocklyDragging"),this.getFullBlockField()&&this.recomputeAriaContext());for(let b=0;b<this.childBlocks_.length;b++)this.childBlocks_[b].setDragging(a)}isDragging(){return this.dragging}setMovable(a){super.setMovable(a);this.pathObject.updateMovable(a)}setEditable(a){super.setEditable(a);a?Ma(this.svgGroup,"blocklyNotEditable"):n(this.svgGroup,"blocklyNotEditable");a=this.getIcons();
1333
+ (this.translation="",Wk.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(Wk.length=0,this.removeClass("blocklyDragging"),this.getFullBlockField()&&this.recomputeAriaContext());for(let b=0;b<this.childBlocks_.length;b++)this.childBlocks_[b].setDragging(a)}isDragging(){return this.dragging}setMovable(a){super.setMovable(a);this.pathObject.updateMovable(a)}setEditable(a){super.setEditable(a);a?Ma(this.svgGroup,"blocklyNotEditable"):n(this.svgGroup,"blocklyNotEditable");a=this.getIcons();
1333
1334
  for(let b=0;b<a.length;b++)a[b].updateEditable()}setShadow(a){super.setShadow(a);this.applyColour();this.recomputeAriaContext()}setInsertionMarker(a){this.isInsertionMarker_!==a&&(this.isInsertionMarker_=a)&&(this.setColour(this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR),this.pathObject.updateInsertionMarker(!0))}getSvgRoot(){return this.svgGroup}getNearestNeighbour(){if(!this.workspace.rendered)return null;var a=this.workspace.getAllBlocks(!1).filter(e=>!e.isDeadOrDying()),b=
1334
1335
  null,c=Number.MAX_SAFE_INTEGER,d=this.getRelativeToSurfaceXY();for(let e of a)a=e.getRelativeToSurfaceXY(),a=Math.sqrt(Math.pow(a.x-d.x,2)+Math.pow(a.y-d.y,2)),a<c&&(b=e,c=a);return b}dispose(a,b){this.disposing=!0;If(this.pathObject.svgPath);delete this.pathObject.svgPath.tooltip;Tf();Gg();b&&(this.unplug(a),Kh(this));var c=$.t(),d,e;b=(e=(d=c.getFocusedNode())==null?void 0:d.getFocusableElement())!=null?e:null;super.dispose(!!a);Oa(this.svgGroup);if(this.getSvgRoot().contains(b)){let f=this.getParent();
1335
1336
  if(!f){let g;if(a=(g=this.outputConnection)!=null?g:this.previousConnection){let h;f=(h=a.closest(0,new D(0,0)).connection)==null?void 0:h.getSourceBlock()}}setTimeout(()=>{if(this.workspace.rendered)if(f)c.focusNode(f);else{let g=this.getNearestNeighbour();g?c.focusNode(g):c.focusTree(this.workspace)}},0)}}disposeInternal(){this.disposing=!0;super.disposeInternal();$.t().getFocusedNode()===this&&this.workspace.cancelCurrentGesture();[...this.warningTextDb.values()].forEach(a=>clearTimeout(a));this.warningTextDb.clear();
1336
- this.getIcons().forEach(a=>a.dispose())}checkAndDelete(){this.workspace.isFlyout||($.B(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),$.B(!1))}toCopyData(a=!1){return this.isInsertionMarker_?null:{paster:Qn.TYPE,blockState:ce(this,{addCoordinates:!0,addNextBlocks:a,saveIds:!1}),typeCounts:ub(this,!0)}}applyColour(){var a,b;(b=(a=this.pathObject).applyColour)==null||b.call(a,this);a=this.getIcons();for(b=0;b<a.length;b++)a[b].applyColour();for(let c of this.getFields())c.applyColour()}updateDisabled(){var a=
1337
+ this.getIcons().forEach(a=>a.dispose())}checkAndDelete(){this.workspace.isFlyout||($.B(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),$.B(!1))}toCopyData(a=!1){return this.isInsertionMarker_?null:{paster:Rn.TYPE,blockState:ce(this,{addCoordinates:!0,addNextBlocks:a,saveIds:!1}),typeCounts:ub(this,!0)}}applyColour(){var a,b;(b=(a=this.pathObject).applyColour)==null||b.call(a,this);a=this.getIcons();for(b=0;b<a.length;b++)a[b].applyColour();for(let c of this.getFields())c.applyColour()}updateDisabled(){var a=
1337
1338
  !this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===a){let b;(b=this.getNextBlock())==null||b.updateDisabled()}else{this.applyColour();this.visuallyDisabled=a;for(let b of this.getChildren(!1))b.updateDisabled();this.recomputeAriaContext()}}setWarningText(a,b=""){if(b)this.warningTextDb.has(b)&&(clearTimeout(this.warningTextDb.get(b)),this.warningTextDb.delete(b));else{for(var c of this.warningTextDb.values())clearTimeout(c);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(b,
1338
- setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(b),this.setWarningText(a,b))},100));else if(this.isInFlyout&&(a=null),c=this.getIcon(co.TYPE),a){let d=this.getSurroundParent(),e=null;for(;d;)d.isCollapsed()&&(e=d),d=d.getSurroundParent();e&&e.setWarningText($.C.COLLAPSED_WARNINGS_WARNING,ii.COLLAPSED_WARNING_ID);c?c.addMessage(a,b):this.addIcon((new co(this)).addMessage(a,b))}else c&&(b?(c.addMessage("",b),c.getText()||this.removeIcon(co.TYPE)):this.removeIcon(co.TYPE))}setMutator(a){this.removeIcon($.sh.TYPE);
1339
+ setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(b),this.setWarningText(a,b))},100));else if(this.isInFlyout&&(a=null),c=this.getIcon(eo.TYPE),a){let d=this.getSurroundParent(),e=null;for(;d;)d.isCollapsed()&&(e=d),d=d.getSurroundParent();e&&e.setWarningText($.C.COLLAPSED_WARNINGS_WARNING,ii.COLLAPSED_WARNING_ID);c?c.addMessage(a,b):this.addIcon((new eo(this)).addMessage(a,b))}else c&&(b?(c.addMessage("",b),c.getText()||this.removeIcon(eo.TYPE)):this.removeIcon(eo.TYPE))}setMutator(a){this.removeIcon($.sh.TYPE);
1339
1340
  a&&this.addIcon(a)}addIcon(a){super.addIcon(a);a instanceof $.sh&&(this.mutator=a);a.initView(this.createIconPointerDownListener(a));a.applyColour();a.updateEditable();this.queueRender();return a}createIconPointerDownListener(a){return b=>{!this.isDeadOrDying()&&(b=this.workspace.getGesture(b))&&(this.bringToFront(),b.setStartIcon(a),$.t().focusNode(a))}}removeIcon(a){var b=super.removeIcon(a);a.equals($.sh.TYPE)&&(this.mutator=null);this.queueRender();return b}setDisabledReason(a,b){var c=this.isEnabled();
1340
1341
  super.setDisabledReason(a,b);this.isEnabled()===c||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(a){super.setDeletable(a);a?Ma(this.svgGroup,"blocklyNotDeletable"):n(this.svgGroup,"blocklyNotDeletable")}setHighlighted(a){this.pathObject.updateHighlighted(a)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(a){this.pathObject.updateDraggingDelete(a)}getColour(){return this.style.colourPrimary}setColour(a){super.setColour(a);
1341
1342
  a=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_);var b,c;(c=(b=this.pathObject).setStyle)==null||c.call(b,a.style);this.style=a.style;this.styleName_=a.name;this.applyColour()}setStyle(a){var b=this.workspace.getRenderer().getConstants().getBlockStyle(a);this.styleName_&&Ma(this.svgGroup,this.styleName_);if(b){this.hat=b.hat;let c,d;(d=(c=this.pathObject).setStyle)==null||d.call(c,b);this.colour_=b.colourPrimary;this.style=b;this.applyColour();n(this.svgGroup,a);
@@ -1350,49 +1351,49 @@ b){this.dragStrategy.drag(a,b)}endDrag(a,b){this.dragStrategy.endDrag(a,b)}rever
1350
1351
  a.getNestingLevel()+1:0}getFocusableElement(){var a=this.getFullBlockField();return a?a.getFocusableElement():this.pathObject.svgPath}getFocusableTree(){return this.workspace}onNodeFocus(){this.recomputeAriaContext();this.select();this.workspace.isFlyout||this.moveSvgRootToFront();var a=$.t().getFocusedNode();a&&a!==this&&cd().then(()=>{this.workspace.scrollBoundsIntoView(this.getBoundingRectangleWithoutChildren())})}onNodeBlur(){this.unselect()}canBeFocused(){return!0}performAction(a){if(this.workspace.isFlyout)ri.mover.startMove(this,
1351
1352
  a);else{if(this.isSimpleReporter())for(var b of this.inputList)for(let c of b.fieldRow)if(c.isClickable()&&c.isFullBlockField()){c.showEditor();return}if(this.workspace.getNavigator().getInNode(this))a=this.workspace,b=re(a.RTL?K.NAVIGATE_LEFT:K.NAVIGATE_RIGHT),b=$.C.KEYBOARD_NAV_BLOCK_NAVIGATION_HINT.replace("%1",b),li.show(a,{message:b,id:"blockNavigationHint"});else if(a=this.workspace,b=re("list_shortcuts"))b=$.C.HELP_PROMPT.replace("%1",b),li.show(a,{message:b,id:"helpHint"})}}getParents(){for(var a=
1352
1353
  new Set,b=this.getParent();b;)a.add(b),b=b.getParent();return a}getOutputParents(){var a=new Set;a.add(this);for(var b,c=(b=this.outputConnection)==null?void 0:b.targetBlock();c;){a.add(c);let d;c=(d=c.outputConnection)==null?void 0:d.targetBlock()}return a}getRowId(){var a,b,c=(a=this.outputConnection)==null?void 0:(b=a.targetConnection)==null?void 0:b.getParentInput();return c?c.getRowId():this.id}recomputeAriaContext(){var a=this.getFullBlockField();a?a.recomputeAriaContext():(l(this.getFocusableElement(),
1353
- p.LABEL,this.getAriaLabel(we.STANDARD)),ya(this.getSvgRoot(),Ka.NONE),a=this.getFocusableElement(),this.isInFlyout||ya(a,Ka.FIGURE),l(a,p.ROLEDESCRIPTION,this.getAriaRoleDescription()))}getAriaLabel(a){return Ce(this,a)}getStackBlocksCountLabel(){for(var a=1,b=this.getNextBlock();b;)a++,b=b.getNextBlock();return a<=1?Ce(this,we.TERSE):$.C.BLOCK_LABEL_STACK_BLOCKS.replace("%1",a.toString())}};ii.INLINE=-1;ii.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var eo=class{constructor(){}onDragEnter(){}onDragOver(){}onDragExit(){}onDrop(){}getClientRect(){return null}shouldPreventMove(){return!1}};var fo=class extends eo{constructor(){super();this.wouldDelete_=!1}wouldDelete(a){ri.mover.isMoving()?this.updateWouldDelete_(!1):a instanceof ii?(a=!a.getParent()&&a.isDeletable(),this.updateWouldDelete_(a)):this.updateWouldDelete_(fi(a)&&a.isDeletable());return this.wouldDelete_}updateWouldDelete_(a){this.wouldDelete_=a}};var go=class{constructor(a,b){this.element=a;this.type=b}getElement(){return this.element}getType(){return this.type}};var ho=class{constructor(a){this.workspace_=a}getDimensionsPx_(a){var b=0,c=0;a&&(b=a.getWidth(),c=a.getHeight());return new hc(b,c)}getFlyoutMetrics(a){a=this.getDimensionsPx_(this.workspace_.getFlyout(a));return{width:a.width,height:a.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){var a=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:a.width,height:a.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){var a=
1354
+ p.LABEL,this.getAriaLabel(we.STANDARD)),ya(this.getSvgRoot(),Ka.NONE),a=this.getFocusableElement(),this.isInFlyout||ya(a,Ka.FIGURE),l(a,p.ROLEDESCRIPTION,this.getAriaRoleDescription()))}getAriaLabel(a){return Ce(this,a)}getStackBlocksCountLabel(){for(var a=1,b=this.getNextBlock();b;)a++,b=b.getNextBlock();return a<=1?Ce(this,we.TERSE):$.C.BLOCK_LABEL_STACK_BLOCKS.replace("%1",a.toString())}};ii.INLINE=-1;ii.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var fo=class{constructor(){}onDragEnter(){}onDragOver(){}onDragExit(){}onDrop(){}getClientRect(){return null}shouldPreventMove(){return!1}};var go=class extends fo{constructor(){super();this.wouldDelete_=!1}wouldDelete(a){ri.mover.isMoving()?this.updateWouldDelete_(!1):a instanceof ii?(a=!a.getParent()&&a.isDeletable(),this.updateWouldDelete_(a)):this.updateWouldDelete_(fi(a)&&a.isDeletable());return this.wouldDelete_}updateWouldDelete_(a){this.wouldDelete_=a}};var ho=class{constructor(a,b){this.element=a;this.type=b}getElement(){return this.element}getType(){return this.type}};var io=class{constructor(a){this.workspace_=a}getDimensionsPx_(a){var b=0,c=0;a&&(b=a.getWidth(),c=a.getHeight());return new hc(b,c)}getFlyoutMetrics(a){a=this.getDimensionsPx_(this.workspace_.getFlyout(a));return{width:a.width,height:a.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){var a=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:a.width,height:a.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){var a=
1354
1355
  0,b=0,c=this.getToolboxMetrics(),d=this.getFlyoutMetrics(),e=!!this.workspace_.getToolbox(),f,g=!((f=this.workspace_.getFlyout())==null?0:f.autoClose);f=e?c.position:d.position;var h=f===F.TOP;f===F.LEFT&&(e&&(a+=c.width),g&&(a+=d.width));h&&(e&&(b+=c.height),g&&(b+=d.height));return{top:b,left:a}}getViewMetrics(a){a=a?this.workspace_.scale:1;var b=this.getSvgMetrics(),c=this.getToolboxMetrics(),d=this.getFlyoutMetrics(),e=!!this.workspace_.getToolbox(),f,g=!((f=this.workspace_.getFlyout())==null?
1355
1356
  0:f.autoClose);f=e?c.position:d.position;var h=f===F.LEFT||f===F.RIGHT;if(f===F.TOP||f===F.BOTTOM)e&&(b.height-=c.height),g&&(b.height-=d.height);h&&(e&&(b.width-=c.width),g&&(b.width-=d.width));return{height:b.height/a,width:b.width/a,top:-this.workspace_.scrollY/a,left:-this.workspace_.scrollX/a}}getContentMetrics(a){a=a?1:this.workspace_.scale;var b=this.workspace_.getBlocksBoundingBox();return{height:(b.bottom-b.top)*a,width:(b.right-b.left)*a,top:b.top*a,left:b.left*a}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||
1356
1357
  !this.workspace_.isMovableVertically()}getComputedFixedEdges_(a){if(!this.hasFixedEdges())return{};var b=this.workspace_.isMovableHorizontally(),c=this.workspace_.isMovableVertically();a=a||this.getViewMetrics(!1);var d={};c||(d.top=a.top,d.bottom=a.top+a.height);b||(d.left=a.left,d.right=a.left+a.width);return d}getPaddedContent_(a,b){var c=b.top+b.height,d=b.left+b.width,e=a.width;a=a.height;var f=e/2,g=a/2;return{top:Math.min(b.top-g,c-a),bottom:Math.max(c+g,b.top+a),left:Math.min(b.left-f,d-e),
1357
1358
  right:Math.max(d+f,b.left+e)}}getScrollMetrics(a,b,c){a=a?this.workspace_.scale:1;b=b||this.getViewMetrics(!1);var d=c||this.getContentMetrics();c=this.getComputedFixedEdges_(b);b=this.getPaddedContent_(b,d);d=c.top!==void 0?c.top:b.top;var e=c.left!==void 0?c.left:b.left;return{top:d/a,left:e/a,width:((c.right!==void 0?c.right:b.right)-e)/a,height:((c.bottom!==void 0?c.bottom:b.bottom)-d)/a}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){var a=
1358
1359
  this.getToolboxMetrics(),b=this.getFlyoutMetrics(!0),c=this.getSvgMetrics(),d=this.getAbsoluteMetrics(),e=this.getViewMetrics(),f=this.getContentMetrics(),g=this.getScrollMetrics(!1,e,f);return{contentHeight:f.height,contentWidth:f.width,contentTop:f.top,contentLeft:f.left,scrollHeight:g.height,scrollWidth:g.width,scrollTop:g.top,scrollLeft:g.left,viewHeight:e.height,viewWidth:e.width,viewTop:e.top,viewLeft:e.left,absoluteTop:d.top,absoluteLeft:d.left,svgHeight:c.height,svgWidth:c.width,toolboxWidth:a.width,
1359
- toolboxHeight:a.height,toolboxPosition:a.position,flyoutWidth:b.width,flyoutHeight:b.height}}};A(y.METRICS_MANAGER,"default",ho);var io=class extends ho{constructor(a,b){super(a);this.flyout_=b}getBoundingBox(){try{var a=this.workspace_.getCanvas().getBBox()}catch(b){a={height:0,y:0,width:0,x:0}}return a}getContentMetrics(a){var b=this.getBoundingBox();a=a?1:this.workspace_.scale;return{height:b.height*a,width:b.width*a,top:b.y*a,left:b.x*a}}getScrollMetrics(a,b,c){b=c||this.getContentMetrics();c=this.flyout_.MARGIN*this.workspace_.scale;a=a?this.workspace_.scale:1;return{height:(b.height+2*c)/a,width:(b.width+b.left+c)/a,
1360
- top:0,left:0}}};var jo=class{constructor(a,b){this.gap=a;this.axis=b;this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case "x":return new cc(this.y,this.y,this.x,this.x+this.gap);case "y":return new cc(this.y,this.y+this.gap,this.x,this.x)}}moveBy(a,b){this.x+=a;this.y+=b}isNavigable(){return!1}getFocusableElement(){throw Error("Cannot be focused");}getFocusableTree(){throw Error("Cannot be focused");}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}};var ko=class{getFirstChild(){return null}getParent(a){return a.getWorkspace()}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.getId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof Di}};var lo=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(){return"error"}isNavigable(){return!1}isApplicable(a){return a instanceof jo}};var mo=class{getFirstChild(a){return $i(a)[0]}getParent(a){var b;if((b=a.previousConnection)==null?0:b.targetBlock()){if(b=a.getSurroundParent())return b}else{let c;if((c=a.outputConnection)==null?0:c.targetBlock())return a.outputConnection.targetBlock()}return a.workspace}getNextSibling(a){if(a.nextConnection){let c;return(c=a.nextConnection.targetBlock())!=null?c:a.nextConnection}var b;return((b=a.outputConnection)==null?0:b.targetConnection)?(b=this.getParent(a),aj(b,a,1)):null}getPreviousSibling(a){var b;
1361
- if((b=a.previousConnection)==null?0:b.targetBlock())return a.previousConnection;var c;return((c=a.outputConnection)==null?0:c.targetBlock())?aj(a.outputConnection.targetBlock(),a,-1):null}getRowId(a){return a.getRowId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof ii}};var no=class{getFirstChild(){return null}getParent(a){var b;return(b=a.getOwner())!=null?b:null}getNextSibling(a){var b;return aj((b=a.getOwner())==null?void 0:b.getSourceBlock(),a,1)}getPreviousSibling(a){var b;return aj((b=a.getOwner())==null?void 0:b.getSourceBlock(),a,-1)}getRowId(a){var b,c,d;return(d=(b=a.getOwner())==null?void 0:(c=b.getSourceBlock())==null?void 0:c.getRowId())!=null?d:""}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof sn}};var oo=class{getFirstChild(){return null}getParent(a){return a.getCommentView().workspace.getCommentById(a.getCommentView().commentId)}getNextSibling(a){var b=a.getCommentView().getCommentBarButtons();a=b.indexOf(a);return a>=0&&a+1<b.length?b[a+1]:null}getPreviousSibling(a){var b=a.getCommentView().getCommentBarButtons();a=b.indexOf(a);return a>0?b[a-1]:null}getRowId(a){return a.getCommentView().commentId}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof dn}};var po=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.id}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof fn}};var qo=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){if(a.getParentInput())return aj(a.getSourceBlock(),a,1);if(a.type===G.NEXT_STATEMENT&&a.getSourceBlock().getSurroundParent()&&!a.targetConnection)return aj(a.getSourceBlock().getSurroundParent(),a,1);switch(a.type){case G.NEXT_STATEMENT:return a.targetConnection;case G.PREVIOUS_STATEMENT:case G.OUTPUT_VALUE:return a.getSourceBlock()}return null}getPreviousSibling(a){if(a.getParentInput())return aj(a.getParentInput().getSourceBlock(),
1360
+ toolboxHeight:a.height,toolboxPosition:a.position,flyoutWidth:b.width,flyoutHeight:b.height}}};A(y.METRICS_MANAGER,"default",io);var jo=class extends io{constructor(a,b){super(a);this.flyout_=b}getBoundingBox(){try{var a=this.workspace_.getCanvas().getBBox()}catch(b){a={height:0,y:0,width:0,x:0}}return a}getContentMetrics(a){var b=this.getBoundingBox();a=a?1:this.workspace_.scale;return{height:b.height*a,width:b.width*a,top:b.y*a,left:b.x*a}}getScrollMetrics(a,b,c){b=c||this.getContentMetrics();c=this.flyout_.MARGIN*this.workspace_.scale;a=a?this.workspace_.scale:1;return{height:(b.height+2*c)/a,width:(b.width+b.left+c)/a,
1361
+ top:0,left:0}}};var ko=class{constructor(a,b){this.gap=a;this.axis=b;this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case "x":return new cc(this.y,this.y,this.x,this.x+this.gap);case "y":return new cc(this.y,this.y+this.gap,this.x,this.x)}}moveBy(a,b){this.x+=a;this.y+=b}isNavigable(){return!1}getFocusableElement(){throw Error("Cannot be focused");}getFocusableTree(){throw Error("Cannot be focused");}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}};var lo=class{getFirstChild(){return null}getParent(a){return a.getWorkspace()}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.getId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof Di}};var mo=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(){return"error"}isNavigable(){return!1}isApplicable(a){return a instanceof ko}};var no=class{getFirstChild(a){return $i(a)[0]}getParent(a){var b;if((b=a.previousConnection)==null?0:b.targetBlock()){if(b=a.getSurroundParent())return b}else{let c;if((c=a.outputConnection)==null?0:c.targetBlock())return a.outputConnection.targetBlock()}return a.workspace}getNextSibling(a){if(a.nextConnection){let c;return(c=a.nextConnection.targetBlock())!=null?c:a.nextConnection}var b;return((b=a.outputConnection)==null?0:b.targetConnection)?(b=this.getParent(a),aj(b,a,1)):null}getPreviousSibling(a){var b;
1362
+ if((b=a.previousConnection)==null?0:b.targetBlock())return a.previousConnection;var c;return((c=a.outputConnection)==null?0:c.targetBlock())?aj(a.outputConnection.targetBlock(),a,-1):null}getRowId(a){return a.getRowId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof ii}};var oo=class{getFirstChild(){return null}getParent(a){var b;return(b=a.getOwner())!=null?b:null}getNextSibling(a){var b;return aj((b=a.getOwner())==null?void 0:b.getSourceBlock(),a,1)}getPreviousSibling(a){var b;return aj((b=a.getOwner())==null?void 0:b.getSourceBlock(),a,-1)}getRowId(a){var b,c,d;return(d=(b=a.getOwner())==null?void 0:(c=b.getSourceBlock())==null?void 0:c.getRowId())!=null?d:""}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof tn}};var po=class{getFirstChild(){return null}getParent(a){return a.getCommentView().workspace.getCommentById(a.getCommentView().commentId)}getNextSibling(a){var b=a.getCommentView().getCommentBarButtons();a=b.indexOf(a);return a>=0&&a+1<b.length?b[a+1]:null}getPreviousSibling(a){var b=a.getCommentView().getCommentBarButtons();a=b.indexOf(a);return a>0?b[a-1]:null}getRowId(a){return a.getCommentView().commentId}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof en}};var qo=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.id}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof gn}};var ro=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){if(a.getParentInput())return aj(a.getSourceBlock(),a,1);if(a.type===G.NEXT_STATEMENT&&a.getSourceBlock().getSurroundParent()&&!a.targetConnection)return aj(a.getSourceBlock().getSurroundParent(),a,1);switch(a.type){case G.NEXT_STATEMENT:return a.targetConnection;case G.PREVIOUS_STATEMENT:case G.OUTPUT_VALUE:return a.getSourceBlock()}return null}getPreviousSibling(a){if(a.getParentInput())return aj(a.getParentInput().getSourceBlock(),
1362
1363
  a,-1);switch(a.type){case G.NEXT_STATEMENT:return a.getSourceBlock();case G.PREVIOUS_STATEMENT:case G.OUTPUT_VALUE:return a.targetConnection}return null}getRowId(a){switch(a.type){case G.NEXT_STATEMENT:case G.PREVIOUS_STATEMENT:return a.id;case G.INPUT_VALUE:return a.getParentInput().getRowId();default:return a.getSourceBlock().getRowId()}}isNavigable(a){if(!a.canBeFocused())return!1;if(a.type===G.NEXT_STATEMENT){if(a.targetBlock())return!1;let b,c=(b=a.getSourceBlock().getRootBlock())!=null?b:a.getSourceBlock();
1363
- return a===c.lastConnectionInStack(!1)?!1:!0}return a.type===G.INPUT_VALUE&&!a.targetBlock()}isApplicable(a){return a instanceof Mi}};var ro=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){return aj(a.getSourceBlock(),a,1)}getPreviousSibling(a){return aj(a.getSourceBlock(),a,-1)}getRowId(a){return a.getParentInput().getRowId()}isNavigable(a){var b;return a.canBeFocused()&&a.isVisible()&&(a.isClickable()||a.isCurrentlyEditable())&&!(((b=a.getSourceBlock())==null?0:b.isSimpleReporter())&&a.isFullBlockField())&&a.getParentInput().isVisible()}isApplicable(a){return a instanceof rg}};var so=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){return aj(a.getSourceBlock(),a,1)}getPreviousSibling(a){return aj(a.getSourceBlock(),a,-1)}getRowId(a){return a.getSourceBlock().getRowId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof un}};var to=class{getFirstChild(a){return a.view.getCommentBarButtons()[0]}getParent(a){return a.workspace}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.id}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof dh}};var uo=class{getFirstChild(a){a=a.getTopBlocks(!0);return a.length?a[0]:null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.id}isNavigable(a){return a.canBeFocused()&&!a.isMutator}isApplicable(a){return a instanceof $h}};var vo,wo=vo||(vo={});wo[wo.NEXT=0]="NEXT";wo[wo.PREVIOUS=1]="PREVIOUS";wo[wo.IN=2]="IN";wo[wo.OUT=3]="OUT";
1364
- var xo=class{constructor(){this.rules=[new mo,new ro,new qo,new uo,new so,new to,new oo,new no,new po];this.navigationLoops=!0}addNavigationPolicy(a){this.rules.push(a)}get(a){return this.rules.find(b=>b.isApplicable(a))}getFirstChild(a){var b,c=(b=this.get(a))==null?void 0:b.getFirstChild(a);return c?this.isNavigable(c)?c:this.getFirstChild(c)||this.getNextSibling(c):null}getParent(a){var b,c=(b=this.get(a))==null?void 0:b.getParent(a);return c?this.isNavigable(c)?c:this.getParent(c):null}getNextSibling(a){var b,
1365
- c=(b=this.get(a))==null?void 0:b.getNextSibling(a);return c?this.isNavigable(c)?c:this.getNextSibling(c):null}getPreviousSibling(a){var b,c=(b=this.get(a))==null?void 0:b.getPreviousSibling(a);return c?this.isNavigable(c)?c:this.getPreviousSibling(c):null}getPreviousNode(a=$.t().getFocusedNode()){if(!a)return null;var b=this.getPreviousNodeImpl(a,a,vo.PREVIOUS);if(!b||b===a.getFocusableTree()){b=this.navigateStacks(a,-1);if(!b)return null;b=this.getLastNodeInStack(b,a)}return this.getLeftmostSibling(b)}getOutNode(a=
1366
- $.t().getFocusedNode()){return this.getPreviousNodeImpl(a,a,vo.OUT)}getNextNode(a=$.t().getFocusedNode()){var b=this.getNextNodeImpl(a,a,vo.NEXT);return a&&b===null?this.navigateStacks(a,1):b}getInNode(a=$.t().getFocusedNode()){return this.getNextNodeImpl(a,a,vo.IN)}getPreviousNodeImpl(a,b,c,d=new Set){if(!b||!a||d.has(b))return null;var e=this.getRightMostChild(this.getPreviousSibling(b),b)||this.getParent(b);return e&&this.transitionAllowed(a,e,c)?e:e?(d.add(b),this.getPreviousNodeImpl(a,e,c,d)):
1364
+ return a===c.lastConnectionInStack(!1)?!1:!0}return a.type===G.INPUT_VALUE&&!a.targetBlock()}isApplicable(a){return a instanceof Mi}};var so=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){return aj(a.getSourceBlock(),a,1)}getPreviousSibling(a){return aj(a.getSourceBlock(),a,-1)}getRowId(a){return a.getParentInput().getRowId()}isNavigable(a){var b;return a.canBeFocused()&&a.isVisible()&&(a.isClickable()||a.isCurrentlyEditable())&&!(((b=a.getSourceBlock())==null?0:b.isSimpleReporter())&&a.isFullBlockField())&&a.getParentInput().isVisible()}isApplicable(a){return a instanceof rg}};var to=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){return aj(a.getSourceBlock(),a,1)}getPreviousSibling(a){return aj(a.getSourceBlock(),a,-1)}getRowId(a){return a.getSourceBlock().getRowId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof vn}};var uo=class{getFirstChild(a){return a.view.getCommentBarButtons()[0]}getParent(a){return a.workspace}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.id}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof dh}};var vo=class{getFirstChild(a){a=a.getTopBlocks(!0);return a.length?a[0]:null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(a){return a.id}isNavigable(a){return a.canBeFocused()&&!a.isMutator}isApplicable(a){return a instanceof $h}};var wo,xo=wo||(wo={});xo[xo.NEXT=0]="NEXT";xo[xo.PREVIOUS=1]="PREVIOUS";xo[xo.IN=2]="IN";xo[xo.OUT=3]="OUT";
1365
+ var yo=class{constructor(){this.rules=[new no,new so,new ro,new vo,new to,new uo,new po,new oo,new qo];this.navigationLoops=!0}addNavigationPolicy(a){this.rules.push(a)}get(a){return this.rules.find(b=>b.isApplicable(a))}getFirstChild(a){var b,c=(b=this.get(a))==null?void 0:b.getFirstChild(a);return c?this.isNavigable(c)?c:this.getFirstChild(c)||this.getNextSibling(c):null}getParent(a){var b,c=(b=this.get(a))==null?void 0:b.getParent(a);return c?this.isNavigable(c)?c:this.getParent(c):null}getNextSibling(a){var b,
1366
+ c=(b=this.get(a))==null?void 0:b.getNextSibling(a);return c?this.isNavigable(c)?c:this.getNextSibling(c):null}getPreviousSibling(a){var b,c=(b=this.get(a))==null?void 0:b.getPreviousSibling(a);return c?this.isNavigable(c)?c:this.getPreviousSibling(c):null}getPreviousNode(a=$.t().getFocusedNode()){if(!a)return null;var b=this.getPreviousNodeImpl(a,a,wo.PREVIOUS);if(!b||b===a.getFocusableTree()){b=this.navigateStacks(a,-1);if(!b)return null;b=this.getLastNodeInStack(b,a)}return this.getLeftmostSibling(b)}getOutNode(a=
1367
+ $.t().getFocusedNode()){return this.getPreviousNodeImpl(a,a,wo.OUT)}getNextNode(a=$.t().getFocusedNode()){var b=this.getNextNodeImpl(a,a,wo.NEXT);return a&&b===null?this.navigateStacks(a,1):b}getInNode(a=$.t().getFocusedNode()){return this.getNextNodeImpl(a,a,wo.IN)}getPreviousNodeImpl(a,b,c,d=new Set){if(!b||!a||d.has(b))return null;var e=this.getRightMostChild(this.getPreviousSibling(b),b)||this.getParent(b);return e&&this.transitionAllowed(a,e,c)?e:e?(d.add(b),this.getPreviousNodeImpl(a,e,c,d)):
1367
1368
  null}getNextNodeImpl(a,b,c,d=new Set){if(!b||!a||d.has(b))return null;for(var e=this.getFirstChild(b)||this.getNextSibling(b),f=b;f&&!e;){f=this.getParent(f);if(!f)break;e=this.getNextSibling(f)}return e&&this.transitionAllowed(a,e,c)?e:e?(d.add(b),this.getNextNodeImpl(a,e,c,d)):null}getRightMostChild(a,b){if(!a)return a;var c=this.getFirstChild(a);if(!c||c===b)return a;for(a=c;a&&a!==b;a=this.getNextSibling(c))c=a;return this.getRightMostChild(c,b)}setNavigationLoops(a){this.navigationLoops=a}getNavigationLoops(){return this.navigationLoops}getFirstNode(){var a,
1368
- b=(a=$.t().getFocusedTree())==null?void 0:a.getRootFocusableNode();return b?this.getTopLevelItems(b)[0]:null}getLastNode(){var a,b=(a=$.t().getFocusedTree())==null?void 0:a.getRootFocusableNode();return b?this.getTopLevelItems(b).slice(-1)[0]:null}transitionAllowed(a,b,c){switch(c){case vo.IN:case vo.OUT:return this.getRowId(a)===this.getRowId(b);case vo.NEXT:case vo.PREVIOUS:return this.getRowId(a)!==this.getRowId(b)}}getLeftmostSibling(a){if(!a)return null;for(var b;b=this.getPreviousNodeImpl(a,
1369
- a,vo.OUT);)a=b;return a}getLastNodeInStack(a,b){for(var c;(c=this.getNextNodeImpl(a,a,vo.NEXT))&&c!==b;)a=c;return a}getRowId(a){var b;return(b=this.get(a))==null?void 0:b.getRowId(a)}navigateStacks(a,b){var c=this.getTopLevelItems(a),d,e,f=(e=(d=this.getSourceBlockFromNode(a))==null?void 0:d.getRootBlock())!=null?e:a;a=c.indexOf(f)+b;b=null;a>=0&&a<c.length?b=c[a]:a<0&&this.getNavigationLoops()?b=c[c.length-1]:a>=c.length&&this.getNavigationLoops()&&(b=c[0]);return b}getTopLevelItems(a){return a.getFocusableTree().getTopBoundedElements(!0)}isNavigable(a){var b;
1370
- return(b=this.get(a))==null?void 0:b.isNavigable(a)}getSourceBlockFromNode(a){return a instanceof ii?a:a instanceof rg||a instanceof Mi||a instanceof un?a.getSourceBlock():a instanceof fn?(a=a.getParent(),a instanceof ii?a:null):null}};var yo=class{getFirstChild(a){return bj(a)?a.getChildToolboxItems()[0]:null}getParent(a){return a.getParent()}getNextSibling(a){var b=a.getParentToolbox().getToolboxItems();a=b.indexOf(a);var c;return(c=b[a+1])!=null?c:null}getPreviousSibling(a){var b=a.getParentToolbox().getToolboxItems();a=b.indexOf(a);var c;return(c=b[a-1])!=null?c:null}getRowId(a){return a.getId()}isNavigable(a){return a.canBeFocused()&&this.allParentsExpanded(a)}allParentsExpanded(a){return(a=a.getParent())&&bj(a)?a.isExpanded()&&
1371
- this.allParentsExpanded(a):!0}isApplicable(a){return ue(a)}};var zo=class extends xo{constructor(a){super();this.toolbox=a;this.rules=[new yo]}getInNode(a=$.t().getFocusedNode(),b=!1){var c=cj(this.toolbox.getWorkspace());if(!b)switch(c){case F.TOP:case F.BOTTOM:return this.getNextNode(a,!0);case F.RIGHT:return this.getOutNode(a,!0)}if(!ve(a)||ve(a)&&!a.getContents().length)return null;var d;return(a=(d=this.toolbox.getFlyout())==null?void 0:d.getWorkspace().getNavigator())?!this.toolbox.getWorkspace().RTL||c!==F.TOP&&c!==F.BOTTOM?a.getFirstNode():a.getLastNode():
1369
+ b=(a=$.t().getFocusedTree())==null?void 0:a.getRootFocusableNode();return b?this.getTopLevelItems(b)[0]:null}getLastNode(){var a,b=(a=$.t().getFocusedTree())==null?void 0:a.getRootFocusableNode();return b?this.getTopLevelItems(b).slice(-1)[0]:null}transitionAllowed(a,b,c){switch(c){case wo.IN:case wo.OUT:return this.getRowId(a)===this.getRowId(b);case wo.NEXT:case wo.PREVIOUS:return this.getRowId(a)!==this.getRowId(b)}}getLeftmostSibling(a){if(!a)return null;for(var b;b=this.getPreviousNodeImpl(a,
1370
+ a,wo.OUT);)a=b;return a}getLastNodeInStack(a,b){for(var c;(c=this.getNextNodeImpl(a,a,wo.NEXT))&&c!==b;)a=c;return a}getRowId(a){var b;return(b=this.get(a))==null?void 0:b.getRowId(a)}navigateStacks(a,b){var c=this.getTopLevelItems(a),d,e,f=(e=(d=this.getSourceBlockFromNode(a))==null?void 0:d.getRootBlock())!=null?e:a;a=c.indexOf(f)+b;b=null;a>=0&&a<c.length?b=c[a]:a<0&&this.getNavigationLoops()?b=c[c.length-1]:a>=c.length&&this.getNavigationLoops()&&(b=c[0]);return b}getTopLevelItems(a){return a.getFocusableTree().getTopBoundedElements(!0)}isNavigable(a){var b;
1371
+ return(b=this.get(a))==null?void 0:b.isNavigable(a)}getSourceBlockFromNode(a){return a instanceof ii?a:a instanceof rg||a instanceof Mi||a instanceof vn?a.getSourceBlock():a instanceof gn?(a=a.getParent(),a instanceof ii?a:null):null}};var zo=class{getFirstChild(a){return bj(a)?a.getChildToolboxItems()[0]:null}getParent(a){return a.getParent()}getNextSibling(a){var b=a.getParentToolbox().getToolboxItems();a=b.indexOf(a);var c;return(c=b[a+1])!=null?c:null}getPreviousSibling(a){var b=a.getParentToolbox().getToolboxItems();a=b.indexOf(a);var c;return(c=b[a-1])!=null?c:null}getRowId(a){return a.getId()}isNavigable(a){return a.canBeFocused()&&this.allParentsExpanded(a)}allParentsExpanded(a){return(a=a.getParent())&&bj(a)?a.isExpanded()&&
1372
+ this.allParentsExpanded(a):!0}isApplicable(a){return ue(a)}};var Ao=class extends yo{constructor(a){super();this.toolbox=a;this.rules=[new zo]}getInNode(a=$.t().getFocusedNode(),b=!1){var c=cj(this.toolbox.getWorkspace());if(!b)switch(c){case F.TOP:case F.BOTTOM:return this.getNextNode(a,!0);case F.RIGHT:return this.getOutNode(a,!0)}if(!ve(a)||ve(a)&&!a.getContents().length)return null;var d;return(a=(d=this.toolbox.getFlyout())==null?void 0:d.getWorkspace().getNavigator())?!this.toolbox.getWorkspace().RTL||c!==F.TOP&&c!==F.BOTTOM?a.getFirstNode():a.getLastNode():
1372
1373
  null}getOutNode(a,b=!1){if(!b)switch(cj(this.toolbox.getWorkspace())){case F.TOP:case F.BOTTOM:return this.getPreviousNode(a,!0);case F.RIGHT:return this.getInNode(a,!0)}return super.getOutNode(a)}getNextNode(a,b=!1){if(!b)switch(cj(this.toolbox.getWorkspace())){case F.TOP:return this.getInNode(a,!0);case F.BOTTOM:return this.getOutNode(a,!0)}return super.getNextNode(a)}getPreviousNode(a,b=!1){if(!b)switch(cj(this.toolbox.getWorkspace())){case F.TOP:return this.getOutNode(a,!0);case F.BOTTOM:return this.getInNode(a,
1373
- !0)}return super.getPreviousNode(a)}getTopLevelItems(){return this.toolbox.getToolboxItems()}};var Ao=class extends xo{constructor(a){super();this.flyout=a;this.rules.push(new ko,new lo)}getOutNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(cj(this.flyout.targetWorkspace)){case F.TOP:case F.BOTTOM:return this.flyout.RTL?this.getNextNode(a,!0):this.getPreviousNode(a,!0);case F.RIGHT:return null}var c;return(a=(c=this.flyout.targetWorkspace)==null?void 0:c.getToolbox())?a.getSelectedItem():null}getInNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(cj(this.flyout.targetWorkspace)){case F.TOP:case F.BOTTOM:return this.flyout.RTL?
1374
+ !0)}return super.getPreviousNode(a)}getTopLevelItems(){return this.toolbox.getToolboxItems()}};var Bo=class extends yo{constructor(a){super();this.flyout=a;this.rules.push(new lo,new mo)}getOutNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(cj(this.flyout.targetWorkspace)){case F.TOP:case F.BOTTOM:return this.flyout.RTL?this.getNextNode(a,!0):this.getPreviousNode(a,!0);case F.RIGHT:return null}var c;return(a=(c=this.flyout.targetWorkspace)==null?void 0:c.getToolbox())?a.getSelectedItem():null}getInNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(cj(this.flyout.targetWorkspace)){case F.TOP:case F.BOTTOM:return this.flyout.RTL?
1374
1375
  this.getPreviousNode(a,!0):this.getNextNode(a,!0);case F.RIGHT:return this.getOutNode(a,!0)}return super.getInNode(a)}getNextNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(cj(this.flyout.targetWorkspace)){case F.TOP:return null;case F.BOTTOM:return this.getOutNode(a,!0)}return super.getNextNode(a)}getPreviousNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(cj(this.flyout.targetWorkspace)){case F.TOP:return this.getOutNode(a,!0);case F.BOTTOM:return null}return super.getPreviousNode(a)}getTopLevelItems(){return this.flyout.getContents().map(a=>
1375
- a.getElement()).filter(a=>this.isNavigable(a))}isNavigable(a){return super.isNavigable(a)&&this.flyout.getContents().map(b=>b.getElement()).includes(a)}};var Gj=class{constructor(a,b,c,d,e){this.workspace=a;this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null;b=b===void 0?!0:b;c=c===void 0?!0:c;var f=b&&c;b&&(this.hScroll=new Ic(a,!0,f,d,e));c&&(this.vScroll=new Ic(a,!1,f,d,e));f&&(this.corner_=r(q.RECT,{height:Ic.scrollbarThickness,width:Ic.scrollbarThickness,"class":"blocklyScrollbarBackground"}),Pa(this.corner_,a.getBubbleCanvas()))}dispose(){Oa(this.corner_);this.oldHostMetrics=this.corner_=null;this.hScroll&&(this.hScroll.dispose(),
1376
+ a.getElement()).filter(a=>this.isNavigable(a))}isNavigable(a){return super.isNavigable(a)&&this.flyout.getContents().map(b=>b.getElement()).includes(a)}};var Hj=class{constructor(a,b,c,d,e){this.workspace=a;this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null;b=b===void 0?!0:b;c=c===void 0?!0:c;var f=b&&c;b&&(this.hScroll=new Ic(a,!0,f,d,e));c&&(this.vScroll=new Ic(a,!1,f,d,e));f&&(this.corner_=r(q.RECT,{height:Ic.scrollbarThickness,width:Ic.scrollbarThickness,"class":"blocklyScrollbarBackground"}),Pa(this.corner_,a.getBubbleCanvas()))}dispose(){Oa(this.corner_);this.oldHostMetrics=this.corner_=null;this.hScroll&&(this.hScroll.dispose(),
1376
1377
  this.hScroll=null);this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){var a=this.workspace.getMetrics();if(a){var b=!1,c=!1;this.oldHostMetrics&&this.oldHostMetrics.viewWidth===a.viewWidth&&this.oldHostMetrics.viewHeight===a.viewHeight&&this.oldHostMetrics.absoluteTop===a.absoluteTop&&this.oldHostMetrics.absoluteLeft===a.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===a.scrollWidth&&this.oldHostMetrics.viewLeft===a.viewLeft&&this.oldHostMetrics.scrollLeft===a.scrollLeft||
1377
1378
  (b=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===a.scrollHeight&&this.oldHostMetrics.viewTop===a.viewTop&&this.oldHostMetrics.scrollTop===a.scrollTop||(c=!0)):c=b=!0;if(b||c){try{$.Ub++,this.hScroll&&b&&this.hScroll.resize(a),this.vScroll&&c&&this.vScroll.resize(a)}finally{$.Ub--}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==a.viewWidth||this.oldHostMetrics.absoluteLeft!==a.absoluteLeft){let d;(d=
1378
1379
  this.corner_)==null||d.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==a.viewHeight||this.oldHostMetrics.absoluteTop!==a.absoluteTop){let d;(d=this.corner_)==null||d.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics=a}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(a,b){this.hScroll&&this.hScroll.setOrigin(a,b);this.vScroll&&this.vScroll.setOrigin(a,b)}set(a,b,c){this.hScroll&&
1379
1380
  this.hScroll.set(a,!1);this.vScroll&&this.vScroll.set(b,!1);if(c||c===void 0)a={},this.hScroll&&(a.x=this.hScroll.getRatio_()),this.vScroll&&(a.y=this.vScroll.getRatio_()),this.workspace.setMetrics(a)}setX(a){this.hScroll&&this.hScroll.set(a,!0)}setY(a){this.vScroll&&this.vScroll.set(a,!0)}setContainerVisible(a){this.hScroll&&this.hScroll.setContainerVisible(a);this.vScroll&&this.vScroll.setContainerVisible(a)}isVisible(){var a=!1;this.hScroll&&(a=this.hScroll.isVisible());this.vScroll&&(a=a||this.vScroll.isVisible());
1380
- return a}setVisible(a){this.hScroll&&this.hScroll.setVisibleInternal(a);this.vScroll&&this.vScroll.setVisibleInternal(a)}resizeContent(a){this.hScroll&&this.hScroll.resizeContentHorizontal(a);this.vScroll&&this.vScroll.resizeContentVertical(a)}resizeView(a){this.hScroll&&this.hScroll.resizeViewHorizontal(a);this.vScroll&&this.vScroll.resizeViewVertical(a)}};var Bo=class{load(a,b){a=new jo(0,b.horizontalLayout?"x":"y");return new go(a,"sep")}gapForItem(a,b){var c;return(c=parseInt(String(a.gap)))!=null?c:b}disposeItem(){}getType(){return"sep"}};A(y.FLYOUT_INFLATER,"sep",Bo);var Co=class extends fo{constructor(a){super();this.horizontalLayout=!1;this.boundEvents=[];this.reflowWrapper=null;this.inhibitReflowWrapper=!1;this.contents=[];this.autoClose=!0;this.visible=!1;this.containerVisible=!0;this.CORNER_RADIUS=8;this.SCROLLBAR_MARGIN=2.5;this.height_=this.width_=0;this.svgGroup_=this.svgBackground_=null;this.inflaters=new Map;a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new $h(a);this.workspace_.setMetricsManager(new io(this.workspace_,this));this.workspace_.internalIsFlyout=
1381
- !0;this.workspace_.setVisible(this.visible);this.workspace_.setNavigator(new Ao(this));this.id=Nb();this.RTL=!!a.RTL;this.toolboxPosition_=a.toolboxPosition;this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH;this.MARGIN=this.CORNER_RADIUS;this.GAP_X=this.MARGIN*3;this.GAP_Y=this.MARGIN*3}createDom(a){this.svgGroup_=r(a,{"class":"blocklyFlyout"});this.svgGroup_.style.display="none";this.svgBackground_=r(q.PATH,{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());
1381
+ return a}setVisible(a){this.hScroll&&this.hScroll.setVisibleInternal(a);this.vScroll&&this.vScroll.setVisibleInternal(a)}resizeContent(a){this.hScroll&&this.hScroll.resizeContentHorizontal(a);this.vScroll&&this.vScroll.resizeContentVertical(a)}resizeView(a){this.hScroll&&this.hScroll.resizeViewHorizontal(a);this.vScroll&&this.vScroll.resizeViewVertical(a)}};var Co=class{load(a,b){a=new ko(0,b.horizontalLayout?"x":"y");return new ho(a,"sep")}gapForItem(a,b){var c;return(c=parseInt(String(a.gap)))!=null?c:b}disposeItem(){}getType(){return"sep"}};A(y.FLYOUT_INFLATER,"sep",Co);var Do=class extends go{constructor(a){super();this.horizontalLayout=!1;this.boundEvents=[];this.reflowWrapper=null;this.inhibitReflowWrapper=!1;this.contents=[];this.autoClose=!0;this.visible=!1;this.containerVisible=!0;this.CORNER_RADIUS=8;this.SCROLLBAR_MARGIN=2.5;this.height_=this.width_=0;this.svgGroup_=this.svgBackground_=null;this.inflaters=new Map;a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new $h(a);this.workspace_.setMetricsManager(new jo(this.workspace_,this));this.workspace_.internalIsFlyout=
1382
+ !0;this.workspace_.setVisible(this.visible);this.workspace_.setNavigator(new Bo(this));this.id=Nb();this.RTL=!!a.RTL;this.toolboxPosition_=a.toolboxPosition;this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH;this.MARGIN=this.CORNER_RADIUS;this.GAP_X=this.MARGIN*3;this.GAP_Y=this.MARGIN*3}createDom(a){this.svgGroup_=r(a,{"class":"blocklyFlyout"});this.svgGroup_.style.display="none";this.svgBackground_=r(q.PATH,{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());
1382
1383
  this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutBackgroundColour","fill");this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutOpacity","fill-opacity");this.svgGroup_.addEventListener("keydown",b=>{b.key==="Escape"&&($.t().focusTree(this.targetWorkspace),this.targetWorkspace.isMutator||this.autoHide(!1),b.preventDefault(),b.stopPropagation())});return this.svgGroup_}init(a){this.targetWorkspace=a;this.workspace_.targetWorkspace=a;this.workspace_.setInitialAriaContext();
1383
- this.workspace_.scrollbar=new Gj(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN);this.hide();this.boundEvents.push(k(this.svgGroup_,"wheel",this,this.wheel_,!1,{passive:!1}));this.boundEvents.push(k(this.svgBackground_,"pointerdown",this,this.onMouseDown));this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace);this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap());this.workspace_.createPotentialVariableMap();
1384
- a.getComponentManager().addComponent({component:this,weight:Dk.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Dk.Capability.AUTOHIDEABLE,Dk.Capability.DELETE_AREA,Dk.Capability.DRAG_TARGET]})}dispose(){this.hide();this.targetWorkspace.getComponentManager().removeComponent(this.id);for(let a of this.boundEvents)ka(a);this.boundEvents.length=0;this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose());this.svgGroup_&&Oa(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(a){this.autoClose=
1384
+ this.workspace_.scrollbar=new Hj(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN);this.hide();this.boundEvents.push(k(this.svgGroup_,"wheel",this,this.wheel_,!1,{passive:!1}));this.boundEvents.push(k(this.svgBackground_,"pointerdown",this,this.onMouseDown));this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace);this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap());this.workspace_.createPotentialVariableMap();
1385
+ a.getComponentManager().addComponent({component:this,weight:Ek.ComponentWeight.FLYOUT_WEIGHT,capabilities:[Ek.Capability.AUTOHIDEABLE,Ek.Capability.DELETE_AREA,Ek.Capability.DRAG_TARGET]})}dispose(){this.hide();this.targetWorkspace.getComponentManager().removeComponent(this.id);for(let a of this.boundEvents)ka(a);this.boundEvents.length=0;this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose());this.svgGroup_&&Oa(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(a){this.autoClose=
1385
1386
  a;this.targetWorkspace.recordDragTargets();this.targetWorkspace.resizeContents()}autoHide(a){!a&&this.targetWorkspace.getFlyout(!0)===this&&this.autoClose&&this.hide()}getTargetWorkspace(){return this.targetWorkspace}isVisible(){return this.visible}setVisible(a){var b=a!==this.isVisible();this.visible=a;b&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(a){var b=a!==this.containerVisible;this.containerVisible=a;b&&this.updateDisplay()}getContents(){return this.contents}setContents(a){this.contents=
1386
1387
  a}updateDisplay(){var a=this.containerVisible?this.isVisible():!1;this.svgGroup_&&(this.svgGroup_.style.display=a?"block":"none");var b;(b=this.workspace_.scrollbar)==null||b.setContainerVisible(a)}positionAt_(a,b,c,d){var e;(e=this.svgGroup_)==null||e.setAttribute("width",`${a}`);var f;(f=this.svgGroup_)==null||f.setAttribute("height",`${b}`);this.workspace_.setCachedParentSvgSize(a,b);this.svgGroup_&&Qa(this.svgGroup_,"translate("+c+"px,"+d+"px)");if(a=this.workspace_.scrollbar)a.setOrigin(c,d),
1387
1388
  a.resize(),a.hScroll&&a.hScroll.setPosition(a.hScroll.position.x,a.hScroll.position.y),a.vScroll&&a.vScroll.setPosition(a.vScroll.position.x,a.vScroll.position.y)}hide(){this.isVisible()&&(this.setVisible(!1),this.reflowWrapper&&(this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowWrapper=null))}show(a){$.t().getFocusedTree()===this.workspace_&&$.t().getFocusedNode()!==this.workspace_&&$.t().focusNode(this.workspace_);this.workspace_.setResizesEnabled(!1);$.Qc=!1;this.hide();this.clearOldBlocks();
1388
1389
  typeof a==="string"&&(a=this.getDynamicCategoryContents(a));this.setVisible(!0);a=Dc(a);a=this.createFlyoutInfo(a);dd(this.workspace_);this.setContents(a);this.layout_(a);this.horizontalLayout?this.height_=0:this.width_=0;this.reflow();this.updateAriaContext();$.Qc=!0;this.workspace_.setResizesEnabled(!0);this.reflowWrapper=b=>{this.inhibitReflowWrapper||b.type!==v.BLOCK_CHANGE&&b.type!==v.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()};this.workspace_.addChangeListener(this.reflowWrapper)}updateAriaContext(){var a=
1389
1390
  this.getContents().map(c=>c.getElement()).filter(c=>c.canBeFocused()).map(c=>c.getFocusableElement().id);l(this.getWorkspace().getCanvas(),p.OWNS,a.join(" "));this.targetWorkspace.isMutator||this.autoClose?ya(this.getWorkspace().svgGroup_,Ka.NONE):ya(this.getWorkspace().svgGroup_,Ka.REGION);var b=(a=(b=this.targetWorkspace.getToolbox())==null?void 0:b.getSelectedItem())&&ve(a)?a.getName():"";b=$.C.WORKSPACE_LABEL_FLYOUT_WORKSPACE.replace("%1",b).trim();l(this.getWorkspace().getCanvas(),p.LABEL,b);
1390
- ya(this.getWorkspace().getCanvas(),Ka.LISTBOX)}createFlyoutInfo(a){var b=[],c=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(let d of a)if("custom"in d&&(a=this.getDynamicCategoryContents(d.custom),a=Dc(a),b.push(...this.createFlyoutInfo(a))),a=d.kind.toLowerCase(),a=this.getInflaterForType(a))b.push(a.load(d,this)),(a=a.gapForItem(d,c))&&b.push(new go(new jo(a,this.horizontalLayout?"x":"y"),"sep"));return this.normalizeSeparators(b)}normalizeSeparators(a){for(let b=a.length-1;b>0;b--){let c=a[b].getType().toLowerCase(),
1391
+ ya(this.getWorkspace().getCanvas(),Ka.LISTBOX)}createFlyoutInfo(a){var b=[],c=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(let d of a)if("custom"in d&&(a=this.getDynamicCategoryContents(d.custom),a=Dc(a),b.push(...this.createFlyoutInfo(a))),a=d.kind.toLowerCase(),a=this.getInflaterForType(a))b.push(a.load(d,this)),(a=a.gapForItem(d,c))&&b.push(new ho(new ko(a,this.horizontalLayout?"x":"y"),"sep"));return this.normalizeSeparators(b)}normalizeSeparators(a){for(let b=a.length-1;b>0;b--){let c=a[b].getType().toLowerCase(),
1391
1392
  d=a[b-1].getType().toLowerCase();c==="sep"&&d==="sep"&&a.splice(b-1,1)}return a}getDynamicCategoryContents(a){a=this.workspace_.targetWorkspace.getToolboxCategoryCallback(a);if(typeof a!=="function")throw TypeError("Couldn't find a callback function when opening a toolbox category.");return a(this.workspace_.targetWorkspace)}clearOldBlocks(){this.getContents().forEach(b=>{var c;(c=this.getInflaterForType(b.getType()))==null||c.disposeItem(b)});var a;(a=this.workspace_.getPotentialVariableMap())==
1392
- null||a.clear()}onMouseDown(a){var b=this.targetWorkspace.getGesture(a);b&&b.handleFlyoutStart(a,this)}reflow(){this.inhibitReflowWrapper=!0;this.reflowInternal_();this.inhibitReflowWrapper=!1}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}getInflaterForType(a){if(this.inflaters.has(a)){var b;return(b=this.inflaters.get(a))!=null?b:null}return(b=Fb(y.FLYOUT_INFLATER,a,void 0))?(b=new b,this.inflaters.set(a,b),b):null}};var Do=class{constructor(a){this.workspace=a;this.horizontalScrollEnabled=this.workspace.isMovableHorizontally();this.verticalScrollEnabled=this.workspace.isMovableVertically();this.startScrollXY_=new D(a.scrollX,a.scrollY)}startDrag(){}endDrag(a){this.drag(a)}drag(a){a=D.sum(this.startScrollXY_,a);if(this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(a.x,a.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(a.x,this.workspace.scrollY);else if(this.verticalScrollEnabled)this.workspace.scroll(this.workspace.scrollX,
1393
- a.y);else throw new TypeError("Invalid state.");}};var Eo=class{constructor(a,b){this.creatorWorkspace=b;this.mouseDownXY=new D(0,0);this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null;this.hasExceededDragRadius=!1;this.boundEvents=[];this.workspaceDragger=this.dragger=null;this.dragging=!1;this.flyout=null;this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1;this.cachedPoints=new Map;this.startDistance=this.previousScale=0;this.currentDropdownOwner=
1393
+ null||a.clear()}onMouseDown(a){var b=this.targetWorkspace.getGesture(a);b&&b.handleFlyoutStart(a,this)}reflow(){this.inhibitReflowWrapper=!0;this.reflowInternal_();this.inhibitReflowWrapper=!1}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}getInflaterForType(a){if(this.inflaters.has(a)){var b;return(b=this.inflaters.get(a))!=null?b:null}return(b=Fb(y.FLYOUT_INFLATER,a,void 0))?(b=new b,this.inflaters.set(a,b),b):null}};var Eo=class{constructor(a){this.workspace=a;this.horizontalScrollEnabled=this.workspace.isMovableHorizontally();this.verticalScrollEnabled=this.workspace.isMovableVertically();this.startScrollXY_=new D(a.scrollX,a.scrollY)}startDrag(){}endDrag(a){this.drag(a)}drag(a){a=D.sum(this.startScrollXY_,a);if(this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(a.x,a.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(a.x,this.workspace.scrollY);else if(this.verticalScrollEnabled)this.workspace.scroll(this.workspace.scrollX,
1394
+ a.y);else throw new TypeError("Invalid state.");}};var Fo=class{constructor(a,b){this.creatorWorkspace=b;this.mouseDownXY=new D(0,0);this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null;this.hasExceededDragRadius=!1;this.boundEvents=[];this.workspaceDragger=this.dragger=null;this.dragging=!1;this.flyout=null;this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1;this.cachedPoints=new Map;this.startDistance=this.previousScale=0;this.currentDropdownOwner=
1394
1395
  this.isPinchZoomEnabled=null;this.mostRecentEvent=a;this.currentDragDeltaXY=new D(0,0)}dispose(){ha=null;Jf=!1;this.creatorWorkspace.clearGesture();for(let a of this.boundEvents)ka(a);this.boundEvents.length=0}updateFromEvent(a){var b=new D(a.clientX,a.clientY);this.updateDragDelta(b)&&(this.updateIsDragging(a),aa());this.mostRecentEvent=a}updateDragDelta(a){this.currentDragDeltaXY=D.difference(a,this.mouseDownXY);return this.hasExceededDragRadius?!1:this.hasExceededDragRadius=D.magnitude(this.currentDragDeltaXY)>
1395
- (this.flyout?$.Og.flyoutDragRadius:$.Og.dragRadius)}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");if(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())this.dragging=!0,this.workspaceDragger=new Do(this.startWorkspace_),this.workspaceDragger.startDrag()}updateIsDragging(a){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");
1396
+ (this.flyout?$.Og.flyoutDragRadius:$.Og.dragRadius)}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");if(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())this.dragging=!0,this.workspaceDragger=new Eo(this.startWorkspace_),this.workspaceDragger.startDrag()}updateIsDragging(a){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");
1396
1397
  if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0;var b=nb();b&&gi(b)&&b.isMovable()?(this.dragging=!0,this.dragger=this.createDragger(b),this.dragger.onDragStart(a),this.dragger.onDrag(a,this.currentDragDeltaXY)):this.updateIsDraggingWorkspace()}createDragger(a){return new (Jb(y.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(a)}doStart(a){if(!this.startWorkspace_)throw Error("Cannot start the touch gesture becauase the start workspace is undefined");
1397
1398
  this.isPinchZoomEnabled=this.startWorkspace_.options.zoomOptions&&this.startWorkspace_.options.zoomOptions.pinch;la(a)?this.cancel():(this.gestureHasStarted=!0,Mh(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=ff,this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=a,Vf(),na(a)?this.handleRightClick(a):(a.type.toLowerCase()==="pointerdown"&&a.pointerType!==
1398
1399
  "mouse"&&ca(a,this),this.mouseDownXY=new D(a.clientX,a.clientY),this.bindMouseEvents(a),this.isEnding_||this.handleTouchStart(a)))}bindMouseEvents(a){this.boundEvents.push(k(document,"pointerdown",null,this.handleStart.bind(this),!0));this.boundEvents.push(k(document,"pointermove",null,this.handleMove.bind(this),!0));this.boundEvents.push(k(document,"pointerup",null,this.handleUp.bind(this),!0));this.boundEvents.push(k(document,"pointercancel",null,this.handleUp.bind(this),!0));a.preventDefault();
@@ -1409,37 +1410,37 @@ b=oc(c,b);a.x=b.x;a.y=b.y;de(a,c,{recordUndo:!0});c.hideChaff(!1)}}else{if(!this
1409
1410
  a)}setStartIcon(a){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=a)}setStartBubble(a){this.startBubble||(this.startBubble=a)}setStartComment(a){this.startComment||(this.startComment=a)}setStartBlock(a){var b,c,d;this.startBlock||this.startBubble||this.startIcon&&(!a.isInFlyout||((d=(c=this.startIcon).isClickableInFlyout)==null?0:d.call(c,!((b=a.workspace.getFlyout())==null||!b.autoClose))))||(this.startBlock=
1410
1411
  a,a.isInFlyout&&a!==a.getRootBlock()?this.setTargetBlock(a.getRootBlock()):this.setTargetBlock(a))}setTargetBlock(a){a.isShadow()?this.setTargetBlock(a.getParent()):(this.targetBlock=a,this.targetBlock.bringToFront(),$.t().focusNode(this.targetBlock))}setStartWorkspace(a){this.startWorkspace_||(this.startWorkspace_=a)}setStartFlyout(a){this.flyout||(this.flyout=a)}isBubbleClick(){return!!this.startBubble&&!this.hasExceededDragRadius}isCommentClick(){return!!this.startComment&&!this.hasExceededDragRadius}isBlockClick(){return!!this.startBlock&&
1411
1412
  !this.hasExceededDragRadius&&!this.isFieldClick()&&!this.isIconClick()}isFieldClick(){return this.startField?this.startField.isClickable()&&!this.hasExceededDragRadius&&(!this.flyout||this.startField.isClickableInFlyout(this.flyout.autoClose)):!1}isIconClick(){if(!this.startIcon)return!1;var a=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&a}isWorkspaceClick(){return!this.startBlock&&!this.startBubble&&
1412
- !this.startField&&!this.hasExceededDragRadius}getCurrentDragger(){var a,b;return(b=(a=this.workspaceDragger)!=null?a:this.dragger)!=null?b:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){var a=gb();for(let b=0,c;c=a[b];b++)if(c.currentGesture_)return!0;return!1}};var Cj=class{constructor(a,b){this.pattern=a;this.scale=1;var c;this.spacing=(c=b.spacing)!=null?c:0;var d;this.length=(d=b.length)!=null?d:1;this.line2=(this.line1=a.firstChild)&&this.line1.nextSibling;var e;this.snapToGrid=(e=b.snap)!=null?e:!1}setSpacing(a){this.spacing=a;this.update(this.scale)}getSpacing(){return this.spacing}setLength(a){this.length=a;this.update(this.scale)}getLength(){return this.length}setSnapToGrid(a){this.snapToGrid=a}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(a){this.scale=
1413
+ !this.startField&&!this.hasExceededDragRadius}getCurrentDragger(){var a,b;return(b=(a=this.workspaceDragger)!=null?a:this.dragger)!=null?b:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){var a=gb();for(let b=0,c;c=a[b];b++)if(c.currentGesture_)return!0;return!1}};var Dj=class{constructor(a,b){this.pattern=a;this.scale=1;var c;this.spacing=(c=b.spacing)!=null?c:0;var d;this.length=(d=b.length)!=null?d:1;this.line2=(this.line1=a.firstChild)&&this.line1.nextSibling;var e;this.snapToGrid=(e=b.snap)!=null?e:!1}setSpacing(a){this.spacing=a;this.update(this.scale)}getSpacing(){return this.spacing}setLength(a){this.length=a;this.update(this.scale)}getLength(){return this.length}setSnapToGrid(a){this.snapToGrid=a}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(a){this.scale=
1413
1414
  a;var b=this.spacing*a;this.pattern.setAttribute("width",`${b}`);this.pattern.setAttribute("height",`${b}`);b=Math.floor(this.spacing/2)+.5;var c=b-this.length/2,d=b+this.length/2;b*=a;c*=a;d*=a;this.setLineAttributes(this.line1,a,c,d,b,b);this.setLineAttributes(this.line2,a,b,b,c,d)}setLineAttributes(a,b,c,d,e,f){a&&(a.setAttribute("stroke-width",`${b}`),a.setAttribute("x1",`${c}`),a.setAttribute("y1",`${e}`),a.setAttribute("x2",`${d}`),a.setAttribute("y2",`${f}`))}moveTo(a,b){this.pattern.setAttribute("x",
1414
1415
  `${a}`);this.pattern.setAttribute("y",`${b}`)}alignXY(a){var b=this.getSpacing(),c=b/2,d=Math.round(Math.round((a.x-c)/b)*b+c);b=Math.round(Math.round((a.y-c)/b)*b+c);return d===a.x&&b===a.y?a:new D(d,b)}static createDom(a,b,c,d){a=r(q.PATTERN,{id:"blocklyGridPattern"+a,patternUnits:"userSpaceOnUse"},c);var e,f;if(((e=b.length)!=null?e:1)>0&&((f=b.spacing)!=null?f:0)>0){r(q.LINE,{stroke:b.colour},a);let g;(g=b.length)!=null&&g&&r(q.LINE,{stroke:b.colour},a)}else r(q.LINE,{},a);d&&d.style.setProperty("--blocklyGridPattern",
1415
- `url(#${a.id})`);return a}};var Fo=class{constructor(a){this.workspace=a;this.layers=new Map;if(a=a.getInjectionDiv())this.dragLayer=this.createDragLayer(a),this.animationLayer=this.createAnimationLayer(a);a=this.createLayer(50);n(a,"blocklyBlockCanvas");a=this.createLayer(100);n(a,"blocklyBubbleCanvas")}createDragLayer(a){var b=r(q.SVG,{"class":"blocklyBlockDragSurface",xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});a.append(b);return r(q.G,
1416
+ `url(#${a.id})`);return a}};var Go=class{constructor(a){this.workspace=a;this.layers=new Map;if(a=a.getInjectionDiv())this.dragLayer=this.createDragLayer(a),this.animationLayer=this.createAnimationLayer(a);a=this.createLayer(50);n(a,"blocklyBlockCanvas");a=this.createLayer(100);n(a,"blocklyBubbleCanvas")}createDragLayer(a){var b=r(q.SVG,{"class":"blocklyBlockDragSurface",xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});a.append(b);return r(q.G,
1416
1417
  {},b)}createAnimationLayer(a){var b=r(q.SVG,{"class":"blocklyAnimationLayer",xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"});a.append(b);return r(q.G,{},b)}appendToAnimationLayer(a){var b,c=(b=this.dragLayer)==null?void 0:b.getAttribute("transform");if(c){let e;(e=this.animationLayer)==null||e.setAttribute("transform",c)}var d;(d=this.animationLayer)==null||d.appendChild(a.getSvgRoot())}translateLayers(a,b){a=
1417
1418
  `translate(${a.x}, ${a.y}) scale(${b})`;var c;(c=this.dragLayer)==null||c.setAttribute("transform",a);for(let [,d]of this.layers)d.setAttribute("transform",a)}moveToDragLayer(a,b=!0){var c;(c=this.dragLayer)==null||c.appendChild(a.getSvgRoot());b&&a.canBeFocused()&&$.t().focusNode(a)}moveOffDragLayer(a,b,c=!0){this.append(a,b);c&&a.canBeFocused()&&$.t().focusNode(a)}append(a,b){this.layers.has(b)||this.createLayer(b);a=a.getSvgRoot();var c;if(((c=this.layers.get(b))==null?void 0:c.lastChild)!==a){let d;
1418
- (d=this.layers.get(b))==null||d.appendChild(a)}}createLayer(a){var b=this.workspace.getSvgGroup(),c=r(q.G,{}),d=!1,e=[...this.layers].sort((f,g)=>f[0]-g[0]);for(let [f,g]of e)if(a<f){b.insertBefore(c,g);d=!0;break}d||b.appendChild(c);this.layers.set(a,c);return c}hasLayer(a){return a===this.dragLayer||(new Set(this.layers.values())).has(a)}getBlockLayer(){return this.layers.get(50)}getBubbleLayer(){return this.layers.get(100)}getDragLayer(){return this.dragLayer}};var Go={};Go.register=dj;Go.unregister=function(a){Eb(y.ICON,a)};var Wj=class extends un{constructor(a){super(a);this.sourceBlock=a;this.textInputBubble=null;this.text="";this.bubbleSize=new hc(160,80);this.bubbleVisiblity=!1}getType(){return Wj.TYPE}initView(a){this.svgRoot||(super.initView(a),r(q.CIRCLE,{"class":"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),r(q.PATH,{"class":"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},
1419
- this.svgRoot),r(q.RECT,{"class":"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),n(this.svgRoot,"blocklyCommentIcon"))}dispose(){super.dispose();var a;(a=this.textInputBubble)==null||a.dispose()}getWeight(){return Wj.WEIGHT}getSize(){return new hc(17,17)}applyColour(){super.applyColour();var a=this.sourceBlock.getColour(),b;(b=this.textInputBubble)==null||b.setColour(a)}updateEditable(){var a=this,b=()=>super.updateEditable;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){b().call(a);
1419
+ (d=this.layers.get(b))==null||d.appendChild(a)}}createLayer(a){var b=this.workspace.getSvgGroup(),c=r(q.G,{}),d=!1,e=[...this.layers].sort((f,g)=>f[0]-g[0]);for(let [f,g]of e)if(a<f){b.insertBefore(c,g);d=!0;break}d||b.appendChild(c);this.layers.set(a,c);return c}hasLayer(a){return a===this.dragLayer||(new Set(this.layers.values())).has(a)}getBlockLayer(){return this.layers.get(50)}getBubbleLayer(){return this.layers.get(100)}getDragLayer(){return this.dragLayer}};var Ho={};Ho.register=dj;Ho.unregister=function(a){Eb(y.ICON,a)};var Xj=class extends vn{constructor(a){super(a);this.sourceBlock=a;this.textInputBubble=null;this.text="";this.bubbleSize=new hc(160,80);this.bubbleVisiblity=!1}getType(){return Xj.TYPE}initView(a){this.svgRoot||(super.initView(a),r(q.CIRCLE,{"class":"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),r(q.PATH,{"class":"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},
1420
+ this.svgRoot),r(q.RECT,{"class":"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),n(this.svgRoot,"blocklyCommentIcon"))}dispose(){super.dispose();var a;(a=this.textInputBubble)==null||a.dispose()}getWeight(){return Xj.WEIGHT}getSize(){return new hc(17,17)}applyColour(){super.applyColour();var a=this.sourceBlock.getColour(),b;(b=this.textInputBubble)==null||b.setColour(a)}updateEditable(){var a=this,b=()=>super.updateEditable;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){b().call(a);
1420
1421
  a.bubbleIsVisible()&&(yield a.setBubbleVisible(!1),yield a.setBubbleVisible(!0))})}onLocationChange(a){var b=this.workspaceLocation;super.onLocationChange(a);this.bubbleLocation&&(a=D.difference(this.workspaceLocation,b),this.bubbleLocation=D.sum(this.bubbleLocation,a));a=this.getAnchorLocation();var c;(c=this.textInputBubble)==null||c.setAnchorLocation(a)}setText(a){var b=this.text;w(new (u(v.BLOCK_CHANGE))(this.sourceBlock,"comment",null,b,a));this.text=a;var c;(c=this.textInputBubble)==null||c.setText(this.text)}getText(){return this.text}setBubbleSize(a){this.bubbleSize=
1421
1422
  a;var b;(b=this.textInputBubble)==null||b.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}setBubbleLocation(a){this.bubbleLocation=a;var b;(b=this.textInputBubble)==null||b.moveDuringDrag(a)}getBubbleLocation(){return this.bubbleLocation}saveState(){if(this.text){let a={text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width},b=this.getBubbleLocation();b&&(a.x=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(b.x+
1422
1423
  this.bubbleSize.width):b.x,a.y=b.y);return a}return null}loadState(a){var b;this.text=(b=a.text)!=null?b:"";var c,d;this.bubbleSize=new hc((c=a.width)!=null?c:160,(d=a.height)!=null?d:80);var e;this.bubbleVisiblity=(e=a.pinned)!=null?e:!1;this.setBubbleVisible(this.bubbleVisiblity);var f=a.x,g=a.y;cd().then(()=>{f&&g&&(f=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(f+this.bubbleSize.width):f,this.setBubbleLocation(new D(f,g)))})}onClick(){super.onClick();this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var a=
1423
1424
  this.textInputBubble.getText();this.text!==a&&(w(new (u(v.BLOCK_CHANGE))(this.sourceBlock,"comment",null,this.text,a)),this.text=a)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}onBubbleLocationChange(){this.textInputBubble&&(this.bubbleLocation=this.textInputBubble.getRelativeToSurfaceXY())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(a){var b=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){b.bubbleVisiblity!==a&&(b.bubbleVisiblity=
1424
1425
  a,yield cd(),!b.sourceBlock.rendered||b.sourceBlock.isInFlyout||b.sourceBlock.isInsertionMarker()||(a?(b.sourceBlock.isEditable()?b.showEditableBubble():b.showNonEditableBubble(),b.applyColour()):b.hideBubble(),w(new (u(v.BUBBLE_OPEN))(b.sourceBlock,a,"comment")),b.svgRoot&&b.recomputeAriaContext()))})}getBubble(){return this.textInputBubble}showEditableBubble(){this.createBubble();var a;(a=this.textInputBubble)==null||a.addTextChangeListener(()=>this.onTextChange());var b;(b=this.textInputBubble)==
1425
- null||b.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();var a;(a=this.textInputBubble)==null||a.setEditable(!1)}createBubble(){this.textInputBubble=new zn(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect(),this);this.textInputBubble.getEditor().setParent(this.sourceBlock);this.textInputBubble.setText(this.getText());this.textInputBubble.setSize(this.bubbleSize,!0);this.bubbleLocation&&this.textInputBubble.moveDuringDrag(this.bubbleLocation);
1426
+ null||b.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();var a;(a=this.textInputBubble)==null||a.setEditable(!1)}createBubble(){this.textInputBubble=new An(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect(),this);this.textInputBubble.getEditor().setParent(this.sourceBlock);this.textInputBubble.setText(this.getText());this.textInputBubble.setSize(this.bubbleSize,!0);this.bubbleLocation&&this.textInputBubble.moveDuringDrag(this.bubbleLocation);
1426
1427
  this.textInputBubble.addTextChangeListener(()=>this.onTextChange());this.textInputBubble.addSizeChangeListener(()=>this.onSizeChange());this.textInputBubble.addLocationChangeListener(()=>this.onBubbleLocationChange());this.textInputBubble.setAriaLabelProvider(()=>$.C.BUBBLE_LABEL_COMMENT.replace("%1",this.getText()))}hideBubble(){var a;(a=this.textInputBubble)==null||a.dispose();this.textInputBubble=null}getAnchorLocation(){return D.sum(this.workspaceLocation,new D(8.5,8.5))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}getAriaLabel(){return this.bubbleIsVisible()?
1427
- $.C.ICON_LABEL_COMMENT_OPEN:$.C.ICON_LABEL_COMMENT_CLOSED}};Wj.TYPE=Zg.COMMENT;Wj.WEIGHT=3;dj(Wj.TYPE,Wj);var Ho={};Ho.CommentIcon=Wj;Ho.Icon=un;Ho.IconType=Zg;Ho.MutatorIcon=$.sh;Ho.WarningIcon=co;Ho.exceptions=Dn;Ho.registry=Go;var Io,Jo;
1428
+ $.C.ICON_LABEL_COMMENT_OPEN:$.C.ICON_LABEL_COMMENT_CLOSED}};Xj.TYPE=Zg.COMMENT;Xj.WEIGHT=3;dj(Xj.TYPE,Xj);var Io={};Io.CommentIcon=Xj;Io.Icon=vn;Io.IconType=Zg;Io.MutatorIcon=$.sh;Io.WarningIcon=eo;Io.exceptions=En;Io.registry=Ho;var Jo,Ko;
1428
1429
  $.kj=class{constructor(a,b){this.db=new Map;this.dbReverse=new Set;this.variableMap=null;this.variablePrefix=b||"";this.reservedWords=new Set(a?a.split(","):[])}reset(){this.db.clear();this.dbReverse.clear();this.variableMap=null}setVariableMap(a){this.variableMap=a}getNameForUserVariable(a){return this.variableMap?(a=this.variableMap.getVariableById(a))?a.getName():null:(console.warn("Deprecated call to Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:\nBlockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());"),null)}populateVariables(a){a=
1429
1430
  $.Bd(a);for(let b=0;b<a.length;b++)this.getName(a[b].getId(),$.P.VARIABLE)}populateProcedures(){throw Error("The implementation of populateProcedures should be monkey-patched in by blockly.ts");}getName(a,b){var c=a;b===$.P.VARIABLE&&(a=this.getNameForUserVariable(a))&&(c=a);a=c.toLowerCase();var d=b===$.P.VARIABLE||b===$.P.DEVELOPER_VARIABLE?this.variablePrefix:"";this.db.has(b)||this.db.set(b,new Map);var e=this.db.get(b);if(e.has(a))return d+e.get(a);b=this.getDistinctName(c,b);e.set(a,b.substr(d.length));
1430
1431
  return b}getUserNames(a){var b;return(a=(b=this.db.get(a))==null?void 0:b.keys())?Array.from(a):[]}getDistinctName(a,b){a=this.safeName(a);for(var c=null,d,e;this.dbReverse.has(a+((d=c)!=null?d:""))||this.reservedWords.has(a+((e=c)!=null?e:""));)c=c?c+1:2;var f;a+=(f=c)!=null?f:"";this.dbReverse.add(a);return(b===$.P.VARIABLE||b===$.P.DEVELOPER_VARIABLE?this.variablePrefix:"")+a}safeName(a){a?(a=encodeURI(a.replace(/ /g,"_")).replace(/[^\w]/g,"_"),"0123456789".includes(a[0])&&(a="my_"+a)):a=$.C.UNNAMED_KEY||
1431
- "unnamed";return a}static equals(a,b){return a.toLowerCase()===b.toLowerCase()}};Io=$.kj||($.kj={});Jo=Io.NameType||(Io.NameType={});Jo.DEVELOPER_VARIABLE="DEVELOPER_VARIABLE";Jo.VARIABLE="VARIABLE";Jo.PROCEDURE="PROCEDURE";$.P=$.kj.NameType;$.kj.DEVELOPER_VARIABLE_TYPE=$.P.DEVELOPER_VARIABLE;var Ko=class extends Map{constructor(){super()}set(a,b){if(this.get(a)===b)return this;super.set(a,b);fj(b)&&b.startPublishing();return this}delete(a){var b=this.get(a);a=super.delete(a);if(!a)return a;fj(b)&&b.stopPublishing();return a}clear(){if(this.size)for(let a of this.keys())this.delete(a)}add(a){return this.set(a.getId(),a)}getProcedures(){return[...this.values()]}};var Lo={CATEGORY_NAME:"PROCEDURE",DEFAULT_ARG:"x"};Lo.ObservableProcedureMap=Ko;Lo.allProcedures=hj;Lo.findLegalName=$.jj;Lo.flyoutCategory=nj;Lo.getCallers=rj;Lo.getDefinition=$.tj;Lo.isNameUsed=ij;Lo.isProcedureBlock=ej;Lo.mutateCallers=$.sj;Lo.mutatorOpenListener=qj;Lo.rename=$.mj;var Mo=class{constructor(){this.NONE=0;this.FIELD=1;this.HAT=2;this.ICON=4;this.SPACER=8;this.BETWEEN_ROW_SPACER=16;this.IN_ROW_SPACER=32;this.EXTERNAL_VALUE_INPUT=64;this.INPUT=128;this.INLINE_INPUT=256;this.STATEMENT_INPUT=512;this.CONNECTION=1024;this.PREVIOUS_CONNECTION=2048;this.NEXT_CONNECTION=4096;this.OUTPUT_CONNECTION=8192;this.CORNER=16384;this.LEFT_SQUARE_CORNER=32768;this.LEFT_ROUND_CORNER=65536;this.RIGHT_SQUARE_CORNER=131072;this.RIGHT_ROUND_CORNER=262144;this.JAGGED_EDGE=524288;this.ROW=
1432
+ "unnamed";return a}static equals(a,b){return a.toLowerCase()===b.toLowerCase()}};Jo=$.kj||($.kj={});Ko=Jo.NameType||(Jo.NameType={});Ko.DEVELOPER_VARIABLE="DEVELOPER_VARIABLE";Ko.VARIABLE="VARIABLE";Ko.PROCEDURE="PROCEDURE";$.P=$.kj.NameType;$.kj.DEVELOPER_VARIABLE_TYPE=$.P.DEVELOPER_VARIABLE;var Lo=class extends Map{constructor(){super()}set(a,b){if(this.get(a)===b)return this;super.set(a,b);fj(b)&&b.startPublishing();return this}delete(a){var b=this.get(a);a=super.delete(a);if(!a)return a;fj(b)&&b.stopPublishing();return a}clear(){if(this.size)for(let a of this.keys())this.delete(a)}add(a){return this.set(a.getId(),a)}getProcedures(){return[...this.values()]}};var Mo={CATEGORY_NAME:"PROCEDURE",DEFAULT_ARG:"x"};Mo.ObservableProcedureMap=Lo;Mo.allProcedures=hj;Mo.findLegalName=$.jj;Mo.flyoutCategory=nj;Mo.getCallers=rj;Mo.getDefinition=$.tj;Mo.isNameUsed=ij;Mo.isProcedureBlock=ej;Mo.mutateCallers=$.sj;Mo.mutatorOpenListener=qj;Mo.rename=$.mj;var No=class{constructor(){this.NONE=0;this.FIELD=1;this.HAT=2;this.ICON=4;this.SPACER=8;this.BETWEEN_ROW_SPACER=16;this.IN_ROW_SPACER=32;this.EXTERNAL_VALUE_INPUT=64;this.INPUT=128;this.INLINE_INPUT=256;this.STATEMENT_INPUT=512;this.CONNECTION=1024;this.PREVIOUS_CONNECTION=2048;this.NEXT_CONNECTION=4096;this.OUTPUT_CONNECTION=8192;this.CORNER=16384;this.LEFT_SQUARE_CORNER=32768;this.LEFT_ROUND_CORNER=65536;this.RIGHT_SQUARE_CORNER=131072;this.RIGHT_ROUND_CORNER=262144;this.JAGGED_EDGE=524288;this.ROW=
1432
1433
  1048576;this.TOP_ROW=2097152;this.BOTTOM_ROW=4194304;this.INPUT_ROW=8388608;this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|this.LEFT_ROUND_CORNER;this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER;this.nextTypeValue_=16777216}getType(a){Object.prototype.hasOwnProperty.call(this,a)||(this[a]=this.nextTypeValue_,this.nextTypeValue_<<=1);return this[a]}isField(a){return(a.type&this.FIELD)>=1}isHat(a){return(a.type&this.HAT)>=1}isIcon(a){return(a.type&this.ICON)>=1}isSpacer(a){return(a.type&
1433
1434
  this.SPACER)>=1}isInRowSpacer(a){return(a.type&this.IN_ROW_SPACER)>=1}isSpacerRow(a){return(a.type&this.BETWEEN_ROW_SPACER)>=1}isInput(a){return(a.type&this.INPUT)>=1}isExternalInput(a){return(a.type&this.EXTERNAL_VALUE_INPUT)>=1}isInlineInput(a){return(a.type&this.INLINE_INPUT)>=1}isStatementInput(a){return(a.type&this.STATEMENT_INPUT)>=1}isPreviousConnection(a){return(a.type&this.PREVIOUS_CONNECTION)>=1}isNextConnection(a){return(a.type&this.NEXT_CONNECTION)>=1}isPreviousOrNextConnection(a){return this.isPreviousConnection(a)||
1434
1435
  this.isNextConnection(a)}isRoundCorner(a){return(a.type&this.LEFT_ROUND_CORNER)>=1||(a.type&this.RIGHT_ROUND_CORNER)>=1}isLeftRoundedCorner(a){return this.isRoundCorner(a)&&(a.type&this.LEFT_ROUND_CORNER)>=1}isRightRoundedCorner(a){return this.isRoundCorner(a)&&(a.type&this.RIGHT_ROUND_CORNER)>=1}isLeftSquareCorner(a){return(a.type&this.LEFT_SQUARE_CORNER)>=1}isRightSquareCorner(a){return(a.type&this.RIGHT_SQUARE_CORNER)>=1}isCorner(a){return(a.type&this.CORNER)>=1}isJaggedEdge(a){return(a.type&this.JAGGED_EDGE)>=
1435
- 1}isRow(a){return(a.type&this.ROW)>=1}isBetweenRowSpacer(a){return(a.type&this.BETWEEN_ROW_SPACER)>=1}isTopRow(a){return(a.type&this.TOP_ROW)>=1}isBottomRow(a){return(a.type&this.BOTTOM_ROW)>=1}isTopOrBottomRow(a){return this.isTopRow(a)||this.isBottomRow(a)}isInputRow(a){return(a.type&this.INPUT_ROW)>=1}},Q=new Mo;var No=class{constructor(a){this.centerline=this.xPos=this.height=this.width=0;this.constants_=a;this.type=Q.NONE;this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}};var Oo=class{constructor(a){this.elements=[];this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0;this.hasStatement=this.hasExternalInput=!1;this.statementEdge=0;this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=!1;this.align=null;this.constants_=a;this.type=Q.ROW;this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let a=this.elements.length-1;a>=0;a--){let b=this.elements[a];if(Q.isInput(b))return b}return null}measure(){throw Error("Unexpected attempt to measure a base Row.");
1436
- }startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let a=0;a<this.elements.length;a++){let b=this.elements[a];if(Q.isInRowSpacer(b))return b}return null}getLastSpacer(){for(let a=this.elements.length-1;a>=0;a--){let b=this.elements[a];if(Q.isInRowSpacer(b))return b}return null}};var Po=class extends Oo{constructor(a){super(a);this.hasNextConnection=!1;this.connection=null;this.baseline=this.descenderHeight=0;this.type|=Q.BOTTOM_ROW}hasLeftSquareCorner(a){return!!a.outputConnection||!!a.getNextBlock()}hasRightSquareCorner(){return!0}measure(){var a=0,b=0,c=0;for(let d=0;d<this.elements.length;d++){let e=this.elements[d];b+=e.width;Q.isSpacer(e)||(Q.isNextConnection(e)?c=Math.max(c,e.height):a=Math.max(a,e.height))}this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,
1437
- a)+c;this.descenderHeight=c;this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}};var Qo=class extends No{constructor(a,b){super(a);this.connectionModel=b;this.type|=Q.CONNECTION;this.shape=this.constants_.shapeFor(b);this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic;this.highlighted=b.isHighlighted()}};var Ro=class extends Qo{constructor(a,b){super(a,b.connection);this.input=b;this.connectionOffsetY=this.connectionOffsetX=0;this.type|=Q.INPUT;this.align=b.align;this.connectedBlock=b.connection&&b.connection.targetBlock()?b.connection.targetBlock():null;a=b.connection.getInsertionMarker();this.connectedBlockHeight=this.connectedBlockWidth=0;this.connectedBlock&&(b=this.connectedBlock.getHeightWidth(),this.connectedBlockWidth=b.width,this.connectedBlockHeight=b.height);a&&(a=a.getHeightWidth(),this.connectedBlockWidth+=
1438
- a.width,this.connectedBlockHeight+=a.height)}};var So=class extends Ro{constructor(a,b){super(a,b);this.height=0;this.type|=Q.EXTERNAL_VALUE_INPUT;if(this.connectedBlockHeight){if(a=this.connectionModel.getInsertionMarker())this.connectedBlockHeight=a.getHeightWidth().height;this.height=this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING}else this.height=this.shape.height;this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING;this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP;
1439
- this.connectionHeight=this.shape.height;this.connectionWidth=this.shape.width}};var To=class extends No{constructor(a,b,c){super(a);this.field=b;this.parentInput=c;this.isEditable=b.EDITABLE;this.flipRtl=b.getFlipRtl();this.type|=Q.FIELD;a=this.field.getSize();this.height=a.height;this.width=a.width}};var Xo=class extends No{constructor(a){super(a);this.type|=Q.HAT;this.height=this.constants_.START_HAT.height;this.width=this.constants_.START_HAT.width;this.ascenderHeight=this.height}};var Yo=class extends No{constructor(a,b){super(a);this.icon=b;this.flipRtl=!1;this.type|=Q.ICON;a=b.getSize();this.height=a.height;this.width=a.width}};var Zo=class extends No{constructor(a,b){super(a);this.type|=Q.SPACER|Q.IN_ROW_SPACER;this.width=b;this.height=this.constants_.SPACER_DEFAULT_HEIGHT}};var $o=class extends Ro{constructor(a,b){super(a,b);this.type|=Q.INLINE_INPUT;this.connectedBlockWidth||this.connectedBlockHeight?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING);this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height;this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width;this.connectedBlockHeight||
1440
- (this.width+=this.connectionWidth*(this.isDynamicShape?2:1));this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP;this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):0}};var ap=class extends Oo{constructor(a){super(a);this.connectedBlockWidths=0;this.type|=Q.INPUT_ROW}measure(){this.width=this.minWidth;this.height=this.minHeight;var a=0;for(let b=0;b<this.elements.length;b++){let c=this.elements[b];this.width+=c.width;Q.isInput(c)&&(Q.isStatementInput(c)?a+=c.connectedBlockWidth:Q.isExternalInput(c)&&c.connectedBlockWidth!==0&&(a+=c.connectedBlockWidth-c.connectionWidth));Q.isSpacer(c)||(this.height=Math.max(this.height,c.height))}this.connectedBlockWidths=a;this.widthWithConnectedBlocks=
1441
- this.width+a}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}};var bp=class extends No{constructor(a){super(a);this.type|=Q.JAGGED_EDGE;this.height=this.constants_.JAGGED_TEETH.height;this.width=this.constants_.JAGGED_TEETH.width}};var cp=class extends Qo{constructor(a,b){super(a,b);this.type|=Q.NEXT_CONNECTION;this.height=this.shape.height;this.width=this.shape.width;if(a=b.getInsertionMarker())this.height+=a.getHeightWidth().height}};var dp=class extends Qo{constructor(a,b){super(a,b);this.connectionOffsetX=0;this.type|=Q.OUTPUT_CONNECTION;this.height=this.isDynamicShape?0:this.shape.height;this.startX=this.width=this.isDynamicShape?0:this.shape.width;this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}};var ep=class extends Qo{constructor(a,b){super(a,b);this.type|=Q.PREVIOUS_CONNECTION;this.height=this.shape.height;this.width=this.shape.width}};var fp=class extends No{constructor(a,b){super(a);this.type=(b&&b!=="left"?Q.RIGHT_ROUND_CORNER:Q.LEFT_ROUND_CORNER)|Q.CORNER;this.width=this.constants_.CORNER_RADIUS;this.height=this.constants_.CORNER_RADIUS/2}};var gp=class extends Oo{constructor(a,b,c){super(a);this.height=b;this.width=c;this.precedesStatement=this.followsStatement=!1;this.widthWithConnectedBlocks=0;this.type|=Q.SPACER|Q.BETWEEN_ROW_SPACER;this.elements=[new Zo(this.constants_,c)]}measure(){}};var hp=class extends No{constructor(a,b){super(a);this.type=(b&&b!=="left"?Q.RIGHT_SQUARE_CORNER:Q.LEFT_SQUARE_CORNER)|Q.CORNER;this.width=this.height=this.constants_.NO_PADDING}};var ip=class extends Ro{constructor(a,b){super(a,b);this.type|=Q.STATEMENT_INPUT;this.height=this.connectedBlockHeight?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT;this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}};var jp=class extends Oo{constructor(a){super(a);this.ascenderHeight=this.capline=0;this.hasPreviousConnection=!1;this.connection=null;this.type|=Q.TOP_ROW}hasLeftSquareCorner(a){var b=(a.hat?a.hat==="cap":this.constants_.ADD_START_HATS)&&!a.outputConnection&&!a.previousConnection,c=a.getPreviousBlock();return!!a.outputConnection||b||(c?c.getNextBlock()===a:!1)}hasRightSquareCorner(){return!0}measure(){var a=0,b=0,c=0;for(let d=0;d<this.elements.length;d++){let e=this.elements[d];b+=e.width;Q.isSpacer(e)||
1442
- (Q.isHat(e)?c=Math.max(c,e.ascenderHeight):a=Math.max(a,e.height))}this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,a)+c;this.capline=this.ascenderHeight=c;this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}};var kp=new Map,lp=class{constructor(){this.NO_PADDING=0;this.SMALL_PADDING=3;this.MEDIUM_PADDING=5;this.MEDIUM_LARGE_PADDING=8;this.LARGE_PADDING=10;this.TAB_HEIGHT=15;this.TAB_OFFSET_FROM_TOP=5;this.TAB_VERTICAL_OVERLAP=2.5;this.TAB_WIDTH=8;this.NOTCH_WIDTH=15;this.NOTCH_HEIGHT=4;this.MIN_BLOCK_WIDTH=12;this.EMPTY_BLOCK_SPACER_HEIGHT=16;this.CORNER_RADIUS=8;this.NOTCH_OFFSET_LEFT=15;this.STATEMENT_BOTTOM_SPACER=0;this.STATEMENT_INPUT_PADDING_LEFT=20;this.BETWEEN_STATEMENT_PADDING_Y=4;this.ADD_START_HATS=
1436
+ 1}isRow(a){return(a.type&this.ROW)>=1}isBetweenRowSpacer(a){return(a.type&this.BETWEEN_ROW_SPACER)>=1}isTopRow(a){return(a.type&this.TOP_ROW)>=1}isBottomRow(a){return(a.type&this.BOTTOM_ROW)>=1}isTopOrBottomRow(a){return this.isTopRow(a)||this.isBottomRow(a)}isInputRow(a){return(a.type&this.INPUT_ROW)>=1}},Q=new No;var Oo=class{constructor(a){this.centerline=this.xPos=this.height=this.width=0;this.constants_=a;this.type=Q.NONE;this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}};var Po=class{constructor(a){this.elements=[];this.xPos=this.yPos=this.widthWithConnectedBlocks=this.minWidth=this.minHeight=this.width=this.height=0;this.hasStatement=this.hasExternalInput=!1;this.statementEdge=0;this.hasJaggedEdge=this.hasDummyInput=this.hasInlineInput=!1;this.align=null;this.constants_=a;this.type=Q.ROW;this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let a=this.elements.length-1;a>=0;a--){let b=this.elements[a];if(Q.isInput(b))return b}return null}measure(){throw Error("Unexpected attempt to measure a base Row.");
1437
+ }startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let a=0;a<this.elements.length;a++){let b=this.elements[a];if(Q.isInRowSpacer(b))return b}return null}getLastSpacer(){for(let a=this.elements.length-1;a>=0;a--){let b=this.elements[a];if(Q.isInRowSpacer(b))return b}return null}};var Qo=class extends Po{constructor(a){super(a);this.hasNextConnection=!1;this.connection=null;this.baseline=this.descenderHeight=0;this.type|=Q.BOTTOM_ROW}hasLeftSquareCorner(a){return!!a.outputConnection||!!a.getNextBlock()}hasRightSquareCorner(){return!0}measure(){var a=0,b=0,c=0;for(let d=0;d<this.elements.length;d++){let e=this.elements[d];b+=e.width;Q.isSpacer(e)||(Q.isNextConnection(e)?c=Math.max(c,e.height):a=Math.max(a,e.height))}this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,
1438
+ a)+c;this.descenderHeight=c;this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}};var Ro=class extends Oo{constructor(a,b){super(a);this.connectionModel=b;this.type|=Q.CONNECTION;this.shape=this.constants_.shapeFor(b);this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic;this.highlighted=b.isHighlighted()}};var So=class extends Ro{constructor(a,b){super(a,b.connection);this.input=b;this.connectionOffsetY=this.connectionOffsetX=0;this.type|=Q.INPUT;this.align=b.align;this.connectedBlock=b.connection&&b.connection.targetBlock()?b.connection.targetBlock():null;a=b.connection.getInsertionMarker();this.connectedBlockHeight=this.connectedBlockWidth=0;this.connectedBlock&&(b=this.connectedBlock.getHeightWidth(),this.connectedBlockWidth=b.width,this.connectedBlockHeight=b.height);a&&(a=a.getHeightWidth(),this.connectedBlockWidth+=
1439
+ a.width,this.connectedBlockHeight+=a.height)}};var To=class extends So{constructor(a,b){super(a,b);this.height=0;this.type|=Q.EXTERNAL_VALUE_INPUT;if(this.connectedBlockHeight){if(a=this.connectionModel.getInsertionMarker())this.connectedBlockHeight=a.getHeightWidth().height;this.height=this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING}else this.height=this.shape.height;this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING;this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP;
1440
+ this.connectionHeight=this.shape.height;this.connectionWidth=this.shape.width}};var Uo=class extends Oo{constructor(a,b,c){super(a);this.field=b;this.parentInput=c;this.isEditable=b.EDITABLE;this.flipRtl=b.getFlipRtl();this.type|=Q.FIELD;a=this.field.getSize();this.height=a.height;this.width=a.width}};var Yo=class extends Oo{constructor(a){super(a);this.type|=Q.HAT;this.height=this.constants_.START_HAT.height;this.width=this.constants_.START_HAT.width;this.ascenderHeight=this.height}};var Zo=class extends Oo{constructor(a,b){super(a);this.icon=b;this.flipRtl=!1;this.type|=Q.ICON;a=b.getSize();this.height=a.height;this.width=a.width}};var $o=class extends Oo{constructor(a,b){super(a);this.type|=Q.SPACER|Q.IN_ROW_SPACER;this.width=b;this.height=this.constants_.SPACER_DEFAULT_HEIGHT}};var ap=class extends So{constructor(a,b){super(a,b);this.type|=Q.INLINE_INPUT;this.connectedBlockWidth||this.connectedBlockHeight?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING);this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height;this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width;this.connectedBlockHeight||
1441
+ (this.width+=this.connectionWidth*(this.isDynamicShape?2:1));this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP;this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):0}};var bp=class extends Po{constructor(a){super(a);this.connectedBlockWidths=0;this.type|=Q.INPUT_ROW}measure(){this.width=this.minWidth;this.height=this.minHeight;var a=0;for(let b=0;b<this.elements.length;b++){let c=this.elements[b];this.width+=c.width;Q.isInput(c)&&(Q.isStatementInput(c)?a+=c.connectedBlockWidth:Q.isExternalInput(c)&&c.connectedBlockWidth!==0&&(a+=c.connectedBlockWidth-c.connectionWidth));Q.isSpacer(c)||(this.height=Math.max(this.height,c.height))}this.connectedBlockWidths=a;this.widthWithConnectedBlocks=
1442
+ this.width+a}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}};var cp=class extends Oo{constructor(a){super(a);this.type|=Q.JAGGED_EDGE;this.height=this.constants_.JAGGED_TEETH.height;this.width=this.constants_.JAGGED_TEETH.width}};var dp=class extends Ro{constructor(a,b){super(a,b);this.type|=Q.NEXT_CONNECTION;this.height=this.shape.height;this.width=this.shape.width;if(a=b.getInsertionMarker())this.height+=a.getHeightWidth().height}};var ep=class extends Ro{constructor(a,b){super(a,b);this.connectionOffsetX=0;this.type|=Q.OUTPUT_CONNECTION;this.height=this.isDynamicShape?0:this.shape.height;this.startX=this.width=this.isDynamicShape?0:this.shape.width;this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}};var fp=class extends Ro{constructor(a,b){super(a,b);this.type|=Q.PREVIOUS_CONNECTION;this.height=this.shape.height;this.width=this.shape.width}};var gp=class extends Oo{constructor(a,b){super(a);this.type=(b&&b!=="left"?Q.RIGHT_ROUND_CORNER:Q.LEFT_ROUND_CORNER)|Q.CORNER;this.width=this.constants_.CORNER_RADIUS;this.height=this.constants_.CORNER_RADIUS/2}};var hp=class extends Po{constructor(a,b,c){super(a);this.height=b;this.width=c;this.precedesStatement=this.followsStatement=!1;this.widthWithConnectedBlocks=0;this.type|=Q.SPACER|Q.BETWEEN_ROW_SPACER;this.elements=[new $o(this.constants_,c)]}measure(){}};var ip=class extends Oo{constructor(a,b){super(a);this.type=(b&&b!=="left"?Q.RIGHT_SQUARE_CORNER:Q.LEFT_SQUARE_CORNER)|Q.CORNER;this.width=this.height=this.constants_.NO_PADDING}};var jp=class extends So{constructor(a,b){super(a,b);this.type|=Q.STATEMENT_INPUT;this.height=this.connectedBlockHeight?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT;this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}};var kp=class extends Po{constructor(a){super(a);this.ascenderHeight=this.capline=0;this.hasPreviousConnection=!1;this.connection=null;this.type|=Q.TOP_ROW}hasLeftSquareCorner(a){var b=(a.hat?a.hat==="cap":this.constants_.ADD_START_HATS)&&!a.outputConnection&&!a.previousConnection,c=a.getPreviousBlock();return!!a.outputConnection||b||(c?c.getNextBlock()===a:!1)}hasRightSquareCorner(){return!0}measure(){var a=0,b=0,c=0;for(let d=0;d<this.elements.length;d++){let e=this.elements[d];b+=e.width;Q.isSpacer(e)||
1443
+ (Q.isHat(e)?c=Math.max(c,e.ascenderHeight):a=Math.max(a,e.height))}this.width=Math.max(this.minWidth,b);this.height=Math.max(this.minHeight,a)+c;this.capline=this.ascenderHeight=c;this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}};var lp=new Map,mp=class{constructor(){this.NO_PADDING=0;this.SMALL_PADDING=3;this.MEDIUM_PADDING=5;this.MEDIUM_LARGE_PADDING=8;this.LARGE_PADDING=10;this.TAB_HEIGHT=15;this.TAB_OFFSET_FROM_TOP=5;this.TAB_VERTICAL_OVERLAP=2.5;this.TAB_WIDTH=8;this.NOTCH_WIDTH=15;this.NOTCH_HEIGHT=4;this.MIN_BLOCK_WIDTH=12;this.EMPTY_BLOCK_SPACER_HEIGHT=16;this.CORNER_RADIUS=8;this.NOTCH_OFFSET_LEFT=15;this.STATEMENT_BOTTOM_SPACER=0;this.STATEMENT_INPUT_PADDING_LEFT=20;this.BETWEEN_STATEMENT_PADDING_Y=4;this.ADD_START_HATS=
1443
1444
  !1;this.START_HAT_HEIGHT=15;this.START_HAT_WIDTH=100;this.SPACER_DEFAULT_HEIGHT=15;this.MIN_BLOCK_HEIGHT=24;this.EMPTY_INLINE_INPUT_PADDING=14.5;this.EXTERNAL_VALUE_INPUT_PADDING=2;this.JAGGED_TEETH_HEIGHT=12;this.JAGGED_TEETH_WIDTH=6;this.FIELD_TEXT_FONTSIZE=11;this.FIELD_TEXT_FONTWEIGHT="normal";this.FIELD_TEXT_FONTFAMILY="sans-serif";this.FIELD_TEXT_BASELINE=this.FIELD_TEXT_HEIGHT=-1;this.FIELD_BORDER_RECT_RADIUS=4;this.FIELD_BORDER_RECT_HEIGHT=16;this.FIELD_BORDER_RECT_X_PADDING=5;this.FIELD_BORDER_RECT_Y_PADDING=
1444
1445
  3;this.FIELD_BORDER_RECT_COLOUR="#fff";this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!1;this.FIELD_DROPDOWN_SVG_ARROW_SIZE=12;this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=!1;this.FIELD_COLOUR_DEFAULT_WIDTH=26;this.defs=null;this.embossFilterId="";this.embossFilter=null;this.disabledPatternId="";this.disabledPattern=null;this.debugFilterId="";this.debugFilter=null;this.CURSOR_COLOUR="#cc0a0a";this.MARKER_COLOUR="#4286f4";this.CURSOR_WS_WIDTH=
1445
1446
  100;this.WS_CURSOR_HEIGHT=5;this.CURSOR_STACK_PADDING=10;this.CURSOR_BLOCK_PADDING=2;this.CURSOR_STROKE_WIDTH=4;this.FULL_BLOCK_FIELDS=!1;this.INSERTION_MARKER_COLOUR="#000000";this.INSERTION_MARKER_OPACITY=.2;this.SHAPES={PUZZLE:1,NOTCH:2};this.TALL_INPUT_FIELD_OFFSET_Y=this.MEDIUM_PADDING;this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=this.DUMMY_INPUT_MIN_HEIGHT=this.TAB_HEIGHT;this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT;this.TOP_ROW_MIN_HEIGHT=this.MEDIUM_PADDING;this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=
@@ -1454,11 +1455,11 @@ d,c),H(g*3,0),H(g*d,-c)])}var b=this.NOTCH_WIDTH,c=this.NOTCH_HEIGHT,d=(b-3)/2,e
1454
1455
  bottomRight:e,bottomLeft:d,rightHeight:a}}shapeFor(a){switch(a.type){case G.INPUT_VALUE:case G.OUTPUT_VALUE:return this.PUZZLE_TAB;case G.PREVIOUS_STATEMENT:case G.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type");}}createDom(a,b,c){if(c){let d=c.getRootNode();this.injectCSS_(d,b)}this.defs=r(q.DEFS,{},a);a=r(q.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs);r(q.FEGAUSSIANBLUR,{"in":"SourceAlpha",stdDeviation:1,result:"blur"},a);b=r(q.FESPECULARLIGHTING,
1455
1456
  {"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},a);r(q.FEPOINTLIGHT,{x:-5E3,y:-1E4,z:2E4},b);r(q.FECOMPOSITE,{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},a);r(q.FECOMPOSITE,{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},a);this.embossFilterId=a.id;this.embossFilter=a;a=r(q.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",width:10,height:10},this.defs);
1456
1457
  r(q.RECT,{width:10,height:10,fill:"#aaa"},a);r(q.PATH,{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},a);this.disabledPatternId=a.id;this.disabledPattern=a;this.createDebugFilter();c&&(c.style.setProperty("--blocklyEmbossFilter",`url(#${this.embossFilterId})`),c.style.setProperty("--blocklyDisabledPattern",`url(#${this.disabledPatternId})`),c.style.setProperty("--blocklyDebugFilter",`url(#${this.debugFilterId})`))}createDebugFilter(){if(!this.debugFilter){let a=r(q.FILTER,{id:"blocklyDebugFilter"+
1457
- this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),b=r(q.FECOMPONENTTRANSFER,{result:"outBlur"},a);r(q.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},b);r(q.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},a);r(q.FECOMPOSITE,{"in":"outColor",in2:"outBlur",operator:"in",result:"outGlow"},a);this.debugFilterId=a.id;this.debugFilter=a}}injectCSS_(a,b){if(typeof window!=="undefined"){var c;if((c=kp.get(b))==null||!c.has(a)){c=document.createElement("style");
1458
- c.className="blockly-renderer-style";c.textContent=this.getCSS_(b).join("\n");(typeof globalThis.ShadowRoot!=="undefined"&&a instanceof ShadowRoot?a:document.head).prepend(c);var d;c=(d=kp.get(b))!=null?d:new WeakSet;c.add(a);kp.set(b,c)}}}getCSS_(a){return[`${a}.injectionDiv {`,"--blockly-active-node-color: #fc3;","}",`${a} .blocklyText, `,`${a} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${a} .blocklyText {`,
1458
+ this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),b=r(q.FECOMPONENTTRANSFER,{result:"outBlur"},a);r(q.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},b);r(q.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},a);r(q.FECOMPOSITE,{"in":"outColor",in2:"outBlur",operator:"in",result:"outGlow"},a);this.debugFilterId=a.id;this.debugFilter=a}}injectCSS_(a,b){if(typeof window!=="undefined"){var c;if((c=lp.get(b))==null||!c.has(a)){c=document.createElement("style");
1459
+ c.className="blockly-renderer-style";c.textContent=this.getCSS_(b).join("\n");(typeof globalThis.ShadowRoot!=="undefined"&&a instanceof ShadowRoot?a:document.head).prepend(c);var d;c=(d=lp.get(b))!=null?d:new WeakSet;c.add(a);lp.set(b,c)}}}getCSS_(a){return[`${a}.injectionDiv {`,"--blockly-active-node-color: #fc3;","}",`${a} .blocklyText, `,`${a} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${a} .blocklyText {`,
1459
1460
  "fill: #fff;","}",`${a} .blocklyNonEditableField>rect,`,`${a} .blocklyEditableField>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${a} .blocklyNonEditableField>text,`,`${a} .blocklyEditableField>text {`,"fill: #000;","}",`${a} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${a} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${a} .blocklyEditableField:not(.blocklyEditing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${a} .blocklyHtmlInput {`,
1460
1461
  `font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${a} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${a} .blocklyHighlightedConnectionPathVisible {`,"stroke: #fc3;","}",`${a} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${a} .blocklyReplaceable .blocklyPathLight,`,`${a} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${a} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,
1461
- "stroke: none;","}"]}};var mp=class{constructor(a,b){this.inlinePath_=this.outlinePath_="";this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.constants_=b.getRenderer().getConstants()}draw(){this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();this.block_.pathObject.setPath(this.outlinePath_+"\n"+this.inlinePath_);this.info_.RTL&&this.block_.pathObject.flipRTL();this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height;this.block_.width=this.info_.widthWithChildren;
1462
+ "stroke: none;","}"]}};var np=class{constructor(a,b){this.inlinePath_=this.outlinePath_="";this.block_=a;this.info_=b;this.topLeft_=a.getRelativeToSurfaceXY();this.constants_=b.getRenderer().getConstants()}draw(){this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();this.block_.pathObject.setPath(this.outlinePath_+"\n"+this.inlinePath_);this.info_.RTL&&this.block_.pathObject.flipRTL();this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height;this.block_.width=this.info_.widthWithChildren;
1462
1463
  this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let a=1;a<this.info_.rows.length-1;a++){let b=this.info_.rows[a];b.hasJaggedEdge?this.drawJaggedEdge_(b):b.hasStatement?this.drawStatementInput_(b):b.hasExternalInput?this.drawValueInput_(b):this.drawRightSideRow_(b)}this.drawBottom_();this.drawLeft_()}drawTop_(){var a=this.info_.topRow,b=a.elements;this.positionPreviousConnection_();this.outlinePath_+=Dh(a.xPos,this.info_.startY);for(let c=0,d;d=b[c];c++)Q.isLeftRoundedCorner(d)?
1463
1464
  this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:Q.isRightRoundedCorner(d)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:Q.isPreviousConnection(d)?this.outlinePath_+=d.shape.pathLeft:Q.isHat(d)?this.outlinePath_+=this.constants_.START_HAT.path:Q.isSpacer(d)&&(this.outlinePath_+=I("h",d.width));this.outlinePath_+=I("v",a.height-a.ascenderHeight)}drawJaggedEdge_(a){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+I("v",a.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(a){var b=
1464
1465
  a.getLastInput();this.positionExternalValueConnection_(a);var c=b.shape.isDynamic?b.shape.pathDown(b.height):b.shape.pathDown;this.outlinePath_+=I("H",b.xPos+b.width)+c+I("v",a.height-b.connectionHeight)}drawStatementInput_(a){var b=a.getLastInput();if(b){var c=b.xPos+b.notchOffset+b.shape.width;b=b.shape.pathRight+I("h",-(b.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var d=a.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=I("H",c)+b+
@@ -1467,36 +1468,36 @@ c=this.constants_.OUTSIDE_CORNERS.rightHeight):Q.isSpacer(f)&&(d+=I("h",f.width*
1467
1468
  (Q.isIcon(d)||Q.isField(d))&&this.layoutField_(d)}layoutField_(a){var b=a.centerline-a.height/2,c=a.xPos,d="";this.info_.RTL&&(c=-(c+a.width),a.flipRtl&&(c+=a.width,d="scale(-1 1)"));Q.isIcon(a)?(d=a.icon,d.setOffsetInBlock(new D(c,b)),this.info_.isInsertionMarker&&d.hideForInsertionMarker()):(a=a.field.getSvgRoot(),a.setAttribute("transform","translate("+c+","+b+")"+d),this.info_.isInsertionMarker&&a.setAttribute("display","none"))}drawInlineInput_(a){var b=a.width,c=a.height,d=a.connectionOffsetY,
1468
1469
  e=a.connectionHeight+d;this.inlinePath_+=Ch(a.xPos+a.connectionWidth,a.centerline-c/2)+I("v",d)+a.shape.pathDown+I("v",c-e)+I("h",b-a.connectionWidth)+I("v",-c)+"z";this.positionInlineInputConnection_(a)}positionInlineInputConnection_(a){var b=a.centerline-a.height/2;if(a.connectionModel){let c=a.xPos+a.connectionWidth+a.connectionOffsetX;this.info_.RTL&&(c*=-1);a.connectionModel.setOffsetInBlock(c,b+a.connectionOffsetY)}}positionStatementInputConnection_(a){var b=a.getLastInput();if(b==null?0:b.connectionModel){let c=
1469
1470
  a.xPos+a.statementEdge+b.notchOffset;this.info_.RTL&&(c*=-1);b.connectionModel.setOffsetInBlock(c,a.yPos)}}positionExternalValueConnection_(a){var b=a.getLastInput();if(b&&b.connectionModel){let c=a.xPos+a.width;this.info_.RTL&&(c*=-1);b.connectionModel.setOffsetInBlock(c,a.yPos)}}positionPreviousConnection_(){var a=this.info_.topRow;if(a.connection){let b=a.xPos+a.notchOffset;a.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-b:b,0)}}positionNextConnection_(){var a=this.info_.bottomRow;
1470
- if(a.connection){let b=a.connection,c=b.xPos;b.connectionModel.setOffsetInBlock(this.info_.RTL?-c:c,a.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){var a=this.info_.startX+this.info_.outputConnection.connectionOffsetX;a=this.info_.RTL?-a:a;let b;(b=this.block_.outputConnection)==null||b.setOffsetInBlock(a,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(let a of this.info_.rows)for(let b of a.elements){if(!(b instanceof Qo))continue;let c=this.drawConnectionHighlightPath(b);
1471
+ if(a.connection){let b=a.connection,c=b.xPos;b.connectionModel.setOffsetInBlock(this.info_.RTL?-c:c,a.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){var a=this.info_.startX+this.info_.outputConnection.connectionOffsetX;a=this.info_.RTL?-a:a;let b;(b=this.block_.outputConnection)==null||b.setOffsetInBlock(a,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(let a of this.info_.rows)for(let b of a.elements){if(!(b instanceof Ro))continue;let c=this.drawConnectionHighlightPath(b);
1471
1472
  c&&(b.connectionModel.setAriaRole(c),c.classList.toggle("blocklyHighlightedConnectionPathVisible",b.highlighted))}}drawConnectionHighlightPath(a){var b=a.connectionModel;a=b.type===G.INPUT_VALUE||b.type===G.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(a):this.getStatementConnectionHighlightPath(a);var c=b.getSourceBlock(),d,e;return(e=(d=c.pathObject).addConnectionHighlight)==null?void 0:e.call(d,b,a,b.getOffsetInBlock(),c.RTL)}getExpressionConnectionHighlightPath(a){var b="";if(a.shape.isDynamic)b=
1472
- a.shape.pathDown(a.height);else{var c=a.shape;c.pathDown!==void 0&&c.pathUp!==void 0&&(b=a.shape.pathDown)}a=this.constants_.TAB_OFFSET_FROM_TOP;return Dh(0,-a)+I("v",a)+b+I("v",a)}getStatementConnectionHighlightPath(a){var b=a.shape;if(b.pathLeft===void 0||b.pathRight===void 0)throw Error("Statement connections should have notch shapes");b=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return Dh(-b,0)+I("h",b)+a.shape.pathLeft+I("h",b)}};var np=class{constructor(a,b){this.statementEdge=this.width=this.widthWithChildren=this.height=0;this.rows=[];this.inputRows=[];this.startY=this.startX=0;this.renderer_=a;this.block_=b;this.constants_=this.renderer_.getConstants();this.outputConnection=b.outputConnection?new dp(this.constants_,b.outputConnection):null;this.isInline=b.getInputsInline()&&!b.isCollapsed();this.isCollapsed=b.isCollapsed();this.isInsertionMarker=b.isInsertionMarker();this.RTL=b.RTL;this.topRow=new jp(this.constants_);
1473
- this.bottomRow=new Po(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_();this.addElemSpacing_();this.addRowSpacing_();this.computeBounds_();this.alignRowElements_();this.finalize_()}createRows_(){this.populateTopRow_();this.rows.push(this.topRow);var a=new ap(this.constants_);this.inputRows.push(a);var b=this.block_.getIcons();for(let c=0,d;d=b[c];c++){let e=new Yo(this.constants_,d);this.isCollapsed&&!d.isShownWhenCollapsed()||a.elements.push(e)}b=void 0;for(let c=
1474
- 0,d;d=this.block_.inputList[c];c++)if(d.isVisible()){this.shouldStartNewRow_(d,b)&&(this.rows.push(a),a=new ap(this.constants_),this.inputRows.push(a));for(let e=0,f;f=d.fieldRow[e];e++)a.elements.push(new To(this.constants_,f,d));this.addInput_(d,a);b=d}this.isCollapsed&&(a.hasJaggedEdge=!0,a.elements.push(new bp(this.constants_)));(a.elements.length||a.hasDummyInput)&&this.rows.push(a);this.populateBottomRow_();this.rows.push(this.bottomRow)}populateTopRow_(){var a=!!this.block_.previousConnection,
1475
- b=(this.block_.hat?this.block_.hat==="cap":this.constants_.ADD_START_HATS)&&!this.outputConnection&&!a,c=this.topRow.hasLeftSquareCorner(this.block_)?hp:fp;this.topRow.elements.push(new c(this.constants_));b?(a=new Xo(this.constants_),this.topRow.elements.push(a)):a&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new ep(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection));this.block_.inputList.length&&this.block_.inputList[0]instanceof Mn&&
1476
- !this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT;c=this.topRow.hasRightSquareCorner(this.block_)?hp:fp;this.topRow.elements.push(new c(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Mn?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:
1477
- this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new hp(this.constants_)):this.bottomRow.elements.push(new fp(this.constants_));this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new cp(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new hp(this.constants_,"right")):this.bottomRow.elements.push(new fp(this.constants_,
1478
- "right"))}addInput_(a,b){if(this.isInline&&a instanceof $.Nn)b.elements.push(new $o(this.constants_,a)),b.hasInlineInput=!0;else if(a instanceof Mn)b.elements.push(new ip(this.constants_,a)),b.hasStatement=!0;else if(a instanceof $.Nn)b.elements.push(new So(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Kn||a instanceof Ln)b.minHeight=Math.max(b.minHeight,a.getSourceBlock()&&a.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),
1479
- b.hasDummyInput=!0;b.align===null&&(b.align=a.align)}shouldStartNewRow_(a,b){return b?b instanceof Ln||a instanceof Mn||b instanceof Mn?!0:a instanceof $.Nn||a instanceof Kn||b instanceof $.Nn?!this.isInline:!1:!1}addElemSpacing_(){for(let a=0,b;b=this.rows[a];a++){let c=b.elements;b.elements=[];b.startsWithElemSpacer()&&b.elements.push(new Zo(this.constants_,this.getInRowSpacing_(null,c[0])));if(c.length){for(let d=0;d<c.length-1;d++){b.elements.push(c[d]);let e=this.getInRowSpacing_(c[d],c[d+1]);
1480
- b.elements.push(new Zo(this.constants_,e))}b.elements.push(c[c.length-1]);b.endsWithElemSpacer()&&b.elements.push(new Zo(this.constants_,this.getInRowSpacing_(c[c.length-1],null)))}}}getInRowSpacing_(a,b){if(!a&&b&&Q.isStatementInput(b))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(a&&Q.isInput(a)&&!b){if(Q.isExternalInput(a))return this.constants_.NO_PADDING;if(Q.isInlineInput(a))return this.constants_.LARGE_PADDING;if(Q.isStatementInput(a))return this.constants_.NO_PADDING}return a&&Q.isLeftSquareCorner(a)&&
1473
+ a.shape.pathDown(a.height);else{var c=a.shape;c.pathDown!==void 0&&c.pathUp!==void 0&&(b=a.shape.pathDown)}a=this.constants_.TAB_OFFSET_FROM_TOP;return Dh(0,-a)+I("v",a)+b+I("v",a)}getStatementConnectionHighlightPath(a){var b=a.shape;if(b.pathLeft===void 0||b.pathRight===void 0)throw Error("Statement connections should have notch shapes");b=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return Dh(-b,0)+I("h",b)+a.shape.pathLeft+I("h",b)}};var op=class{constructor(a,b){this.statementEdge=this.width=this.widthWithChildren=this.height=0;this.rows=[];this.inputRows=[];this.startY=this.startX=0;this.renderer_=a;this.block_=b;this.constants_=this.renderer_.getConstants();this.outputConnection=b.outputConnection?new ep(this.constants_,b.outputConnection):null;this.isInline=b.getInputsInline()&&!b.isCollapsed();this.isCollapsed=b.isCollapsed();this.isInsertionMarker=b.isInsertionMarker();this.RTL=b.RTL;this.topRow=new kp(this.constants_);
1474
+ this.bottomRow=new Qo(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_();this.addElemSpacing_();this.addRowSpacing_();this.computeBounds_();this.alignRowElements_();this.finalize_()}createRows_(){this.populateTopRow_();this.rows.push(this.topRow);var a=new bp(this.constants_);this.inputRows.push(a);var b=this.block_.getIcons();for(let c=0,d;d=b[c];c++){let e=new Zo(this.constants_,d);this.isCollapsed&&!d.isShownWhenCollapsed()||a.elements.push(e)}b=void 0;for(let c=
1475
+ 0,d;d=this.block_.inputList[c];c++)if(d.isVisible()){this.shouldStartNewRow_(d,b)&&(this.rows.push(a),a=new bp(this.constants_),this.inputRows.push(a));for(let e=0,f;f=d.fieldRow[e];e++)a.elements.push(new Uo(this.constants_,f,d));this.addInput_(d,a);b=d}this.isCollapsed&&(a.hasJaggedEdge=!0,a.elements.push(new cp(this.constants_)));(a.elements.length||a.hasDummyInput)&&this.rows.push(a);this.populateBottomRow_();this.rows.push(this.bottomRow)}populateTopRow_(){var a=!!this.block_.previousConnection,
1476
+ b=(this.block_.hat?this.block_.hat==="cap":this.constants_.ADD_START_HATS)&&!this.outputConnection&&!a,c=this.topRow.hasLeftSquareCorner(this.block_)?ip:gp;this.topRow.elements.push(new c(this.constants_));b?(a=new Yo(this.constants_),this.topRow.elements.push(a)):a&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new fp(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection));this.block_.inputList.length&&this.block_.inputList[0]instanceof Nn&&
1477
+ !this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT;c=this.topRow.hasRightSquareCorner(this.block_)?ip:gp;this.topRow.elements.push(new c(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection;this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Nn?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:
1478
+ this.constants_.BOTTOM_ROW_MIN_HEIGHT;this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new ip(this.constants_)):this.bottomRow.elements.push(new gp(this.constants_));this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new dp(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection));this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new ip(this.constants_,"right")):this.bottomRow.elements.push(new gp(this.constants_,
1479
+ "right"))}addInput_(a,b){if(this.isInline&&a instanceof $.On)b.elements.push(new ap(this.constants_,a)),b.hasInlineInput=!0;else if(a instanceof Nn)b.elements.push(new jp(this.constants_,a)),b.hasStatement=!0;else if(a instanceof $.On)b.elements.push(new To(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Ln||a instanceof Mn)b.minHeight=Math.max(b.minHeight,a.getSourceBlock()&&a.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),
1480
+ b.hasDummyInput=!0;b.align===null&&(b.align=a.align)}shouldStartNewRow_(a,b){return b?b instanceof Mn||a instanceof Nn||b instanceof Nn?!0:a instanceof $.On||a instanceof Ln||b instanceof $.On?!this.isInline:!1:!1}addElemSpacing_(){for(let a=0,b;b=this.rows[a];a++){let c=b.elements;b.elements=[];b.startsWithElemSpacer()&&b.elements.push(new $o(this.constants_,this.getInRowSpacing_(null,c[0])));if(c.length){for(let d=0;d<c.length-1;d++){b.elements.push(c[d]);let e=this.getInRowSpacing_(c[d],c[d+1]);
1481
+ b.elements.push(new $o(this.constants_,e))}b.elements.push(c[c.length-1]);b.endsWithElemSpacer()&&b.elements.push(new $o(this.constants_,this.getInRowSpacing_(c[c.length-1],null)))}}}getInRowSpacing_(a,b){if(!a&&b&&Q.isStatementInput(b))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(a&&Q.isInput(a)&&!b){if(Q.isExternalInput(a))return this.constants_.NO_PADDING;if(Q.isInlineInput(a))return this.constants_.LARGE_PADDING;if(Q.isStatementInput(a))return this.constants_.NO_PADDING}return a&&Q.isLeftSquareCorner(a)&&
1481
1482
  b&&(Q.isPreviousConnection(b)||Q.isNextConnection(b))?b.notchOffset:a&&Q.isLeftRoundedCorner(a)&&b&&(Q.isPreviousConnection(b)||Q.isNextConnection(b))?b.notchOffset-this.constants_.CORNER_RADIUS:a&&Q.isField(a)&&a.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING}computeBounds_(){var a=0,b=0,c=0;for(let e=0,f;f=this.rows[e];e++){f.measure();b=Math.max(b,f.width);if(f.hasStatement){var d=f.getLastInput();let g;d=f.width-((g=d==null?void 0:d.width)!=null?g:0);a=Math.max(a,d)}c=Math.max(c,
1482
1483
  f.widthWithConnectedBlocks)}this.statementEdge=a;this.width=b;for(let e=0,f;f=this.rows[e];e++)f.hasStatement&&(f.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(b,c);this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let b=0,c;c=this.rows[b];b++)if(c.hasStatement)this.alignStatementRow_(c);else{var a=c.width;a=this.getDesiredRowWidth_(c)-a;a>0&&this.addAlignmentPadding_(c,
1483
- a);Q.isTopOrBottomRow(c)&&(c.widthWithConnectedBlocks=c.width)}}getDesiredRowWidth_(){return this.width-this.startX}addAlignmentPadding_(a,b){var c=a.getFirstSpacer(),d=a.getLastSpacer();if(a.hasExternalInput||a.hasStatement)a.widthWithConnectedBlocks+=b;if(a.align===$.En.LEFT&&d)d.width+=b;else if(a.align===$.En.CENTRE&&c&&d)c.width+=b/2,d.width+=b/2;else if(a.align===$.En.RIGHT&&c)c.width+=b;else if(d)d.width+=b;else return;a.width+=b}alignStatementRow_(a){var b=a.getLastInput();if(b){var c=a.width-
1484
+ a);Q.isTopOrBottomRow(c)&&(c.widthWithConnectedBlocks=c.width)}}getDesiredRowWidth_(){return this.width-this.startX}addAlignmentPadding_(a,b){var c=a.getFirstSpacer(),d=a.getLastSpacer();if(a.hasExternalInput||a.hasStatement)a.widthWithConnectedBlocks+=b;if(a.align===$.Fn.LEFT&&d)d.width+=b;else if(a.align===$.Fn.CENTRE&&c&&d)c.width+=b/2,d.width+=b/2;else if(a.align===$.Fn.RIGHT&&c)c.width+=b;else if(d)d.width+=b;else return;a.width+=b}alignStatementRow_(a){var b=a.getLastInput();if(b){var c=a.width-
1484
1485
  b.width,d=this.statementEdge;c=d-c;c>0&&this.addAlignmentPadding_(a,c);c=a.width;d=this.getDesiredRowWidth_(a);b.width+=d-c;b.height=Math.max(b.height,a.height);a.width+=d-c;a.widthWithConnectedBlocks=Math.max(a.width,this.statementEdge+a.connectedBlockWidths)}}addRowSpacing_(){var a=this.rows;this.rows=[];for(let b=0;b<a.length;b++)this.rows.push(a[b]),b!==a.length-1&&this.rows.push(this.makeSpacerRow_(a[b],a[b+1]))}makeSpacerRow_(a,b){var c=this.getSpacerRowHeight_(a,b),d=this.getSpacerRowWidth_(a,
1485
- b);c=new gp(this.constants_,c,d);a.hasStatement&&(c.followsStatement=!0);b.hasStatement&&(c.precedesStatement=!0);return c}getSpacerRowWidth_(){return this.width-this.startX}getSpacerRowHeight_(){return this.constants_.MEDIUM_PADDING}getElemCenterline_(a,b){return Q.isSpacer(b)?a.yPos+b.height/2:Q.isBottomRow(a)?(a=a.yPos+a.height-a.descenderHeight,Q.isNextConnection(b)?a+b.height/2:a-b.height/2):Q.isTopRow(a)?Q.isHat(b)?a.capline-b.height/2:a.capline+b.height/2:a.yPos+a.height/2}recordElemPositions_(a){var b=
1486
+ b);c=new hp(this.constants_,c,d);a.hasStatement&&(c.followsStatement=!0);b.hasStatement&&(c.precedesStatement=!0);return c}getSpacerRowWidth_(){return this.width-this.startX}getSpacerRowHeight_(){return this.constants_.MEDIUM_PADDING}getElemCenterline_(a,b){return Q.isSpacer(b)?a.yPos+b.height/2:Q.isBottomRow(a)?(a=a.yPos+a.height-a.descenderHeight,Q.isNextConnection(b)?a+b.height/2:a-b.height/2):Q.isTopRow(a)?Q.isHat(b)?a.capline-b.height/2:a.capline+b.height/2:a.yPos+a.height/2}recordElemPositions_(a){var b=
1486
1487
  a.xPos;for(let c=0,d;d=a.elements[c];c++)Q.isSpacer(d)&&(d.height=a.height),d.xPos=b,d.centerline=this.getElemCenterline_(a,d),b+=d.width}finalize_(){var a=0,b=0;for(let c=0,d;d=this.rows[c];c++)d.yPos=b,d.xPos=this.startX,b+=d.height,a=Math.max(a,d.widthWithConnectedBlocks),this.recordElemPositions_(d);if(this.outputConnection&&this.block_.nextConnection){let c=this.block_.nextConnection.targetBlock();c&&(a=Math.max(a,c.getHeightWidth().width))}this.widthWithChildren=a+this.startX;this.height=b;
1487
- this.startY=this.topRow.capline;this.bottomRow.baseline=b-this.bottomRow.descenderHeight}getMeasureableForConnection(a){var b;if(((b=this.outputConnection)==null?void 0:b.connectionModel)===a)return this.outputConnection;for(let c of this.rows)for(let d of c.elements)if(d instanceof Qo&&d.connectionModel===a)return d;return null}};var op=class{constructor(a,b,c){this.connectionHighlights=new WeakMap;this.highlightOffsets=new WeakMap;this.constants=c;this.style=b;this.svgRoot=a;this.svgPath=r(q.PATH,{"class":"blocklyPath"},this.svgRoot);this.setClass_("blocklyBlock",!0)}setPath(a){this.svgPath.setAttribute("d",a)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}applyColour(a){this.svgPath.setAttribute("stroke",this.style.colourTertiary);this.svgPath.setAttribute("fill",this.style.colourPrimary);this.updateShadow_(a.isShadow());
1488
+ this.startY=this.topRow.capline;this.bottomRow.baseline=b-this.bottomRow.descenderHeight}getMeasureableForConnection(a){var b;if(((b=this.outputConnection)==null?void 0:b.connectionModel)===a)return this.outputConnection;for(let c of this.rows)for(let d of c.elements)if(d instanceof Ro&&d.connectionModel===a)return d;return null}};var pp=class{constructor(a,b,c){this.connectionHighlights=new WeakMap;this.highlightOffsets=new WeakMap;this.constants=c;this.style=b;this.svgRoot=a;this.svgPath=r(q.PATH,{"class":"blocklyPath"},this.svgRoot);this.setClass_("blocklyBlock",!0)}setPath(a){this.svgPath.setAttribute("d",a)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}applyColour(a){this.svgPath.setAttribute("stroke",this.style.colourTertiary);this.svgPath.setAttribute("fill",this.style.colourPrimary);this.updateShadow_(a.isShadow());
1488
1489
  this.updateDisabled_(!a.isEnabled()||a.getInheritedDisabled())}setStyle(a){this.style=a}setClass_(a,b){a&&(b?n(this.svgRoot,a):Ma(this.svgRoot,a))}updateHighlighted(a){a?this.setClass_("blocklyHighlighted",!0):this.setClass_("blocklyHighlighted",!1)}updateShadow_(a){a?(this.setClass_("blocklyShadow",!0),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)):this.setClass_("blocklyShadow",!1)}updateDisabled_(a){this.setClass_("blocklyDisabled",a);this.setClass_("blocklyDisabledPattern",
1489
1490
  a)}updateSelected(a){this.setClass_("blocklySelected",a)}updateDraggingDelete(a){this.setClass_("blocklyDraggingDelete",a)}updateInsertionMarker(a){this.setClass_("blocklyInsertionMarker",a)}updateMovable(a){this.setClass_("blocklyDraggable",a)}updateReplacing(a){this.setClass_("blocklyReplaceable",a)}addConnectionHighlight(a,b,c,d){c=`translate(${c.x}, ${c.y})`+(d?" scale(-1 1)":"");if(d=this.connectionHighlights.get(a))return d.setAttribute("d",b),d.setAttribute("transform",c),d;b=r(q.PATH,{id:a.id,
1490
- "class":"blocklyHighlightedConnectionPath",d:b,transform:c},this.svgRoot);this.connectionHighlights.set(a,b);return b}removeConnectionHighlight(a){var b=this.connectionHighlights.get(a);b&&(Oa(b),this.connectionHighlights.delete(a))}};var pp=class{constructor(a){this.overrides=null;this.name=a}getClassName(){return this.name+"-renderer"}init(a,b){this.constants_=this.makeConstants_();b&&(this.overrides=b,Object.assign(this.constants_,b));this.constants_.setTheme(a);this.constants_.init()}createDom(a,b,c){this.constants_.createDom(a,"."+this.getClassName()+"."+b.getClassName(),c)}refreshDom(a,b,c){var d=this.getConstants();d.dispose();this.constants_=this.makeConstants_();this.overrides&&Object.assign(this.constants_,this.overrides);
1491
- this.constants_.randomIdentifier=d.randomIdentifier;this.constants_.setTheme(b);this.constants_.init();this.createDom(a,b,c)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new lp}makeRenderInfo_(a){return new np(this,a)}makeDrawer_(a,b){return new mp(a,b)}makePathObject(a,b){return new op(a,b,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(a){return!a.getSourceBlock().isDragging()}orphanCanConnectAtEnd(a,b,c){return!!Bn.getConnectionForOrphanedConnection(a,
1492
- c===G.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}render(a){var b=this.makeRenderInfo_(a);b.measure();this.makeDrawer_(a,b).draw()}};var qp={};qp.BottomRow=Po;qp.Connection=Qo;qp.ConstantProvider=lp;qp.Drawer=mp;qp.ExternalValueInput=So;qp.Field=To;qp.Hat=Xo;qp.Icon=Yo;qp.InRowSpacer=Zo;qp.InlineInput=$o;qp.InputConnection=Ro;qp.InputRow=ap;qp.JaggedEdge=bp;qp.Measurable=No;qp.NextConnection=cp;qp.OutputConnection=dp;qp.PathObject=op;qp.PreviousConnection=ep;qp.RenderInfo=np;qp.Renderer=pp;qp.RoundCorner=fp;qp.Row=Oo;qp.SpacerRow=gp;qp.SquareCorner=hp;qp.StatementInput=ip;qp.TopRow=jp;qp.Types=Q;qp.init=vj;qp.register=uj;
1493
- qp.unregister=function(a){Eb(y.RENDERER,a)};var rp=class{constructor(a,b){this.workspace=a;this.theme=b;this.subscribedWorkspaces=[];this.componentDB=new Map}getTheme(){return this.theme}setTheme(a){var b=this.theme;this.theme=a;if(a=this.workspace.getInjectionDiv())b&&(b=b.getClassName())&&Ma(a,b),(b=this.theme.getClassName())&&n(a,b);for(let c=0,d;d=this.subscribedWorkspaces[c];c++)d.refreshTheme();for(let [c,d]of this.componentDB)for(let e of d){a=e.element;b=e.propertyName;let f=this.theme&&this.theme.getComponentStyle(c);a.style.setProperty(b,
1491
+ "class":"blocklyHighlightedConnectionPath",d:b,transform:c},this.svgRoot);this.connectionHighlights.set(a,b);return b}removeConnectionHighlight(a){var b=this.connectionHighlights.get(a);b&&(Oa(b),this.connectionHighlights.delete(a))}};var qp=class{constructor(a){this.overrides=null;this.name=a}getClassName(){return this.name+"-renderer"}init(a,b){this.constants_=this.makeConstants_();b&&(this.overrides=b,Object.assign(this.constants_,b));this.constants_.setTheme(a);this.constants_.init()}createDom(a,b,c){this.constants_.createDom(a,"."+this.getClassName()+"."+b.getClassName(),c)}refreshDom(a,b,c){var d=this.getConstants();d.dispose();this.constants_=this.makeConstants_();this.overrides&&Object.assign(this.constants_,this.overrides);
1492
+ this.constants_.randomIdentifier=d.randomIdentifier;this.constants_.setTheme(b);this.constants_.init();this.createDom(a,b,c)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new mp}makeRenderInfo_(a){return new op(this,a)}makeDrawer_(a,b){return new np(a,b)}makePathObject(a,b){return new pp(a,b,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(a){return!a.getSourceBlock().isDragging()}orphanCanConnectAtEnd(a,b,c){return!!Cn.getConnectionForOrphanedConnection(a,
1493
+ c===G.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}render(a){var b=this.makeRenderInfo_(a);b.measure();this.makeDrawer_(a,b).draw()}};var rp={};rp.BottomRow=Qo;rp.Connection=Ro;rp.ConstantProvider=mp;rp.Drawer=np;rp.ExternalValueInput=To;rp.Field=Uo;rp.Hat=Yo;rp.Icon=Zo;rp.InRowSpacer=$o;rp.InlineInput=ap;rp.InputConnection=So;rp.InputRow=bp;rp.JaggedEdge=cp;rp.Measurable=Oo;rp.NextConnection=dp;rp.OutputConnection=ep;rp.PathObject=pp;rp.PreviousConnection=fp;rp.RenderInfo=op;rp.Renderer=qp;rp.RoundCorner=gp;rp.Row=Po;rp.SpacerRow=hp;rp.SquareCorner=ip;rp.StatementInput=jp;rp.TopRow=kp;rp.Types=Q;rp.init=vj;rp.register=uj;
1494
+ rp.unregister=function(a){Eb(y.RENDERER,a)};var sp=class{constructor(a,b){this.workspace=a;this.theme=b;this.subscribedWorkspaces=[];this.componentDB=new Map}getTheme(){return this.theme}setTheme(a){var b=this.theme;this.theme=a;if(a=this.workspace.getInjectionDiv())b&&(b=b.getClassName())&&Ma(a,b),(b=this.theme.getClassName())&&n(a,b);for(let c=0,d;d=this.subscribedWorkspaces[c];c++)d.refreshTheme();for(let [c,d]of this.componentDB)for(let e of d){a=e.element;b=e.propertyName;let f=this.theme&&this.theme.getComponentStyle(c);a.style.setProperty(b,
1494
1495
  f||"")}for(let c of this.subscribedWorkspaces)c.hideChaff()}subscribeWorkspace(a){this.subscribedWorkspaces.push(a)}unsubscribeWorkspace(a){if(!qa(this.subscribedWorkspaces,a))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.");}subscribe(a,b,c){this.componentDB.has(b)||this.componentDB.set(b,[]);this.componentDB.get(b).push({element:a,propertyName:c});b=this.theme&&this.theme.getComponentStyle(b);a.style.setProperty(c,b||"")}unsubscribe(a){if(a)for(let [b,c]of this.componentDB){for(let d=
1495
- c.length-1;d>=0;d--)c[d].element===a&&c.splice(d,1);c.length||this.componentDB.delete(b)}}dispose(){this.subscribedWorkspaces.length=0;this.componentDB.clear()}};var sp={CATEGORY_NAME:"VARIABLE_DYNAMIC"};sp.flyoutCategory=zj;
1496
- sp.flyoutCategoryBlocks=function(a){a=a.getVariableMap().getAllVariables();var b=[];if(a.length>0){if(zb.variables_set_dynamic){var c=a[a.length-1];let d=$.rc("block");d.setAttribute("type","variables_set_dynamic");d.setAttribute("gap","24");d.appendChild(Ud(c));b.push(d)}if(zb.variables_get_dynamic){a.sort(Hd);for(let d=0,e;e=a[d];d++)c=$.rc("block"),c.setAttribute("type","variables_get_dynamic"),c.setAttribute("gap","8"),c.appendChild(Ud(e)),b.push(c)}}return b};
1497
- sp.onCreateVariableButtonClick_Colour=yj;sp.onCreateVariableButtonClick_Number=xj;sp.onCreateVariableButtonClick_String=wj;var tp=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(a){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1;this.MAX_UNDO=1024;this.connectionDBList=[];this.topBlocks=[];this.topComments=[];this.commentDB=new Map;this.listeners=[];this.undoStack_=[];this.redoStack_=[];this.blockDB=new Map;this.typedBlocksDB=new Map;this.procedureMap=new Ko;this.readOnly=!1;this.potentialVariableMap=null;this.id=Nb();hb(this);this.options=
1498
- a||new pn({});this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.connectionChecker=new (Jb(y.CONNECTION_CHECKER,this.options,!0))(this);this.variableMap=new (this.getVariableMapClass())(this);this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0;this.clear();ib(this)}sortObjects(a,b){var c=d=>({getBoundingRectangle:()=>{var e=d.getRelativeToSurfaceXY();return new cc(e.y,e.y,e.x,e.x)},moveBy:()=>
1499
- {}});return this.sortByOrigin(c(a),c(b))}sortByOrigin(a,b){var c=Math.sin(Ne(tp.SCAN_ANGLE))*(this.RTL?-1:1);a=a.getBoundingRectangle().getOrigin();b=b.getBoundingRectangle().getOrigin();return a.y+c*a.x-(b.y+c*b.x)}addTopBlock(a){this.topBlocks.push(a)}removeTopBlock(a){if(!qa(this.topBlocks,a))throw Error("Block not present in workspace's list of top-most blocks.");}getTopBlocks(a=!1){var b=[].concat(this.topBlocks);a&&b.length>1&&b.sort(this.sortObjects.bind(this));return b}addTypedBlock(a){this.typedBlocksDB.has(a.type)||
1496
+ c.length-1;d>=0;d--)c[d].element===a&&c.splice(d,1);c.length||this.componentDB.delete(b)}}dispose(){this.subscribedWorkspaces.length=0;this.componentDB.clear()}};var tp={CATEGORY_NAME:"VARIABLE_DYNAMIC"};tp.flyoutCategory=zj;
1497
+ tp.flyoutCategoryBlocks=function(a){a=a.getVariableMap().getAllVariables();var b=[];if(a.length>0){if(zb.variables_set_dynamic){var c=a[a.length-1];let d=$.rc("block");d.setAttribute("type","variables_set_dynamic");d.setAttribute("gap","24");d.appendChild(Ud(c));b.push(d)}if(zb.variables_get_dynamic){a.sort(Hd);for(let d=0,e;e=a[d];d++)c=$.rc("block"),c.setAttribute("type","variables_get_dynamic"),c.setAttribute("gap","8"),c.appendChild(Ud(e)),b.push(c)}}return b};
1498
+ tp.onCreateVariableButtonClick_Colour=yj;tp.onCreateVariableButtonClick_Number=xj;tp.onCreateVariableButtonClick_String=wj;var up=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(a){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1;this.MAX_UNDO=1024;this.connectionDBList=[];this.topBlocks=[];this.topComments=[];this.commentDB=new Map;this.listeners=[];this.undoStack_=[];this.redoStack_=[];this.blockDB=new Map;this.typedBlocksDB=new Map;this.procedureMap=new Lo;this.readOnly=!1;this.potentialVariableMap=null;this.id=Nb();hb(this);this.options=
1499
+ a||new qn({});this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.connectionChecker=new (Jb(y.CONNECTION_CHECKER,this.options,!0))(this);this.variableMap=new (this.getVariableMapClass())(this);this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0;this.clear();jb(this)}sortObjects(a,b){var c=d=>({getBoundingRectangle:()=>{var e=d.getRelativeToSurfaceXY();return new cc(e.y,e.y,e.x,e.x)},moveBy:()=>
1500
+ {}});return this.sortByOrigin(c(a),c(b))}sortByOrigin(a,b){var c=Math.sin(Ne(up.SCAN_ANGLE))*(this.RTL?-1:1);a=a.getBoundingRectangle().getOrigin();b=b.getBoundingRectangle().getOrigin();return a.y+c*a.x-(b.y+c*b.x)}addTopBlock(a){this.topBlocks.push(a)}removeTopBlock(a){if(!qa(this.topBlocks,a))throw Error("Block not present in workspace's list of top-most blocks.");}getTopBlocks(a=!1){var b=[].concat(this.topBlocks);a&&b.length>1&&b.sort(this.sortObjects.bind(this));return b}addTypedBlock(a){this.typedBlocksDB.has(a.type)||
1500
1501
  this.typedBlocksDB.set(a.type,[]);this.typedBlocksDB.get(a.type).push(a)}removeTypedBlock(a){qa(this.typedBlocksDB.get(a.type),a);this.typedBlocksDB.get(a.type).length||this.typedBlocksDB.delete(a.type)}getBlocksByType(a,b=!1){if(!this.typedBlocksDB.has(a))return[];a=this.typedBlocksDB.get(a).slice(0);b&&a&&a.length>1&&a.sort(this.sortObjects.bind(this));return a.filter(c=>!c.isInsertionMarker())}addTopComment(a){this.topComments.push(a);this.commentDB.has(a.id)&&console.warn('Overriding an existing comment on this workspace, with id "'+
1501
1502
  a.id+'"');this.commentDB.set(a.id,a)}removeTopComment(a){if(!qa(this.topComments,a))throw Error("Comment not present in workspace's list of top-most comments.");this.commentDB.delete(a.id)}getTopComments(a=!1){var b=[].concat(this.topComments);a&&b.length>1&&b.sort(this.sortObjects.bind(this));return b}getAllBlocks(a=!1){if(a){var b=this.getTopBlocks(!0);a=[];for(let c=0;c<b.length;c++)a.push(...b[c].getDescendants(!0))}else for(a=this.getTopBlocks(!1),b=0;b<a.length;b++)a.push(...a[b].getChildren(!1));
1502
1503
  return a.filter(c=>!c.isInsertionMarker())}clear(){this.isClearing=!0;try{let a=$.gd;for(a||$.B(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();$.B(a);this.isFlyout||this.variableMap.clear();this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}getWidth(){return 0}newBlock(){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts");}newComment(){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts");
@@ -1504,95 +1505,95 @@ return a.filter(c=>!c.isInsertionMarker())}clear(){this.isClearing=!0;try{let a=
1504
1505
  Infinity||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(a=!1){var b=a?this.redoStack_:this.undoStack_,c=a?this.undoStack_:this.redoStack_,d=b.pop();if(d){for(var e=[d];b.length&&d.group&&d.group===b[b.length-1].group;){let f=b.pop();f&&e.push(f)}for(b=0;b<e.length;b++)c.push(e[b]);$.Qc=!1;try{for(c=0;c<e.length;c++)e[c].run(a)}finally{$.Qc=!0}}}redo(){this.undo(!0)}clearUndo(){this.undoStack_.length=0;this.redoStack_.length=0;Tb()}addChangeListener(a){this.listeners.push(a);
1505
1506
  return a}removeChangeListener(a){qa(this.listeners,a)}fireChangeListener(a){if(a.recordUndo)for(this.undoStack_.push(a),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&this.MAX_UNDO>=0;)this.undoStack_.shift();for(let b=0;b<this.listeners.length;b++)(0,this.listeners[b])(a)}getBlockById(a){return this.blockDB.get(a)||null}setBlockById(a,b){this.blockDB.set(a,b)}removeBlockById(a){this.blockDB.delete(a)}getCommentById(a){var b;return(b=this.commentDB.get(a))!=null?b:null}allInputsFilled(a){var b=
1506
1507
  this.getTopBlocks(!1);for(let c=0;c<b.length;c++)if(!b[c].allInputsFilled(a))return!1;return!0}getPotentialVariableMap(){return this.potentialVariableMap}createPotentialVariableMap(){this.potentialVariableMap=new (this.getVariableMapClass())(this,!0)}getVariableMap(){return this.variableMap}setVariableMap(a){this.variableMap=a}getProcedureMap(){return this.procedureMap}getRootWorkspace(){var a=null,b=this.options.parentWorkspace;this.isFlyout?b&&b.options&&(a=b.options.parentWorkspace):b&&(a=b);return a}static getById(a){return fb(a)}static getAll(){return gb()}getVariableMapClass(){var a=
1507
- Jb(y.VARIABLE_MAP,this.options,!0);if(!a)throw Error("No variable map is registered.");return a}isReadOnly(){return this.readOnly}setIsReadOnly(a){this.readOnly=a;this.options.readOnly=a}};tp.SCAN_ANGLE=3;var up=class{constructor(a){this.parentWorkspace=a;this.sounds=new Map;this.lastSound=null;this.muted=!1;window.AudioContext&&(this.context=new AudioContext)}dispose(){this.sounds.clear();var a;(a=this.context)==null||a.close()}load(a,b){var c=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(a.length){var d=yield(yield fetch(a[0])).arrayBuffer(),e;(e=c.context)==null||e.decodeAudioData(d,f=>{c.sounds.set(b,f)})}})}play(a,b){var c=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(c.isPlayingAllowed()&&
1508
+ Jb(y.VARIABLE_MAP,this.options,!0);if(!a)throw Error("No variable map is registered.");return a}isReadOnly(){return this.readOnly}setIsReadOnly(a){this.readOnly=a;this.options.readOnly=a}};up.SCAN_ANGLE=3;var vp=class{constructor(a){this.parentWorkspace=a;this.sounds=new Map;this.lastSound=null;this.muted=!1;window.AudioContext&&(this.context=new AudioContext)}dispose(){this.sounds.clear();var a;(a=this.context)==null||a.close()}load(a,b){var c=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(a.length){var d=yield(yield fetch(a[0])).arrayBuffer(),e;(e=c.context)==null||e.decodeAudioData(d,f=>{c.sounds.set(b,f)})}})}play(a,b){var c=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(c.isPlayingAllowed()&&
1508
1509
  b!==0){var d=c.sounds.get(a);if(d){yield c.prepareToPlay();let e=c.context.createBufferSource(),f=c.context.createGain();f.gain.value=b!=null?b:1;f.connect(c.context.destination);e.buffer=d;e.connect(f);e.addEventListener("ended",()=>{e.disconnect();f.disconnect()});e.start()}else c.parentWorkspace&&(d=c.parentWorkspace.getAudioManager(),d!==c&&d.play(a,b))}})}beep(a,b=.2){var c=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(c.isPlayingAllowed()){yield c.prepareToPlay();var d=
1509
1510
  c.context.createOscillator();d.type="sine";d.frequency.setValueAtTime(a,c.context.currentTime);var e=c.context.createGain();e.gain.setValueAtTime(0,c.context.currentTime);e.gain.linearRampToValueAtTime(.5,c.context.currentTime+.01);e.gain.linearRampToValueAtTime(0,c.context.currentTime+b);d.connect(e);e.connect(c.context.destination);d.start(c.context.currentTime);d.stop(c.context.currentTime+b)}})}playErrorBeep(){var a=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){return a.beep(260)})}maybePlayScopeChangeAudioCue(a){if(Nd.getScopeChangeAudioCuesEnabled()){var b=
1510
1511
  this.parentWorkspace.getNavigator(),c=b.getSourceBlockFromNode($.t().getFocusedNode());a=b.getSourceBlockFromNode(a);b=0;c&&a&&c.getNestingLevel()!==(b=a.getNestingLevel())&&this.beep(400+b*60)}}isPlayingAllowed(){var a=new Date;return this.getMuted()||!this.context||this.lastSound!==null&&a.getTime()-this.lastSound.getTime()<100?!1:!0}prepareToPlay(){var a=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){a.lastSound=new Date;a.context.state==="suspended"&&(yield a.context.resume())})}setMuted(a){this.muted=
1511
- a}getMuted(){return this.muted}};var vp=class{constructor(a,b){this.workspace=a;this.element=b}getFocusableElement(){return this.element}getFocusableTree(){return this.workspace}onNodeFocus(){this.workspace.handleWorkspaceFocusTargetFocus()}onNodeBlur(){}canBeFocused(){return!0}getWorkspace(){return this.workspace}};var $h=class extends tp{constructor(a){super(a);this.resizeHandlerWrapper=null;this.resizesEnabled=this.visible=this.rendered=!0;this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0;this.oldScale=this.scale=1;this.oldLeft=this.oldTop=0;this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null;this.inverseScreenCTMDirty=!0;this.highlightedBlocks=
1512
- [];this.toolboxCategoryCallbacks=new Map;this.flyoutButtonCallbacks=new Map;this.cachedParentSvg=null;this.topBoundedElements=[];this.dragTargetAreas=[];this.workspaceFocusTarget=this.workspaceFocusTargetElement=this.workspaceSelectionRing=this.workspaceFocusRing=this.zoomControls_=this.layerManager=null;this.navigator=new xo;this.metricsManager=new (Jb(y.METRICS_MANAGER,a,!0))(this);this.getMetrics=a.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager);this.setMetrics=a.setMetrics||
1513
- $h.setTopLevelWorkspaceMetrics;this.componentManager=new Dk;this.connectionDBList=An.init(this.connectionChecker);var b;this.audioManager=new up((b=a.parentWorkspace)!=null?b:this);this.grid=this.options.gridPattern?new Cj(this.options.gridPattern,a.gridOptions):null;Mm&&Fd&&this.registerToolboxCategoryCallback("VARIABLE",Fd);sp&&zj&&this.registerToolboxCategoryCallback("VARIABLE_DYNAMIC",zj);Lo&&nj&&(this.registerToolboxCategoryCallback("PROCEDURE",nj),this.addChangeListener(qj));this.addChangeListener(this.variableChangeCallback.bind(this));
1514
- this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new rp(this,this.options.theme||on);this.themeManager_.subscribeWorkspace(this);var c;this.renderer=vj(this.options.renderer||"geras",this.getTheme(),(c=this.options.rendererOverrides)!=null?c:void 0);this.cachedParentSvgSize=new hc(0,0)}getMetricsManager(){return this.metricsManager}setMetricsManager(a){this.metricsManager=a;this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(a){a||
1515
- (a=on);this.themeManager_.setTheme(a)}refreshTheme(){if(this.svgGroup_){var a=this.options.parentWorkspace===null;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),a?this.getInjectionDiv():void 0)}this.updateBlockStyles(this.getAllBlocks(!1).filter(b=>!!b.getStyleName()));this.refreshToolboxSelection();this.toolbox&&this.toolbox.refreshTheme();this.isVisible()&&this.setVisible(!0);a=new (u(v.THEME_CHANGE))(this.getTheme().name,this.id);w(a)}updateBlockStyles(a){for(let b=0,c;c=a[b];b++){let d=
1512
+ a}getMuted(){return this.muted}};var wp=class{constructor(a,b){this.workspace=a;this.element=b}getFocusableElement(){return this.element}getFocusableTree(){return this.workspace}onNodeFocus(){this.workspace.handleWorkspaceFocusTargetFocus()}onNodeBlur(){}canBeFocused(){return!0}getWorkspace(){return this.workspace}};var $h=class extends up{constructor(a){super(a);this.resizeHandlerWrapper=null;this.resizesEnabled=this.visible=this.rendered=!0;this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0;this.oldScale=this.scale=1;this.oldLeft=this.oldTop=0;this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null;this.inverseScreenCTMDirty=!0;this.highlightedBlocks=
1513
+ [];this.toolboxCategoryCallbacks=new Map;this.flyoutButtonCallbacks=new Map;this.cachedParentSvg=null;this.topBoundedElements=[];this.dragTargetAreas=[];this.workspaceFocusTarget=this.workspaceFocusTargetElement=this.workspaceSelectionRing=this.workspaceFocusRing=this.zoomControls_=this.layerManager=null;this.navigator=new yo;this.metricsManager=new (Jb(y.METRICS_MANAGER,a,!0))(this);this.getMetrics=a.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager);this.setMetrics=a.setMetrics||
1514
+ $h.setTopLevelWorkspaceMetrics;this.componentManager=new Ek;this.connectionDBList=Bn.init(this.connectionChecker);var b;this.audioManager=new vp((b=a.parentWorkspace)!=null?b:this);this.grid=this.options.gridPattern?new Dj(this.options.gridPattern,a.gridOptions):null;Nm&&Fd&&this.registerToolboxCategoryCallback("VARIABLE",Fd);tp&&zj&&this.registerToolboxCategoryCallback("VARIABLE_DYNAMIC",zj);Mo&&nj&&(this.registerToolboxCategoryCallback("PROCEDURE",nj),this.addChangeListener(qj));this.addChangeListener(this.variableChangeCallback.bind(this));
1515
+ this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new sp(this,this.options.theme||pn);this.themeManager_.subscribeWorkspace(this);var c;this.renderer=vj(this.options.renderer||"geras",this.getTheme(),(c=this.options.rendererOverrides)!=null?c:void 0);this.cachedParentSvgSize=new hc(0,0)}getMetricsManager(){return this.metricsManager}setMetricsManager(a){this.metricsManager=a;this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(a){a||
1516
+ (a=pn);this.themeManager_.setTheme(a)}refreshTheme(){if(this.svgGroup_){var a=this.options.parentWorkspace===null;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),a?this.getInjectionDiv():void 0)}this.updateBlockStyles(this.getAllBlocks(!1).filter(b=>!!b.getStyleName()));this.refreshToolboxSelection();this.toolbox&&this.toolbox.refreshTheme();this.isVisible()&&this.setVisible(!0);a=new (u(v.THEME_CHANGE))(this.getTheme().name,this.id);w(a)}updateBlockStyles(a){for(let b=0,c;c=a[b];b++){let d=
1516
1517
  c.getStyleName();d&&c.setStyle(d)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){let a=this.getParentSvg().getScreenCTM();a&&(this.inverseScreenCTM=a.inverse(),this.inverseScreenCTMDirty=!1)}return this.inverseScreenCTM}updateInverseScreenCTM(){this.inverseScreenCTMDirty=!0}isVisible(){return this.visible}getSvgXY(a){var b=0,c=0,d=1;if(this.getCanvas().contains(a)||this.getBubbleCanvas().contains(a))d=this.scale;do{let e=kc(a);if(a===this.getCanvas()||a===this.getBubbleCanvas())d=1;b+=e.x*
1517
1518
  d;c+=e.y*d;a=a.parentNode}while(a&&a!==this.getParentSvg()&&a!==this.getInjectionDiv());return new D(b,c)}getCachedParentSvgSize(){var a=this.cachedParentSvgSize;return new hc(a.width,a.height)}getOriginOffsetInPixels(){return lc(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let a=this.svgGroup_;for(;a;){if((" "+(a.getAttribute("class")||"")+" ").includes(" injectionDiv ")){this.injectionDiv=a;break}a=a.parentNode}}return this.injectionDiv}getSvgGroup(){return this.svgGroup_}getBlockCanvas(){return this.getCanvas()}setResizeHandlerWrapper(a){this.resizeHandlerWrapper=
1518
1519
  a}setInitialAriaContext(){if(!this.svgGroup_)throw Error("Must initialize svgGroup_ by calling `createDom` before calling setAriaContext");this.isFlyout||(ya(this.svgGroup_,Ka.REGION),this.isMutator?l(this.svgGroup_,p.LABEL,$.C.WORKSPACE_LABEL_MUTATOR_WORKSPACE):(l(this.svgGroup_,p.LABEL,$.C.WORKSPACE_LABEL_PLAIN),this.workspaceFocusTargetElement&&(ya(this.workspaceFocusTargetElement,Ka.FIGURE),l(this.workspaceFocusTargetElement,p.ROLEDESCRIPTION,$.C.WORKSPACE_ROLEDESCRIPTION),this.updateAriaLabel())))}updateAriaLabel(){if(this.workspaceFocusTargetElement){var a=
1519
1520
  this.getTopBlocks(!1).length;a==1?l(this.workspaceFocusTargetElement,p.LABEL,$.C.WORKSPACE_LABEL_1_STACK):l(this.workspaceFocusTargetElement,p.LABEL,$.C.WORKSPACE_LABEL_MANY_STACKS.replace("%1",String(a)))}}createDom(a,b){this.injectionDiv||(this.injectionDiv=b!=null?b:null);this.svgGroup_=r(q.G,{"class":"blocklyWorkspace",id:this.id});a&&(this.svgBackground_=r(q.RECT,{height:"100%",width:"100%","class":a},this.svgGroup_),a==="blocklyMainBackground"&&this.grid?this.svgBackground_.style.fill="var(--blocklyGridPattern)":
1520
- this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill"));this.workspaceSelectionRing=a=r(q.RECT,{fill:"none",class:"blocklyWorkspaceSelectionRing"},this.svgGroup_);this.workspaceFocusRing=r(q.RECT,{fill:"none",class:"blocklyWorkspaceFocusRing"},this.svgGroup_);this.isFlyout||this.isMutator||(a.id=`${this.id}_focusTarget`,this.workspaceFocusTargetElement=a,this.workspaceFocusTarget=new vp(this,a));this.layerManager=new Fo(this);this.svgBlockCanvas_=this.layerManager.getBlockLayer();
1521
+ this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill"));this.workspaceSelectionRing=a=r(q.RECT,{fill:"none",class:"blocklyWorkspaceSelectionRing"},this.svgGroup_);this.workspaceFocusRing=r(q.RECT,{fill:"none",class:"blocklyWorkspaceFocusRing"},this.svgGroup_);this.isFlyout||this.isMutator||(a.id=`${this.id}_focusTarget`,this.workspaceFocusTargetElement=a,this.workspaceFocusTarget=new wp(this,a));this.layerManager=new Go(this);this.svgBlockCanvas_=this.layerManager.getBlockLayer();
1521
1522
  this.svgBubbleCanvas_=this.layerManager.getBubbleLayer();this.setInitialAriaContext();this.isFlyout||(k(this.svgGroup_,"pointerdown",this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener("wheel",this.dummyWheelListener,{passive:!0}),k(this.svgGroup_,"wheel",this,this.onMouseWheel,!1,{passive:!1}));this.options.hasCategories&&(this.toolbox=new (Jb(y.TOOLBOX,this.options,!0))(this));this.grid&&this.grid.update(this.scale);this.recordDragTargets();a=this.options.parentWorkspace===
1522
1523
  null;this.renderer.createDom(this.svgGroup_,this.getTheme(),a?this.getInjectionDiv():void 0);$.t().registerTree(this,!!this.injectionDiv||this.isFlyout);return this.svgGroup_}dispose(){this.rendered=!1;this.currentGesture_&&this.currentGesture_.cancel();this.svgGroup_&&Oa(this.svgGroup_);this.toolbox&&(this.toolbox.dispose(),this.toolbox=null);this.flyout&&(this.flyout.dispose(),this.flyout=null);this.trashcan&&(this.trashcan.dispose(),this.trashcan=null);this.scrollbar&&(this.scrollbar.dispose(),
1523
1524
  this.scrollbar=null);this.zoomControls_&&this.zoomControls_.dispose();this.audioManager&&this.audioManager.dispose();this.grid&&(this.grid=null);this.renderer.dispose();super.dispose();this.themeManager_&&(this.themeManager_.unsubscribeWorkspace(this),this.themeManager_.unsubscribe(this.svgBackground_),this.options.parentWorkspace||this.themeManager_.dispose());this.connectionDBList.length=0;this.toolboxCategoryCallbacks.clear();this.flyoutButtonCallbacks.clear();if(!this.options.parentWorkspace){let c=
1524
1525
  this.getParentSvg();c&&c.parentNode&&Oa(c.parentNode)}this.resizeHandlerWrapper&&(ka(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null);this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null);var a;(a=this.workspaceFocusRing)==null||a.remove();var b;(b=this.workspaceSelectionRing)==null||b.remove();$.t().isRegistered(this)&&$.t().unregisterTree(this)}addTrashcan(){this.trashcan=$h.newTrashcan(this);var a=this.trashcan.createDom();
1525
- this.svgGroup_.insertBefore(a,this.getCanvas())}static newTrashcan(){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts");}addZoomControls(){this.zoomControls_=new ql(this);var a=this.zoomControls_.createDom();this.svgGroup_.appendChild(a)}copyOptionsForFlyout(){return new pn({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,
1526
+ this.svgGroup_.insertBefore(a,this.getCanvas())}static newTrashcan(){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts");}addZoomControls(){this.zoomControls_=new rl(this);var a=this.zoomControls_.createDom();this.svgGroup_.appendChild(a)}copyOptionsForFlyout(){return new qn({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,
1526
1527
  plugins:this.options.plugins,modalInputs:this.options.modalInputs,move:{scrollbars:!0}})}addFlyout(a){var b=this.copyOptionsForFlyout();b.toolboxPosition=this.options.toolboxPosition;this.flyout=this.horizontalLayout?new (Jb(y.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(b):new (Jb(y.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(b);this.flyout.autoClose=!1;this.flyout.getWorkspace().setVisible(!0);return this.flyout.createDom(a)}getFlyout(a){return this.flyout||a?this.flyout:this.toolbox?this.toolbox.getFlyout():
1527
- null}getToolbox(){return this.toolbox}updateScreenCalculations(){this.updateInverseScreenCTM();this.recordDragTargets()}resizeContents(){this.resizesEnabled&&this.rendered&&(this.scrollbar&&this.scrollbar.resize(),this.updateInverseScreenCTM())}resize(){this.toolbox?this.toolbox.position():this.flyout&&this.flyout.position();var a=this.componentManager.getComponents(Dk.Capability.POSITIONABLE,!0),b=this.getMetricsManager().getUiMetrics(),c=[];for(let d=0,e;e=a[d];d++){e.position(b,c);let f=e.getBoundingRectangle();
1528
+ null}getToolbox(){return this.toolbox}updateScreenCalculations(){this.updateInverseScreenCTM();this.recordDragTargets()}resizeContents(){this.resizesEnabled&&this.rendered&&(this.scrollbar&&this.scrollbar.resize(),this.updateInverseScreenCTM())}resize(){this.toolbox?this.toolbox.position():this.flyout&&this.flyout.position();var a=this.componentManager.getComponents(Ek.Capability.POSITIONABLE,!0),b=this.getMetricsManager().getUiMetrics(),c=[];for(let d=0,e;e=a[d];d++){e.position(b,c);let f=e.getBoundingRectangle();
1528
1529
  f&&c.push(f)}this.scrollbar&&this.scrollbar.resize();this.updateScreenCalculations();this.workspaceFocusRing&&this.workspaceSelectionRing&&(this.resizeWorkspaceRing(this.workspaceSelectionRing,5),this.resizeWorkspaceRing(this.workspaceFocusRing,0))}resizeWorkspaceRing(a,b){var c=this.getMetrics();a.setAttribute("x",`${c.absoluteLeft+b}`);a.setAttribute("y",`${c.absoluteTop+b}`);a.setAttribute("width",`${Math.max(0,c.viewWidth-b*2)}`);a.setAttribute("height",`${Math.max(0,c.svgHeight-b*2)}`)}updateScreenCalculationsIfScrolled(){var a=
1529
1530
  nc();D.equals(this.lastRecordedPageScroll,a)||(this.lastRecordedPageScroll=a,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(a,b){var c=this.getParentSvg();a!=null&&(this.cachedParentSvgSize.width=a,c.setAttribute("data-cached-width",`${a}`));b!=null&&(this.cachedParentSvgSize.height=b,c.setAttribute("data-cached-height",`${b}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let a=
1530
1531
  this.svgGroup_;for(;a;){if(a.tagName==="svg"){this.cachedParentSvg=a;break}a=a.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(Vb()){var a=this.scale,b=-this.scrollY,c=-this.scrollX;if(!(a===this.oldScale&&Math.abs(b-this.oldTop)<1&&Math.abs(c-this.oldLeft)<1)){var d=new (u(v.VIEWPORT_CHANGE))(b,c,a,this.id,this.oldScale);this.oldScale=a;this.oldTop=b;this.oldLeft=c;w(d)}}}translate(a,b){var c;(c=this.layerManager)==null||c.translateLayers(new D(a,b),this.scale);var d;(d=
1531
1532
  this.grid)==null||d.moveTo(a,b);this.maybeFireViewportChangeEvent()}getWidth(){var a=this.getMetrics();return a?a.viewWidth/this.scale:0}setVisible(a){this.visible=a;this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(a),this.getFlyout()&&this.getFlyout().setContainerVisible(a),this.getParentSvg().style.display=a?"block":"none",this.toolbox&&this.toolbox.setVisible(a),a||this.hideChaff(!0))}render(){var a=this.getAllBlocks(!1);for(let b=a.length-1;b>=0;b--)a[b].queueRender();this.getTopBlocks().flatMap(b=>
1532
1533
  b.getDescendants(!1)).filter(b=>b.isInsertionMarker()).forEach(b=>b.queueRender())}highlightBlock(a,b){if(b===void 0){for(let c=0,d;d=this.highlightedBlocks[c];c++)d.setHighlighted(!1);this.highlightedBlocks.length=0}if(a=a?this.getBlockById(a):null)(b=b===void 0||b)?this.highlightedBlocks.includes(a)||this.highlightedBlocks.push(a):qa(this.highlightedBlocks,a),a.setHighlighted(b)}variableChangeCallback(a){switch(a.type){case v.VAR_CREATE:case v.VAR_DELETE:case v.VAR_RENAME:case v.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){var a=
1533
- this.isFlyout?this.targetWorkspace:this;a&&!a.currentGesture_&&a.toolbox&&a.toolbox.getFlyout()&&a.toolbox.refreshSelection()}recordDragTargets(){var a=this.componentManager.getComponents(Dk.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let b=0,c;c=a[b];b++){let d=c.getClientRect();d&&this.dragTargetAreas.push({component:c,clientRect:d})}}newBlock(){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts");}newComment(){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts");
1534
+ this.isFlyout?this.targetWorkspace:this;a&&!a.currentGesture_&&a.toolbox&&a.toolbox.getFlyout()&&a.toolbox.refreshSelection()}recordDragTargets(){var a=this.componentManager.getComponents(Ek.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let b=0,c;c=a[b];b++){let d=c.getClientRect();d&&this.dragTargetAreas.push({component:c,clientRect:d})}}newBlock(){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts");}newComment(){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts");
1534
1535
  }getDragTarget(a){a=a instanceof D?a:new D(a.clientX,a.clientY);for(let b=0,c;c=this.dragTargetAreas[b];b++)if(c.clientRect.contains(a.x,a.y))return c.component;return null}onMouseDown(a){var b=this.getGesture(a);b&&b.handleWsStart(a,this)}startDrag(a,b){Sg(this,a,b)}moveDrag(a){return Tg(this,a)}isDragging(){return ri.mover.isMoving()||this.currentGesture_!==null&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&&
1535
- !!this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){var a=!!this.scrollbar;return this.isMovable()&&(!a||a&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){var a=!!this.scrollbar;return this.isMovable()&&(!a||a&&this.scrollbar.canScrollVertically())}onMouseWheel(a){if(Eo.inProgress())a.preventDefault(),
1536
+ !!this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){var a=!!this.scrollbar;return this.isMovable()&&(!a||a&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){var a=!!this.scrollbar;return this.isMovable()&&(!a||a&&this.scrollbar.canScrollVertically())}onMouseWheel(a){if(Fo.inProgress())a.preventDefault(),
1536
1537
  a.stopPropagation();else{var b=this.options.zoomOptions&&this.options.zoomOptions.wheel,c=this.options.moveOptions&&this.options.moveOptions.wheel;if(b||c){var d=pa(a);if(ma)var e=a.metaKey;b&&(a.ctrlKey||e||!c)?(d=-d.y/50,b=oa(a,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(b.x,b.y,d)):(b=this.scrollX-d.x,c=this.scrollY-d.y,a.shiftKey&&!d.x&&(b=this.scrollX-d.y,c=this.scrollY),this.scroll(b,c));a.preventDefault()}}}getBlocksBoundingBox(){var a=this.getTopBoundedElements();if(!a.length)return new cc(0,
1537
1538
  0,0,0);var b=a[0].getBoundingRectangle();for(let d=1;d<a.length;d++){var c=a[d];if(c.isInsertionMarker&&c.isInsertionMarker())continue;c=c.getBoundingRectangle();c.top<b.top&&(b.top=c.top);c.bottom>b.bottom&&(b.bottom=c.bottom);c.left<b.left&&(b.left=c.left);c.right>b.right&&(b.right=c.right)}return b}cleanUp(){function a(g){for(let h of e)if(g.intersects(h))return h;return null}this.setResizesEnabled(!1);var b=$.gd;b||$.B(!0);var c=this.getTopBlocks(!0),d=c.filter(g=>g.isMovable()),e=c.filter(g=>
1538
1539
  !g.isMovable()).map(g=>g.getBoundingRectangle()),f=0;c=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(let g of d){d=g.getBoundingRectangle();g.moveBy(-d.left,f-d.top,["cleanup"]);g.snapToGrid();d=g.getBoundingRectangle();for(f=a(d);f!=null;)f=f.top+f.getHeight()+c,g.moveBy(0,f-d.top,["cleanup"]),g.snapToGrid(),d=g.getBoundingRectangle(),f=a(d);f=g.getRelativeToSurfaceXY().y+g.getHeightWidth().height+c}$.B(b);this.setResizesEnabled(!0)}showContextMenu(a){if(!this.isReadOnly()&&!this.isFlyout){var b=
1539
- Kj.registry.getContextMenuOptions({workspace:this,focusedNode:this},a);this.configureContextMenu&&this.configureContextMenu(b,a);if(a instanceof PointerEvent)var c=new D(a.clientX,a.clientY);else c=this.RTL?this.getWidth()-5:5,c=pc(this,new D(c,5));Hg(a,b,this.RTL,this,c)}}updateToolbox(a){if(a=Cc(a)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Fc(a)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=
1540
+ Lj.registry.getContextMenuOptions({workspace:this,focusedNode:this},a);this.configureContextMenu&&this.configureContextMenu(b,a);if(a instanceof PointerEvent)var c=new D(a.clientX,a.clientY);else c=this.RTL?this.getWidth()-5:5,c=pc(this,new D(c,5));Hg(a,b,this.RTL,this,c)}}updateToolbox(a){if(a=Cc(a)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Fc(a)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=
1540
1541
  a;this.toolbox.render(a)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=a;this.flyout.show(a)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.");}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(mb(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(a,b,c){c=Math.pow(this.options.zoomOptions.scaleSpeed,c);var d=this.scale*c;if(this.scale!==d){d>this.options.zoomOptions.maxScale?
1541
1542
  c=this.options.zoomOptions.maxScale/this.scale:d<this.options.zoomOptions.minScale&&(c=this.options.zoomOptions.minScale/this.scale);var e=this.getCanvas().getCTM(),f=this.getParentSvg().createSVGPoint();f.x=a;f.y=b;f=f.matrixTransform(e.inverse());a=f.x;b=f.y;e=e.translate(a*(1-c),b*(1-c)).scale(c);this.scrollX=e.e;this.scrollY=e.f;this.setScale(d)}}zoomCenter(a){var b=this.getMetrics();if(this.flyout){var c=b.svgWidth?b.svgWidth/2:0;b=b.svgHeight?b.svgHeight/2:0}else c=b.viewWidth/2+b.absoluteLeft,
1542
1543
  b=b.viewHeight/2+b.absoluteTop;this.zoom(c,b,a)}zoomToFit(){if(this.isMovable()){var a=this.getMetrics(),b=a.viewWidth;a=a.viewHeight;var c=this.getBlocksBoundingBox(),d=c.right-c.left+40;c=c.bottom-c.top+40;if(d){this.flyout&&(this.horizontalLayout?(a+=this.flyout.getHeight(),c+=this.flyout.getHeight()/this.scale):(b+=this.flyout.getWidth(),d+=this.flyout.getWidth()/this.scale));$.Ub++;try{this.setScale(Math.min(b/d,a/c)),this.scrollCenter()}finally{$.Ub--}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){n(this.getCanvas(),
1543
1544
  "blocklyCanvasTransitioning");n(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}endCanvasTransition(){Ma(this.getCanvas(),"blocklyCanvasTransitioning");Ma(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}scrollCenter(){if(this.isMovable()){var a=this.getMetrics(),b=(a.scrollWidth-a.viewWidth)/2,c=(a.scrollHeight-a.viewHeight)/2;b=-b-a.scrollLeft;c=-c-a.scrollTop;this.scroll(b,c)}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}centerOnBlock(a,
1544
1545
  b){if(this.isMovable()){var c=a?this.getBlockById(a):null;if(c){a=c.getRelativeToSurfaceXY();c=b?{height:c.height,width:c.width}:c.getHeightWidth();var d=this.scale;b=(a.x+(this.RTL?-1:1)*c.width/2)*d;a=(a.y+c.height/2)*d;c=this.getMetrics();this.scroll(-(b-c.viewWidth/2),-(a-c.viewHeight/2))}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}setScale(a){this.options.zoomOptions.maxScale&&a>this.options.zoomOptions.maxScale?a=this.options.zoomOptions.maxScale:
1545
1546
  this.options.zoomOptions.minScale&&a<this.options.zoomOptions.minScale&&(a=this.options.zoomOptions.minScale);this.scale=a;this.hideChaff(!1);(a=this.getFlyout(!1))&&a.isVisible()&&(a.reflow(),this.recordDragTargets());this.grid&&this.grid.update(this.scale);a=this.getMetrics();this.scrollX-=a.absoluteLeft;this.scrollY-=a.absoluteTop;a.viewLeft+=a.absoluteLeft;a.viewTop+=a.absoluteTop;this.scroll(this.scrollX,this.scrollY);this.scrollbar&&(this.flyout?this.scrollbar.resizeView(a):this.scrollbar.resizeContent(a))}getScale(){return this.scale}getAbsoluteScale(){var a=
1546
- c=>{if(c.isFlyout){let d,e=(d=c.targetWorkspace)==null?void 0:d.getFlyout();if(e instanceof Co)return e.getFlyoutScale()}return c.getScale()},b=(c,d)=>c.options.parentWorkspace&&c.options.parentWorkspace.getSvgGroup().contains(c.getSvgGroup())?b(c.options.parentWorkspace,d*a(c)):d*a(c);return b(this,1)}scroll(a,b){this.hideChaff(!0);var c=this.getMetrics();a=Math.min(a,-c.scrollLeft);b=Math.min(b,-c.scrollTop);var d=c.scrollTop+Math.max(0,c.scrollHeight-c.viewHeight);a=Math.max(a,-(c.scrollLeft+Math.max(0,
1547
+ c=>{if(c.isFlyout){let d,e=(d=c.targetWorkspace)==null?void 0:d.getFlyout();if(e instanceof Do)return e.getFlyoutScale()}return c.getScale()},b=(c,d)=>c.options.parentWorkspace&&c.options.parentWorkspace.getSvgGroup().contains(c.getSvgGroup())?b(c.options.parentWorkspace,d*a(c)):d*a(c);return b(this,1)}scroll(a,b){this.hideChaff(!0);var c=this.getMetrics();a=Math.min(a,-c.scrollLeft);b=Math.min(b,-c.scrollTop);var d=c.scrollTop+Math.max(0,c.scrollHeight-c.viewHeight);a=Math.max(a,-(c.scrollLeft+Math.max(0,
1547
1548
  c.scrollWidth-c.viewWidth)));b=Math.max(b,-d);this.scrollX=a;this.scrollY=b;this.scrollbar&&this.scrollbar.set(-(a+c.scrollLeft),-(b+c.scrollTop),!1);a+=c.absoluteLeft;b+=c.absoluteTop;this.translate(a,b)}getBlockById(a){return super.getBlockById(a)}getAllBlocks(a=!1){return super.getAllBlocks(a)}getTopBlocks(a=!1){return super.getTopBlocks(a)}addTopBlock(a){this.addTopBoundedElement(a);super.addTopBlock(a)}removeTopBlock(a){this.removeTopBoundedElement(a);super.removeTopBlock(a)}addTopComment(a){this.addTopBoundedElement(a);
1548
1549
  super.addTopComment(a)}removeTopComment(a){this.removeTopBoundedElement(a);super.removeTopComment(a)}getTopComments(a=!1){return super.getTopComments(a)}getCommentById(a){return super.getCommentById(a)}getRootWorkspace(){return super.getRootWorkspace()}addTopBoundedElement(a){this.topBoundedElements.push(a)}removeTopBoundedElement(a){qa(this.topBoundedElements,a)}getTopBoundedElements(a=!1){var b=[].concat(this.topBoundedElements);a&&b.sort(this.sortByOrigin.bind(this));return b}setResizesEnabled(a){var b=
1549
1550
  !this.resizesEnabled&&a;this.resizesEnabled=a;b&&this.resizeContents()}clear(){this.setResizesEnabled(!1);super.clear();this.topBoundedElements=[];this.setResizesEnabled(!0)}registerButtonCallback(a,b){if(typeof b!=="function")throw TypeError("Button callbacks must be functions.");this.flyoutButtonCallbacks.set(a,b)}getButtonCallback(a){var b;return(b=this.flyoutButtonCallbacks.get(a))!=null?b:null}removeButtonCallback(a){this.flyoutButtonCallbacks.delete(a)}registerToolboxCategoryCallback(a,b){if(typeof b!==
1550
1551
  "function")throw TypeError("Toolbox category callbacks must be functions.");this.toolboxCategoryCallbacks.set(a,b)}getToolboxCategoryCallback(a){return this.toolboxCategoryCallbacks.get(a)||null}removeToolboxCategoryCallback(a){this.toolboxCategoryCallbacks.delete(a)}getGesture(a){if(ri.mover.isMoving())return a==null||a.preventDefault(),a==null||a.stopPropagation(),null;var b=(a==null?void 0:a.type)==="pointerdown",c;b&&((c=this.currentGesture_)==null?0:c.hasStarted())&&(console.warn("Tried to start the same gesture twice."),
1551
- this.currentGesture_.cancel());!this.currentGesture_&&b&&(this.currentGesture_=new Eo(a,this));return this.currentGesture_}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(a=!1){Lf();wg(this);of();this.hideComponents(a)}hideComponents(a=!1){this.getComponentManager().getComponents(Dk.Capability.AUTOHIDEABLE,!0).forEach(b=>b.autoHide(a))}static setTopLevelWorkspaceMetrics(a){var b=
1552
+ this.currentGesture_.cancel());!this.currentGesture_&&b&&(this.currentGesture_=new Fo(a,this));return this.currentGesture_}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(a=!1){Lf();wg(this);of();this.hideComponents(a)}hideComponents(a=!1){this.getComponentManager().getComponents(Ek.Capability.AUTOHIDEABLE,!0).forEach(b=>b.autoHide(a))}static setTopLevelWorkspaceMetrics(a){var b=
1552
1553
  this.getMetrics();typeof a.x==="number"&&(this.scrollX=-(b.scrollLeft+(b.scrollWidth-b.viewWidth)*a.x));typeof a.y==="number"&&(this.scrollY=-(b.scrollTop+(b.scrollHeight-b.viewHeight)*a.y));this.translate(this.scrollX+b.absoluteLeft,this.scrollY+b.absoluteTop)}addClass(a){this.injectionDiv&&n(this.injectionDiv,a)}removeClass(a){this.injectionDiv&&Ma(this.injectionDiv,a)}setIsReadOnly(a){super.setIsReadOnly(a);a?this.addClass("blocklyReadOnly"):this.removeClass("blocklyReadOnly")}scrollBoundsIntoView(a,
1553
- b=10){if(!Eo.inProgress()){var c=this.getScale(),d=this.getMetricsManager().getViewMetrics(!0);d=new cc(d.top,d.top+d.height,d.left,d.left+d.width);if(!(a.left>=d.left&&a.top>=d.top&&a.right<=d.right&&a.bottom<=d.bottom)){a=a.clone();a.top-=b;a.bottom+=b;a.left-=b;a.right+=b;var e=b=0;a.left<d.left?b=this.RTL?Math.min(d.left-a.left,d.right-a.right):d.left-a.left:a.right>d.right&&(b=this.RTL?d.right-a.right:Math.max(d.right-a.right,d.left-a.left));a.top<d.top?e=d.top-a.top:a.bottom>d.bottom&&(e=Math.max(d.bottom-
1554
+ b=10){if(!Fo.inProgress()){var c=this.getScale(),d=this.getMetricsManager().getViewMetrics(!0);d=new cc(d.top,d.top+d.height,d.left,d.left+d.width);if(!(a.left>=d.left&&a.top>=d.top&&a.right<=d.right&&a.bottom<=d.bottom)){a=a.clone();a.top-=b;a.bottom+=b;a.left-=b;a.right+=b;var e=b=0;a.left<d.left?b=this.RTL?Math.min(d.left-a.left,d.right-a.right):d.left-a.left:a.right>d.right&&(b=this.RTL?d.right-a.right:Math.max(d.right-a.right,d.left-a.left));a.top<d.top?e=d.top-a.top:a.bottom>d.bottom&&(e=Math.max(d.bottom-
1554
1555
  a.bottom,d.top-a.top));this.scroll(this.scrollX+b*c,this.scrollY+e*c)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this}onNodeFocus(){this.maybeAnnounceScreenreaderHint()}handleWorkspaceFocusTargetFocus(){this.updateAriaLabel();this.maybeAnnounceScreenreaderHint()}maybeAnnounceScreenreaderHint(){$h.everFocused||this.options.parentWorkspace||(Ja($.C.SCREENREADER_HINT.replace("%1",re(K.TOGGLE_SCREENREADER))),$h.everFocused=!0)}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(a){if(a)return a;
1555
- var b;a=(b=this.targetWorkspace)==null?void 0:b.getFlyout();if(this.isFlyout&&a){let c,d;return(d=(c=a.getContents().find(e=>{e=e.getElement();return $a(e)&&e.canBeFocused()}))==null?void 0:c.getElement())!=null?d:null}if(this.isMutator){let c;return(c=this.getTopBlocks(!0)[0])!=null?c:null}return this.workspaceFocusTarget}getWorkspaceFocusTarget(){return this.workspaceFocusTarget}getNestedTrees(){var a=this.getAllBlocks().map(c=>c.getIcons()).flat().filter(c=>c instanceof $.sh&&c.bubbleIsVisible()).map(c=>
1556
- {var d;return(d=c.getBubble())==null?void 0:d.getWorkspace()}).filter(c=>!!c),b=this.getFlyout(!0);b&&a.push(b.getWorkspace());return a}searchForWorkspaceComment(a){for(let b of this.getTopComments())if(b instanceof dh&&b.canBeFocused()&&b.getFocusableElement().id===a)return b}lookUpFocusableNode(a){if(this.workspaceFocusTargetElement&&this.workspaceFocusTargetElement.id===a)return this.workspaceFocusTarget;var b,c=(b=this.targetWorkspace)==null?void 0:b.getFlyout();if(this.isFlyout&&c)for(var d of c.getContents())if(b=
1557
- d.getElement(),$a(b)&&b.canBeFocused()&&b.getFocusableElement().id===a)return b;d=a.indexOf("_field_");b=a.indexOf("_connection_");if(d!==-1){var e=a.substring(0,d);if(e=this.getBlockById(e))for(var f of e.getFields())if(f.canBeFocused()&&f.getFocusableElement().id===a)return f;return null}if(b!==-1){e=a.substring(0,b);if(e=this.getBlockById(e))for(let m of e.getConnections_(!0))if(m.id===a)return m;return null}f=Math.max(a.indexOf("_comment_textarea_"),a.indexOf("_collapse_bar_button"),a.indexOf("_delete_bar_button"));
1558
- if(f!==-1&&(f=a.substring(0,f),f=this.searchForWorkspaceComment(f))){if(a.indexOf("_comment_textarea_")>-1)return f.getEditorFocusableNode();var g;return(g=f.view.getCommentBarButtons().find(m=>m.getFocusableElement().id.includes(a)))!=null?g:null}if((g=this.getAllBlocks(!1).find(m=>m.getFocusableElement().id===a))||(g=this.searchForWorkspaceComment(a)))return g;g=this.getAllBlocks().map(m=>m.getIcons()).flat();for(var h of g){if(h.canBeFocused()&&h.getFocusableElement().id===a)return h;if(xd(h)){if((g=
1559
- h.getBubble())&&g.canBeFocused()&&g.getFocusableElement().id===a)return g;if(g instanceof zn&&g.getEditor().getFocusableElement().id===a)return g.getEditor()}}h=this.getComponentManager().getComponents(Dk.Capability.FOCUSABLE,!1);for(e of h)if(e.getFocusableElement().getAttribute("id")===a)return e;return null}onTreeFocus(){this.updateAriaLabel()}onTreeBlur(a){if(this.isFlyout&&this.targetWorkspace&&!$.t().ephemeralFocusTaken()){var b=this.targetWorkspace.getToolbox();b&&a===b||b&&typeof b.autoHide===
1560
- "function"&&b.autoHide(!1)}}performAction(){li.show(this,{message:$.C.KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT,id:"workspaceNavigationHint"})}getNavigator(){return this.navigator}setNavigator(a){this.navigator=a}};$h.everFocused=!1;var wp=class{constructor(a,b,c,d){this.workspace=a;this.name=b;this.type=c||"";this.id=d||Nb()}getId(){return this.id}getName(){return this.name}setName(a){this.name=a;return this}getType(){return this.type}setType(a){this.type=a;return this}getWorkspace(){return this.workspace}save(){var a={name:this.getName(),id:this.getId()},b=this.getType();b&&(a.type=b);return a}static load(a,b){a=new this(b,a.name,a.type,a.id);b.getVariableMap().addVariable(a);w(new (u(v.VAR_CREATE))(a))}};
1561
- A(y.VARIABLE_MODEL,"default",wp);var xp=class{constructor(a,b=!1){this.workspace=a;this.potentialMap=b;this.variableMap=new Map}clear(){for(let a of this.variableMap.values())for(let b of a.values())this.deleteVariable(b);if(this.variableMap.size!==0)throw Error("Non-empty variable map");}renameVariable(a,b){if(a.getName()===b)return a;var c=a.getType();c=this.getVariable(b,c);var d=this.workspace.getAllBlocks(!1),e="";this.potentialMap||(e=$.gd)||$.B(!0);try{c&&c.getId()!==a.getId()?this.renameVariableWithConflict(a,b,c,d):this.renameVariableAndUses(a,
1556
+ var b;a=(b=this.targetWorkspace)==null?void 0:b.getFlyout();if(this.isFlyout&&a){let c,d;return(d=(c=a.getContents().find(e=>{e=e.getElement();return $a(e)&&e.canBeFocused()}))==null?void 0:c.getElement())!=null?d:null}if(this.isMutator){let c;return(c=this.getTopBlocks(!0)[0])!=null?c:null}return this.workspaceFocusTarget}getWorkspaceFocusTarget(){return this.workspaceFocusTarget}getNestedTrees(){var a=gb().filter(c=>c.isMutator&&c.options.parentWorkspace===this),b=this.getFlyout(!0);b&&a.push(b.getWorkspace());
1557
+ return a}searchForWorkspaceComment(a){for(let b of this.getTopComments())if(b instanceof dh&&b.canBeFocused()&&b.getFocusableElement().id===a)return b}lookUpFocusableNode(a){if(this.workspaceFocusTargetElement&&this.workspaceFocusTargetElement.id===a)return this.workspaceFocusTarget;var b,c=(b=this.targetWorkspace)==null?void 0:b.getFlyout();if(this.isFlyout&&c)for(var d of c.getContents())if(b=d.getElement(),$a(b)&&b.canBeFocused()&&b.getFocusableElement().id===a)return b;d=a.indexOf("_field_");
1558
+ b=a.indexOf("_connection_");if(d!==-1){var e=a.substring(0,d);if(e=this.getBlockById(e))for(var f of e.getFields())if(f.canBeFocused()&&f.getFocusableElement().id===a)return f;return null}if(b!==-1){e=a.substring(0,b);if(e=this.getBlockById(e))for(let m of e.getConnections_(!0))if(m.id===a)return m;return null}f=Math.max(a.indexOf("_comment_textarea_"),a.indexOf("_collapse_bar_button"),a.indexOf("_delete_bar_button"));if(f!==-1&&(f=a.substring(0,f),f=this.searchForWorkspaceComment(f))){if(a.indexOf("_comment_textarea_")>
1559
+ -1)return f.getEditorFocusableNode();var g;return(g=f.view.getCommentBarButtons().find(m=>m.getFocusableElement().id.includes(a)))!=null?g:null}if((g=this.getAllBlocks(!1).find(m=>m.getFocusableElement().id===a))||(g=this.searchForWorkspaceComment(a)))return g;g=this.getAllBlocks().map(m=>m.getIcons()).flat();for(var h of g){if(h.canBeFocused()&&h.getFocusableElement().id===a)return h;if(xd(h)){if((g=h.getBubble())&&g.canBeFocused()&&g.getFocusableElement().id===a)return g;if(g instanceof An&&g.getEditor().getFocusableElement().id===
1560
+ a)return g.getEditor()}}h=this.getComponentManager().getComponents(Ek.Capability.FOCUSABLE,!1);for(e of h)if(e.getFocusableElement().getAttribute("id")===a)return e;return null}onTreeFocus(){this.updateAriaLabel()}onTreeBlur(a){if(this.isFlyout&&this.targetWorkspace&&!$.t().ephemeralFocusTaken()){var b=this.targetWorkspace.getToolbox();b&&a===b||b&&typeof b.autoHide==="function"&&b.autoHide(!1)}}performAction(){li.show(this,{message:$.C.KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT,id:"workspaceNavigationHint"})}getNavigator(){return this.navigator}setNavigator(a){this.navigator=
1561
+ a}};$h.everFocused=!1;var xp=class{constructor(a,b,c,d){this.workspace=a;this.name=b;this.type=c||"";this.id=d||Nb()}getId(){return this.id}getName(){return this.name}setName(a){this.name=a;return this}getType(){return this.type}setType(a){this.type=a;return this}getWorkspace(){return this.workspace}save(){var a={name:this.getName(),id:this.getId()},b=this.getType();b&&(a.type=b);return a}static load(a,b){a=new this(b,a.name,a.type,a.id);b.getVariableMap().addVariable(a);w(new (u(v.VAR_CREATE))(a))}};
1562
+ A(y.VARIABLE_MODEL,"default",xp);var yp=class{constructor(a,b=!1){this.workspace=a;this.potentialMap=b;this.variableMap=new Map}clear(){for(let a of this.variableMap.values())for(let b of a.values())this.deleteVariable(b);if(this.variableMap.size!==0)throw Error("Non-empty variable map");}renameVariable(a,b){if(a.getName()===b)return a;var c=a.getType();c=this.getVariable(b,c);var d=this.workspace.getAllBlocks(!1),e="";this.potentialMap||(e=$.gd)||$.B(!0);try{c&&c.getId()!==a.getId()?this.renameVariableWithConflict(a,b,c,d):this.renameVariableAndUses(a,
1562
1563
  b,d)}finally{this.potentialMap||$.B(e)}return a}changeVariableType(a,b){var c=a.getType();if(c===b)return a;var d=this.variableMap.get(c);d==null||d.delete(a.getId());(d==null?void 0:d.size)===0&&this.variableMap.delete(c);a.setType(b);var e;d=(e=this.variableMap.get(b))!=null?e:new Map;d.set(a.getId(),a);this.variableMap.has(b)||this.variableMap.set(b,d);w(new (u(v.VAR_TYPE_CHANGE))(a,c,b));return a}renameVariableAndUses(a,b,c){this.potentialMap||w(new (u(v.VAR_RENAME))(a,b));a.setName(b);for(b=
1563
1564
  0;b<c.length;b++)c[b].updateVarName(a)}renameVariableWithConflict(a,b,c,d){var e=a.getType(),f=c.getName();b!==f&&this.renameVariableAndUses(c,b,d);for(b=0;b<d.length;b++)d[b].renameVarById(a.getId(),c.getId());this.potentialMap||w(new (u(v.VAR_DELETE))(a));var g;(g=this.variableMap.get(e))==null||g.delete(a.getId())}createVariable(a,b,c){var d=this.getVariable(a,b);if(d){if(c&&d.getId()!==c)throw Error('Variable "'+a+'" is already in use and its id is "'+d.getId()+'" which conflicts with the passed in id, "'+
1564
1565
  c+'".');return d}if(c&&this.getVariableById(c))throw Error('Variable id, "'+c+'", is already in use.');d=c||Nb();b=b||"";c=Jb(y.VARIABLE_MODEL,this.workspace.options,!0);if(!c)throw Error("No variable model is registered.");d=new c(this.workspace,a,b,d);var e;a=(e=this.variableMap.get(b))!=null?e:new Map;a.set(d.getId(),d);this.variableMap.has(b)||this.variableMap.set(b,a);this.potentialMap||w(new (u(v.VAR_CREATE))(d));return d}addVariable(a){var b=a.getType();this.variableMap.has(b)||this.variableMap.set(b,
1565
1566
  new Map);var c;(c=this.variableMap.get(b))==null||c.set(a.getId(),a)}deleteVariable(a){var b=Zd(this.workspace,a.getId()),c="";this.potentialMap||(c=$.gd)||$.B(!0);try{for(let e=0;e<b.length;e++)b[e].isDeadOrDying()||b[e].dispose(!0);let d=this.variableMap.get(a.getType());d&&d.has(a.getId())&&(d.delete(a.getId()),this.potentialMap||w(new (u(v.VAR_DELETE))(a)),d.size===0&&this.variableMap.delete(a.getType()))}finally{this.potentialMap||$.B(c)}}getVariable(a,b){b=this.variableMap.get(b||"");if(!b)return null;
1566
- var c;return(c=[...b.values()].find(d=>$.kj.equals(d.getName(),a)))!=null?c:null}getVariableById(a){for(let b of this.variableMap.values())if(b.has(a)){let c;return(c=b.get(a))!=null?c:null}return null}getVariablesOfType(a){return(a=this.variableMap.get(a||""))?[...a.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){var a=[];for(let b of this.variableMap.values())a=a.concat(...b.values());return a}};A(y.VARIABLE_MAP,"default",xp);var yp=class extends fo{constructor(a){super();this.workspace=a;this.id="trashcan";this.uniqueId=Lb();this.contents=[];this.flyout=null;this.isLidOpen=!1;this.svgGroup=null;this.top=this.left=0;this.initialized=!1;this.workspace.options.maxTrashcanContents<=0||(a=this.workspace.copyOptionsForFlyout(),this.workspace.horizontalLayout?(a.toolboxPosition=this.workspace.toolboxPosition===F.TOP?F.BOTTOM:F.TOP,this.flyout=new (Jb(y.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(a)):(a.toolboxPosition=
1567
+ var c;return(c=[...b.values()].find(d=>$.kj.equals(d.getName(),a)))!=null?c:null}getVariableById(a){for(let b of this.variableMap.values())if(b.has(a)){let c;return(c=b.get(a))!=null?c:null}return null}getVariablesOfType(a){return(a=this.variableMap.get(a||""))?[...a.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){var a=[];for(let b of this.variableMap.values())a=a.concat(...b.values());return a}};A(y.VARIABLE_MAP,"default",yp);var zp=class extends go{constructor(a){super();this.workspace=a;this.id="trashcan";this.uniqueId=Lb();this.contents=[];this.flyout=null;this.isLidOpen=!1;this.svgGroup=null;this.top=this.left=0;this.initialized=!1;this.workspace.options.maxTrashcanContents<=0||(a=this.workspace.copyOptionsForFlyout(),this.workspace.horizontalLayout?(a.toolboxPosition=this.workspace.toolboxPosition===F.TOP?F.BOTTOM:F.TOP,this.flyout=new (Jb(y.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(a)):(a.toolboxPosition=
1567
1568
  this.workspace.toolboxPosition===F.RIGHT?F.LEFT:F.RIGHT,this.flyout=new (Jb(y.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(a)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=r(q.G,{"class":"blocklyTrash",tabindex:"0",id:this.uniqueId});r(q.RECT,{width:55,height:68,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},this.svgGroup);ya(this.svgGroup,Ka.BUTTON);l(this.svgGroup,p.LABEL,$.C.ARIA_LABEL_TRASH_EMPTY);l(this.svgGroup,p.DISABLED,!0);var a=
1568
- String(Math.random()).substring(2);var b=r(q.CLIPPATH,{id:"blocklyTrashBodyClipPath"+a},this.svgGroup);r(q.RECT,{width:47,height:44,y:16},b);r(q.IMAGE,{width:ll.width,x:-0,height:ll.height,y:-32,"clip-path":"url(#blocklyTrashBodyClipPath"+a+")"},this.svgGroup).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace.options.pathToMedia+ll.url);b=r(q.CLIPPATH,{id:"blocklyTrashLidClipPath"+a},this.svgGroup);r(q.RECT,{width:47,height:16},b);b=r(q.G,{"class":"blocklyTrashLid"},this.svgGroup);
1569
- b=r(q.SVG,{viewBox:"0 32 47 16",width:47,height:16},b);r(q.IMAGE,{width:ll.width,height:ll.height,href:this.workspace.options.pathToMedia+ll.url},b);ja(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable);ja(this.svgGroup,"pointerup",this,this.click);return this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){let a=this.flyout.createDom(q.SVG);n(a,"blocklyTrashcanFlyout");Pa(a,this.workspace.getParentSvg());this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,
1570
- weight:Dk.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Dk.Capability.AUTOHIDEABLE,Dk.Capability.DELETE_AREA,Dk.Capability.DRAG_TARGET,Dk.Capability.POSITIONABLE,Dk.Capability.FOCUSABLE]});this.initialized=!0;this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan");this.svgGroup&&Oa(this.svgGroup)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var a=this.contents.map(function(c){return JSON.parse(c)}),
1569
+ String(Math.random()).substring(2);var b=r(q.CLIPPATH,{id:"blocklyTrashBodyClipPath"+a},this.svgGroup);r(q.RECT,{width:47,height:44,y:16},b);r(q.IMAGE,{width:ml.width,x:-0,height:ml.height,y:-32,"clip-path":"url(#blocklyTrashBodyClipPath"+a+")"},this.svgGroup).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace.options.pathToMedia+ml.url);b=r(q.CLIPPATH,{id:"blocklyTrashLidClipPath"+a},this.svgGroup);r(q.RECT,{width:47,height:16},b);b=r(q.G,{"class":"blocklyTrashLid"},this.svgGroup);
1570
+ b=r(q.SVG,{viewBox:"0 32 47 16",width:47,height:16},b);r(q.IMAGE,{width:ml.width,height:ml.height,href:this.workspace.options.pathToMedia+ml.url},b);ja(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable);ja(this.svgGroup,"pointerup",this,this.click);return this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){let a=this.flyout.createDom(q.SVG);n(a,"blocklyTrashcanFlyout");Pa(a,this.workspace.getParentSvg());this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,
1571
+ weight:Ek.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[Ek.Capability.AUTOHIDEABLE,Ek.Capability.DELETE_AREA,Ek.Capability.DRAG_TARGET,Ek.Capability.POSITIONABLE,Ek.Capability.FOCUSABLE]});this.initialized=!0;this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan");this.svgGroup&&Oa(this.svgGroup)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var a=this.contents.map(function(c){return JSON.parse(c)}),
1571
1572
  b=this.workspace.getParentSvg().style;b.cursor="wait";setTimeout(()=>{var c;(c=this.flyout)==null||c.show(a);b.cursor="";var d;(d=this.workspace.scrollbar)==null||d.setVisible(!1);if(Nd.getIsActive()){let e,f;(c=(f=(e=this.flyout)==null?void 0:e.getWorkspace())==null?void 0:f.getNavigator().getFirstNode())&&$.t().focusNode(c)}},10);this.fireUiEvent(!0)}}closeFlyout(){if(this.contentsIsOpen()){var a;(a=this.flyout)==null||a.hide();var b;(b=this.workspace.scrollbar)==null||b.setVisible(!0);this.fireUiEvent(!1);
1572
1573
  this.workspace.recordDragTargets()}}autoHide(a){!a&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&this.svgGroup&&(this.contents.length=0,this.svgGroup.classList.remove("blocklyTrashFull"),l(this.svgGroup,p.LABEL,$.C.ARIA_LABEL_TRASH_EMPTY),l(this.svgGroup,p.DISABLED,!0),this.closeFlyout())}position(a,b){if(this.initialized){var c=Lc(this.workspace,a);a=Kc(c,new hc(47,60),20,20,a,this.workspace);b=Nc(a,20,c.vertical===Jc.TOP?Mc.DOWN:Mc.UP,b);this.top=b.top;this.left=b.left;var d;
1573
1574
  (d=this.svgGroup)==null||d.setAttribute("transform","translate("+this.left+","+this.top+")");var e;(e=this.flyout)==null||e.position()}}getBoundingRectangle(){return new cc(this.top,this.top+44+16,this.left,this.left+47)}getClientRect(){if(!this.svgGroup)return null;var a=this.svgGroup.getBoundingClientRect(),b=a.top+32-10;a=a.left+0-10;return new cc(b,b+16+44+20,a,a+47+20)}onDragOver(){ri.mover.isMoving()||this.setLidOpen(this.wouldDelete_)}onDragExit(){ri.mover.isMoving()||this.setLidOpen(!1)}onDrop(){ri.mover.isMoving()||
1574
1575
  setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(a){if(this.isLidOpen!==a){this.isLidOpen=a;var b;(b=this.svgGroup)==null||b.classList.toggle("blocklyTrashOpen",a)}}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(a){a=new (u(v.TRASHCAN_OPEN))(a,this.workspace.id);w(a)}blockMouseDownWhenOpenable(a){!this.contentsIsOpen()&&this.hasContents()&&a.stopPropagation()}onDelete(a){if(!(this.workspace.options.maxTrashcanContents<=
1575
1576
  0||a.type!==v.BLOCK_DELETE||a.wasShadow)&&this.svgGroup){if(!a.oldJson)throw Error("Encountered a delete event without proper oldJson");a=JSON.stringify(this.cleanBlockJson(a.oldJson));if(!this.contents.includes(a)){for(this.contents.unshift(a);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.svgGroup.classList.add("blocklyTrashFull");l(this.svgGroup,p.LABEL,$.C.OPEN_TRASH);za(this.svgGroup,p.DISABLED)}}}cleanBlockJson(a){function b(c){if(c){delete c.id;delete c.x;
1576
1577
  delete c.y;delete c.enabled;delete c.disabledReasons;if(c.icons&&c.icons.comment){var d=c.icons.comment;delete d.height;delete d.width;delete d.pinned}d=c.inputs;for(var e in d){var f=d[e];let g=f.block;f=f.shadow;g&&b(g);f&&b(f)}c.next&&(e=c.next,c=e.block,e=e.shadow,c&&b(c),e&&b(e))}}a=JSON.parse(JSON.stringify(a));b(a);return Object.assign({},{kind:"BLOCK"},a)}getFocusableElement(){if(!this.svgGroup)throw Error("Tried to focus uninitialized trashcan");return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!!this.svgGroup}performAction(){this.click()}};
1577
- ta("\n .blocklyTrash {\n opacity: 0.4;\n transition: opacity 0.08 ease-out;\n }\n\n .blocklyTrashLid {\n transition: rotate 0.08s ease-out;\n transform-origin: 46px 12px;\n rotate: 0deg;\n pointer-events: none;\n }\n\n .blocklyRTL .blocklyTrashLid {\n transform-origin: 0px 12px;\n }\n\n .blocklyTrash.blocklyTrashFull .blocklyTrashLid {\n rotate: 5deg;\n }\n\n .blocklyRTL .blocklyTrash.blocklyTrashFull .blocklyTrashLid {\n rotate: -5deg;\n }\n\n .blocklyTrash.blocklyTrashOpen,\n .blocklyTrash.blocklyTrashFull:hover,\n .blocklyTrash.blocklyTrashFull:focus {\n opacity: 0.8;\n }\n\n .blocklyTrash.blocklyTrashOpen .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:hover .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:focus .blocklyTrashLid {\n rotate: 45deg;\n }\n\n .blocklyRTL .blocklyTrash.blocklyTrashOpen .blocklyTrashLid,\n .blocklyRTL .blocklyTrash.blocklyTrashFull:hover .blocklyTrashLid,\n .blocklyRTL .blocklyTrash.blocklyTrashFull:focus .blocklyTrashLid {\n rotate: -45deg;\n }\n");var zp=class{constructor(a,b){this.procedureModelClass=a;this.parameterModelClass=b;this.priority=75}save(a){a=a.getProcedureMap().getProcedures().map(b=>Aj(b));return a.length?a:null}load(a,b){var c=b.getProcedureMap();for(let d of a)c.add(Bj(this.procedureModelClass,this.parameterModelClass,d,b))}clear(a){a.getProcedureMap().clear()}},Ap={};Ap.ProcedureSerializer=zp;Ap.loadProcedure=Bj;Ap.saveProcedure=Aj;var Bp=class{constructor(){this.priority=100}save(a){a=a.getVariableMap().getAllVariables().map(b=>b.save());return a.length?a:null}load(a,b){var c=Fb(y.VARIABLE_MODEL,"default",void 0);a.forEach(d=>{c==null||c.load(d,b)})}clear(a){a.getVariableMap().clear()}};Oc("variables",new Bp);var Cp={};Cp.VariableSerializer=Bp;var Dp={blocks:Qm,exceptions:Om,priorities:{BLOCKS:50,PROCEDURES:75,VARIABLES:100,WORKSPACE_COMMENTS:25},procedures:Ap,registry:rl,variables:Cp,workspaceComments:tl,workspaces:{load:function(a,b,{recordUndo:c=!1}={}){var d=Ib(y.SERIALIZER,!0);if(d){d=Object.entries(d).sort((f,g)=>g[1].priority-f[1].priority);var e=$.Qc;$.Qc=c;(c=$.gd)||$.B(!0);Ta();b instanceof $h&&b.setResizesEnabled(!1);for(let [,f]of d.reverse()){let g;(g=f)==null||g.clear(b)}for(let [f,g]of d.reverse())if(a[f]){let h;(h=g)==null||
1578
- h.load(a[f],b)}b instanceof $h&&b.setResizesEnabled(!0);Ua();w(new (u(v.FINISHED_LOADING))(b));$.B(c);$.Qc=e}},save:function(a){var b=Object.create(null),c=Ib(y.SERIALIZER,!0);for(let d in c){let e,f=(e=c[d])==null?void 0:e.save(a);f&&(b[d]=f)}return b}}};"Blockly"in globalThis||(globalThis.Blockly={Msg:$k});var Ep=class{load(a,b){a=new Di(b.getWorkspace(),b.targetWorkspace,a,!0);a.show();return new go(a,"label")}gapForItem(a,b){return b}disposeItem(a){a=a.getElement();a instanceof Di&&a.dispose()}getType(){return"label"}};A(y.FLYOUT_INFLATER,"label",Ep);var Fp=class{constructor(){this.size=new hc(0,0)}getHeightWidth(){return this.size}show(a,b){this.parentConnection=a;this.parentConnection.attachInsertionMarker(this);var c=b.getSourceBlock(),d=new Map;for(var e of c.getConnections_(!1))d.set(e,e.targetConnection),e.targetConnection=null;b.targetConnection=a;c.workspace.getRenderer().render(c);this.partiallyTighten(c,b);this.marker=this.makeMarker(c);e=c.getBoundingRectangleWithoutChildren();this.size=new hc(e.getWidth(),e.getHeight());e=a.getSourceBlock().getRelativeToSurfaceXY();
1578
+ ta("\n .blocklyTrash {\n opacity: 0.4;\n transition: opacity 0.08 ease-out;\n }\n\n .blocklyTrashLid {\n transition: rotate 0.08s ease-out;\n transform-origin: 46px 12px;\n rotate: 0deg;\n pointer-events: none;\n }\n\n .blocklyRTL .blocklyTrashLid {\n transform-origin: 0px 12px;\n }\n\n .blocklyTrash.blocklyTrashFull .blocklyTrashLid {\n rotate: 5deg;\n }\n\n .blocklyRTL .blocklyTrash.blocklyTrashFull .blocklyTrashLid {\n rotate: -5deg;\n }\n\n .blocklyTrash.blocklyTrashOpen,\n .blocklyTrash.blocklyTrashFull:hover,\n .blocklyTrash.blocklyTrashFull:focus {\n opacity: 0.8;\n }\n\n .blocklyTrash.blocklyTrashOpen .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:hover .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:focus .blocklyTrashLid {\n rotate: 45deg;\n }\n\n .blocklyRTL .blocklyTrash.blocklyTrashOpen .blocklyTrashLid,\n .blocklyRTL .blocklyTrash.blocklyTrashFull:hover .blocklyTrashLid,\n .blocklyRTL .blocklyTrash.blocklyTrashFull:focus .blocklyTrashLid {\n rotate: -45deg;\n }\n");var Ap=class{constructor(a,b){this.procedureModelClass=a;this.parameterModelClass=b;this.priority=75}save(a){a=a.getProcedureMap().getProcedures().map(b=>Aj(b));return a.length?a:null}load(a,b){var c=b.getProcedureMap();for(let d of a)c.add(Bj(this.procedureModelClass,this.parameterModelClass,d,b))}clear(a){a.getProcedureMap().clear()}},Bp={};Bp.ProcedureSerializer=Ap;Bp.loadProcedure=Bj;Bp.saveProcedure=Aj;var Cp=class{constructor(){this.priority=100}save(a){a=a.getVariableMap().getAllVariables().map(b=>b.save());return a.length?a:null}load(a,b){var c=Fb(y.VARIABLE_MODEL,"default",void 0);a.forEach(d=>{c==null||c.load(d,b)})}clear(a){a.getVariableMap().clear()}};Oc("variables",new Cp);var Dp={};Dp.VariableSerializer=Cp;var Ep={blocks:Rm,exceptions:Pm,priorities:{BLOCKS:50,PROCEDURES:75,VARIABLES:100,WORKSPACE_COMMENTS:25},procedures:Bp,registry:sl,variables:Dp,workspaceComments:ul,workspaces:{load:function(a,b,{recordUndo:c=!1}={}){var d=Ib(y.SERIALIZER,!0);if(d){d=Object.entries(d).sort((f,g)=>g[1].priority-f[1].priority);var e=$.Qc;$.Qc=c;(c=$.gd)||$.B(!0);Ta();b instanceof $h&&b.setResizesEnabled(!1);for(let [,f]of d.reverse()){let g;(g=f)==null||g.clear(b)}for(let [f,g]of d.reverse())if(a[f]){let h;(h=g)==null||
1579
+ h.load(a[f],b)}b instanceof $h&&b.setResizesEnabled(!0);Ua();w(new (u(v.FINISHED_LOADING))(b));$.B(c);$.Qc=e}},save:function(a){var b=Object.create(null),c=Ib(y.SERIALIZER,!0);for(let d in c){let e,f=(e=c[d])==null?void 0:e.save(a);f&&(b[d]=f)}return b}}};"Blockly"in globalThis||(globalThis.Blockly={Msg:al});var Fp=class{load(a,b){a=new Di(b.getWorkspace(),b.targetWorkspace,a,!0);a.show();return new ho(a,"label")}gapForItem(a,b){return b}disposeItem(a){a=a.getElement();a instanceof Di&&a.dispose()}getType(){return"label"}};A(y.FLYOUT_INFLATER,"label",Fp);var Gp=class{constructor(){this.size=new hc(0,0)}getHeightWidth(){return this.size}show(a,b){this.parentConnection=a;this.parentConnection.attachInsertionMarker(this);var c=b.getSourceBlock(),d=new Map;for(var e of c.getConnections_(!1))d.set(e,e.targetConnection),e.targetConnection=null;b.targetConnection=a;c.workspace.getRenderer().render(c);this.partiallyTighten(c,b);this.marker=this.makeMarker(c);e=c.getBoundingRectangleWithoutChildren();this.size=new hc(e.getWidth(),e.getHeight());e=a.getSourceBlock().getRelativeToSurfaceXY();
1579
1580
  var f=D.difference(a.getOffsetInBlock(),b.getOffsetInBlock());for(let [g,h]of d.entries())g.targetConnection=h;c.workspace.getRenderer().render(c);this.partiallyTighten(c,b);this.marker.setAttribute("transform",`${`translate(${e.x+f.x}, ${e.y+f.y})`} ${c.workspace.RTL?"scale(-1, 1)":""}`);a.getSourceBlock().queueRender();dd()}hide(){if(this.parentConnection){var a;(a=this.marker)==null||a.remove();this.marker=void 0;this.parentConnection.detachInsertionMarker();var b;(b=this.parentConnection)==null||
1580
1581
  b.getSourceBlock().queueRender();dd();this.parentConnection=void 0}}makeMarker(a){var b=r(q.G,{transform:`translate(${a.relativeCoords.x}, ${a.relativeCoords.y})`,"class":"blocklyInsertionMarker"}),c;r(q.PATH,{d:(c=a.pathObject.svgPath.getAttribute("d"))!=null?c:"","class":"blocklyPath"},b);a.workspace.getCanvas().appendChild(b);return b}partiallyTighten(a,b){for(let c of a.inputList){if(c===b.getParentInput())continue;let d=c.connection;d&&d.tightenEfficiently()}a.nextConnection&&a.nextConnection!==
1581
- b&&a.nextConnection.tightenEfficiently()}};var Gp=class extends lp{constructor(){super();this.FIELD_TEXT_BASELINE_CENTER=!1;this.DARK_PATH_OFFSET=1;this.MAX_BOTTOM_WIDTH=30;this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(a){return super.getCSS_(a).concat([`${a} .blocklyInsertionMarker>.blocklyPathLight,`,`${a} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}};var Hp=class{constructor(a){this.inlineSteps_=this.steps_="";this.info_=a;this.RTL_=this.info_.RTL;a=a.getRenderer();this.constants_=a.getConstants();this.highlightConstants_=a.getHighlightConstants();this.highlightOffset=this.highlightConstants_.OFFSET;this.outsideCornerPaths_=this.highlightConstants_.OUTSIDE_CORNER;this.insideCornerPaths_=this.highlightConstants_.INSIDE_CORNER;this.puzzleTabPaths_=this.highlightConstants_.PUZZLE_TAB;this.notchPaths_=this.highlightConstants_.NOTCH;this.startPaths_=
1582
+ b&&a.nextConnection.tightenEfficiently()}};var Hp=class extends mp{constructor(){super();this.FIELD_TEXT_BASELINE_CENTER=!1;this.DARK_PATH_OFFSET=1;this.MAX_BOTTOM_WIDTH=30;this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(a){return super.getCSS_(a).concat([`${a} .blocklyInsertionMarker>.blocklyPathLight,`,`${a} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}};var Ip=class{constructor(a){this.inlineSteps_=this.steps_="";this.info_=a;this.RTL_=this.info_.RTL;a=a.getRenderer();this.constants_=a.getConstants();this.highlightConstants_=a.getHighlightConstants();this.highlightOffset=this.highlightConstants_.OFFSET;this.outsideCornerPaths_=this.highlightConstants_.OUTSIDE_CORNER;this.insideCornerPaths_=this.highlightConstants_.INSIDE_CORNER;this.puzzleTabPaths_=this.highlightConstants_.PUZZLE_TAB;this.notchPaths_=this.highlightConstants_.NOTCH;this.startPaths_=
1582
1583
  this.highlightConstants_.START_HAT;this.jaggedTeethPaths_=this.highlightConstants_.JAGGED_TEETH}getPath(){return this.steps_+"\n"+this.inlineSteps_}drawTopCorner(a){this.steps_+=Dh(a.xPos,this.info_.startY);for(let b=0,c;c=a.elements[b];b++)Q.isLeftSquareCorner(c)?this.steps_+=this.highlightConstants_.START_POINT:Q.isLeftRoundedCorner(c)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):Q.isPreviousConnection(c)?this.steps_+=this.notchPaths_.pathLeft:Q.isHat(c)?this.steps_+=this.startPaths_.path(this.RTL_):
1583
1584
  Q.isSpacer(c)&&c.width!==0&&(this.steps_+=I("H",c.xPos+c.width-this.highlightOffset));this.steps_+=I("H",a.xPos+a.width-this.highlightOffset)}drawJaggedEdge_(a){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+I("v",a.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(a){var b=a.getLastInput();if(this.RTL_){let c=a.height-b.connectionHeight;this.steps_+=Ch(b.xPos+b.width-this.highlightOffset,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+I("v",c)}else this.steps_+=
1584
1585
  Ch(b.xPos+b.width,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(a){var b=a.getLastInput();if(b)if(this.RTL_){let c=a.height-2*this.insideCornerPaths_.height;this.steps_+=Ch(b.xPos,a.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+I("v",c)+this.insideCornerPaths_.pathBottom(this.RTL_)+Eh(a.width-b.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=Ch(b.xPos,a.yPos+a.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Eh(a.width-b.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(a){var b=
1585
- a.xPos+a.width-this.highlightOffset;a instanceof gp&&a.followsStatement&&(this.steps_+=I("H",b));this.RTL_&&(this.steps_+=I("H",b),a.height>this.highlightOffset&&(this.steps_+=I("V",a.yPos+a.height-this.highlightOffset)))}drawBottomRow(a){if(this.RTL_)this.steps_+=I("V",a.baseline-this.highlightOffset);else{let b=this.info_.bottomRow.elements[0];Q.isLeftSquareCorner(b)?this.steps_+=Ch(a.xPos+this.highlightOffset,a.baseline-this.highlightOffset):Q.isLeftRoundedCorner(b)&&(this.steps_+=Ch(a.xPos,a.baseline),
1586
+ a.xPos+a.width-this.highlightOffset;a instanceof hp&&a.followsStatement&&(this.steps_+=I("H",b));this.RTL_&&(this.steps_+=I("H",b),a.height>this.highlightOffset&&(this.steps_+=I("V",a.yPos+a.height-this.highlightOffset)))}drawBottomRow(a){if(this.RTL_)this.steps_+=I("V",a.baseline-this.highlightOffset);else{let b=this.info_.bottomRow.elements[0];Q.isLeftSquareCorner(b)?this.steps_+=Ch(a.xPos+this.highlightOffset,a.baseline-this.highlightOffset):Q.isLeftRoundedCorner(b)&&(this.steps_+=Ch(a.xPos,a.baseline),
1586
1587
  this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var a=this.info_.outputConnection;a&&(a=a.connectionOffsetY+a.height,this.RTL_?this.steps_+=Ch(this.info_.startX,a):(this.steps_+=Ch(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=I("V",a)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_));this.RTL_||(a=this.info_.topRow,Q.isLeftRoundedCorner(a.elements[0])?this.steps_+=I("V",this.outsideCornerPaths_.height):this.steps_+=I("V",
1587
- a.capline+this.highlightOffset))}drawInlineInput(a){var b=this.highlightOffset,c=a.xPos+a.connectionWidth,d=a.centerline-a.height/2,e=a.width-a.connectionWidth,f=d+b;this.RTL_?(d=a.connectionOffsetY-b,a=a.height-(a.connectionOffsetY+a.connectionHeight)+b,this.inlineSteps_+=Ch(c-b,f)+I("v",d)+this.puzzleTabPaths_.pathDown(this.RTL_)+I("v",a)+I("h",e)):this.inlineSteps_+=Ch(a.xPos+a.width+b,f)+I("v",a.height)+I("h",-e)+Ch(c,d+a.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}};var Ip=class extends mp{constructor(a,b){super(a,b);this.highlighter_=new Hp(b)}draw(){this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();var a=this.block_.pathObject;a.setPath(this.outlinePath_+"\n"+this.inlinePath_);a.setHighlightPath(this.highlighter_.getPath());this.info_.RTL&&a.flipRTL();this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow);this.highlighter_.drawRightSideRow(this.info_.topRow);super.drawTop_()}drawJaggedEdge_(a){this.highlighter_.drawJaggedEdge_(a);
1588
+ a.capline+this.highlightOffset))}drawInlineInput(a){var b=this.highlightOffset,c=a.xPos+a.connectionWidth,d=a.centerline-a.height/2,e=a.width-a.connectionWidth,f=d+b;this.RTL_?(d=a.connectionOffsetY-b,a=a.height-(a.connectionOffsetY+a.connectionHeight)+b,this.inlineSteps_+=Ch(c-b,f)+I("v",d)+this.puzzleTabPaths_.pathDown(this.RTL_)+I("v",a)+I("h",e)):this.inlineSteps_+=Ch(a.xPos+a.width+b,f)+I("v",a.height)+I("h",-e)+Ch(c,d+a.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}};var Jp=class extends np{constructor(a,b){super(a,b);this.highlighter_=new Ip(b)}draw(){this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();var a=this.block_.pathObject;a.setPath(this.outlinePath_+"\n"+this.inlinePath_);a.setHighlightPath(this.highlighter_.getPath());this.info_.RTL&&a.flipRTL();this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow);this.highlighter_.drawRightSideRow(this.info_.topRow);super.drawTop_()}drawJaggedEdge_(a){this.highlighter_.drawJaggedEdge_(a);
1588
1589
  super.drawJaggedEdge_(a)}drawValueInput_(a){this.highlighter_.drawValueInput(a);super.drawValueInput_(a)}drawStatementInput_(a){this.highlighter_.drawStatementInput(a);super.drawStatementInput_(a)}drawRightSideRow_(a){this.highlighter_.drawRightSideRow(a);this.outlinePath_+=I("H",a.xPos+a.width)+I("V",a.yPos+a.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow);super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft();super.drawLeft_()}drawInlineInput_(a){this.highlighter_.drawInlineInput(a);
1589
1590
  super.drawInlineInput_(a)}positionInlineInputConnection_(a){var b=a.centerline-a.height/2;if(a.connectionModel){let c=a.xPos+a.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);a.connectionModel.setOffsetInBlock(c,b+a.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(a){var b=a.getLastInput();if(b==null?0:b.connectionModel){let c=a.xPos+a.statementEdge+b.notchOffset;c=this.info_.RTL?c*-1:c+this.constants_.DARK_PATH_OFFSET;b.connectionModel.setOffsetInBlock(c,
1590
- a.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(a){var b=a.getLastInput();if(b&&b.connectionModel){let c=a.xPos+a.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);b.connectionModel.setOffsetInBlock(c,a.yPos)}}positionNextConnection_(){var a=this.info_.bottomRow;if(a.connection){let b=a.connection,c=b.xPos;b.connectionModel.setOffsetInBlock((this.info_.RTL?-c:c)+this.constants_.DARK_PATH_OFFSET/2,a.baseline+this.constants_.DARK_PATH_OFFSET)}}};var Jp=class{constructor(a){this.OFFSET=.5;this.constantProvider=a;this.START_POINT=Dh(this.OFFSET,this.OFFSET)}init(){this.INSIDE_CORNER=this.makeInsideCorner();this.OUTSIDE_CORNER=this.makeOutsideCorner();this.PUZZLE_TAB=this.makePuzzleTab();this.NOTCH=this.makeNotch();this.JAGGED_TEETH=this.makeJaggedTeeth();this.START_HAT=this.makeStartHat()}makeInsideCorner(){var a=this.constantProvider.CORNER_RADIUS,b=this.OFFSET,c=(1-Math.SQRT1_2)*(a+b)-b,d=Dh(c,c)+Gh("a","0 0,0",a,H(-c-b,a-c)),e=Gh("a","0 0,0",
1591
+ a.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(a){var b=a.getLastInput();if(b&&b.connectionModel){let c=a.xPos+a.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(c*=-1);b.connectionModel.setOffsetInBlock(c,a.yPos)}}positionNextConnection_(){var a=this.info_.bottomRow;if(a.connection){let b=a.connection,c=b.xPos;b.connectionModel.setOffsetInBlock((this.info_.RTL?-c:c)+this.constants_.DARK_PATH_OFFSET/2,a.baseline+this.constants_.DARK_PATH_OFFSET)}}};var Kp=class{constructor(a){this.OFFSET=.5;this.constantProvider=a;this.START_POINT=Dh(this.OFFSET,this.OFFSET)}init(){this.INSIDE_CORNER=this.makeInsideCorner();this.OUTSIDE_CORNER=this.makeOutsideCorner();this.PUZZLE_TAB=this.makePuzzleTab();this.NOTCH=this.makeNotch();this.JAGGED_TEETH=this.makeJaggedTeeth();this.START_HAT=this.makeStartHat()}makeInsideCorner(){var a=this.constantProvider.CORNER_RADIUS,b=this.OFFSET,c=(1-Math.SQRT1_2)*(a+b)-b,d=Dh(c,c)+Gh("a","0 0,0",a,H(-c-b,a-c)),e=Gh("a","0 0,0",
1591
1592
  a+b,H(a+b,a+b)),f=Dh(c,-c)+Gh("a","0 0,0",a+b,H(a-c,c+b));return{width:a+b,height:a,pathTop(g){return g?d:""},pathBottom(g){return g?e:f}}}makeOutsideCorner(){var a=this.constantProvider.CORNER_RADIUS,b=this.OFFSET,c=(1-Math.SQRT1_2)*(a-b)+b,d=Dh(c,c)+Gh("a","0 0,1",a-b,H(a-c,-c+b)),e=Dh(b,a)+Gh("a","0 0,1",a-b,H(a,-a+b)),f=-c,g=Dh(c,f)+Gh("a","0 0,1",a-b,H(-c+b,-f-a));return{height:a,topLeft(h){return h?d:e},bottomLeft(){return g}}}makePuzzleTab(){var a=this.constantProvider.TAB_WIDTH,b=this.constantProvider.TAB_HEIGHT,
1592
1593
  c=Dh(-2,-b+2.5+.9)+Eh(a*-.45,-2.1),d=I("v",2.5)+Dh(-a*.97,2.5)+Bh("q",[H(-a*.05,10),H(a*.3,9.5)])+Dh(a*.67,-1.9)+I("v",2.5),e=I("v",-1.5)+Dh(a*-.92,-.5)+Bh("q",[H(a*-.19,-5.5),H(0,-11)])+Dh(a*.92,1),f=Dh(-5,b-.7)+Eh(a*.46,-2.1);return{width:a,height:b,pathUp(g){return g?c:e},pathDown(g){return g?d:f}}}makeNotch(){return{pathLeft:I("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Eh(5.1,2.6)+Dh(-10.2,6.8)+Eh(5.1,2.6),height:12,width:10.2}}makeStartHat(){var a=
1593
- this.constantProvider.START_HAT.height,b=Dh(25,-8.7)+Bh("c",[H(29.7,-6.2),H(57.2,-.5),H(75,8.7)]),c=Bh("c",[H(17.8,-9.2),H(45.3,-14.9),H(75,-8.7)])+Ch(100.5,a+.5);return{path(d){return d?b:c}}}};var Kp=class extends $o{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}};var Lp=class extends ip{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}};var Mp=class extends np{constructor(a,b){super(a,b);this.renderer_=a}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_();this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Mn||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(a,b){if(this.isInline&&a instanceof $.Nn)b.elements.push(new Kp(this.constants_,a)),b.hasInlineInput=!0;else if(a instanceof Mn)b.elements.push(new Lp(this.constants_,
1594
- a)),b.hasStatement=!0;else if(a instanceof $.Nn)b.elements.push(new So(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Kn||a instanceof Ln)b.minHeight=Math.max(b.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),b.hasDummyInput=!0;this.isInline||b.align!==null||(b.align=a.align)}addElemSpacing_(){var a=!1;for(let c=0,d;d=this.rows[c];c++)d.hasExternalInput&&(a=!0);for(let c=0,d;d=this.rows[c];c++){var b=d.elements;d.elements=[];d.startsWithElemSpacer()&&d.elements.push(new Zo(this.constants_,
1595
- this.getInRowSpacing_(null,b[0])));if(b.length){for(let e=0;e<b.length-1;e++){d.elements.push(b[e]);let f=this.getInRowSpacing_(b[e],b[e+1]);d.elements.push(new Zo(this.constants_,f))}d.elements.push(b[b.length-1]);d.endsWithElemSpacer()&&(b=this.getInRowSpacing_(b[b.length-1],null),a&&d.hasDummyInput&&(b+=this.constants_.TAB_WIDTH),d.elements.push(new Zo(this.constants_,b)))}}}getInRowSpacing_(a,b){if(!a)return b&&Q.isField(b)&&b.isEditable?this.constants_.MEDIUM_PADDING:b&&Q.isInlineInput(b)?this.constants_.MEDIUM_LARGE_PADDING:
1594
+ this.constantProvider.START_HAT.height,b=Dh(25,-8.7)+Bh("c",[H(29.7,-6.2),H(57.2,-.5),H(75,8.7)]),c=Bh("c",[H(17.8,-9.2),H(45.3,-14.9),H(75,-8.7)])+Ch(100.5,a+.5);return{path(d){return d?b:c}}}};var Lp=class extends ap{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}};var Mp=class extends jp{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}};var Np=class extends op{constructor(a,b){super(a,b);this.renderer_=a}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_();this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Nn||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(a,b){if(this.isInline&&a instanceof $.On)b.elements.push(new Lp(this.constants_,a)),b.hasInlineInput=!0;else if(a instanceof Nn)b.elements.push(new Mp(this.constants_,
1595
+ a)),b.hasStatement=!0;else if(a instanceof $.On)b.elements.push(new To(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Ln||a instanceof Mn)b.minHeight=Math.max(b.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),b.hasDummyInput=!0;this.isInline||b.align!==null||(b.align=a.align)}addElemSpacing_(){var a=!1;for(let c=0,d;d=this.rows[c];c++)d.hasExternalInput&&(a=!0);for(let c=0,d;d=this.rows[c];c++){var b=d.elements;d.elements=[];d.startsWithElemSpacer()&&d.elements.push(new $o(this.constants_,
1596
+ this.getInRowSpacing_(null,b[0])));if(b.length){for(let e=0;e<b.length-1;e++){d.elements.push(b[e]);let f=this.getInRowSpacing_(b[e],b[e+1]);d.elements.push(new $o(this.constants_,f))}d.elements.push(b[b.length-1]);d.endsWithElemSpacer()&&(b=this.getInRowSpacing_(b[b.length-1],null),a&&d.hasDummyInput&&(b+=this.constants_.TAB_WIDTH),d.elements.push(new $o(this.constants_,b)))}}}getInRowSpacing_(a,b){if(!a)return b&&Q.isField(b)&&b.isEditable?this.constants_.MEDIUM_PADDING:b&&Q.isInlineInput(b)?this.constants_.MEDIUM_LARGE_PADDING:
1596
1597
  b&&Q.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!Q.isInput(a)&&(!b||Q.isStatementInput(b)))return Q.isField(a)&&a.isEditable?a.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:Q.isIcon(a)?this.constants_.LARGE_PADDING*2+1:Q.isHat(a)?this.constants_.NO_PADDING:Q.isPreviousOrNextConnection(a)?this.constants_.LARGE_PADDING:Q.isLeftRoundedCorner(a)?this.constants_.MIN_BLOCK_WIDTH:Q.isJaggedEdge(a)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;
1597
1598
  if(Q.isInput(a)&&!b){if(Q.isExternalInput(a))return this.constants_.NO_PADDING;if(Q.isInlineInput(a))return this.constants_.LARGE_PADDING;if(Q.isStatementInput(a))return this.constants_.NO_PADDING}if(!Q.isInput(a)&&b&&Q.isInput(b)){if(Q.isField(a)&&a.isEditable){if(Q.isInlineInput(b)||Q.isExternalInput(b))return this.constants_.SMALL_PADDING}else{if(Q.isInlineInput(b)||Q.isExternalInput(b))return this.constants_.MEDIUM_LARGE_PADDING;if(Q.isStatementInput(b))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-
1598
1599
  1}if(Q.isIcon(a)&&b&&!Q.isInput(b))return this.constants_.LARGE_PADDING;if(Q.isInlineInput(a)&&b&&Q.isField(b))return b.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(Q.isLeftSquareCorner(a)&&b){if(Q.isHat(b))return this.constants_.NO_PADDING;if(Q.isPreviousConnection(b))return b.notchOffset;if(Q.isNextConnection(b))return b.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(Q.isLeftRoundedCorner(a)&&b){if(Q.isPreviousConnection(b))return b.notchOffset-this.constants_.CORNER_RADIUS;
@@ -1601,17 +1602,17 @@ a.hasExternalInput&&b.hasExternalInput?this.constants_.LARGE_PADDING:!a.hasState
1601
1602
  b.height/2:a.capline+b.height/2;var c=a.yPos;Q.isField(b)||Q.isIcon(b)?(c+=b.height/2,(a.hasInlineInput||a.hasStatement)&&b.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=a.height&&(c+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):c=Q.isInlineInput(b)?c+b.height/2:c+a.height/2;return c}alignRowElements_(){if(this.isInline){var a=0,b=new WeakMap,c=null;for(let d=this.rows.length-1,e;e=this.rows[d];d--)b.set(e,a),Q.isInputRow(e)&&(e.hasStatement&&this.alignStatementRow_(e),c&&c.hasStatement&&e.width<
1602
1603
  c.width?b.set(e,c.width):a=e.hasStatement?e.width:Math.max(a,e.width),c=e);a=0;for(let d=0,e;e=this.rows[d];d++)e.hasStatement?a=this.getDesiredRowWidth_(e):Q.isSpacer(e)?e.width=Math.max(a,b.get(e)):(c=e.width,a=Math.max(a,b.get(e))-c,a>0&&this.addAlignmentPadding_(e,a),a=e.width)}else super.alignRowElements_()}getDesiredRowWidth_(a){return this.isInline&&a.hasStatement?this.statementEdge+this.constants_.MAX_BOTTOM_WIDTH+this.startX:super.getDesiredRowWidth_(a)}finalize_(){var a=0,b=0;for(let d=
1603
1604
  0,e;e=this.rows[d];d++){e.yPos=b;e.xPos=this.startX;b+=e.height;a=Math.max(a,e.widthWithConnectedBlocks);var c=b-this.topRow.ascenderHeight;e===this.bottomRow&&c<this.constants_.MIN_BLOCK_HEIGHT&&(c=this.constants_.MIN_BLOCK_HEIGHT-c,this.bottomRow.height+=c,b+=c);this.recordElemPositions_(e)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(c=this.block_.nextConnection.targetBlock())&&(a=Math.max(a,c.getHeightWidth().width-this.constants_.DARK_PATH_OFFSET));
1604
- this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=a+this.startX+this.constants_.DARK_PATH_OFFSET;this.width+=this.constants_.DARK_PATH_OFFSET;this.height=b+this.constants_.DARK_PATH_OFFSET;this.startY=this.topRow.capline}};var Np=class extends op{constructor(a,b,c){super(a,b,c);this.constants=c;this.colourDark="#000000";this.svgPathDark=r(q.PATH,{"class":"blocklyPathDark",transform:"translate(1,1)"});this.svgRoot.insertBefore(this.svgPathDark,this.svgPath);this.svgPathLight=r(q.PATH,{"class":"blocklyPathLight"},this.svgRoot)}setPath(a){this.svgPath.setAttribute("d",a);this.svgPathDark.setAttribute("d",a)}setHighlightPath(a){this.svgPathLight.setAttribute("d",a)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)");
1605
+ this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=a+this.startX+this.constants_.DARK_PATH_OFFSET;this.width+=this.constants_.DARK_PATH_OFFSET;this.height=b+this.constants_.DARK_PATH_OFFSET;this.startY=this.topRow.capline}};var Op=class extends pp{constructor(a,b,c){super(a,b,c);this.constants=c;this.colourDark="#000000";this.svgPathDark=r(q.PATH,{"class":"blocklyPathDark",transform:"translate(1,1)"});this.svgRoot.insertBefore(this.svgPathDark,this.svgPath);this.svgPathLight=r(q.PATH,{"class":"blocklyPathLight"},this.svgRoot)}setPath(a){this.svgPath.setAttribute("d",a);this.svgPathDark.setAttribute("d",a)}setHighlightPath(a){this.svgPathLight.setAttribute("d",a)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)");
1605
1606
  this.svgPathLight.setAttribute("transform","scale(-1 1)");this.svgPathDark.setAttribute("transform","translate(1,1) scale(-1 1)")}applyColour(a){this.svgPathLight.style.display="";this.svgPathDark.style.display="";this.svgPathLight.setAttribute("stroke",this.style.colourTertiary);this.svgPathDark.setAttribute("fill",this.colourDark);super.applyColour(a);this.svgPath.setAttribute("stroke","none")}setStyle(a){this.style=a;this.colourDark=bg("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(a){super.updateHighlighted(a);
1606
- this.svgPathLight.style.display=a?"none":"inline"}updateShadow_(a){super.updateShadow_(a);a&&(this.svgPathLight.style.display="none",this.svgPathDark.setAttribute("fill",this.style.colourSecondary))}updateDisabled_(a){super.updateDisabled_(a);a&&this.svgPath.setAttribute("stroke","none")}};var Op=class extends pp{constructor(a){super(a);this.highlightConstants=null}init(a,b){super.init(a,b);this.highlightConstants=this.makeHighlightConstants_();this.highlightConstants.init()}refreshDom(a,b,c){super.refreshDom(a,b,c);this.getHighlightConstants().init()}makeConstants_(){return new Gp}makeRenderInfo_(a){return new Mp(this,a)}makeDrawer_(a,b){return new Ip(a,b)}makePathObject(a,b){return new Np(a,b,this.getConstants())}makeHighlightConstants_(){return new Jp(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");
1607
- return this.highlightConstants}};uj("geras",Op);var Pp=class extends np{constructor(a,b){super(a,b)}getRenderer(){return this.renderer_}addElemSpacing_(){var a=!1;for(var b=0;b<this.rows.length;b++)if(this.rows[b].hasExternalInput){a=!0;break}for(b=0;b<this.rows.length;b++){let d=this.rows[b];var c=d.elements;d.elements=[];d.startsWithElemSpacer()&&d.elements.push(new Zo(this.constants_,this.getInRowSpacing_(null,c[0])));if(c.length){for(let e=0;e<c.length-1;e++){d.elements.push(c[e]);let f=this.getInRowSpacing_(c[e],c[e+1]);d.elements.push(new Zo(this.constants_,
1608
- f))}d.elements.push(c[c.length-1]);d.endsWithElemSpacer()&&(c=this.getInRowSpacing_(c[c.length-1],null),a&&d.hasDummyInput&&(c+=this.constants_.TAB_WIDTH),d.elements.push(new Zo(this.constants_,c)))}}}getInRowSpacing_(a,b){if(!a)return b&&Q.isField(b)&&b.isEditable?this.constants_.MEDIUM_PADDING:b&&Q.isInlineInput(b)?this.constants_.MEDIUM_LARGE_PADDING:b&&Q.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!Q.isInput(a)&&!b)return Q.isField(a)&&a.isEditable?
1607
+ this.svgPathLight.style.display=a?"none":"inline"}updateShadow_(a){super.updateShadow_(a);a&&(this.svgPathLight.style.display="none",this.svgPathDark.setAttribute("fill",this.style.colourSecondary))}updateDisabled_(a){super.updateDisabled_(a);a&&this.svgPath.setAttribute("stroke","none")}};var Pp=class extends qp{constructor(a){super(a);this.highlightConstants=null}init(a,b){super.init(a,b);this.highlightConstants=this.makeHighlightConstants_();this.highlightConstants.init()}refreshDom(a,b,c){super.refreshDom(a,b,c);this.getHighlightConstants().init()}makeConstants_(){return new Hp}makeRenderInfo_(a){return new Np(this,a)}makeDrawer_(a,b){return new Jp(a,b)}makePathObject(a,b){return new Op(a,b,this.getConstants())}makeHighlightConstants_(){return new Kp(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");
1608
+ return this.highlightConstants}};uj("geras",Pp);var Qp=class extends op{constructor(a,b){super(a,b)}getRenderer(){return this.renderer_}addElemSpacing_(){var a=!1;for(var b=0;b<this.rows.length;b++)if(this.rows[b].hasExternalInput){a=!0;break}for(b=0;b<this.rows.length;b++){let d=this.rows[b];var c=d.elements;d.elements=[];d.startsWithElemSpacer()&&d.elements.push(new $o(this.constants_,this.getInRowSpacing_(null,c[0])));if(c.length){for(let e=0;e<c.length-1;e++){d.elements.push(c[e]);let f=this.getInRowSpacing_(c[e],c[e+1]);d.elements.push(new $o(this.constants_,
1609
+ f))}d.elements.push(c[c.length-1]);d.endsWithElemSpacer()&&(c=this.getInRowSpacing_(c[c.length-1],null),a&&d.hasDummyInput&&(c+=this.constants_.TAB_WIDTH),d.elements.push(new $o(this.constants_,c)))}}}getInRowSpacing_(a,b){if(!a)return b&&Q.isField(b)&&b.isEditable?this.constants_.MEDIUM_PADDING:b&&Q.isInlineInput(b)?this.constants_.MEDIUM_LARGE_PADDING:b&&Q.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!Q.isInput(a)&&!b)return Q.isField(a)&&a.isEditable?
1609
1610
  a.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:Q.isIcon(a)?this.constants_.LARGE_PADDING*2+1:Q.isHat(a)?this.constants_.NO_PADDING:Q.isPreviousOrNextConnection(a)?this.constants_.LARGE_PADDING:Q.isLeftRoundedCorner(a)?this.constants_.MIN_BLOCK_WIDTH:Q.isJaggedEdge(a)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(Q.isInput(a)&&!b){if(Q.isExternalInput(a))return this.constants_.NO_PADDING;if(Q.isInlineInput(a))return this.constants_.LARGE_PADDING;if(Q.isStatementInput(a))return this.constants_.NO_PADDING}if(!Q.isInput(a)&&
1610
1611
  b&&Q.isInput(b)){if(Q.isField(a)&&a.isEditable){if(Q.isInlineInput(b)||Q.isExternalInput(b))return this.constants_.SMALL_PADDING}else{if(Q.isInlineInput(b)||Q.isExternalInput(b))return this.constants_.MEDIUM_LARGE_PADDING;if(Q.isStatementInput(b))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(Q.isIcon(a)&&b&&!Q.isInput(b))return this.constants_.LARGE_PADDING;if(Q.isInlineInput(a)&&b&&Q.isField(b))return b.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;
1611
1612
  if(Q.isLeftSquareCorner(a)&&b){if(Q.isHat(b))return this.constants_.NO_PADDING;if(Q.isPreviousConnection(b)||Q.isNextConnection(b))return b.notchOffset}return Q.isLeftRoundedCorner(a)&&b?b.notchOffset-this.constants_.CORNER_RADIUS:Q.isField(a)&&b&&Q.isField(b)&&a.isEditable===b.isEditable?a.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:b&&Q.isJaggedEdge(b)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(a,b){return Q.isTopRow(a)&&Q.isBottomRow(b)?
1612
1613
  this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:Q.isTopRow(a)||Q.isBottomRow(b)?this.constants_.NO_PADDING:a.hasExternalInput&&b.hasExternalInput?this.constants_.LARGE_PADDING:!a.hasStatement&&b.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:a.hasStatement&&b.hasStatement||a.hasDummyInput||b.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(a,b){if(Q.isSpacer(b))return a.yPos+b.height/2;if(Q.isBottomRow(a))return a=a.yPos+a.height-a.descenderHeight,
1613
1614
  Q.isNextConnection(b)?a+b.height/2:a-b.height/2;if(Q.isTopRow(a))return Q.isHat(b)?a.capline-b.height/2:a.capline+b.height/2;var c=a.yPos;return c=Q.isField(b)&&a.hasStatement?c+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+b.height/2):c+a.height/2}finalize_(){var a=0,b=0;for(var c=0;c<this.rows.length;c++){let e=this.rows[c];e.yPos=b;e.xPos=this.startX;b+=e.height;a=Math.max(a,e.widthWithConnectedBlocks);var d=b-this.topRow.ascenderHeight;e===this.bottomRow&&d<this.constants_.MIN_BLOCK_HEIGHT&&(d=this.constants_.MIN_BLOCK_HEIGHT-
1614
- d,this.bottomRow.height+=d,b+=d);this.recordElemPositions_(e)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(c=this.block_.nextConnection.targetBlock())&&(a=Math.max(a,c.getHeightWidth().width));this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=a+this.startX;this.height=b;this.startY=this.topRow.capline}};var Qp=class extends pp{constructor(a){super(a)}makeRenderInfo_(a){return new Pp(this,a)}};uj("thrasos",Qp);var Rp=class extends lp{constructor(a){super();this.GRID_UNIT=4;this.CURSOR_COLOUR="#ffa200";this.CURSOR_RADIUS=5;this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0;this.START_HAT_HEIGHT=22;this.START_HAT_WIDTH=96;this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5};this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,
1615
+ d,this.bottomRow.height+=d,b+=d);this.recordElemPositions_(e)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(c=this.block_.nextConnection.targetBlock())&&(a=Math.max(a,c.getHeightWidth().width));this.bottomRow.baseline=b-this.bottomRow.descenderHeight;this.widthWithChildren=a+this.startX;this.height=b;this.startY=this.topRow.capline}};var Rp=class extends qp{constructor(a){super(a)}makeRenderInfo_(a){return new Qp(this,a)}};uj("thrasos",Rp);var Sp=class extends mp{constructor(a){super();this.GRID_UNIT=4;this.CURSOR_COLOUR="#ffa200";this.CURSOR_RADIUS=5;this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0;this.START_HAT_HEIGHT=22;this.START_HAT_WIDTH=96;this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5};this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,
1615
1616
  2:2*this.GRID_UNIT,3:2*this.GRID_UNIT}};this.FULL_BLOCK_FIELDS=!0;this.FIELD_TEXT_FONTWEIGHT="bold";this.FIELD_TEXT_FONTFAMILY='"Helvetica Neue", "Segoe UI", Helvetica, sans-serif';this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!0;this.SELECTED_GLOW_COLOUR="#fff200";this.SELECTED_GLOW_SIZE=.5;this.selectedGlowFilterId="";this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.selectedGlowFilter=
1616
1617
  null;a&&(this.GRID_UNIT=a);this.SMALL_PADDING=this.GRID_UNIT;this.MEDIUM_PADDING=2*this.GRID_UNIT;this.MEDIUM_LARGE_PADDING=3*this.GRID_UNIT;this.LARGE_PADDING=4*this.GRID_UNIT;this.CORNER_RADIUS=1*this.GRID_UNIT;this.NOTCH_WIDTH=9*this.GRID_UNIT;this.NOTCH_HEIGHT=2*this.GRID_UNIT;this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT=3*this.GRID_UNIT;this.MIN_BLOCK_WIDTH=2*this.GRID_UNIT;this.MIN_BLOCK_HEIGHT=12*this.GRID_UNIT;this.EMPTY_STATEMENT_INPUT_HEIGHT=6*this.GRID_UNIT;this.TOP_ROW_MIN_HEIGHT=
1617
1618
  this.CORNER_RADIUS;this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING;this.BOTTOM_ROW_MIN_HEIGHT=this.CORNER_RADIUS;this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=6*this.GRID_UNIT;this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT;this.STATEMENT_INPUT_SPACER_MIN_WIDTH=40*this.GRID_UNIT;this.STATEMENT_INPUT_PADDING_LEFT=4*this.GRID_UNIT;this.EMPTY_INLINE_INPUT_PADDING=4*this.GRID_UNIT;this.EMPTY_INLINE_INPUT_HEIGHT=8*this.GRID_UNIT;this.DUMMY_INPUT_MIN_HEIGHT=8*this.GRID_UNIT;this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=
@@ -1628,56 +1629,56 @@ a));return{width:a,height:a,pathTop:b,pathBottom:d,rightWidth:a,rightHeight:a,pa
1628
1629
  "}",`${a} .blocklyTextInputBubble textarea {`,"font-weight: normal;","}",`${a} .blocklyText {`,"fill: #fff;","}",`${a} .blocklyNonEditableField>rect:not(.blocklyDropdownRect),`,`${a} .blocklyEditableField>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${a} .blocklyNonEditableField>text,`,`${a} .blocklyEditableField>text,`,`${a} .blocklyNonEditableField>g>text,`,`${a} .blocklyEditableField>g>text {`,"fill: #575E75;","}",`${a} .blocklyFlyoutLabelText {`,"fill: #575E75;",
1629
1630
  "}",`${a} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${a} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>rect,",`${a} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${a} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${a} .blocklyDropdownText {`,"fill: #fff !important;",
1630
1631
  "}",`${a}.blocklyWidgetDiv .blocklyMenuItem,`,`${a}.blocklyDropDownDiv .blocklyMenuItem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${a}.blocklyDropDownDiv .blocklyMenuItemContent {`,"color: #fff;","}",`${a} .blocklyHighlightedConnectionPathVisible {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${a} .blocklyDisabledPattern > .blocklyOutlinePath {`,"fill: var(--blocklyDisabledPattern)","}",`${a} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;",
1631
- "}",`${a} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}"]}};var Sp=class extends mp{constructor(a,b){super(a,b)}draw(){var a=this.block_.pathObject;a.beginDrawing();this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();a.setPath(this.outlinePath_+"\n"+this.inlinePath_);this.info_.RTL&&a.flipRTL();this.recordSizeOnBlock_();this.info_.outputConnection&&(a.outputShapeType=this.info_.outputConnection.shape.type);a.endDrawing()}drawOutline_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&
1632
+ "}",`${a} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}"]}};var Tp=class extends np{constructor(a,b){super(a,b)}draw(){var a=this.block_.pathObject;a.beginDrawing();this.drawOutline_();this.drawInternals_();this.updateConnectionHighlights();a.setPath(this.outlinePath_+"\n"+this.inlinePath_);this.info_.RTL&&a.flipRTL();this.recordSizeOnBlock_();this.info_.outputConnection&&(a.outputShapeType=this.info_.outputConnection.shape.type);a.endDrawing()}drawOutline_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape&&!this.info_.hasStatementInput&&
1632
1633
  !this.info_.bottomRow.hasNextConnection?(this.drawFlatTop_(),this.drawRightDynamicConnection_(),this.drawFlatBottom_(),this.drawLeftDynamicConnection_()):super.drawOutline_()}drawLeft_(){this.info_.outputConnection&&this.info_.outputConnection.isDynamicShape?this.drawLeftDynamicConnection_():super.drawLeft_()}drawRightSideRow_(a){if(!(a.height<=0)){if(Q.isSpacer(a)){let d=a.precedesStatement;var b=a.followsStatement;if(d||b){let e=this.constants_.INSIDE_CORNERS;var c=e.rightHeight;c=a.height-(d?c:
1633
1634
  0);b=b?e.pathBottomRight:"";a=c>0?I("V",a.yPos+c):"";this.outlinePath_+=b+a+(d?e.pathTopRight:"");return}}this.outlinePath_+=I("V",a.yPos+a.height)}}drawRightDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.outlinePath_+=this.info_.outputConnection.shape.pathRightDown(this.info_.outputConnection.height)}drawLeftDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");
1634
1635
  this.positionOutputConnection_();this.outlinePath_+=this.info_.outputConnection.shape.pathUp(this.info_.outputConnection.height);this.outlinePath_+="z"}drawFlatTop_(){var a=this.info_.topRow;this.positionPreviousConnection_();this.outlinePath_+=Dh(a.xPos,this.info_.startY);this.outlinePath_+=I("h",a.width)}drawFlatBottom_(){var a=this.info_.bottomRow;this.positionNextConnection_();this.outlinePath_+=I("V",a.baseline);this.outlinePath_+=I("h",-a.width)}drawInlineInput_(a){this.positionInlineInputConnection_(a);
1635
1636
  var b=a.input.name;a.connectedBlock||this.info_.isInsertionMarker||(a=Ch(a.xPos+a.connectionWidth,a.centerline-a.height/2)+this.getInlineInputPath(a),this.block_.pathObject.setOutlinePath(b,a))}getInlineInputPath(a){var b=a.width-a.connectionWidth*2,c=a.height;return I("h",b)+a.shape.pathRightDown(c)+I("h",-b)+a.shape.pathUp(c)+"z"}drawStatementInput_(a){var b=a.getLastInput(),c=b.xPos+b.notchOffset+b.shape.width,d=this.constants_.INSIDE_CORNERS,e=b.shape.pathRight+I("h",-(b.notchOffset-d.width))+
1636
1637
  d.pathTop,f=a.height-2*d.height;b=d.pathBottom+I("h",b.notchOffset-d.width)+(b.connectedBottomNextConnection?"":b.shape.pathLeft);this.outlinePath_+=I("H",c)+e+I("v",f)+b+I("H",a.xPos+a.width);this.positionStatementInputConnection_(a)}drawConnectionHighlightPath(a){var b=a.connectionModel;if(b.type===G.NEXT_STATEMENT||b.type===G.PREVIOUS_STATEMENT||b.type===G.OUTPUT_VALUE&&!a.isDynamicShape)return super.drawConnectionHighlightPath(a);a=b.type===G.INPUT_VALUE?Ch(a.connectionWidth,-a.height/2)+this.getInlineInputPath(a):
1637
- Ch(a.width,-a.height/2)+a.shape.pathDown(a.height);var c=b.getSourceBlock(),d,e;return(e=(d=c.pathObject).addConnectionHighlight)==null?void 0:e.call(d,b,a,b.getOffsetInBlock(),c.RTL)}};var Tp=class extends rg{constructor(a,b,c,d,e,f,g){super(rg.SKIP_SETUP);this.imageElement=this.clickHandler=null;this.flipRtl=this.isDirty_=this.EDITABLE=!1;this.altText="";c=Number(hg(c));b=Number(hg(b));if(isNaN(c)||isNaN(b))throw Error("Height and width values of an image field must cast to numbers.");if(c<=0||b<=0)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new hc(b,c+Tp.Y_PADDING);this.imageHeight=c;typeof e==="function"&&(this.clickHandler=e);
1638
+ Ch(a.width,-a.height/2)+a.shape.pathDown(a.height);var c=b.getSourceBlock(),d,e;return(e=(d=c.pathObject).addConnectionHighlight)==null?void 0:e.call(d,b,a,b.getOffsetInBlock(),c.RTL)}};var Up=class extends rg{constructor(a,b,c,d,e,f,g){super(rg.SKIP_SETUP);this.imageElement=this.clickHandler=null;this.flipRtl=this.isDirty_=this.EDITABLE=!1;this.altText="";c=Number(hg(c));b=Number(hg(b));if(isNaN(c)||isNaN(b))throw Error("Height and width values of an image field must cast to numbers.");if(c<=0||b<=0)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new hc(b,c+Up.Y_PADDING);this.imageHeight=c;typeof e==="function"&&(this.clickHandler=e);
1638
1639
  a!==rg.SKIP_SETUP&&(g?this.configure_(g):typeof d==="object"&&d!==null&&!Array.isArray(d)&&("alt"in d||"flipRtl"in d)?this.configure_(d):(this.flipRtl=!!f,this.altText=typeof d==="string"?hg(d)||"":""),this.setValue(hg(a)))}configure_(a){super.configure_(a);a.flipRtl&&(this.flipRtl=a.flipRtl);a.alt&&(this.altText=hg(a.alt))}initView(){this.imageElement=r(q.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_);this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink",
1639
1640
  "xlink:href",this.value_);this.fieldGroup_&&n(this.fieldGroup_,"blocklyImageField");this.clickHandler&&(this.imageElement.style.cursor="pointer");this.recomputeAriaContext()}updateSize_(){}doClassValidation_(a){return typeof a!=="string"?null:a}doValueUpdate_(a){this.value_=a;this.imageElement&&this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.value_);this.recomputeAriaContext()}getFlipRtl(){return this.flipRtl}setAlt(a){a!==this.altText&&(this.altText=a||"",this.imageElement&&
1640
1641
  this.imageElement.setAttribute("alt",this.altText))}isClickable(){return super.isClickable()&&!!this.clickHandler}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(a){this.clickHandler=a}getText_(){return this.altText}static fromJson(a){if(!a.src||!a.width||!a.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(a.src,a.width,a.height,void 0,void 0,void 0,a)}getAriaTypeName(){return this.ariaTypeName||
1641
- $.C.ARIA_TYPE_FIELD_IMAGE}getAriaValue(){return this.altText||null}computeAriaLabel(a){return this.isClickable()?"":super.computeAriaLabel(a)}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement();if(!this.isClickable())return ya(a,Ka.NONE),za(a,p.LABEL),!1;var b=this.getAriaValue()||"";l(a,p.LABEL,b);return!0}};Tp.Y_PADDING=1;jh("field_image",Tp);Tp.prototype.DEFAULT_VALUE="";var Up=class extends rg{set size_(a){super.size_=a}get size_(){var a=super.size_;a.width<14&&(a.width=14);return a}constructor(a,b,c){super(rg.SKIP_SETUP);this.spellcheck_=!0;this.htmlInput_=null;this.isTextValid_=this.isBeingEdited_=!1;this.onInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=this.warningIcon=null;this.fullBlockClickTarget_=!1;this.workspace_=null;this.SERIALIZABLE=!0;a!==rg.SKIP_SETUP&&(c&&this.configure_(c),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a);
1642
+ $.C.ARIA_TYPE_FIELD_IMAGE}getAriaValue(){return this.altText||null}computeAriaLabel(a){return this.isClickable()?"":super.computeAriaLabel(a)}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement();if(!this.isClickable())return ya(a,Ka.NONE),za(a,p.LABEL),!1;var b=this.getAriaValue()||"";l(a,p.LABEL,b);return!0}};Up.Y_PADDING=1;jh("field_image",Up);Up.prototype.DEFAULT_VALUE="";var Vp=class extends rg{set size_(a){super.size_=a}get size_(){var a=super.size_;a.width<14&&(a.width=14);return a}constructor(a,b,c){super(rg.SKIP_SETUP);this.spellcheck_=!0;this.htmlInput_=null;this.isTextValid_=this.isBeingEdited_=!1;this.onInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=this.warningIcon=null;this.fullBlockClickTarget_=!1;this.workspace_=null;this.SERIALIZABLE=!0;a!==rg.SKIP_SETUP&&(c&&this.configure_(c),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a);
1642
1643
  a.spellcheck!==void 0&&(this.spellcheck_=a.spellcheck)}initView(){if(!this.getSourceBlock())throw new lj;this.isFullBlockField()||this.createBorderRect_();this.createTextElement_();this.fieldGroup_&&n(this.fieldGroup_,"blocklyField");this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot());this.fieldGroup_&&n(this.fieldGroup_,"blocklyInputField");this.recomputeAriaContext()}isFullBlockField(){var a=this.getSourceBlock();if(!a)throw new lj;var b;return this.fullBlockClickTarget_=
1643
1644
  !((b=this.getConstants())==null||!b.FULL_BLOCK_FIELDS)&&a.isSimpleReporter()}createWarningIcon(){if(!this.sourceBlock_)return null;var a=this.getScaledBBox();a=a.bottom-a.top;a=r(q.SVG,{"class":"blocklyInputWarning",viewBox:"-4 0 24 16",x:"0",y:"0",height:`${a}px`,width:`${a}px`});r(q.PATH,{"class":"blocklyInputWarningIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},a);r(q.PATH,{"class":"blocklyInputWarningIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},a);
1644
1645
  r(q.RECT,{"class":"blocklyInputWarningIconSymbol",x:"7",y:"11",height:"2",width:"2"},a);return a}doValueInvalid_(a,b=!0){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,a=this.value_,this.value_=this.valueWhenEditorWasOpened_,this.sourceBlock_&&Vb()&&this.value_!==a&&b&&w(new (u(v.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,a,this.value_)));this.recomputeAriaContext()}doValueUpdate_(a){this.isTextValid_=this.isDirty_=!0;this.value_=a;this.recomputeAriaContext()}applyColour(){var a=
1645
1646
  this.getSourceBlock();if(!a)throw new lj;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",a.getColourTertiary())):a.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR))}getSize(){var a;if((a=this.getConstants())==null?0:a.FULL_BLOCK_FIELDS)this.render_(),this.isDirty_=!1;return super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){super.render_();
1646
1647
  var a=this.getSourceBlock();if(!a)throw new lj;if(this.isBeingEdited_){let b=this.htmlInput_;this.renderWarningIcon(a.RTL,this.isTextValid_);this.isTextValid_?(Ma(b,"blocklyInvalidInput"),l(b,p.INVALID,!1)):(n(b,"blocklyInvalidInput"),l(b,p.INVALID,!0))}this.getConstants().FULL_BLOCK_FIELDS&&a.applyColour()}renderWarningIcon(a,b){var c=this.htmlInput_;if(this.warningIcon)if(b)c.style.paddingRight="",c.style.paddingLeft="",Ma(this.warningIcon,"blocklyInputWarningInvalid");else{b=this.getScaledBBox();
1647
1648
  var d=b.bottom-b.top;d=(b=!!this.borderRect_)?this.getConstants().FIELD_BORDER_RECT_X_PADDING:d/2;n(this.warningIcon,"blocklyInputWarningInvalid");let e=this.warningIcon.getBoundingClientRect().width;c.setAttribute("width",`${c.offsetWidth+e}px`);let f=e/1.5;a?c.style.paddingRight=`${f}px`:c.style.paddingLeft=`${f}px`;this.size_.width=e;a=b?this.getConstants().FIELD_TEXT_HEIGHT-this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;this.updateSize_(d+a)}}setSpellcheck(a){a!==this.spellcheck_&&(this.spellcheck_=
1648
- a,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(a,b=!1,c=!0){this.workspace_=this.sourceBlock_.workspace;!b&&this.workspace_.options.modalInputs&&(yk||xk||Vi)?this.showPromptEditor():this.showInlineEditor(b,c)}showPromptEditor(){vd($.C.CHANGE_VALUE_TITLE,this.getText(),a=>{a!==null&&this.setValue(this.getValueFromEditorText_(a));this.onFinishEditing_(this.value_)})}showInlineEditor(a,b){var c=this.getSourceBlock();if(!c)throw new lj;ug(this,c.RTL,this.widgetDispose_.bind(this),
1649
+ a,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(a,b=!1,c=!0){this.workspace_=this.sourceBlock_.workspace;!b&&this.workspace_.options.modalInputs&&(zk||yk||Vi)?this.showPromptEditor():this.showInlineEditor(b,c)}showPromptEditor(){vd($.C.CHANGE_VALUE_TITLE,this.getText(),a=>{a!==null&&this.setValue(this.getValueFromEditorText_(a));this.onFinishEditing_(this.value_)})}showInlineEditor(a,b){var c=this.getSourceBlock();if(!c)throw new lj;ug(this,c.RTL,this.widgetDispose_.bind(this),
1649
1650
  this.workspace_,b);this.htmlInput_=this.widgetCreate_();this.isBeingEdited_=!0;this.valueWhenEditorWasOpened_=this.value_;a||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var a=this.getSourceBlock();if(!a)throw new lj;$.B(!0);var b=mg,c=this.getClickTarget_();if(!c)throw Error("A click target has not been set.");n(c,"blocklyEditing");c=document.createElement("input");c.className="blocklyHtmlInput";c.setAttribute("spellcheck",this.spellcheck_);this.warningIcon=
1650
- this.createWarningIcon();var d=this.workspace_.getAbsoluteScale(),e=this.getConstants().FIELD_TEXT_FONTSIZE*d+"pt";b.style.fontSize=e;c.style.fontSize=e;e=Up.BORDERRADIUS*d+"px";if(this.isFullBlockField()){let f=this.getScaledBBox();e=(f.bottom-f.top)/2+"px";a=a.getParent()?a.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary();c.style.border=1*d+"px solid "+a;b.style.borderRadius=e;b.style.transition="box-shadow 0.25s ease 0s";this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(b.style.boxShadow=
1651
+ this.createWarningIcon();var d=this.workspace_.getAbsoluteScale(),e=this.getConstants().FIELD_TEXT_FONTSIZE*d+"pt";b.style.fontSize=e;c.style.fontSize=e;e=Vp.BORDERRADIUS*d+"px";if(this.isFullBlockField()){let f=this.getScaledBBox();e=(f.bottom-f.top)/2+"px";a=a.getParent()?a.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary();c.style.border=1*d+"px solid "+a;b.style.borderRadius=e;b.style.transition="box-shadow 0.25s ease 0s";this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(b.style.boxShadow=
1651
1652
  "rgba(255, 255, 255, 0.3) 0 0 0 "+4*d+"px");a=(f.bottom-f.top)/4;this.warningIcon.style.paddingLeft=`${a}px`;this.warningIcon.style.paddingRight=`${a}px`}c.style.borderRadius=e;this.warningIcon&&b.appendChild(this.warningIcon);b.appendChild(c);c.value=c.defaultValue=this.getEditorText_(this.value_);c.setAttribute("data-untyped-default-value",String(this.value_));this.resizeEditor_();this.bindInputEvents_(c);return c}widgetDispose_(){this.isBeingEdited_=!1;this.isTextValid_=!0;this.forceRerender();
1652
1653
  this.onFinishEditing_(this.value_);this.sourceBlock_&&Vb()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(w(new (u(v.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null);$.B(!1);this.unbindInputEvents_();var a=mg.style;a.width="auto";a.height="auto";a.fontSize="";a.transition="";a.boxShadow="";this.htmlInput_=null;a=this.getClickTarget_();if(!a)throw Error("A click target has not been set.");
1653
1654
  Ma(a,"blocklyEditing");this.recomputeAriaContext()}onFinishEditing_(){}bindInputEvents_(a){this.onKeyDownWrapper=k(a,"keydown",this,this.onHtmlInputKeyDown_);this.onInputWrapper=k(a,"input",this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(ka(this.onKeyDownWrapper),this.onKeyDownWrapper=null);this.onInputWrapper&&(ka(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(a){if(a.key==="Enter")vg(this),of(),a.stopPropagation();else if(a.key==="Escape")this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),
1654
- !1),vg(this),of();else if(a.key==="Tab"){a.preventDefault();var b;let c=(b=this.workspace_)==null?void 0:b.getNavigator(),d=e=>(e instanceof Up||e instanceof ii&&e.isSimpleReporter())&&e!==this.getSourceBlock();b=this;do b=a.shiftKey?c==null?void 0:c.getOutNode(b):c==null?void 0:c.getInNode(b);while(b&&!d(b));b=b instanceof ii&&b.isSimpleReporter()?b.getFields().next().value:b;b instanceof Up&&(vg(this),of(),a=b.getSourceBlock(),b.isFullBlockField()&&a&&a instanceof ii?$.t().focusNode(a):$.t().focusNode(b),
1655
+ !1),vg(this),of();else if(a.key==="Tab"){a.preventDefault();var b;let c=(b=this.workspace_)==null?void 0:b.getNavigator(),d=e=>(e instanceof Vp||e instanceof ii&&e.isSimpleReporter())&&e!==this.getSourceBlock();b=this;do b=a.shiftKey?c==null?void 0:c.getOutNode(b):c==null?void 0:c.getInNode(b);while(b&&!d(b));b=b instanceof ii&&b.isSimpleReporter()?b.getFields().next().value:b;b instanceof Vp&&(vg(this),of(),a=b.getSourceBlock(),b.isFullBlockField()&&a&&a instanceof ii?$.t().focusNode(a):$.t().focusNode(b),
1655
1656
  b.showEditor())}}onHtmlInputChange(){var a=this.value_;this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1);this.sourceBlock_&&Vb()&&this.value_!==a&&w(new (u(v.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,a,this.value_))}setEditorValue_(a,b=!0){this.isDirty_=!0;this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(a));this.setValue(a,b)}resizeEditor_(){cd().then(()=>{var a=this.getSourceBlock();if(!a)throw new lj;var b=mg,c=this.getScaledBBox();b.style.width=
1656
1657
  c.right-c.left+"px";b.style.height=c.bottom-c.top+"px";a=a.RTL?c.right-b.offsetWidth:c.left;c=c.top;var d=b==null?void 0:b.parentElement;d&&(d=d.getBoundingClientRect(),a-=d.left+window.scrollX,c-=d.top+window.scrollY);b.style.left=`${a}px`;b.style.top=`${c}px`})}repositionForWindowResize(){var a,b=(a=this.getSourceBlock())==null?void 0:a.getRootBlock();if(!(b instanceof ii))return!1;Uh(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),b)||this.resizeEditor_();return!0}positionTextElement_(a,
1657
1658
  b){var c=a*2+b;super.positionTextElement_(a+(c<14?(14-c)/2:0),b)}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(a){return`${a}`}getValueFromEditorText_(a){return a}getAriaTypeName(){return this.ariaTypeName||$.C.ARIA_TYPE_FIELD_INPUT}getAriaValue(){return this.getText()||$.C.FIELD_LABEL_EMPTY}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement(),b=this.computeAriaLabel(!0),c,d=this.isCurrentlyEditable()&&
1658
- !((c=this.getSourceBlock())==null?0:c.isInFlyout);if(this.isFullBlockField()){if(c=Ce(this.getSourceBlock(),we.STANDARD,b),d){b=c.split(", ");d=xe(this.getSourceBlock());d=d===void 0?-1:b.indexOf(d);d=d===-1?0:d+1;let e;b[d]=$.C.FIELD_LABEL_EDIT_PREFIX.replace("%1",(e=b[d])!=null?e:"");b=b.join(", ")}}else d&&(b=$.C.FIELD_LABEL_EDIT_PREFIX.replace("%1",b));l(a,p.LABEL,b);return!0}};Up.BORDERRADIUS=4;ta("\n .blocklyInputWarningIconShape {\n stroke: #1f1f1f;\n stroke-width: 1px;\n fill: none;\n }\n .blocklyInputWarningIconSymbol {\n fill: #1f1f1f;\n }\n .blocklyInputWarning {\n display: none;\n position: absolute;\n }\n .blocklyInputWarning.blocklyInputWarningInvalid {\n display: inline;\n }\n");$.Vp=class extends Up{constructor(a,b,c){super(a,b,c)}initView(){super.initView();this.fieldGroup_&&n(this.fieldGroup_,"blocklyTextInputField")}doClassValidation_(a){return a===void 0?null:`${a}`}static fromJson(a){return new this(hg(a.text),void 0,a)}getAriaTypeName(){return this.ariaTypeName||$.C.ARIA_TYPE_FIELD_TEXT_INPUT}};jh("field_input",$.Vp);$.Vp.prototype.DEFAULT_VALUE="";var Wp=class extends Po{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){return!!a.outputConnection}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&!a.nextConnection}};var Yj=class extends ip{constructor(a,b){super(a,b);this.connectedBottomNextConnection=!1;if(this.connectedBlock){for(a=this.connectedBlock;b=a.getNextBlock();)a=b;a.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}};var Xp=class extends No{constructor(a){super(a);this.width=this.height=0;this.type|=Q.getType("RIGHT_CONNECTION")}};var Yp=class extends jp{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){var b=(a.hat?a.hat==="cap":this.constants_.ADD_START_HATS)&&!a.outputConnection&&!a.previousConnection;return!!a.outputConnection||b}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&!a.nextConnection}};var Zp=class extends np{constructor(a,b){super(a,b);this.isInline=!0;this.renderer_=a;this.constants_=this.renderer_.getConstants();this.topRow=new Yp(this.constants_);this.bottomRow=new Wp(this.constants_);this.isMultiRow=!b.getInputsInline()||b.isCollapsed();this.hasStatementInput=b.statementInputCount>0;this.rightSide=this.outputConnection?new Xp(this.constants_):null;this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_();this.addElemSpacing_();
1659
- this.addRowSpacing_();this.adjustXPosition_();this.computeBounds_();this.alignRowElements_();this.finalize_()}shouldStartNewRow_(a,b){return b?b instanceof Ln||a instanceof Mn||b instanceof Mn?!0:a instanceof $.Nn||a instanceof Kn||a instanceof Ln?!this.isInline||this.isMultiRow:!1:!1}getDesiredRowWidth_(a){return a.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(a)}getInRowSpacing_(a,b){return a&&b||!this.outputConnection||!this.outputConnection.isDynamicShape||
1659
+ !((c=this.getSourceBlock())==null?0:c.isInFlyout);if(this.isFullBlockField()){if(c=Ce(this.getSourceBlock(),we.STANDARD,b),d){b=c.split(", ");d=xe(this.getSourceBlock());d=d===void 0?-1:b.indexOf(d);d=d===-1?0:d+1;let e;b[d]=$.C.FIELD_LABEL_EDIT_PREFIX.replace("%1",(e=b[d])!=null?e:"");b=b.join(", ")}}else d&&(b=$.C.FIELD_LABEL_EDIT_PREFIX.replace("%1",b));l(a,p.LABEL,b);return!0}};Vp.BORDERRADIUS=4;ta("\n .blocklyInputWarningIconShape {\n stroke: #1f1f1f;\n stroke-width: 1px;\n fill: none;\n }\n .blocklyInputWarningIconSymbol {\n fill: #1f1f1f;\n }\n .blocklyInputWarning {\n display: none;\n position: absolute;\n }\n .blocklyInputWarning.blocklyInputWarningInvalid {\n display: inline;\n }\n");var Wp=class extends Qo{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){return!!a.outputConnection}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&!a.nextConnection}};var Zj=class extends jp{constructor(a,b){super(a,b);this.connectedBottomNextConnection=!1;if(this.connectedBlock){for(a=this.connectedBlock;b=a.getNextBlock();)a=b;a.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}};var Xp=class extends Oo{constructor(a){super(a);this.width=this.height=0;this.type|=Q.getType("RIGHT_CONNECTION")}};var Yp=class extends kp{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){var b=(a.hat?a.hat==="cap":this.constants_.ADD_START_HATS)&&!a.outputConnection&&!a.previousConnection;return!!a.outputConnection||b}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&!a.nextConnection}};var Zp=class extends op{constructor(a,b){super(a,b);this.isInline=!0;this.renderer_=a;this.constants_=this.renderer_.getConstants();this.topRow=new Yp(this.constants_);this.bottomRow=new Wp(this.constants_);this.isMultiRow=!b.getInputsInline()||b.isCollapsed();this.hasStatementInput=b.statementInputCount>0;this.rightSide=this.outputConnection?new Xp(this.constants_):null;this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_();this.addElemSpacing_();
1660
+ this.addRowSpacing_();this.adjustXPosition_();this.computeBounds_();this.alignRowElements_();this.finalize_()}shouldStartNewRow_(a,b){return b?b instanceof Mn||a instanceof Nn||b instanceof Nn?!0:a instanceof $.On||a instanceof Ln||a instanceof Mn?!this.isInline||this.isMultiRow:!1:!1}getDesiredRowWidth_(a){return a.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(a)}getInRowSpacing_(a,b){return a&&b||!this.outputConnection||!this.outputConnection.isDynamicShape||
1660
1661
  this.hasStatementInput||this.bottomRow.hasNextConnection?!a&&b&&Q.isStatementInput(b)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:a&&Q.isLeftRoundedCorner(a)&&b&&(Q.isPreviousConnection(b)||Q.isNextConnection(b))?b.notchOffset-this.constants_.CORNER_RADIUS:a&&Q.isLeftSquareCorner(a)&&b&&Q.isHat(b)||a&&Q.isField(a)&&a.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(a,b){if(Q.isTopRow(a)&&Q.isBottomRow(b))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;
1661
1662
  var c=Q.isInputRow(a)&&a.hasStatement,d=Q.isInputRow(b)&&b.hasStatement;return d||c?(a=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),d&&c?Math.max(a,this.constants_.DUMMY_INPUT_MIN_HEIGHT):a):Q.isTopRow(a)?a.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):Q.isBottomRow(b)?this.outputConnection?!b.hasNextConnection&&this.hasStatementInput?Math.abs(this.constants_.NOTCH_HEIGHT-
1662
1663
  this.constants_.CORNER_RADIUS):this.constants_.NO_PADDING:Math.max(this.topRow.minHeight,Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.CORNER_RADIUS))-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}getSpacerRowWidth_(a,b){var c=this.width-this.startX;return Q.isInputRow(a)&&a.hasStatement||Q.isInputRow(b)&&b.hasStatement?Math.max(c,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):c}getElemCenterline_(a,b){if(a.hasStatement&&!Q.isSpacer(b)&&!Q.isStatementInput(b))return a.yPos+
1663
- this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(Q.isInlineInput(b)){let c=b.connectedBlock;if(c&&c.outputConnection&&c.nextConnection)return a.yPos+c.height/2}return super.getElemCenterline_(a,b)}addInput_(a,b){if((a instanceof Kn||a instanceof Ln)&&b.hasDummyInput&&b.align===$.En.LEFT&&a.align===$.En.RIGHT)this.rightAlignedDummyInputs.set(b,a);else if(a instanceof Mn){b.elements.push(new Yj(this.constants_,a));b.hasStatement=!0;b.align===null&&(b.align=a.align);return}super.addInput_(a,b)}addAlignmentPadding_(a,
1664
+ this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(Q.isInlineInput(b)){let c=b.connectedBlock;if(c&&c.outputConnection&&c.nextConnection)return a.yPos+c.height/2}return super.getElemCenterline_(a,b)}addInput_(a,b){if((a instanceof Ln||a instanceof Mn)&&b.hasDummyInput&&b.align===$.Fn.LEFT&&a.align===$.Fn.RIGHT)this.rightAlignedDummyInputs.set(b,a);else if(a instanceof Nn){b.elements.push(new Zj(this.constants_,a));b.hasStatement=!0;b.align===null&&(b.align=a.align);return}super.addInput_(a,b)}addAlignmentPadding_(a,
1664
1665
  b){if(this.rightAlignedDummyInputs.get(a)){let c;for(let d=0;d<a.elements.length;d++){let e=a.elements[d];Q.isSpacer(e)&&(c=e);if(Q.isField(e)&&e.parentInput===this.rightAlignedDummyInputs.get(a))break}if(c){c.width+=b;a.width+=b;return}}super.addAlignmentPadding_(a,b)}adjustXPosition_(){var a=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH,b=a;for(let e=2;e<this.rows.length-1;e+=2){var c=this.rows[e-1];let f=this.rows[e];var d=this.rows[e+1];c=e===2?!!this.topRow.hasPreviousConnection:
1665
- !!c.followsStatement;d=e+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!d.precedesStatement;if(Q.isInputRow(f)&&f.hasStatement){f.measure();let g,h;b=f.width-((h=(g=f.getLastInput())==null?void 0:g.width)!=null?h:0)+a}else if(c&&(e===2||d)&&Q.isInputRow(f)&&!f.hasStatement){d=f.xPos;c=null;for(let g=0;g<f.elements.length;g++){let h=f.elements[g];Q.isSpacer(h)&&(c=h);!(c&&(Q.isField(h)||Q.isInput(h))&&d<b)||Q.isField(h)&&(h.field instanceof ao||h.field instanceof Tp)||(c.width+=b-d);d+=
1666
+ !!c.followsStatement;d=e+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!d.precedesStatement;if(Q.isInputRow(f)&&f.hasStatement){f.measure();let g,h;b=f.width-((h=(g=f.getLastInput())==null?void 0:g.width)!=null?h:0)+a}else if(c&&(e===2||d)&&Q.isInputRow(f)&&!f.hasStatement){d=f.xPos;c=null;for(let g=0;g<f.elements.length;g++){let h=f.elements[g];Q.isSpacer(h)&&(c=h);!(c&&(Q.isField(h)||Q.isInput(h))&&d<b)||Q.isField(h)&&(h.field instanceof bo||h.field instanceof Up)||(c.width+=b-d);d+=
1666
1667
  h.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var a=this.outputConnection.shape;if("isDynamic"in a&&a.isDynamic){var b=0;for(var c=0;c<this.rows.length;c++){let d=this.rows[c];d.yPos=b;b+=d.height}this.height=b;c=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height;b=a.height(c);c=a.width(c);this.outputConnection.height=b;this.outputConnection.width=c;this.outputConnection.startX=c;this.outputConnection.connectionOffsetY=
1667
1668
  a.connectionOffsetY(b);this.outputConnection.connectionOffsetX=a.connectionOffsetX(c);a=0;this.hasStatementInput||this.bottomRow.hasNextConnection||(a=c,this.rightSide.height=b,this.rightSide.width=a,this.rightSide.centerline=b/2,this.rightSide.xPos=this.width+a);this.startX=c;this.width+=c+a;this.widthWithChildren+=c+a}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){var a=0;for(var b=0;b<this.rows.length;b++){var c=this.rows[b];
1668
- if(!Q.isInputRow(c))continue;a=c.elements[c.elements.length-2];let d=this.getNegativeSpacing_(c.elements[1]),e=this.getNegativeSpacing_(a);a=d+e;let f=this.constants_.MIN_BLOCK_WIDTH+this.outputConnection.width*2;this.width-a<f&&(a=this.width-f,d=a/2,e=a/2);c.elements.unshift(new Zo(this.constants_,-d));c.elements.push(new Zo(this.constants_,-e))}if(a)for(this.width-=a,this.widthWithChildren-=a,this.rightSide.xPos-=a,b=0;b<this.rows.length;b++)c=this.rows[b],Q.isTopOrBottomRow(c)&&(c.elements[1].width-=
1669
- a),c.width-=a,c.widthWithConnectedBlocks-=a}}getNegativeSpacing_(a){if(!a||!this.outputConnection)return 0;var b=this.outputConnection.width,c=this.outputConnection.shape.type,d=this.constants_;if(this.inputRows.length>1)switch(c){case d.SHAPES.ROUND:return c=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,c=this.height/2>c?c:this.height/2,b-c*(1-Math.sin(Math.acos((c-this.constants_.SMALL_PADDING)/c)));default:return 0}if(Q.isInlineInput(a)){let e=a.connectedBlock;a=e?e.pathObject.outputShapeType:
1670
- a.shape.type;return a==null||e&&e.outputConnection&&(e.statementInputCount||e.nextConnection)||c===d.SHAPES.HEXAGONAL&&c!==a?0:b-this.constants_.SHAPE_IN_SHAPE_PADDING[c][a]}return Q.isField(a)?c===d.SHAPES.ROUND&&a.field instanceof $.Vp?b-2.75*d.GRID_UNIT:b-this.constants_.SHAPE_IN_SHAPE_PADDING[c][0]:Q.isIcon(a)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let d=2;d<this.rows.length-1;d+=2){let e=this.rows[d-1],f=this.rows[d],g=this.rows[d+1];var a=
1671
- d===2,b=d+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!g.precedesStatement;if(a?this.topRow.hasPreviousConnection:e.followsStatement){var c=f.elements[1];c=f.elements.length===3&&c instanceof To&&(c.field instanceof ao||c.field instanceof Tp);if(!a&&c)e.height-=this.constants_.SMALL_PADDING,g.height-=this.constants_.SMALL_PADDING,f.height-=this.constants_.MEDIUM_PADDING;else if(!a&&!b)e.height+=this.constants_.SMALL_PADDING;else if(b){a=!1;for(b=0;b<f.elements.length;b++)if(c=f.elements[b],
1672
- Q.isInlineInput(c)&&c.connectedBlock&&!c.connectedBlock.isShadow()&&c.connectedBlock.getHeightWidth().height>=40){a=!0;break}a&&(e.height-=this.constants_.SMALL_PADDING,g.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_();this.finalizeHorizontalAlignment_();this.finalizeVerticalAlignment_();super.finalize_();this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}};var $p=class extends op{constructor(a,b,c){super(a,b,c);this.svgPathSelected=null;this.outlines=new Map;this.remainingOutlines=new Set;this.outputShapeType=null;this.constants=c}setPath(a){super.setPath(a);this.svgPathSelected&&this.svgPathSelected.setAttribute("d",a)}applyColour(a){super.applyColour(a);var b=a.getParent();a.isShadow()&&b&&this.svgPath.setAttribute("stroke",b.getColourTertiary());for(let c of this.outlines.values())c.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();
1669
+ if(!Q.isInputRow(c))continue;a=c.elements[c.elements.length-2];let d=this.getNegativeSpacing_(c.elements[1]),e=this.getNegativeSpacing_(a);a=d+e;let f=this.constants_.MIN_BLOCK_WIDTH+this.outputConnection.width*2;this.width-a<f&&(a=this.width-f,d=a/2,e=a/2);c.elements.unshift(new $o(this.constants_,-d));c.elements.push(new $o(this.constants_,-e))}if(a)for(this.width-=a,this.widthWithChildren-=a,this.rightSide.xPos-=a,b=0;b<this.rows.length;b++)c=this.rows[b],Q.isTopOrBottomRow(c)&&(c.elements[1].width-=
1670
+ a),c.width-=a,c.widthWithConnectedBlocks-=a}}getNegativeSpacing_(a){if(!a||!this.outputConnection)return 0;var b=this.outputConnection.width,c=this.outputConnection.shape.type,d=this.constants_;if(this.inputRows.length>1)switch(c){case d.SHAPES.ROUND:return c=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,c=this.height/2>c?c:this.height/2,c=Cj(c,c-this.constants_.SMALL_PADDING),b-c;default:return 0}if(Q.isInlineInput(a)){var e=a.connectedBlock;a=e?e.pathObject.outputShapeType:a.shape.type;return a==
1671
+ null||e&&e.outputConnection&&(e.statementInputCount||e.nextConnection)||c===d.SHAPES.HEXAGONAL&&c!==a?0:b-this.constants_.SHAPE_IN_SHAPE_PADDING[c][a]}if(Q.isField(a)){if(c===d.SHAPES.ROUND&&a.field instanceof Vp)return b-2.75*d.GRID_UNIT;let f=e=this.constants_.SHAPE_IN_SHAPE_PADDING[c][0];c===d.SHAPES.ROUND&&(c=Cj(b,a.height/2)+d.SMALL_PADDING,f=Math.min(b,Math.max(e,c)));return b-f}return Q.isIcon(a)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let d=
1672
+ 2;d<this.rows.length-1;d+=2){let e=this.rows[d-1],f=this.rows[d],g=this.rows[d+1];var a=d===2,b=d+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!g.precedesStatement;if(a?this.topRow.hasPreviousConnection:e.followsStatement){var c=f.elements[1];c=f.elements.length===3&&c instanceof Uo&&(c.field instanceof bo||c.field instanceof Up);if(!a&&c)e.height-=this.constants_.SMALL_PADDING,g.height-=this.constants_.SMALL_PADDING,f.height-=this.constants_.MEDIUM_PADDING;else if(!a&&!b)e.height+=this.constants_.SMALL_PADDING;
1673
+ else if(b){a=!1;for(b=0;b<f.elements.length;b++)if(c=f.elements[b],Q.isInlineInput(c)&&c.connectedBlock&&!c.connectedBlock.isShadow()&&c.connectedBlock.getHeightWidth().height>=40){a=!0;break}a&&(e.height-=this.constants_.SMALL_PADDING,g.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_();this.finalizeHorizontalAlignment_();this.finalizeVerticalAlignment_();super.finalize_();this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}};var $p=class extends pp{constructor(a,b,c){super(a,b,c);this.svgPathSelected=null;this.outlines=new Map;this.remainingOutlines=new Set;this.outputShapeType=null;this.constants=c}setPath(a){super.setPath(a);this.svgPathSelected&&this.svgPathSelected.setAttribute("d",a)}applyColour(a){super.applyColour(a);var b=a.getParent();a.isShadow()&&b&&this.svgPath.setAttribute("stroke",b.getColourTertiary());for(let c of this.outlines.values())c.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();
1673
1674
  for(let b of this.outlines.values())b.setAttribute("transform","scale(-1 1)");var a;(a=this.svgPathSelected)==null||a.setAttribute("transform","scale(-1 1)")}updateSelected(a){this.setClass_("blocklySelected",a);a?this.svgPathSelected||(this.svgPathSelected=r(q.PATH,{"class":"blocklyPath blocklyPathSelected",stroke:this.svgPath.getAttribute("stroke")||"",fill:this.svgPath.getAttribute("fill")||"",d:this.svgPath.getAttribute("d")||"",transform:this.svgPath.getAttribute("transform")||"",role:Ka.NONE},
1674
1675
  this.svgRoot),this.svgRoot.appendChild(this.svgPathSelected)):this.svgPathSelected&&(this.svgRoot.removeChild(this.svgPathSelected),this.svgPathSelected=null)}beginDrawing(){this.remainingOutlines.clear();for(let a of this.outlines.keys())this.remainingOutlines.add(a)}endDrawing(){if(this.remainingOutlines.size)for(let a of this.remainingOutlines)this.removeOutlinePath(a);this.remainingOutlines.clear()}setOutlinePath(a,b){a=this.getOutlinePath(a);a.setAttribute("d",b);a.setAttribute("fill",this.style.colourTertiary)}getOutlinePath(a){this.outlines.has(a)||
1675
- this.outlines.set(a,r(q.PATH,{"class":"blocklyOutlinePath",d:""},this.svgRoot));this.remainingOutlines.delete(a);return this.outlines.get(a)}removeOutlinePath(a){var b,c;(b=this.outlines.get(a))==null||(c=b.parentNode)==null||c.removeChild(this.outlines.get(a));this.outlines.delete(a)}};var aq=class extends pp{constructor(a){super(a)}makeConstants_(){return new Rp}makeRenderInfo_(a){return new Zp(this,a)}makeDrawer_(a,b){return new Sp(a,b)}makePathObject(a,b){return new $p(a,b,this.getConstants())}getConstants(){return this.constants_}shouldHighlightConnection(a){return super.shouldHighlightConnection(a)||a.type===G.INPUT_VALUE}};uj("zelos",aq);var bq=class{constructor(a){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null;this.workspace=a.workspace;this.insertionMarker=new Fp}previewReplacement(a,b,c){$.Ub++;try{this.hidePreview(),this.fadedBlock=c,c.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(b)&&(b.highlight(),this.staticConn=b)}finally{$.Ub--}}previewConnection(a,b){if(a!==this.draggedConn||b!==this.staticConn){$.Ub++;try{this.hidePreview(),this.shouldUseMarkerPreview(a,b)&&(this.shouldUseFastInsertionMarkers()?
1676
+ this.outlines.set(a,r(q.PATH,{"class":"blocklyOutlinePath",d:""},this.svgRoot));this.remainingOutlines.delete(a);return this.outlines.get(a)}removeOutlinePath(a){var b,c;(b=this.outlines.get(a))==null||(c=b.parentNode)==null||c.removeChild(this.outlines.get(a));this.outlines.delete(a)}};var aq=class extends qp{constructor(a){super(a)}makeConstants_(){return new Sp}makeRenderInfo_(a){return new Zp(this,a)}makeDrawer_(a,b){return new Tp(a,b)}makePathObject(a,b){return new $p(a,b,this.getConstants())}getConstants(){return this.constants_}shouldHighlightConnection(a){return super.shouldHighlightConnection(a)||a.type===G.INPUT_VALUE}};uj("zelos",aq);var bq=class{constructor(a){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null;this.workspace=a.workspace;this.insertionMarker=new Gp}previewReplacement(a,b,c){$.Ub++;try{this.hidePreview(),this.fadedBlock=c,c.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(b)&&(b.highlight(),this.staticConn=b)}finally{$.Ub--}}previewConnection(a,b){if(a!==this.draggedConn||b!==this.staticConn){$.Ub++;try{this.hidePreview(),this.shouldUseMarkerPreview(a,b)&&(this.shouldUseFastInsertionMarkers()?
1676
1677
  this.insertionMarker.show(b,a):this.markerConn=this.previewMarker(a,b)),this.workspace.getRenderer().shouldHighlightConnection(b)&&b.highlight(),this.workspace.getRenderer().shouldHighlightConnection(a)&&a.highlight(),this.draggedConn=a,this.staticConn=b}finally{$.Ub--}}}shouldUseMarkerPreview(a,b){return b.type===G.PREVIOUS_STATEMENT||b.type===G.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof aq)}previewMarker(a,b){var c=a.getSourceBlock(),d=this.createInsertionMarker(c),e=this.getMatchingConnection(c,
1677
1678
  d,a);if(!e)return null;d.queueRender();dd();e.connect(b);var f={x:b.x-e.x,y:b.y-e.y},g=e.getOffsetInBlock().clone();cd().then(()=>{if(!d.isDeadOrDying()){$.Ub++;try{d==null||d.positionNearConnection(e,f,g),d==null||d.getSvgRoot().setAttribute("visibility","visible")}finally{$.Ub--}}});return e}serializeBlockToInsertionMarker(a){var b=ce(a,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!b)throw Error(`Failed to serialize source block. ${a.toDevString()}`);return b}createInsertionMarker(a){a=
1678
1679
  this.serializeBlockToInsertionMarker(a);a=ee(a,this.workspace);for(let b of a.getDescendants(!1))b.setInsertionMarker(!0);a.initSvg();a.getSvgRoot().setAttribute("visibility","hidden");return a}getMatchingConnection(a,b,c){a=a.getConnections_(!0);b=b.getConnections_(!0);if(a.length!==b.length)return null;for(let d=0;d<a.length;d++)if(a[d]===c)return b[d];return null}hidePreview(){$.Ub++;try{this.staticConn&&(this.staticConn.unhighlight(),this.staticConn=null),this.draggedConn&&(this.draggedConn.unhighlight(),
1679
1680
  this.draggedConn=null),this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null),this.shouldUseFastInsertionMarkers()?this.insertionMarker.hide():this.markerConn&&(this.hideInsertionMarker(this.markerConn),this.draggedConn=this.markerConn=null)}finally{$.Ub--}}hideInsertionMarker(a){var b=a.getSourceBlock(),c=b.outputConnection,d;if(((d=b.previousConnection)==null?0:d.targetConnection)||(c==null?0:c.targetConnection))b.unplug(!0);else{let e;(e=a.targetBlock())==null||e.unplug(!1)}b.dispose()}dispose(){this.hidePreview()}shouldUseFastInsertionMarkers(){var a=
1680
- this.workspace.getRenderer();return a.constructor===Qp||a.constructor===Op||a.constructor===aq||bq.useFastInsertionMarkers}};bq.useFastInsertionMarkers=!1;A(y.CONNECTION_PREVIEWER,"default",bq);var cq={};cq.Align=$.En;cq.DummyInput=Kn;cq.EndRowInput=Ln;cq.Input=Jn;cq.StatementInput=Mn;cq.ValueInput=$.Nn;cq.inputTypes=$.je;var Jj=!1;$.dq=class{constructor(a){this.forBlock=Object.create(null);this.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}";this.STATEMENT_SUFFIX=this.STATEMENT_PREFIX=this.INFINITE_LOOP_TRAP=null;this.INDENT=" ";this.COMMENT_WRAP=60;this.ORDER_OVERRIDES=[];this.isInitialized=null;this.RESERVED_WORDS_="";this.definitions_=Object.create(null);this.functionNames_=Object.create(null);this.nameDB_=void 0;this.name_=a;this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(a){a||
1681
+ this.workspace.getRenderer();return a.constructor===Rp||a.constructor===Pp||a.constructor===aq||bq.useFastInsertionMarkers}};bq.useFastInsertionMarkers=!1;A(y.CONNECTION_PREVIEWER,"default",bq);var cq={};cq.Align=$.Fn;cq.DummyInput=Ln;cq.EndRowInput=Mn;cq.Input=Kn;cq.StatementInput=Nn;cq.ValueInput=$.On;cq.inputTypes=$.je;var Kj=!1;$.dq=class{constructor(a){this.forBlock=Object.create(null);this.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}";this.STATEMENT_SUFFIX=this.STATEMENT_PREFIX=this.INFINITE_LOOP_TRAP=null;this.INDENT=" ";this.COMMENT_WRAP=60;this.ORDER_OVERRIDES=[];this.isInitialized=null;this.RESERVED_WORDS_="";this.definitions_=Object.create(null);this.functionNames_=Object.create(null);this.nameDB_=void 0;this.name_=a;this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(a){a||
1681
1682
  (console.warn("No workspace specified in workspaceToCode call. Guessing."),a=kb);var b=[];this.init(a);a=a.getTopBlocks(!0);for(let c=0,d;d=a[c];c++){let e=this.blockToCode(d);Array.isArray(e)&&(e=e[0]);e&&(d.outputConnection&&(e=this.scrubNakedValue(e),this.STATEMENT_PREFIX&&!d.suppressPrefixSuffix&&(e=this.injectId(this.STATEMENT_PREFIX,d)+e),this.STATEMENT_SUFFIX&&!d.suppressPrefixSuffix&&(e+=this.injectId(this.STATEMENT_SUFFIX,d))),b.push(e))}b=b.join("\n");b=this.finish(b);b=b.replace(/^\s+\n/,
1682
1683
  "");b=b.replace(/\n\s+$/,"\n");return b=b.replace(/[ \t]+\n/g,"\n")}prefixLines(a,b){return b+a.replace(/(?!\n$)\n/g,"\n"+b)}allNestedComments(a){var b=[];a=a.getDescendants(!0);for(let c=0;c<a.length;c++){let d=a[c].getCommentText();d&&b.push(d)}b.length&&b.push("");return b.join("\n")}blockToCode(a,b){this.isInitialized===!1&&console.warn("CodeGenerator init was not called before blockToCode was called.");if(!a)return"";if(!a.isEnabled())return b?"":this.blockToCode(a.getNextBlock());if(a.isInsertionMarker())return b?
1683
1684
  "":this.blockToCode(a.getChildren(!1)[0]);var c=this.forBlock[a.type];if(typeof c!=="function")throw Error(`${this.name_} generator does not know how to generate code for block type "${a.type}".`);c=c.call(a,a,this);if(Array.isArray(c)){if(!a.outputConnection)throw TypeError("Expecting string from statement block: "+a.type);return[this.scrub_(a,c[0],b),c[1]]}if(typeof c==="string")return this.STATEMENT_PREFIX&&!a.suppressPrefixSuffix&&(c=this.injectId(this.STATEMENT_PREFIX,a)+c),this.STATEMENT_SUFFIX&&
@@ -1685,13 +1686,13 @@ this.workspace.getRenderer();return a.constructor===Qp||a.constructor===Op||a.co
1685
1686
  a=b[0];b=b[1];if(isNaN(b))throw TypeError("Expecting valid order from value block: "+d.type);if(!a)return"";d=!1;var e=Math.floor(c),f=Math.floor(b);if(e<=f&&(e!==f||e!==0&&e!==99))for(d=!0,e=0;e<this.ORDER_OVERRIDES.length;e++)if(this.ORDER_OVERRIDES[e][0]===c&&this.ORDER_OVERRIDES[e][1]===b){d=!1;break}d&&(a="("+a+")");return a}statementToCode(a,b){var c=a.getInputTargetBlock(b);if(!c&&!a.getInput(b))throw ReferenceError(`Input "${b}" doesn't exist on "${a.type}"`);a=this.blockToCode(c);if(typeof a!==
1686
1687
  "string")throw TypeError("Expecting code from statement block: "+(c&&c.type));a&&(a=this.prefixLines(a,this.INDENT));return a}addLoopTrap(a,b){this.INFINITE_LOOP_TRAP&&(a=this.prefixLines(this.injectId(this.INFINITE_LOOP_TRAP,b),this.INDENT)+a);this.STATEMENT_SUFFIX&&!b.suppressPrefixSuffix&&(a=this.prefixLines(this.injectId(this.STATEMENT_SUFFIX,b),this.INDENT)+a);this.STATEMENT_PREFIX&&!b.suppressPrefixSuffix&&(a+=this.prefixLines(this.injectId(this.STATEMENT_PREFIX,b),this.INDENT));return a}injectId(a,
1687
1688
  b){b=b.id.replace(/\$/g,"$$$$");return a.replace(/%1/g,"'"+b+"'")}addReservedWords(a){this.RESERVED_WORDS_+=a+","}provideFunction_(a,b){if(!this.definitions_[a]){let c=this.nameDB_.getDistinctName(a,$.P.PROCEDURE);this.functionNames_[a]=c;Array.isArray(b)&&(b=b.join("\n"));b=b.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,c);let d;for(;d!==b;)d=b,b=b.replace(/^(( {2})*) {2}/gm,"$1\x00");b=b.replace(/\0/g,this.INDENT);this.definitions_[a]=b}return this.functionNames_[a]}getVariableName(a){return this.getName(a,
1688
- $.P.VARIABLE)}getProcedureName(a){return this.getName(a,$.P.PROCEDURE)}getName(a,b){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(a,b)}init(){this.definitions_=Object.create(null);this.functionNames_=Object.create(null)}scrub_(a,b){return b}finish(a){this.definitions_=Object.create(null);this.functionNames_=Object.create(null);return a}scrubNakedValue(a){return a}};var eq=class extends Co{constructor(a){super(a)}setMetrics_(a){if(this.isVisible()){var b=this.workspace_.getMetricsManager(),c=b.getScrollMetrics(),d=b.getViewMetrics();b=b.getAbsoluteMetrics();typeof a.y==="number"&&(this.workspace_.scrollY=-(c.top+(c.height-d.height)*a.y));this.workspace_.translate(this.workspace_.scrollX+b.left,this.workspace_.scrollY+b.top)}}getX(){if(!this.isVisible())return 0;var a=this.targetWorkspace.getMetricsManager(),b=a.getAbsoluteMetrics(),c=a.getViewMetrics();a=a.getToolboxMetrics();
1689
+ $.P.VARIABLE)}getProcedureName(a){return this.getName(a,$.P.PROCEDURE)}getName(a,b){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(a,b)}init(){this.definitions_=Object.create(null);this.functionNames_=Object.create(null)}scrub_(a,b){return b}finish(a){this.definitions_=Object.create(null);this.functionNames_=Object.create(null);return a}scrubNakedValue(a){return a}};var eq=class extends Do{constructor(a){super(a)}setMetrics_(a){if(this.isVisible()){var b=this.workspace_.getMetricsManager(),c=b.getScrollMetrics(),d=b.getViewMetrics();b=b.getAbsoluteMetrics();typeof a.y==="number"&&(this.workspace_.scrollY=-(c.top+(c.height-d.height)*a.y));this.workspace_.translate(this.workspace_.scrollX+b.left,this.workspace_.scrollY+b.top)}}getX(){if(!this.isVisible())return 0;var a=this.targetWorkspace.getMetricsManager(),b=a.getAbsoluteMetrics(),c=a.getViewMetrics();a=a.getToolboxMetrics();
1689
1690
  return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===F.LEFT?a.width:c.width-this.getWidth():this.toolboxPosition_===F.LEFT?0:c.width:this.toolboxPosition_===F.LEFT?0:c.width+b.left-this.getWidth()}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var a=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=a.height;var b=this.getWidth()-this.CORNER_RADIUS;this.setBackgroundPath(b,
1690
1691
  a.height-2*this.CORNER_RADIUS);a=this.getX();b=this.getY();this.positionAt_(this.getWidth(),this.getHeight(),a,b)}}setBackgroundPath(a,b){var c=this.toolboxPosition_===F.RIGHT,d=a+this.CORNER_RADIUS;d=["M "+(c?d:0)+",0"];d.push("h",c?-a:a);d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,c?0:1,c?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS);d.push("v",Math.max(0,b));d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,c?0:1,c?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS);
1691
1692
  d.push("h",c?a:-a);d.push("z");this.svgBackground_.setAttribute("d",d.join(" "))}scrollToStart(){var a;(a=this.workspace_.scrollbar)==null||a.setY(0)}wheel_(a){var b=pa(a);if(b.y){let c=this.workspace_.getMetricsManager(),d=c.getScrollMetrics();b=c.getViewMetrics().top-d.top+b.y;let e;(e=this.workspace_.scrollbar)==null||e.setY(b);wg(this.workspace_);of()}a.preventDefault();a.stopPropagation()}layout_(a){this.workspace_.scale=this.targetWorkspace.scale;var b=this.MARGIN,c=this.RTL?b:b+this.tabWidth_;
1692
1693
  for(let d of a)d.getElement().moveBy(c,b),b+=d.getElement().getBoundingRectangle().getHeight()}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.left;return this.toolboxPosition_===F.LEFT?new cc(-1E9,1E9,-1E9,b+a.width):new cc(-1E9,1E9,b,1E9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();var a=this.getContents().reduce((b,c)=>Math.max(b,c.getElement().getBoundingRectangle().getWidth()),0);a+=this.MARGIN*
1693
1694
  1.5+this.tabWidth_;a*=this.workspace_.scale;a+=Ic.scrollbarThickness;if(this.getWidth()!==a){if(this.RTL)for(let b of this.getContents()){let c=b.getElement().getBoundingRectangle().left,d=a/this.workspace_.scale-b.getElement().getBoundingRectangle().getWidth()-this.MARGIN-this.tabWidth_;b.getElement().moveBy(d-c,0)}this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==F.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+a,
1694
- this.targetWorkspace.scrollY);this.width_=a;this.position();this.targetWorkspace.resizeContents();this.targetWorkspace.recordDragTargets()}}};eq.registryName="verticalFlyout";A(y.FLYOUTS_VERTICAL_TOOLBOX,"default",eq);var fq=class extends Co{constructor(a){super(a);this.horizontalLayout=!0}setMetrics_(a){if(this.isVisible()){var b=this.workspace_.getMetricsManager(),c=b.getScrollMetrics(),d=b.getViewMetrics();b=b.getAbsoluteMetrics();typeof a.x==="number"&&(this.workspace_.scrollX=-(c.left+(c.width-d.width)*a.x));this.workspace_.translate(this.workspace_.scrollX+b.left,this.workspace_.scrollY+b.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var a=this.targetWorkspace.getMetricsManager(),b=a.getAbsoluteMetrics(),
1695
+ this.targetWorkspace.scrollY);this.width_=a;this.position();this.targetWorkspace.resizeContents();this.targetWorkspace.recordDragTargets()}}};eq.registryName="verticalFlyout";A(y.FLYOUTS_VERTICAL_TOOLBOX,"default",eq);var fq=class extends Do{constructor(a){super(a);this.horizontalLayout=!0}setMetrics_(a){if(this.isVisible()){var b=this.workspace_.getMetricsManager(),c=b.getScrollMetrics(),d=b.getViewMetrics();b=b.getAbsoluteMetrics();typeof a.x==="number"&&(this.workspace_.scrollX=-(c.left+(c.width-d.width)*a.x));this.workspace_.translate(this.workspace_.scrollX+b.left,this.workspace_.scrollY+b.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var a=this.targetWorkspace.getMetricsManager(),b=a.getAbsoluteMetrics(),
1695
1696
  c=a.getViewMetrics();a=a.getToolboxMetrics();var d=this.toolboxPosition_===F.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?d?a.height:c.height-this.getHeight():d?0:c.height:d?0:c.height+b.top-this.getHeight()}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var a=this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=a.width;a=a.width-2*this.CORNER_RADIUS;var b=this.getHeight()-this.CORNER_RADIUS;this.setBackgroundPath(a,
1696
1697
  b);a=this.getX();b=this.getY();this.positionAt_(this.getWidth(),this.getHeight(),a,b)}}setBackgroundPath(a,b){var c=this.toolboxPosition_===F.TOP,d=["M 0,"+(c?0:this.CORNER_RADIUS)];c?(d.push("h",a+2*this.CORNER_RADIUS),d.push("v",b),d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),d.push("h",-a),d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,
1697
1698
  -this.CORNER_RADIUS),d.push("h",a),d.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),d.push("v",b),d.push("h",-a-2*this.CORNER_RADIUS));d.push("z");this.svgBackground_.setAttribute("d",d.join(" "))}scrollToStart(){var a;(a=this.workspace_.scrollbar)==null||a.setX(this.RTL?Infinity:0)}wheel_(a){var b=pa(a);if(b=b.x||b.y){let c=this.workspace_.getMetricsManager(),d=c.getScrollMetrics();b=c.getViewMetrics().left-d.left+b;let e;(e=this.workspace_.scrollbar)==
@@ -1706,55 +1707,55 @@ if(!b)throw new lj;this.variable=$.Vd(b.workspace,a);super.doValueUpdate_(a)}typ
1706
1707
  a=Array.from(new Set([...a,...b.getTypes()]))}return a}setTypes(a=null,b=""){var c=this.getText();if(Array.isArray(a)){if(a.length===0)throw Error(`'variableTypes' of field variable ${c} was an empty list. If you want to include all variable types, pass 'null' instead.`);c=!1;for(let d=0;d<a.length;d++)a[d]===b&&(c=!0);if(!c)throw Error("Invalid default type '"+b+"' in the definition of a FieldVariable");}else if(a!==null)throw Error(`'variableTypes' was not an array or null in the definition of FieldVariable ${c}`);
1707
1708
  this.defaultType=b;this.variableTypes=a}refreshVariableName(){this.forceRerender()}onItemSelected_(a,b){a=b.getValue();if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(a==="RENAME_VARIABLE_ID"&&this.variable){$.Rd(this.sourceBlock_.workspace,this.variable);return}if(a==="DELETE_VARIABLE_ID"&&this.variable){a=this.variable.getWorkspace();$.$d(a,this.variable,this.sourceBlock_);return}}this.setValue(a)}referencesVariables(){return!0}static fromJson(a){return new this(hg(a.variable),void 0,
1708
1709
  void 0,void 0,a)}static dropdownCreate(){if(!this.variable)throw Error("Tried to call dropdownCreate on a variable field with no variable selected.");var a=this.getText(),b=[],c=this.getSourceBlock();if(c&&!c.isDeadOrDying()){c=c.workspace;let f=this.getVariableTypes();for(let g=0;g<f.length;g++){let h=f[g],m=c.getVariableMap().getVariablesOfType(h);b=b.concat(m);if(c.isFlyout){var d=void 0,e=void 0;b=b.concat((e=(d=c.getPotentialVariableMap())==null?void 0:d.getVariablesOfType(h))!=null?e:[])}}}b.sort(Hd);
1709
- d=[];for(e=0;e<b.length;e++)d[e]=[b[e].getName(),b[e].getId()];d.push([$.C.RENAME_VARIABLE.replace("%1",a),"RENAME_VARIABLE_ID"]);$.C.DELETE_VARIABLE&&d.push([$.C.DELETE_VARIABLE.replace("%1",a),"DELETE_VARIABLE_ID"]);return d}getAriaValue(){return $.C.FIELD_LABEL_VARIABLE.replace("%1",super.getAriaValue())}};jh("field_variable",gq);var hq=class extends Up{constructor(a,b,c,d,e,f){super(rg.SKIP_SETUP);this.min_=-Infinity;this.max_=Infinity;this.precision_=0;this.decimalPlaces=null;this.spellcheck_=!1;a!==rg.SKIP_SETUP&&(f?this.configure_(f):this.setConstraints(b,c,d),this.setValue(a),e&&this.setValidator(e))}configure_(a){super.configure_(a);this.setMinInternal(a.min);this.setMaxInternal(a.max);this.setPrecisionInternal(a.precision)}setConstraints(a,b,c){this.setMinInternal(a);this.setMaxInternal(b);this.setPrecisionInternal(c);
1710
+ d=[];for(e=0;e<b.length;e++)d[e]=[b[e].getName(),b[e].getId()];d.push([$.C.RENAME_VARIABLE.replace("%1",a),"RENAME_VARIABLE_ID"]);$.C.DELETE_VARIABLE&&d.push([$.C.DELETE_VARIABLE.replace("%1",a),"DELETE_VARIABLE_ID"]);return d}getAriaValue(){return $.C.FIELD_LABEL_VARIABLE.replace("%1",super.getAriaValue())}};jh("field_variable",gq);$.hq=class extends Vp{constructor(a,b,c){super(a,b,c)}initView(){super.initView();this.fieldGroup_&&n(this.fieldGroup_,"blocklyTextInputField")}doClassValidation_(a){return a===void 0?null:`${a}`}static fromJson(a){return new this(hg(a.text),void 0,a)}getAriaTypeName(){return this.ariaTypeName||$.C.ARIA_TYPE_FIELD_TEXT_INPUT}};jh("field_input",$.hq);$.hq.prototype.DEFAULT_VALUE="";var iq=class extends Vp{constructor(a,b,c,d,e,f){super(rg.SKIP_SETUP);this.min_=-Infinity;this.max_=Infinity;this.precision_=0;this.decimalPlaces=null;this.spellcheck_=!1;a!==rg.SKIP_SETUP&&(f?this.configure_(f):this.setConstraints(b,c,d),this.setValue(a),e&&this.setValidator(e))}configure_(a){super.configure_(a);this.setMinInternal(a.min);this.setMaxInternal(a.max);this.setPrecisionInternal(a.precision)}setConstraints(a,b,c){this.setMinInternal(a);this.setMaxInternal(b);this.setPrecisionInternal(c);
1710
1711
  this.setValue(this.getValue())}setMin(a){this.setMinInternal(a);this.setValue(this.getValue())}setMinInternal(a){a==null?this.min_=-Infinity:(a=Number(a),isNaN(a)||(this.min_=a))}getMin(){return this.min_}setMax(a){this.setMaxInternal(a);this.setValue(this.getValue())}setMaxInternal(a){a==null?this.max_=Infinity:(a=Number(a),isNaN(a)||(this.max_=a))}getMax(){return this.max_}setPrecision(a){this.setPrecisionInternal(a);this.setValue(this.getValue())}setPrecisionInternal(a){this.precision_=Number(a)||
1711
1712
  0;var b=String(this.precision_);b.includes("e")&&(b=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));var c=b.indexOf(".");this.decimalPlaces=c===-1?a?0:null:b.length-c-1}getPrecision(){return this.precision_}doClassValidation_(a){if(a===null)return null;a=`${a}`.replace(/O/gi,"0");a=a.replace(/,/g,"");a=a.replace(/infinity/i,"Infinity");a=Number(a||0);if(isNaN(a))return null;a=Math.min(Math.max(a,this.min_),this.max_);this.precision_&&isFinite(a)&&(a=Math.round(a/this.precision_)*
1712
- this.precision_);this.decimalPlaces!==null&&(a=Number(a.toFixed(this.decimalPlaces)));return a}widgetCreate_(){var a=super.widgetCreate_();this.min_>-Infinity&&(a.min=`${this.min_}`);this.max_<Infinity&&(a.max=`${this.max_}`);return a}initView(){super.initView();this.fieldGroup_&&n(this.fieldGroup_,"blocklyNumberField")}static fromJson(a){return new this(a.value,void 0,void 0,void 0,void 0,a)}getAriaTypeName(){return this.ariaTypeName||$.C.ARIA_TYPE_FIELD_NUMBER}};jh("field_number",hq);
1713
- hq.prototype.DEFAULT_VALUE=0;var iq=class extends ao{constructor(a,b,c){super(String(a!=null?a:""),b,c);this.EDITABLE=!1;this.SERIALIZABLE=!0}static fromJson(a){return new this(hg(a.text),void 0,a)}};jh("field_label_serializable",iq);var jq=class extends rg{constructor(a,b,c){super(rg.SKIP_SETUP);this.SERIALIZABLE=!0;this.value_=this.value_;this.checkChar=jq.CHECK_CHAR;a!==rg.SKIP_SETUP&&(c&&this.configure_(c),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a);a.checkCharacter&&(this.checkChar=a.checkCharacter)}saveState(){var a=this.saveLegacyState(jq);return a!==null?a:this.getValueBoolean()}initView(){super.initView();var a=this.getTextElement();n(this.fieldGroup_,"blocklyCheckboxField");a.style.display=
1714
- this.value_?"block":"none";this.recomputeAriaContext()}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_());this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(a){this.checkChar=a||jq.CHECK_CHAR;this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(a){return a===!0||a==="TRUE"?"TRUE":a===!1||a==="FALSE"?"FALSE":null}doValueUpdate_(a){this.value_=this.convertValueToBool(a);this.textElement_&&
1713
+ this.precision_);this.decimalPlaces!==null&&(a=Number(a.toFixed(this.decimalPlaces)));return a}widgetCreate_(){var a=super.widgetCreate_();this.min_>-Infinity&&(a.min=`${this.min_}`);this.max_<Infinity&&(a.max=`${this.max_}`);return a}initView(){super.initView();this.fieldGroup_&&n(this.fieldGroup_,"blocklyNumberField")}static fromJson(a){return new this(a.value,void 0,void 0,void 0,void 0,a)}getAriaTypeName(){return this.ariaTypeName||$.C.ARIA_TYPE_FIELD_NUMBER}};jh("field_number",iq);
1714
+ iq.prototype.DEFAULT_VALUE=0;var jq=class extends bo{constructor(a,b,c){super(String(a!=null?a:""),b,c);this.EDITABLE=!1;this.SERIALIZABLE=!0}static fromJson(a){return new this(hg(a.text),void 0,a)}};jh("field_label_serializable",jq);var kq=class extends rg{constructor(a,b,c){super(rg.SKIP_SETUP);this.SERIALIZABLE=!0;this.value_=this.value_;this.checkChar=kq.CHECK_CHAR;a!==rg.SKIP_SETUP&&(c&&this.configure_(c),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a);a.checkCharacter&&(this.checkChar=a.checkCharacter)}saveState(){var a=this.saveLegacyState(kq);return a!==null?a:this.getValueBoolean()}initView(){super.initView();var a=this.getTextElement();n(this.fieldGroup_,"blocklyCheckboxField");a.style.display=
1715
+ this.value_?"block":"none";this.recomputeAriaContext()}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_());this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(a){this.checkChar=a||kq.CHECK_CHAR;this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(a){return a===!0||a==="TRUE"?"TRUE":a===!1||a==="FALSE"?"FALSE":null}doValueUpdate_(a){this.value_=this.convertValueToBool(a);this.textElement_&&
1715
1716
  (this.textElement_.style.display=this.value_?"block":"none");this.recomputeAriaContext()}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool(this.value_))}convertValueToBool(a){return typeof a==="string"?a==="TRUE":!!a}getAriaTypeName(){return this.ariaTypeName||$.C.ARIA_TYPE_FIELD_CHECKBOX}getAriaValue(){return this.convertValueToBool(this.value_)?$.C.FIELD_LABEL_CHECKBOX_CHECKED:$.C.FIELD_LABEL_CHECKBOX_UNCHECKED}static fromJson(a){return new this(a.checked,
1716
- void 0,a)}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement();l(a,p.HIDDEN,!1);ya(a,Ka.CHECKBOX);var b=this.convertValueToBool(this.value_);l(a,p.CHECKED,b);b=this.getAriaTypeName();l(a,p.LABEL,b);return!0}};jq.CHECK_CHAR="\u2713";jh("field_checkbox",jq);jq.prototype.DEFAULT_VALUE=!1;var kq=class{constructor(a){this.draggable=a;this.dragTarget=null;this.startLoc=a.getRelativeToSurfaceXY()}onDragStart(a){$.gd||$.B(!0);this.draggable=this.draggable.startDrag(a);this.startLoc=this.draggable.getRelativeToSurfaceXY();return this.draggable}onDrag(a,b){this.moveDraggable(a,b);if(a=a instanceof PointerEvent?a:null)a=new D(a.clientX,a.clientY),fi(this.draggable)&&this.draggable.setDeleteStyle(this.wouldDeleteDraggable(a,this.draggable)),this.updateDragTarget(a)}updateDragTarget(a){a=this.draggable.workspace.getDragTarget(a);
1717
- if(this.dragTarget!==a){let b;(b=this.dragTarget)==null||b.onDragExit(this.draggable);a==null||a.onDragEnter(this.draggable)}a==null||a.onDragOver(this.draggable);this.dragTarget=a}moveDraggable(a,b){b=this.pixelsToWorkspaceUnits(b);b=D.sum(this.startLoc,b);this.draggable.drag(b,a)}wouldDeleteDraggable(a,b){return(a=this.draggable.workspace.getDragTarget(a))&&this.draggable.workspace.getComponentManager().hasCapability(a.id,Dk.Capability.DELETE_AREA)?a.wouldDelete(b):!1}onDragEnd(a){var b=$.gd,c=
1718
- a instanceof PointerEvent?a:null;if(c){c=new D(c.clientX,c.clientY);if(this.draggable.workspace.getDragTarget(c)){var d;(d=this.dragTarget)==null||d.onDrop(this.draggable)}d=!1;this.shouldReturnToStart(c,this.draggable)&&(d=!0,this.draggable.revertDrag());(c=fi(this.draggable)&&this.wouldDeleteDraggable(c,this.draggable))&&fi(this.draggable)?(this.draggable.endDrag(a,Un.DELETE),$.B(b),this.draggable.dispose()):this.draggable.endDrag(a,d?Un.REVERT:Un.COMMIT);$.B(!1);!c&&$a(this.draggable)&&$.t().focusNode(this.draggable)}else this.draggable.endDrag(a,
1719
- Un.COMMIT),$a(this.draggable)&&$.t().focusNode(this.draggable)}onDragRevert(){this.draggable.revertDrag();$a(this.draggable)&&$.t().focusNode(this.draggable)}shouldReturnToStart(a,b){return(a=this.draggable.workspace.getDragTarget(a))?a.shouldPreventMove(b):!1}pixelsToWorkspaceUnits(a){a=new D(a.x/this.draggable.workspace.scale,a.y/this.draggable.workspace.scale);this.draggable.workspace.isMutator&&a.scale(1/this.draggable.workspace.options.parentWorkspace.scale);return a}};
1720
- A(y.BLOCK_DRAGGER,"default",kq);var lq={};lq.BlockDragStrategy=$n;lq.BubbleDragStrategy=qn;lq.CommentDragStrategy=cn;lq.Dragger=kq;var mq={};mq.BottomRow=Wp;mq.ConstantProvider=Rp;mq.Drawer=Sp;mq.PathObject=$p;mq.RenderInfo=Zp;mq.Renderer=aq;mq.RightConnectionShape=Xp;mq.StatementInput=Yj;mq.TopRow=Yp;ik();var nq={};nq.registerCleanup=Nj;nq.registerCollapse=Pj;nq.registerCollapseExpandBlock=ak;nq.registerComment=Xj;nq.registerCommentCreate=hk;nq.registerCommentDelete=fk;nq.registerCommentDuplicate=gk;nq.registerCommentOptions=function(){gk();fk();hk()};nq.registerDefaultOptions=ik;nq.registerDelete=dk;nq.registerDeleteAll=Uj;nq.registerDisable=ck;nq.registerDuplicate=Vj;nq.registerExpand=Qj;nq.registerHelp=ek;nq.registerInline=Zj;nq.registerRedo=Mj;nq.registerUndo=Lj;var oq=class{canConnect(a,b,c,d){return this.canConnectWithReason(a,b,c,d)===Bn.CAN_CONNECT}canConnectWithReason(a,b,c,d){var e=this.doSafetyChecks(a,b);return e!==Bn.CAN_CONNECT?e:this.doTypeChecks(a,b)?c&&!this.doDragChecks(a,b,d||0)?Bn.REASON_DRAG_CHECKS_FAILED:Bn.CAN_CONNECT:Bn.REASON_CHECKS_FAILED}getErrorMessage(a,b,c){switch(a){case Bn.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Bn.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Bn.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";
1721
- case Bn.REASON_TARGET_NULL:return"Target connection is null.";case Bn.REASON_CHECKS_FAILED:return"Connection checks failed. "+(b+" expected "+b.getCheck()+", found "+c.getCheck());case Bn.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Bn.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Bn.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(a,
1722
- b){if(!a||!b)return Bn.REASON_TARGET_NULL;if(a.isSuperior()){var c=a.getSourceBlock();var d=b.getSourceBlock();var e=b}else d=a.getSourceBlock(),c=b.getSourceBlock(),e=a,a=b;return c===d?Bn.REASON_SELF_CONNECTION:e.type!==Gn[a.type]?Bn.REASON_WRONG_TYPE:c.workspace!==d.workspace?Bn.REASON_DIFFERENT_WORKSPACES:c.isShadow()&&!d.isShadow()?Bn.REASON_SHADOW_PARENT:e.type===G.OUTPUT_VALUE&&d.previousConnection&&d.previousConnection.isConnected()||e.type===G.PREVIOUS_STATEMENT&&d.outputConnection&&d.outputConnection.isConnected()?
1723
- Bn.REASON_PREVIOUS_AND_OUTPUT:Bn.CAN_CONNECT}doTypeChecks(a,b){a=a.getCheck();b=b.getCheck();if(!a||!b)return!0;for(let c=0;c<a.length;c++)if(b.includes(a[c]))return!0;return!1}doDragChecks(a,b,c){if(a.distanceFrom(b)>c||b.getSourceBlock().isInsertionMarker())return!1;switch(b.type){case G.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(a,b);case G.OUTPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isInsertionMarker()||a.isConnected())return!1;break;case G.INPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isMovable()&&
1724
- !b.targetBlock().isShadow())return!1;break;case G.NEXT_STATEMENT:if(b.isConnected()&&!a.getSourceBlock().nextConnection&&!b.targetBlock().isShadow()&&b.targetBlock().nextConnection||b.targetBlock()&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow())return!1;break;default:return!1}return Vk.includes(b)?!1:!0}canConnectToPrevious_(a,b){if(a.targetConnection||Vk.includes(b))return!1;if(!b.targetConnection)return!0;a=b.targetBlock();return a.isInsertionMarker()?!a.getPreviousBlock():!1}};
1725
- A(y.CONNECTION_CHECKER,"default",oq);var pq=class{load(a,b){a=new Di(b.getWorkspace(),b.targetWorkspace,a,!1);a.show();return new go(a,"button")}gapForItem(a,b){return b}disposeItem(a){a=a.getElement();a instanceof Di&&a.dispose()}getType(){return"button"}};A(y.FLYOUT_INFLATER,"button",pq);var qq={};qq.Bubble=sn;qq.MiniWorkspaceBubble=tn;qq.TextBubble=bo;qq.TextInputBubble=zn;var rq=class{constructor(){this.permanentlyDisabledBlocks=new Set;this.listeners=new Map;this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(a,b){this.setFlyout(b);a=this.createBlock(a,b.getWorkspace());a.isEnabled()?this.updateStateBasedOnCapacity(a):this.permanentlyDisabledBlocks.add(a);a.getDescendants(!1).forEach(f=>{f.isInFlyout=!0;f=f.getFocusableElement();l(f,p.HIDDEN,!0);ya(f,Ka.NONE)});var c=a.getFocusableElement();za(c,p.HIDDEN);ya(c,Ka.OPTION);var d=a.getIcons().filter(f=>
1726
- {var g;return(g=f.isClickableInFlyout)==null?void 0:g.call(f,b.autoClose)}).map(f=>f.getFocusableElement().id).filter(f=>!!f),e=a.getConnections_(!0).map(f=>f.id);d=[...d,...e];d.length&&l(c,p.OWNS,d);this.addBlockListeners(a);return new go(a,"block")}createBlock(a,b){a.blockxml?(a=typeof a.blockxml==="string"?$.uc(a.blockxml):a.blockxml,b=Ng(a,b)):(a.enabled===void 0&&(a.enabled=a.disabled!=="true"&&a.disabled!==!0),a.disabledReasons===void 0&&a.enabled===!1&&(a.disabledReasons=["MANUALLY_DISABLED"]),
1717
+ void 0,a)}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement();l(a,p.HIDDEN,!1);ya(a,Ka.CHECKBOX);var b=this.convertValueToBool(this.value_);l(a,p.CHECKED,b);b=this.getAriaTypeName();l(a,p.LABEL,b);return!0}};kq.CHECK_CHAR="\u2713";jh("field_checkbox",kq);kq.prototype.DEFAULT_VALUE=!1;var lq=class{constructor(a){this.draggable=a;this.dragTarget=null;this.startLoc=a.getRelativeToSurfaceXY()}onDragStart(a){$.gd||$.B(!0);this.draggable=this.draggable.startDrag(a);this.startLoc=this.draggable.getRelativeToSurfaceXY();return this.draggable}onDrag(a,b){this.moveDraggable(a,b);if(a=a instanceof PointerEvent?a:null)a=new D(a.clientX,a.clientY),fi(this.draggable)&&this.draggable.setDeleteStyle(this.wouldDeleteDraggable(a,this.draggable)),this.updateDragTarget(a)}updateDragTarget(a){a=this.draggable.workspace.getDragTarget(a);
1718
+ if(this.dragTarget!==a){let b;(b=this.dragTarget)==null||b.onDragExit(this.draggable);a==null||a.onDragEnter(this.draggable)}a==null||a.onDragOver(this.draggable);this.dragTarget=a}moveDraggable(a,b){b=this.pixelsToWorkspaceUnits(b);b=D.sum(this.startLoc,b);this.draggable.drag(b,a)}wouldDeleteDraggable(a,b){return(a=this.draggable.workspace.getDragTarget(a))&&this.draggable.workspace.getComponentManager().hasCapability(a.id,Ek.Capability.DELETE_AREA)?a.wouldDelete(b):!1}onDragEnd(a){var b=$.gd,c=
1719
+ a instanceof PointerEvent?a:null;if(c){c=new D(c.clientX,c.clientY);if(this.draggable.workspace.getDragTarget(c)){var d;(d=this.dragTarget)==null||d.onDrop(this.draggable)}d=!1;this.shouldReturnToStart(c,this.draggable)&&(d=!0,this.draggable.revertDrag());(c=fi(this.draggable)&&this.wouldDeleteDraggable(c,this.draggable))&&fi(this.draggable)?(this.draggable.endDrag(a,Vn.DELETE),$.B(b),this.draggable.dispose()):this.draggable.endDrag(a,d?Vn.REVERT:Vn.COMMIT);$.B(!1);!c&&$a(this.draggable)&&$.t().focusNode(this.draggable)}else this.draggable.endDrag(a,
1720
+ Vn.COMMIT),$a(this.draggable)&&$.t().focusNode(this.draggable)}onDragRevert(){this.draggable.revertDrag();$a(this.draggable)&&$.t().focusNode(this.draggable)}shouldReturnToStart(a,b){return(a=this.draggable.workspace.getDragTarget(a))?a.shouldPreventMove(b):!1}pixelsToWorkspaceUnits(a){a=new D(a.x/this.draggable.workspace.scale,a.y/this.draggable.workspace.scale);this.draggable.workspace.isMutator&&a.scale(1/this.draggable.workspace.options.parentWorkspace.scale);return a}};
1721
+ A(y.BLOCK_DRAGGER,"default",lq);var mq={};mq.BlockDragStrategy=ao;mq.BubbleDragStrategy=rn;mq.CommentDragStrategy=dn;mq.Dragger=lq;var nq={};nq.BottomRow=Wp;nq.ConstantProvider=Sp;nq.Drawer=Tp;nq.PathObject=$p;nq.RenderInfo=Zp;nq.Renderer=aq;nq.RightConnectionShape=Xp;nq.StatementInput=Zj;nq.TopRow=Yp;jk();var oq={};oq.registerCleanup=Oj;oq.registerCollapse=Qj;oq.registerCollapseExpandBlock=ck;oq.registerComment=Yj;oq.registerCommentCreate=ik;oq.registerCommentDelete=gk;oq.registerCommentDuplicate=hk;oq.registerCommentOptions=function(){hk();gk();ik()};oq.registerDefaultOptions=jk;oq.registerDelete=ek;oq.registerDeleteAll=Vj;oq.registerDisable=dk;oq.registerDuplicate=Wj;oq.registerExpand=Rj;oq.registerHelp=fk;oq.registerInline=ak;oq.registerRedo=Nj;oq.registerUndo=Mj;var pq=class{canConnect(a,b,c,d){return this.canConnectWithReason(a,b,c,d)===Cn.CAN_CONNECT}canConnectWithReason(a,b,c,d){var e=this.doSafetyChecks(a,b);return e!==Cn.CAN_CONNECT?e:this.doTypeChecks(a,b)?c&&!this.doDragChecks(a,b,d||0)?Cn.REASON_DRAG_CHECKS_FAILED:Cn.CAN_CONNECT:Cn.REASON_CHECKS_FAILED}getErrorMessage(a,b,c){switch(a){case Cn.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Cn.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Cn.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";
1722
+ case Cn.REASON_TARGET_NULL:return"Target connection is null.";case Cn.REASON_CHECKS_FAILED:return"Connection checks failed. "+(b+" expected "+b.getCheck()+", found "+c.getCheck());case Cn.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Cn.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Cn.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(a,
1723
+ b){if(!a||!b)return Cn.REASON_TARGET_NULL;if(a.isSuperior()){var c=a.getSourceBlock();var d=b.getSourceBlock();var e=b}else d=a.getSourceBlock(),c=b.getSourceBlock(),e=a,a=b;return c===d?Cn.REASON_SELF_CONNECTION:e.type!==Hn[a.type]?Cn.REASON_WRONG_TYPE:c.workspace!==d.workspace?Cn.REASON_DIFFERENT_WORKSPACES:c.isShadow()&&!d.isShadow()?Cn.REASON_SHADOW_PARENT:e.type===G.OUTPUT_VALUE&&d.previousConnection&&d.previousConnection.isConnected()||e.type===G.PREVIOUS_STATEMENT&&d.outputConnection&&d.outputConnection.isConnected()?
1724
+ Cn.REASON_PREVIOUS_AND_OUTPUT:Cn.CAN_CONNECT}doTypeChecks(a,b){a=a.getCheck();b=b.getCheck();if(!a||!b)return!0;for(let c=0;c<a.length;c++)if(b.includes(a[c]))return!0;return!1}doDragChecks(a,b,c){if(a.distanceFrom(b)>c||b.getSourceBlock().isInsertionMarker())return!1;switch(b.type){case G.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(a,b);case G.OUTPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isInsertionMarker()||a.isConnected())return!1;break;case G.INPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isMovable()&&
1725
+ !b.targetBlock().isShadow())return!1;break;case G.NEXT_STATEMENT:if(b.isConnected()&&!a.getSourceBlock().nextConnection&&!b.targetBlock().isShadow()&&b.targetBlock().nextConnection||b.targetBlock()&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow())return!1;break;default:return!1}return Wk.includes(b)?!1:!0}canConnectToPrevious_(a,b){if(a.targetConnection||Wk.includes(b))return!1;if(!b.targetConnection)return!0;a=b.targetBlock();return a.isInsertionMarker()?!a.getPreviousBlock():!1}};
1726
+ A(y.CONNECTION_CHECKER,"default",pq);var qq=class{load(a,b){a=new Di(b.getWorkspace(),b.targetWorkspace,a,!1);a.show();return new ho(a,"button")}gapForItem(a,b){return b}disposeItem(a){a=a.getElement();a instanceof Di&&a.dispose()}getType(){return"button"}};A(y.FLYOUT_INFLATER,"button",qq);var rq={};rq.Bubble=tn;rq.MiniWorkspaceBubble=un;rq.TextBubble=co;rq.TextInputBubble=An;var sq=class{constructor(){this.permanentlyDisabledBlocks=new Set;this.listeners=new Map;this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(a,b){this.setFlyout(b);a=this.createBlock(a,b.getWorkspace());a.isEnabled()?this.updateStateBasedOnCapacity(a):this.permanentlyDisabledBlocks.add(a);a.getDescendants(!1).forEach(f=>{f.isInFlyout=!0;f=f.getFocusableElement();l(f,p.HIDDEN,!0);ya(f,Ka.NONE)});var c=a.getFocusableElement();za(c,p.HIDDEN);ya(c,Ka.OPTION);var d=a.getIcons().filter(f=>
1727
+ {var g;return(g=f.isClickableInFlyout)==null?void 0:g.call(f,b.autoClose)}).map(f=>f.getFocusableElement().id).filter(f=>!!f),e=a.getConnections_(!0).map(f=>f.id);d=[...d,...e];d.length&&l(c,p.OWNS,d);this.addBlockListeners(a);return new ho(a,"block")}createBlock(a,b){a.blockxml?(a=typeof a.blockxml==="string"?$.uc(a.blockxml):a.blockxml,b=Ng(a,b)):(a.enabled===void 0&&(a.enabled=a.disabled!=="true"&&a.disabled!==!0),a.disabledReasons===void 0&&a.enabled===!1&&(a.disabledReasons=["MANUALLY_DISABLED"]),
1727
1728
  "x"in a&&delete a.x,"y"in a&&delete a.y,b=de(a,b));return b}gapForItem(a,b){if(a.gap)var c=parseInt(String(a.gap));else a.blockxml&&(a=typeof a.blockxml==="string"?$.uc(a.blockxml):a.blockxml,c=parseInt(a.getAttribute("gap")));return!c||isNaN(c)?b:c}disposeItem(a){a=a.getElement();a instanceof ii&&(this.removeListeners(a.id),this.permanentlyDisabledBlocks.delete(a),a.dispose(!1,!1))}removeListeners(a){var b;((b=this.listeners.get(a))!=null?b:[]).forEach(c=>ka(c));this.listeners.delete(a)}setFlyout(a){if(this.flyout!==
1728
1729
  a){if(this.flyout){let c;(c=this.flyout.targetWorkspace)==null||c.removeChangeListener(this.capacityWrapper)}this.flyout=a;var b;(b=this.flyout.targetWorkspace)==null||b.addChangeListener(this.capacityWrapper)}}updateStateBasedOnCapacity(a){for(var b,c,d=(b=this.flyout)==null?void 0:(c=b.targetWorkspace)==null?void 0:c.isCapacityAvailable(ub(a));a;)a.setDisabledReason(!d,"WORKSPACE_AT_BLOCK_CAPACITY"),a=a.getNextBlock()}addBlockListeners(a){var b=[];b.push(k(a.getSvgRoot(),"pointerdown",a,c=>{var d,
1729
1730
  e,f=(d=this.flyout)==null?void 0:(e=d.targetWorkspace)==null?void 0:e.getGesture(c);f&&this.flyout&&(f.setStartBlock(a),f.handleFlyoutStart(c,this.flyout))}));b.push(ja(a.getSvgRoot(),"pointermove",null,()=>{var c,d;((c=this.flyout)==null?0:(d=c.targetWorkspace)==null?0:d.isDragging())||a.addSelect()}));b.push(ja(a.getSvgRoot(),"pointerleave",null,()=>{var c,d;((c=this.flyout)==null?0:(d=c.targetWorkspace)==null?0:d.isDragging())||a.removeSelect()}));this.listeners.set(a.id,b)}filterFlyoutBasedOnCapacity(a){!this.flyout||
1730
- a&&a.type!==v.BLOCK_CREATE&&a.type!==v.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(b=>{this.permanentlyDisabledBlocks.has(b)||this.updateStateBasedOnCapacity(b)})}getType(){return"block"}};A(y.FLYOUT_INFLATER,"block",rq);var sq={};sq.ConstantProvider=Gp;sq.Drawer=Ip;sq.HighlightConstantProvider=Jp;sq.Highlighter=Hp;sq.InlineInput=Kp;sq.PathObject=Np;sq.RenderInfo=Mp;sq.Renderer=Op;sq.StatementInput=Lp;var tq={};tq.RenderInfo=Pp;tq.Renderer=Qp;var uq=new nn("zelos",{colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",
1731
+ a&&a.type!==v.BLOCK_CREATE&&a.type!==v.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(b=>{this.permanentlyDisabledBlocks.has(b)||this.updateStateBasedOnCapacity(b)})}getType(){return"block"}};A(y.FLYOUT_INFLATER,"block",sq);var tq={};tq.ConstantProvider=Hp;tq.Drawer=Jp;tq.HighlightConstantProvider=Kp;tq.Highlighter=Ip;tq.InlineInput=Lp;tq.PathObject=Op;tq.RenderInfo=Np;tq.Renderer=Pp;tq.StatementInput=Mp;var uq={};uq.RenderInfo=Qp;uq.Renderer=Rp;var vq=new on("zelos",{colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",
1731
1732
  colourSecondary:"#FF4D6A",colourTertiary:"#FF3355"},text_blocks:{colourPrimary:"#FFBF00",colourSecondary:"#E6AC00",colourTertiary:"#CC9900"},variable_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},variable_dynamic_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},hat_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC",hat:"cap"}},{colour_category:{colour:"#CF63CF"},list_category:{colour:"#9966FF"},
1732
- logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}});var vq={Classic:on,Zelos:uq};var wq=class{constructor(a,b,c){this.id_=a.toolboxitemid||Lb();this.level_=(this.parent_=c||null)?this.parent_.getLevel()+1:0;this.toolboxItemDef_=a;this.parentToolbox_=b;this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(){}getFocusableElement(){var a=this.getDiv();if(!a)throw Error("Trying to access toolbox item before DOM is initialized.");
1733
- if(!(a instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return a}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getParentToolbox(){return this.parentToolbox_}};var xq=class extends wq{constructor(a,b,c){super(a,b,c);this.colour_=this.name_="";this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null;this.isDisabled_=this.isHidden_=!1;this.flyoutItems_=[];this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_);this.parseContents_(this.toolboxItemDef_);this.createDom_();this.toolboxItemDef_.hidden==="true"&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategoryContainer",row:"blocklyToolboxCategory",
1733
+ logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}});var wq={Classic:pn,Zelos:vq};var xq=class{constructor(a,b,c){this.id_=a.toolboxitemid||Lb();this.level_=(this.parent_=c||null)?this.parent_.getLevel()+1:0;this.toolboxItemDef_=a;this.parentToolbox_=b;this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(){}getFocusableElement(){var a=this.getDiv();if(!a)throw Error("Trying to access toolbox item before DOM is initialized.");
1734
+ if(!(a instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return a}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getParentToolbox(){return this.parentToolbox_}};var yq=class extends xq{constructor(a,b,c){super(a,b,c);this.colour_=this.name_="";this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null;this.isDisabled_=this.isHidden_=!1;this.flyoutItems_=[];this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_);this.parseContents_(this.toolboxItemDef_);this.createDom_();this.toolboxItemDef_.hidden==="true"&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategoryContainer",row:"blocklyToolboxCategory",
1734
1735
  rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyToolboxCategoryIcon",label:"blocklyToolboxCategoryLabel",contents:"blocklyToolboxCategoryGroup",selected:"blocklyToolboxSelected",openicon:"blocklyToolboxCategoryIconOpen",closedicon:"blocklyToolboxCategoryIconClosed"}}parseContents_(a){if("custom"in a)this.flyoutItems_=a.custom;else if(a=a.contents)for(let b=0;b<a.length;b++){let c=a[b];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(c)}}parseCategoryDef_(a){this.name_="name"in
1735
1736
  a?hg(a.name):"";this.colour_=this.getColour_(a);Object.assign(this.cssConfig_,a.cssconfig||a.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_();ya(this.htmlDiv_,Ka.TREEITEM);l(this.htmlDiv_,p.SELECTED,!1);l(this.htmlDiv_,p.LEVEL,this.level_+1);this.rowDiv_=this.createRowContainer_();this.rowDiv_.style.pointerEvents="auto";this.htmlDiv_.appendChild(this.rowDiv_);this.rowContents_=this.createRowContentsContainer_();this.rowContents_.style.pointerEvents="none";this.rowDiv_.appendChild(this.rowContents_);
1736
1737
  this.iconDom_=this.createIconDom_();ya(this.iconDom_,Ka.NONE);this.rowContents_.appendChild(this.iconDom_);this.labelDom_=this.createLabelDom_(this.name_);this.rowContents_.appendChild(this.labelDom_);var a=this.labelDom_.getAttribute("id");a&&l(this.htmlDiv_,p.LABELLEDBY,a);this.addColourBorder_(this.colour_);return this.htmlDiv_}createContainer_(){var a=document.createElement("div");a.tabIndex=-1;a.id=this.getId();var b=this.cssConfig_.container;b&&n(a,b);return a}createRowContainer_(){var a=document.createElement("div"),
1737
- b=this.cssConfig_.row;b&&n(a,b);b=`${xq.nestedPadding*this.getLevel()}px`;this.workspace_.RTL?a.style.paddingRight=b:a.style.paddingLeft=b;return a}createRowContentsContainer_(){var a=document.createElement("div"),b=this.cssConfig_.rowcontentcontainer;b&&n(a,b);return a}createIconDom_(){var a=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){let b=this.cssConfig_.icon;b&&n(a,b)}a.style.display="inline-block";return a}createLabelDom_(a){var b=document.createElement("span");b.setAttribute("id",
1738
- this.getId()+".label");b.textContent=a;(a=this.cssConfig_.label)&&n(b,a);return b}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_);this.addColourBorder_(this.colour_)}addColourBorder_(a){a&&(a=xq.borderWidth+"px solid "+(a||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=a:this.rowDiv_.style.borderLeft=a)}getColour_(a){var b=a.categorystyle||a.categoryStyle;if((a=a.colour)&&b)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(b)return this.getColourfromStyle(b);
1738
+ b=this.cssConfig_.row;b&&n(a,b);b=`${yq.nestedPadding*this.getLevel()}px`;this.workspace_.RTL?a.style.paddingRight=b:a.style.paddingLeft=b;return a}createRowContentsContainer_(){var a=document.createElement("div"),b=this.cssConfig_.rowcontentcontainer;b&&n(a,b);return a}createIconDom_(){var a=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){let b=this.cssConfig_.icon;b&&n(a,b)}a.style.display="inline-block";return a}createLabelDom_(a){var b=document.createElement("span");b.setAttribute("id",
1739
+ this.getId()+".label");b.textContent=a;(a=this.cssConfig_.label)&&n(b,a);return b}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_);this.addColourBorder_(this.colour_)}addColourBorder_(a){a&&(a=yq.borderWidth+"px solid "+(a||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=a:this.rowDiv_.style.borderLeft=a)}getColour_(a){var b=a.categorystyle||a.categoryStyle;if((a=a.colour)&&b)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(b)return this.getColourfromStyle(b);
1739
1740
  if(a)return this.parseColour(a)}return""}getColour(){return this.colour_}getColourfromStyle(a){var b=this.workspace_.getTheme();if(a&&b){if((b=b.categoryStyles[a])&&b.colour)return this.parseColour(b.colour);console.warn('Style "'+a+'" must exist and contain a colour value')}return""}getClickTarget(){return this.rowDiv_}parseColour(a){a=hg(a);if(a==null||a==="")return"";var b=Number(a);if(isNaN(b)){if(b=Zf(a))return b;console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+
1740
1741
  a);return""}return eg(b)}openIcon_(a){if(a){var b=this.cssConfig_.closedicon;b&&La(a,b);(b=this.cssConfig_.openicon)&&n(a,b)}}closeIcon_(a){if(a){var b=this.cssConfig_.openicon;b&&La(a,b);(b=this.cssConfig_.closedicon)&&n(a,b)}}setVisible_(a){this.htmlDiv_.style.display=a?"block":"none";this.isHidden_=!a;this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}hide(){this.setVisible_(!1)}show(){this.setVisible_(!0)}isVisible(){return!this.isHidden_&&this.allAncestorsExpanded_()}allAncestorsExpanded_(){for(var a=
1741
- this;a.getParent();)if(a=a.getParent(),!a.isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(){}setSelected(a){if(this.rowDiv_){var b=this.cssConfig_.selected;if(a){let c=this.parseColour(xq.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||c;b&&n(this.rowDiv_,b)}else this.rowDiv_.style.backgroundColor="",b&&Ma(this.rowDiv_,b);l(this.htmlDiv_,p.SELECTED,a)}}setDisabled(a){this.isDisabled_=a;this.getDiv().setAttribute("disabled",
1742
+ this;a.getParent();)if(a=a.getParent(),!a.isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(){}setSelected(a){if(this.rowDiv_){var b=this.cssConfig_.selected;if(a){let c=this.parseColour(yq.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||c;b&&n(this.rowDiv_,b)}else this.rowDiv_.style.backgroundColor="",b&&Ma(this.rowDiv_,b);l(this.htmlDiv_,p.SELECTED,a)}}setDisabled(a){this.isDisabled_=a;this.getDiv().setAttribute("disabled",
1742
1743
  `${a}`);a?this.getDiv().setAttribute("disabled","true"):this.getDiv().removeAttribute("disabled")}getName(){return this.name_}getParent(){return this.parent_}getDiv(){return this.htmlDiv_}onNodeFocus(){this.getParentToolbox().getSelectedItem()!==this&&this.getParentToolbox().setSelectedItem(this)}getContents(){return this.flyoutItems_}updateFlyoutContents(a){this.flyoutItems_=[];this.toolboxItemDef_=typeof a==="string"?{kind:this.toolboxItemDef_.kind,custom:a,id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,
1743
1744
  colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden}:{kind:this.toolboxItemDef_.kind,name:"name"in this.toolboxItemDef_?this.toolboxItemDef_.name:"",contents:Dc(a),id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden};this.parseContents_(this.toolboxItemDef_)}dispose(){Oa(this.htmlDiv_)}};
1744
- xq.registrationName="category";xq.nestedPadding=19;xq.borderWidth=8;xq.defaultBackgroundColour="#57e";ta('\n.blocklyToolboxCategory:not(.blocklyToolboxSelected):hover {\n background-color: rgba(255, 255, 255, .2);\n}\n\n.blocklyToolbox[layout="h"] .blocklyToolboxCategoryContainer {\n margin: 1px 5px 1px 0;\n}\n\n.blocklyToolbox[dir="RTL"][layout="h"] .blocklyToolboxCategoryContainer {\n margin: 1px 0 1px 5px;\n}\n\n.blocklyToolboxCategory {\n height: 22px;\n line-height: 22px;\n margin-bottom: 3px;\n padding-right: 8px;\n white-space: nowrap;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxCategory {\n margin-left: 8px;\n padding-right: 0;\n}\n\n.blocklyToolboxCategoryIcon {\n background-image: url(<<<PATH>>>/sprites.svg);\n height: 16px;\n vertical-align: middle;\n visibility: hidden;\n width: 16px;\n}\n\n.blocklyToolboxCategoryIconClosed {\n background-position: -32px -1px;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxCategoryIconClosed {\n background-position: 0 -1px;\n}\n\n.blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {\n background-position: -32px -17px;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {\n background-position: 0 -17px;\n}\n\n.blocklyToolboxCategoryIconOpen {\n background-position: -16px -1px;\n}\n\n.blocklyToolboxSelected>.blocklyToolboxCategoryIconOpen {\n background-position: -16px -17px;\n}\n\n.blocklyToolboxCategoryLabel {\n cursor: default;\n font: 16px sans-serif;\n padding: 0 3px;\n vertical-align: middle;\n}\n\n.blocklyToolboxDelete .blocklyToolboxCategoryLabel {\n cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxSelected .blocklyToolboxCategoryLabel {\n color: #fff;\n}\n');
1745
- A(y.TOOLBOX_ITEM,xq.registrationName,xq);var yq=class extends wq{constructor(a,b){super(a,b);this.cssConfig_={container:"blocklyTreeSeparator"};this.htmlDiv=null;Object.assign(this.cssConfig_,a.cssconfig||a.cssConfig)}init(){this.createDom_()}createDom_(){var a=document.createElement("div");a.id=this.getId();var b=this.cssConfig_.container;b&&n(a,b);ya(a,Ka.NONE);return this.htmlDiv=a}getDiv(){return this.htmlDiv}dispose(){Oa(this.htmlDiv)}canBeFocused(){return!1}};yq.registrationName="sep";ta('\n.blocklyTreeSeparator {\n border-bottom: solid #e5e5e5 1px;\n height: 0;\n margin: 5px 0;\n}\n\n.blocklyToolbox[layout="h"] .blocklyTreeSeparator {\n border-right: solid #e5e5e5 1px;\n border-bottom: none;\n height: auto;\n margin: 0 5px 0 5px;\n padding: 5px 0;\n width: 0;\n}\n');
1746
- A(y.TOOLBOX_ITEM,yq.registrationName,yq);var zq=class extends xq{constructor(a,b,c){super(a,b,c);this.subcategoriesDiv_=null;this.expanded_=!1;this.toolboxItems_=[]}makeDefaultCssConfig_(){var a=super.makeDefaultCssConfig_();a.contents="blocklyToolboxCategoryGroup";return a}parseContents_(a){if("custom"in a)this.flyoutItems_=a.custom;else{let b=a.contents;if(b){this.flyoutItems_=[];a=!0;for(let c=0;c<b.length;c++){let d=b[c];!Gb(y.TOOLBOX_ITEM,d.kind)||d.kind.toLowerCase()===yq.registrationName&&a?(this.flyoutItems_.push(d),a=!0):(this.createToolboxItem(d),
1747
- a=!1)}}}}createToolboxItem(a){var b=a.kind;b.toUpperCase()==="CATEGORY"&&Gc(a)&&(b=zq.registrationName);a=new (Fb(y.TOOLBOX_ITEM,b,void 0))(a,this.parentToolbox_,this);this.toolboxItems_.push(a)}init(){super.init();this.setExpanded(this.toolboxItemDef_.expanded==="true"||this.toolboxItemDef_.expanded===!0)}createDom_(){super.createDom_();var a=this.getChildToolboxItems();this.subcategoriesDiv_=this.createSubCategoriesDom_(a);ya(this.subcategoriesDiv_,Ka.GROUP);this.htmlDiv_.appendChild(this.subcategoriesDiv_);
1745
+ yq.registrationName="category";yq.nestedPadding=19;yq.borderWidth=8;yq.defaultBackgroundColour="#57e";ta('\n.blocklyToolboxCategory:not(.blocklyToolboxSelected):hover {\n background-color: rgba(255, 255, 255, .2);\n}\n\n.blocklyToolbox[layout="h"] .blocklyToolboxCategoryContainer {\n margin: 1px 5px 1px 0;\n}\n\n.blocklyToolbox[dir="RTL"][layout="h"] .blocklyToolboxCategoryContainer {\n margin: 1px 0 1px 5px;\n}\n\n.blocklyToolboxCategory {\n height: 22px;\n line-height: 22px;\n margin-bottom: 3px;\n padding-right: 8px;\n white-space: nowrap;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxCategory {\n margin-left: 8px;\n padding-right: 0;\n}\n\n.blocklyToolboxCategoryIcon {\n background-image: url(<<<PATH>>>/sprites.svg);\n height: 16px;\n vertical-align: middle;\n visibility: hidden;\n width: 16px;\n}\n\n.blocklyToolboxCategoryIconClosed {\n background-position: -32px -1px;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxCategoryIconClosed {\n background-position: 0 -1px;\n}\n\n.blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {\n background-position: -32px -17px;\n}\n\n.blocklyToolbox[dir="RTL"] .blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {\n background-position: 0 -17px;\n}\n\n.blocklyToolboxCategoryIconOpen {\n background-position: -16px -1px;\n}\n\n.blocklyToolboxSelected>.blocklyToolboxCategoryIconOpen {\n background-position: -16px -17px;\n}\n\n.blocklyToolboxCategoryLabel {\n cursor: default;\n font: 16px sans-serif;\n padding: 0 3px;\n vertical-align: middle;\n}\n\n.blocklyToolboxDelete .blocklyToolboxCategoryLabel {\n cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxSelected .blocklyToolboxCategoryLabel {\n color: #fff;\n}\n');
1746
+ A(y.TOOLBOX_ITEM,yq.registrationName,yq);var zq=class extends xq{constructor(a,b){super(a,b);this.cssConfig_={container:"blocklyTreeSeparator"};this.htmlDiv=null;Object.assign(this.cssConfig_,a.cssconfig||a.cssConfig)}init(){this.createDom_()}createDom_(){var a=document.createElement("div");a.id=this.getId();var b=this.cssConfig_.container;b&&n(a,b);ya(a,Ka.NONE);return this.htmlDiv=a}getDiv(){return this.htmlDiv}dispose(){Oa(this.htmlDiv)}canBeFocused(){return!1}};zq.registrationName="sep";ta('\n.blocklyTreeSeparator {\n border-bottom: solid #e5e5e5 1px;\n height: 0;\n margin: 5px 0;\n}\n\n.blocklyToolbox[layout="h"] .blocklyTreeSeparator {\n border-right: solid #e5e5e5 1px;\n border-bottom: none;\n height: auto;\n margin: 0 5px 0 5px;\n padding: 5px 0;\n width: 0;\n}\n');
1747
+ A(y.TOOLBOX_ITEM,zq.registrationName,zq);var Aq=class extends yq{constructor(a,b,c){super(a,b,c);this.subcategoriesDiv_=null;this.expanded_=!1;this.toolboxItems_=[]}makeDefaultCssConfig_(){var a=super.makeDefaultCssConfig_();a.contents="blocklyToolboxCategoryGroup";return a}parseContents_(a){if("custom"in a)this.flyoutItems_=a.custom;else{let b=a.contents;if(b){this.flyoutItems_=[];a=!0;for(let c=0;c<b.length;c++){let d=b[c];!Gb(y.TOOLBOX_ITEM,d.kind)||d.kind.toLowerCase()===zq.registrationName&&a?(this.flyoutItems_.push(d),a=!0):(this.createToolboxItem(d),
1748
+ a=!1)}}}}createToolboxItem(a){var b=a.kind;b.toUpperCase()==="CATEGORY"&&Gc(a)&&(b=Aq.registrationName);a=new (Fb(y.TOOLBOX_ITEM,b,void 0))(a,this.parentToolbox_,this);this.toolboxItems_.push(a)}init(){super.init();this.setExpanded(this.toolboxItemDef_.expanded==="true"||this.toolboxItemDef_.expanded===!0)}createDom_(){super.createDom_();var a=this.getChildToolboxItems();this.subcategoriesDiv_=this.createSubCategoriesDom_(a);ya(this.subcategoriesDiv_,Ka.GROUP);this.htmlDiv_.appendChild(this.subcategoriesDiv_);
1748
1749
  this.closeIcon_(this.iconDom_);l(this.htmlDiv_,p.EXPANDED,!1);return this.htmlDiv_}createIconDom_(){var a=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){let b=this.cssConfig_.icon;b&&n(a,b);a.style.visibility="visible"}a.style.display="inline-block";return a}createSubCategoriesDom_(a){var b=document.createElement("div");b.style.display="none";var c=this.cssConfig_.contents;c&&n(b,c);for(c=0;c<a.length;c++){let d=a[c];d.init();let e=d.getDiv();b.appendChild(e);if(d.getClickTarget){let f;
1749
1750
  (f=d.getClickTarget())==null||f.setAttribute("id",d.getId())}}return b}setExpanded(a){this.expanded_!==a&&((this.expanded_=a)?(this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_)):(this.setFlyoutVisible(!1),this.subcategoriesDiv_.style.display="none",this.closeIcon_(this.iconDom_)),l(this.htmlDiv_,p.EXPANDED,a),this.parentToolbox_.handleToolboxItemResize())}setVisible_(a){this.htmlDiv_.style.display=a?"block":"none";var b=this.getChildToolboxItems();for(let c=0;c<b.length;c++)b[c].setVisible_(a);
1750
1751
  this.isHidden_=!a;this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}isExpanded(){return this.expanded_}isCollapsible(){return!0}onClick(){if(this.flyoutItems_.length>0){var a=this.getParentToolbox();let b;a=a.getSelectedItem()===this&&((b=a.getFlyout())==null?void 0:b.isVisible());if(this.expanded_&&!a){this.setFlyoutVisible(!0);return}}this.toggleExpanded()}setFlyoutVisible(a){var b;(b=this.parentToolbox_.getFlyout())==null||b.setVisible(a)}toggleExpanded(){this.setExpanded(!this.expanded_)}getDiv(){return this.htmlDiv_}getChildToolboxItems(){return this.toolboxItems_}};
1751
- zq.registrationName="collapsibleCategory";A(y.TOOLBOX_ITEM,zq.registrationName,zq);var Aq=class extends fo{constructor(a){super();this.id="toolbox";this.contentsDiv_=this.HtmlDiv=null;this.isVisible_=!1;this.height_=this.width_=0;this.flyout=null;this.contents=new Map;this.previouslySelectedItem_=this.selectedItem_=null;this.boundEvents_=[];this.mouseDown=!1;this.navigator=new zo(this);this.workspace_=a;this.toolboxDef_=a.options.languageTree||{contents:[]};this.horizontalLayout=a.options.horizontalLayout;this.RTL=a.options.RTL;this.toolboxPosition=a.options.toolboxPosition}onShortcut(){return!1}init(){var a=
1752
+ Aq.registrationName="collapsibleCategory";A(y.TOOLBOX_ITEM,Aq.registrationName,Aq);var Bq=class extends go{constructor(a){super();this.id="toolbox";this.contentsDiv_=this.HtmlDiv=null;this.isVisible_=!1;this.height_=this.width_=0;this.flyout=null;this.contents=new Map;this.previouslySelectedItem_=this.selectedItem_=null;this.boundEvents_=[];this.mouseDown=!1;this.navigator=new Ao(this);this.workspace_=a;this.toolboxDef_=a.options.languageTree||{contents:[]};this.horizontalLayout=a.options.horizontalLayout;this.RTL=a.options.RTL;this.toolboxPosition=a.options.toolboxPosition}onShortcut(){return!1}init(){var a=
1752
1753
  this.workspace_,b=a.getParentSvg();this.flyout=this.createFlyout_();this.HtmlDiv=this.createDom_(this.workspace_);var c=this.flyout.createDom("svg");a.getInjectionDiv().insertBefore(c,b);n(c,"blocklyToolboxFlyout");this.setVisible(!0);this.flyout.init(a);this.render(this.toolboxDef_);a=a.getThemeManager();a.subscribe(this.HtmlDiv,"toolboxBackgroundColour","background-color");a.subscribe(this.HtmlDiv,"toolboxForegroundColour","color");this.workspace_.getComponentManager().addComponent({component:this,
1753
- weight:Dk.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Dk.Capability.AUTOHIDEABLE,Dk.Capability.DELETE_AREA,Dk.Capability.DRAG_TARGET]});$.t().registerTree(this,!0)}createDom_(a){a=a.getParentSvg();var b=this.createContainer_();b.id=Lb();this.contentsDiv_=this.createContentsContainer_();ya(this.contentsDiv_,Ka.TREE);b.appendChild(this.contentsDiv_);var c;(c=a.parentNode)==null||c.insertBefore(b,a);this.attachEvents_(b,this.contentsDiv_);return b}createContainer_(){var a=document.createElement("div");
1754
+ weight:Ek.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[Ek.Capability.AUTOHIDEABLE,Ek.Capability.DELETE_AREA,Ek.Capability.DRAG_TARGET]});$.t().registerTree(this,!0)}createDom_(a){a=a.getParentSvg();var b=this.createContainer_();b.id=Lb();this.contentsDiv_=this.createContentsContainer_();ya(this.contentsDiv_,Ka.TREE);b.appendChild(this.contentsDiv_);var c;(c=a.parentNode)==null||c.insertBefore(b,a);this.attachEvents_(b,this.contentsDiv_);return b}createContainer_(){var a=document.createElement("div");
1754
1755
  a.setAttribute("layout",this.isHorizontal()?"h":"v");n(a,"blocklyToolbox");a.setAttribute("dir",this.RTL?"RTL":"LTR");return a}createContentsContainer_(){var a=document.createElement("div");n(a,"blocklyToolboxCategoryGroup");this.isHorizontal()&&(a.style.flexDirection="row");return a}attachEvents_(a,b){var c=k(a,"pointerdown",this,this.onClick_,!1);this.boundEvents_.push(c);a=ja(a,"pointerup",this,()=>{this.mouseDown=!1});this.boundEvents_.push(a);b=k(b,"keydown",this,this.onKeyDown_,!1);this.boundEvents_.push(b)}onClick_(a){var b=
1755
1756
  ()=>{$.t().focusNode(this);this.clearSelection();kb.hideChaff(!1);a.preventDefault()};this.mouseDown=!0;if(na(a)||a.target===this.HtmlDiv)b();else{var c=a.target.getAttribute("id");c&&(c=this.getToolboxItemById(c),c==null?0:c.isSelectable())&&(c.onClick(a),c===this.getSelectedItem()?b():(this.setSelectedItem(c),kb.hideChaff(!0)))}ha=null}onKeyDown_(a){var b=!1;switch(a.key){case "ArrowLeft":b=this.toggleSelectedItem(!1);break;case "ArrowRight":b=this.toggleSelectedItem(!0);break;case "Escape":$.t().focusTree(this.getWorkspace()),
1756
1757
  b=!0}b&&(a.preventDefault(),a.stopPropagation())}createFlyout_(){var a=this.workspace_,b=a.copyOptionsForFlyout();b.toolboxPosition=a.options.toolboxPosition;return new (a.horizontalLayout?Jb(y.FLYOUTS_HORIZONTAL_TOOLBOX,a.options,!0):Jb(y.FLYOUTS_VERTICAL_TOOLBOX,a.options,!0))(b)}render(a){this.toolboxDef_=a;this.contents.forEach(b=>b.dispose());this.contents.clear();this.renderContents_(a.contents);this.position();this.handleToolboxItemResize()}renderContents_(a){var b=document.createDocumentFragment();
1757
- for(let d=0;d<a.length;d++)this.createToolboxItem(a[d],b);var c;(c=this.contentsDiv_)==null||c.appendChild(b)}createToolboxItem(a,b){var c=a.kind;c.toUpperCase()==="CATEGORY"&&Gc(a)&&(c=zq.registrationName);if(c=Hb(y.TOOLBOX_ITEM,c.toLowerCase())){a=new c(a,this);a.init();this.addToolboxItem_(a);(c=a.getDiv())&&b.appendChild(c);let d;(d=a.getClickTarget())==null||d.setAttribute("id",a.getId())}}addToolboxItem_(a){this.contents.set(a.getId(),a);if(a.isCollapsible()){a=a.getChildToolboxItems();for(let b=
1758
+ for(let d=0;d<a.length;d++)this.createToolboxItem(a[d],b);var c;(c=this.contentsDiv_)==null||c.appendChild(b)}createToolboxItem(a,b){var c=a.kind;c.toUpperCase()==="CATEGORY"&&Gc(a)&&(c=Aq.registrationName);if(c=Hb(y.TOOLBOX_ITEM,c.toLowerCase())){a=new c(a,this);a.init();this.addToolboxItem_(a);(c=a.getDiv())&&b.appendChild(c);let d;(d=a.getClickTarget())==null||d.setAttribute("id",a.getId())}}addToolboxItem_(a){this.contents.set(a.getId(),a);if(a.isCollapsible()){a=a.getChildToolboxItems();for(let b=
1758
1759
  0;b<a.length;b++)this.addToolboxItem_(a[b])}}getToolboxItems(){return[...this.contents.values()]}addStyle(a){a&&this.HtmlDiv&&n(this.HtmlDiv,a)}removeStyle(a){a&&this.HtmlDiv&&Ma(this.HtmlDiv,a)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var a=this.HtmlDiv.getBoundingClientRect(),b=a.top,c=b+a.height,d=a.left;a=d+a.width;return this.toolboxPosition===F.TOP?new cc(-1E7,c,-1E7,1E7):this.toolboxPosition===F.BOTTOM?new cc(b,1E7,-1E7,1E7):this.toolboxPosition===F.LEFT?new cc(-1E7,1E7,
1759
1760
  -1E7,a):new cc(-1E7,1E7,d,1E7)}onDragEnter(){ri.mover.isMoving()||this.updateCursorDeleteStyle_(!0)}onDragExit(){ri.mover.isMoving()||this.updateCursorDeleteStyle_(!1)}onDrop(){ri.mover.isMoving()||this.updateCursorDeleteStyle_(!1)}updateWouldDelete_(a){a!==this.wouldDelete_&&(this.updateCursorDeleteStyle_(!1),this.wouldDelete_=a,this.updateCursorDeleteStyle_(!0))}updateCursorDeleteStyle_(a){var b=this.wouldDelete_?"blocklyToolboxDelete":"blocklyToolboxGrab";a?this.addStyle(b):this.removeStyle(b)}getToolboxItemById(a){return this.contents.get(a)||
1760
1761
  null}getWidth(){return this.width_}getHeight(){return this.height_}getFlyout(){return this.flyout}getWorkspace(){return this.workspace_}getSelectedItem(){return this.selectedItem_}getPreviouslySelectedItem(){return this.previouslySelectedItem_}isHorizontal(){return this.horizontalLayout}position(){var a=this.workspace_.getMetrics(),b=this.HtmlDiv;if(b){this.horizontalLayout?(b.style.left="0",b.style.height="auto",b.style.width="100%",this.height_=b.offsetHeight,this.width_=a.viewWidth,this.toolboxPosition===
@@ -1765,17 +1766,17 @@ l(this.contentsDiv_,p.ACTIVEDESCENDANT,"")}selectItem_(a,b){this.selectedItem_=b
1765
1766
  a&&a.getName(),d=b&&b.getName();a===b&&(d=null);a=new (u(v.TOOLBOX_ITEM_SELECT))(c,d,this.workspace_.id);w(a)}toggleSelectedItem(a){var b,c;return bj(this.selectedItem_)&&((b=this.selectedItem_)==null?0:b.isCollapsible())&&((c=this.selectedItem_)==null?void 0:c.isExpanded())!==a?(this.selectedItem_.toggleExpanded(),!0):!1}dispose(){this.workspace_.getComponentManager().removeComponent("toolbox");var a;(a=this.flyout)==null||a.dispose();this.contents.forEach(b=>b.dispose());for(a=0;a<this.boundEvents_.length;a++)ka(this.boundEvents_[a]);
1766
1767
  this.boundEvents_=[];this.contents.clear();this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),Oa(this.HtmlDiv));$.t().unregisterTree(this)}getFocusableElement(){if(!this.HtmlDiv)throw Error("Toolbox DOM has not yet been created.");return this.HtmlDiv}getFocusableTree(){return this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(a){if(!a||a===this){let b;return(b=this.getToolboxItems().find(c=>c.isSelectable()))!=
1767
1768
  null?b:null}return null}getNestedTrees(){return[]}lookUpFocusableNode(a){return this.getToolboxItemById(a)}onTreeFocus(a){a!==this?this.getSelectedItem()===a||this.mouseDown||this.setSelectedItem(a):this.clearSelection()}onTreeBlur(a){var b;a&&a===((b=this.flyout)==null?void 0:b.getWorkspace())||this.autoHide(!1)}getNavigator(){return this.navigator}};ta('\n.blocklyToolboxDelete {\n cursor: url("<<<PATH>>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxGrab {\n cursor: url("<<<PATH>>>/handclosed.cur"), auto;\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n/* Category tree in Toolbox. */\n.blocklyToolbox {\n box-sizing: border-box;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n background-color: #ddd;\n overflow-x: visible;\n overflow-y: auto;\n padding: 4px 0 4px 0;\n position: absolute;\n z-index: 70; /* so blocks go under toolbox when dragging */\n -webkit-tap-highlight-color: transparent; /* issue #1345 */\n}\n\n.blocklyToolboxCategoryGroup {\n display: flex;\n flex-wrap: wrap;\n flex-direction: column;\n}\n\n.blocklyToolboxCategoryGroup:focus {\n outline: none;\n}\n');
1768
- A(y.TOOLBOX,"default",Aq);var Bq=G.INPUT_VALUE,Cq=G.OUTPUT_VALUE,Dq=G.NEXT_STATEMENT,Eq=G.PREVIOUS_STATEMENT,Fq=F.TOP,Gq=F.BOTTOM,Hq=F.LEFT,Iq=F.RIGHT;tp.prototype.newBlock=function(a,b){return new On(this,a,b)};$h.prototype.newBlock=function(a,b){return new ii(this,a,b)};tp.prototype.newComment=function(a){return new eh(this,a)};$h.prototype.newComment=function(a){return new dh(this,a)};$h.newTrashcan=function(a){return new yp(a)};tn.prototype.newWorkspaceSvg=function(a){return new $h(a)};
1769
- $.kj.prototype.populateProcedures=function(a){a=hj(a);a=a[0].concat(a[1]);for(let b=0;b<a.length;b++)this.getName(a[b][0],$.kj.NameType.PROCEDURE)};var R={};R.Block=On;R.BlockFlyoutInflater=rq;R.BlockNavigationPolicy=mo;R.BlockSvg=ii;R.Blocks=zb;R.BubbleNavigationPolicy=no;R.ButtonFlyoutInflater=pq;R.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";R.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";R.COLLAPSE_CHARS=30;R.CodeGenerator=$.dq;R.CollapsibleToolboxCategory=zq;
1770
- R.CommentBarButtonNavigationPolicy=oo;R.CommentEditorNavigationPolicy=po;R.ComponentManager=Dk;R.Connection=Bn;R.ConnectionChecker=oq;R.ConnectionDB=An;R.ConnectionNavigationPolicy=qo;R.ConnectionType=G;R.ContextMenu=Zm;R.ContextMenuItems=nq;R.ContextMenuRegistry=Kj;R.Css=Gk;R.DELETE_VARIABLE_ID="DELETE_VARIABLE_ID";R.DeleteArea=fo;R.Direction=si;R.DragDisposition=Un;R.DragTarget=eo;R.DropDownDiv=Tm;R.Events=N;R.Extensions=wn;R.Field=rg;R.FieldCheckbox=jq;R.FieldDropdown=zh;R.FieldImage=Tp;
1771
- R.FieldLabel=ao;R.FieldLabelSerializable=iq;R.FieldNavigationPolicy=ro;R.FieldNumber=hq;R.FieldTextInput=$.Vp;R.FieldVariable=gq;R.Flyout=Co;R.FlyoutButton=Di;R.FlyoutButtonNavigationPolicy=ko;R.FlyoutItem=go;R.FlyoutMetricsManager=io;R.FlyoutNavigator=Ao;R.FlyoutSeparator=jo;R.FlyoutSeparatorNavigationPolicy=lo;R.FocusManager=Za;R.FocusableTreeTraverser=Pk;R.Generator=$.dq;R.Gesture=Eo;R.Grid=Cj;R.HorizontalFlyout=fq;R.INPUT_VALUE=Bq;R.IconNavigationPolicy=so;R.Input=Jn;
1772
- R.InsertionMarkerPreviewer=bq;R.KeyboardMover=ri;R.KeyboardNavigationController=Lm;R.LabelFlyoutInflater=Ep;R.Menu=Ig;R.MenuItem=Kg;R.MetricsManager=ho;R.MoveIndicator=ln;R.Msg=$.C;R.NEXT_STATEMENT=Dq;R.Names=$.kj;R.NavigationDirection=vo;R.Navigator=xo;R.OPPOSITE_TYPE=Gn;R.OUTPUT_VALUE=Cq;R.Options=pn;R.PREVIOUS_STATEMENT=Eq;R.PROCEDURE_CATEGORY_NAME="PROCEDURE";R.Procedures=Lo;R.RENAME_VARIABLE_ID="RENAME_VARIABLE_ID";R.RenderedConnection=Mi;R.Scrollbar=Ic;R.ScrollbarPair=Gj;
1773
- R.SeparatorFlyoutInflater=Bo;R.ShortcutItems=Xn;R.ShortcutRegistry=x;R.TOOLBOX_AT_BOTTOM=Gq;R.TOOLBOX_AT_LEFT=Hq;R.TOOLBOX_AT_RIGHT=Iq;R.TOOLBOX_AT_TOP=Fq;R.Theme=nn;R.ThemeManager=rp;R.Themes=vq;R.Toast=li;R.Toolbox=Aq;R.ToolboxCategory=xq;R.ToolboxItem=wq;R.ToolboxItemNavigationPolicy=yo;R.ToolboxNavigator=zo;R.ToolboxSeparator=yq;R.Tooltip=Vm;R.Touch=lk;R.Trashcan=yp;R.UnattachedFieldError=lj;R.VARIABLE_CATEGORY_NAME="VARIABLE";R.VARIABLE_DYNAMIC_CATEGORY_NAME="VARIABLE_DYNAMIC";R.VERSION="13.2.1";
1774
- R.VariableMap=xp;R.VariableModel=wp;R.Variables=Mm;R.VariablesDynamic=sp;R.VerticalFlyout=eq;R.WidgetDiv=Ym;R.Workspace=tp;R.WorkspaceAudio=up;R.WorkspaceCommentNavigationPolicy=to;R.WorkspaceDragger=Do;R.WorkspaceNavigationPolicy=uo;R.WorkspaceSvg=$h;R.Xml=jn;R.ZoomControls=ql;R.blockAnimations=Pn;R.blockRendering=qp;R.browserEvents=Ak;R.bubbles=qq;R.bumpObjects=Rn;R.clipboard=Sn;R.comments=Tn;R.common=Wk;R.config=$.Og;
1775
- R.constants={COLLAPSED_FIELD_NAME:"_TEMP_COLLAPSED_FIELD",COLLAPSED_INPUT_NAME:"_TEMP_COLLAPSED_INPUT",MANUALLY_DISABLED:"MANUALLY_DISABLED"};R.defineBlocksWithJsonArray=xb;R.dialog=Bl;R.dragging=lq;R.fieldRegistry=kn;R.geras=sq;R.getFocusManager=$.t;R.getMainWorkspace=lb;R.getSelected=nb;R.hasBubble=xd;R.hideChaff=function(a){kb.hideChaff(a)};R.icons=Ho;
1776
- R.inject=function(a,b){var c=null;c=typeof a==="string"?document.getElementById(a)||document.querySelector(a):a;var d;if(!document.contains(c)&&document!==((d=c)==null?void 0:d.ownerDocument))throw Error("Error: container is not in current document");a=new pn(b||{});d=document.createElement("div");n(d,"injectionDiv");(b==null?0:b.rtl)&&n(d,"blocklyRTL");ya(d,Ka.APPLICATION);c.appendChild(d);b=Dj(d,a);var e=Ej(d,b,a);Ij(e);mb(e);tb(e);d.addEventListener("focusin",function(){mb(e)});k(d,"keydown",null,
1769
+ A(y.TOOLBOX,"default",Bq);var Cq=G.INPUT_VALUE,Dq=G.OUTPUT_VALUE,Eq=G.NEXT_STATEMENT,Fq=G.PREVIOUS_STATEMENT,Gq=F.TOP,Hq=F.BOTTOM,Iq=F.LEFT,Jq=F.RIGHT;up.prototype.newBlock=function(a,b){return new Pn(this,a,b)};$h.prototype.newBlock=function(a,b){return new ii(this,a,b)};up.prototype.newComment=function(a){return new eh(this,a)};$h.prototype.newComment=function(a){return new dh(this,a)};$h.newTrashcan=function(a){return new zp(a)};un.prototype.newWorkspaceSvg=function(a){return new $h(a)};
1770
+ $.kj.prototype.populateProcedures=function(a){a=hj(a);a=a[0].concat(a[1]);for(let b=0;b<a.length;b++)this.getName(a[b][0],$.kj.NameType.PROCEDURE)};var R={};R.Block=Pn;R.BlockFlyoutInflater=sq;R.BlockNavigationPolicy=no;R.BlockSvg=ii;R.Blocks=zb;R.BubbleNavigationPolicy=oo;R.ButtonFlyoutInflater=qq;R.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";R.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";R.COLLAPSE_CHARS=30;R.CodeGenerator=$.dq;R.CollapsibleToolboxCategory=Aq;
1771
+ R.CommentBarButtonNavigationPolicy=po;R.CommentEditorNavigationPolicy=qo;R.ComponentManager=Ek;R.Connection=Cn;R.ConnectionChecker=pq;R.ConnectionDB=Bn;R.ConnectionNavigationPolicy=ro;R.ConnectionType=G;R.ContextMenu=$m;R.ContextMenuItems=oq;R.ContextMenuRegistry=Lj;R.Css=Hk;R.DELETE_VARIABLE_ID="DELETE_VARIABLE_ID";R.DeleteArea=go;R.Direction=si;R.DragDisposition=Vn;R.DragTarget=fo;R.DropDownDiv=Um;R.Events=N;R.Extensions=xn;R.Field=rg;R.FieldCheckbox=kq;R.FieldDropdown=zh;R.FieldImage=Up;
1772
+ R.FieldLabel=bo;R.FieldLabelSerializable=jq;R.FieldNavigationPolicy=so;R.FieldNumber=iq;R.FieldTextInput=$.hq;R.FieldVariable=gq;R.Flyout=Do;R.FlyoutButton=Di;R.FlyoutButtonNavigationPolicy=lo;R.FlyoutItem=ho;R.FlyoutMetricsManager=jo;R.FlyoutNavigator=Bo;R.FlyoutSeparator=ko;R.FlyoutSeparatorNavigationPolicy=mo;R.FocusManager=Za;R.FocusableTreeTraverser=Qk;R.Generator=$.dq;R.Gesture=Fo;R.Grid=Dj;R.HorizontalFlyout=fq;R.INPUT_VALUE=Cq;R.IconNavigationPolicy=to;R.Input=Kn;
1773
+ R.InsertionMarkerPreviewer=bq;R.KeyboardMover=ri;R.KeyboardNavigationController=Mm;R.LabelFlyoutInflater=Fp;R.Menu=Ig;R.MenuItem=Kg;R.MetricsManager=io;R.MoveIndicator=mn;R.Msg=$.C;R.NEXT_STATEMENT=Eq;R.Names=$.kj;R.NavigationDirection=wo;R.Navigator=yo;R.OPPOSITE_TYPE=Hn;R.OUTPUT_VALUE=Dq;R.Options=qn;R.PREVIOUS_STATEMENT=Fq;R.PROCEDURE_CATEGORY_NAME="PROCEDURE";R.Procedures=Mo;R.RENAME_VARIABLE_ID="RENAME_VARIABLE_ID";R.RenderedConnection=Mi;R.Scrollbar=Ic;R.ScrollbarPair=Hj;
1774
+ R.SeparatorFlyoutInflater=Co;R.ShortcutItems=Yn;R.ShortcutRegistry=x;R.TOOLBOX_AT_BOTTOM=Hq;R.TOOLBOX_AT_LEFT=Iq;R.TOOLBOX_AT_RIGHT=Jq;R.TOOLBOX_AT_TOP=Gq;R.Theme=on;R.ThemeManager=sp;R.Themes=wq;R.Toast=li;R.Toolbox=Bq;R.ToolboxCategory=yq;R.ToolboxItem=xq;R.ToolboxItemNavigationPolicy=zo;R.ToolboxNavigator=Ao;R.ToolboxSeparator=zq;R.Tooltip=Wm;R.Touch=mk;R.Trashcan=zp;R.UnattachedFieldError=lj;R.VARIABLE_CATEGORY_NAME="VARIABLE";R.VARIABLE_DYNAMIC_CATEGORY_NAME="VARIABLE_DYNAMIC";R.VERSION="13.2.2-beta.0";
1775
+ R.VariableMap=yp;R.VariableModel=xp;R.Variables=Nm;R.VariablesDynamic=tp;R.VerticalFlyout=eq;R.WidgetDiv=Zm;R.Workspace=up;R.WorkspaceAudio=vp;R.WorkspaceCommentNavigationPolicy=uo;R.WorkspaceDragger=Eo;R.WorkspaceNavigationPolicy=vo;R.WorkspaceSvg=$h;R.Xml=kn;R.ZoomControls=rl;R.blockAnimations=Qn;R.blockRendering=rp;R.browserEvents=Bk;R.bubbles=rq;R.bumpObjects=Sn;R.clipboard=Tn;R.comments=Un;R.common=Xk;R.config=$.Og;
1776
+ R.constants={COLLAPSED_FIELD_NAME:"_TEMP_COLLAPSED_FIELD",COLLAPSED_INPUT_NAME:"_TEMP_COLLAPSED_INPUT",MANUALLY_DISABLED:"MANUALLY_DISABLED"};R.defineBlocksWithJsonArray=xb;R.dialog=Cl;R.dragging=mq;R.fieldRegistry=ln;R.geras=tq;R.getFocusManager=$.t;R.getMainWorkspace=lb;R.getSelected=nb;R.hasBubble=xd;R.hideChaff=function(a){kb.hideChaff(a)};R.icons=Io;
1777
+ R.inject=function(a,b){var c=null;c=typeof a==="string"?document.getElementById(a)||document.querySelector(a):a;var d;if(!document.contains(c)&&document!==((d=c)==null?void 0:d.ownerDocument))throw Error("Error: container is not in current document");a=new qn(b||{});d=document.createElement("div");n(d,"injectionDiv");(b==null?0:b.rtl)&&n(d,"blocklyRTL");ya(d,Ka.APPLICATION);c.appendChild(d);b=Ej(d,a);var e=Fj(d,b,a);Jj(e);mb(e);tb(e);d.addEventListener("focusin",function(){mb(e)});k(d,"keydown",null,
1777
1778
  Bb);Ea(d);return e};R.inputs=cq;R.isBoundedElement=function(a){return typeof a.getBoundingRectangle==="function"&&typeof a.moveBy==="function"};R.isCopyable=ei;R.isDeletable=fi;R.isDraggable=gi;R.isIcon=Ih;R.isObservable=fj;R.isPaster=function(a){return a&&typeof a.paste==="function"};R.isRenderedElement=function(a){return a&&typeof a.getSvgRoot==="function"};R.isSelectable=ab;R.isSerializable=Vc;R.isVariableBackedParameterModel=Ad;R.keyboardNavigationController=Nd;R.layers={BLOCK:50,BUBBLE:100};
1778
- R.navigateBlock=aj;R.procedures=Lo;R.registry=Yk;R.renderManagement=xl;R.serialization=Dp;R.setLocale=Xb;R.setParentContainer=sb;R.svgResize=tb;R.thrasos=tq;R.uiPosition=kl;R.utils=yn;R.zelos=mq;$.__chunk_blockly=R;
1779
+ R.navigateBlock=aj;R.procedures=Mo;R.registry=Zk;R.renderManagement=yl;R.serialization=Ep;R.setLocale=Xb;R.setParentContainer=sb;R.svgResize=tb;R.thrasos=uq;R.uiPosition=ll;R.utils=zn;R.zelos=nq;$.__chunk_blockly=R;
1779
1780
  $.__chunk_blockly.__namespace__=$;
1780
1781
  return $.__chunk_blockly;
1781
1782
  }));
@@ -2497,43 +2498,43 @@ return Blockly.Msg;
2497
2498
  }
2498
2499
  }(this, function(__parent__) {
2499
2500
  var $=__parent__.__namespace__;
2500
- var Jq=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();$.Rd(b,c)}},Kq=function(a){return function(){var b=a.getField("VAR").getVariable();b&&$.$d(b.getWorkspace(),b,a)}},Lq=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();$.Rd(b,c)}},Mq=function(a){return function(){var b=a.getField("VAR").getVariable();b&&$.$d(b.getWorkspace(),b,a)}},Nq=$.yb([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],
2501
+ var Kq=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();$.Rd(b,c)}},Lq=function(a){return function(){var b=a.getField("VAR").getVariable();b&&$.$d(b.getWorkspace(),b,a)}},Mq=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();$.Rd(b,c)}},Nq=function(a){return function(){var b=a.getField("VAR").getVariable();b&&$.$d(b.getWorkspace(),b,a)}},Oq=$.yb([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],
2501
2502
  output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_dynamic_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",
2502
2503
  extensions:["contextMenu_variableDynamicSetterGetter"]}]);
2503
2504
  $.ph("contextMenu_variableDynamicSetterGetter",{customContextMenu:function(a){if(!this.isInFlyout){if(this.type==="variables_get_dynamic"){var b="variables_set_dynamic";var c=$.C.VARIABLES_GET_CREATE_SET}else b="variables_get_dynamic",c=$.C.VARIABLES_SET_CREATE_GET;var d=this.getField("VAR");b={type:b,fields:{VAR:d.saveState(!0)}};a.push({enabled:this.workspace.remainingCapacity()>0,text:c.replace("%1",d.getText()),callback:$.Pg(this,b)})}else if(this.type==="variables_get_dynamic"||this.type==="variables_get_reporter_dynamic")d=
2504
- this.getField("VAR").getText(),c={text:$.C.RENAME_VARIABLE.replace("%1",d),enabled:!0,callback:Jq(this)},d={text:$.C.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:Kq(this)},a.unshift(c),a.unshift(d)},onchange:function(){var a=this.getFieldValue("VAR");a=$.Vd(this.workspace,a);this.type==="variables_get_dynamic"?this.outputConnection.setCheck(a.getType()):this.getInput("VALUE").connection.setCheck(a.getType())}});$.Ab(Nq);var Oq={blocks:Nq};var Pq=$.yb([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE",ariaLabelText:"%{BKY_INPUT_LABEL_VARIABLES_SET}"}],
2505
+ this.getField("VAR").getText(),c={text:$.C.RENAME_VARIABLE.replace("%1",d),enabled:!0,callback:Kq(this)},d={text:$.C.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:Lq(this)},a.unshift(c),a.unshift(d)},onchange:function(){var a=this.getFieldValue("VAR");a=$.Vd(this.workspace,a);this.type==="variables_get_dynamic"?this.outputConnection.setCheck(a.getType()):this.getInput("VALUE").connection.setCheck(a.getType())}});$.Ab(Oq);var Pq={blocks:Oq};var Qq=$.yb([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE",ariaLabelText:"%{BKY_INPUT_LABEL_VARIABLES_SET}"}],
2505
2506
  previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]);
2506
2507
  $.ph("contextMenu_variableSetterGetter",{customContextMenu:function(a){if(!this.isInFlyout){if(this.type==="variables_get"){var b="variables_set";var c=$.C.VARIABLES_GET_CREATE_SET}else b="variables_get",c=$.C.VARIABLES_SET_CREATE_GET;var d=this.getField("VAR");b={type:b,fields:{VAR:d.saveState(!0)}};a.push({enabled:this.workspace.remainingCapacity()>0,text:c.replace("%1",d.getText()),callback:$.Pg(this,b)})}else if(this.type==="variables_get"||this.type==="variables_get_reporter")d=this.getField("VAR").getText(),
2507
- c={text:$.C.RENAME_VARIABLE.replace("%1",d),enabled:!0,callback:Lq(this)},d={text:$.C.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:Mq(this)},a.unshift(c),a.unshift(d)}});$.Ab(Pq);var Qq={blocks:Pq};var Rq=$.yb([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",
2508
+ c={text:$.C.RENAME_VARIABLE.replace("%1",d),enabled:!0,callback:Mq(this)},d={text:$.C.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:Nq(this)},a.unshift(c),a.unshift(d)}});$.Ab(Qq);var Rq={blocks:Qq};var Sq=$.yb([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",
2508
2509
  args0:[{type:"input_dummy"},{type:"input_statement",name:"STACK"}],style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_TOOLTIP}",enableContextMenu:!1},{type:"text_create_join_item",message0:"%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}",previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}",enableContextMenu:!1},{type:"text_append",message0:"%{BKY_TEXT_APPEND_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_TEXT_APPEND_VARIABLE}"},{type:"input_value",
2509
2510
  name:"TEXT",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_APPEND}"}],previousStatement:null,nextStatement:null,style:"text_blocks",extensions:["text_append_tooltip"]},{type:"text_length",message0:"%{BKY_TEXT_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"],ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"}],output:"Number",style:"text_blocks",tooltip:"%{BKY_TEXT_LENGTH_TOOLTIP}",helpUrl:"%{BKY_TEXT_LENGTH_HELPURL}"},{type:"text_isEmpty",message0:"%{BKY_TEXT_ISEMPTY_TITLE}",args0:[{type:"input_value",
2510
2511
  name:"VALUE",check:["String","Array"],ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"}],output:"Boolean",style:"text_blocks",tooltip:"%{BKY_TEXT_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_TEXT_ISEMPTY_HELPURL}"},{type:"text_indexOf",message0:"%{BKY_TEXT_INDEXOF_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"},{type:"field_dropdown",name:"END",options:[["%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}","FIRST"],["%{BKY_TEXT_INDEXOF_OPERATOR_LAST}","LAST"]]},
2511
2512
  {type:"input_value",name:"FIND",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_FIND}"}],output:"Number",style:"text_blocks",helpUrl:"%{BKY_TEXT_INDEXOF_HELPURL}",inputsInline:!0,extensions:["text_indexOf_tooltip"]},{type:"text_charAt",message0:"%{BKY_TEXT_CHARAT_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"},{type:"field_dropdown",name:"WHERE",options:[["%{BKY_TEXT_CHARAT_FROM_START}","FROM_START","%{BKY_TEXT_FROM_START_ARIA}"],
2512
2513
  ["%{BKY_TEXT_CHARAT_FROM_END}","FROM_END","%{BKY_TEXT_FROM_END_ARIA}"],["%{BKY_TEXT_CHARAT_FIRST}","FIRST"],["%{BKY_TEXT_CHARAT_LAST}","LAST"],["%{BKY_TEXT_CHARAT_RANDOM}","RANDOM"]]}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_CHARAT_HELPURL}",inputsInline:!0,mutator:"text_charAt_mutator"}]);
2513
- Rq.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[$.C.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START",$.C.TEXT_FROM_START_ARIA],[$.C.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END",$.C.TEXT_FROM_END_ARIA],[$.C.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[$.C.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START",$.C.TEXT_FROM_START_ARIA],[$.C.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END",$.C.TEXT_FROM_END_ARIA],[$.C.TEXT_GET_SUBSTRING_END_LAST,"LAST"]];this.setHelpUrl($.C.TEXT_GET_SUBSTRING_HELPURL);
2514
+ Sq.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[$.C.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START",$.C.TEXT_FROM_START_ARIA],[$.C.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END",$.C.TEXT_FROM_END_ARIA],[$.C.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[$.C.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START",$.C.TEXT_FROM_START_ARIA],[$.C.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END",$.C.TEXT_FROM_END_ARIA],[$.C.TEXT_GET_SUBSTRING_END_LAST,"LAST"]];this.setHelpUrl($.C.TEXT_GET_SUBSTRING_HELPURL);
2514
2515
  this.setStyle("text_blocks");this.appendValueInput("STRING").setCheck("String").appendField($.C.TEXT_GET_SUBSTRING_INPUT_IN_TEXT).setAriaLabelProvider($.C.INPUT_LABEL_TEXT_TO_CHECK);var a=b=>{var c=$.lh({type:"field_dropdown",options:this["WHERE_OPTIONS_"+b]});c.setValidator(function(d){var e=this.getValue();d=d==="FROM_START"||d==="FROM_END";d!==(e==="FROM_START"||e==="FROM_END")&&this.getSourceBlock().updateAt_(b,d)});return c};this.appendDummyInput("WHERE1_INPUT").appendField(a(1),"WHERE1");this.appendDummyInput("AT1");
2515
- this.appendDummyInput("WHERE2_INPUT").appendField(a(2),"WHERE2");this.appendDummyInput("AT2");$.C.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField($.C.TEXT_GET_SUBSTRING_TAIL);this.setInputsInline(!0);this.setOutput(!0,"String");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip($.C.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var a=$.rc("mutation"),b=this.getInput("AT1")instanceof $.Nn;a.setAttribute("at1",`${b}`);b=this.getInput("AT2")instanceof $.Nn;a.setAttribute("at2",
2516
+ this.appendDummyInput("WHERE2_INPUT").appendField(a(2),"WHERE2");this.appendDummyInput("AT2");$.C.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField($.C.TEXT_GET_SUBSTRING_TAIL);this.setInputsInline(!0);this.setOutput(!0,"String");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip($.C.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var a=$.rc("mutation"),b=this.getInput("AT1")instanceof $.On;a.setAttribute("at1",`${b}`);b=this.getInput("AT2")instanceof $.On;a.setAttribute("at2",
2516
2517
  `${b}`);return a},domToMutation:function(a){var b=a.getAttribute("at1")==="true";a=a.getAttribute("at2")==="true";this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number").setAriaLabelProvider(a===1?$.C.INPUT_LABEL_TEXT_START_POSITION:$.C.INPUT_LABEL_TEXT_END_POSITION),$.C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField($.C.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+
2517
2518
  a);a===2&&$.C.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField($.C.TEXT_GET_SUBSTRING_TAIL));a===1&&(this.moveInputBefore("AT1","WHERE2_INPUT"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","WHERE2_INPUT"))}};
2518
- Rq.text_changeCase={init:function(){var a=[[$.C.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[$.C.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[$.C.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl($.C.TEXT_CHANGECASE_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField($.lh({type:"field_dropdown",options:a}),"CASE").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_TO_CHANGE);this.setOutput(!0,"String");this.setTooltip($.C.TEXT_CHANGECASE_TOOLTIP)}};
2519
- Rq.text_trim={init:function(){var a=[[$.C.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[$.C.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[$.C.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl($.C.TEXT_TRIM_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField($.lh({type:"field_dropdown",options:a}),"MODE").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_TO_CHANGE);this.setOutput(!0,"String");this.setTooltip($.C.TEXT_TRIM_TOOLTIP)}};
2520
- Rq.text_print={init:function(){this.jsonInit({message0:$.C.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:$.C.TEXT_PRINT_TOOLTIP,helpUrl:$.C.TEXT_PRINT_HELPURL})}};var Sq={updateType_:function(a){this.outputConnection.setCheck(a==="NUMBER"?"Number":"String")},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
2521
- Rq.text_prompt_ext=Object.assign({},Sq,{init:function(){var a=[[$.C.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[$.C.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl($.C.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");a=$.lh({type:"field_dropdown",options:a});a.setValidator(b=>{this.updateType_(b)});this.appendValueInput("TEXT").appendField(a,"TYPE").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_PROMPT_MESSAGE);this.setOutput(!0,"String");this.setTooltip(()=>this.getFieldValue("TYPE")==="TEXT"?$.C.TEXT_PROMPT_TOOLTIP_TEXT:
2519
+ Sq.text_changeCase={init:function(){var a=[[$.C.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[$.C.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[$.C.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl($.C.TEXT_CHANGECASE_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField($.lh({type:"field_dropdown",options:a}),"CASE").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_TO_CHANGE);this.setOutput(!0,"String");this.setTooltip($.C.TEXT_CHANGECASE_TOOLTIP)}};
2520
+ Sq.text_trim={init:function(){var a=[[$.C.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[$.C.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[$.C.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl($.C.TEXT_TRIM_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField($.lh({type:"field_dropdown",options:a}),"MODE").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_TO_CHANGE);this.setOutput(!0,"String");this.setTooltip($.C.TEXT_TRIM_TOOLTIP)}};
2521
+ Sq.text_print={init:function(){this.jsonInit({message0:$.C.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:$.C.TEXT_PRINT_TOOLTIP,helpUrl:$.C.TEXT_PRINT_HELPURL})}};var Tq={updateType_:function(a){this.outputConnection.setCheck(a==="NUMBER"?"Number":"String")},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
2522
+ Sq.text_prompt_ext=Object.assign({},Tq,{init:function(){var a=[[$.C.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[$.C.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl($.C.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");a=$.lh({type:"field_dropdown",options:a});a.setValidator(b=>{this.updateType_(b)});this.appendValueInput("TEXT").appendField(a,"TYPE").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_PROMPT_MESSAGE);this.setOutput(!0,"String");this.setTooltip(()=>this.getFieldValue("TYPE")==="TEXT"?$.C.TEXT_PROMPT_TOOLTIP_TEXT:
2522
2523
  $.C.TEXT_PROMPT_TOOLTIP_NUMBER)}});
2523
- Rq.text_prompt=Object.assign({},Sq,{init:function(){this.mixin(Tq);var a=[[$.C.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[$.C.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl($.C.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");a=$.lh({type:"field_dropdown",options:a});a.setValidator(b=>{this.updateType_(b)});this.appendDummyInput().appendField(a,"TYPE").appendField(this.newQuote_(!0)).appendField($.lh({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");this.setTooltip(()=>
2524
- this.getFieldValue("TYPE")==="TEXT"?$.C.TEXT_PROMPT_TOOLTIP_TEXT:$.C.TEXT_PROMPT_TOOLTIP_NUMBER)}});Rq.text_count={init:function(){this.jsonInit({message0:$.C.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_FIND}"},{type:"input_value",name:"TEXT",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:$.C.TEXT_COUNT_TOOLTIP,helpUrl:$.C.TEXT_COUNT_HELPURL})}};
2525
- Rq.text_replace={init:function(){this.jsonInit({message0:$.C.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_FIND}"},{type:"input_value",name:"TO",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_REPLACE}"},{type:"input_value",name:"TEXT",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:$.C.TEXT_REPLACE_TOOLTIP,helpUrl:$.C.TEXT_REPLACE_HELPURL})}};
2526
- Rq.text_reverse={init:function(){this.jsonInit({message0:$.C.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHANGE}"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:$.C.TEXT_REVERSE_TOOLTIP,helpUrl:$.C.TEXT_REVERSE_HELPURL})}};
2527
- var Tq={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",
2524
+ Sq.text_prompt=Object.assign({},Tq,{init:function(){this.mixin(Uq);var a=[[$.C.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[$.C.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl($.C.TEXT_PROMPT_HELPURL);this.setStyle("text_blocks");a=$.lh({type:"field_dropdown",options:a});a.setValidator(b=>{this.updateType_(b)});this.appendDummyInput().appendField(a,"TYPE").appendField(this.newQuote_(!0)).appendField($.lh({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");this.setTooltip(()=>
2525
+ this.getFieldValue("TYPE")==="TEXT"?$.C.TEXT_PROMPT_TOOLTIP_TEXT:$.C.TEXT_PROMPT_TOOLTIP_NUMBER)}});Sq.text_count={init:function(){this.jsonInit({message0:$.C.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_FIND}"},{type:"input_value",name:"TEXT",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:$.C.TEXT_COUNT_TOOLTIP,helpUrl:$.C.TEXT_COUNT_HELPURL})}};
2526
+ Sq.text_replace={init:function(){this.jsonInit({message0:$.C.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_FIND}"},{type:"input_value",name:"TO",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_REPLACE}"},{type:"input_value",name:"TEXT",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHECK}"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:$.C.TEXT_REPLACE_TOOLTIP,helpUrl:$.C.TEXT_REPLACE_HELPURL})}};
2527
+ Sq.text_reverse={init:function(){this.jsonInit({message0:$.C.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String",ariaLabelText:"%{BKY_INPUT_LABEL_TEXT_TO_CHANGE}"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:$.C.TEXT_REVERSE_TOOLTIP,helpUrl:$.C.TEXT_REVERSE_HELPURL})}};
2528
+ var Uq={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",
2528
2529
  QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(a){for(let b=0,c;c=this.inputList[b];b++)for(let d=0,e;e=c.fieldRow[d];d++)if(a===e.name){c.insertFieldAt(d,this.newQuote_(!0));c.insertFieldAt(d+2,this.newQuote_(!1));return}console.warn('field named "'+a+'" not found in '+this.toDevString())},newQuote_:function(a){a=this.RTL?!a:a;return $.lh({type:"field_image",src:a?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,width:this.QUOTE_IMAGE_WIDTH,height:this.QUOTE_IMAGE_HEIGHT,
2529
- alt:a?"\u201c":"\u201d"})}};$.oh("text_append_tooltip",$.Ah("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));$.oh("text_indexOf_tooltip",function(){this.setTooltip(()=>$.C.TEXT_INDEXOF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))});$.oh("text_quotes",function(){this.mixin(Tq);this.quoteField_("TEXT")});$.ph("quote_image_mixin",Tq);
2530
+ alt:a?"\u201c":"\u201d"})}};$.oh("text_append_tooltip",$.Ah("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));$.oh("text_indexOf_tooltip",function(){this.setTooltip(()=>$.C.TEXT_INDEXOF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))});$.oh("text_quotes",function(){this.mixin(Uq);this.quoteField_("TEXT")});$.ph("quote_image_mixin",Uq);
2530
2531
  $.th("text_join_mutator",{itemCount_:0,mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("items",`${this.itemCount_}`);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(a){this.itemCount_=a.itemCount;this.updateShape_()},decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();var c,d=(c=b.getInput("STACK"))==null?void 0:
2531
2532
  c.connection;for(c=0;c<this.itemCount_;c++){let e=a.newBlock("text_create_join_item");e.initSvg();if(e.previousConnection){let f;(f=d)==null||f.connect(e.previousConnection)}d=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)b.isInsertionMarker()||a.push(b.valueConnection_),b=b.getNextBlock();for(b=0;b<this.itemCount_;b++){let c=this.getInput("ADD"+b).connection.targetConnection;c&&!a.includes(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();
2532
2533
  for(b=0;b<this.itemCount_;b++){let c;(c=a[b])==null||c.reconnect(this,"ADD"+b)}},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){if(a.isInsertionMarker()){a=a.getNextBlock();continue}let c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;a=a.getNextBlock();b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));
2533
- for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){let b=this.appendValueInput("ADD"+a).setAlign($.En.RIGHT).setAriaLabelProvider($.C.INPUT_LABEL_TEXT_JOIN_ITEM.replace("%1",(a+1).toString()));a===0&&b.appendField($.C.TEXT_JOIN_TITLE_CREATEWITH)}for(a=this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}},function(){this.mixin(Tq);this.itemCount_=2;this.updateShape_();this.setMutator(new $.sh(["text_create_join_item"],this))});
2534
+ for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){let b=this.appendValueInput("ADD"+a).setAlign($.Fn.RIGHT).setAriaLabelProvider($.C.INPUT_LABEL_TEXT_JOIN_ITEM.replace("%1",(a+1).toString()));a===0&&b.appendField($.C.TEXT_JOIN_TITLE_CREATEWITH)}for(a=this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}},function(){this.mixin(Uq);this.itemCount_=2;this.updateShape_();this.setMutator(new $.sh(["text_create_join_item"],this))});
2534
2535
  $.th("text_charAt_mutator",{isAt_:!1,mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("at",`${this.isAt_}`);return a},domToMutation:function(a){a=a.getAttribute("at")!=="false";this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT",!0);this.removeInput("ORDINAL",!0);a&&(this.appendValueInput("AT").setCheck("Number").setAriaLabelProvider($.C.INPUT_LABEL_TEXT_POSITION),$.C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.C.ORDINAL_NUMBER_SUFFIX));$.C.TEXT_CHARAT_TAIL&&
2535
2536
  (this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField($.C.TEXT_CHARAT_TAIL));this.isAt_=a}},function(){this.getField("WHERE").setValidator(function(a){a=a==="FROM_START"||a==="FROM_END";var b=this.getSourceBlock();a!==b.isAt_&&b.updateAt_(a)});this.updateAt_(!0);this.setTooltip(()=>{var a=this.getFieldValue("WHERE"),b=$.C.TEXT_CHARAT_TOOLTIP;(a==="FROM_START"||a==="FROM_END")&&(a=a==="FROM_START"?$.C.LISTS_INDEX_FROM_START_TOOLTIP:$.C.LISTS_INDEX_FROM_END_TOOLTIP)&&(b+=" "+a.replace("%1",
2536
- this.workspace.options.oneBasedIndex?"#1":"#0"));return b})});$.Ab(Rq);var Uq={blocks:Rq};var Vq={},Wq={setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField($.C.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){var a="";this.arguments_.length&&(a=$.C.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));$.Ub++;try{this.setFieldValue(a,"PARAMS")}finally{$.Ub--}},mutationToDom:function(a){var b=$.rc("mutation");a&&b.setAttribute("name",
2537
+ this.workspace.options.oneBasedIndex?"#1":"#0"));return b})});$.Ab(Sq);var Vq={blocks:Sq};var Wq={},Xq={setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField($.C.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){var a="";this.arguments_.length&&(a=$.C.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));$.Ub++;try{this.setFieldValue(a,"PARAMS")}finally{$.Ub--}},mutationToDom:function(a){var b=$.rc("mutation");a&&b.setAttribute("name",
2537
2538
  this.getFieldValue("NAME"));for(let c=0;c<this.argumentVarModels_.length;c++){let d=$.rc("arg"),e=this.argumentVarModels_[c];d.setAttribute("name",e.getName());d.setAttribute("varid",e.getId());a&&this.paramIds_&&d.setAttribute("paramId",this.paramIds_[c]);b.appendChild(d)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];this.argumentVarModels_=[];for(let c=0,d;d=a.childNodes[c];c++)if(d.nodeName.toLowerCase()==="arg"){var b=d;let e=
2538
2539
  b.getAttribute("name");b=b.getAttribute("varid")||b.getAttribute("varId");this.arguments_.push(e);b=$.Wd(this.workspace,b,e,"");b!==null?this.argumentVarModels_.push(b):console.log(`Failed to create a variable named "${e}", ignoring.`)}this.updateParams_();$.sj(this);this.setStatements_(a.getAttribute("statements")!=="false")},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;var a=Object.create(null);if(this.argumentVarModels_.length){a.params=[];for(let b=
2539
2540
  0;b<this.argumentVarModels_.length;b++)a.params.push({name:this.argumentVarModels_[b].getName(),id:this.argumentVarModels_[b].getId()})}this.hasStatements_||(a.hasStatements=!1);return a},loadExtraState:function(a){this.arguments_=[];this.argumentVarModels_=[];if(a.params)for(let c=0;c<a.params.length;c++){var b=a.params[c];b=$.Wd(this.workspace,b.id,b.name,"");this.arguments_.push(b.getName());this.argumentVarModels_.push(b)}this.updateParams_();$.sj(this);this.setStatements_(a.hasStatements===!1?
@@ -2543,30 +2544,30 @@ null&&(a=a==="TRUE",this.hasStatements_!==a))if(a){this.setStatements_(!0);var d
2543
2544
  c.getName();b=this.workspace.getVariableMap().getVariableById(b);var d=!1;for(let e=0;e<this.argumentVarModels_.length;e++)this.argumentVarModels_[e].getId()===a&&(this.arguments_[e]=b.getName(),this.argumentVarModels_[e]=b,d=!0);d&&(this.displayRenamedVar_(c,b.getName()),$.sj(this))}},updateVarName:function(a){var b=a.getName(),c=!1;for(let e=0;e<this.argumentVarModels_.length;e++)if(this.argumentVarModels_[e].getId()===a.getId()){var d=this.arguments_[e];this.arguments_[e]=b;c=!0}c&&(this.displayRenamedVar_(d,
2544
2545
  b),$.sj(this))},displayRenamedVar_:function(a,b){this.updateParams_();var c=this.getIcon($.sh.TYPE);if(c&&c.bubbleIsVisible()){c=c.getWorkspace().getAllBlocks(!1);for(let d=0,e;e=c[d];d++)e.type==="procedures_mutatorarg"&&$.kj.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")}},customContextMenu:function(a){if(!this.isInFlyout){var b=this.getFieldValue("NAME"),c={type:this.callType_,extraState:{name:b,params:this.arguments_}};a.push({enabled:!0,text:$.C.PROCEDURES_CREATE_DO.replace("%1",
2545
2546
  b),callback:$.Pg(this,c)});if(!this.isCollapsed())for(b=0;b<this.argumentVarModels_.length;b++){c=this.argumentVarModels_[b];let d={type:"variables_get",fields:{VAR:{name:c.getName(),id:c.getId(),type:c.getType()}}};a.push({enabled:!0,text:$.C.VARIABLES_SET_CREATE_GET.replace("%1",c.getName()),callback:$.Pg(this,d)})}}}};
2546
- Vq.procedures_defnoreturn=Object.assign({},Wq,{init:function(){var a=$.jj("",this);a=$.lh({type:"field_input",text:a,ariaTypeName:$.C.ARIA_TYPE_FIELD_TEXT_INPUT_PROCEDURE});a.setValidator($.mj);a.setSpellcheck(!1);this.appendDummyInput().appendField($.C.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.setMutator(new $.sh(["procedures_mutatorarg"],this));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&
2547
+ Wq.procedures_defnoreturn=Object.assign({},Xq,{init:function(){var a=$.jj("",this);a=$.lh({type:"field_input",text:a,ariaTypeName:$.C.ARIA_TYPE_FIELD_TEXT_INPUT_PROCEDURE});a.setValidator($.mj);a.setSpellcheck(!1);this.appendDummyInput().appendField($.C.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.setMutator(new $.sh(["procedures_mutatorarg"],this));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&
2547
2548
  $.C.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText($.C.PROCEDURES_DEFNORETURN_COMMENT);this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_DEFNORETURN_TOOLTIP);this.setHelpUrl($.C.PROCEDURES_DEFNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},callType_:"procedures_callnoreturn"});
2548
- Vq.procedures_defreturn=Object.assign({},Wq,{init:function(){var a=$.jj("",this);a=$.lh({type:"field_input",text:a,ariaTypeName:$.C.ARIA_TYPE_FIELD_TEXT_INPUT_PROCEDURE});a.setValidator($.mj);a.setSpellcheck(!1);this.appendDummyInput().appendField($.C.PROCEDURES_DEFRETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.appendValueInput("RETURN").setAlign($.En.RIGHT).appendField($.C.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new $.sh(["procedures_mutatorarg"],this));(this.workspace.options.comments||
2549
+ Wq.procedures_defreturn=Object.assign({},Xq,{init:function(){var a=$.jj("",this);a=$.lh({type:"field_input",text:a,ariaTypeName:$.C.ARIA_TYPE_FIELD_TEXT_INPUT_PROCEDURE});a.setValidator($.mj);a.setSpellcheck(!1);this.appendDummyInput().appendField($.C.PROCEDURES_DEFRETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.appendValueInput("RETURN").setAlign($.Fn.RIGHT).appendField($.C.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new $.sh(["procedures_mutatorarg"],this));(this.workspace.options.comments||
2549
2550
  this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&$.C.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText($.C.PROCEDURES_DEFRETURN_COMMENT);this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_DEFRETURN_TOOLTIP);this.setHelpUrl($.C.PROCEDURES_DEFRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},
2550
- callType_:"procedures_callreturn"});Vq.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField($.C.PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.appendDummyInput("STATEMENT_INPUT").appendField($.C.PROCEDURES_ALLOW_STATEMENTS).appendField($.lh({type:"field_checkbox",checked:!0}),"STATEMENTS");this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1}};
2551
- var Xq=class extends $.Vp{constructor(){super(...arguments);this.editingInteractively=!1}showEditor_(a){super.showEditor_(a);this.editingInteractively=!0;this.editingVariable=void 0}onFinishEditing_(a){super.onFinishEditing_(a);this.editingInteractively=!1}};
2552
- Vq.procedures_mutatorarg={init:function(){var a=new Xq("x",this.validator_,{ariaTypeName:$.C.ARIA_TYPE_FIELD_TEXT_INPUT_ARGUMENT});this.appendDummyInput().appendField($.C.PROCEDURES_MUTATORARG_TITLE).appendField(a,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1},validator_:function(a){var b=this.getSourceBlock(),c=b.workspace.getRootWorkspace();a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,
2551
+ callType_:"procedures_callreturn"});Wq.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField($.C.PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.appendDummyInput("STATEMENT_INPUT").appendField($.C.PROCEDURES_ALLOW_STATEMENTS).appendField($.lh({type:"field_checkbox",checked:!0}),"STATEMENTS");this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1}};
2552
+ var Yq=class extends $.hq{constructor(){super(...arguments);this.editingInteractively=!1}showEditor_(a){super.showEditor_(a);this.editingInteractively=!0;this.editingVariable=void 0}onFinishEditing_(a){super.onFinishEditing_(a);this.editingInteractively=!1}};
2553
+ Wq.procedures_mutatorarg={init:function(){var a=new Yq("x",this.validator_,{ariaTypeName:$.C.ARIA_TYPE_FIELD_TEXT_INPUT_ARGUMENT});this.appendDummyInput().appendField($.C.PROCEDURES_MUTATORARG_TITLE).appendField(a,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1},validator_:function(a){var b=this.getSourceBlock(),c=b.workspace.getRootWorkspace();a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,
2553
2554
  "");if(!a)return null;var d=(b.workspace.targetWorkspace||b.workspace).getAllBlocks(!1),e=a.toLowerCase();for(let f=0;f<d.length;f++){if(d[f].id===this.getSourceBlock().id)continue;let g=d[f].getFieldValue("NAME");if(g&&g.toLowerCase()===e)return null}if(b.isInFlyout)return a;b=c.getVariableMap();(c=b.getVariable(a,""))&&c.getName()!==a&&b.renameVariable(c,a);c||(this.editingInteractively?this.editingVariable?b.renameVariable(this.editingVariable,a):this.editingVariable=b.createVariable(a,""):b.createVariable(a,
2554
2555
  ""));return a}};
2555
- var Yq={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){$.kj.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?$.C.PROCEDURES_CALLRETURN_TOOLTIP:$.C.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=$.tj(this.getProcedureCall(),this.workspace);(c=(c=c&&c.getIcon($.sh.TYPE))&&c.bubbleIsVisible())?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=
2556
+ var Zq={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){$.kj.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?$.C.PROCEDURES_CALLRETURN_TOOLTIP:$.C.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=$.tj(this.getProcedureCall(),this.workspace);(c=(c=c&&c.getIcon($.sh.TYPE))&&c.bubbleIsVisible())?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=
2556
2557
  null);if(a.join("\n")===this.arguments_.join("\n"))this.quarkIds_=b;else{if(b.length!==a.length)throw RangeError("paramNames and paramIds must be the same length.");this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);for(let e=0;e<this.arguments_.length;e++){var d=this.getInput("ARG"+e);d&&(d=d.connection.targetConnection,this.quarkConnections_[this.quarkIds_[e]]=d,c&&d&&!b.includes(this.quarkIds_[e])&&(d.disconnect(),d.getSourceBlock().bumpNeighbours()))}this.arguments_=[].concat(a);this.argumentVarModels_=
2557
2558
  [];for(a=0;a<this.arguments_.length;a++)c=$.Wd(this.workspace,null,this.arguments_[a],""),this.argumentVarModels_.push(c);this.updateShape_();if(this.quarkIds_=b)for(b=0;b<this.arguments_.length;b++)if(a=this.quarkIds_[b],a in this.quarkConnections_){let e;((e=this.quarkConnections_[a])==null?0:e.reconnect(this,"ARG"+b))||delete this.quarkConnections_[a]}}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);if(b){$.Ub++;try{b.setValue(this.arguments_[a])}finally{$.Ub--}}else b=
2558
- $.lh({type:"field_label",text:this.arguments_[a]}),this.appendValueInput("ARG"+a).setAlign($.En.RIGHT).appendField(b,"ARGNAME"+a)}for(a=this.arguments_.length;this.getInput("ARG"+a);a++)this.removeInput("ARG"+a);(a=this.getInput("TOPROW"))&&(this.arguments_.length?this.getField("WITH")||a.appendField($.C.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"):this.getField("WITH")&&a.removeField("WITH"))},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("name",this.getProcedureCall());for(let b=0;b<this.arguments_.length;b++){let c=
2559
+ $.lh({type:"field_label",text:this.arguments_[a]}),this.appendValueInput("ARG"+a).setAlign($.Fn.RIGHT).appendField(b,"ARGNAME"+a)}for(a=this.arguments_.length;this.getInput("ARG"+a);a++)this.removeInput("ARG"+a);(a=this.getInput("TOPROW"))&&(this.arguments_.length?this.getField("WITH")||a.appendField($.C.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"):this.getField("WITH")&&a.removeField("WITH"))},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("name",this.getProcedureCall());for(let b=0;b<this.arguments_.length;b++){let c=
2559
2560
  $.rc("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);b=[];var c=[];for(let d=0,e;e=a.childNodes[d];d++)e.nodeName.toLowerCase()==="arg"&&(b.push(e.getAttribute("name")),c.push(e.getAttribute("paramId")));this.setProcedureParameters_(b,c)},saveExtraState:function(){var a=Object.create(null);a.name=this.getProcedureCall();this.arguments_.length&&(a.params=this.arguments_);
2560
2561
  return a},loadExtraState:function(a){this.renameProcedure(this.getProcedureCall(),a.name);if(a=a.params){let b=[];b.length=a.length;b.fill(null);this.setProcedureParameters_(a,b)}},getVarModels:function(){return this.argumentVarModels_},onchange:function(a){if(this.workspace&&!this.workspace.isFlyout&&a.recordUndo)if(a.type===$.Od&&a.ids.includes(this.id)){var b=this.getProcedureCall(),c=$.tj(b,this.workspace);!c||c.type===this.defType_&&JSON.stringify(c.getVarModels().map(e=>e.getName()))===JSON.stringify(this.arguments_)||
2561
2562
  (c=null);if(c)c.isEnabled()||(this.setDisabledReason(!0,"DISABLED_PROCEDURE_DEFINITION"),this.setWarningText($.C.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1",b)));else{$.B(a.group);a=$.rc("xml");b=$.rc("block");b.setAttribute("type",this.defType_);c=this.getRelativeToSurfaceXY();var d=c.y+$.Og.snapRadius*2;b.setAttribute("x",`${c.x+$.Og.snapRadius*(this.RTL?-1:1)}`);b.setAttribute("y",`${d}`);c=this.mutationToDom();b.appendChild(c);c=$.rc("field");c.setAttribute("name","NAME");d=this.getProcedureCall();
2562
- let e=$.jj(d,this);d!==e&&this.renameProcedure(d,e);c.appendChild($.sc(d));b.appendChild(c);a.appendChild(b);$.ch(a,this.workspace);$.B(!1)}}else a.type===$.lm?(b=this.getProcedureCall(),$.tj(b,this.workspace)||($.B(a.group),this.dispose(!0),$.B(!1))):a.type===$.km&&a.element==="disabled"&&(b=this.getProcedureCall(),(d=$.tj(b,this.workspace))&&d.id===a.blockId&&((c=$.gd)&&console.log("Saw an existing group while responding to a definition change"),$.B(a.group),a=d.isEnabled(),this.setDisabledReason(!a,
2563
+ let e=$.jj(d,this);d!==e&&this.renameProcedure(d,e);c.appendChild($.sc(d));b.appendChild(c);a.appendChild(b);$.ch(a,this.workspace);$.B(!1)}}else a.type===$.mm?(b=this.getProcedureCall(),$.tj(b,this.workspace)||($.B(a.group),this.dispose(!0),$.B(!1))):a.type===$.lm&&a.element==="disabled"&&(b=this.getProcedureCall(),(d=$.tj(b,this.workspace))&&d.id===a.blockId&&((c=$.gd)&&console.log("Saw an existing group while responding to a definition change"),$.B(a.group),a=d.isEnabled(),this.setDisabledReason(!a,
2563
2564
  "DISABLED_PROCEDURE_DEFINITION"),this.setWarningText(a?null:$.C.PROCEDURES_CALL_DISABLED_DEF_WARNING.replace("%1",b)),$.B(c)))},customContextMenu:function(a){if(this.workspace.isMovable()){var b=this.getProcedureCall(),c=this.workspace;a.push({enabled:!0,text:$.C.PROCEDURES_HIGHLIGHT_DEF,callback:function(){var d=$.tj(b,c);d&&(c.centerOnBlock(d.id),$.t().focusNode(d))}})}}};
2564
- Vq.procedures_callnoreturn=Object.assign({},Yq,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setHelpUrl($.C.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null},defType_:"procedures_defnoreturn"});
2565
- Vq.procedures_callreturn=Object.assign({},Yq,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setStyle("procedure_blocks");this.setHelpUrl($.C.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null},defType_:"procedures_defreturn"});
2566
- Vq.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField($.C.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField($.C.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_IFRETURN_TOOLTIP);this.setHelpUrl($.C.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("value",
2567
- String(Number(this.hasReturnValue_)));return a},domToMutation:function(a){this.hasReturnValue_=a.getAttribute("value")==="1";this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField($.C.PROCEDURES_DEFRETURN_RETURN))},onchange:function(a){if(!(this.workspace.isDragging&&this.workspace.isDragging()||a.type!==$.nm&&a.type!==$.Od)){a=!1;var b=this;do{if(this.FUNCTION_TYPES.includes(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?(b.type==="procedures_defnoreturn"&&
2565
+ Wq.procedures_callnoreturn=Object.assign({},Zq,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setHelpUrl($.C.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null},defType_:"procedures_defnoreturn"});
2566
+ Wq.procedures_callreturn=Object.assign({},Zq,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setStyle("procedure_blocks");this.setHelpUrl($.C.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null},defType_:"procedures_defreturn"});
2567
+ Wq.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField($.C.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField($.C.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip($.C.PROCEDURES_IFRETURN_TOOLTIP);this.setHelpUrl($.C.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("value",
2568
+ String(Number(this.hasReturnValue_)));return a},domToMutation:function(a){this.hasReturnValue_=a.getAttribute("value")==="1";this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField($.C.PROCEDURES_DEFRETURN_RETURN))},onchange:function(a){if(!(this.workspace.isDragging&&this.workspace.isDragging()||a.type!==$.om&&a.type!==$.Od)){a=!1;var b=this;do{if(this.FUNCTION_TYPES.includes(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?(b.type==="procedures_defnoreturn"&&
2568
2569
  this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField($.C.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):b.type!=="procedures_defreturn"||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField($.C.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText($.C.PROCEDURES_IFRETURN_WARNING);if(!this.isInFlyout)try{$.Qc=!1,this.setDisabledReason(!a,"UNPARENTED_IFRETURN")}finally{$.Qc=
2569
- !0}}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};$.Ab(Vq);var Zq={blocks:Vq};var $q=$.yb([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_NUMBER_A}"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD","%{BKY_MATH_ADDITION_SYMBOL_ARIA}"],
2570
+ !0}}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};$.Ab(Wq);var $q={blocks:Wq};var ar=$.yb([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_NUMBER_A}"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD","%{BKY_MATH_ADDITION_SYMBOL_ARIA}"],
2570
2571
  ["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS","%{BKY_MATH_SUBTRACTION_SYMBOL_ARIA}"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}","MULTIPLY","%{BKY_MATH_MULTIPLICATION_SYMBOL_ARIA}"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE","%{BKY_MATH_DIVISION_SYMBOL_ARIA}"],["%{BKY_MATH_POWER_SYMBOL}","POWER","%{BKY_MATH_POWER_SYMBOL_ARIA}"]]},{type:"input_value",name:"B",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_NUMBER_B}"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",
2571
2572
  extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS","%{BKY_MATH_SINGLE_OP_ABSOLUTE_ARIA}"],["-","NEG","%{BKY_MATH_SINGLE_OP_NEG_ARIA}"],["ln","LN","%{BKY_MATH_SINGLE_OP_LN_ARIA}"],["log10","LOG10","%{BKY_MATH_SINGLE_OP_LOG10_ARIA}"],["e^","EXP","%{BKY_MATH_SINGLE_OP_EXP_ARIA}"],["10^","POW10","%{BKY_MATH_SINGLE_OP_POW10_ARIA}"]]},{type:"input_value",name:"NUM",
2572
2573
  check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_NUMBER}"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN","%{BKY_MATH_TRIG_SIN_ARIA}"],["%{BKY_MATH_TRIG_COS}","COS","%{BKY_MATH_TRIG_COS_ARIA}"],["%{BKY_MATH_TRIG_TAN}","TAN","%{BKY_MATH_TRIG_TAN_ARIA}"],["%{BKY_MATH_TRIG_ASIN}","ASIN","%{BKY_MATH_TRIG_ASIN_ARIA}"],["%{BKY_MATH_TRIG_ACOS}",
@@ -2584,7 +2585,7 @@ $.oh("math_op_tooltip",$.yh("OP",{ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS
2584
2585
  SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"}));
2585
2586
  $.th("math_is_divisibleby_mutator",{mutationToDom:function(){var a=$.rc("mutation"),b=this.getFieldValue("PROPERTY")==="DIVISIBLE_BY";a.setAttribute("divisor_input",String(b));return a},domToMutation:function(a){a=a.getAttribute("divisor_input")==="true";this.updateShape_(a)},updateShape_:function(a){var b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):b&&this.removeInput("DIVISOR")}},function(){this.getField("PROPERTY").setValidator(function(a){a=a==="DIVISIBLE_BY";
2586
2587
  this.getSourceBlock().updateShape_(a)})});$.oh("math_change_tooltip",$.Ah("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));
2587
- $.th("math_modes_of_list_mutator",{updateType_:function(a){a==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){a=a.getAttribute("op");if(a===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(a)}},function(){this.getField("OP").setValidator(function(a){this.updateType_(a)}.bind(this))});$.Ab($q);var ar={blocks:$q};var br=$.yb([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_TIMES}"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",
2588
+ $.th("math_modes_of_list_mutator",{updateType_:function(a){a==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("op",this.getFieldValue("OP"));return a},domToMutation:function(a){a=a.getAttribute("op");if(a===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(a)}},function(){this.getField("OP").setValidator(function(a){this.updateType_(a)}.bind(this))});$.Ab(ar);var br={blocks:ar};var cr=$.yb([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_TIMES}"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",
2588
2589
  name:"TIMES",value:10,min:0,precision:1,ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_TIMES}"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}",
2589
2590
  "UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean",ariaLabelText:"%{BKY_INPUT_LABEL_CONDITION}"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",
2590
2591
  align:"RIGHT",ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_FROM}"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT",ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_TO}"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT",ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_BY}"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock",
@@ -2592,8 +2593,8 @@ align:"RIGHT",ariaLabelText:"%{BKY_INPUT_LABEL_LOOP_FROM}"},{type:"input_value",
2592
2593
  {type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]);
2593
2594
  $.oh("controls_whileUntil_tooltip",$.yh("MODE",{WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"}));$.oh("controls_flow_tooltip",$.yh("FLOW",{BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"}));
2594
2595
  $.ph("contextMenu_newGetVariableBlock",{customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR"),c=b.getVariable().getName();this.isCollapsed()||c===null||(b={type:"variables_get",fields:{VAR:b.saveState(!0)}},a.push({enabled:!0,text:$.C.VARIABLES_SET_CREATE_GET.replace("%1",c),callback:$.Pg(this,b)}))}}});$.oh("controls_for_tooltip",$.Ah("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR"));$.oh("controls_forEach_tooltip",$.Ah("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR"));
2595
- var cr=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);
2596
- $.ph("controls_flow_in_loop_check",{getSurroundLoop:function(){var a=this;do{if(cr.has(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){var b=this.workspace;if(b.isDragging&&!b.isDragging()&&(a.type===$.nm||a.type===$.Od)&&(a=!!this.getSurroundLoop(),this.setWarningText(a?null:$.C.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout))try{$.Qc=!1,this.setDisabledReason(!a,"CONTROL_FLOW_NOT_IN_LOOP")}finally{$.Qc=!0}}});$.Ab(br);var dr={blocks:br,loopTypes:cr};var er=$.yb([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,
2596
+ var dr=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);
2597
+ $.ph("controls_flow_in_loop_check",{getSurroundLoop:function(){var a=this;do{if(dr.has(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){var b=this.workspace;if(b.isDragging&&!b.isDragging()&&(a.type===$.om||a.type===$.Od)&&(a=!!this.getSurroundLoop(),this.setWarningText(a?null:$.C.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout))try{$.Qc=!1,this.setDisabledReason(!a,"CONTROL_FLOW_NOT_IN_LOOP")}finally{$.Qc=!0}}});$.Ab(cr);var er={blocks:cr,loopTypes:dr};var fr=$.yb([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,
2597
2598
  nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,
2598
2599
  style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",ariaLabelText:"%{BKY_INPUT_LABEL_VALUE_A}"},{type:"field_dropdown",name:"OP",options:[["=","EQ","%{BKY_LOGIC_COMPARE_EQ_ARIA}"],["\u2260","NEQ","%{BKY_LOGIC_COMPARE_NEQ_ARIA}"],["\u200f<","LT","%{BKY_LOGIC_COMPARE_LT_ARIA}"],["\u200f\u2264","LTE","%{BKY_LOGIC_COMPARE_LTE_ARIA}"],["\u200f>","GT","%{BKY_LOGIC_COMPARE_GT_ARIA}"],
2599
2600
  ["\u200f\u2265","GTE","%{BKY_LOGIC_COMPARE_GTE_ARIA}"]]},{type:"input_value",name:"B",ariaLabelText:"%{BKY_INPUT_LABEL_VALUE_B}"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean",ariaLabelText:"%{BKY_INPUT_LABEL_CONDITION_A}"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}",
@@ -2608,44 +2609,44 @@ c,d)},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a
2608
2609
  rebuildShape_:function(){var a=[null],b=[null],c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(let d=1;this.getInput("IF"+d);d++){let e=this.getInput("IF"+d),f=this.getInput("DO"+d);a.push(e.connection.targetConnection);b.push(f.connection.targetConnection)}this.updateShape_();this.reconnectChildBlocks_(a,b,c)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);a++)this.removeInput("IF"+a),this.removeInput("DO"+
2609
2610
  a);for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField($.C.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField($.C.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField($.C.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(a,b,c){for(let d=1;d<=this.elseifCount_;d++){let e;(e=a[d])==null||e.reconnect(this,"IF"+d);let f;(f=b[d])==null||f.reconnect(this,"DO"+d)}c==null||c.reconnect(this,"ELSE")}},null,["controls_if_elseif",
2610
2611
  "controls_if_else"]);$.oh("controls_if_tooltip",function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return $.C.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return $.C.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return $.C.CONTROLS_IF_TOOLTIP_4}else return $.C.CONTROLS_IF_TOOLTIP_1;return""}.bind(this))});
2611
- var fr={onchange:function(a){this.prevBlocks_||(this.prevBlocks_=[null,null]);var b=this.getInputTargetBlock("A"),c=this.getInputTargetBlock("B");b&&c&&!this.workspace.connectionChecker.doTypeChecks(b.outputConnection,c.outputConnection)&&($.B(a.group),a=this.prevBlocks_[0],a!==b&&(b.unplug(),!a||a.isDisposed()||a.isShadow()||this.getInput("A").connection.connect(a.outputConnection)),b=this.prevBlocks_[1],b!==c&&(c.unplug(),!b||b.isDisposed()||b.isShadow()||this.getInput("B").connection.connect(b.outputConnection)),
2612
- this.bumpNeighbours(),$.B(!1));this.prevBlocks_[0]=this.getInputTargetBlock("A");this.prevBlocks_[1]=this.getInputTargetBlock("B")}};$.oh("logic_compare",function(){this.mixin(fr)});
2613
- $.ph("logic_ternary",{prevParentConnection_:null,onchange:function(a){var b=this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),d=this.outputConnection.targetConnection;if((b||c)&&d)for(let e=0;e<2;e++){let f=e===1?b:c;f&&!f.workspace.connectionChecker.doTypeChecks(f.outputConnection,d)&&($.B(a.group),d===this.prevParentConnection_?(this.unplug(),d.getSourceBlock().bumpNeighbours()):(f.unplug(),f.bumpNeighbours()),$.B(!1))}this.prevParentConnection_=d}});$.Ab(er);var gr={blocks:er};var hr=$.yb([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM",ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_REPEAT_ITEM}"},{type:"input_value",name:"NUM",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_REPEAT_NUM}"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",
2612
+ var gr={onchange:function(a){this.prevBlocks_||(this.prevBlocks_=[null,null]);var b=this.getInputTargetBlock("A"),c=this.getInputTargetBlock("B");b&&c&&!this.workspace.connectionChecker.doTypeChecks(b.outputConnection,c.outputConnection)&&($.B(a.group),a=this.prevBlocks_[0],a!==b&&(b.unplug(),!a||a.isDisposed()||a.isShadow()||this.getInput("A").connection.connect(a.outputConnection)),b=this.prevBlocks_[1],b!==c&&(c.unplug(),!b||b.isDisposed()||b.isShadow()||this.getInput("B").connection.connect(b.outputConnection)),
2613
+ this.bumpNeighbours(),$.B(!1));this.prevBlocks_[0]=this.getInputTargetBlock("A");this.prevBlocks_[1]=this.getInputTargetBlock("B")}};$.oh("logic_compare",function(){this.mixin(gr)});
2614
+ $.ph("logic_ternary",{prevParentConnection_:null,onchange:function(a){var b=this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),d=this.outputConnection.targetConnection;if((b||c)&&d)for(let e=0;e<2;e++){let f=e===1?b:c;f&&!f.workspace.connectionChecker.doTypeChecks(f.outputConnection,d)&&($.B(a.group),d===this.prevParentConnection_?(this.unplug(),d.getSourceBlock().bumpNeighbours()):(f.unplug(),f.bumpNeighbours()),$.B(!1))}this.prevParentConnection_=d}});$.Ab(fr);var hr={blocks:fr};var ir=$.yb([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM",ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_REPEAT_ITEM}"},{type:"input_value",name:"NUM",check:"Number",ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_REPEAT_NUM}"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",
2614
2615
  helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array",ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_TO_CHANGE}"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"],ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_TO_CHECK}"}],
2615
2616
  output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"],ariaLabelText:"%{BKY_INPUT_LABEL_LISTS_TO_CHECK}"}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]);
2616
- hr.lists_create_with={init:function(){this.setHelpUrl($.C.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new $.sh(["lists_create_with_item"],this));this.setTooltip($.C.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("items",String(this.itemCount_));return a},domToMutation:function(a){a=a.getAttribute("items");if(!a)throw new TypeError("element did not have items");this.itemCount_=
2617
+ ir.lists_create_with={init:function(){this.setHelpUrl($.C.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new $.sh(["lists_create_with_item"],this));this.setTooltip($.C.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("items",String(this.itemCount_));return a},domToMutation:function(a){a=a.getAttribute("items");if(!a)throw new TypeError("element did not have items");this.itemCount_=
2617
2618
  parseInt(a,10);this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(a){this.itemCount_=a.itemCount;this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();var c=b.getInput("STACK").connection;for(let d=0;d<this.itemCount_;d++){let e=a.newBlock("lists_create_with_item");e.initSvg();if(!e.previousConnection)throw Error("itemBlock has no previousConnection");c.connect(e.previousConnection);c=e.nextConnection}return b},
2618
2619
  compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)b.isInsertionMarker()||a.push(b.valueConnection_),b=b.getNextBlock();for(b=0;b<this.itemCount_;b++){let c=this.getInput("ADD"+b).connection.targetConnection;c&&!a.includes(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++){let c;(c=a[b])==null||c.reconnect(this,"ADD"+b)}},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){if(a.isInsertionMarker()){a=a.getNextBlock();
2619
- continue}let c=this.getInput("ADD"+b);a.valueConnection_=c==null?void 0:c.connection.targetConnection;a=a.getNextBlock();b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField($.C.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){let b=this.appendValueInput("ADD"+a).setAlign($.En.RIGHT).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_CREATE_WITH_ITEM.replace("%1",
2620
- String(a+1)));a===0&&b.appendField($.C.LISTS_CREATE_WITH_INPUT_WITH)}for(a=this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}};hr.lists_create_with_container={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField($.C.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);this.appendStatementInput("STACK");this.setTooltip($.C.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);this.contextMenu=!1}};
2621
- hr.lists_create_with_item={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField($.C.LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip($.C.LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
2622
- hr.lists_indexOf={init:function(){var a=[[$.C.LISTS_INDEX_OF_FIRST,"FIRST"],[$.C.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl($.C.LISTS_INDEX_OF_HELPURL);this.setStyle("list_blocks");this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("Array").appendField($.C.LISTS_INDEX_OF_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);a=$.lh({type:"field_dropdown",options:a});if(!a)throw Error("field_dropdown not found");this.appendValueInput("FIND").appendField(a,"END");this.setInputsInline(!0);
2620
+ continue}let c=this.getInput("ADD"+b);a.valueConnection_=c==null?void 0:c.connection.targetConnection;a=a.getNextBlock();b++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField($.C.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){let b=this.appendValueInput("ADD"+a).setAlign($.Fn.RIGHT).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_CREATE_WITH_ITEM.replace("%1",
2621
+ String(a+1)));a===0&&b.appendField($.C.LISTS_CREATE_WITH_INPUT_WITH)}for(a=this.itemCount_;this.getInput("ADD"+a);a++)this.removeInput("ADD"+a)}};ir.lists_create_with_container={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField($.C.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);this.appendStatementInput("STACK");this.setTooltip($.C.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);this.contextMenu=!1}};
2622
+ ir.lists_create_with_item={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField($.C.LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip($.C.LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
2623
+ ir.lists_indexOf={init:function(){var a=[[$.C.LISTS_INDEX_OF_FIRST,"FIRST"],[$.C.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl($.C.LISTS_INDEX_OF_HELPURL);this.setStyle("list_blocks");this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("Array").appendField($.C.LISTS_INDEX_OF_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);a=$.lh({type:"field_dropdown",options:a});if(!a)throw Error("field_dropdown not found");this.appendValueInput("FIND").appendField(a,"END");this.setInputsInline(!0);
2623
2624
  this.setTooltip(()=>$.C.LISTS_INDEX_OF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1"))}};
2624
- hr.lists_getIndex={init:function(){var a=[[$.C.LISTS_GET_INDEX_GET,"GET"],[$.C.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[$.C.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[$.C.LISTS_GET_INDEX_FROM_START,"FROM_START"],[$.C.LISTS_GET_INDEX_FROM_END,"FROM_END"],[$.C.LISTS_GET_INDEX_FIRST,"FIRST"],[$.C.LISTS_GET_INDEX_LAST,"LAST"],[$.C.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl($.C.LISTS_GET_INDEX_HELPURL);this.setStyle("list_blocks");a=$.lh({type:"field_dropdown",options:a});a.setValidator(function(b){b=
2625
+ ir.lists_getIndex={init:function(){var a=[[$.C.LISTS_GET_INDEX_GET,"GET"],[$.C.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[$.C.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[$.C.LISTS_GET_INDEX_FROM_START,"FROM_START"],[$.C.LISTS_GET_INDEX_FROM_END,"FROM_END"],[$.C.LISTS_GET_INDEX_FIRST,"FIRST"],[$.C.LISTS_GET_INDEX_LAST,"LAST"],[$.C.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl($.C.LISTS_GET_INDEX_HELPURL);this.setStyle("list_blocks");a=$.lh({type:"field_dropdown",options:a});a.setValidator(function(b){b=
2625
2626
  b==="REMOVE";this.getSourceBlock().updateStatement_(b)});this.appendValueInput("VALUE").setCheck("Array").appendField($.C.LISTS_GET_INDEX_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);this.appendDummyInput().appendField(a,"MODE").appendField("","SPACE");a=$.lh({type:"field_dropdown",options:this.WHERE_OPTIONS});a.setValidator(function(b){var c=this.getValue();b=b==="FROM_START"||b==="FROM_END";b!==(c==="FROM_START"||c==="FROM_END")&&this.getSourceBlock().updateAt_(b)});this.appendDummyInput().appendField(a,
2626
2627
  "WHERE");this.appendDummyInput("AT");$.C.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField($.C.LISTS_GET_INDEX_TAIL);this.setInputsInline(!0);this.setOutput(!0);this.updateAt_(!0);this.setTooltip(()=>{var b=this.getFieldValue("MODE"),c=this.getFieldValue("WHERE"),d="";switch(b+" "+c){case "GET FROM_START":case "GET FROM_END":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case "GET FIRST":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case "GET LAST":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_LAST;
2627
2628
  break;case "GET RANDOM":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case "GET_REMOVE FROM_START":case "GET_REMOVE FROM_END":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case "GET_REMOVE FIRST":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case "GET_REMOVE LAST":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case "GET_REMOVE RANDOM":d=$.C.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case "REMOVE FROM_START":case "REMOVE FROM_END":d=$.C.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;
2628
2629
  case "REMOVE FIRST":d=$.C.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case "REMOVE LAST":d=$.C.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case "REMOVE RANDOM":d=$.C.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}if(c==="FROM_START"||c==="FROM_END")d+=" "+(c==="FROM_START"?$.C.LISTS_INDEX_FROM_START_TOOLTIP:$.C.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0");return d})},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("statement",String(!this.outputConnection));
2629
- var b=this.getInput("AT")instanceof $.Nn;a.setAttribute("at",String(b));return a},domToMutation:function(a){var b=a.getAttribute("statement")==="true";this.updateStatement_(b);a=a.getAttribute("at")!=="false";this.updateAt_(a)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(a){a.isStatement?this.updateStatement_(!0):typeof a==="string"&&this.domToMutation($.uc(a))},updateStatement_:function(a){a!==!this.outputConnection&&(this.unplug(!0,!0),a?
2630
+ var b=this.getInput("AT")instanceof $.On;a.setAttribute("at",String(b));return a},domToMutation:function(a){var b=a.getAttribute("statement")==="true";this.updateStatement_(b);a=a.getAttribute("at")!=="false";this.updateAt_(a)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(a){a.isStatement?this.updateStatement_(!0):typeof a==="string"&&this.domToMutation($.uc(a))},updateStatement_:function(a){a!==!this.outputConnection&&(this.unplug(!0,!0),a?
2630
2631
  (this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number").setAriaLabelProvider($.C.INPUT_LABEL_LISTS_POSITION),$.C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.C.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");$.C.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",
2631
2632
  null)}};
2632
- hr.lists_setIndex={init:function(){var a=[[$.C.LISTS_SET_INDEX_SET,"SET"],[$.C.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[$.C.LISTS_GET_INDEX_FROM_START,"FROM_START"],[$.C.LISTS_GET_INDEX_FROM_END,"FROM_END"],[$.C.LISTS_GET_INDEX_FIRST,"FIRST"],[$.C.LISTS_GET_INDEX_LAST,"LAST"],[$.C.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl($.C.LISTS_SET_INDEX_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField($.C.LISTS_SET_INDEX_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);a=
2633
+ ir.lists_setIndex={init:function(){var a=[[$.C.LISTS_SET_INDEX_SET,"SET"],[$.C.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[$.C.LISTS_GET_INDEX_FROM_START,"FROM_START"],[$.C.LISTS_GET_INDEX_FROM_END,"FROM_END"],[$.C.LISTS_GET_INDEX_FIRST,"FIRST"],[$.C.LISTS_GET_INDEX_LAST,"LAST"],[$.C.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl($.C.LISTS_SET_INDEX_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField($.C.LISTS_SET_INDEX_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);a=
2633
2634
  $.lh({type:"field_dropdown",options:a});this.appendDummyInput().appendField(a,"MODE").appendField("","SPACE");a=$.lh({type:"field_dropdown",options:this.WHERE_OPTIONS});a.setValidator(function(b){var c=this.getValue();b=b==="FROM_START"||b==="FROM_END";b!==(c==="FROM_START"||c==="FROM_END")&&this.getSourceBlock().updateAt_(b)});this.appendDummyInput().appendField(a,"WHERE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField($.C.LISTS_SET_INDEX_INPUT_TO).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_VALUE_TO_SET);
2634
2635
  this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip($.C.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);this.setTooltip(()=>{var b=this.getFieldValue("MODE"),c=this.getFieldValue("WHERE"),d="";switch(b+" "+c){case "SET FROM_START":case "SET FROM_END":d=$.C.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case "SET FIRST":d=$.C.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case "SET LAST":d=$.C.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case "SET RANDOM":d=$.C.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;
2635
2636
  break;case "INSERT FROM_START":case "INSERT FROM_END":d=$.C.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case "INSERT FIRST":d=$.C.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case "INSERT LAST":d=$.C.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case "INSERT RANDOM":d=$.C.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}if(c==="FROM_START"||c==="FROM_END")d+=" "+$.C.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0");return d})},mutationToDom:function(){var a=$.rc("mutation"),
2636
- b=this.getInput("AT")instanceof $.Nn;a.setAttribute("at",String(b));return a},domToMutation:function(a){a=a.getAttribute("at")!=="false";this.updateAt_(a)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number").setAriaLabelProvider($.C.INPUT_LABEL_LISTS_POSITION),$.C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.C.ORDINAL_NUMBER_SUFFIX)):
2637
+ b=this.getInput("AT")instanceof $.On;a.setAttribute("at",String(b));return a},domToMutation:function(a){a=a.getAttribute("at")!=="false";this.updateAt_(a)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number").setAriaLabelProvider($.C.INPUT_LABEL_LISTS_POSITION),$.C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField($.C.ORDINAL_NUMBER_SUFFIX)):
2637
2638
  this.appendDummyInput("AT");this.moveInputBefore("AT","TO");this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO")}};
2638
- hr.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[$.C.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[$.C.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[$.C.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[$.C.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[$.C.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[$.C.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl($.C.LISTS_GET_SUBLIST_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField($.C.LISTS_GET_SUBLIST_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);
2639
+ ir.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[$.C.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[$.C.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[$.C.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[$.C.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[$.C.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[$.C.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl($.C.LISTS_GET_SUBLIST_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField($.C.LISTS_GET_SUBLIST_INPUT_IN_LIST).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_TO_CHECK);
2639
2640
  var a=b=>{var c=$.lh({type:"field_dropdown",options:this["WHERE_OPTIONS_"+b]});c.setValidator(function(d){var e=this.getValue();d=d==="FROM_START"||d==="FROM_END";d!==(e==="FROM_START"||e==="FROM_END")&&this.getSourceBlock().updateAt_(b,d)});return c};this.appendDummyInput("WHERE1_INPUT").appendField(a(1),"WHERE1");this.appendDummyInput("AT1");this.appendDummyInput("WHERE2_INPUT").appendField(a(2),"WHERE2");this.appendDummyInput("AT2");$.C.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField($.C.LISTS_GET_SUBLIST_TAIL);
2640
- this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip($.C.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=$.rc("mutation"),b=this.getInput("AT1")instanceof $.Nn;a.setAttribute("at1",String(b));b=this.getInput("AT2")instanceof $.Nn;a.setAttribute("at2",String(b));return a},domToMutation:function(a){var b=a.getAttribute("at1")==="true";a=a.getAttribute("at2")==="true";this.updateAt_(1,b);this.updateAt_(2,a)},saveExtraState:function(){return null},
2641
+ this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip($.C.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=$.rc("mutation"),b=this.getInput("AT1")instanceof $.On;a.setAttribute("at1",String(b));b=this.getInput("AT2")instanceof $.On;a.setAttribute("at2",String(b));return a},domToMutation:function(a){var b=a.getAttribute("at1")==="true";a=a.getAttribute("at2")==="true";this.updateAt_(1,b);this.updateAt_(2,a)},saveExtraState:function(){return null},
2641
2642
  loadExtraState:function(){},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number").setAriaLabelProvider(a===1?$.C.INPUT_LABEL_LISTS_START_POSITION:$.C.INPUT_LABEL_LISTS_END_POSITION),$.C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField($.C.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+a);a===1&&(this.moveInputBefore("AT1","WHERE2_INPUT"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1",
2642
2643
  "WHERE2_INPUT"));$.C.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};
2643
- hr.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array",ariaLabelText:$.C.INPUT_LABEL_LISTS_TO_CHANGE}],
2644
+ ir.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array",ariaLabelText:$.C.INPUT_LABEL_LISTS_TO_CHANGE}],
2644
2645
  output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}};
2645
- hr.lists_split={init:function(){var a=$.lh({type:"field_dropdown",options:[[$.C.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[$.C.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});if(!a)throw Error("field_dropdown not found");a.setValidator(b=>{this.updateType_(b)});this.setHelpUrl($.C.LISTS_SPLIT_HELPURL);this.setStyle("list_blocks");this.appendValueInput("INPUT").setCheck("String").appendField(a,"MODE").setAriaLabelProvider(()=>{var b=this.getFieldValue("MODE");if(b==="SPLIT")return $.C.INPUT_LABEL_LISTS_LIST_FROM_TEXT;
2646
+ ir.lists_split={init:function(){var a=$.lh({type:"field_dropdown",options:[[$.C.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[$.C.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});if(!a)throw Error("field_dropdown not found");a.setValidator(b=>{this.updateType_(b)});this.setHelpUrl($.C.LISTS_SPLIT_HELPURL);this.setStyle("list_blocks");this.appendValueInput("INPUT").setCheck("String").appendField(a,"MODE").setAriaLabelProvider(()=>{var b=this.getFieldValue("MODE");if(b==="SPLIT")return $.C.INPUT_LABEL_LISTS_LIST_FROM_TEXT;
2646
2647
  if(b==="JOIN")return $.C.INPUT_LABEL_LISTS_TEXT_FROM_LIST});this.appendValueInput("DELIM").setCheck("String").appendField($.C.INPUT_LABEL_LISTS_DELIMITER).setAriaLabelProvider($.C.INPUT_LABEL_LISTS_SPLIT_WITH_DELIMITER);this.setInputsInline(!0);this.setOutput(!0,"Array");this.setTooltip(()=>{var b=this.getFieldValue("MODE");if(b==="SPLIT")return $.C.LISTS_SPLIT_TOOLTIP_SPLIT;if(b==="JOIN")return $.C.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+b);})},updateType_:function(a){if(this.getFieldValue("MODE")!==
2647
2648
  a){let b=this.getInput("INPUT").connection;b.setShadowDom(null);let c=b.targetBlock();c&&(b.disconnect(),c.isShadow()?c.dispose(!1):this.bumpNeighbours())}a==="SPLIT"?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){var a=$.rc("mutation");a.setAttribute("mode",this.getFieldValue("MODE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("mode"))},
2648
- saveExtraState:function(){return{mode:this.getFieldValue("MODE")}},loadExtraState:function(a){this.updateType_(a.mode)}};$.Ab(hr);var ir={blocks:hr};var jr={blocks:Object.assign({},hr,er,br,$q,Vq,Rq,Pq,Nq),lists:ir,logic:gr,loops:dr,math:ar,procedures:Zq,texts:Uq,variables:Qq,variablesDynamic:Oq};$.__chunk_blocks=jr;
2649
+ saveExtraState:function(){return{mode:this.getFieldValue("MODE")}},loadExtraState:function(a){this.updateType_(a.mode)}};$.Ab(ir);var jr={blocks:ir};var kr={blocks:Object.assign({},ir,fr,cr,ar,Wq,Sq,Qq,Oq),lists:jr,logic:hr,loops:er,math:br,procedures:$q,texts:Vq,variables:Rq,variablesDynamic:Pq};$.__chunk_blocks=kr;
2649
2650
  $.__chunk_blocks.__namespace__=$;
2650
2651
  return $.__chunk_blocks;
2651
2652
  }));
@@ -2667,26 +2668,26 @@ return $.__chunk_blocks;
2667
2668
  }
2668
2669
  }(this, function(__parent__) {
2669
2670
  var $=__parent__.__namespace__;
2670
- var kr=function(a,b,c){return b==="FIRST"?"0":b==="FROM_END"?a+".length - 1 - "+c:b==="LAST"?a+".length - 1":c},lr=function(a,b){var c=0,d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{let e=b.valueToCode(a,"IF"+c,S.NONE)||"false",f=b.statementToCode(a,"DO"+c);b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(c>0?" else ":"")+"if ("+e+") {\n"+f+"}";c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)c=a.getInput("ELSE")?b.statementToCode(a,
2671
- "ELSE"):"",b.STATEMENT_SUFFIX&&(c=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+c),d+=" else {\n"+c+"}";return d+"\n"},mr=function(a,b){var c=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):b.valueToCode(a,"TIMES",S.ASSIGNMENT)||"0";var d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a);a="";var e=b.nameDB_.getDistinctName("count",$.P.VARIABLE),f=c;c.match(/^\w+$/)||$.zf(c)||(f=b.nameDB_.getDistinctName("repeat_end",$.P.VARIABLE),a+="var "+f+" = "+c+";\n");return a+("for (var "+
2672
- e+" = 0; "+e+" < "+f+"; "+e+"++) {\n"+d+"}\n")},nr=function(a,b){var c=a.getFieldValue("OP");if(c==="NEG")return a=b.valueToCode(a,"NUM",S.UNARY_NEGATION)||"0",a[0]==="-"&&(a=" "+a),["-"+a,S.UNARY_NEGATION];a=c==="SIN"||c==="COS"||c==="TAN"?b.valueToCode(a,"NUM",S.DIVISION)||"0":b.valueToCode(a,"NUM",S.NONE)||"0";switch(c){case "ABS":var d="Math.abs("+a+")";break;case "ROOT":d="Math.sqrt("+a+")";break;case "LN":d="Math.log("+a+")";break;case "EXP":d="Math.exp("+a+")";break;case "POW10":d="Math.pow(10,"+
2671
+ var lr=function(a,b,c){return b==="FIRST"?"0":b==="FROM_END"?a+".length - 1 - "+c:b==="LAST"?a+".length - 1":c},mr=function(a,b){var c=0,d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));do{let e=b.valueToCode(a,"IF"+c,S.NONE)||"false",f=b.statementToCode(a,"DO"+c);b.STATEMENT_SUFFIX&&(f=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+f);d+=(c>0?" else ":"")+"if ("+e+") {\n"+f+"}";c++}while(a.getInput("IF"+c));if(a.getInput("ELSE")||b.STATEMENT_SUFFIX)c=a.getInput("ELSE")?b.statementToCode(a,
2672
+ "ELSE"):"",b.STATEMENT_SUFFIX&&(c=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT)+c),d+=" else {\n"+c+"}";return d+"\n"},nr=function(a,b){var c=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):b.valueToCode(a,"TIMES",S.ASSIGNMENT)||"0";var d=b.statementToCode(a,"DO");d=b.addLoopTrap(d,a);a="";var e=b.nameDB_.getDistinctName("count",$.P.VARIABLE),f=c;c.match(/^\w+$/)||$.zf(c)||(f=b.nameDB_.getDistinctName("repeat_end",$.P.VARIABLE),a+="var "+f+" = "+c+";\n");return a+("for (var "+
2673
+ e+" = 0; "+e+" < "+f+"; "+e+"++) {\n"+d+"}\n")},or=function(a,b){var c=a.getFieldValue("OP");if(c==="NEG")return a=b.valueToCode(a,"NUM",S.UNARY_NEGATION)||"0",a[0]==="-"&&(a=" "+a),["-"+a,S.UNARY_NEGATION];a=c==="SIN"||c==="COS"||c==="TAN"?b.valueToCode(a,"NUM",S.DIVISION)||"0":b.valueToCode(a,"NUM",S.NONE)||"0";switch(c){case "ABS":var d="Math.abs("+a+")";break;case "ROOT":d="Math.sqrt("+a+")";break;case "LN":d="Math.log("+a+")";break;case "EXP":d="Math.exp("+a+")";break;case "POW10":d="Math.pow(10,"+
2673
2674
  a+")";break;case "ROUND":d="Math.round("+a+")";break;case "ROUNDUP":d="Math.ceil("+a+")";break;case "ROUNDDOWN":d="Math.floor("+a+")";break;case "SIN":d="Math.sin("+a+" / 180 * Math.PI)";break;case "COS":d="Math.cos("+a+" / 180 * Math.PI)";break;case "TAN":d="Math.tan("+a+" / 180 * Math.PI)"}if(d)return[d,S.FUNCTION_CALL];switch(c){case "LOG10":d="Math.log("+a+") / Math.log(10)";break;case "ASIN":d="Math.asin("+a+") / Math.PI * 180";break;case "ACOS":d="Math.acos("+a+") / Math.PI * 180";break;case "ATAN":d=
2674
- "Math.atan("+a+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+c);}return[d,S.DIVISION]},or=function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(d+=b.injectId(b.STATEMENT_SUFFIX,a));d&&(d=b.prefixLines(d,b.INDENT));var e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));var f="";a.getInput("STACK")&&(f=b.statementToCode(a,"STACK"));var g="";a.getInput("RETURN")&&
2675
- (g=b.valueToCode(a,"RETURN",S.NONE)||"");var h="";f&&g&&(h=d);g&&(g=b.INDENT+"return "+g+";\n");var m=[],z=a.getVarModels();for(let E=0;E<z.length;E++)m[E]=b.getVariableName(z[E].getId());d="function "+c+"("+m.join(", ")+") {\n"+d+e+f+h+g+"}";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},qr=function(a){return pr.test(a)?[a,S.ATOMIC]:["String("+a+")",S.FUNCTION_CALL]},rr=function(a,b,c){return b==="FIRST"?"0":b==="FROM_END"?a+".length - 1 - "+c:b==="LAST"?a+".length - 1":c},sr=function(a,b){b=
2676
- "window.prompt("+(a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",S.NONE)||"''")+")";a.getFieldValue("TYPE")==="NUMBER"&&(b="Number("+b+")");return[b,S.FUNCTION_CALL]},tr=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),S.ATOMIC]},ur=function(a,b){var c=b.valueToCode(a,"VALUE",S.ASSIGNMENT)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+";\n"},S,U=S||(S={});U[U.ATOMIC=0]="ATOMIC";U[U.NEW=1.1]="NEW";U[U.MEMBER=1.2]="MEMBER";
2675
+ "Math.atan("+a+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+c);}return[d,S.DIVISION]},pr=function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d="";b.STATEMENT_PREFIX&&(d+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(d+=b.injectId(b.STATEMENT_SUFFIX,a));d&&(d=b.prefixLines(d,b.INDENT));var e="";b.INFINITE_LOOP_TRAP&&(e=b.prefixLines(b.injectId(b.INFINITE_LOOP_TRAP,a),b.INDENT));var f="";a.getInput("STACK")&&(f=b.statementToCode(a,"STACK"));var g="";a.getInput("RETURN")&&
2676
+ (g=b.valueToCode(a,"RETURN",S.NONE)||"");var h="";f&&g&&(h=d);g&&(g=b.INDENT+"return "+g+";\n");var m=[],z=a.getVarModels();for(let E=0;E<z.length;E++)m[E]=b.getVariableName(z[E].getId());d="function "+c+"("+m.join(", ")+") {\n"+d+e+f+h+g+"}";d=b.scrub_(a,d);b.definitions_["%"+c]=d;return null},rr=function(a){return qr.test(a)?[a,S.ATOMIC]:["String("+a+")",S.FUNCTION_CALL]},sr=function(a,b,c){return b==="FIRST"?"0":b==="FROM_END"?a+".length - 1 - "+c:b==="LAST"?a+".length - 1":c},tr=function(a,b){b=
2677
+ "window.prompt("+(a.getField("TEXT")?b.quote_(a.getFieldValue("TEXT")):b.valueToCode(a,"TEXT",S.NONE)||"''")+")";a.getFieldValue("TYPE")==="NUMBER"&&(b="Number("+b+")");return[b,S.FUNCTION_CALL]},ur=function(a,b){return[b.getVariableName(a.getFieldValue("VAR")),S.ATOMIC]},vr=function(a,b){var c=b.valueToCode(a,"VALUE",S.ASSIGNMENT)||"0";return b.getVariableName(a.getFieldValue("VAR"))+" = "+c+";\n"},S,U=S||(S={});U[U.ATOMIC=0]="ATOMIC";U[U.NEW=1.1]="NEW";U[U.MEMBER=1.2]="MEMBER";
2677
2678
  U[U.FUNCTION_CALL=2]="FUNCTION_CALL";U[U.INCREMENT=3]="INCREMENT";U[U.DECREMENT=3]="DECREMENT";U[U.BITWISE_NOT=4.1]="BITWISE_NOT";U[U.UNARY_PLUS=4.2]="UNARY_PLUS";U[U.UNARY_NEGATION=4.3]="UNARY_NEGATION";U[U.LOGICAL_NOT=4.4]="LOGICAL_NOT";U[U.TYPEOF=4.5]="TYPEOF";U[U.VOID=4.6]="VOID";U[U.DELETE=4.7]="DELETE";U[U.AWAIT=4.8]="AWAIT";U[U.EXPONENTIATION=5]="EXPONENTIATION";U[U.MULTIPLICATION=5.1]="MULTIPLICATION";U[U.DIVISION=5.2]="DIVISION";U[U.MODULUS=5.3]="MODULUS";U[U.SUBTRACTION=6.1]="SUBTRACTION";
2678
2679
  U[U.ADDITION=6.2]="ADDITION";U[U.BITWISE_SHIFT=7]="BITWISE_SHIFT";U[U.RELATIONAL=8]="RELATIONAL";U[U.IN=8]="IN";U[U.INSTANCEOF=8]="INSTANCEOF";U[U.EQUALITY=9]="EQUALITY";U[U.BITWISE_AND=10]="BITWISE_AND";U[U.BITWISE_XOR=11]="BITWISE_XOR";U[U.BITWISE_OR=12]="BITWISE_OR";U[U.LOGICAL_AND=13]="LOGICAL_AND";U[U.LOGICAL_OR=14]="LOGICAL_OR";U[U.CONDITIONAL=15]="CONDITIONAL";U[U.ASSIGNMENT=16]="ASSIGNMENT";U[U.YIELD=17]="YIELD";U[U.COMMA=18]="COMMA";U[U.NONE=99]="NONE";
2679
- var vr=class extends $.dq{constructor(a="JavaScript"){super(a);this.ORDER_OVERRIDES=[[S.FUNCTION_CALL,S.MEMBER],[S.FUNCTION_CALL,S.FUNCTION_CALL],[S.MEMBER,S.MEMBER],[S.MEMBER,S.FUNCTION_CALL],[S.LOGICAL_NOT,S.LOGICAL_NOT],[S.MULTIPLICATION,S.MULTIPLICATION],[S.ADDITION,S.ADDITION],[S.LOGICAL_AND,S.LOGICAL_AND],[S.LOGICAL_OR,S.LOGICAL_OR]];this.isInitialized=!1;for(let b in S)a=S[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+
2680
+ var wr=class extends $.dq{constructor(a="JavaScript"){super(a);this.ORDER_OVERRIDES=[[S.FUNCTION_CALL,S.MEMBER],[S.FUNCTION_CALL,S.FUNCTION_CALL],[S.MEMBER,S.MEMBER],[S.MEMBER,S.FUNCTION_CALL],[S.LOGICAL_NOT,S.LOGICAL_NOT],[S.MULTIPLICATION,S.MULTIPLICATION],[S.ADDITION,S.ADDITION],[S.LOGICAL_AND,S.LOGICAL_AND],[S.LOGICAL_OR,S.LOGICAL_OR]];this.isInitialized=!1;for(let b in S)a=S[b],typeof a!=="string"&&(this["ORDER_"+b]=a);this.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+
2680
2681
  Object.getOwnPropertyNames(globalThis).join(","))}init(a){super.init(a);this.nameDB_?this.nameDB_.reset():this.nameDB_=new $.kj(this.RESERVED_WORDS_);this.nameDB_.setVariableMap(a.getVariableMap());this.nameDB_.populateVariables(a);this.nameDB_.populateProcedures(a);var b=[],c=$.Cd(a);for(let d=0;d<c.length;d++)b.push(this.nameDB_.getName(c[d],$.P.DEVELOPER_VARIABLE));a=$.Bd(a);for(c=0;c<a.length;c++)b.push(this.nameDB_.getName(a[c].getId(),$.P.VARIABLE));b.length&&(this.definitions_.variables="var "+
2681
2682
  b.join(", ")+";");this.isInitialized=!0}finish(a){var b=Object.values(this.definitions_);super.finish(a);this.isInitialized=!1;this.nameDB_.reset();return b.join("\n\n")+"\n\n\n"+a}scrubNakedValue(a){return a+";\n"}quote_(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"}multiline_quote_(a){return a.split(/\n/g).map(this.quote_).join(" + '\\n' +\n")}scrub_(a,b,c=!1){var d="";if(!a.outputConnection||!a.outputConnection.targetConnection){var e=a.getCommentText();
2682
2683
  e&&(e=$.yf(e,this.COMMENT_WRAP-3),d+=this.prefixLines(e+"\n","// "));for(let f=0;f<a.inputList.length;f++)a.inputList[f].type===$.je.VALUE&&(e=a.inputList[f].connection.targetBlock())&&(e=this.allNestedComments(e))&&(d+=this.prefixLines(e,"// "))}a=a.nextConnection&&a.nextConnection.targetBlock();c=c?"":this.blockToCode(a);return d+b+c}getAdjusted(a,b,c=0,d=!1,e=S.NONE){a.workspace.options.oneBasedIndex&&c--;var f=a.workspace.options.oneBasedIndex?"1":"0",g=e;c>0?g=S.ADDITION:c<0?g=S.SUBTRACTION:
2683
- d&&(g=S.UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;if(c===0&&!d)return a;if($.zf(a))return a=String(Number(a)+c),d&&(a=String(-Number(a))),a;c>0?a=`${a} + ${c}`:c<0&&(a=`${a} - ${-c}`);d&&(a=c?`-(${a})`:`-${a}`);Math.floor(e)>=Math.floor(g)&&(a=`(${a})`);return a}};var wr={};wr.controls_if=lr;wr.controls_ifelse=lr;wr.logic_boolean=function(a){return[a.getFieldValue("BOOL")==="TRUE"?"true":"false",S.ATOMIC]};wr.logic_compare=function(a,b){var c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=c==="=="||c==="!="?S.EQUALITY:S.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]};wr.logic_negate=function(a,b){var c=S.LOGICAL_NOT;return["!"+(b.valueToCode(a,"BOOL",c)||"true"),c]};
2684
- wr.logic_null=function(){return["null",S.ATOMIC]};wr.logic_operation=function(a,b){var c=a.getFieldValue("OP")==="AND"?"&&":"||",d=c==="&&"?S.LOGICAL_AND:S.LOGICAL_OR,e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="&&"?"true":"false",e||(e=b),a||(a=b)):a=e="false";return[e+" "+c+" "+a,d]};
2685
- wr.logic_ternary=function(a,b){var c=b.valueToCode(a,"IF",S.CONDITIONAL)||"false",d=b.valueToCode(a,"THEN",S.CONDITIONAL)||"null";a=b.valueToCode(a,"ELSE",S.CONDITIONAL)||"null";return[c+" ? "+d+" : "+a,S.CONDITIONAL]};var xr={controls_flow_statements:function(a,b){var c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){let d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break;\n";case "CONTINUE":return c+"continue;\n"}throw Error("Unknown flow statement.");},controls_for:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),
2684
+ d&&(g=S.UNARY_NEGATION);a=this.valueToCode(a,b,g)||f;if(c===0&&!d)return a;if($.zf(a))return a=String(Number(a)+c),d&&(a=String(-Number(a))),a;c>0?a=`${a} + ${c}`:c<0&&(a=`${a} - ${-c}`);d&&(a=c?`-(${a})`:`-${a}`);Math.floor(e)>=Math.floor(g)&&(a=`(${a})`);return a}};var xr={};xr.controls_if=mr;xr.controls_ifelse=mr;xr.logic_boolean=function(a){return[a.getFieldValue("BOOL")==="TRUE"?"true":"false",S.ATOMIC]};xr.logic_compare=function(a,b){var c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],d=c==="=="||c==="!="?S.EQUALITY:S.RELATIONAL,e=b.valueToCode(a,"A",d)||"0";a=b.valueToCode(a,"B",d)||"0";return[e+" "+c+" "+a,d]};xr.logic_negate=function(a,b){var c=S.LOGICAL_NOT;return["!"+(b.valueToCode(a,"BOOL",c)||"true"),c]};
2685
+ xr.logic_null=function(){return["null",S.ATOMIC]};xr.logic_operation=function(a,b){var c=a.getFieldValue("OP")==="AND"?"&&":"||",d=c==="&&"?S.LOGICAL_AND:S.LOGICAL_OR,e=b.valueToCode(a,"A",d);a=b.valueToCode(a,"B",d);e||a?(b=c==="&&"?"true":"false",e||(e=b),a||(a=b)):a=e="false";return[e+" "+c+" "+a,d]};
2686
+ xr.logic_ternary=function(a,b){var c=b.valueToCode(a,"IF",S.CONDITIONAL)||"false",d=b.valueToCode(a,"THEN",S.CONDITIONAL)||"null";a=b.valueToCode(a,"ELSE",S.CONDITIONAL)||"null";return[c+" ? "+d+" : "+a,S.CONDITIONAL]};var yr={controls_flow_statements:function(a,b){var c="";b.STATEMENT_PREFIX&&(c+=b.injectId(b.STATEMENT_PREFIX,a));b.STATEMENT_SUFFIX&&(c+=b.injectId(b.STATEMENT_SUFFIX,a));if(b.STATEMENT_PREFIX){let d=a.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(c+=b.injectId(b.STATEMENT_PREFIX,d))}switch(a.getFieldValue("FLOW")){case "BREAK":return c+"break;\n";case "CONTINUE":return c+"continue;\n"}throw Error("Unknown flow statement.");},controls_for:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),
2686
2687
  d=b.valueToCode(a,"FROM",S.ASSIGNMENT)||"0",e=b.valueToCode(a,"TO",S.ASSIGNMENT)||"0",f=b.valueToCode(a,"BY",S.ASSIGNMENT)||"1",g=b.statementToCode(a,"DO");g=b.addLoopTrap(g,a);if($.zf(d)&&$.zf(e)&&$.zf(f))b=Number(d)<=Number(e),a="for ("+c+" = "+d+"; "+c+(b?" <= ":" >= ")+e+"; "+c,c=Math.abs(Number(f)),a=c===1?a+(b?"++":"--"):a+((b?" += ":" -= ")+c),a+=") {\n"+g+"}\n";else{a="";let h=d;d.match(/^\w+$/)||$.zf(d)||(h=b.nameDB_.getDistinctName(c+"_start",$.P.VARIABLE),a+="var "+h+" = "+d+";\n");d=e;
2687
2688
  e.match(/^\w+$/)||$.zf(e)||(d=b.nameDB_.getDistinctName(c+"_end",$.P.VARIABLE),a+="var "+d+" = "+e+";\n");e=b.nameDB_.getDistinctName(c+"_inc",$.P.VARIABLE);a+="var "+e+" = ";a=$.zf(f)?a+(Math.abs(Number(f))+";\n"):a+("Math.abs("+f+");\n");a+="if ("+h+" > "+d+") {\n";a+=b.INDENT+e+" = -"+e+";\n";a=a+"}\nfor ("+(c+" = "+h+"; "+e+" >= 0 ? "+c+" <= "+d+" : "+c+" >= "+d+"; "+c+" += "+e+") {\n"+g+"}\n")}return a},controls_forEach:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR")),d=b.valueToCode(a,
2688
- "LIST",S.ASSIGNMENT)||"[]",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);a="";var f=d;d.match(/^\w+$/)||(f=b.nameDB_.getDistinctName(c+"_list",$.P.VARIABLE),a+="var "+f+" = "+d+";\n");d=b.nameDB_.getDistinctName(c+"_index",$.P.VARIABLE);e=b.INDENT+c+" = "+f+"["+d+"];\n"+e;return a+("for (var "+d+" in "+f+") {\n"+e+"}\n")}};xr.controls_repeat=mr;xr.controls_repeat_ext=mr;
2689
- xr.controls_whileUntil=function(a,b){var c=a.getFieldValue("MODE")==="UNTIL",d=b.valueToCode(a,"BOOL",c?S.LOGICAL_NOT:S.NONE)||"false",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);c&&(d="!"+d);return"while ("+d+") {\n"+e+"}\n"};var yr={math_arithmetic:function(a,b){var c={ADD:[" + ",S.ADDITION],MINUS:[" - ",S.SUBTRACTION],MULTIPLY:[" * ",S.MULTIPLICATION],DIVIDE:[" / ",S.DIVISION],POWER:[null,S.NONE]}[a.getFieldValue("OP")],d=c[0];c=c[1];var e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return d?[e+d+a,c]:["Math.pow("+e+", "+a+")",S.FUNCTION_CALL]},math_atan2:function(a,b){var c=b.valueToCode(a,"X",S.NONE)||"0";return["Math.atan2("+(b.valueToCode(a,"Y",S.NONE)||"0")+", "+c+") / Math.PI * 180",S.DIVISION]},
2689
+ "LIST",S.ASSIGNMENT)||"[]",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);a="";var f=d;d.match(/^\w+$/)||(f=b.nameDB_.getDistinctName(c+"_list",$.P.VARIABLE),a+="var "+f+" = "+d+";\n");d=b.nameDB_.getDistinctName(c+"_index",$.P.VARIABLE);e=b.INDENT+c+" = "+f+"["+d+"];\n"+e;return a+("for (var "+d+" in "+f+") {\n"+e+"}\n")}};yr.controls_repeat=nr;yr.controls_repeat_ext=nr;
2690
+ yr.controls_whileUntil=function(a,b){var c=a.getFieldValue("MODE")==="UNTIL",d=b.valueToCode(a,"BOOL",c?S.LOGICAL_NOT:S.NONE)||"false",e=b.statementToCode(a,"DO");e=b.addLoopTrap(e,a);c&&(d="!"+d);return"while ("+d+") {\n"+e+"}\n"};var zr={math_arithmetic:function(a,b){var c={ADD:[" + ",S.ADDITION],MINUS:[" - ",S.SUBTRACTION],MULTIPLY:[" * ",S.MULTIPLICATION],DIVIDE:[" / ",S.DIVISION],POWER:[null,S.NONE]}[a.getFieldValue("OP")],d=c[0];c=c[1];var e=b.valueToCode(a,"A",c)||"0";a=b.valueToCode(a,"B",c)||"0";return d?[e+d+a,c]:["Math.pow("+e+", "+a+")",S.FUNCTION_CALL]},math_atan2:function(a,b){var c=b.valueToCode(a,"X",S.NONE)||"0";return["Math.atan2("+(b.valueToCode(a,"Y",S.NONE)||"0")+", "+c+") / Math.PI * 180",S.DIVISION]},
2690
2691
  math_change:function(a,b){var c=b.valueToCode(a,"DELTA",S.ADDITION)||"0";a=b.getVariableName(a.getFieldValue("VAR"));return a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+c+";\n"},math_constant:function(a){return{PI:["Math.PI",S.MEMBER],E:["Math.E",S.MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",S.DIVISION],SQRT2:["Math.SQRT2",S.MEMBER],SQRT1_2:["Math.SQRT1_2",S.MEMBER],INFINITY:["Infinity",S.ATOMIC]}[a.getFieldValue("CONSTANT")]},math_constrain:function(a,b){var c=b.valueToCode(a,"VALUE",S.NONE)||
2691
2692
  "0",d=b.valueToCode(a,"LOW",S.NONE)||"0";a=b.valueToCode(a,"HIGH",S.NONE)||"Infinity";return["Math.min(Math.max("+c+", "+d+"), "+a+")",S.FUNCTION_CALL]},math_modulo:function(a,b){var c=b.valueToCode(a,"DIVIDEND",S.MODULUS)||"0";a=b.valueToCode(a,"DIVISOR",S.MODULUS)||"0";return[c+" % "+a,S.MODULUS]},math_number:function(a){a=Number(a.getFieldValue("NUM"));return[String(a),a>=0?S.ATOMIC:S.UNARY_NEGATION]},math_number_property:function(a,b){var c={EVEN:[" % 2 === 0",S.MODULUS,S.EQUALITY],ODD:[" % 2 === 1",
2692
2693
  S.MODULUS,S.EQUALITY],WHOLE:[" % 1 === 0",S.MODULUS,S.EQUALITY],POSITIVE:[" > 0",S.RELATIONAL,S.RELATIONAL],NEGATIVE:[" < 0",S.RELATIONAL,S.RELATIONAL],DIVISIBLE_BY:[null,S.MODULUS,S.EQUALITY],PRIME:[null,S.NONE,S.FUNCTION_CALL]},d=a.getFieldValue("PROPERTY"),[e,f,g]=c[d];c=b.valueToCode(a,"NUMBER_TO_CHECK",f)||"0";d==="PRIME"?a=b.provideFunction_("mathIsPrime",`
@@ -2780,8 +2781,8 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
2780
2781
  }
2781
2782
  return Math.floor(Math.random() * (b - a + 1) + a);
2782
2783
  }
2783
- `)+"("+c+", "+a+")",S.FUNCTION_CALL]}};yr.math_round=nr;yr.math_single=nr;yr.math_trig=nr;var zr={procedures_callnoreturn:function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+";\n"},procedures_callreturn:function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVarModels();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,S.NONE)||"null";return[c+"("+d.join(", ")+")",S.FUNCTION_CALL]}};zr.procedures_defnoreturn=or;zr.procedures_defreturn=or;
2784
- zr.procedures_ifreturn=function(a,b){var c="if ("+(b.valueToCode(a,"CONDITION",S.NONE)||"false")+") {\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",S.NONE)||"null",c+=b.INDENT+"return "+a+";\n"):c+=b.INDENT+"return;\n";return c+"}\n"};var pr=/^\s*'([^']|\\')*'\s*$/,Ar={text:function(a,b){return[b.quote_(a.getFieldValue("TEXT")),S.ATOMIC]},text_append:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",S.NONE)||"''";return c+" += "+qr(a)[0]+";\n"},text_changeCase:function(a,b){var c={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=b.valueToCode(a,"TEXT",c?S.MEMBER:S.NONE)||"''";return[c?a+c:b.provideFunction_("textToTitleCase",`
2784
+ `)+"("+c+", "+a+")",S.FUNCTION_CALL]}};zr.math_round=or;zr.math_single=or;zr.math_trig=or;var Ar={procedures_callnoreturn:function(a,b){return b.forBlock.procedures_callreturn(a,b)[0]+";\n"},procedures_callreturn:function(a,b){var c=b.getProcedureName(a.getFieldValue("NAME")),d=[],e=a.getVarModels();for(let f=0;f<e.length;f++)d[f]=b.valueToCode(a,"ARG"+f,S.NONE)||"null";return[c+"("+d.join(", ")+")",S.FUNCTION_CALL]}};Ar.procedures_defnoreturn=pr;Ar.procedures_defreturn=pr;
2785
+ Ar.procedures_ifreturn=function(a,b){var c="if ("+(b.valueToCode(a,"CONDITION",S.NONE)||"false")+") {\n";b.STATEMENT_SUFFIX&&(c+=b.prefixLines(b.injectId(b.STATEMENT_SUFFIX,a),b.INDENT));a.hasReturnValue_?(a=b.valueToCode(a,"VALUE",S.NONE)||"null",c+=b.INDENT+"return "+a+";\n"):c+=b.INDENT+"return;\n";return c+"}\n"};var qr=/^\s*'([^']|\\')*'\s*$/,Br={text:function(a,b){return[b.quote_(a.getFieldValue("TEXT")),S.ATOMIC]},text_append:function(a,b){var c=b.getVariableName(a.getFieldValue("VAR"));a=b.valueToCode(a,"TEXT",S.NONE)||"''";return c+" += "+rr(a)[0]+";\n"},text_changeCase:function(a,b){var c={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[a.getFieldValue("CASE")];a=b.valueToCode(a,"TEXT",c?S.MEMBER:S.NONE)||"''";return[c?a+c:b.provideFunction_("textToTitleCase",`
2785
2786
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(str) {
2786
2787
  return str.replace(/\\S+/g,
2787
2788
  function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
@@ -2803,19 +2804,19 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
2803
2804
  `)+"("+c+", "+a+")",S.FUNCTION_CALL]},text_getSubstring:function(a,b){var c={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"},d=a.getFieldValue("WHERE1"),e=a.getFieldValue("WHERE2"),f=d!=="FROM_END"&&d!=="LAST"&&e!=="FROM_END"&&e!=="LAST",g=b.valueToCode(a,"STRING",f?S.MEMBER:S.NONE)||"''";if(d==="FIRST"&&e==="LAST")return[g,S.NONE];if(g.match(/^'?\w+'?$/)||f){switch(d){case "FROM_START":c=b.getAdjusted(a,"AT1");break;case "FROM_END":c=b.getAdjusted(a,"AT1",1,!1,S.SUBTRACTION);
2804
2805
  c=g+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (text_getSubstring).");}switch(e){case "FROM_START":b=b.getAdjusted(a,"AT2",1);break;case "FROM_END":b=b.getAdjusted(a,"AT2",0,!1,S.SUBTRACTION);b=g+".length - "+b;break;case "LAST":b=g+".length";break;default:throw Error("Unhandled option (text_getSubstring).");}g=g+".slice("+c+", "+b+")"}else f=b.getAdjusted(a,"AT1"),a=b.getAdjusted(a,"AT2"),g=b.provideFunction_("subsequence"+c[d]+c[e],`
2805
2806
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(sequence${d==="FROM_END"||d==="FROM_START"?", at1":""}${e==="FROM_END"||e==="FROM_START"?", at2":""}) {
2806
- var start = ${rr("sequence",d,"at1")};
2807
- var end = ${rr("sequence",e,"at2")} + 1;
2807
+ var start = ${sr("sequence",d,"at1")};
2808
+ var end = ${sr("sequence",e,"at2")} + 1;
2808
2809
  return sequence.slice(start, end);
2809
2810
  }
2810
2811
  `)+"("+g+(d==="FROM_END"||d==="FROM_START"?", "+f:"")+(e==="FROM_END"||e==="FROM_START"?", "+a:"")+")";return[g,S.FUNCTION_CALL]},text_indexOf:function(a,b){var c=a.getFieldValue("END")==="FIRST"?"indexOf":"lastIndexOf",d=b.valueToCode(a,"FIND",S.NONE)||"''";b=(b.valueToCode(a,"VALUE",S.MEMBER)||"''")+"."+c+"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",S.ADDITION]:[b,S.FUNCTION_CALL]},text_isEmpty:function(a,b){return["!"+(b.valueToCode(a,"VALUE",S.MEMBER)||"''")+".length",S.LOGICAL_NOT]},
2811
- text_join:function(a,b){switch(a.itemCount_){case 0:return["''",S.ATOMIC];case 1:return a=b.valueToCode(a,"ADD0",S.NONE)||"''",qr(a);case 2:var c=b.valueToCode(a,"ADD0",S.NONE)||"''";a=b.valueToCode(a,"ADD1",S.NONE)||"''";return[qr(c)[0]+" + "+qr(a)[0],S.ADDITION];default:c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,S.NONE)||"''";return["["+c.join(",")+"].join('')",S.FUNCTION_CALL]}},text_length:function(a,b){return[(b.valueToCode(a,"VALUE",S.MEMBER)||"''")+".length",
2812
- S.MEMBER]},text_print:function(a,b){return"window.alert("+(b.valueToCode(a,"TEXT",S.NONE)||"''")+");\n"}};Ar.text_prompt=sr;Ar.text_prompt_ext=sr;Ar.text_replace=function(a,b){var c=b.valueToCode(a,"TEXT",S.NONE)||"''",d=b.valueToCode(a,"FROM",S.NONE)||"''";a=b.valueToCode(a,"TO",S.NONE)||"''";return[b.provideFunction_("textReplace",`
2812
+ text_join:function(a,b){switch(a.itemCount_){case 0:return["''",S.ATOMIC];case 1:return a=b.valueToCode(a,"ADD0",S.NONE)||"''",rr(a);case 2:var c=b.valueToCode(a,"ADD0",S.NONE)||"''";a=b.valueToCode(a,"ADD1",S.NONE)||"''";return[rr(c)[0]+" + "+rr(a)[0],S.ADDITION];default:c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,S.NONE)||"''";return["["+c.join(",")+"].join('')",S.FUNCTION_CALL]}},text_length:function(a,b){return[(b.valueToCode(a,"VALUE",S.MEMBER)||"''")+".length",
2813
+ S.MEMBER]},text_print:function(a,b){return"window.alert("+(b.valueToCode(a,"TEXT",S.NONE)||"''")+");\n"}};Br.text_prompt=tr;Br.text_prompt_ext=tr;Br.text_replace=function(a,b){var c=b.valueToCode(a,"TEXT",S.NONE)||"''",d=b.valueToCode(a,"FROM",S.NONE)||"''";a=b.valueToCode(a,"TO",S.NONE)||"''";return[b.provideFunction_("textReplace",`
2813
2814
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
2814
2815
  needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
2815
2816
  .replace(/\\x08/g, '\\\\x08');
2816
2817
  return haystack.replace(new RegExp(needle, 'g'), replacement);
2817
2818
  }
2818
- `)+"("+c+", "+d+", "+a+")",S.FUNCTION_CALL]};Ar.text_reverse=function(a,b){return[(b.valueToCode(a,"TEXT",S.MEMBER)||"''")+".split('').reverse().join('')",S.FUNCTION_CALL]};Ar.text_trim=function(a,b){var c={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(b.valueToCode(a,"TEXT",S.MEMBER)||"''")+c,S.FUNCTION_CALL]};var Br={};Br.variables_get=tr;Br.variables_set=ur;var Cr={};Cr.variables_get_dynamic=tr;Cr.variables_set_dynamic=ur;var Dr=new vr,Er=Object.assign({},{lists_create_empty:function(){return["[]",S.ATOMIC]},lists_create_with:function(a,b){var c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,S.NONE)||"null";return["["+c.join(", ")+"]",S.ATOMIC]},lists_getIndex:function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=b.valueToCode(a,"VALUE",d==="RANDOM"?S.NONE:S.MEMBER)||"[]";switch(d){case "FIRST":if(c==="GET")return[e+"[0]",S.MEMBER];if(c==="GET_REMOVE")return[e+
2819
+ `)+"("+c+", "+d+", "+a+")",S.FUNCTION_CALL]};Br.text_reverse=function(a,b){return[(b.valueToCode(a,"TEXT",S.MEMBER)||"''")+".split('').reverse().join('')",S.FUNCTION_CALL]};Br.text_trim=function(a,b){var c={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[a.getFieldValue("MODE")];return[(b.valueToCode(a,"TEXT",S.MEMBER)||"''")+c,S.FUNCTION_CALL]};var Cr={};Cr.variables_get=ur;Cr.variables_set=vr;var Dr={};Dr.variables_get_dynamic=ur;Dr.variables_set_dynamic=vr;var Er=new wr,Fr=Object.assign({},{lists_create_empty:function(){return["[]",S.ATOMIC]},lists_create_with:function(a,b){var c=Array(a.itemCount_);for(let d=0;d<a.itemCount_;d++)c[d]=b.valueToCode(a,"ADD"+d,S.NONE)||"null";return["["+c.join(", ")+"]",S.ATOMIC]},lists_getIndex:function(a,b){var c=a.getFieldValue("MODE")||"GET",d=a.getFieldValue("WHERE")||"FROM_START",e=b.valueToCode(a,"VALUE",d==="RANDOM"?S.NONE:S.MEMBER)||"[]";switch(d){case "FIRST":if(c==="GET")return[e+"[0]",S.MEMBER];if(c==="GET_REMOVE")return[e+
2819
2820
  ".shift()",S.MEMBER];if(c==="REMOVE")return e+".shift();\n";break;case "LAST":if(c==="GET")return[e+".slice(-1)[0]",S.MEMBER];if(c==="GET_REMOVE")return[e+".pop()",S.MEMBER];if(c==="REMOVE")return e+".pop();\n";break;case "FROM_START":a=b.getAdjusted(a,"AT");if(c==="GET")return[e+"["+a+"]",S.MEMBER];if(c==="GET_REMOVE")return[e+".splice("+a+", 1)[0]",S.FUNCTION_CALL];if(c==="REMOVE")return e+".splice("+a+", 1);\n";break;case "FROM_END":a=b.getAdjusted(a,"AT",1,!0);if(c==="GET")return[e+".slice("+
2820
2821
  a+")[0]",S.FUNCTION_CALL];if(c==="GET_REMOVE")return[e+".splice("+a+", 1)[0]",S.FUNCTION_CALL];if(c==="REMOVE")return e+".splice("+a+", 1);";break;case "RANDOM":e=b.provideFunction_("listsGetRandomItem",`
2821
2822
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
@@ -2830,8 +2831,8 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
2830
2831
  b.getAdjusted(a,"AT1");break;case "FROM_END":c=b.getAdjusted(a,"AT1",1,!1,S.SUBTRACTION);c=d+".length - "+c;break;case "FIRST":c="0";break;default:throw Error("Unhandled option (lists_getSublist).");}switch(f){case "FROM_START":b=b.getAdjusted(a,"AT2",1);break;case "FROM_END":b=b.getAdjusted(a,"AT2",0,!1,S.SUBTRACTION);b=d+".length - "+b;break;case "LAST":b=d+".length";break;default:throw Error("Unhandled option (lists_getSublist).");}d=d+".slice("+c+", "+b+")"}else{let g=b.getAdjusted(a,"AT1");a=
2831
2832
  b.getAdjusted(a,"AT2");d=b.provideFunction_("subsequence"+c[e]+c[f],`
2832
2833
  function ${b.FUNCTION_NAME_PLACEHOLDER_}(sequence${e==="FROM_END"||e==="FROM_START"?", at1":""}${f==="FROM_END"||f==="FROM_START"?", at2":""}) {
2833
- var start = ${kr("sequence",e,"at1")};
2834
- var end = ${kr("sequence",f,"at2")} + 1;
2834
+ var start = ${lr("sequence",e,"at1")};
2835
+ var end = ${lr("sequence",f,"at2")} + 1;
2835
2836
  return sequence.slice(start, end);
2836
2837
  }
2837
2838
  `)+"("+d+(e==="FROM_END"||e==="FROM_START"?", "+g:"")+(f==="FROM_END"||f==="FROM_START"?", "+a:"")+")"}return[d,S.FUNCTION_CALL]},lists_indexOf:function(a,b){var c=a.getFieldValue("END")==="FIRST"?"indexOf":"lastIndexOf",d=b.valueToCode(a,"FIND",S.NONE)||"''";b=(b.valueToCode(a,"VALUE",S.MEMBER)||"[]")+"."+c+"("+d+")";return a.workspace.options.oneBasedIndex?[b+" + 1",S.ADDITION]:[b,S.FUNCTION_CALL]},lists_isEmpty:function(a,b){return["!"+(b.valueToCode(a,"VALUE",S.MEMBER)||"[]")+".length",S.LOGICAL_NOT]},
@@ -2859,7 +2860,7 @@ function ${b.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
2859
2860
  var compare = compareFuncs[type];
2860
2861
  return function(a, b) { return compare(a, b) * direction; };
2861
2862
  }
2862
- `);return[c+".slice().sort("+b+'("'+a+'", '+d+"))",S.FUNCTION_CALL]},lists_split:function(a,b){var c=b.valueToCode(a,"INPUT",S.MEMBER);b=b.valueToCode(a,"DELIM",S.NONE)||"''";a=a.getFieldValue("MODE");if(a==="SPLIT")c||(c="''"),a="split";else if(a==="JOIN")c||(c="[]"),a="join";else throw Error("Unknown mode: "+a);return[c+"."+a+"("+b+")",S.FUNCTION_CALL]}},wr,xr,yr,zr,Ar,Br,Cr);for(let a in Er)Dr.forBlock[a]=Er[a];var Fr={};Fr.JavascriptGenerator=vr;Fr.Order=S;Fr.javascriptGenerator=Dr;$.__chunk_javascript=Fr;
2863
+ `);return[c+".slice().sort("+b+'("'+a+'", '+d+"))",S.FUNCTION_CALL]},lists_split:function(a,b){var c=b.valueToCode(a,"INPUT",S.MEMBER);b=b.valueToCode(a,"DELIM",S.NONE)||"''";a=a.getFieldValue("MODE");if(a==="SPLIT")c||(c="''"),a="split";else if(a==="JOIN")c||(c="[]"),a="join";else throw Error("Unknown mode: "+a);return[c+"."+a+"("+b+")",S.FUNCTION_CALL]}},xr,yr,zr,Ar,Br,Cr,Dr);for(let a in Fr)Er.forBlock[a]=Fr[a];var Gr={};Gr.JavascriptGenerator=wr;Gr.Order=S;Gr.javascriptGenerator=Er;$.__chunk_javascript=Gr;
2863
2864
  $.__chunk_javascript.__namespace__=$;
2864
2865
  return $.__chunk_javascript;
2865
2866
  }));