diff --git a/packages/blockly/build/blockly.loader.mjs b/packages/blockly/build/blockly.loader.mjs new file mode 100644 index 00000000000..feb4695c80f --- /dev/null +++ b/packages/blockly/build/blockly.loader.mjs @@ -0,0 +1,177 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; + + +export const { + Block, + BlockFlyoutInflater, + BlockNavigationPolicy, + BlockSvg, + Blocks, + BubbleNavigationPolicy, + ButtonFlyoutInflater, + COLLAPSED_FIELD_NAME, + COLLAPSED_INPUT_NAME, + COLLAPSE_CHARS, + CodeGenerator, + CollapsibleToolboxCategory, + CommentBarButtonNavigationPolicy, + CommentEditorNavigationPolicy, + ComponentManager, + Connection, + ConnectionChecker, + ConnectionDB, + ConnectionNavigationPolicy, + ConnectionType, + ContextMenu, + ContextMenuItems, + ContextMenuRegistry, + Css, + DELETE_VARIABLE_ID, + DeleteArea, + Direction, + DragDisposition, + DragTarget, + DropDownDiv, + Events, + Extensions, + Field, + FieldCheckbox, + FieldDropdown, + FieldImage, + FieldLabel, + FieldLabelSerializable, + FieldNavigationPolicy, + FieldNumber, + FieldTextInput, + FieldVariable, + Flyout, + FlyoutButton, + FlyoutButtonNavigationPolicy, + FlyoutItem, + FlyoutMetricsManager, + FlyoutNavigator, + FlyoutSeparator, + FlyoutSeparatorNavigationPolicy, + FocusManager, + FocusableTreeTraverser, + Generator, + Gesture, + Grid, + HorizontalFlyout, + INPUT_VALUE, + IconNavigationPolicy, + Input, + InsertionMarkerPreviewer, + KeyboardMover, + KeyboardNavigationController, + LabelFlyoutInflater, + Menu, + MenuItem, + MetricsManager, + MoveIndicator, + Msg, + NEXT_STATEMENT, + Names, + NavigationDirection, + Navigator, + OPPOSITE_TYPE, + OUTPUT_VALUE, + Options, + PREVIOUS_STATEMENT, + PROCEDURE_CATEGORY_NAME, + Procedures, + RENAME_VARIABLE_ID, + RenderedConnection, + Scrollbar, + ScrollbarPair, + SeparatorFlyoutInflater, + ShortcutItems, + ShortcutRegistry, + TOOLBOX_AT_BOTTOM, + TOOLBOX_AT_LEFT, + TOOLBOX_AT_RIGHT, + TOOLBOX_AT_TOP, + Theme, + ThemeManager, + Themes, + Toast, + Toolbox, + ToolboxCategory, + ToolboxItem, + ToolboxItemNavigationPolicy, + ToolboxNavigator, + ToolboxSeparator, + Tooltip, + Touch, + Trashcan, + UnattachedFieldError, + VARIABLE_CATEGORY_NAME, + VARIABLE_DYNAMIC_CATEGORY_NAME, + VERSION, + VariableMap, + VariableModel, + Variables, + VariablesDynamic, + VerticalFlyout, + WidgetDiv, + Workspace, + WorkspaceAudio, + WorkspaceCommentNavigationPolicy, + WorkspaceDragger, + WorkspaceNavigationPolicy, + WorkspaceSvg, + Xml, + ZoomControls, + blockAnimations, + blockRendering, + browserEvents, + bubbles, + bumpObjects, + clipboard, + comments, + common, + config, + constants, + defineBlocksWithJsonArray, + dialog, + dragging, + fieldRegistry, + geras, + getFocusManager, + getMainWorkspace, + getSelected, + hasBubble, + hideChaff, + icons, + inject, + inputs, + isBoundedElement, + isCopyable, + isDeletable, + isDraggable, + isIcon, + isObservable, + isPaster, + isRenderedElement, + isSelectable, + isSerializable, + isVariableBackedParameterModel, + keyboardNavigationController, + layers, + navigateBlock, + procedures, + registry, + renderManagement, + serialization, + setLocale, + setParentContainer, + svgResize, + thrasos, + uiPosition, + utils, + zelos, +} = await loadChunk( + 'build/src/core/blockly.js', + 'dist/blockly_compressed.js', + 'Blockly', +); diff --git a/packages/blockly/build/blocks.loader.mjs b/packages/blockly/build/blocks.loader.mjs new file mode 100644 index 00000000000..eb424ef4f42 --- /dev/null +++ b/packages/blockly/build/blocks.loader.mjs @@ -0,0 +1,18 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; +import './blockly.loader.mjs'; + +export const { + blocks, + lists, + logic, + loops, + math, + procedures, + texts, + variables, + variablesDynamic, +} = await loadChunk( + 'build/src/blocks/blocks.js', + 'dist/blocks_compressed.js', + 'Blockly.libraryBlocks', +); diff --git a/packages/blockly/build/dart.loader.mjs b/packages/blockly/build/dart.loader.mjs new file mode 100644 index 00000000000..a1d3c0c4bac --- /dev/null +++ b/packages/blockly/build/dart.loader.mjs @@ -0,0 +1,12 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; +import './blockly.loader.mjs'; + +export const { + DartGenerator, + Order, + dartGenerator, +} = await loadChunk( + 'build/src/generators/dart.js', + 'dist/dart_compressed.js', + 'dart', +); diff --git a/packages/blockly/build/javascript.loader.mjs b/packages/blockly/build/javascript.loader.mjs new file mode 100644 index 00000000000..741aed5ab3a --- /dev/null +++ b/packages/blockly/build/javascript.loader.mjs @@ -0,0 +1,12 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; +import './blockly.loader.mjs'; + +export const { + JavascriptGenerator, + Order, + javascriptGenerator, +} = await loadChunk( + 'build/src/generators/javascript.js', + 'dist/javascript_compressed.js', + 'javascript', +); diff --git a/packages/blockly/build/lua.loader.mjs b/packages/blockly/build/lua.loader.mjs new file mode 100644 index 00000000000..dff0c896952 --- /dev/null +++ b/packages/blockly/build/lua.loader.mjs @@ -0,0 +1,12 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; +import './blockly.loader.mjs'; + +export const { + LuaGenerator, + Order, + luaGenerator, +} = await loadChunk( + 'build/src/generators/lua.js', + 'dist/lua_compressed.js', + 'lua', +); diff --git a/packages/blockly/build/php.loader.mjs b/packages/blockly/build/php.loader.mjs new file mode 100644 index 00000000000..b4bc78c512b --- /dev/null +++ b/packages/blockly/build/php.loader.mjs @@ -0,0 +1,12 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; +import './blockly.loader.mjs'; + +export const { + Order, + PhpGenerator, + phpGenerator, +} = await loadChunk( + 'build/src/generators/php.js', + 'dist/php_compressed.js', + 'php', +); diff --git a/packages/blockly/build/python.loader.mjs b/packages/blockly/build/python.loader.mjs new file mode 100644 index 00000000000..e075bac658d --- /dev/null +++ b/packages/blockly/build/python.loader.mjs @@ -0,0 +1,12 @@ +import {loadChunk} from '../tests/scripts/load.mjs'; +import './blockly.loader.mjs'; + +export const { + Order, + PythonGenerator, + pythonGenerator, +} = await loadChunk( + 'build/src/generators/python.js', + 'dist/python_compressed.js', + 'python', +); diff --git a/packages/blockly/dist/blockly_compressed.js b/packages/blockly/dist/blockly_compressed.js new file mode 100644 index 00000000000..dd0e77f9e8f --- /dev/null +++ b/packages/blockly/dist/blockly_compressed.js @@ -0,0 +1,1835 @@ +// Do not edit this file; automatically generated. + +/* eslint-disable */ +;(function(root, factory) { + if (typeof define === 'function' && define.amd) { // AMD + define([], factory); + } else if (typeof exports === 'object') { // Node.js + module.exports = factory(); + } else { // Script + root.Blockly = factory(); + } +}(this, function() { +var $={}; +var ca,aa,ea,fa,da,k,ka,la,ma,oa,pa,qa,n,ta,ua,va,wa,xa,ya,Aa,Ca,p,Ha,Ia,Ea,Ja,La,Ma,t,Na,Oa,u,Pa,Qa,Ua,$a,z,v,bb,cb,eb,fb,gb,hb,kb,lb,nb,mb,pb,ob,rb,tb,ub,vb,xb,Ga,zb,Ab,Bb,Db,Eb,Fb,Gb,Ib,Jb,Kb,Lb,Mb,Ob,Sb,Tb,$b,ac,bc,Ub,Wb,kc,ic,jc,sc,qc,uc,wc,zc,Cc,Dc,Ec,Gc,Ic,Kc,Ac,Mc,Nc,Oc,Qc,Rc,Tc,Sc,Vc,Wc,Xc,Yc,$c,ad,cd,bd,gd,dd,hd,ld,md,nd,od,pd,qd,rd,sd,zd,Ad,vd,ud,wd,Ed,Dd,Cd,Fd,xd,Hd,Id,Kd,Jd,yd,Ld,Md,Rd,Ud,Vd,Wd,$d,ae,Zd,Yd,ce,je,ke,ie,me,Td,le,he,pe,qe,re,se,ue,te,ye,xe,Ae,Ee,Fe,Be,Ce,De,Qe,Ie,Re,Se, +Pe,We,Ve,Xe,Ye,Ze,bf,cf,df,ef,ff,jf,lf,sf,hf,tf,uf,vf,wf,xf,Ff,Af,Cf,Kf,Ef,zf,Jf,Pf,Rf,Sf,Tf,Uf,Xf,Vf,Zf,$f,ag,Lf,bg,ig,jg,gg,kg,lg,mg,rg,sg,qg,vg,pg,xg,Bg,yg,Cg,Eg,Fg,Gg,hg,tg,Kg,Ng,Mg,Og,Mf,Pg,Qg,Wg,Xg,$g,dh,eh,fh,gh,bh,ch,ah,qh,lh,kh,ph,rh,wh,xh,G,yh,zh,Ah,Bh,Ch,H,Dh,Eh,Fh,Hh,Gh,Ih,Mh,Lh,Jh,Qh,Oh,Ph,Rh,Uh,Th,Vh,Wh,Xh,Yh,Zh,$h,ai,bi,ci,ei,di,fi,ki,li,ni,mi,oi,ri,si,ti,ui,vi,wi,Ai,Bi,Di,Ii,Ki,Ji,Li,Mi,Ni,Pi,Qi,Si,Ti,Ui,Wi,Xi,dj,ej,fj,hj,ij,jj,kj,lj,mj,oj,pj,qj,rj,sj,tj,vj,xj,yj,zj,Bj,Cj,Dj,Ej,Fj, +Hj,Jj,Kj,Oj,Pj,Qj,Rj,Uj,Vj,Wj,Yj,Zj,ak,bk,ck,dk,ek,fk,gk,hk,ik,kk,nk,ok,pk,qk,rk,sk,tk,uk,vk,xk,yk,Ck,zk,Bk,Ek,Fk,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}; +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;m0;b--){let c=Fa[b-1];if(c.group!==a.group||c.workspaceId!==a.workspaceId||c.type!==q.BLOCK_MOVE||c.newParentId!==a.blockId)break}Fa.splice(b,0,a)}else Fa.push(a)}; +Ea=function(a){var b=[];for(let c of a)if(a=b[b.length-1],!c.isNull())if(!a||a.workspaceId!==c.workspaceId||a.group!==c.group)b.push(c);else if(c.type===q.BLOCK_MOVE&&a.type===q.BLOCK_MOVE&&c.blockId===a.blockId){if(a.newParentId=c.newParentId,a.newInputName=c.newInputName,a.newCoordinate=c.newCoordinate,a.reason||c.reason){let d,e;a.reason=Array.from(new Set(((d=a.reason)!=null?d:[]).concat((e=c.reason)!=null?e:[])))}}else if(c.type===q.BLOCK_CHANGE&&a.type===q.BLOCK_CHANGE&&c.blockId===a.blockId&& +c.element===a.element&&c.name===a.name)a.newValue=c.newValue;else if(c.type===q.VIEWPORT_CHANGE&&a.type===q.VIEWPORT_CHANGE)a.viewTop=c.viewTop,a.viewLeft=c.viewLeft,a.scale=c.scale,a.oldScale=c.oldScale;else if(c.type!==q.CLICK||a.type!==q.BUBBLE_OPEN)c.type===q.SELECTED&&a.type===q.SELECTED&&a.newElementId===void 0?(a.newElementId=c.newElementId,a.oldElementId===a.newElementId&&b.pop()):b.push(c);return a=b.filter(c=>!c.isNull())};Ja=function(){for(let a=0,b;b=Fa[a];a++)b.recordUndo=!1}; +La=function(){return $.Ka===0};$.r=function(a){Da.setGroupInternal(a)};Ma=function(a){var b=[];a=a.getDescendants(!1);for(let c=0,d;d=a[c];c++)b[c]=d.id;return b};t=function(a){var b=ua(l.EVENT,a,void 0);if(!b)throw Error(`Event type ${a} not found in registry.`);return b};Na=function(a){a.removeAttribute("role")};Oa=function(a,b){b?a.setAttribute("role",b):Na(a)};u=function(a,b,c){Array.isArray(c)&&(c=c.join(" "));a.setAttribute("aria-"+b,`${c}`)};Pa=function(a,b){a.removeAttribute("aria-"+b)}; +Qa=function(a,b){return(a=a.getAttribute("aria-"+b))?a:null};Ua=function(a){if(!Ra||!document.contains(Ra)){var b=document.createElement("div");b.textContent="";b.id="blocklyAriaAnnounce";v(b,"hiddenForAria");u(b,w.LIVE,Sa.POLITE);Oa(b,Ta);u(b,w.ATOMIC,!0);a.appendChild(b);Ra=b}}; +$a=function(a,b){if(!Ra)throw Error("ARIA live region not initialized.");var c=Ra,{assertiveness:d=Sa.POLITE,role:e=Ta}=b||{};Va.push(a);Wa=d===Sa.ASSERTIVE||Wa===Sa.ASSERTIVE?Sa.ASSERTIVE:d===Sa.POLITE||Wa===Sa.POLITE?Sa.POLITE:Sa.OFF;clearTimeout(Ya);Ya=setTimeout(()=>{c.replaceChildren();u(c,w.LIVE,Wa);Oa(c,e);var f=document.createElement("span");f.textContent=Va.join("\n")+(Za?"\u00a0":"");Za=!Za;c.appendChild(f);Va.length=0;Wa=Sa.OFF},10)}; +z=function(a,b,c){var d=document.createElementNS("http://www.w3.org/2000/svg",`${a}`);a!==x.SVG.toString()&&a!==x.G.toString()&&d.tagName!==x.SVG.toString()&&d.tagName!==x.G.toString()||Oa(d,ab.NONE);for(let e in b)d.setAttribute(e,`${b[e]}`);c&&c.appendChild(d);return d};v=function(a,b){b=b.split(" ");if(b.every(c=>a.classList.contains(c)))return!1;a.classList.add(...b);return!0};bb=function(a,b){a.classList.remove(...b.split(" "))}; +cb=function(a,b){b=b.split(" ");if(b.every(c=>!a.classList.contains(c)))return!1;a.classList.remove(...b);return!0};eb=function(a,b){return a.classList.contains(b)};fb=function(a){return a&&a.parentNode?a.parentNode.removeChild(a):null};gb=function(a,b){var c=b.nextSibling;b=b.parentNode;if(!b)throw Error("Reference node has no parent.");c?b.insertBefore(a,c):b.appendChild(a)};hb=function(a,b){a.style.transform=b;a.style["-webkit-transform"]=b};kb=function(){ib++;jb||(jb=Object.create(null))}; +lb=function(){ib--;ib||(jb=null)};nb=function(a){return mb(a).width};mb=function(a){var b=window.getComputedStyle(a);return ob(a,b.fontSize,b.fontWeight,b.fontFamily,b.letterSpacing,b.wordSpacing)};pb=function(a,b,c,d,e,f){return ob(a,b,c,d,e,f).width}; +ob=function(a,b,c,d,e,f){var g=a.textContent;a=g+"\n"+`${b}-${c}-${d}-${e}-${f}`;var h;if(jb&&(h=jb[a]))return h;qb||(h=document.createElement("canvas"),h.className="blocklyComputeCanvas",document.body.appendChild(h),qb=h.getContext("2d"));g&&qb?(qb.font=c+" "+b+" "+d,qb.letterSpacing=e&&e!=="normal"?e:"0px",qb.wordSpacing=f&&f!=="normal"?f:"0px",b=qb.measureText(g),h={width:Math.ceil(b.width),height:Math.ceil(b.fontBoundingBoxAscent+b.fontBoundingBoxDescent)}):h={width:0,height:0};jb&&(jb[a]=h); +return h}; +rb=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}; +$.A=function(){return sb.getFocusManager()};tb=function(a){return a&&typeof a.getFocusableElement==="function"&&typeof a.getFocusableTree==="function"&&typeof a.onNodeFocus==="function"&&typeof a.onNodeBlur==="function"&&typeof a.canBeFocused==="function"};ub=function(a){return tb(a)&&typeof a.id==="string"&&typeof a.workspace==="object"&&typeof a.select==="function"&&typeof a.unselect==="function"}; +vb=function(a,b){for(let c in b)b[c]!==null&&Array.isArray(b[c])?a[c]=vb(a[c]||[],b[c]):a[c]=b[c]!==null&&typeof b[c]==="object"?vb(a[c]||Object.create(null),b[c]):b[c];return a};xb=function(a,b,c,d){a=a+" was deprecated in "+b+" and will be deleted in "+c+".";d&&(a+="\nUse "+d+" instead.");wb.has(a)||(wb.add(a),console.warn(a))};Ga=function(a){return yb[a]||null};zb=function(){var a=[];for(let b in yb)a.push(yb[b]);return a};Ab=function(a){yb[a.id]=a};Bb=function(a){delete yb[a.id]};Db=function(){return Cb}; +Eb=function(a){Cb=a;a.rendered&&$.A().setPopoverFocusRoot(a.getInjectionDiv())};Fb=function(){var a=$.A().getFocusedNode();return a&&ub(a)?a:null};Gb=function(a){var b=Fb(),c,d,e,f,g=new (t(q.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:"");p(g)};Ib=function(a=Cb){return Hb?Hb:a&&a.rendered?a.getInjectionDiv():null};Jb=function(a){Hb=a}; +Kb=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()}}; +Lb=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};Mb=function(a){return function(){this.jsonInit(a)}};Ob=function(a){Nb.defineBlocksWithJsonArrayInternal(a)};$.Pb=function(a){var b={};for(let c=0;c{Yb=b;Zb=window.requestAnimationFrame(()=>{Wb();b()})}));return Xb};ac=function(){return Xb?Xb:Promise.resolve()};bc=function(a){a||window.cancelAnimationFrame(Zb);Wb(a);!a&&Yb&&Yb()};Ub=function(a){cc.add(a);dc.set(a,{group:$.ec,recordUndo:$.fc});var b=a.getParent();b?Ub(b):hc.add(a)}; +Wb=function(a){var b=a?new Set([a]):new Set([...hc].map(g=>g.workspace)),c=[...hc].filter(ic).filter(g=>b.has(g.workspace));for(var d of c)jc(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=$.ec;f=$.fc;if(d=dc.get(g))d.group&&$.r(d.group),$.fc=d.recordUndo;g.bumpNeighbours(); +$.r(e);$.fc=f}for(let g of c)kc(g);a||(Xb=null)};kc=function(a){hc.delete(a);cc.delete(a);dc.delete(a);for(let b of a.getChildren(!1))kc(b)};ic=function(a){return!a.isDisposed()&&!a.getParent()};jc=function(a){if(cc.has(a)&&a.initialized){for(let b of a.getChildren(!1))jc(b);a.renderEfficiently()}};$.mc=function(a){return lc.createElementNS("https://developers.google.com/blockly/xml",a)};$.nc=function(a){return lc.createTextNode(a)}; +$.pc=function(a){var b=oc.parseFromString(a,"text/xml");if(b&&b.documentElement&&!b.getElementsByTagName("parsererror").length)return b.documentElement;if((b=oc.parseFromString(a,"text/html"))&&b.body.firstChild&&b.body.firstChild.nodeName.toLowerCase()==="xml")return b.body.firstChild;throw Error(`DOMParser was unable to parse: ${a}`);};sc=function(a){return qc(rc.serializeToString(a))};qc=function(a){return a.replace(tc,b=>`&#${b.charCodeAt(0)};`)}; +uc=function(a){Object.keys(a).forEach(function(b){$.C[b]=a[b]})};wc=function(a){vc.push(a)};zc=function(a,b,c){b&&typeof window!=="undefined"&&(a=a.getRootNode(),xc.has(a)||(xc.add(a),c=c.replace(/[\\/]$/,""),c=[yc,...vc].join("\n").replace(/<<>>/g,c),b=document.createElement("style"),b.id="blockly-common-style",b.textContent=c,(typeof globalThis.ShadowRoot!=="undefined"&&a instanceof ShadowRoot?a:document.head).prepend(b)))};Cc=function(a,b){Ac(Bc.ALERT,a,b,void 0)}; +Dc=function(a,b){Ac(Bc.CONFIRM,a,b,void 0)};Ec=function(a,b,c){Ac(Bc.PROMPT,a,c,b)};Gc=function(a,b){Fc(a,b)};Ic=function(a,b){Hc(a,b)};Kc=function(a,b,c){Jc(a,b,c)}; +Ac=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"),y=document.createElement("button");e.className="blocklyDialog";f.className="blocklyDialogForm";g.className="blocklyDialogPrompt";m.className="blocklyDialogButtonRow";y.className="blocklyDialogConfirmButton";f.setAttribute("method","dialog");g.textContent=b;g.setAttribute("for","blockly-form-input");y.textContent= +$.C.DIALOG_OK;y.value="ok";e.appendChild(f);f.appendChild(g);a===Bc.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(y);if(a===Bc.CONFIRM||a===Bc.PROMPT)b=document.createElement("button"),b.className="blocklyDialogCancelButton",b.textContent=$.C.DIALOG_CANCEL,b.value="cancel",m.appendChild(b);f.appendChild(m);var F;Lc===0&&(F=$.A().ephemeralFocusTaken()?void 0:$.A().takeEphemeralFocus(e)); +Lc++;e.addEventListener("close",()=>{Lc--;if(!Lc){let J;(J=F)==null||J()}e.remove();switch(a){case Bc.CONFIRM:c(e.returnValue==="ok");break;case Bc.PROMPT:c(e.returnValue==="ok"?h.value:null);break;case Bc.ALERT:c==null||c()}});document.body.appendChild(e);e.showModal()};Mc=function(a){return typeof a.bubbleIsVisible==="function"&&typeof a.setBubbleVisible==="function"&&typeof a.getBubble==="function"};Nc=function(a,b){n(l.SERIALIZER,a,b)}; +Oc=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}; +Qc=function(a,b,{recordUndo:c=!1}={}){var d=$.fc;$.fc=c;c=b.newComment(a.id);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 Pc((f=a.width)!=null?f:e.width,(g=a.height)!=null?g:e.height))}a.text!==void 0&&c.setText(a.text);a.collapsed!==void 0&&c.setCollapsed(a.collapsed);a.editable!==void 0&&c.setEditable(a.editable); +a.movable!==void 0&&c.setMovable(a.movable);a.deletable!==void 0&&c.setDeletable(a.deletable);$.fc=d;return c};Rc=function(a,b){n(l.PASTER,a,b)};Tc=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());Sc(D.sum(c,d),e);)d.translate(b.RTL?-30:30,30);a.moveTo(D.sum(c,d))};Sc=function(a,b){return b.some(c=>Math.abs(c.x-a.x)<=1&&Math.abs(c.y-a.y)<=1)};Vc=function(a){return Uc.getSizeInternal(a)}; +Wc=function(a,b){a=window.getComputedStyle(a);return a[b]||a.getPropertyValue(b)};Xc=function(a){var b=new D(0,0);a=a.getBoundingClientRect();var c=document.documentElement;c=new D(window.pageXOffset||c.scrollLeft,window.pageYOffset||c.scrollTop);b.x=a.left+c.x;b.y=a.top+c.y;return b};Yc=function(){var a=document.body,b=document.documentElement;return new D(a.scrollLeft||b.scrollLeft,a.scrollTop||b.scrollTop)}; +$c=function(a){var b=parseFloat(Wc(a,"borderLeftWidth")),c=parseFloat(Wc(a,"borderRightWidth")),d=parseFloat(Wc(a,"borderTopWidth"));a=parseFloat(Wc(a,"borderBottomWidth"));return new Zc(d,a,b,c)};ad=function(a,b,c){var d=c.getBoundingClientRect();c=$c(c);return new D(a-(d.left+window.scrollX+c.left),b-(d.top+window.scrollY+c.top))};cd=function(a,b,c){a=bd(a,b,c);b.scrollLeft=a.x;b.scrollTop=a.y}; +bd=function(a,b,c){var d=Xc(a),e=Xc(b),f=$c(b),g=d.x-e.x-f.left;d=d.y-e.y-f.top;e=new Pc(a.offsetWidth,a.offsetHeight);a=b.clientWidth-e.width;e=b.clientHeight-e.height;f=b.scrollLeft;b=b.scrollTop;c?(f+=g-a/2,b+=d-e/2):(f+=Math.min(g,Math.max(g-a,0)),b+=Math.min(d,Math.max(d-e,0)));return new D(f,b)};gd=function(a){a=dd(a,ed);return a.length?a[0].join(fd?" ":" + "):""}; +dd=function(a,b){a=B.registry.getKeyCodesByShortcutName(a);if(a.length===0)return[];a=a.map(d=>d.split("+"));a.forEach(d=>d.sort((e,f)=>{e=hd(e);f=hd(f);return e-f}));a.sort((d,e)=>{d=d.includes("Meta")?1:0;return(e.includes("Meta")?1:0)-d});var c=a.filter(d=>d.includes("Meta")===fd);c=c.length===0?a:c;c.sort((d,e)=>d.length-e.length);return(c.some(d=>d.some(e=>"Meta"===e||"Alt"===e||"Control"===e))?[c[0]]:c).map(d=>d.map(e=>{if(Number.isFinite(+e))if(e=+e,e>=65&&e<=90)e=String.fromCharCode(e);else{var f= +{8:$.C.BACKSPACE_KEY,9:$.C.TAB_KEY,13:$.C.ENTER_KEY,16:$.C.SHIFT_KEY,17:$.C.CONTROL_KEY,18:$.C.ALT_KEY,19:$.C.PAUSE_KEY,20:$.C.CAPS_LOCK_KEY,27:$.C.ESCAPE,32:$.C.SPACE_KEY,33:$.C.PAGE_UP_KEY,34:$.C.PAGE_DOWN_KEY,35:$.C.END_KEY,36:$.C.HOME_KEY,37:"\u2190",38:"\u2191",39:"\u2192",40:"\u2193",45:$.C.INSERT_KEY,46:$.C.DELETE_KEY,48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",93:$.C.CONTEXT_MENU_KEY,96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8", +105:"9",106:"\u00d7",107:"+",109:"\u2212",110:".",111:"\u00f7",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",186:";",187:"=",189:"-",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"\u2318"}[e];f?e=f:(console.warn("Unknown key code: "+e),e=String.fromCharCode(e))}return e}).map(e=>{var f,g=(f=b[e])!=null?f:e;return g.charAt(0).toUpperCase()+g.substring(1)}))}; +hd=function(a){a=id.indexOf(a);return a===-1?Number.MAX_VALUE:a};ld=function(a){var b=new D(0,0),c=a.x&&a.getAttribute("x"),d=a.y&&a.getAttribute("y");c&&(b.x=parseInt(c));d&&(b.y=parseInt(d));if(c=(c=a.getAttribute("transform"))&&c.match(jd))b.x+=Number(c[1]),c[3]&&(b.y+=Number(c[3]));(a=a.getAttribute("style"))&&a.includes("translate")&&(a=a.match(kd))&&(b.x+=Number(a[1]),a[3]&&(b.y+=Number(a[3])));return b}; +md=function(a){for(var b=0,c=0;a;){let d=ld(a);b+=d.x;c+=d.y;if((" "+(a.getAttribute("class")||"")+" ").includes(" injectionDiv "))break;a=a.parentNode}return new D(b,c)};nd=function(){var a=Yc();return new Zc(a.y,document.documentElement.clientHeight+a.y,a.x,document.documentElement.clientWidth+a.x)};od=function(){var a=document.documentElement,b=window;return new D(b.pageXOffset||a.scrollLeft,b.pageYOffset||a.scrollTop)}; +pd=function(a,b){var c=b.x;b=b.y;var d=a.getInjectionDiv().getBoundingClientRect();c=new D(c-d.left,b-d.top);b=a.getOriginOffsetInPixels();return D.difference(c,b).scale(1/a.scale)};qd=function(a,b){var c=b.scale(a.scale);b=c.x;c=c.y;var d=a.getInjectionDiv().getBoundingClientRect();a=a.getOriginOffsetInPixels();return new D(b+d.left+a.x,c+d.top+a.y)}; +rd=function(a){return a&&typeof a.init==="function"&&typeof a.getDiv==="function"&&typeof a.getId==="function"&&typeof a.getParent==="function"&&typeof a.getLevel==="function"&&typeof a.isSelectable==="function"&&typeof a.isCollapsible==="function"&&typeof a.dispose==="function"&&typeof a.getClickTarget==="function"&&typeof a.setVisible_==="function"&&typeof a.getParentToolbox==="function"}; +sd=function(a){return typeof a.getName==="function"&&typeof a.getContents==="function"&&typeof a.setSelected==="function"&&typeof a.onClick==="function"&&rd(a)&&a.isSelectable()}; +zd=function(a,b=td.STANDARD,c){return[b>=td.STANDARD&&ud(a),vd(a),...wd(a,b,c),b===td.LOQUACIOUS&&xd(a),b>=td.STANDARD&&(a.isEnabled()?void 0:$.C.BLOCK_LABEL_DISABLED),b>=td.STANDARD&&(a.isCollapsed()?$.C.BLOCK_LABEL_COLLAPSED:void 0),b>=td.LOQUACIOUS&&(a.isShadow()?$.C.BLOCK_LABEL_REPLACEABLE:void 0),b>=td.STANDARD&&yd(a),b>=td.LOQUACIOUS&&a.getAriaRoleDescription()].filter(d=>!!d).join(", ")}; +Ad=function(a,b,c=td.STANDARD){var d=c>=td.LOQUACIOUS,e=[],f=a.fieldRow.filter(h=>h.isVisible()).flatMap((h,m,y)=>{if(h.isLabelField()){if(m=1)return e.push(h.computeAriaLabel(d)),h=e.join(" "),e=[],h}return h.computeAriaLabel(d)});if(!f.length&&b){let h=a.getSourceBlock().inputList,m=h.indexOf(a);if(m>0)return Ad(h[m-1],b,c)}var g;a.type===$.Bd.VALUE&&((g=a.connection)==null?void 0:g.targetConnection)===null&& +c>=td.STANDARD&&f.push($.C.INPUT_LABEL_EMPTY);return f.filter(h=>!!h)}; +vd=function(a){var b,c,d,e=(b=(d=a.outputConnection)!=null?d:a.previousConnection)==null?void 0:(c=b.targetConnection)==null?void 0:c.getParentInput();if(e&&(a=e.getSourceBlock(),!a.isInsertionMarker())){if(b=e.getAriaLabelText())a=b;else{if(!a.statementInputCount)return;b=a.inputList.find(f=>f.type===$.Bd.STATEMENT);if(e===b)return;a=Cd(a,e,!1);if(!a.length)return;a=a.join(", ")}return e.type===$.Bd.STATEMENT?(e=Array.isArray(a)?a.join(" "):a,$.C.BLOCK_LABEL_BEGIN_PREFIX.replace("%1",e)):a}}; +ud=function(a){if(!a.isInFlyout&&!a.isDragging())return a.getRootBlock()===a?$.C.BLOCK_LABEL_BEGIN_STACK:void 0}; +wd=function(a,b=td.STANDARD,c){if(c)return[c];c=a=a.inputList.filter(e=>e.isVisible());if(b<=td.STANDARD){let e=a.filter(f=>f.type===$.Bd.STATEMENT);e.length>1&&(c=a.slice(0,a.indexOf(e[0])+1))}var d=[];return c.flatMap((e,f,g)=>{var h=e.getLabel(b),m;if(m=f0?(d.push(h),e=d.join(" "),d=[],e):h})};Ed=function(a){a=a.fieldRow.filter(b=>b.isVisible());return a.length>0&&a[0].isLabelField()};Dd=function(a){if(a.type===$.Bd.VALUE||a.type===$.Bd.STATEMENT)return!1;a=a.fieldRow.filter(b=>b.isVisible());return a.length>0&&a[a.length-1].isLabelField()}; +Cd=function(a,b,c){var d=a.inputList.indexOf(b);if(d===-1)throw Error(`Input with name "${b.name}" not found on block with id "${a.id}".`);var e=b.type===$.Bd.STATEMENT,f=e?Fd(a.inputList,d):d,g=a.inputList.slice(f,d+1).filter(y=>y.isVisible()),h=g.map(y=>y.getLabel(td.TERSE,y!==b||c)),m=e&&h.slice(0,-1).some(y=>!!y);return h.map((y,F)=>{if(y)return y;y=g[F];if(!(y.type===$.Bd.DUMMY||y.type===$.Bd.END_ROW||e&&F===h.length-1&&m))return $.C.INPUT_LABEL_INDEX.replace("%1",(y.getIndex()+1).toString())}).filter(y=> +y!==void 0)};Fd=function(a,b){for(--b;b>=0;b--)if(a[b].type===$.Bd.STATEMENT)return b+1;return 0};xd=function(a){var b=a.workspace.getToolbox();if(b){var c=void 0;for(let d of b.getToolboxItems()){if(!sd(d))continue;b=d.getContents();if(Array.isArray(b)&&b.some(e=>e.kind.toLowerCase()==="block"&&"type"in e&&e.type===a.type)){c=d;break}"getColour"in d&&typeof d.getColour==="function"&&d.getColour()===a.getColour()&&(c=d)}if(c)return $.C.BLOCK_LABEL_TOOLBOX_CATEGORY.replace("%1",c.getName())}}; +Hd=function(a){switch(a){case Gd.BEFORE:return $.C.ANNOUNCE_MOVE_BEFORE;case Gd.AFTER:return $.C.ANNOUNCE_MOVE_AFTER;case Gd.INSIDE:return $.C.ANNOUNCE_MOVE_INSIDE;case Gd.AROUND:return $.C.ANNOUNCE_MOVE_AROUND;default:return $.C.ANNOUNCE_MOVE_TO}};Id=function(a,b){var c=a.getParentInput();if(!c)return b;var d=c.getAriaLabelText();if(!d){a=Cd(a.getSourceBlock(),c,!0);if(!a.length)return b;d=a.join(", ")}return b?$.C.ANNOUNCE_MOVE_OF.replace("%1",d).replace("%2",b):d}; +Kd=function(a,b,c,d=!1){var e=Jd(a,b),f=Hd(e),g=![Gd.BEFORE,Gd.AFTER].includes(e);e=g&&c(!0);c=g&&c(!1);d=d?a.getSourceBlock().getStackBlocksCountLabel():"";g=b.getSourceBlock().getAriaLabel(td.TERSE);e&&(d=Id(a,d));c&&(g=Id(b,g));return f.replace("%1",d).replace("%2",g)}; +Jd=function(a,b){switch(a.type){case E.INPUT_VALUE:case E.OUTPUT_VALUE:return Gd.TO;case E.NEXT_STATEMENT:return a===a.getSourceBlock().nextConnection?Gd.BEFORE:Gd.AROUND;case E.PREVIOUS_STATEMENT:return b===b.getSourceBlock().nextConnection?Gd.AFTER:Gd.INSIDE}return Gd.UNKNOWN}; +yd=function(a){var b=a.inputList.filter(c=>c.type===$.Bd.STATEMENT).length;if(b>1)return $.C.BLOCK_LABEL_HAS_BRANCHES.replace("%1",b.toString());switch(a.inputList.reduce((c,d)=>{var e;return d.fieldRow.reduce((f,g)=>g.EDITABLE&&!g.isFullBlockField()?++f:f,c)+(((e=d.connection)==null?void 0:e.type)===E.INPUT_VALUE?1:0)},0)){case 0:break;case 1:return $.C.BLOCK_LABEL_HAS_INPUT;default:return $.C.BLOCK_LABEL_HAS_INPUTS}};Ld=function(a){return a*Math.PI/180}; +Md=function(a,b,c){if(c{Sb(a);a.stopPropagation()}),Qd=document.createElement("div"),Qd.className="blocklyDropDownArrow",Nd.appendChild(Qd),Nd.style.opacity="0",Nd.style.transition="transform 0.25s, opacity 0.25s")}; +Ud=function(){Sd&&(Sd(!1),Sd=null);Td()};Vd=function(){Pd&&(la(Pd),Pd=null);Nd.remove();Rd()};Wd=function(a,b){Nd.style.backgroundColor=a;Nd.style.borderColor=b};$d=function(a,b,c,d=!0){Xd=!0;return Yd(Zd(a),a,d,b,c)};ae=function(a){var b=a.getSvgRoot(),c=a.workspace.scale,d=a.height*c;a=a.width*c;b=Xc(b);return new Zc(b.y,b.y+d,b.x,b.x+a)};Zd=function(a){a=a.getScaledBBox();return new Zc(a.top,a.bottom,a.left,a.right)}; +Yd=function(a,b,c,d,e){var f=a.left+(a.right-a.left)/2,g=a.bottom;a=a.top;e&&(a+=e);e=b.getSourceBlock();for(var h=e.workspace;h.options.parentWorkspace;)h=h.options.parentWorkspace;be=h.getParentSvg().parentNode;return ce(b,e.RTL,f,g,f,a,c,d)}; +ce=function(a,b,c,d,e,f,g,h){$.A().registerPopoverFocusLossHandler(Ud);var m;(m=Ib())==null||m.appendChild(Nd);de=a;ee=h||null;Nd.style.direction=b?"rtl":"ltr";a=Cb;fe=a.getRenderer().getClassName();ge=a.getTheme().getClassName();v(Nd,fe);v(Nd,ge);b=Qa(a.getFocusableElement(),w.OWNS);u(a.getFocusableElement(),w.OWNS,b?[b,Nd.id]:Nd.id);a.getFocusableElement().classList.add("blocklyShowingDropDownDiv");c=he(c,d,e,f);g&&(Sd=$.A().takeEphemeralFocus(Nd));return c}; +je=function(a,b,c,d){a=ie(a,c.left,c.right,d.width);return{initialX:a.divX,initialY:b,finalX:a.divX,finalY:b+16,arrowX:a.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}};ke=function(a,b,c,d){a=ie(a,c.left,c.right,d.width);return{initialX:a.divX,initialY:b-d.height,finalX:a.divX,finalY:b-d.height-16,arrowX:a.arrowX,arrowY:d.height-2-8,arrowAtTop:!1,arrowVisible:!0}};ie=function(a,b,c,d){b=Md(b,a-d/2,c-d);a=a-8-b;a=Md(12,a,d-12-16);return{arrowX:a,divX:b}}; +me=function(a,b){return de===a?(b?le():Td(),!0):!1};Td=function(){de&&($.A().unregisterPopoverFocusLossHandler(Ud),Nd.style.transform="translate(0, 0)",Nd.style.opacity="0",ne=setTimeout(function(){le()},250),ee&&(ee(),ee=null))}; +le=function(){if(de){ne&&clearTimeout(ne);ee&&(ee(),ee=null);de=null;var a=Cb,b,c=(b=Qa(a.getFocusableElement(),w.OWNS))!=null?b:"";u(a.getFocusableElement(),w.OWNS,c.replace(Nd.id,""));a.getFocusableElement().classList.remove("blocklyShowingDropDownDiv");a.markFocused();Sd&&(Sd(),Sd=null);Vd()}}; +he=function(a,b,c,d){a=oe.getPositionMetrics(a,b,c,d);a.arrowVisible?(b=a.arrowX,c=a.arrowY,d=a.arrowAtTop?45:225,Qd.style.display="",Qd.style.transform=`translate(${b}px, ${c}px) rotate(${d}deg)`,Qd.setAttribute("class","blocklyDropDownArrow")):Qd.style.display="none";b=Math.floor(a.initialX);c=Math.floor(a.initialY);d=Math.floor(a.finalX);var e=Math.floor(a.finalY),f=Nd.parentElement;f&&({x:b,y:c}=ad(b,c,f),{x:d,y:e}=ad(d,e,f));Nd.style.left=b+"px";Nd.style.top=c+"px";Nd.style.visibility="visible"; +Nd.style.opacity="1";Nd.style.transform="translate("+(d-b)+"px,"+(e-c)+"px)";return!!a.arrowAtTop};pe=function(){if(de){var a=de.getSourceBlock();a=Xd?Zd(de):ae(a);let b=a.left+(a.right-a.left)/2;he(b,a.bottom,b,a.top)}else Td()};qe=function(a){return a.length?a.reduce(function(b,c){return b.lengthf&&(f=J[d].length);var g=-Infinity;let V=1;do{F=g;d=e;var h=[];g=J.length/V;e=1;for(var m=0;mF);f=d}a[c]=f}return a.join("\n")}; +ue=function(a,b,c){var d=[0],e=[];for(var f=0;f1&&d[d.length-1]<=d[d.length-2]&&(b+=.5);return b}; +te=function(a,b,c){var d=ue(a,b,c);for(let f=0;fd){d=h;var e=g}}return e?te(a,e,c):b};$.we=function(a){return/^\s*-?\d+(\.\d+)?\s*$/.test(a)};ye=function(a){if(a=xe(a)){for(a=a.tooltip;typeof a==="function";)a=a();if(typeof a!=="string")throw Error("Tooltip function must return a string.");return a}return""}; +xe=function(a){for(;a&&a.tooltip;){if(typeof a.tooltip==="string"||typeof a.tooltip==="function")return a;a=a.tooltip}return null};Ae=function(){document.querySelector(".blocklyTooltipDiv")||(ze=document.createElement("div"),ze.className="blocklyTooltipDiv",(Ib()||document.body).appendChild(ze))};Ee=function(a){a.mouseOverWrapper_=ka(a,"pointerover",null,Be);a.mouseOutWrapper_=ka(a,"pointerout",null,Ce);a.addEventListener("pointermove",De,!1)}; +Fe=function(a){a&&(la(a.mouseOverWrapper_),la(a.mouseOutWrapper_),a.removeEventListener("pointermove",De))};Be=function(a){Ge||(a=xe(a.currentTarget),He!==a&&(Ie(),Je=null,He=a),clearTimeout(Ke))};Ce=function(){Ge||(Ke=setTimeout(function(){Je=He=null;Ie()},1),clearTimeout(Le),Le=0)}; +De=function(a){if(He&&He.tooltip&&!Ge)if(Me){let b=Ne-a.pageX;a=Oe-a.pageY;Math.sqrt(b*b+a*a)>10&&Ie()}else Je!==He&&(clearTimeout(Le),Ne=a.pageX,Oe=a.pageY,Le=setTimeout(()=>{if(this instanceof Element)for(let c of zb()){if(!c.rendered)continue;let d;if((d=c.getInjectionDiv())==null?0:d.contains(this)){var b=c;break}}Pe(b)},750))};Qe=function(){Je=He=null;Ie()};Ie=function(){Me&&(Me=!1,ze&&(ze.style.display="none"));Le&&(clearTimeout(Le),Le=0)}; +Re=function(a,b){He!==a&&(Ie(),Je=null,He=a);He&&He.tooltip&&!Ge&&(a=a.getFocusableElement().getBoundingClientRect(),Ne=He.RTL?a.x+a.width:a.x,Oe=a.y+a.height,Pe(b))};Se=function(){Ie();Ge=!0}; +Pe=function(a){if(!Ge&&(Je=He,ze)){var b;(b=Ib(a))==null||b.appendChild(ze);ze.textContent="";if(ze&&He)if(typeof Te==="function")Te(ze,He);else for(a=ye(He),a=$.ve(a,50),a=a.split("\n"),b=0;bc+window.scrollY&&(e-=ze.offsetHeight+20);a?d=Math.max(5-window.scrollX,d):d+ze.offsetWidth>b+window.scrollX-10&&(d=b-ze.offsetWidth-10);var {x:h,y:m}={x:d,y:e};ze.style.left=h+"px";ze.style.top=m+"px"}}; +We=function(a){a=`${a}`.toLowerCase().trim();var b=Ue[a];if(b)return b;b=a.substring(0,2)==="0x"?"#"+a.substring(2):a;b=b[0]==="#"?b:"#"+b;if(/^#[0-9a-f]{6}$/.test(b))return b;if(/^#[0-9a-f]{3}$/.test(b))return["#",b[1],b[1],b[2],b[2],b[3],b[3]].join("");var c=a.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return c&&(a=Number(c[1]),b=Number(c[2]),c=Number(c[3]),a>=0&&a<256&&b>=0&&b<256&&c>=0&&c<256)?Ve(a,b,c):null}; +Ve=function(a,b,c){b=a<<16|b<<8|c;return a<16?"#"+(16777216|b).toString(16).substr(1):"#"+b.toString(16)};Xe=function(a){a=We(a);if(!a)return[0,0,0];a=parseInt(a.substr(1),16);return[a>>16,a>>8&255,a&255]}; +Ye=function(a,b,c){var d=0,e=0,f=0;if(b===0)f=e=d=c;else{let g=Math.floor(a/60),h=a/60-g;a=c*(1-b);let m=c*(1-b*h);b=c*(1-b*(1-h));switch(g){case 1:d=m;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=m;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=m;break;case 6:case 0:d=c,e=b,f=a}}return Ve(Math.floor(d),Math.floor(e),Math.floor(f))}; +Ze=function(a,b,c){a=We(a);if(!a)return null;b=We(b);if(!b)return null;a=Xe(a);b=Xe(b);return Ve(Math.round(b[0]+c*(a[0]-b[0])),Math.round(b[1]+c*(a[1]-b[1])),Math.round(b[2]+c*(a[2]-b[2])))};bf=function(a){return Ye(a,$e,af*255)}; +cf=function(a,b,c){var d=[],e=a.split("");e.push("");var f=0;a=[];var g=null;for(let y=0;y{Sb(c);c.stopPropagation()});a.appendChild(kf)}; +sf=function(a,b,c,d,e=!0){hf();mf=a;nf=c;if(c=kf){of=d!=null?d:Cb;var f=Qa(of.getFocusableElement(),w.OWNS);u(of.getFocusableElement(),w.OWNS,f?[f,c.id]:c.id);of.getFocusableElement().classList.add("blocklyShowingWidgetDiv");var g;(g=Ib())==null||g.appendChild(c);c.style.direction=b?"rtl":"ltr";c.style.display="block";!d&&a instanceof pf&&a.getSourceBlock();qf=of.getRenderer().getClassName();rf=of.getTheme().getClassName();qf&&v(c,qf);rf&&v(c,rf);e&&(gf=$.A().takeEphemeralFocus(c));$.A().registerPopoverFocusLossHandler(jf)}}; +hf=function(){if(mf){mf=null;var a=kf;if(a){$.A().unregisterPopoverFocusLossHandler(jf);a.style.display="none";a.style.left="";a.style.top="";nf&&(nf(),nf=null);a.textContent="";qf&&(cb(a,qf),qf="");rf&&(cb(a,rf),rf="");var b;(b=of)==null||b.markFocused();gf&&(gf(),gf=null);if(of&&kf){var c;a=(c=Qa(of.getFocusableElement(),w.OWNS))!=null?c:"";u(of.getFocusableElement(),w.OWNS,a.replace(kf.id,""));of.getFocusableElement().classList.remove("blocklyShowingWidgetDiv")}}}};tf=function(a){mf===a&&hf()}; +uf=function(a){for(var b=of===null,c=of;!b&&c;){if(c===a){b=!0;break}c=c.options.parentWorkspace}b&&hf()};vf=function(a,b,c){if(kf){var d=kf.parentElement;d&&({x:a,y:b}=ad(a,b,d));kf.style.left=a+"px";kf.style.top=b+"px";kf.style.height=c+"px"}};wf=function(a,b,c,d){var e=b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom;a=d?Math.min(Math.max(b.right-c.width,a.left),a.right-c.width):Math.max(Math.min(b.left,a.right-c.width),a.left);e<0?vf(a,0,c.height+e):vf(a,e,c.height)}; +xf=function(){var a;(a=mf)!=null&&a.repositionForWindowResize&&mf.repositionForWindowResize()||hf()};Ff=function(a,b,c,d,e){sf(yf,c,zf,d);if(b.length){e||(a instanceof PointerEvent?e=new D(a.clientX,a.clientY):(console.warn("Context menu opened with keyboard but no location given"),e=new D(0,0)));var f=Af(b,c,a,e);Bf=f;Cf(f,c,e);setTimeout(function(){f.focus()},1);Df=null}else Ef()}; +Af=function(a,b,c,d){var e=new Gf;e.setRole(ab.MENU);for(let f=0;f{setTimeout(()=>{g.callback(g.scope,c,y,d)},0)})},{})}return e}; +Cf=function(a,b,c){var d=nd();c=new Zc(c.y+d.top,c.y+d.top,c.x+d.left,c.x+d.left);var e=kf;if(!e)throw Error("Attempting to create a context menu when widget div is null");e=a.render(e);v(e,"blocklyContextMenu");k(e,"contextmenu",null,Kf);a.focus();e=a.getSize();b&&(c.left+=e.width,c.right+=e.width,d.left+=e.width,d.right+=e.width);wf(d,c,e,b);a.focus()};Kf=function(a){a.preventDefault();a.stopPropagation()};Ef=function(){tf(yf);Df=null;var a;(a=Bf)==null||a.dispose();Bf=null}; +zf=function(){Bf&&(Bf.dispose(),Bf=null)};$.Of=function(a,b){return()=>{$.Ka++;try{var c=b instanceof Element?Lf(b,a.workspace):Mf(b,a.workspace);let d=a.getRelativeToSurfaceXY();d.x=a.RTL?d.x-$.Nf.snapRadius:d.x+$.Nf.snapRadius;d.y+=$.Nf.snapRadius*2;c.moveBy(d.x,d.y)}finally{$.Ka--}La()&&!c.isShadow()&&p(new (t(q.BLOCK_CREATE))(c));$.A().focusNode(c);return c}}; +Jf=function(a){var b=a.text;if(b&&!(b instanceof HTMLElement)){let c=document.createElement("div");c.className="blocklyShortcutContainer";let d=document.createElement("span");d.textContent=b;b=document.createElement("span");b.className="blocklyShortcut";a="id"in a&&a.associatedKeyboardShortcut?gd(a.associatedKeyboardShortcut):"";b.textContent=` ${a}`;c.appendChild(d);c.appendChild(b);return c}return a.text}; +Pf=function(a,b){b=pa(b,a.getParentSvg(),a.getInverseScreenCTM());b.x/=a.scale;b.y/=a.scale;return b};Rf=function(a,b,c){b=Pf(a,b);Qf.set(a,D.difference(c,b))};Sf=function(a,b){b=Pf(a,b);a=Qf.get(a);if(!a)throw Error("Drag not initialized");return D.sum(a,b)}; +Tf=function(a,b=!1){var c=$.mc("comment");b||c.setAttribute("id",a.id);b=a.workspace;var d=a.getRelativeToSurfaceXY().clone();d.x=b.RTL?b.getWidth()-d.x:d.x;c.setAttribute("x",`${d.x}`);c.setAttribute("y",`${d.y}`);c.setAttribute("w",`${a.getSize().width}`);c.setAttribute("h",`${a.getSize().height}`);a.getText()&&(c.textContent=a.getText());a.isCollapsed()&&c.setAttribute("collapsed","true");a.isOwnEditable()||c.setAttribute("editable","false");a.isOwnMovable()||c.setAttribute("movable","false"); +a.isOwnDeletable()||c.setAttribute("deletable","false");return c};Uf=function(a){var b=$.mc("variables");for(let c=0;c/g,"<$1$2>")}; +$.cg=function(a,b){var c=0;b.RTL&&(c=b.getWidth());var d=[];kb();var e=$.ec;e||$.r(!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(),y=h;if(m==="block"||m==="shadow"&&!$.fc){let F=Lf(y,b);d.push(F.id);let J,V=parseInt((J=y.getAttribute("x"))!=null?J:"10",10),ja,Xa=parseInt((ja=y.getAttribute("y"))!=null?ja:"10",10);isNaN(V)||isNaN(Xa)||F.moveBy(b.RTL?c-V:V,Xa,["create"]);f=!1}else{if(m==="shadow")throw TypeError("Shadow block cannot be a top-level block."); +if(m==="comment")ag(y,b);else if(m==="variables"){if(f)bg(y,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{$.r(e),b.setResizesEnabled&&b.setResizesEnabled(!0),b.rendered&&bc(),lb()}p(new (t(q.FINISHED_LOADING))(b));return d}; +ag=function(a,b){var c,d=(c=a.getAttribute("id"))!=null?c:void 0;c=b.rendered?new dg(b,d):new eg(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 Pc(b,h));a.getAttribute("collapsed")=== +"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};$.fg=function(a,b){a=Lf(a,b);b.rendered&&bc();return a}; +Lf=function(a,b){$.Ka++;var c=b.getVariableMap().getAllVariables();try{var d=gg(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{$.Ka--}if(La()){a=hg(b,c);for(b=0;b{isNaN(J)||isNaN(ja)||(J=b.workspace.RTL?b.workspace.getWidth()- +(J+h):J,Xa.setBubbleLocation(new D(J,ja)));Xa.setBubbleVisible(f)},1)}};jg=function(a){var b=null,c=null;for(let d=0;da.getBlockById(c)).filter(c=>c&&c.isShadow()).length===b.length};lg=function(a){return a&&typeof a.getProcedureDef==="function"}; +mg=function(a){return a.getVariableModel!==void 0};$.ng=function(a){a=a.getAllBlocks(!1);var b=new Set;for(let c=0;c({kind:"block",type:d,gap:8,fields:sg(g)})));return a};vg=function(a){return ug.generateUniqueNameInternal(a)}; +$.wg=function(a,b){if(!b.length)return a;for(var c="",d="ijkmnopqrstuvwxyzabcdefgh".indexOf(a);;){let e=!1;for(let f=0;f{V.type===$.Ag&&(V=V.blockId)&&(V=J.getBlockById(V))&& +V.type==="variables_set"&&V.getFieldValue("VAR")===F.getId()&&($.A().focusNode(V),J.removeChangeListener(y))};J.addChangeListener(y)}}}else b&&b(null)})}var e=c||"";d("")}; +$.Dg=function(a,b,c){function d(e){var f=$.C.RENAME_VARIABLE_TITLE.replace("%1",b.getName());xg(f,e,function(g){if(g){var h=Bg(g,b.getType(),a),m=Cg(b.getName(),g,a);if(h||m){var y="";h?y=$.C.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",h.getName()).replace("%2",h.getType()):m&&(y=$.C.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",g).replace("%2",m));Gc(y,function(){d(g)})}else a.getVariableMap().renameVariable(b,g),c&&c(g)}else c&&c(null)})}d("")}; +xg=function(a,b,c){Kc(a,b,function(d){d&&(d=d.replace(/[\s\xa0]+/g," ").trim(),d===$.C.RENAME_VARIABLE||d===$.C.NEW_VARIABLE)&&(d=null);c(d)})};Bg=function(a,b,c){c=c.getVariableMap().getAllVariables();a=a.toLowerCase();for(let d=0,e;e=c[d];d++)if(e.getName().toLowerCase()===a&&e.getType()!==b)return e;return null};yg=function(a,b){b=b.getVariableMap().getAllVariables();a=a.toLowerCase();for(let c=0,d;d=b[c];c++)if(d.getName().toLowerCase()===a)return d;return null}; +Cg=function(a,b,c){return c.getProcedureMap().getProcedures().length?Eg(a,b,c):Fg(a,b,c)};Eg=function(a,b,c){a=a.toLowerCase();b=b.toLowerCase();c=c.getProcedureMap().getProcedures();for(let e of c){var d=e.getParameters().filter(mg).map(f=>f.getVariableModel().getName());if(!d)continue;c=d.some(f=>f.toLowerCase()===a);d=d.some(f=>f.toLowerCase()===b);if(c&&d)return e.getName()}return null}; +Fg=function(a,b,c){a=a.toLowerCase();b=b.toLowerCase();c=c.getAllBlocks(!1);for(let e of c){if(!lg(e))continue;c=e.getProcedureDef();var d=c[1];let f=d.some(g=>g.toLowerCase()===a);d=d.some(g=>g.toLowerCase()===b);if(f&&d)return c[0]}return null};Gg=function(a){var b=$.mc("field");b.setAttribute("name","VAR");b.setAttribute("id",a.getId());b.setAttribute("variabletype",a.getType());a=$.nc(a.getName());b.appendChild(a);return b}; +$.Ig=function(a,b,c,d){var e=$.Hg(a,b,c,d);if(!e){e=a.getVariableMap();let f=a.getPotentialVariableMap();c||(c=vg(a.isFlyout?a.targetWorkspace:a));e=f?f.createVariable(c,d,b!=null?b:void 0):e.createVariable(c,d,b)}return e}; +$.Hg=function(a,b,c,d){var e=a.getPotentialVariableMap(),f=null;if(b&&(f=a.getVariableMap().getVariableById(b),!f&&e&&(f=e.getVariableById(b)),f))return f;if(c){if(d===void 0)throw Error("Tried to look up a variable by name without a type");f=a.getVariableMap().getVariable(c,d);!f&&e&&(f=e.getVariable(c,d))}return f};hg=function(a,b){a=a.getVariableMap().getAllVariables();var c=[];if(b.length!==a.length)for(let d=0;d=0;f--){let g=e[f];if(g.type==="procedures_defnoreturn"||g.type==="procedures_defreturn"){c=String(g.getFieldValue("NAME"));d=$.C.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",d).replace("%2",c);Fc(d,void 0);return}g===c&&e.splice(f,1)}c&&e.length||e.length>1?(d=$.C.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(e.length+(c&&!c.workspace.isFlyout?1:0))).replace("%2",d),Ic(d,f=>{f&&b&&a.getVariableMap().deleteVariable(b)})): +a.getVariableMap().deleteVariable(b)}; +Ng=function(a,{addCoordinates:b=!1,addInputBlocks:c=!0,addNextBlocks:d=!0,doFullSerialization:e=!0,saveIds:f=!0}={}){if(a.isInsertionMarker())return null;var g={type:a.type,id:f?a.id:void 0};if(b){b=a.workspace;var h=a.getRelativeToSurfaceXY();g.x=Math.round(b.RTL?b.getWidth()-h.x:h.x);g.y=Math.round(h.y)}a.isCollapsed()&&(g.collapsed=!0);a.isEnabled()||(g.disabledReasons=Array.from(a.getDisabledReasons()));a.isOwnDeletable()||(g.deletable=!1);a.isOwnMovable()||(g.movable=!1);a.isOwnEditable()||(g.editable= +!1);a.inputsInline!==void 0&&a.inputsInline!==a.inputsInlineDefault&&(g.inline=a.inputsInline);a.data&&(g.data=a.data);a.saveExtraState?(b=a.saveExtraState(e),b!==null&&(g.extraState=b)):a.mutationToDom&&(b=a.mutationToDom(),b!==null&&(g.extraState=$f(b).replace(' xmlns="https://developers.google.com/blockly/xml"',"")));b=Object.create(null);for(var m of a.getIcons())Tb(m)&&(h=m.saveState(e))&&(b[m.getType().toString()]=h);Object.keys(b).length&&(g.icons=b);m=Object.create(null);for(var y of a.getFields())y.isSerializable()&& +(m[y.name]=y.saveState(e));Object.keys(m).length&&(g.fields=m);if(c){c=Object.create(null);for(y=0;y{m.disposed||m.setConnectionTracking(!0)},1)}return h}; +Pg=function(a,b,{parentConnection:c,isShadow:d=!1}={}){if(!a.type)throw new Rg(a);var e=b.newBlock(a.type,a.id);e.setShadow(d);d=a.x===void 0?0:a.x;var f=a.y===void 0?0:a.y,g=e.workspace;d=g.RTL?g.getWidth()-d:d;e.moveBy(d,f);a.collapsed&&e.setCollapsed(!0);a.deletable===!1&&e.setDeletable(!1);a.movable===!1&&e.setMovable(!1);a.editable===!1&&e.setEditable(!1);a.enabled===!1&&e.setDisabledReason(!0,"MANUALLY_DISABLED");if(Array.isArray(a.disabledReasons))for(var h of a.disabledReasons)e.setDisabledReason(!0, +h);a.inline!==void 0&&e.setInputsInline(a.inline);a.data!==void 0&&(e.data=a.data);a.extraState&&(e.loadExtraState?e.loadExtraState(a.extraState):e.domToMutation&&e.domToMutation($.pc(a.extraState)));if(c){if(c.getSourceBlock().isShadow()&&!e.isShadow())throw new Sg(a);if(c.type===$.Bd.VALUE){if(h=e.outputConnection,!h)throw new Tg("output",e,a);}else if(h=e.previousConnection,!h)throw new Tg("previous",e,a);if(!c.connect(h))throw b=e.workspace.connectionChecker,new Ug(b.getErrorMessage(b.canConnectWithReason(h, +c,!1),h,c),c.type===$.Bd.VALUE?"output connection":"previous connection",e,a);}if(a.icons){c=Object.keys(a.icons);for(var m of c){c=a.icons[m];h=e.getIcon(m);if(!h){h=ua(l.ICON,m,!1);if(!h)throw new Vg(m,e,a);h=new h(e);e.addIcon(h)}Tb(h)&&h.loadState(c)}}if(a.fields)for(m=Object.keys(a.fields),c=0;c0&&!a[0].nodeType?a:bh(a):[]}; +fh=function(a){if(!a)return!1;var b=a.kind;return b?b==="categoryToolbox":!!a.contents.filter(c=>c.kind.toUpperCase()==="CATEGORY").length};gh=function(a){return a&&a.contents?!!a.contents.filter(function(b){return b.kind.toUpperCase()==="CATEGORY"}).length:!1};bh=function(a){var b=[],c=a.childNodes;c||(c=a);for(let d=0,e;e=c[d];d++){if(!e.tagName)continue;a={};let f=e.tagName.toUpperCase();a.kind=f;f==="BLOCK"?a.blockxml=e:e.childNodes&&e.childNodes.length>0&&(a.contents=bh(e));ch(e,a);b.push(a)}return b}; +ch=function(a,b){for(let c=0;c document.");}else a instanceof Element&&(b=a);return b}; +$.ih=function(a,b){if(typeof a!=="string"||a.trim()==="")throw Error('Error: Invalid extension name "'+a+'"');if(hh[a])throw Error('Error: Extension "'+a+'" is already registered.');if(typeof b!=="function")throw Error('Error: Extension "'+a+'" must be a function');hh[a]=b};$.jh=function(a,b){if(!b||typeof b!=="object")throw Error('Error: Mixin "'+a+'" must be a object');$.ih(a,function(){this.mixin(b)})}; +$.nh=function(a,b,c,d){var e='Error when registering mutator "'+a+'": ';kh(e,b);var f=lh(b.compose,b.decompose,e+" compose/decompose");if(c&&typeof c!=="function")throw Error(e+'Extension "'+a+'" is not a function');$.ih(a,function(){f&&this.setMutator(new $.mh(d||[],this));this.mixin(b);c&&c.apply(this)})};$.oh=function(a){return!!hh[a]}; +qh=function(a,b,c){var d=hh[a];if(typeof d!=="function")throw Error('Error: Extension "'+a+'" not found.');if(c){if(ph(b).length)throw Error('Error: tried to apply mutation "'+a+'" to a block that already has mutator functions. Block id: '+b.id);}else var e=ph(b);d.apply(b);if(c)kh('Error after applying mutator "'+a+'": ',b);else{a:if(c=e,b=ph(b),b.length!==c.length)b=!1;else{for(d=0;d100||wh())){var d=a.getRelativeToSurfaceXY(),e=c.cloneNode(!0);e.setAttribute("transform","translate("+d.x+","+d.y+")");var f;(f=b.getLayerManager())==null||f.appendToAnimationLayer({getSvgRoot:()=>e});Gh(e,{x:d.x,y:d.y,width:a.width,height:a.height},b.RTL,new Date)}}; +Gh=function(a,b,c,d){var e=((new Date).getTime()-d.getTime())/150;e>1?fb(a):(a.setAttribute("transform","translate("+(b.x+(c?-1:1)*b.width/2*e)+","+(b.y+b.height/2*e)+") scale("+(1-e)+")"),setTimeout(Gh,10,a,b,c,d))}; +Ih=function(a){var b=a.workspace,c=b.scale;b.getAudioManager().play("click");if(!(c<1||wh())){var d=b.getSvgXY(a.getSvgRoot());a.outputConnection?(d.x+=(a.RTL?3:-3)*c,d.y+=13*c):a.previousConnection&&(d.x+=(a.RTL?-23:23)*c,d.y+=3*c);var e=z(x.CIRCLE,{cx:d.x,cy:d.y,r:0,fill:"none",stroke:"#888","stroke-width":10},b.getParentSvg());a=z(x.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*c},e);b=z(x.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity", +dur:"150ms",from:1,to:0},e);a.beginElement();b.beginElement();setTimeout(()=>void fb(e),150)}};Mh=function(a){Jh();a.workspace.getAudioManager().play("disconnect");if(!(a.workspace.scale<1||wh())){var b=a.getHeightWidth().height;b=Math.atan(10/b)/Math.PI*180;a.RTL||(b*=-1);Kh=a;Lh(a,b,new Date,0)}}; +Lh=function(a,b,c,d){var e=[.66,1,.66,0,-.66,-1,-.66,0],f="";c.getTime()+200>(new Date).getTime()&&(f=`skewX(${Math.round(e[d%e.length]*b)})`,Nh=setTimeout(Lh,15,a,b,c,d+1));a.getSvgRoot().setAttribute("transform",`${a.getTranslation()} ${f}`)};Jh=function(){Kh&&(Nh&&(clearTimeout(Nh),Nh=null),Kh.getSvgRoot().setAttribute("transform",Kh.getTranslation()),Kh=null)}; +Qh=function(a,b){a.workspace.RTL&&(b.x=a.workspace.getWidth()-b.x);for(var c=a.workspace,d=$.Nf.snapRadius,e=D.difference(b,a.getRelativeToSurfaceXY()),f=new D(0,0),g=c.getAllBlocks(!1).filter(h=>h.id!=a.id).map(h=>h.getRelativeToSurfaceXY());Oh(D.sum(b,f),g)||Ph(a,D.sum(e,f),d);)c.RTL?f.translate(-d,d*2):f.translate(d,d*2);a.moveTo(D.sum(b,f))};Oh=function(a,b){return b.some(c=>Math.abs(c.x-a.x)<=1&&Math.abs(c.y-a.y)<=1)};Ph=function(a,b,c){return a.getConnections_(!1).some(d=>!!d.closest(c,b).connection)}; +Rh=function(a,b,c){var d=c.getBoundingRectangle(),e=d.right-d.left,f=Md(b.top,d.top,b.top+b.height-(d.bottom-d.top))-d.top,g=b.left;b=b.left+b.width-e;a.RTL?g=Math.min(b,g):b=Math.max(g,b);return(a=Md(g,d.left,b)-d.left)||f?(c.moveBy(a,f,["inbounds"]),!0):!1}; +Uh=function(a){return b=>{var c=a.getMetricsManager();if(c.hasFixedEdges()&&!a.isDragging()){var d;if(Sh.includes((d=b.type)!=null?d:"")){c=c.getScrollMetrics(!0);d=null;switch(b.type){case q.BLOCK_CREATE:case q.BLOCK_MOVE:(d=a.getBlockById(b.blockId))&&(d=d.getRootBlock());break;case q.COMMENT_CREATE:case q.COMMENT_MOVE:case q.COMMENT_RESIZE:d=a.getCommentById(b.commentId)}if(d){var e=$.ec||!1;$.r(b.group);Rh(a,c,d)&&!b.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."); +$.r(e)}}else b.type===q.VIEWPORT_CHANGE&&b.scale&&b.oldScale&&b.scale>b.oldScale&&Th(a)}}};Th=function(a){var b=a.getMetricsManager();if(b.hasFixedEdges()&&!a.isDragging()){b=b.getScrollMetrics(!0);var c=a.getTopBoundedElements();for(let d=0,e;e=c[d];d++)Rh(a,b,e)}};Vh=function(a){return a&&typeof a.isDeletable==="function"&&typeof a.dispose==="function"&&typeof a.setDeleteStyle==="function"}; +Wh=function(a){var b=[];for(var c of a.getIcons()){if(a.isCollapsed()&&!c.isShownWhenCollapsed())continue;b.push(c);let d;Mc(c)&&c.bubbleIsVisible()&&(d=c.getBubble())&&b.push(d)}for(let d of a.inputList){if(!d.isVisible())continue;b.push(...d.fieldRow);c=d.connection;if(!c)continue;b.push(c);c=c.targetBlock();if(!c)continue;b.push(c);(c=c.lastConnectionInStack(!1))&&b.push(c)}a.nextConnection&&!a.isCollapsed()&&b.push(a.nextConnection);return b}; +Xh=function(a,b,c){a=Wh(a);b=a.indexOf(b);if(b===-1)return null;c=b+c;return c>=0&&c!d.getReturnTypes()).map(d=>[d.getName(),d.getParameters().map(e=>e.getName()),!1]);a.getBlocksByType("procedures_defnoreturn",!1).forEach(d=>{!bi(d)&&lg(d)&&b.push(d.getProcedureDef())});var c=a.getProcedureMap().getProcedures().filter(d=>!!d.getReturnTypes()).map(d=>[d.getName(),d.getParameters().map(e=>e.getName()),!0]);a.getBlocksByType("procedures_defreturn",!1).forEach(d=>{!bi(d)&&lg(d)&&c.push(d.getProcedureDef())});b.sort(di); +c.sort(di);return[b,c]};di=function(a,b){return a[0].localeCompare(b[0],void 0,{sensitivity:"base"})};$.gi=function(a,b){if(b.isInFlyout)return a;for(a=a||$.C.UNNAMED_KEY||"unnamed";fi(a,b.workspace,b);){let c=a.match(/^(.*?)(\d+)$/);a=c?c[1]+(parseInt(c[2])+1):a+"2"}return a}; +fi=function(a,b,c){for(let d of b.getAllBlocks(!1))if(d!==c&&lg(d)&&$.hi.equals(d.getProcedureDef()[0],a))return!0;c=c&&bi(c)?c==null?void 0:c.getProcedureModel():void 0;for(let d of b.getProcedureMap().getProcedures())if(d!==c&&$.hi.equals(d.getName(),a))return!0;return!1}; +$.ji=function(a){var b=this.getSourceBlock();if(!b)throw new ii;a=a.trim();var c=$.gi(a,b);bi(b)&&!b.isInsertionMarker()&&b.getProcedureModel().setName(c);var d=this.getValue();if(d!==a&&d!==c)for(a=b.workspace.getAllBlocks(!1),b=0;bbi(c)&&!c.isProcedureDef()&&c.getProcedureModel()&&$.hi.equals(c.getProcedureModel().getName(),a)||c&&typeof c.getProcedureCall==="function"&&typeof c.renameProcedure==="function"&&$.hi.equals(c.getProcedureCall(),a))}; +$.pi=function(a){var b=$.fc,c=a.getProcedureDef()[0],d=a.mutationToDom(!0);a=oi(c,a.workspace);for(let f=0,g;g=a[f];f++){c=(c=g.mutationToDom())&&sc(c);g.domToMutation&&g.domToMutation(d);var e=g.mutationToDom();e=e&&sc(e);c!==e&&($.fc=!1,p(new (t(q.BLOCK_CHANGE))(g,"mutation",null,c,e)),$.fc=b)}};$.qi=function(a,b){for(let c of b.getAllBlocks(!1))if(bi(c)&&c.isProcedureDef()&&$.hi.equals(c.getProcedureModel().getName(),a)||lg(c)&&$.hi.equals(c.getProcedureDef()[0],a))return c;return null}; +ri=function(a,b){n(l.RENDERER,a,b)};si=function(a,b,c){a=new (ua(l.RENDERER,a,void 0))(a);a.init(b,c);return a};ti=function(a){pg(a.getTargetWorkspace(),void 0,"String")};ui=function(a){pg(a.getTargetWorkspace(),void 0,"Number")};vi=function(a){pg(a.getTargetWorkspace(),void 0,"Colour")}; +wi=function(a){Qb.variables_set_dynamic||Qb.variables_get_dynamic||console.warn("There are no dynamic variable blocks, but there is a dynamic variable category.");a.registerButtonCallback("CREATE_VARIABLE_STRING",ti);a.registerButtonCallback("CREATE_VARIABLE_NUMBER",ui);a.registerButtonCallback("CREATE_VARIABLE_COLOUR",vi);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", +text:$.C.NEW_COLOUR_VARIABLE,callbackkey:"CREATE_VARIABLE_COLOUR"},...qg(a,a.getVariableMap().getAllVariables(),!1,"variables_get_dynamic","variables_set_dynamic")]}; +Ai=function(a,b,c,d,e,f){var g=f.scrollbar&&f.scrollbar.canScrollVertically();a.horizontal===xi.LEFT?(c=e.absoluteMetrics.left+c,g&&f.RTL&&(c+=yi.scrollbarThickness)):(c=e.absoluteMetrics.left+e.viewMetrics.width-b.width-c,g&&!f.RTL&&(c-=yi.scrollbarThickness));a.vertical===zi.TOP?a=e.absoluteMetrics.top+d:(a=e.absoluteMetrics.top+e.viewMetrics.height-b.height-d,f.scrollbar&&f.scrollbar.canScrollHorizontally()&&(a-=yi.scrollbarThickness));return new Zc(a,a+b.height,c,c+b.width)}; +Bi=function(a,b){return{horizontal:b.toolboxMetrics.position===I.LEFT||a.horizontalLayout&&!a.RTL?xi.RIGHT:xi.LEFT,vertical:b.toolboxMetrics.position===I.BOTTOM?zi.TOP:zi.BOTTOM}};Di=function(a,b,c,d){var e=a.left,f=a.right-a.left,g=a.bottom-a.top;for(let h=0;h$.C.SHORTCUTS_ESCAPE})}; +Pi=function(){B.registry.register({name:K.DELETE,preconditionFn(a,b){b=b.focusedNode;(b=!a.isReadOnly()&&b!=null&&Vh(b)&&b.isDeletable()&&!a.isDragging()&&!$.A().ephemeralFocusTaken())||a.getAudioManager().playErrorBeep();return b},callback(a,b,c,d){b.preventDefault();b=d.focusedNode;b instanceof Oi?b.checkAndDelete():Vh(b)&&b.isDeletable()&&($.r(!0),b.dispose(),$.r(!1),a.getAudioManager().play("delete"));return!0},keyCodes:[L.DELETE,L.BACKSPACE],displayText:()=>$.C.SHORTCUTS_DELETE})}; +Qi=function(a){return Mi(a)&&Vh(a)&&$h(a)?a.isCopyable?a.isCopyable():a instanceof Oi||a instanceof dg?a.isOwnDeletable()&&a.isOwnMovable():a.isDeletable()&&a.isMovable():!1}; +Si=function(){var a=B.registry.createSerializedKey(L.C,[L.CTRL_CMD]);B.registry.register({name:K.COPY,preconditionFn(b,c){c=c.focusedNode;var d=b.isFlyout?b.targetWorkspace:b;(c=!!c&&!!d&&!d.isDragging()&&!$.A().ephemeralFocusTaken()&&Qi(c))||b.getAudioManager().playErrorBeep();return c},callback(b,c,d,e){c.preventDefault();d=e.focusedNode;if(!d||!Mi(d)||!Qi(d))return!1;e=b.isFlyout?b.targetWorkspace:b;if(!e)return!1;d.workspace.isFlyout||e.hideChaff();e=$h(d)&&d.workspace==e?d.getRelativeToSurfaceXY(): +void 0;(d=!!Ii(d,e))&&c instanceof KeyboardEvent&&Ri.show(b,{message:$.C.KEYBOARD_NAV_COPIED_HINT.replace("%1",gd(K.PASTE)),duration:7,id:"copiedHint"});return d},keyCodes:[a],displayText:()=>$.C.COPY_SHORTCUT})}; +Ti=function(){var a=B.registry.createSerializedKey(L.X,[L.CTRL_CMD]);B.registry.register({name:K.CUT,preconditionFn(b,c){c=c.focusedNode;(c=!!c&&!b.isReadOnly()&&!b.isDragging()&&!$.A().ephemeralFocusTaken()&&Qi(c)&&Vh(c)&&c.isDeletable())||b.getAudioManager().playErrorBeep();return c},callback(b,c,d,e){d=e.focusedNode;if(!(d&&Qi(d)&&Vh(d)&&d.isDeletable()&&Mi(d)))return!1;e=$h(d)?d.getRelativeToSurfaceXY():void 0;e=Ii(d,e);d instanceof Oi?(d.checkAndDelete(),c.preventDefault()):Vh(d)&&($.r(!0),d.dispose(), +$.r(!1),b.getAudioManager().play("delete"),c.preventDefault());e&&c instanceof KeyboardEvent&&Ri.show(b,{message:$.C.KEYBOARD_NAV_CUT_HINT.replace("%1",gd(K.PASTE)),duration:7,id:"cutHint"});return!!e},keyCodes:[a],displayText:()=>$.C.CUT_SHORTCUT})}; +Ui=function(){var a=B.registry.createSerializedKey(L.V,[L.CTRL_CMD]);B.registry.register({name:K.PASTE,preconditionFn(){var b=Fi;if(!b||!b.rendered)return!1;var c=b.isFlyout?b.targetWorkspace:b;(c=!!Ei&&!!c&&!c.isReadOnly()&&!c.isDragging()&&!$.A().ephemeralFocusTaken())||b.getAudioManager().playErrorBeep();return c},callback(b,c){var d=Ei,e=$.A().getFocusedNode();if(!d)return!1;var f=Fi;if(!f)return!1;Ri.hide(b,"cutHint");Ri.hide(b,"copiedHint");b=f.isFlyout?f.targetWorkspace:f;if(!b||b.isReadOnly())return!1; +if(c instanceof PointerEvent){var g=pd(b,new D(c.clientX,c.clientY));return!!Ki(d,b,g)}if(c=(g=b.getNavigator().getSourceBlockFromNode(e))==null?void 0:g.getRelativeToSurfaceXY())return!!Ki(d,b,c);g=Hi;if(!g)return!!Ki(d,b);var {left:h,top:m,width:y,height:F}=b.getMetricsManager().getViewMetrics(!0);if((new Zc(m,m+F,h,h+y)).contains(g.x,g.y))return!!Ki(d,b);g=new D(h+y/2,m+F/2);return!!Ki(d,b,g)},keyCodes:[a],displayText:()=>$.C.PASTE_SHORTCUT})}; +Wi=function(){var a=B.registry.createSerializedKey(L.Z,[L.CTRL_CMD]);B.registry.register({name:K.UNDO,preconditionFn(b){return!b.isReadOnly()&&!b.isDragging()&&!$.A().ephemeralFocusTaken()},callback(b,c){b.hideChaff();b.undo();c.preventDefault();return!0},keyCodes:[a],displayText:()=>$.C.UNDO})}; +Xi=function(){var a=B.registry.createSerializedKey(L.Z,[L.CTRL_CMD,L.SHIFT]),b=B.registry.createSerializedKey(L.Y,[L.CTRL]);B.registry.register({name:K.REDO,preconditionFn(c){return!c.isDragging()&&!c.isReadOnly()&&!$.A().ephemeralFocusTaken()},callback(c,d){c.hideChaff();c.redo();d.preventDefault();return!0},keyCodes:[a,b],displayText:()=>$.C.REDO})}; +dj=function(){var a=d=>{var e=$.A().getFocusedNode();if($h(e))return e;var f;return(f=d.getNavigator().getSourceBlockFromNode($.A().getFocusedNode()))!=null?f:void 0},b=B.registry.createSerializedKey(L.M,[L.SHIFT]),c={name:K.START_MOVE,preconditionFn:d=>{d=a(d);return!!d&&Yi.mover.canMove(d)},callback:(d,e)=>{zg.setIsActive(!0);(d=a(d))&&$.A().focusNode(d);return!!d&&Yi.mover.startMove(d,e)},keyCodes:[L.M],displayText:()=>$.C.SHORTCUTS_START_MOVE};b=[c,Object.assign({},c,{name:K.START_MOVE_STACK, +keyCodes:[b],displayText:()=>$.C.SHORTCUTS_START_MOVE_STACK}),{name:K.FINISH_MOVE,preconditionFn:()=>Yi.mover.isMoving(),callback:(d,e)=>Yi.mover.finishMove(e),keyCodes:[L.ENTER,L.SPACE],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_FINISH_MOVE},{name:K.ABORT_MOVE,preconditionFn:()=>Yi.mover.isMoving(),callback:(d,e)=>Yi.mover.abortMove(e),keyCodes:[L.ESC],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_ABORT_MOVE},{name:K.MOVE_LEFT,preconditionFn:()=>Yi.mover.isMoving(),callback:(d,e)=>{e.preventDefault(); +return Yi.mover.move(Zi.LEFT,e)},keyCodes:[L.LEFT,$i],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_MOVE_LEFT},{name:K.MOVE_RIGHT,preconditionFn:()=>Yi.mover.isMoving(),callback:(d,e)=>{e.preventDefault();return Yi.mover.move(Zi.RIGHT,e)},keyCodes:[L.RIGHT,aj],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_MOVE_RIGHT},{name:K.MOVE_UP,preconditionFn:()=>Yi.mover.isMoving(),callback:(d,e)=>{e.preventDefault();return Yi.mover.move(Zi.UP,e)},keyCodes:[L.UP,bj],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_MOVE_UP}, +{name:K.MOVE_DOWN,preconditionFn:()=>Yi.mover.isMoving(),callback:(d,e)=>{e.preventDefault();return Yi.mover.move(Zi.DOWN,e)},keyCodes:[L.DOWN,cj],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_MOVE_DOWN}];for(let d of b)B.registry.register(d)}; +ej=function(){var a=B.registry.createSerializedKey(L.ENTER,[L.CTRL_CMD]),b=B.registry.createSerializedKey(L.F10,[L.SHIFT]);B.registry.register({name:K.MENU,preconditionFn:c=>!c.isDragging(),callback:(c,d)=>{zg.setIsActive(!0);if((c=$.A().getFocusedNode())&&typeof c.showContextMenu==="function"){c.showContextMenu(d);let e;(e=Bf)==null||e.highlightNext();return!0}return!1},keyCodes:[a,b,L.CONTEXT_MENU],displayText:()=>$.C.SHORTCUTS_SHOW_CONTEXT_MENU})}; +fj=function(){var a={right:{name:K.NAVIGATE_RIGHT,preconditionFn:b=>!b.isDragging()&&!de&&!mf,callback:(b,c)=>{c.preventDefault();zg.setIsActive(!0);var d,e;c=b.RTL?(d=$.A().getFocusedTree())==null?void 0:d.getNavigator().getOutNode():(e=$.A().getFocusedTree())==null?void 0:e.getNavigator().getInNode();if(!c)return b.getAudioManager().playErrorBeep(),!1;$.A().focusNode(c);return!0},keyCodes:[L.RIGHT],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_NAVIGATE_RIGHT},left:{name:K.NAVIGATE_LEFT,preconditionFn:b=> +!b.isDragging()&&!de&&!mf,callback:(b,c)=>{c.preventDefault();zg.setIsActive(!0);var d,e;c=b.RTL?(d=$.A().getFocusedTree())==null?void 0:d.getNavigator().getInNode():(e=$.A().getFocusedTree())==null?void 0:e.getNavigator().getOutNode();if(!c)return b.getAudioManager().playErrorBeep(),!1;$.A().focusNode(c);return!0},keyCodes:[L.LEFT],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_NAVIGATE_LEFT},down:{name:K.NAVIGATE_DOWN,preconditionFn:b=>!b.isDragging()&&!de&&!mf,callback:(b,c)=>{c.preventDefault(); +zg.setIsActive(!0);var d;c=(d=$.A().getFocusedTree())==null?void 0:d.getNavigator().getNextNode();if(!c)return b.getAudioManager().playErrorBeep(),!1;b.getAudioManager().maybePlayScopeChangeAudioCue(c);$.A().focusNode(c);return!0},keyCodes:[L.DOWN],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_NAVIGATE_DOWN},up:{name:K.NAVIGATE_UP,preconditionFn:b=>!b.isDragging()&&!de&&!mf,callback:(b,c)=>{c.preventDefault();zg.setIsActive(!0);var d;c=(d=$.A().getFocusedTree())==null?void 0:d.getNavigator().getPreviousNode(); +if(!c)return b.getAudioManager().playErrorBeep(),!1;b.getAudioManager().maybePlayScopeChangeAudioCue(c);$.A().focusNode(c);return!0},keyCodes:[L.UP],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_NAVIGATE_UP}};for(let b of Object.values(a))B.registry.register(b)}; +hj=function(){B.registry.register({name:K.FOCUS_WORKSPACE,preconditionFn:a=>!a.isDragging(),callback:a=>{zg.setIsActive(!0);a=gj(a);var b;$.A().focusNode((b=a.getWorkspaceFocusTarget())!=null?b:a);return!0},keyCodes:[L.W],displayText:()=>$.C.SHORTCUTS_FOCUS_WORKSPACE})}; +ij=function(){B.registry.register({name:K.FOCUS_TOOLBOX,preconditionFn:a=>!a.isDragging(),callback:(a,b)=>{var c=a.getToolbox();if(c)zg.setIsActive(!0),$.A().focusTree(c);else{a=a.getFlyout();if(!a)return!1;zg.setIsActive(!0);$.A().focusTree(a.getWorkspace())}b.preventDefault();return!0},keyCodes:[L.T],displayText:()=>$.C.SHORTCUTS_FOCUS_TOOLBOX})}; +jj=function(){B.registry.register({name:K.INFORMATION,preconditionFn:()=>!0,callback:a=>{var b=$.A().getFocusedNode(),c=a.getNavigator().getSourceBlockFromNode(b);if(c)return a=zd(c,td.LOQUACIOUS),$a(a),!0;if(b===a){b=gj(a);a=b.getTopBlocks().length;b=b.getTopComments().length;c=a===0?"WORKSPACE_CONTENTS_BLOCKS_ZERO":a===1?"WORKSPACE_CONTENTS_BLOCKS_ONE":"WORKSPACE_CONTENTS_BLOCKS_MANY";let d="";b>0&&(d=$.C[b===1?"WORKSPACE_CONTENTS_COMMENTS_ONE":"WORKSPACE_CONTENTS_COMMENTS_MANY"].replace("%1",String(b))); +a=$.C[c].replace("%1",String(a)).replace("%2",d);$a(a);return!0}return!1},keyCodes:[L.I],displayText:()=>$.C.SHORTCUTS_INFORMATION})}; +kj=function(){var a=B.registry.createSerializedKey(L.I,[L.SHIFT]);B.registry.register({name:K.EXTENDED_INFORMATION,preconditionFn:()=>!0,callback:b=>{b=b.getNavigator().getSourceBlockFromNode($.A().getFocusedNode());if(!b)return!1;for(var c=[],d=b,e;(e=d.outputConnection)==null?0:e.isConnected();)d=d.getParent();d!==b&&c.push(zd(d,td.TERSE));for(e=d.getParent();e;)c.push(zd(e,td.TERSE)),e=e.getParent();if(c.length){c.reverse();let f;((f=b.outputConnection)==null?0:f.isConnected())||c.push($.C.CURRENT_BLOCK_ANNOUNCEMENT.replace("%1", +zd(b,td.TERSE)));$a($.C.PARENT_BLOCKS_ANNOUNCEMENT.replace("%1",c.join(",")))}else $a($.C.NO_PARENT_ANNOUNCEMENT);return!0},keyCodes:[a],displayText:()=>$.C.SHORTCUTS_EXTENDED_INFORMATION})}; +lj=function(){var a=B.registry.createSerializedKey(L.X,[L.SHIFT]);B.registry.register({name:K.DISCONNECT,preconditionFn:(b,c)=>{c=c.focusedNode;(c=!b.isDragging()&&!b.isReadOnly()&&c instanceof Oi&&!c.isShadow())||b.getAudioManager().playErrorBeep();return c},callback:(b,c)=>{zg.setIsActive(!0);b=$.A().getFocusedNode();if(!(b instanceof Oi))return!1;c=!(c instanceof KeyboardEvent&&c.shiftKey);$.r(!0);b.unplug(c);$.r(!1);return!0},keyCodes:[L.X,a],displayText:()=>$.C.SHORTCUTS_DISCONNECT})}; +mj=function(){var a=(c,d=$.A().getFocusedNode())=>{var e=c.getNavigator();for(let f=d;f&&f!==c;f=e.getParent(f))d=f;return ub(d)?d:null},b={name:K.PREVIOUS_STACK,preconditionFn:c=>!c.isDragging()&&!!a(c)&&!de&&!mf,callback:c=>{zg.setIsActive(!0);var d=a(c);if(!d)return!1;c=a(c,c.getNavigator().navigateStacks(d,-1));if(!c)return!1;$.A().focusNode(c);return!0},keyCodes:[L.B],displayText:()=>$.C.SHORTCUTS_PREVIOUS_STACK};B.registry.register({name:K.NEXT_STACK,preconditionFn:c=>!c.isDragging()&&!!a(c)&& +!de&&!mf,callback:c=>{zg.setIsActive(!0);var d=a(c);if(!d)return!1;c=c.getNavigator().navigateStacks(d,1);if(!c)return!1;$.A().focusNode(c);return!0},keyCodes:[L.N],displayText:()=>$.C.SHORTCUTS_NEXT_STACK});B.registry.register(b)}; +oj=function(){var a=()=>{var e=$.A().getFocusedTree();if(e instanceof Gi&&e.isFlyout&&e.targetWorkspace){let f;return(f=e.targetWorkspace.getFlyout())!=null?f:null}return null},b=e=>{var f=e.getWorkspace().getNavigator();e=e.getContents().map(m=>m.getElement());for(var g,h=(g=$.A().getFocusedNode())!=null?g:null;h&&!e.includes(h);)h=f.getParent(h);return h},c=(e,f)=>{var g=e.getContents().map(m=>m.getElement());e=(e=b(e))?g.indexOf(e):f===1?-1:g.length;for(let m=1;m<=g.length;m++){var h=e+f*m;if(h< +0||h>=g.length)break;h=g[h];if(h instanceof nj&&h.isLabel())return h}return null},d=B.registry.createSerializedKey(L.H,[L.SHIFT]);d={name:K.PREVIOUS_HEADING,preconditionFn:e=>!e.isDragging()&&!de&&!mf&&!!a(),callback:()=>{var e=a();if(!e)return!1;e=c(e,-1);if(!e)return!1;zg.setIsActive(!0);$.A().focusNode(e);return!0},keyCodes:[d],displayText:()=>$.C.SHORTCUTS_PREVIOUS_HEADING};B.registry.register({name:K.NEXT_HEADING,preconditionFn:e=>!e.isDragging()&&!de&&!mf&&!!a(),callback:()=>{var e=a();if(!e)return!1; +e=c(e,1);if(!e)return!1;zg.setIsActive(!0);$.A().focusNode(e);return!0},keyCodes:[L.H],displayText:()=>$.C.SHORTCUTS_NEXT_HEADING});B.registry.register(d)}; +pj=function(){B.registry.register({name:K.PERFORM_ACTION,preconditionFn:a=>!a.isDragging()&&!de&&!mf&&!$.A().ephemeralFocusTaken(),callback:(a,b)=>{zg.setIsActive(!0);if((a=$.A().getFocusedNode())&&"performAction"in a){b.preventDefault();let c;(c=a.performAction)==null||c.call(a,b);return!0}return!1},keyCodes:[L.ENTER,L.SPACE],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_PERFORM_ACTION})}; +qj=function(){B.registry.register({name:K.DUPLICATE,preconditionFn:(a,b)=>{({focusedNode:b}=b);(b=!a.isDragging()&&!a.isReadOnly()&&!a.isFlyout&&(b instanceof Oi?b.isDuplicatable():!0))||a.getAudioManager().playErrorBeep();return b},callback:(a,b,c,d)=>{zg.setIsActive(!0);b=Mi(d.focusedNode)&&d.focusedNode;return b?(b=b.toCopyData())?!!Ki(b,a):!1:!1},keyCodes:[L.D],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_DUPLICATE})}; +rj=function(){B.registry.register({name:K.CLEANUP,preconditionFn:a=>!a.isDragging()&&!a.isReadOnly()&&!a.isFlyout,callback:a=>{zg.setIsActive(!0);a.cleanUp();return!0},keyCodes:[L.C],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_CLEANUP})}; +sj=function(){var a=B.registry.createSerializedKey(L.J,[L.CTRL_CMD]);B.registry.register({name:K.SHOW_TOOLTIP,preconditionFn:b=>!b.isDragging(),callback:b=>{var c=$.A().getFocusedNode();c!==null&&(zg.setIsActive(!0),Re(c,b));return!0},keyCodes:[a],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_SHOW_TOOLTIP})}; +tj=function(){var a=B.registry.createSerializedKey(L.A,[L.ALT,L.SHIFT]),b=!1;B.registry.register({name:K.TOGGLE_SCREENREADER,preconditionFn:()=>!0,callback:(c,d)=>{b=!b;zg.setScopeChangeAudioCuesEnabled(b);c.getNavigator().setNavigationLoops(!b);var e;(e=c.getToolbox())==null||e.getNavigator().setNavigationLoops(!b);var f;(f=c.getFlyout())==null||f.getWorkspace().getNavigator().setNavigationLoops(!b);Ri.show(c,{message:(b?$.C.SCREENREADER_MODE_ENABLED:$.C.SCREENREADER_MODE_DISABLED).replace("%1", +gd(K.TOGGLE_SCREENREADER)),duration:7,id:"screenreaderHint"});d.preventDefault();return!0},keyCodes:[a],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_TOGGLE_SCREENREADER_MODE})}; +vj=function(){B.registry.register({name:K.JUMP_BLOCK_START,preconditionFn:uj,callback(a,b,c,d){if(!d.focusedNode)return!1;a=a.getNavigator().getSourceBlockFromNode(d.focusedNode);var e;((e=a)==null?0:e.getFullBlockField())&&a.getParent()&&(a=a.getParent());if(!a)return!1;$.A().focusNode(a);return!0},keyCodes:[L.HOME],displayText:()=>$.C.SHORTCUTS_JUMP_BLOCK_START})}; +xj=function(){B.registry.register({name:K.JUMP_BLOCK_END,preconditionFn:uj,callback(a,b,c,d){if(!d.focusedNode)return!1;a=a.getNavigator().getSourceBlockFromNode(d.focusedNode);var e;((e=a)==null?0:e.getFullBlockField())&&a.getParent()&&(a=a.getParent());if(!a)return!1;e=a.inputList;if(!e.length)return!1;e=e[e.length-1].connection;if(!(e&&e instanceof wj))return!1;$.A().focusNode(e);return!0},keyCodes:[L.END],displayText:()=>$.C.SHORTCUTS_JUMP_BLOCK_END})}; +yj=function(){B.registry.register({name:K.JUMP_TOP_STACK,preconditionFn:uj,callback(a,b,c,d){if(!d.focusedNode)return!1;a=a.getNavigator().getSourceBlockFromNode(d.focusedNode);if(!a)return!1;a=a.getRootBlock();$.A().focusNode(a);return!0},keyCodes:[L.PAGE_UP],displayText:()=>$.C.SHORTCUTS_JUMP_TOP_STACK})}; +zj=function(){B.registry.register({name:K.JUMP_BOTTOM_STACK,preconditionFn:uj,callback(a,b,c,d){if(!d.focusedNode)return!1;a=a.getNavigator().getSourceBlockFromNode(d.focusedNode);if(!a)return!1;var e;a=(e=a.getRootBlock().lastConnectionInStack(!1))==null?void 0:e.getSourceBlock();if(!a)return!1;e=a.getDescendants(!0);e=e[e.length-1];$.A().focusNode(e);return!0},keyCodes:[L.PAGE_DOWN],displayText:()=>$.C.SHORTCUTS_JUMP_BOTTOM_STACK})}; +Bj=function(){var a=B.registry.createSerializedKey(L.HOME,[L.CTRL_CMD]);B.registry.register({name:K.JUMP_FIRST_BLOCK,preconditionFn:b=>!b.isDragging()&&!$.A().ephemeralFocusTaken(),callback(b){var c=Aj(b);if(c){if(!c.length)return!1;$.A().focusNode(c[0]);return!0}b=b.getTopBlocks(!0);if(!b.length)return!1;$.A().focusNode(b[0]);return!0},keyCodes:[a],displayText:()=>$.C.SHORTCUTS_JUMP_FIRST_BLOCK})}; +Cj=function(){var a=B.registry.createSerializedKey(L.END,[L.CTRL_CMD]);B.registry.register({name:K.JUMP_LAST_BLOCK,preconditionFn:b=>!b.isDragging()&&!$.A().ephemeralFocusTaken(),callback(b){var c=Aj(b);if(c){if(!c.length)return!1;$.A().focusNode(c[c.length-1]);return!0}b=b.getAllBlocks(!0);if(!b.length)return!1;$.A().focusNode(b[b.length-1]);return!0},keyCodes:[a],displayText:()=>$.C.SHORTCUTS_JUMP_LAST_BLOCK})}; +Dj=function(a,b,c){var d=b[b.length-1].start>=b[0].start;return{items:a,leadingEdge:e=>d?b[e].start:-b[e].end,trailingEdge:e=>d?b[e].end:-b[e].start,viewLeadingEdge:d?c.start:-c.end,viewTrailingEdge:d?c.end:-c.start}}; +Ej=function(a){var b=a.getNavigator().getNavigableItems(a.getRootFocusableNode());if(!b.length)return null;var c=a.isHorizontal(),d=f=>{f=f.getBoundingClientRect();return c?{start:f.left,end:f.right}:{start:f.top,end:f.bottom}};a=a.getRootFocusableNode().getFocusableElement();var e=b.map(f=>d(f.getFocusableElement()));return Dj(b,e,d(a))}; +Fj=function(a){var b=a.getNavigator().getNavigableItems(a.getRootFocusableNode()).filter(f=>Li(f));if(!b.length)return null;var c,d,e=!!((c=a.targetWorkspace)==null?0:(d=c.getFlyout())==null?0:d.horizontalLayout);a=a.getMetricsManager().getViewMetrics(!0);a=e?{start:a.left,end:a.left+a.width}:{start:a.top,end:a.top+a.height};c=b.map(f=>{f=f.getBoundingRectangle();return e?{start:f.left,end:f.right}:{start:f.top,end:f.bottom}});return Dj(b,c,a)}; +Hj=function(a,b){var c=Gj(a);a=c?Ej(c):Fj(a);if(!a)return!1;c=a.items;var d=$.A().getFocusedNode();d=d?c.indexOf(d):-1;var e=a.viewTrailingEdge-a.viewLeadingEdge,f=-1;if(b){var g=d>=0?Math.max(a.viewLeadingEdge,a.leadingEdge(d)):a.viewLeadingEdge;for(var h=0;h=g+e);h++)f=h}else for(g=d>=0?Math.min(a.viewTrailingEdge,a.trailingEdge(d)):a.viewTrailingEdge,h=c.length-1;h>=0&&!(a.trailingEdge(h)<=g-e);h--)f=h;if(f<0||f===d&&(f+=b?1:-1,f<0||f>=c.length))return!1;$.A().focusNode(c[f]); +return!0};Jj=function(){B.registry.register({name:K.JUMP_PREVIOUS_PAGE,preconditionFn:Ij,callback(a,b){if(!Hj(a,!1))return!1;b.preventDefault();return!0},keyCodes:[L.PAGE_UP],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_JUMP_PREVIOUS_PAGE})};Kj=function(){B.registry.register({name:K.JUMP_NEXT_PAGE,preconditionFn:Ij,callback(a,b){if(!Hj(a,!0))return!1;b.preventDefault();return!0},keyCodes:[L.PAGE_DOWN],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_JUMP_NEXT_PAGE})}; +Oj=function(){var a=[{name:K.SCROLL_LEFT,preconditionFn:Lj,callback:(b,c)=>Mj(b,c,Nj.LEFT),keyCodes:[$i],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_SCROLL_LEFT},{name:K.SCROLL_RIGHT,preconditionFn:Lj,callback:(b,c)=>Mj(b,c,Nj.RIGHT),keyCodes:[aj],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_SCROLL_RIGHT},{name:K.SCROLL_UP,preconditionFn:Lj,callback:(b,c)=>Mj(b,c,Nj.UP),keyCodes:[bj],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_SCROLL_UP},{name:K.SCROLL_DOWN,preconditionFn:Lj,callback:(b, +c)=>Mj(b,c,Nj.DOWN),keyCodes:[cj],allowCollision:!0,displayText:()=>$.C.SHORTCUTS_SCROLL_DOWN}];for(let b of a)B.registry.register(b)};Pj=function(){Ni();Pi();Si();Ti();Ui();Wi();Xi()};Qj=function(){ej();dj();hj();ij();fj();lj();mj();oj();pj();qj();rj();sj()};Rj=function(){jj();kj();tj()};Uj=function(a,b=!1){var c=$.C.KEYBOARD_NAV_UNCONSTRAINED_MOVE_HINT.replace("%1",na||Sj||Tj?$.C.COMMAND_KEY:$.C.CONTROL_KEY).replace("%2",$.C.ENTER_KEY);Ri.show(a,{message:c,id:"unconstrainedMoveHint",oncePerSession:!b})}; +Vj=function(a){var b=$.C.KEYBOARD_NAV_CONSTRAINED_MOVE_HINT.replace("%1",$.C.ENTER_KEY);Ri.show(a,{message:b,id:"constrainedMoveHint",oncePerSession:!0})};Wj=function(a,b){if(a<=0)return 0;b=Math.min(Math.abs(b),a);return a-Math.sqrt(a*a-b*b)};Yj=function(){Xj.registry.register({displayText(){return $.C.UNDO},preconditionFn(a){return a.workspace.getUndoStack().length>0?"enabled":"disabled"},callback(a){a.workspace.undo()},scopeType:Xj.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1,associatedKeyboardShortcut:"undo"})}; +Zj=function(){Xj.registry.register({displayText(){return $.C.REDO},preconditionFn(a){return a.workspace.getRedoStack().length>0?"enabled":"disabled"},callback(a){a.workspace.redo()},scopeType:Xj.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2,associatedKeyboardShortcut:"redo"})}; +ak=function(){Xj.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:Xj.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3,associatedKeyboardShortcut:"cleanup"})}; +bk=function(a,b){function c(f){e--;f.setCollapsed(a);e===0&&$.r(!1)}var d=0,e=0;$.r(!0);for(let f=0;f0?"enabled":"disabled":"disabled"},callback(a){if(a.workspace){a.workspace.cancelCurrentGesture();var b=fk(a.workspace);b.length<2?gk(b):Ic($.C.DELETE_ALL_BLOCKS.replace("%1",String(b.length)),function(c){c&&gk(b)})}},scopeType:Xj.ScopeType.WORKSPACE,id:"workspaceDelete", +weight:6})};ik=function(){Xj.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&&Ki(b,a.block.workspace)}},scopeType:Xj.ScopeType.BLOCK,id:"blockDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})}; +kk=function(){Xj.registry.register({displayText(a){return a.block.hasIcon(jk.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(jk.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(jk.TYPE)?a.setCommentText(null):a.setCommentText("")}, +scopeType:Xj.ScopeType.BLOCK,id:"blockComment",weight:2})}; +nk=function(){Xj.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(b.has("MANUALLY_DISABLED")?1:0);return a.getInheritedDisabled()||b?"disabled":"enabled"}return"hidden"},callback(a){a=a.block;var b=$.ec;b||$.r(!0);a.setDisabledReason(!a.hasDisabledReason("MANUALLY_DISABLED"),"MANUALLY_DISABLED"); +$.r(b)},scopeType:Xj.ScopeType.BLOCK,id:"blockDisable",weight:5})}; +qk=function(){Xj.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&&($.A().focusNode(a.block),a.block.checkAndDelete())},scopeType:Xj.ScopeType.BLOCK,id:"blockDelete",weight:6,associatedKeyboardShortcut:"delete"})}; +rk=function(){Xj.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:Xj.ScopeType.BLOCK,id:"blockHelp",weight:7})}; +sk=function(){Xj.registry.register({displayText:()=>$.C.REMOVE_COMMENT,preconditionFn(a){var b;return((b=a.comment)==null?0:b.isDeletable())?"enabled":"hidden"},callback(a){$.r(!0);var b;(b=a.comment)==null||b.dispose();$.r(!1);var c;(c=a.comment)==null||c.workspace.getAudioManager().play("delete")},scopeType:Xj.ScopeType.COMMENT,id:"commentDelete",weight:6,associatedKeyboardShortcut:"delete"})}; +tk=function(){Xj.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&&Ki(b,a.comment.workspace)}},scopeType:Xj.ScopeType.COMMENT,id:"commentDuplicate",weight:1,associatedKeyboardShortcut:"duplicate"})}; +uk=function(){Xj.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)$.r(!0),b=new dg(a),b.moveTo(pd(a,new D(d.x,d.y))),$.A().focusNode(b),$.r(!1)},scopeType:Xj.ScopeType.WORKSPACE,id:"commentCreate",weight:8})};vk=function(){Yj();Zj();ak();ck();dk();hk();ik();kk();nk();ok();pk();qk();rk()}; +xk=function(a,b){a.setAttribute("dir","LTR");zc(a,b.hasCss,b.pathToMedia);var c=z(x.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=z(x.DEFS,{},c),e=String(Math.random()).substring(2);b.gridPattern=wk.createDom(e,b.gridOptions,d,a);return c}; +yk=function(a,b,c){c.parentWorkspace=null;c=new Gi(c);var d=c.options;c.scale=d.zoomOptions.startScale;b.appendChild(c.createDom("blocklyMainBackground",a));var e=c.getRenderer().getClassName();e&&v(a,e);(e=c.getTheme().getClassName())&&v(a,e);!d.hasCategories&&d.languageTree&&(e=c.addFlyout(x.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, +0);c.addChangeListener(Uh(c));Kb(c);lf();Rd();Ae();return c}; +Ck=function(a){var b=a.options,c=a.getParentSvg();k(c.parentNode,"contextmenu",null,function(d){ma(d)||d.preventDefault()});c=k(window,"resize",null,function(){Ie();a.hideComponents(!0);Kb(a);pe();xf();Th(a)});a.setResizeHandlerWrapper(c);zk();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(); +b.moveOptions&&b.moveOptions.scrollbars?(a.scrollbar=new Ak(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&&Bk(b.pathToMedia,a)}; +zk=function(){Dk||(k(document,"scroll",null,function(){var a=zb();for(let b=0,c;c=a[b];b++)c instanceof Gi&&c.updateInverseScreenCTM()}),ka(document,"touchend",null,aa),ka(document,"touchcancel",null,aa),ka(document,"keydown",null,function(a){a.key==="Tab"&&zg.setIsActive(!0)}));Dk=!0};Bk=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")}; +Ek=function(a){var b=a.saveState();if(!a.getParameters().length)return b;b.parameters=a.getParameters().map(c=>c.saveState());return b};Fk=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};M=M||{};M.scope={};M.ASSUME_ES2020=!1;M.ASSUME_ES6=M.ASSUME_ES2020;M.ASSUME_ES5=M.ASSUME_ES6;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}; +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>>0,M.propertyToPolyfillSymbol[d]=M.IS_SYMBOL_NATIVE?M.global.Symbol(d):M.POLYFILL_PREFIX+a+"$"+ +d),M.defineProperty(e,M.propertyToPolyfillSymbol[d],{configurable:!0,writable:!0,value:b})))}; +M.getConstructImplementation=function(){function a(){function c(){}new c;Reflect.construct(c,[],function(){});return new c instanceof c}if(M.TRUST_ES6_POLYFILLS&&typeof Reflect!="undefined"&&Reflect.construct){if(a())return Reflect.construct;var b=Reflect.construct;return function(c,d,e){c=b(c,d);e&&Reflect.setPrototypeOf(c,e.prototype);return c}}return function(c,d,e){e===void 0&&(e=c);e=M.objectCreate(e.prototype||Object.prototype);return Function.prototype.apply.call(c,e,d)||e}};M.construct={valueOf:M.getConstructImplementation}.valueOf(); +M.underscoreProtoCanBeSet=function(){var a={a:!0},b={};try{return b.__proto__=a,b.a}catch(c){}return!1};M.setPrototypeOf=M.ASSUME_ES6||M.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:M.underscoreProtoCanBeSet()?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null; +M.inherits=function(a,b){a.prototype=M.objectCreate(b.prototype);a.prototype.constructor=a;if(M.ASSUME_ES6||M.setPrototypeOf){var c=M.setPrototypeOf;c(a,b)}else for(c in b)if(c!="prototype")if(Object.defineProperties){var d=Object.getOwnPropertyDescriptor(b,c);d&&Object.defineProperty(a,c,d)}else a[c]=b[c];a.superClass_=b.prototype};M.arrayIteratorImpl=function(a){var b=0;return function(){return b0;){var a=this.properties_.pop();if(a in this.object_)return a}return null}; +M.generator.Context.PropertyIterator.prototype.getNext=M.generator.Context.PropertyIterator.prototype.getNext;M.generator.Engine_=function(a){this.context_=new M.generator.Context;this.program_=a};M.generator.Engine_.prototype.next_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_)return this.yieldAllStep_(this.context_.yieldAllIterator_.next,a,this.context_.next_);this.context_.next_(a);return this.nextStep_()}; +M.generator.Engine_.prototype.return_=function(a){this.context_.start_();var b=this.context_.yieldAllIterator_;if(b)return this.yieldAllStep_("return"in b?b["return"]:function(c){return{value:c,done:!0}},a,this.context_.return);this.context_.return(a);return this.nextStep_()}; +M.generator.Engine_.prototype.throw_=function(a){this.context_.start_();if(this.context_.yieldAllIterator_){var b=this.context_.yieldAllIterator_["throw"];if(b)return this.yieldAllStep_(b,a,this.context_.next_);a=this.context_.yieldAllIterator_;this.context_.yieldAllIterator_=null;try{if(a["return"]){var c=a["return"]();M.generator.ensureIteratorResultIsObject_(c)}this.context_.throw_(new TypeError("The iterator does not provide a 'throw' method."))}catch(d){this.context_.throw_(d)}return this.nextStep_()}this.context_.throw_(a); +return this.nextStep_()};M.generator.Engine_.prototype.yieldAllStep_=function(a,b,c){try{var d=a.call(this.context_.yieldAllIterator_,b);M.generator.ensureIteratorResultIsObject_(d);if(!d.done)return this.context_.stop_(),d;var e=d.value}catch(f){return this.context_.yieldAllIterator_=null,this.context_.throw_(f),this.nextStep_()}this.context_.yieldAllIterator_=null;c.call(this.context_,e);return this.nextStep_()}; +M.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var a=this.program_(this.context_);if(a)return this.context_.stop_(),{value:a.value,done:!1}}catch(b){this.context_.yieldResult=void 0,this.context_.throw_(b)}this.context_.stop_();if(this.context_.abruptCompletion_){a=this.context_.abruptCompletion_;this.context_.abruptCompletion_=null;if(a.isException)throw a.exception;return{value:a.return,done:!0}}return{value:void 0,done:!0}}; +M.generator.Generator_=function(a){this.next=function(b){return a.next_(b)};this.throw=function(b){return a.throw_(b)};this.return=function(b){return a.return_(b)};this[Symbol.iterator]=function(){return this}}; +M.generator.createGenerator=function(a,b){b=new M.generator.Generator_(new M.generator.Engine_(b));var c=M.setPrototypeOf;if(c){var d=M.getIteratorPrototype();if(d)if(a.prototype){var e=a.prototype,f=Object.getPrototypeOf;f=(typeof e==="object"&&e!==null||typeof e==="function")&&f?f(e):e.__proto__;if(!d.isPrototypeOf(e)&&f===Object.prototype)try{c(e,d)}catch(g){}}else c(b,d);a.prototype&&c(b,a.prototype)}return b}; +M.asyncExecutePromiseGenerator=function(a){function b(d){return a.next(d)}function c(d){return a.throw(d)}return new Promise(function(d,e){function f(g){g.done?d(g.value):Promise.resolve(g.value).then(b,c).then(f,e)}f(a.next())})};M.asyncExecutePromiseGeneratorFunction=function(a){return M.asyncExecutePromiseGenerator(a())};M.asyncExecutePromiseGeneratorProgram=function(a){return M.asyncExecutePromiseGenerator(new M.generator.Generator_(new M.generator.Engine_(a)))}; +M.polyfill("globalThis",function(a){return a||M.global},"es_2020","es3");M.polyfill("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(c<0&&(c=Math.max(c+e,0));c1,d=arguments[1];M.iteratorDo(this,b,function(e,f){c?d=b(d,e,f):(c=!0,d=e)});if(!c)throw new TypeError("Reduce of empty iterator");return d}},"es_next","es3"); +M.iteratorFromArray=function(a,b){if(M.ASSUME_ES6)return a[Symbol.iterator]();a instanceof String&&(a+="");var c=0,d=!1;return M.iteratorPrototype(function(){if(!d&&c0?(d=Array.prototype.flat.call(d,b-1),c.push.apply(c,d)):c.push(d)});return c}},"es9","es5");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");var Qb=Object.create(null);var Hk="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,Ik= +{TOUCH_ENABLED:Hk,TOUCH_MAP:ia};Ik.checkTouchIdentifier=da;Ik.clearTouchIdentifier=function(){ha=null};Ik.getTouchIdentifierFromEvent=fa;Ik.longStart=ca;Ik.longStop=aa;Ik.shouldHandleEvent=ea;var Jk,Kk,Lk,Mk,Nk,Ok,Pk,Qk,Rk,Sk;(function(a){function b(d){return c.includes(d.toUpperCase())}Jk=a;var c=Jk.toUpperCase();Kk=b("JavaFX");Lk=b("WebKit");Mk=b("Gecko")&&!Lk;Nk=b("Android");a=globalThis.navigator&&globalThis.navigator.maxTouchPoints;Ok=b("iPad")||b("Macintosh")&&a>0;Pk=b("iPhone")&&!Ok;Qk=b("Macintosh");Rk=Ok||Nk&&!b("Mobile")||b("Silk");Sk=!Rk&&(Pk||Nk)})(globalThis.navigator&&globalThis.navigator.userAgent||""); +var Vb=Kk,Tk=Mk,Uk=Nk,Sj=Ok,Tj=Pk,na=Qk,Vk=Sk,fd=na||Sj||Tj,Wk={ANDROID:Uk,APPLE:fd,GECKO:Tk,IPAD:Sj,IPHONE:Tj,JavaFx:Vb,MAC:na,MOBILE:Vk,raw:Jk};var Xk={};Xk.bind=ka;Xk.conditionalBind=k;Xk.getScrollDeltaPixels=qa;Xk.isRightButton=oa;Xk.isTargetInput=ma;Xk.mouseToSvg=pa;Xk.unbind=la;var q,Yk=q||(q={});Yk.BLOCK_CREATE="create";Yk.BLOCK_DELETE="delete";Yk.BLOCK_CHANGE="change";Yk.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change";Yk.BLOCK_MOVE="move";Yk.VAR_CREATE="var_create";Yk.VAR_DELETE="var_delete";Yk.VAR_RENAME="var_rename";Yk.VAR_TYPE_CHANGE="var_type_change";Yk.UI="ui";Yk.BLOCK_DRAG="drag";Yk.SELECTED="selected";Yk.CLICK="click";Yk.MARKER_MOVE="marker_move";Yk.BUBBLE_OPEN="bubble_open";Yk.TRASHCAN_OPEN="trashcan_open";Yk.TOOLBOX_ITEM_SELECT="toolbox_item_select"; +Yk.THEME_CHANGE="theme_change";Yk.VIEWPORT_CHANGE="viewport_change";Yk.COMMENT_CREATE="comment_create";Yk.COMMENT_DELETE="comment_delete";Yk.COMMENT_CHANGE="comment_change";Yk.COMMENT_MOVE="comment_move";Yk.COMMENT_RESIZE="comment_resize";Yk.COMMENT_DRAG="comment_drag";Yk.COMMENT_COLLAPSE="comment_collapse";Yk.FINISHED_LOADING="finished_loading";var Sh=[q.BLOCK_CREATE,q.BLOCK_MOVE,q.COMMENT_CREATE,q.COMMENT_MOVE];var ra=Object.create(null),Zk={typeMap:ra},sa=Object.create(null),l=class{constructor(a){this.name=a}toString(){return this.name}};l.CONNECTION_CHECKER=new l("connectionChecker");l.CONNECTION_PREVIEWER=new l("connectionPreviewer");l.EVENT=new l("event");l.FIELD=new l("field");l.INPUT=new l("input");l.RENDERER=new l("renderer");l.TOOLBOX=new l("toolbox");l.THEME=new l("theme");l.TOOLBOX_ITEM=new l("toolboxItem");l.FLYOUTS_VERTICAL_TOOLBOX=new l("flyoutsVerticalToolbox"); +l.FLYOUTS_HORIZONTAL_TOOLBOX=new l("flyoutsHorizontalToolbox");l.FLYOUT_INFLATER=new l("flyoutInflater");l.METRICS_MANAGER=new l("metricsManager");l.BLOCK_DRAGGER=new l("blockDragger");l.SERIALIZER=new l("serializer");l.ICON=new l("icon");l.PASTER=new l("paster");l.VARIABLE_MODEL=new l("variableModel");l.VARIABLE_MAP=new l("variableMap");var $k={DEFAULT:"default",TEST_ONLY:Zk};$k.Type=l;$k.getAllItems=xa;$k.getClass=wa;$k.getClassFromOptions=ya;$k.getObject=function(a,b,c){return ua(a,b,c)}; +$k.hasItem=va;$k.register=n;$k.unregister=ta;var Ba={genUid:()=>{var a=[];for(let b=0;b<20;b++)a[b]="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.random()*88);return a.join("")}},za=0,al={TEST_ONLY:Ba};al.genUid=Ca;al.getNextUniqueId=Aa;var Fa,Da;$.ec="";$.fc=!0;$.Ka=0;Fa=[];Da={FIRE_QUEUE:Fa,enqueueEvent:Ia,fireNow:Ha,fireInternal:function(a){if(La()){if(!Fa.length)try{requestAnimationFrame(()=>{setTimeout(Ha,0)})}catch(b){setTimeout(Ha,0)}Ia(a)}},setGroupInternal:function(a){$.ec=typeof a==="boolean"?a?Ca():"":a}};var Sa,bl=Sa||(Sa={});bl.ASSERTIVE="assertive";bl.OFF="off";bl.POLITE="polite";var Wa=Sa.OFF,Va=[],ab,cl=ab||(ab={});cl.APPLICATION="application";cl.BUTTON="button";cl.CHECKBOX="checkbox";cl.DIALOG="dialog";cl.FIGURE="figure";cl.GENERIC="generic";cl.GRID="grid";cl.GRIDCELL="gridcell";cl.GROUP="group";cl.LIST="list";cl.LISTBOX="listbox";cl.LISTITEM="listitem";cl.MENU="menu";cl.MENUITEM="menuitem";cl.NONE="none";cl.OPTION="option";cl.REGION="region";cl.ROW="row";cl.SEARCH="search";cl.SEPARATOR="separator"; +cl.STATUS="status";cl.TEXTBOX="textbox";cl.TREE="tree";cl.TREEITEM="treeitem";var Ta=ab.STATUS,w,dl=w||(w={});dl.ACTIVEDESCENDANT="activedescendant";dl.ATOMIC="atomic";dl.CHECKED="checked";dl.CONTROLS="controls";dl.DISABLED="disabled";dl.EXPANDED="expanded";dl.HASPOPUP="haspopup";dl.HIDDEN="hidden";dl.INVALID="invalid";dl.LABEL="label";dl.LABELLEDBY="labelledby";dl.LEVEL="level";dl.LIVE="live";dl.PRESSED="pressed";dl.ROLEDESCRIPTION="roledescription";dl.SELECTED="selected";dl.VALUEMAX="valuemax"; +dl.VALUEMIN="valuemin";dl.OWNS="owns";var td,el=td||(td={});el[el.TERSE=0]="TERSE";el[el.STANDARD=1]="STANDARD";el[el.LOQUACIOUS=2]="LOQUACIOUS";var Ra=null,Ya,Za=!1,fl={};fl.LiveRegionAssertiveness=Sa;fl.Role=ab;fl.State=w;fl.Verbosity=td;fl.announceDynamicAriaState=$a;fl.clearState=Pa;fl.getRole=function(a){return(a=a.getAttribute("role"))&&Object.values(ab).includes(a)?a:null};fl.getState=Qa;fl.initializeGlobalAriaLiveRegion=Ua;fl.removeRole=Na;fl.setRole=Oa;fl.setState=u;var x=class{constructor(a){this.tagName=a}toString(){return this.tagName}};x.ANIMATE=new x("animate");x.CIRCLE=new x("circle");x.CLIPPATH=new x("clipPath");x.DEFS=new x("defs");x.FECOMPOSITE=new x("feComposite");x.FECOMPONENTTRANSFER=new x("feComponentTransfer");x.FEFLOOD=new x("feFlood");x.FEFUNCA=new x("feFuncA");x.FEGAUSSIANBLUR=new x("feGaussianBlur");x.FEPOINTLIGHT=new x("fePointLight");x.FESPECULARLIGHTING=new x("feSpecularLighting");x.FILTER=new x("filter");x.FOREIGNOBJECT=new x("foreignObject"); +x.G=new x("g");x.IMAGE=new x("image");x.LINE=new x("line");x.PATH=new x("path");x.PATTERN=new x("pattern");x.POLYGON=new x("polygon");x.RECT=new x("rect");x.SVG=new x("svg");x.TEXT=new x("text");x.TSPAN=new x("tspan");var Wf,gl=Wf||(Wf={});gl[gl.ELEMENT_NODE=1]="ELEMENT_NODE";gl[gl.TEXT_NODE=3]="TEXT_NODE";gl[gl.COMMENT_NODE=8]="COMMENT_NODE";var jb=null,ib=0,qb=null,hl={HTML_NS:"http://www.w3.org/1999/xhtml"};hl.NodeType=Wf;hl.SVG_NS="http://www.w3.org/2000/svg";hl.XLINK_NS="http://www.w3.org/1999/xlink";hl.addClass=v;hl.createSvgElement=z;hl.getFastTextWidth=function(a,b,c,d,e,f){return pb(a,b+"pt",c,d,e,f)};hl.getFastTextWidthWithSizeString=pb;hl.getTextSize=mb;hl.getTextWidth=nb;hl.hasClass=eb; +hl.insertAfter=gb;hl.measureFontMetrics=rb;hl.removeClass=cb;hl.removeClasses=bb;hl.removeNode=fb;hl.setCssTransform=hb;hl.startTextWidthCache=kb;hl.stopTextWidthCache=lb;var il=class{static findFocusedNode(a){var b=a.getRootFocusableNode();if(!b.canBeFocused())return null;var c=b.getFocusableElement();if(eb(c,il.ACTIVE_CLASS_NAME)||eb(c,il.PASSIVE_CSS_CLASS_NAME))return b;b=c.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR);if(b instanceof HTMLElement||b instanceof SVGElement)if(b=il.findFocusableNodeFor(b,a))return b;c=c.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR);if(c instanceof HTMLElement||c instanceof SVGElement)if(a=il.findFocusableNodeFor(c,a))return a; +return null}static findFocusableNodeFor(a,b){if(!a.id||a.id==="null"||b.getNestedTrees().map(e=>il.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.getAttribute("tabindex");return d!==null&&Number(d)>=0?null:(d=a.parentElement)?il.findFocusableNodeFor(d,b):null}};il.ACTIVE_CLASS_NAME="blocklyActiveFocus"; +il.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus";il.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${il.ACTIVE_CLASS_NAME}`;il.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${il.PASSIVE_CSS_CLASS_NAME}`;var jl=class{constructor(a,b){this.tree=a;this.rootShouldBeAutoTabbable=b}},sb=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()}; +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=il.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)}); +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 jl(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; +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=il.findFocusedNode(a);var d=a.getRootFocusableNode();b&&this.removeHighlight(b);this.focusedNode!==b&&this.focusedNode!==d||this.updateFocusedNode(null);this.removeHighlight(d);c.rootShouldBeAutoTabbable&& +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=il.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();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=il.findFocusableNodeFor(d,c);d=il.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."); +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&& +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&& +!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= +-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();v(a,sb.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);cb(a,sb.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(a){a= +a.getFocusableElement();cb(a,sb.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);v(a,sb.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(a){a=a.getFocusableElement();cb(a,sb.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME);cb(a,sb.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){sb.focusManager||(sb.focusManager=new sb(document.addEventListener));return sb.focusManager}setPopoverFocusRoot(a){var b;(b=this.popoverFocusRoot)==null||b.removeEventListener("focusout",this.popoverFocusOutHandler);this.popoverFocusRoot= +a;this.popoverFocusRoot.addEventListener("focusout",this.popoverFocusOutHandler)}registerPopoverFocusLossHandler(a){this.popoverFocusLossHandlers.add(a)}unregisterPopoverFocusLossHandler(a){this.popoverFocusLossHandlers.delete(a)}};sb.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus";sb.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus";sb.focusManager=null;var kl={};kl.deepMerge=vb;var B=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); +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?this.keyMap.set(a,new Set([b,...d])):this.keyMap.set(a,new Set([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;if(d.delete(b))return d.size===0&&this.keyMap.delete(a),!0;c||console.warn(`No keyboard shortcut named "${b}" registered with key code "${a}"`); +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,new Set(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 vb(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;if(!c||c.preconditionFn&&!c.preconditionFn(a,{focusedNode:(e=$.A().getFocusedNode())!=null?e:void 0}))continue;let f,g;if((f=c.callback)==null?0:f.call(c,a,b,c,{focusedNode:(g=$.A().getFocusedNode())!=null?g:void 0}))return!0}return!1}getShortcutNamesByKeyCode(a){return(a=this.keyMap.get(a))?[...a]:[]}getKeyCodesByShortcutName(a){var b=[];for(let [c,d]of this.keyMap)d.has(a)&&b.push(c);return b}serializeKeyEvent(a){var b="";for(let c in B.modifierKeys)a.getModifierState(c)&&(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 B.modifierKeys))throw Error(b+" is not a valid modifier key.");}createSerializedKey(a,b){var c="";if(b){this.checkModifiers(b);for(let d in B.modifierKeys)b.includes(B.modifierKeys[d])&&(c!==""&&(c+="+"),c+=d)}c!==""&&a?c+="+"+a:a&&(c=`${a}`);return c}};B.registry=new B;var ll=B||(B={}),ml=ll.modifierKeys||(ll.modifierKeys={});ml[ml.Shift=16]="Shift";ml[ml.Control=17]="Control"; +ml[ml.Alt=18]="Alt";ml[ml.Meta=91]="Meta";var wb=new Set,nl={};nl.warn=xb;var yb=Object.create(null),Cb,Hb,ol=[],Nb={defineBlocksWithJsonArrayInternal:function(a){$.Rb($.Pb(a))}},pl={TEST_ONLY:Nb};pl.createBlockDefinitionsFromJsonArray=$.Pb;pl.defineBlocks=$.Rb;pl.defineBlocksWithJsonArray=Ob;pl.draggingConnections=ol;pl.fireSelectedEvent=Gb;pl.getAllWorkspaces=zb;pl.getBlockTypeCounts=Lb;pl.getMainWorkspace=Db;pl.getParentContainer=Ib;pl.getSelected=Fb;pl.getWorkspaceById=Ga;pl.globalShortcutHandler=Sb;pl.registerWorkspace=Ab;pl.setMainWorkspace=Eb; +pl.setParentContainer=Jb;pl.setSelected=function(a){$.A().focusNode(a)};pl.svgResize=Kb;pl.unregisterWorkpace=function(a){xb("Blockly.common.unregisterWorkpace","v13","v14","Blockly.common.unregisterWorkspace");Bb(a)};pl.unregisterWorkspace=Bb;var E,ql=E||(E={});ql[ql.INPUT_VALUE=1]="INPUT_VALUE";ql[ql.OUTPUT_VALUE=2]="OUTPUT_VALUE";ql[ql.NEXT_STATEMENT=3]="NEXT_STATEMENT";ql[ql.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT";var rl;rl=$.Bd||($.Bd={});rl[rl.VALUE=1]="VALUE";rl[rl.STATEMENT=3]="STATEMENT";rl[rl.DUMMY=5]="DUMMY";rl[rl.CUSTOM=6]="CUSTOM";rl[rl.END_ROW=7]="END_ROW";var hc=new Set,cc=new WeakSet,dc=new WeakMap,Xb=null,Yb=null,Zb=0,sl={};sl.finishQueuedRenders=ac;sl.queueRender=$b;sl.triggerQueuedRenders=bc;var oc={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies");}},rc={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies");}},{document:lc,DOMParser:tl,XMLSerializer:ul}=globalThis;tl&&(oc=new tl);ul&&(rc=new ul);var tc=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,vl={NAME_SPACE:"https://developers.google.com/blockly/xml"}; +vl.createElement=$.mc;vl.createTextNode=$.nc;vl.domToText=sc;vl.injectDependencies=function(a){({document:lc=lc,DOMParser:tl=tl,XMLSerializer:ul=ul}=a);oc=new tl;rc=new ul};vl.textToDom=$.pc;var wl;$.C=Object.create(null);wl={Msg:$.C,setLocale:uc};var xc=new WeakSet,vc=[],yc=` +:is( + .injectionDiv, + .blocklyWidgetDiv, + .blocklyDropdownDiv, + .blocklyTooltipDiv, +) * { + box-sizing: border-box; +} + +.blocklySvg { + background-color: #fff; + outline: none; + overflow: hidden; /* IE overflows by default. */ + position: absolute; + display: block; +} + +.blocklyWidgetDiv { + display: none; + position: absolute; + z-index: 99999; /* big value for bootstrap3 compatibility */ +} + +.injectionDiv { + height: 100%; + position: relative; + overflow: hidden; /* So blocks in drag surface disappear at edges */ + touch-action: none; + user-select: none; + -webkit-user-select: none; +} + +.blocklyBlockCanvas.blocklyCanvasTransitioning, +.blocklyBubbleCanvas.blocklyCanvasTransitioning { + transition: transform .5s; +} + +.blocklyEmboss { + filter: var(--blocklyEmbossFilter); +} + +.blocklyTooltipDiv { + background-color: #ffffc7; + border: 1px solid #ddc; + box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15); + color: #000; + display: none; + font: 9pt sans-serif; + opacity: .9; + padding: 2px; + position: absolute; + z-index: 100000; /* big value for bootstrap3 compatibility */ +} + +.blocklyDropDownDiv { + position: absolute; + left: 0; + top: 0; + z-index: 1000; + visibility: hidden; + border: 1px solid; + border-color: #dadce0; + background-color: #fff; + border-radius: 2px; + padding: 4px; + box-shadow: 0 0 3px 1px rgba(0,0,0,.3); +} + +.blocklyDropDownDiv:focus { + box-shadow: 0 0 6px 1px rgba(0,0,0,.3); +} + +.blocklyDropDownContent { + max-height: 300px; /* @todo: spec for maximum height. */ +} + +.blocklyDropDownArrow { + position: absolute; + left: 0; + top: 0; + width: 16px; + height: 16px; + z-index: -1; + background-color: inherit; + border-color: inherit; + border-top: 1px solid; + border-left: 1px solid; + border-top-left-radius: 4px; + border-color: inherit; +} + +.blocklyHighlighted>.blocklyPath { + filter: var(--blocklyEmbossFilter); +} + +.blocklyHighlightedConnectionPath { + fill: none; +} + +.blocklyHighlightedConnectionPathVisible { + stroke: #fc3; + stroke-width: 4px; +} + +.blocklyPathLight { + fill: none; + stroke-linecap: round; + stroke-width: 1; +} + +.blocklySelected>.blocklyPathLight { + display: none; +} + +.blocklyDraggable { + cursor: grab; + cursor: -webkit-grab; +} + +.blocklyDragging { + cursor: grabbing; + cursor: -webkit-grabbing; + /* Drag surface disables events to not block the toolbox, so we have to + * reenable them here for the cursor values to work. */ + pointer-events: auto; +} + + /* Changes cursor on mouse down. Not effective in Firefox because of + https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */ +.blocklyDraggable:active { + cursor: grabbing; + cursor: -webkit-grabbing; +} + +.blocklyDragging.blocklyDraggingDelete, +.blocklyDragging.blocklyDraggingDelete .blocklyField { + cursor: url("<<>>/handdelete.cur"), auto; +} + +.blocklyDragging>.blocklyPath, +.blocklyDragging>.blocklyPathLight { + fill-opacity: .8; + stroke-opacity: .8; +} + +.blocklyDragging>.blocklyPathDark { + display: none; +} + +.blocklyDisabledPattern>.blocklyPath { + fill: var(--blocklyDisabledPattern); + fill-opacity: .5; + stroke-opacity: .5; +} + +.blocklyDisabled>.blocklyPathLight, +.blocklyDisabled>.blocklyPathDark { + display: none; +} + +.blocklyInsertionMarker>.blocklyPath, +.blocklyInsertionMarker>.blocklyPathLight, +.blocklyInsertionMarker>.blocklyPathDark { + fill-opacity: .2; + stroke: none; +} + +.blocklyNonEditableField>text { + pointer-events: none; +} + +.blocklyFlyout { + position: absolute; + z-index: 25; +} + +.blocklyText text { + cursor: default; +} + +/* + Don't allow users to select text. It gets annoying when trying to + drag a block and selected text moves instead. +*/ +.blocklySvg text { + user-select: none; + -ms-user-select: none; + -webkit-user-select: none; + cursor: inherit; +} + +.blocklyIconGroup { + cursor: default; +} + +.blocklyIconGroup:not(:hover):not(:focus), +.blocklyIconGroupReadonly { + opacity: .6; +} + +.blocklyIconShape { + fill: #00f; + stroke: #fff; + stroke-width: 1px; +} + +.blocklyIconSymbol { + fill: #fff; +} + +.blocklyMinimalBody { + margin: 0; + padding: 0; + height: 100%; +} + +.blocklyHtmlInput { + border: none; + border-radius: 4px; + height: 100%; + margin: 0; + outline: none; + padding: 0; + width: 100%; + text-align: center; + display: block; + box-sizing: border-box; +} + +/* Remove the increase and decrease arrows on the field number editor */ +input.blocklyHtmlInput[type=number]::-webkit-inner-spin-button, +input.blocklyHtmlInput[type=number]::-webkit-outer-spin-button { + -webkit-appearance: none; + margin: 0; +} + +input[type=number] { + -moz-appearance: textfield; +} + +.blocklyMainBackground { + stroke-width: 1; + stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */ +} + +.blocklyMutatorBackground { + fill: #fff; + stroke: #ddd; + stroke-width: 1; +} + +.blocklyFlyoutBackground { + fill: #ddd; + fill-opacity: .8; +} + +.blocklyMainWorkspaceScrollbar { + z-index: 20; +} + +.blocklyFlyoutScrollbar { + z-index: 30; +} + +.blocklyScrollbarHorizontal, +.blocklyScrollbarVertical { + position: absolute; + outline: none; +} + +.blocklyScrollbarBackground { + opacity: 0; + pointer-events: none; +} + +.blocklyScrollbarHandle { + fill: #ccc; +} + +.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle, +.blocklyScrollbarHandle:hover { + fill: #bbb; +} + +/* Darken flyout scrollbars due to being on a grey background. */ +/* By contrast, workspace scrollbars are on a white background. */ +.blocklyFlyout .blocklyScrollbarHandle { + fill: #bbb; +} + +.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle, +.blocklyFlyout .blocklyScrollbarHandle:hover { + fill: #aaa; +} + +.blocklyInvalidInput { + background: #faa; +} + +.blocklyVerticalMarker { + stroke-width: 3px; + fill: rgba(255,255,255,.5); + pointer-events: none; +} + +.blocklyComputeCanvas { + position: absolute; + width: 0; + height: 0; +} + +.blocklyNoPointerEvents { + pointer-events: none; +} + +.blocklyContextMenu { + border-radius: 4px; + max-height: 100%; + box-sizing: content-box; +} + +.blocklyDropdownMenu { + border-radius: 2px; + padding: 0 !important; +} + +.blocklyDropdownMenu .blocklyMenuItem { + /* 28px on the left for icon or checkbox. */ + padding-left: 28px; +} + +/* BiDi override for the resting state. */ +.blocklyDropdownMenu .blocklyMenuItemRtl { + /* Flip left/right padding for BiDi. */ + padding-left: 5px; + padding-right: 28px; +} + +.blocklyWidgetDiv .blocklyMenu { + user-select: none; + -ms-user-select: none; + -webkit-user-select: none; + background: #fff; + border: 1px solid transparent; + box-shadow: 0 0 3px 1px rgba(0,0,0,.3); + font: normal 13px Arial, sans-serif; + margin: 0; + outline: none; + padding: 4px 0; + position: absolute; + overflow-y: auto; + overflow-x: hidden; + max-height: 100%; + z-index: 20000; /* Arbitrary, but some apps depend on it... */ +} + +.blocklyWidgetDiv .blocklyMenu:focus { + box-shadow: 0 0 6px 1px rgba(0,0,0,.3); +} + +.blocklyDropDownDiv .blocklyMenu { + user-select: none; + -ms-user-select: none; + -webkit-user-select: none; + background: inherit; /* Compatibility with gapi, reset from goog-menu */ + border: inherit; /* Compatibility with gapi, reset from goog-menu */ + font: normal 13px "Helvetica Neue", Helvetica, sans-serif; + outline: none; + overflow-y: auto; + overflow-x: hidden; + max-height: 100%; + z-index: 20000; /* Arbitrary, but some apps depend on it... */ +} + +/* State: resting. */ +.blocklyMenuItem { + border: none; + color: #000; + cursor: pointer; + list-style: none; + margin: 0; + /* 7em on the right for shortcut. */ + min-width: 7em; + padding: 6px 15px; + white-space: nowrap; +} + +/* State: disabled. */ +.blocklyMenuItemDisabled { + color: #ccc; + cursor: inherit; +} + +/* State: hover. */ +.blocklyMenuItemHighlight { + background-color: rgba(0,0,0,.1); +} + +/* State: selected/checked. */ +.blocklyMenuItemSelected .blocklyMenuItemCheckbox { + background: url(<<>>/sprites.svg) no-repeat -48px -16px; + float: left; + margin-left: -24px; + width: 16px; + height: 16px; + position: static; /* Scroll with the menu. */ + display: block; +} + +.blocklyMenuItemRtl .blocklyMenuItemCheckbox { + float: right; + margin-right: -24px; +} + +.blocklyMenuSeparator { + background-color: #ccc; + height: 1px; + border: 0; + margin-left: 4px; + margin-right: 4px; +} + +.blocklyRTL .blocklyMenuItemContent .blocklyShortcutContainer { + flex-direction: row-reverse; +} +.blocklyMenuItemContent .blocklyShortcutContainer { + width: 100%; + display: flex; + justify-content: space-between; + gap: 16px; +} +.blocklyMenuItemContent .blocklyShortcutContainer .blocklyShortcut { + color: #ccc; +} + +.blocklyBlockDragSurface, .blocklyAnimationLayer { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + overflow: visible !important; + z-index: 80; + pointer-events: none; +} + +.blocklyField { + cursor: default; +} + +.blocklyInputField { + cursor: text; +} + +.blocklyDragging .blocklyField, +.blocklyDragging .blocklyIconGroup { + cursor: grabbing; +} + +.blocklyActiveFocus:is( + .blocklyFlyout, + .blocklyWorkspace, + .blocklyWorkspaceSelectionRing, + .blocklyField, + .blocklyPath, + .blocklyHighlightedConnectionPath, + .blocklyComment, + .blocklyBubble, + .blocklyIconGroup, + .blocklyTextarea, +), +.blocklyZoom:focus, +.blocklyTrash:focus { + outline: none; +} +.hiddenForAria { + position: absolute; + left: -9999px; + width: 1px; + height: 1px; + overflow: hidden; +} + +.injectionDiv { + --blockly-active-node-color: #fff200; + --blockly-active-tree-color: #1379f6; + --blockly-selection-width: 3px; +} + +/* Active focus cases: */ +/* Blocks with active focus. */ +.blocklyKeyboardNavigation + .blocklyActiveFocus:is(.blocklyPath, .blocklyHighlightedConnectionPath), +/* Fields with active focus, */ +.blocklyKeyboardNavigation + .blocklyActiveFocus.blocklyField + > .blocklyFieldRect, +/* Icons with active focus. */ +.blocklyKeyboardNavigation + .blocklyActiveFocus.blocklyIconGroup + > .blocklyIconShape:first-child, +.blocklyKeyboardNavigation + .blocklyActiveFocus + > .blocklyFocusRing, +.blocklyTrash:focus-visible > .blocklyFocusRing, +.blocklyZoom:focus-visible > .blocklyFocusRing { + stroke: var(--blockly-active-node-color); + stroke-width: var(--blockly-selection-width); +} + +/* Passive focus cases: */ +/* Blocks with passive focus except when widget/dropdown div in use. */ +.blocklyKeyboardNavigation:not( + :has( + .blocklyDropDownDiv:focus-within, + .blocklyWidgetDiv:focus-within + ) + ) + .blocklyPassiveFocus:is( + .blocklyPath:not(.blocklyFlyout .blocklyPath), + .blocklyHighlightedConnectionPath + ), +/* Fields with passive focus except when widget/dropdown div in use. */ +.blocklyKeyboardNavigation:not( + :has( + .blocklyDropDownDiv:focus-within, + .blocklyWidgetDiv:focus-within + ) + ) + .blocklyPassiveFocus.blocklyField + > .blocklyFieldRect, +/* Full-block fields use the block path for their passive focus indicator. */ +.blocklyKeyboardNavigation:not( + :has( + .blocklyDropDownDiv:focus-within, + .blocklyWidgetDiv:focus-within + ) + ) + .blocklyBlock:has(> .blocklyFullBlockField.blocklyPassiveFocus) + > .blocklyPath:not(.blocklyFlyout .blocklyPath), +/* Icons with passive focus except when widget/dropdown div in use. */ +.blocklyKeyboardNavigation:not( + :has( + .blocklyDropDownDiv:focus-within, + .blocklyWidgetDiv:focus-within + ) + ) + .blocklyPassiveFocus.blocklyIconGroup + > .blocklyIconShape:first-child { + stroke: var(--blockly-active-node-color); + stroke-dasharray: 5px 3px; + stroke-width: var(--blockly-selection-width); +} + +/* Different ways for toolbox/flyout to be the active tree: */ +/* Active focus in the flyout. */ +.blocklyKeyboardNavigation .blocklyFlyout:has(.blocklyActiveFocus), +/* Active focus in the toolbox. */ +.blocklyKeyboardNavigation .blocklyToolbox:has(.blocklyActiveFocus), +/* Active focus on the toolbox/flyout. */ +.blocklyKeyboardNavigation + .blocklyActiveFocus:is(.blocklyFlyout, .blocklyToolbox) { + outline-offset: calc(var(--blockly-selection-width) * -1); + outline: var(--blockly-selection-width) solid + var(--blockly-active-tree-color); +} + +/* Suppress default outline. */ +.blocklyKeyboardNavigation + .blocklyToolboxCategoryContainer:focus-visible { + outline: none; +} + + /* Different ways for the workspace to be the active tree: */ +/* Active focus within workspace. */ +.blocklyKeyboardNavigation + .blocklyWorkspace:has(.blocklyActiveFocus) + .blocklyWorkspaceFocusRing, +/* Active focus within drag layer. */ +.blocklyKeyboardNavigation + .blocklySvg:has(~ .blocklyBlockDragSurface .blocklyActiveFocus) + .blocklyWorkspaceFocusRing, +/* Active focus on workspace. */ +.blocklyKeyboardNavigation + .blocklyWorkspace.blocklyActiveFocus + .blocklyWorkspaceFocusRing, +/* Focus in widget/dropdown div considered to be in workspace. */ + .blocklyKeyboardNavigation + .blocklyWorkspace.blocklyShowingDropDownDiv + .blocklyWorkspaceFocusRing, +.blocklyKeyboardNavigation + .blocklyWorkspace.blocklyShowingWidgetDiv + .blocklyWorkspaceFocusRing { + stroke: var(--blockly-active-tree-color); + stroke-width: calc(var(--blockly-selection-width) * 2); +} + +/* The region itself is the active node (e.g. focused by clicking the + background). */ +.blocklyKeyboardNavigation + .blocklyWorkspace.blocklyActiveFocus + .blocklyWorkspaceSelectionRing, +/* The selection ring itself is the active node (it doubles as the workspace's + keyboard focus target). */ +.blocklyKeyboardNavigation + .blocklyWorkspaceSelectionRing.blocklyActiveFocus { + stroke: var(--blockly-active-node-color); + stroke-width: var(--blockly-selection-width); +} + +/* The selection ring is a decorative highlight that can also be the workspace's + focus target; either way it should never intercept pointer events. */ +.blocklyWorkspaceSelectionRing { + pointer-events: none; +} + +/* The workspace itself is the active node. */ +.blocklyKeyboardNavigation + .blocklyBubble.blocklyActiveFocus + .blocklyEmboss .blocklyDraggable { + stroke: var(--blockly-active-node-color); + stroke-width: var(--blockly-selection-width); +} +/* Flyout buttons and labels */ +.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutLabel.blocklyActiveFocus, +.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutButton.blocklyActiveFocus { + outline: none; +} +.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutLabel.blocklyActiveFocus > .blocklyFlyoutLabelText, +.blocklyKeyboardNavigation .blocklyFlyout .blocklyFlyoutButton.blocklyActiveFocus > .blocklyFlyoutButtonBackground { + outline-offset: 2px; + outline: var(--blockly-selection-width) solid var(--blockly-active-node-color); + border-radius: 2px; +} +.blocklyDialog { + min-width: 300px; + border-radius: 16px; + box-shadow: 0 8px 8px rgba(0, 0, 0, 0.2); + border: 1px solid #999; +} +.blocklyDialogForm { + display: flex; + flex-direction: column; + row-gap: 8px; +} +.blocklyDialogButtonRow { + display: flex; + flex-direction: ${Vk||fd?"row-reverse":"row"}; + column-gap: 8px; +} + +@media (prefers-reduced-motion: reduce) { + .blocklyBlockCanvas.blocklyCanvasTransitioning, + .blocklyBubbleCanvas.blocklyCanvasTransitioning, + .blocklyDropDownDiv { + transition: none !important; + } +} +`,xl={};xl.inject=zc;xl.register=wc;var Ri=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=Sa.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")); +b.className="blocklyToastCloseButton";u(b,w.LABEL,$.C.CLOSE);var g=z(x.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},b);u(g,w.HIDDEN,!0);z(x.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},g);z(x.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=$.A(),y=m.getPreviouslyFocusedNode();f.remove();(y==null?0:y.canBeFocused())?m.focusNode(y):m.focusTree(a)}); +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();$a(c,{assertiveness:e,role:ab.STATUS});return f}static hide(a,b){a=a.getInjectionDiv().querySelector(".blocklyToast");a instanceof HTMLElement&&(!b||b===a.dataset.toastId)&&a.remove()}};Ri.shownIds=new Set;wc("\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\n@media (prefers-reduced-motion: reduce) {\n .blocklyToast {\n transition: none;\n }\n}\n");var Bc,yl=Bc||(Bc={});yl[yl.ALERT=1]="ALERT";yl[yl.CONFIRM=2]="CONFIRM";yl[yl.PROMPT=3]="PROMPT";var Lc=0,Fc=Cc,Hc=Dc,Jc=Ec,zl=Ri.show.bind(Ri),Al=zl,Bl={};Bl.alert=Gc;Bl.confirm=Ic;Bl.prompt=Kc;Bl.setAlert=function(a=Cc){Fc=a};Bl.setConfirm=function(a=Dc){Hc=a};Bl.setPrompt=function(a=Ec){Jc=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=$.ec;this.recordUndo=$.fc}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=Ga(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 Yf=class{constructor(a){this.name=a}toString(){return this.name}equals(a){return this.name===a.toString()}};Yf.MUTATOR=new Yf("mutator");Yf.WARNING=new Yf("warning");Yf.COMMENT=new Yf("comment");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 Pc=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 Pc(Math.max(a.width,b.width),Math.max(a.height,b.height))}static min(a,b){return new Pc(Math.min(a.width,b.width),Math.min(a.height,b.height))}};var El={};El.register=Nc;El.unregister=function(a){ta(l.SERIALIZER,a)};var Fl=class{constructor(){this.priority=25}save(a){var b=[];for(let c of a.getTopComments())(a=Oc(c,{addCoordinates:!0,saveIds:!0}))&&b.push(a);return b.length?b:null}load(a,b){for(let c of a)Qc(c,b,{recordUndo:$.fc})}clear(a){for(let b of a.getTopComments())b.dispose()}};Nc("workspaceComments",new Fl);var Gl={};Gl.WorkspaceCommentSerializer=Fl;Gl.append=Qc;Gl.save=Oc;var Hl={};Hl.register=Rc;Hl.unregister=function(a){ta(l.PASTER,a)};var Il=class{paste(a,b,c){a=a.commentState;c&&(a.x=c.x,a.y=c.y);$.Ka++;try{var d=Qc(a,b);Tc(d)}finally{$.Ka--}if(!d)return null;La()&&p(new (t(q.COMMENT_CREATE))(d));$.A().focusNode(d);return d}};Il.TYPE="workspace-comment";Rc(Il.TYPE,new Il);$.Nf={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250};var If=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=Aa()}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? +"blocklyMenuItemRtl ":"");var b=document.createElement("div");u(a,w.LABEL,this.getAriaLabel());Oa(b,ab.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&&Oa(a,this.roleName);u(a,w.SELECTED,this.checkable&&this.checked||!1);u(a,w.DISABLED,!this.enabled);return a}getAriaLabel(){return this.ariaLabel||(typeof this.content==="string"? +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", +this.checked),u(a,w.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),u(a,w.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; +if((d=this.getElement())==null||!d.querySelector(".blocklyMenuItemContent .blocklyMenuItemCheckbox")){a=document.createElement("div");u(a,w.HIDDEN,!0);a.className="blocklyMenuItemCheckbox ";var b,c;(b=this.getElement())==null||(c=b.querySelector(".blocklyMenuItemContent"))==null||c.prepend(a)}}else{let d,e;(d=this.getElement())==null||(e=d.querySelector(".blocklyMenuItemContent .blocklyMenuItemCheckbox"))==null||e.remove()}}};var Zc=class{constructor(a,b,c,d){this.top=a;this.bottom=b;this.left=c;this.right=d}static from(a){return new Zc(a.y,a.y+a.height,a.x,a.x+a.width)}clone(){return new Zc(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<= +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 Zc(a,a+c,d,d+b)}};var Uc={getSizeInternal:function(a){if(Wc(a,"display")!=="none")return new Pc(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 Pc(f,a)}},Jl={TEST_ONLY:Uc};Jl.getBorderBox=$c;Jl.getComputedStyle=Wc;Jl.getContainerOffsetToScrollInto=bd;Jl.getPageOffset=Xc;Jl.getSize=Vc;Jl.getViewportPageOffset=Yc; +Jl.pageToContainerOffset=ad;Jl.scrollIntoContainerView=cd;var Gf=class{constructor(){this.menuItems=[];this.roleName=this.element=this.onKeyDownHandler=this.pointerLeaveHandler=this.pointerEnterHandler=this.clickHandler=this.pointerMoveHandler=this.highlightedItem=this.openingCoords=null;this.id=Aa()}addChild(a){this.menuItems.push(a)}render(a){var b=document.createElement("div");b.className="blocklyMenu";b.tabIndex=0;b.id=this.getId();this.roleName&&Oa(b,this.roleName);this.element=b;for(let c=0,d;d=this.menuItems[c];c++)b.appendChild(d.createDom());this.pointerMoveHandler= +k(b,"pointermove",this,this.handlePointerMove,!0);this.clickHandler=k(b,"pointerup",this,this.handleClick,!0);this.pointerEnterHandler=k(b,"pointerenter",this,this.handlePointerEnter,!0);this.pointerLeaveHandler=k(b,"pointerleave",this,this.handlePointerLeave,!0);this.onKeyDownHandler=k(b,"keydown",this,this.handleKeyEvent);a.appendChild(b);return b}getElement(){return this.element}focus(){var a=this.getElement();a&&a.focus({preventScroll:!0})}blur(){var a=this.getElement();a&&a.blur()}setRole(a){this.roleName= +a}dispose(){this.pointerMoveHandler&&(la(this.pointerMoveHandler),this.pointerMoveHandler=null);this.clickHandler&&(la(this.clickHandler),this.clickHandler=null);this.pointerEnterHandler&&(la(this.pointerEnterHandler),this.pointerEnterHandler=null);this.pointerLeaveHandler&&(la(this.pointerLeaveHandler),this.pointerLeaveHandler=null);this.onKeyDownHandler&&(la(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let a=0,b;b=this.menuItems[a];a++)b.dispose();this.element=null}getMenuItem(a){for(var b= +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&&(cd(c,b),u(b,w.ACTIVEDESCENDANT,a.getId()))}}highlightNext(){var a=this.highlightedItem?this.getMenuItems().indexOf(this.highlightedItem): +-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))&& +(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; +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=Vc(a);b.height=a.scrollHeight;return b}getMenuItems(){return this.menuItems.filter(a=>a instanceof If)}getId(){return this.id}};var Hf=class{constructor(){this.element=null}createDom(){this.element=document.createElement("hr");this.element.className="blocklyMenuSeparator";Oa(this.element,ab.SEPARATOR);return this.element}dispose(){var a;(a=this.element)==null||a.remove();this.element=null}};var ed={Control:$.C.CONTROL_KEY,Meta:"\u2318",Alt:fd?"\u2325":$.C.ALT_KEY},id=["Meta","Control","Alt","Shift"];var jd=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,kd=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Kl={TEST_ONLY:{XY_REGEX:jd,XY_STYLE_REGEX:kd}};Kl.getDocumentScroll=od;Kl.getInjectionDivXY=md;Kl.getRelativeXY=ld;Kl.getViewportBBox=nd;Kl.screenToWsCoordinates=pd;Kl.wsToScreenCoordinates=qd;var Gd,Ll=Gd||(Gd={});Ll[Ll.UNKNOWN=0]="UNKNOWN";Ll[Ll.BEFORE=1]="BEFORE";Ll[Ll.AFTER=2]="AFTER";Ll[Ll.AROUND=3]="AROUND";Ll[Ll.INSIDE=4]="INSIDE";Ll[Ll.TO=5]="TO";var Ml={};Ml.clamp=Md;Ml.toDegrees=function(a){return a*180/Math.PI};Ml.toRadians=Ld;var ne=null,ee=null,fe="",ge="",Nd,Od,Qd,be=null,de=null,Xd=null,Sd=null,Pd=null,oe={getBoundsInfo:function(){var a=Xc(be),b=Vc(be);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=oe.getBoundsInfo(),f=Vc(Nd);if(b+f.heighte.top)return ke(c,d,e,f);if(b+f.heightdocument.documentElement.clientTop)return ke(c, +d,e,f);a=ie(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}}},Nl={ANIMATION_TIME:.25,ARROW_HORIZONTAL_PADDING:12,ARROW_SIZE:16,BORDER_SIZE:1,PADDING_Y:16,TEST_ONLY:oe};Nl.clearContent=Vd;Nl.createDom=Rd;Nl.getContentDiv=function(){return Od};Nl.getOwner=function(){return de};Nl.getPositionX=ie;Nl.hide=Td;Nl.hideIfOwner=me;Nl.hideWithoutAnimation=le;Nl.isVisible=function(){return!!de}; +Nl.repositionForWindowResize=pe;Nl.setBoundsElement=function(a){be=a};Nl.setColour=Wd;Nl.show=ce;Nl.showPositionedByBlock=function(a,b,c,d,e=!0){return Yd(ae(b),a,e,c,d)};Nl.showPositionedByField=$d;var Ol={};Ol.commonWordPrefix=re;Ol.commonWordSuffix=se;Ol.isNumber=$.we;Ol.shortestStringLength=qe;Ol.wrap=$.ve;var Te=void 0,Me=!1,Ge=!1,Ke=0,Le=0,Ne=0,Oe=0,He=null,Je=null,ze=null,Pl={HOVER_MS:750,LIMIT:50,MARGINS:5,OFFSET_X:0,OFFSET_Y:10,RADIUS_OK:10};Pl.bindMouseEvents=Ee;Pl.block=Se;Pl.createDom=Ae;Pl.display=Re;Pl.dispose=Qe;Pl.getCustomTooltip=function(){return Te};Pl.getDiv=function(){return ze};Pl.getTooltipOfObject=ye;Pl.hide=Ie;Pl.isVisible=function(){return Me};Pl.setCustomTooltip=function(a){Te=a};Pl.unbindMouseEvents=Fe;Pl.unblock=function(){Ge=!1};var $e=.45,af=.65,Ue={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"},Ql={};Ql.blend=Ze;Ql.getHsvSaturation=function(){return $e};Ql.getHsvValue=function(){return af};Ql.hexToRgb=Xe;Ql.hsvToHex=Ye;Ql.hueToHex=bf;Ql.names=Ue;Ql.parse=We;Ql.rgbToHex=Ve;Ql.setHsvSaturation=function(a){$e=a}; +Ql.setHsvValue=function(a){af=a};var Rl={checkMessageReferences:function(a){var b=!0,c=a.match(/%{BKY_[A-Z]\w*}/gi);if(c)for(let d=0;dthis.maxDisplayLength&&(a=a.substring(0,this.maxDisplayLength-2)+"\u2026");a=a.replace(/\s/g,pf.NBSP);this.sourceBlock_&&this.sourceBlock_.RTL&&(a+="\u200f");return a}getText(){var a= +this.getText_();return a!==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=$.ec;c||$.r(!0);try{let m=this.doClassValidation_(a),y=this.processValidation(a,m,b);if(!(y instanceof Error)){var d,e=(d=this.getValidator())==null?void 0:d.call(this,y),f=this.processValidation(y,e,b);if(!(f instanceof +Error)){var g=this.sourceBlock_;if(!g||!g.disposed){var h=this.getValue();h===f?this.doValueUpdate_(f):(this.doValueUpdate_(f),b&&g&&La()&&p(new (t(q.BLOCK_CHANGE))(g,"field",this.name||null,h,f)),this.isDirty_&&this.forceRerender())}}}}finally{$.r(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_&&!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?ye(a):ye({tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Xc(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){var a= +null,b=this.getSourceBlock();if(!b)throw new ii;var c=b.inputList;for(let d=0;d{d.stopPropagation();$.A().focusNode(this); +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=== +"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", +`${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=Zc.from(this.foreignObject.getBoundingClientRect());this.workspace.scrollBoundsIntoView(Zc.createFromPoint(pd(this.workspace,a.getOrigin()),a.getWidth(),a.getHeight()))}onNodeBlur(){}canBeFocused(){return!!this.id}};var am=class extends Yl{constructor(a,b,c,d){super(`${a}_delete_bar_button`,b,c,d);this.icon=z(x.IMAGE,{"class":"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:this.id},c);this.recomputeAriaContext();this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){la(this.bindId)}reposition(){var a=this.getMargin();this.icon.setAttribute("x","0");var b=this.container.getBBox();this.icon.setAttribute("y",`${a}`);this.icon.setAttribute("x",`${b.width- +this.getSize(!0).getWidth()}`)}performAction(a){ha=null;a&&a instanceof PointerEvent&&oa(a)?a.stopPropagation():(this.getCommentView().dispose(),a==null||a.stopPropagation(),$.A().focusNode(this.workspace),this.workspace.getAudioManager().play("delete"))}getAriaLabel(){return $.C.REMOVE_COMMENT}};var bm=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=z(x.G,{"class":"blocklyComment blocklyEditable blocklyDraggable"});Oa(this.svgRoot,ab.BUTTON);u(this.svgRoot,w.ROLEDESCRIPTION,$.C.ARIA_LABEL_COMMENT);this.highlightRect=this.createHighlightRect(this.svgRoot); +({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();u(this.svgRoot,w.LABELLEDBY,this.commentEditor.getFocusableElement().id);this.resizeHandle=this.createResizeHandle(this.svgRoot,a);var c;(c=a.getLayerManager())==null||c.append(this,50);this.size=bm.defaultCommentSize;this.setSizeWithoutFiringEvents(this.size); +this.moveTo(new D(0,0))}createHighlightRect(a){return z(x.RECT,{"class":"blocklyCommentHighlight"},a)}createTopBar(a){a=z(x.G,{"class":"blocklyCommentTopbar"},a);var b=z(x.RECT,{"class":"blocklyCommentTopbarBackground"},a),c=new am(this.commentId,this.workspace,a,this),d=new Zl(this.commentId,this.workspace,a,this);this.addDisposeListener(()=>{c.dispose();d.dispose()});var e=z(x.TEXT,{"class":"blocklyCommentPreview blocklyCommentText blocklyText"},a),f=document.createTextNode("");e.appendChild(f); +return{topBarGroup:a,topBarBackground:b,deleteButton:c,foldoutButton:d,textPreview:e,textPreviewNode:f}}createTextArea(){var a=new $l(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=z(x.IMAGE,{"class":"blocklyResizeHandle",href:`${b.options.pathToMedia}resize-handle.svg`},a);k(a,"pointerdown", +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=Pc.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); +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=nb(this.textPreview);this.foldoutButton.isVisible()?c+=this.foldoutButton.getSize(!0).getWidth():b&&(c+=4);this.deleteButton.isVisible()?c+=this.deleteButton.getSize(!0).getWidth(): +b&&(c+=4);return new Pc(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", +`${(this.workspace.RTL?-1:1)*d.getWidth()}`);this.textPreview.setAttribute("y",`${b+c.height/2}`);this.textPreview.setAttribute("width",`${a}`)}updateResizeHandlePosition(a,b){this.resizeHandle.setAttribute("y",`${a.height-b.height}`);this.resizeHandle.setAttribute("x",`${a.width-b.width}`)}onSizeChange(a,b){for(let c=this.sizeChangeListeners.length-1;c>=0;c--)this.sizeChangeListeners[c](a,b)}addSizeChangeListener(a){this.sizeChangeListeners.push(a)}removeSizeChangeListener(a){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(a), +1)}onResizePointerDown(a){this.isEditable()&&(this.bringToFront(),oa(a)||(this.preResizeSize=this.getSize(),Rf(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&&(la(this.resizePointerUpListener), +this.resizePointerUpListener=null);this.resizePointerMoveListener&&(la(this.resizePointerMoveListener),this.resizePointerMoveListener=null);this.setSize(this.size);this.preResizeSize=void 0}onResizePointerMove(a){a=Sf(this.workspace,a);this.setSizeWithoutFiringEvents(new Pc(this.workspace.RTL?-a.x:a.x,a.y))}isCollapsed(){return this.collapsed}setCollapsed(a){(this.collapsed=a)?v(this.svgRoot,"blocklyCollapsed"):cb(this.svgRoot,"blocklyCollapsed");this.setSizeWithoutFiringEvents(this.size);this.onCollapse()}onCollapse(){for(let a= +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)?(v(this.svgRoot,"blocklyEditable"),cb(this.svgRoot,"blocklyReadonly")):(cb(this.svgRoot,"blocklyEditable"),v(this.svgRoot,"blocklyReadonly"));this.commentEditor.setEditable(a)}getRelativeToSurfaceXY(){return this.location.clone()}moveTo(a){this.location= +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= +this.svgRoot.parentNode,b=a.childNodes;b[b.length-1]!==this.svgRoot&&a.appendChild(this.svgRoot)}onDeleteDown(a){ha=null;oa(a)||this.dispose();a.stopPropagation()}dispose(){this.disposing=!0;fb(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), +1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};bm.defaultCommentSize=new Pc(120,100);wc("\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.blocklyComment.blocklyActiveFocus .blocklyCommentHighlight {\n stroke: var(--blockly-active-node-color);\n stroke-width: calc(2 * var(--blockly-selection-width));\n}\n\n.blocklyCollapsed.blocklyComment.blocklyActiveFocus .blocklyCommentTopbarBackground {\n stroke: var(--blockly-active-node-color);\n stroke-width: var(--blockly-selection-width);\n}\n\n.blocklyCommentText.blocklyActiveFocus {\n border-color: var(--blockly-active-node-color);\n border-width: var(--blockly-selection-width);\n}\n\n.blocklyCommentTopbar image.blocklyActiveFocus {\n outline: var(--blockly-selection-width) solid var(--blockly-active-node-color);\n}\n\n.blocklyCollapsed.blocklyComment.blocklyActiveFocus .blocklyCommentHighlight {\n stroke: none;\n}\n");var eg=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:Ca();this.size=bm.defaultCommentSize;a.addTopComment(this);this.fireCreateEvent()}fireCreateEvent(){La()&&p(new (t(q.COMMENT_CREATE))(this))}fireDeleteEvent(){La()&&p(new (t(q.COMMENT_DELETE))(this))}fireChangeEvent(a,b){La()&&p(new (t(q.COMMENT_CHANGE))(this,a,b))}fireCollapseEvent(a){La()&& +p(new (t(q.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 (t(q.COMMENT_RESIZE))(this);this.size=a;b.recordCurrentSizeAsNewSize();p(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= +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 (t(q.COMMENT_MOVE))(this);b&&c.setReason(b);this.location=a;c.recordNew();p(c)}getRelativeToSurfaceXY(){return this.location.clone()}dispose(){this.disposing= +!0;this.fireDeleteEvent();this.workspace.removeTopComment(this);this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}};var dg=class extends eg{constructor(a,b){super(a,b);this.dragStrategy=new Xl(this);this.workspace=a;this.view=new bm(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, +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= +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 Zc(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?v(this.getSvgRoot(),"blocklyDragging"):cb(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing= +!0;var a=$.A();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),$.A().focusNode(this))}setDeleteStyle(a){a?v(this.getSvgRoot(),"blocklyDraggingDelete"):cb(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(){v(this.getSvgRoot(), +"blocklySelected");Gb(this)}unselect(){cb(this.getSvgRoot(),"blocklySelected");Gb(null)}toCopyData(){return{paster:Il.TYPE,commentState:Oc(this,{addCoordinates:!0,saveIds:!1})}}showContextMenu(a){var b=Xj.registry.getContextMenuOptions({comment:this,focusedNode:this},a);var c=a instanceof PointerEvent?new D(a.clientX,a.clientY):qd(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10);Ff(a,b,this.workspace.RTL,this.workspace,c)}snapToGrid(){if(!this.isDeadOrDying()){var a=this.workspace.getGrid(); +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); +$.A().focusNode(this.getEditorFocusableNode())}};var cm={appendDomToWorkspace:function(a,b){if(!b.getBlocksBoundingBox)return $.cg(a,b);var c=b.getBlocksBoundingBox();a=$.cg(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;hf&&(f=m.x)}d=d-g+10;c=b.RTL?c-f:c-e;for(e=0;e"&&(b+=" ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1");return a.replace(/^\n/,"")};cm.domToText=$f;cm.domToVariables=bg;cm.domToWorkspace=$.cg;cm.loadWorkspaceComment=ag;cm.saveWorkspaceComment=Tf;cm.variablesToDom=Uf; +cm.workspaceToDom=function(a,b=!1){var c=$.mc("xml"),d=Uf($.ng(a));d.hasChildNodes()&&c.appendChild(d);for(let e of a.getTopComments())c.appendChild(Tf(e,b));a=a.getTopBlocks(!0);for(d=0;d"));p(new dm(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())? +$f(a):"":""}};n(l.EVENT,q.BLOCK_CHANGE,dm);var em=class extends Dl{constructor(a){super(a);this.type=q.BLOCK_CREATE;a&&(a.isShadow()&&(this.recordUndo=!1),this.ids=Ma(a),this.json=Ng(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); +return a}static fromJson(a,b,c){b=Dl.fromJson(a,b,c!=null?c:new em);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(!kg(b,this.ids))if(a)Og(this.json,b);else for(a=0;ab.getName()))}},ln={CATEGORY_NAME:"VARIABLE",TEST_ONLY:ug,VAR_LETTER_OPTIONS:"ijkmnopqrstuvwxyzabcdefgh"};ln.allDeveloperVariables=$.og;ln.allUsedVarModels=$.ng;ln.compareByName=tg;ln.createVariableButtonHandler=pg;ln.deleteVariable=$.Lg;ln.flyoutCategory=rg; +ln.flyoutCategoryBlocks=function(a){a=a.getVariableMap().getVariablesOfType("");var b=[];if(a.length>0){var c=a[a.length-1];if(Qb.variables_set){var d=$.mc("block");d.setAttribute("type","variables_set");d.setAttribute("gap",Qb.math_change?"8":"24");d.appendChild(Gg(c));b.push(d)}Qb.math_change&&(d=$.mc("block"),d.setAttribute("type","math_change"),d.setAttribute("gap",Qb.variables_get?"20":"8"),d.appendChild(Gg(c)),c=$.pc('1'), +d.appendChild(c),b.push(d));if(Qb.variables_get){a.sort(tg);for(let e=0,f;f=a[e];e++)c=$.mc("block"),c.setAttribute("type","variables_get"),c.setAttribute("gap","8"),c.appendChild(Gg(f)),b.push(c)}}return b};ln.generateUniqueName=vg;ln.generateUniqueNameFromOptions=$.wg;ln.generateVariableFieldDom=Gg;ln.getAddedVariables=hg;ln.getOrCreateVariablePackage=$.Ig;ln.getVariable=$.Hg;ln.getVariableUsesById=Kg;ln.jsonFlyoutCategoryBlocks=qg;ln.nameUsedWithAnyType=yg;ln.nameUsedWithConflictingParam=Cg; +ln.promptName=xg;ln.renameVariable=$.Dg;var mn=class extends Error{},Rg=class extends mn{constructor(a){super("Expected to find a 'type' property, defining the block type");this.state=a}},Tg=class extends mn{constructor(a,b,c){super(`The block ${b.toDevString()} is missing a(n) ${a} +connection`);this.block=b;this.state=c}},Ug=class extends mn{constructor(a,b,c,d){super(`The block ${c.toDevString()} could not connect its +${b} to its parent, because: ${a}`);this.childBlock=c;this.childState=d}},Sg=class extends mn{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}},Vg=class extends mn{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.`); +this.block=b;this.state=c}},nn={};nn.BadConnectionCheck=Ug;nn.DeserializationError=mn;nn.MissingBlockType=Rg;nn.MissingConnection=Tg;nn.RealChildOfShadow=Sg;nn.UnregisteredIcon=Vg;var on=class{constructor(){this.priority=50}save(a){var b=[];for(let c of a.getTopBlocks(!1))(a=Ng(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)Og(c,b,{recordUndo:$.fc})}clear(a){for(let b of a.getTopBlocks(!1))b.dispose(!1)}};Nc("blocks",new on);var pn={};pn.BlockSerializer=on;pn.append=Og;pn.appendInternal=Mf;pn.save=Ng;var Yg={fromJsonInternal:function(a){var b=ua(l.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)}},qn={TEST_ONLY:Yg};qn.fromJson=$.Zg;qn.register=Xg;qn.unregister=function(a){ta(l.FIELD,a)};var th=class extends pf{constructor(a,b,c){super(pf.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!==pf.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(th,a)||(this.isOptionListDynamic()&& +this.getOptions(!1),this.setValue(a))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot();this.createTextElement_();this.imageElement=z(x.IMAGE,{},this.fieldGroup_);this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_();this.borderRect_&&v(this.borderRect_,"blocklyDropdownRect");this.fieldGroup_&&(v(this.fieldGroup_,"blocklyField"),v(this.fieldGroup_,"blocklyDropdownField"));this.recomputeAriaContext(); +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=z(x.TSPAN,{},this.textElement_);var a;this.arrow.appendChild(document.createTextNode(((a=this.getSourceBlock())==null?0:a.RTL)?th.ARROW_CHAR+ +" ":" "+th.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=z(x.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_);u(this.svgArrow,w.HIDDEN,!0);this.svgArrow.setAttributeNS("http://www.w3.org/1999/xlink", +"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(a){var b=this.getSourceBlock();if(!b)throw new ii;this.dropdownCreate();this.menu_&&(this.menu_.openingCoords=a&&typeof a.clientX==="number"?new D(a.clientX,a.clientY):null,Vd(),a=this.menu_.render(Od),v(a,"blocklyDropdownMenu"),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(b=b.getColour(),a=this.sourceBlock_.getColourTertiary(),Wd(b,a)),$d(this,this.dropdownDispose_.bind(this)),Od.style.height=`${this.menu_.getSize().height}px`, +this.menu_.focus(),this.selectedMenuItem&&this.menu_.setHighlighted(this.selectedMenuItem),this.applyColour(),u(this.getFocusableElement(),w.EXPANDED,!0))}dropdownCreate(){var a=this.getSourceBlock();if(!a)throw new ii;var b=new Gf;b.setRole(ab.LISTBOX);this.menu_=b;u(this.getFocusableElement(),w.CONTROLS,this.menu_.getId());var c=this.getOptions(!1);this.selectedMenuItem=null;for(let f=0;fb[1]===a)?a:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+a),null)}doValueUpdate_(a){super.doValueUpdate_(a); +a=this.getOptions(!0);for(let b=0,c;c=a[b];b++)c[1]===this.value_&&(this.selectedOption=c);this.isInitialized&&this.recomputeAriaContext()}applyColour(){var a=this.sourceBlock_;this.borderRect_&&(this.borderRect_.setAttribute("stroke",a.getColourTertiary()),this.menu_?this.borderRect_.setAttribute("fill",a.getColourTertiary()):this.borderRect_.setAttribute("fill","transparent"));a&&this.arrow&&(a.isShadow()?this.arrow.style.fill=a.getColourSecondary():this.arrow.style.fill=a.getColour())}render_(){this.getTextContent().nodeValue= +"";this.imageElement.style.display="none";var a=this.selectedOption&&this.selectedOption[0];$g(a)?this.renderSelectedImage(a):this.renderSelectedText();this.positionBorderRect_()}renderSelectedImage(a){var b=this.getSourceBlock();if(!b)throw new ii;this.imageElement.style.display="";this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.src);this.imageElement.setAttribute("height",String(a.height));this.imageElement.setAttribute("width",String(a.width));var c=Number(a.height); +a=Number(a.width);var d=!!this.borderRect_,e=Math.max(d?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,c+th.IMAGE_Y_PADDING);d=d?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;var f=this.svgArrow?this.positionSVGArrow(a+d,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):nb(this.arrow);this.size_=new Pc(a+f+d*2,e);var g=0;b.RTL?this.imageElement.setAttribute("x",`${d+f}`):(g=a+f,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${d}`)); +this.imageElement.setAttribute("y",String(e/2-c/2));this.positionTextElement_(g+d,a+f)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var a=this.getTextElement();v(a,"blocklyDropdownText");a.setAttribute("text-anchor","start");var b=!!this.borderRect_;a=Math.max(b?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);var c=nb(this.getTextElement());b=b?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;var d=0;this.svgArrow&&(d= +this.positionSVGArrow(c+b,a/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2));this.size_=new Pc(c+d+b*2,a);this.positionTextElement_(b,c)}positionSVGArrow(a,b){if(!this.svgArrow)return 0;var c=this.getSourceBlock();if(!c)throw new ii;var d=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,e=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,f=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;this.svgArrow.setAttribute("transform","translate("+(c.RTL?d:a+e)+","+b+")");return f+ +e}getText_(){if(!this.selectedOption)return null;var a=this.selectedOption[0];if($g(a))return a.alt;if(typeof HTMLElement!=="undefined"&&a instanceof HTMLElement){let b;return a.title||((b=a.ariaLabel)!=null?b:a.innerText)}if(typeof a==="string")return a;console.warn("Can't get text for existing dropdown option. If you're using HTMLElement dropdown options in node, ensure you're using jsdom-global or similar.");return null}static fromJson(a){if(!a.options)throw Error("options are required for the dropdown field. The options property must be assigned an array of [humanReadableValue, languageNeutralValue] tuples."); +return new this(a.options,void 0,a)}trimOptions(a){var b=!1,c=a.map(g=>{if(g===th.SEPARATOR)return b=!0,g;var [h,m,y]=g;if(typeof h==="string")return g=[ef(h),m],y&&g.push(ef(y)),g;b=!0;g=[$g(h)?Object.assign({},h,{alt:ef(h.alt)}):h,m];y&&g.push(ef(y));return g});if(b||a.length<2)return{options:c};var d=c.map(([g])=>g),e=qe(d);a=re(d,e);var f=se(d,e);if(!a&&!f||e<=a+f)return{options:c};e=a?d[0].substring(0,a-1):void 0;d=f?d[0].substr(1-f):void 0;return{options:this.applyTrim(c,a,f),prefix:e,suffix:d}}applyTrim(a, +b,c){return a.map(([d,e,f])=>{d=d.substring(b,d.length-c);return f!==void 0?[d,e,f]:[d,e]})}validateOptions(a){if(!Array.isArray(a))throw TypeError("FieldDropdown options must be an array.");if(!a.length)throw TypeError("FieldDropdown options must not be an empty array.");var b=!1;for(let c=0;c{this.abortMove()};this.moving=!1}canMove(a){return!a.workspace.isReadOnly()&&a.isMovable()}isMoving(){return this.moving}startMove(a,b){if(!this.canMove(a)||this.isMoving())return!1;this.moving=!0;var c=ya(l.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();this.updateTotalDelta();this.draggable.getFocusableElement().addEventListener("blur",this.blurListener);a=Object.values(B.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);B.registry.register({name:"commitMove",preconditionFn:()=>this.isMoving(),callback:()=>{this.finishMove();return!1},keyCodes:a,allowCollision:!0}, +!0);this.scrollCurrentElementIntoView();this.moveIndicator=new rn(this.draggable.workspace);this.repositionMoveIndicator();return!0}move(a,b){switch(a){case Zi.UP:this.totalDelta.y-=this.stepDistance;break;case Zi.DOWN:this.totalDelta.y+=this.stepDistance;break;case Zi.LEFT:this.totalDelta.x-=this.stepDistance;break;case Zi.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();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(){ac().then(()=>{var a,b=(a=this.draggable)== +null?void 0:a.getBoundingRectangle();this.draggable&&"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)!==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(){B.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=new D(0,0);this.moving=!1}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))}};Yi.mover=new Yi;var tn=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);n(l.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, +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 tn(a),d=b.base;if(d){if(typeof d==="string"){let e;d=(e=ua(l.THEME,d,void 0))!=null?e:void 0}d instanceof tn&&(vb(c,d),c.name=a)}vb(c.blockStyles,b.blockStyles);vb(c.categoryStyles,b.categoryStyles);vb(c.componentStyles,b.componentStyles);vb(c.fontStyle,b.fontStyle);b.startHats!==null&&(c.startHats=b.startHats);return c}};var un=new tn("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"}, +math_category:{colour:"230"},procedure_category:{colour:"290"},text_category:{colour:"160"},variable_category:{colour:"330"},variable_dynamic_category:{colour:"310"}});var I,vn=I||(I={});vn[vn.TOP=0]="TOP";vn[vn.BOTTOM=1]="BOTTOM";vn[vn.LEFT=2]="LEFT";vn[vn.RIGHT=3]="RIGHT";var wn={};wn.Position=I;wn.convertFlyoutDefToJsonArray=eh;wn.convertToolboxDefToJson=dh;wn.hasCategories=fh;wn.isCategoryCollapsible=gh;wn.parseToolboxTree=ah;var xn=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 y;b=dh((y=a.toolbox)!=null?y:null);c=fh(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}y=a.maxTrashcanContents;d?y===void 0&&(y=32):y=0;var F=!!a.rtl,J=a.horizontalLayout;J===void 0&&(J=!1);var V=a.toolboxPosition!=="end";V=J?V?I.TOP:I.BOTTOM: +V===F?I.RIGHT:I.LEFT;var ja=a.css;ja===void 0&&(ja=!0);var Xa="https://static.blockly.com/media/";a.media&&(Xa=a.media.endsWith("/")?a.media:a.media+"/");var db=a.oneBasedIndex;db=db===void 0?!0:db;var Vi=a.renderer||"thrasos",Xs=a.plugins||{},mk=a.modalInputs;mk===void 0&&(mk=!0);this.RTL=F;this.oneBasedIndex=db;this.collapse=e;this.comments=f;this.disable=g;this.readOnly=m;this.maxBlocks=a.maxBlocks||Infinity;var op;this.maxInstances=(op=a.maxInstances)!=null?op:null;this.modalInputs=mk;this.pathToMedia= +Xa;this.hasCategories=c;this.moveOptions=xn.parseMoveOptions(a,c);this.hasScrollbars=!!this.moveOptions.scrollbars;this.hasTrashcan=d;this.maxTrashcanContents=y;this.hasSounds=h;this.hasCss=ja;this.horizontalLayout=J;this.languageTree=b;this.gridOptions=xn.parseGridOptions(a);this.zoomOptions=xn.parseZoomOptions(a);this.toolboxPosition=V;this.theme=xn.parseThemeOptions(a);this.renderer=Vi;var pp;this.rendererOverrides=(pp=a.rendererOverrides)!=null?pp:null;var qp;this.parentWorkspace=(qp=a.parentWorkspace)!= +null?qp:null;this.plugins=Xs}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=== +"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= +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||un;return typeof a==="string"?ua(l.THEME,a,void 0):a instanceof tn?a:tn.defineTheme(a.name||"builtin"+Aa(),a)}};var yn=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, +100);this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}};var yi=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:yi.DEFAULT_SCROLLBAR_MARGIN;a="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical");d&&(a+=" "+ +d);this.outerSvg=z(x.SVG,{"class":a});d=z(x.G,{},this.outerSvg);this.svgBackground=z(x.RECT,{"class":"blocklyScrollbarBackground"},d);a=Math.floor((yi.scrollbarThickness-5)/2);this.svgHandle=z(x.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");gb(this.outerSvg,this.workspace.getParentSvg());this.setInitialThickness();b? +(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=yi.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(a)),this.outerSvg.setAttribute("height",String(a)),this.svgHandle.setAttribute("height", +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();la(this.onMouseDownBarWrapper_);la(this.onMouseDownHandleWrapper_);fb(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= +a;this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(a){return a=a<=0||isNaN(a)?0:Math.min(a,this.scrollbarLength-this.handleLength)}setHandlePosition(a){this.handlePosition=a;this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(a){this.scrollbarLength=a;this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength));this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(a, +b){this.position.x=a;this.position.y=b;hb(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(a){if(!a&&(a=this.workspace.getMetrics(),!a))return;this.oldHostMetrics&&yi.metricsAreEquivalent(a,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(a):this.resizeVertical(a),this.oldHostMetrics=a,this.updateMetrics())}requiresViewResize(a){return this.oldHostMetrics?this.oldHostMetrics.viewWidth!==a.viewWidth||this.oldHostMetrics.viewHeight!== +a.viewHeight||this.oldHostMetrics.absoluteLeft!==a.absoluteLeft||this.oldHostMetrics.absoluteTop!==a.absoluteTop:!0}resizeHorizontal(a){this.requiresViewResize(a)?this.resizeViewHorizontal(a):this.resizeContentHorizontal(a)}resizeViewHorizontal(a){var b=a.viewWidth-this.margin*2;this.pair&&(b-=yi.scrollbarThickness);this.setScrollbarLength(Math.max(0,b));b=a.absoluteLeft+this.margin;this.pair&&this.workspace.RTL&&(b+=yi.scrollbarThickness);this.setPosition(b,a.absoluteTop+a.viewHeight-yi.scrollbarThickness- +this.margin);this.resizeContentHorizontal(a)}resizeContentHorizontal(a){if(a.viewWidth>=a.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var b=this.scrollbarLength*a.viewWidth/a.scrollWidth;b=this.constrainHandleLength(b);this.setHandleLength(b);b=a.scrollWidth-a.viewWidth;var c=this.scrollbarLength-this.handleLength;a=(a.viewLeft-a.scrollLeft)/b*c;a=this.constrainHandlePosition(a);this.setHandlePosition(a); +this.ratio=c/b}}resizeVertical(a){this.requiresViewResize(a)?this.resizeViewVertical(a):this.resizeContentVertical(a)}resizeViewVertical(a){var b=a.viewHeight-this.margin*2;this.pair&&(b-=yi.scrollbarThickness);this.setScrollbarLength(Math.max(0,b));this.setPosition(this.workspace.RTL?a.absoluteLeft+this.margin:a.absoluteLeft+a.viewWidth-yi.scrollbarThickness-this.margin,a.absoluteTop+this.margin);this.resizeContentVertical(a)}resizeContentVertical(a){if(a.viewHeight>=a.scrollHeight)this.setHandleLength(this.scrollbarLength), +this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var b=this.scrollbarLength*a.viewHeight/a.scrollHeight;b=this.constrainHandleLength(b);this.setHandleLength(b);b=a.scrollHeight-a.viewHeight;var c=this.scrollbarLength-this.handleLength;a=(a.viewTop-a.scrollTop)/b*c;a=this.constrainHandlePosition(a);this.setHandlePosition(a);this.ratio=c/b}}isVisible(){return this.isHandleVisible}setContainerVisible(a){var b=a!==this.containerVisible;this.containerVisible= +a;b&&this.updateDisplay_()}setVisible(a){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(a)}setVisibleInternal(a){var b=a!==this.isVisible();this.isHandleVisible=a;b&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(a){this.workspace.markFocused();ha=null;this.cleanUp();if(oa(a))a.stopPropagation();else{var b= +pa(a,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());b=this.horizontal?b.x:b.y;var c=md(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();oa(a)?a.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse= +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_&& +(la(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null);this.onMouseMoveWrapper_&&(la(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= +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}};yi.scrollbarThickness=Hk?25:15;yi.DEFAULT_SCROLLBAR_MARGIN=.5;var zn,An=class{constructor(a,b,c,d,e){this.workspace=a;this.anchor=b;this.ownerRect=c;this.owner=e;this.size=new Pc(0,0);this.colour="#ffffff";this.disposed=!1;this.relativeLeft=this.relativeTop=0;this.dragStrategy=new yn(this,this.workspace);this.ariaLabelProvider=null;this.id=Aa();this.svgRoot=z(x.G,{"class":"blocklyBubble"},a.getBubbleCanvas());a=z(x.G,{"class":"blocklyEmboss"},this.svgRoot);this.tail=z(x.PATH,{"class":"blocklyBubbleTail"},a);this.background=z(x.RECT,{"class":"blocklyDraggable", +x:0,y:0,rx:zn.BORDER_WIDTH,ry:zn.BORDER_WIDTH},a);this.contentContainer=z(x.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(){fb(this.svgRoot);this.disposed=!0}setAnchorLocation(a,b=!1){this.anchor=a;b?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor();this.renderTail()}setPositionRelativeToAnchor(a, +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,zn.MIN_SIZE);a.height=Math.max(a.height,zn.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", +a);this.background.setAttribute("fill",a)}onMouseDown(a){var b;(b=this.workspace.getGesture(a))==null||b.handleBubbleStart(a,this);$.A().focusNode(this)}onKeyDown(a){a.key==="Escape"&&this.owner&&(this.owner.setBubbleVisible(!1),$.A().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, +b){var c=this.getRelativeToSurfaceXY();this.moveTo(c.x+a,c.y+b)}positionByRect(a=new Zc(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.width)return b;a=this.getWorkspaceViewRect(a);if(this.workspace.RTL){var c=this.anchor.x-b;c-this.size.widtha.right&&(b=-(a.right-this.anchor.x))}else{c=b+this.anchor.x;let d=c+this.size.width;ca.right&&(b=a.right-this.anchor.x-this.size.width)}return b}getOptimalRelativeTop(a){var b= +-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);ca.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 Zc(b,c,d,a)}getScrollbarThickness(){return yi.scrollbarThickness/this.workspace.scale}renderTail(){var a= +[],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 F=Math.cos(h),J=(this.size.width+this.size.height)/zn.TAIL_THICKNESS;J=Math.min(J,this.size.width,this.size.height)/4;h=1-zn.ANCHOR_RADIUS/f;d=b+h*d;e=c+h*e;h=b+J*F;let V=c+J*m;b-=J*F;c-=J*m;m=Ld(this.workspace.RTL? +-zn.TAIL_ANGLE:zn.TAIL_ANGLE);m=g+m;m>Math.PI*2&&(m-=Math.PI*2);g=Math.sin(m)*f/zn.TAIL_BEND;f=Math.cos(m)*f/zn.TAIL_BEND;a.push("M"+h+","+V);a.push("C"+(h+f)+","+(V+g)+" "+d+","+e+" "+d+","+e);a.push("C"+d+","+e+" "+(b+f)+","+(c+g)+" "+b+","+c)}a.push("z");var y;(y=this.tail)==null||y.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? +-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 Zc(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(){Gb(this)}unselect(){Gb(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(); +this.bringToFront();var a=this.getRelativeToSurfaceXY(),b=this.getSize();a=new Zc(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){Oa(a,ab.GROUP);var b,c=(b=this.getAriaLabel())==null?void 0:b.trim();u(a,w.LABEL,c?c:$.C.BUBBLE_LABEL_DEFAULT)}}setAriaLabelProvider(a){this.ariaLabelProvider=a;this.recomputeAriaContext()}getAriaLabel(){if(this.ariaLabelProvider){if(typeof this.ariaLabelProvider=== +"string")return this.ariaLabelProvider;if(typeof this.ariaLabelProvider==="function")return this.ariaLabelProvider(this)}return null}};zn=An;An.BORDER_WIDTH=6;An.DOUBLE_BORDER=zn.BORDER_WIDTH*2;An.MIN_SIZE=zn.DOUBLE_BORDER;An.TAIL_THICKNESS=1;An.TAIL_ANGLE=20;An.TAIL_BEND=4;An.ANCHOR_RADIUS=8;var Bn=class extends An{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 xn(a);this.validateWorkspaceOptions(b);this.svgDialog=z(x.SVG,{x:An.BORDER_WIDTH,y:An.BORDER_WIDTH},this.contentContainer);a.parentWorkspace=this.workspace;this.miniWorkspace=this.newWorkspaceSvg(new xn(a));this.miniWorkspace.internalIsMutator=!0;a=this.miniWorkspace.createDom("blocklyMutatorBackground");this.svgDialog.appendChild(a);b.languageTree&& +(a.insertBefore(this.miniWorkspace.addFlyout(x.G),this.miniWorkspace.getCanvas()),a=this.miniWorkspace.getFlyout(),a==null||a.init(this.miniWorkspace),a==null||a.show(b.languageTree));v(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"); +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 allow scrolling/moving the workspace");if(a.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts");}onWorkspaceChange(){this.bumpBlocksIntoBounds(); +this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging()||Yi.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()||Yi.mover.isMoving()){this.autoLayout&&(this.autoLayout=!Yi.mover.isMoving());var a=this.getSize(),b= +this.calculateWorkspaceSize();Math.abs(a.width-b.width){if(Mc(this)&&this.bubbleIsVisible()){let a=this.getBubble();a&&$.A().focusNode(a)}})}getSourceBlock(){return this.sourceBlock}showContextMenu(a){this.getSourceBlock().showContextMenu(a)}recomputeAriaContext(){var a= +this.getFocusableElement();if(a){var b,c=(b=this.sourceBlock.workspace.targetWorkspace)==null?void 0:b.getFlyout();if(c&&!this.isClickableInFlyout(c.autoClose))u(a,w.HIDDEN,!0);else{Pa(a,w.HIDDEN);Oa(a,ab.BUTTON);var d;b=(d=this.getAriaLabel())!=null?d:$.C.ICON_LABEL_DEFAULT;u(a,w.LABEL,b)}}}getAriaLabel(){return null}};$.mh=class extends Cn{constructor(a,b){super(b);this.flyoutBlockTypes=a;this.sourceBlock=b;this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return $.mh.TYPE}initView(a){this.svgRoot||(super.initView(a),z(x.RECT,{"class":"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),z(x.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"}, +this.svgRoot),z(x.CIRCLE,{"class":"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),v(this.svgRoot,"blocklyMutatorIcon"))}dispose(){super.dispose();var a;(a=this.miniWorkspaceBubble)==null||a.dispose()}getWeight(){return $.mh.WEIGHT}getSize(){return new Pc(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()&& +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 ac();if(a){b.miniWorkspaceBubble= +new Bn(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); +b.saveConnectionsListener=null}p(new (t(q.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=> +({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 Zc(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); +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=> +{$.mh.isIgnorableMutatorEvent(a)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null;this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(a){return a.isUiEvent||a.type===q.BLOCK_CREATE||a.type===q.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=$.ec;a||$.r(!0);var b=dm.getExtraBlockState_(this.sourceBlock); +this.sourceBlock.compose(this.rootBlock);var c=dm.getExtraBlockState_(this.sourceBlock);b!==c&&p(new (t(q.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,b,c));$.r(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}};$.mh.TYPE=Yf.MUTATOR;$.mh.WEIGHT=1;var hh=Object.create(null),Dn={allExtensions:hh};$.ih("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 En={TEST_ONLY:Dn};En.apply=qh;En.buildTooltipForDropdown=$.sh;En.buildTooltipWithFieldText=$.uh;En.isRegistered=$.oh;En.register=$.ih;En.registerMixin=$.jh;En.registerMutator=$.nh; +En.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)}};En.unregister=function(a){$.oh(a)?delete hh[a]:console.warn('No extension mapping for name "'+a+'" found to unregister')};var vh=void 0,Fn={};Fn.shouldReduceMotion=wh;var Gn={};Gn.removeElem=xh;var Hn={};Hn.arc=Dh;Hn.curve=yh;Hn.line=Ch;Hn.lineOnAxis=H;Hn.lineTo=Bh;Hn.moveBy=Ah;Hn.moveTo=zh;Hn.point=G;var In={};In.Coordinate=D;In.KeyCodes=L;In.Rect=Zc;In.Size=Pc;In.Svg=x;In.accessibility=Fn;In.aria=fl;In.array=Gn;In.browserEvents=Xk;In.colour=Ql;In.deprecation=nl;In.dom=hl;In.extensions=En;In.idGenerator=al;In.math=Ml;In.object=kl;In.parsing=Rl;In.string=Ol;In.style=Jl;In.svgMath=Kl;In.svgPaths=Hn;In.toolbox=wn;In.userAgent=Wk;In.xml=vl;var Jn=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_${Aa()}`}connect_(a){var b=E.INPUT_VALUE,c=this.getSourceBlock(),d=a.getSourceBlock();a.isConnected()&&a.disconnectInternal(!1);if(this.isConnected()){let g= +this.stashShadowState(),h=this.targetBlock();if(h.isShadow())h.dispose(!1);else{this.disconnectInternal();var e=h}this.applyShadowState(g)}if(La()){var f=new (t(q.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(),p(f));if(e&&(a=this.type===b?e.outputConnection:e.previousConnection))if(d=Jn.getConnectionForOrphanedConnection(d,a))a.connect(d);else a.onFailedConnect(this)}dispose(){if(this.isConnected()){this.isSuperior()&& +this.setShadowStateInternal();let a=this.targetBlock();a&&!a.isDeadOrDying()&&a.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===E.INPUT_VALUE||this.type===E.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=$.ec;b||$.r(!0);this.isSuperior()? +this.connect_(a):a.connect_(this);$.r(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=$.ec;d||$.r(!0);if(La()){var e=new (t(q.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(), +p(e));c.getSourceBlock().isShadow()||b.respawnShadow_();$.r(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()&& +b.disconnect(),b.connect(this),!0)}targetBlock(){if(this.isConnected()){let a,b;return(b=(a=this.targetConnection)==null?void 0:a.getSourceBlock())!=null?b:null}return null}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(a){a?(Array.isArray(a)||(a=[a]),this.check=a,this.onCheckChanged_()):this.check=null;return this}getCheck(){return this.check}setShadowDom(a){this.setShadowStateInternal({shadowDom:a})}getShadowDom(a){return a&& +this.targetBlock().isShadow()?Vf(this.targetBlock()):this.shadowDom}setShadowState(a){this.setShadowStateInternal({shadowState:a})}getShadowState(a){return a&&this.targetBlock()&&this.targetBlock().isShadow()?Ng(this.targetBlock()):this.shadowState}neighbours(){return[]}getParentInput(){var a=null,b=this.sourceBlock_.inputList;for(let c=0;c{var b=a.parentElement;if(b)for(;a.nextSibling;)b.insertBefore(a.nextSibling,a)}),this.recomputeAriaContext(a))}unhighlight(){this.highlighted=!1;var a=this.findHighlightSvg();a&&cb(a,"blocklyHighlightedConnectionPathVisible")}isHighlighted(){return this.highlighted}setTracking(a){a&&this.trackedState===wj.TrackedState.TRACKED||!a&&this.trackedState===wj.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(a?(this.db.addConnection(this,this.y),this.trackedState=wj.TrackedState.TRACKED): +(this.trackedState===wj.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=wj.TrackedState.UNTRACKED))}stopTrackingAll(){this.setTracking(!1);if(this.targetConnection){let a=this.targetBlock().getDescendants(!1);for(let b=0;bthis.fieldRow.length)throw Error("index "+a+" out of bounds.");if(!(b||b===""&&c))return a;typeof b==="string"&&(b=$.Zg({type:"field_label",text:b}));b.setSourceBlock(this.sourceBlock); +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 "'+ +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 wj){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."); +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? +typeof this.ariaLabelProvider==="string"?ef(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(); +var b=a.indexOf(this),c,d=((c=a[b-1].connection)==null?void 0:c.type)===E.NEXT_STATEMENT,e;return((e=this.connection)==null?void 0:e.type)===E.NEXT_STATEMENT||d?`${this.getSourceBlock().id}-input${b}`:a[b-1].getRowId()}getLabel(a=td.STANDARD,b=!0){if(!this.isVisible())return"";var c=Ad(this,!1,a),d;b&&((d=this.connection)==null?void 0:d.type)===E.INPUT_VALUE&&(b=this.connection.targetBlock())&&!b.isInsertionMarker()&&c.push(wd(b,a).join(", "));return c.join(", ")}getIndex(){var a=[$.Bd.DUMMY,$.Bd.END_ROW]; +return this.getSourceBlock().inputList.filter(b=>!a.includes(b.type)).indexOf(this)}};var Sn=class extends Rn{constructor(a,b){super(a,b);this.name=a;this.type=$.Bd.DUMMY}};var Tn=class extends Rn{constructor(a,b){super(a,b);this.name=a;this.type=$.Bd.END_ROW}};var Un=class extends Rn{constructor(a,b){if(!a)throw Error("Statement inputs must have a non-empty name");super(a,b);this.name=a;this.type=$.Bd.STATEMENT;this.connection=this.makeConnection(E.NEXT_STATEMENT)}};$.Vn=class extends Rn{constructor(a,b){if(!a)throw Error("Value inputs must have a non-empty name");super(a,b);this.name=a;this.type=$.Bd.VALUE;this.connection=this.makeConnection(E.INPUT_VALUE)}};var Wn=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= +this.disposing=!1;this.onchangeWrapper=this.helpUrl=null;this.statementInputCount=0;this.workspace=a;this.id=c&&!a.getBlockById(c)?c:Ca();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=Qb[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===Wn&&this.doInit_()}doInit_(){var a=$.ec;a||$.r(!0);var b= +$.fc;try{typeof this.init==="function"&&($.fc=!1,this.init(),$.fc=b),La()&&p(new (t(q.BLOCK_CREATE))(this))}finally{$.r(a),$.fc=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);La()&&p(new (t(q.BLOCK_DELETE))(this));this.workspace.removeTopBlock(this);this.disposeInternal()}disposeInternal(){this.disposing= +!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(); +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= +null;for(let b=0;b1)return!1;return!0}getMatchingConnection(a,b){var c=this.getConnections_(!0);a=a.getConnections_(!0);if(c.length!==a.length)throw Error("Connection lists did not match in length.");for(let d=0;d{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()); +(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 $.Vn(a,this))}appendStatementInput(a){this.statementInputCount++;return this.appendInput(new Un(a,this))}appendDummyInput(a=""){return this.appendInput(new Sn(a,this))}appendEndRowInput(a=""){return this.appendInput(new Tn(a,this))}appendInput(a){this.inputList.push(a);return a}appendInputFromRegistry(a,b){return(a=ua(l.INPUT, +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, +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&&($.Ka++,this.setInputsInline(a.inputsInline),$.Ka--);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); +a.tooltip!==void 0&&(c=ef(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=ef(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 '"+ +a.type+"' block."),a.extensions=[a.extensions]);a.mutator!==void 0&&qh(a.mutator,this,!0);a=a.extensions;if(Array.isArray(a))for(b=0;bb)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=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);ab.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 Yf?this.icons.find(b=>b.getType().equals(a)):this.icons.find(b=>b.getType().toString()=== +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 (t(q.BLOCK_MOVE))(this);c&&d.setReason(c);this.xy.translate(a,b);d.recordNew();p(d)}makeConnection_(a){return new Jn(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= +this.getNextBlock())?b.allInputsFilled(a):!0}toDevString(){var a=this.type?'"'+this.type+'" block':"Block";this.id&&(a+=' (id="'+this.id+'")');return a}};Wn.COLLAPSED_INPUT_NAME="_TEMP_COLLAPSED_INPUT";Wn.COLLAPSED_FIELD_NAME="_TEMP_COLLAPSED_FIELD";var Nh=null,Kh=null,Xn={};Xn.connectionUiEffect=Ih;Xn.disconnectUiEffect=Mh;Xn.disconnectUiStop=Jh;Xn.disposeUiEffect=Hh;var Yn=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);$.Ka++;try{var d=Mf(a.blockState,b);Qh(d,c)}finally{$.Ka--}if(!d)return d;La()&&!d.isShadow()&&p(new (t(q.BLOCK_CREATE))(d));var e=d;ac().then(()=>{d.isDeadOrDying()||$.A().focusNode(e)});return d}};Yn.TYPE="block";Rc(Yn.TYPE,new Yn);var Zn={};Zn.bumpIntoBounds=Rh;Zn.bumpIntoBoundsHandler=Uh;Zn.bumpTopObjectsIntoBounds=Th;var $n=class extends An{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();v(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(a){this.text=a;fb(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&& +this.rightAlignTextFragments(b.getBBox().width,a);return b}createParagraph(a){return z(x.G,{"class":"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${An.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},a)}createTextFragments(a,b){var c=1;return b.split("\n").map(d=>{var e=z(x.TEXT,{y:`${c}em`,x:An.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", +"start"),c.setAttribute("x",`${a+An.BORDER_WIDTH}`)}updateBubbleSize(){var a=this.paragraph.getBBox();this.setSize(new Pc(a.width+An.BORDER_WIDTH*2,a.height+An.BORDER_WIDTH*2),!0)}};var ao=class extends An{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 Pc(160+An.DOUBLE_BORDER,80+An.DOUBLE_BORDER);this.MIN_SIZE=new Pc(45+An.DOUBLE_BORDER,20+An.DOUBLE_BORDER);this.editable=!0;this.textChangeListener=()=>{this.recomputeAriaContext()};v(this.svgRoot,"blocklyTextInputBubble");this.editor= +new $l(a,this.id,()=>{$.A().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, +b){a=z(x.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-An.DOUBLE_BORDER,d=a.height-An.DOUBLE_BORDER;this.editor.updateSize(new Pc(c,d),new Pc(0,0));this.editor.getDom().setAttribute("x",`${An.DOUBLE_BORDER/2}`);this.editor.getDom().setAttribute("y",`${An.DOUBLE_BORDER/2}`); +this.resizeGroup.setAttribute("y",`${d}`);this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-An.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 Zc(0,0,0,0)){super.positionByRect(a);this.onLocationChange()}onResizePointerDown(a){this.bringToFront(); +oa(a)||(Rf(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&&(la(this.resizePointerUpListener),this.resizePointerUpListener=null);this.resizePointerMoveListener&&(la(this.resizePointerMoveListener), +this.resizePointerMoveListener=null)}onResizePointerMove(a){a=Sf(this.workspace,a);this.setSize(new Pc(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(){$.A().focusNode(this.getEditor())}dispose(){super.dispose();this.editor.removeTextChangeListener(this.textChangeListener)}};wc("\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 bo=class{constructor(a){this.name=a}toString(){return this.name}};bo.POSITIONABLE=new bo("positionable");bo.DRAG_TARGET=new bo("drag_target");bo.DELETE_AREA=new bo("delete_area");bo.AUTOHIDEABLE=new bo("autohideable");bo.FOCUSABLE=new bo("focusable"); +var co=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{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=> +{c.push(this.componentData.get(d).component)});return c}};co.Capability=bo;var eo=co||(co={}),fo=eo.ComponentWeight||(eo.ComponentWeight={});fo[fo.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT";fo[fo.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT";fo[fo.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT";fo[fo.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT";var go=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;da)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, +b){function c(y){var F=e-d[y].x,J=f-d[y].y;Math.sqrt(F*F+J*J)<=b&&m.push(d[y]);return J=0&&c(a);)a--;do g++;while(g=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(;fa.y-b.y)}static init(a){var b=[];b[E.INPUT_VALUE]=new go(a);b[E.OUTPUT_VALUE]=new go(a);b[E.NEXT_STATEMENT]=new go(a);b[E.PREVIOUS_STATEMENT]=new go(a);return b}};var ho=class{constructor(){}onDragEnter(){}onDragOver(){}onDragExit(){}onDrop(){}getClientRect(){return null}shouldPreventMove(){return!1}};var io=class extends ho{constructor(){super();this.wouldDelete_=!1}wouldDelete(a){Yi.mover.isMoving()?this.updateWouldDelete_(!1):a instanceof Oi?(a=!a.getParent()&&a.isDeletable(),this.updateWouldDelete_(a)):this.updateWouldDelete_(Vh(a)&&a.isDeletable());return this.wouldDelete_}updateWouldDelete_(a){this.wouldDelete_=a}};var jo=class{constructor(a,b){this.element=a;this.type=b}getElement(){return this.element}getType(){return this.type}};var ko=class{constructor(a){this.workspace_=a}getDimensionsPx_(a){var b=0,c=0;a&&(b=a.getWidth(),c=a.getHeight());return new Pc(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= +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===I.TOP;f===I.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? +0:f.autoClose);f=e?c.position:d.position;var h=f===I.LEFT||f===I.RIGHT;if(f===I.TOP||f===I.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()|| +!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), +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= +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, +toolboxHeight:a.height,toolboxPosition:a.position,flyoutWidth:b.width,flyoutHeight:b.height}}};n(l.METRICS_MANAGER,"default",ko);var lo=class extends ko{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;var c=b.x,d=b.y,e=b.x+b.width;b=b.y+b.height;for(let f of this.flyout_.getContents()){let g=f.getElement().getBoundingRectangle();c=Math.min(c,g.left);d=Math.min(d,g.top);e=Math.max(e,g.right);b=Math.max(b,g.bottom)}return{height:(b-d)*a,width:(e- +c)*a,top:d*a,left:c*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,top:0,left:0}}};var mo=class{constructor(a,b){this.gap=a;this.axis=b;this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case "x":return new Zc(this.y,this.y,this.x,this.x+this.gap);case "y":return new Zc(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 nj=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=Aa();this.svgGroup=z(x.G,{id:this.id,"class":a},this.workspace.getCanvas());if(!this.isFlyoutLabel){var e= +z(x.RECT,{"class":"blocklyFlyoutButtonShadow",rx:nj.BORDER_RADIUS,ry:nj.BORDER_RADIUS,x:1,y:1},this.svgGroup);Oa(e,ab.NONE)}a=z(x.RECT,{"class":this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:nj.BORDER_RADIUS,ry:nj.BORDER_RADIUS},this.svgGroup);Oa(a,ab.NONE);b=z(x.TEXT,{"class":this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup);c=ef(this.text);this.workspace.RTL&&(c+="\u200f");b.textContent=c;this.isFlyoutLabel&& +(this.svgText=b,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill"));Oa(b,ab.NONE);d=`${c}, ${this.isFlyoutLabel?$.C.ARIA_LABEL_HEADING:$.C.ARIA_LABEL_BUTTON}`;u(this.getFocusableElement(),w.LABEL,d);Oa(this.getFocusableElement(),ab.OPTION);d=Wc(b,"fontSize");var f=Wc(b,"fontWeight"),g=Wc(b,"fontFamily");this.width=pb(b,d,f,g);c=rb(c,d,f,g);this.height=this.height||c.height;if(!this.isFlyoutLabel){this.width+=2*nj.TEXT_MARGIN_X;this.height+=2*nj.TEXT_MARGIN_Y; +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(); +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 Zc(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(){la(this.onMouseDownWrapper); +la(this.onMouseUpWrapper);this.svgGroup&&fb(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)? +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 Zc(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= +this.targetWorkspace;let b=$.C.KEYBOARD_NAV_FLYOUT_LABEL_HINT.replace("%1",gd(K.NEXT_HEADING));Ri.show(a,{message:b,id:"flyoutLabelHint"})}else(a=this.targetWorkspace.getButtonCallback(this.callbackKey))&&a(this)}};nj.TEXT_MARGIN_X=5;nj.TEXT_MARGIN_Y=2;nj.BORDER_RADIUS=4;wc("\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 no=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 nj}};var oo=class{getFirstChild(){return null}getParent(){return null}getNextSibling(){return null}getPreviousSibling(){return null}getRowId(){return"error"}isNavigable(){return!1}isApplicable(a){return a instanceof mo}};var po=class{getFirstChild(a){return Wh(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),Xh(b,a,1)):null}getPreviousSibling(a){var b; +if((b=a.previousConnection)==null?0:b.targetBlock())return a.previousConnection;var c;return((c=a.outputConnection)==null?0:c.targetBlock())?Xh(a.outputConnection.targetBlock(),a,-1):null}getRowId(a){return a.getRowId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof Oi}};var qo=class{getFirstChild(){return null}getParent(a){var b;return(b=a.getOwner())!=null?b:null}getNextSibling(a){var b;return Xh((b=a.getOwner())==null?void 0:b.getSourceBlock(),a,1)}getPreviousSibling(a){var b;return Xh((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 An}};var ro=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+10?b[a-1]:null}getRowId(a){return a.getCommentView().commentId}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof Yl}};var so=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 $l}};var to=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){if(a.getParentInput())return Xh(a.getSourceBlock(),a,1);if(a.type===E.NEXT_STATEMENT&&a.getSourceBlock().getSurroundParent()&&!a.targetConnection)return Xh(a.getSourceBlock().getSurroundParent(),a,1);switch(a.type){case E.NEXT_STATEMENT:return a.targetConnection;case E.PREVIOUS_STATEMENT:case E.OUTPUT_VALUE:return a.getSourceBlock()}return null}getPreviousSibling(a){if(a.getParentInput())return Xh(a.getParentInput().getSourceBlock(), +a,-1);switch(a.type){case E.NEXT_STATEMENT:return a.getSourceBlock();case E.PREVIOUS_STATEMENT:case E.OUTPUT_VALUE:return a.targetConnection}return null}getRowId(a){switch(a.type){case E.NEXT_STATEMENT:case E.PREVIOUS_STATEMENT:return a.id;case E.INPUT_VALUE:return a.getParentInput().getRowId();default:return a.getSourceBlock().getRowId()}}isNavigable(a){if(!a.canBeFocused())return!1;if(a.type===E.NEXT_STATEMENT){if(a.targetBlock())return!1;let b,c=(b=a.getSourceBlock().getRootBlock())!=null?b:a.getSourceBlock(); +return a!==c.lastConnectionInStack(!1)}return a.type===E.INPUT_VALUE&&!a.targetBlock()}isApplicable(a){return a instanceof wj}};var uo=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){return Xh(a.getSourceBlock(),a,1)}getPreviousSibling(a){return Xh(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 pf}};var vo=class{getFirstChild(){return null}getParent(a){return a.getSourceBlock()}getNextSibling(a){return Xh(a.getSourceBlock(),a,1)}getPreviousSibling(a){return Xh(a.getSourceBlock(),a,-1)}getRowId(a){return a.getSourceBlock().getRowId()}isNavigable(a){return a.canBeFocused()}isApplicable(a){return a instanceof Cn}};var wo=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 dg}};var xo=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 Gi}};var yo,zo=yo||(yo={});zo[zo.NEXT=0]="NEXT";zo[zo.PREVIOUS=1]="PREVIOUS";zo[zo.IN=2]="IN";zo[zo.OUT=3]="OUT"; +var Ao,Bo=class{constructor(){this.rules=[new po,new uo,new to,new xo,new vo,new wo,new ro,new qo,new so];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, +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=$.A().getFocusedNode()){if(!a)return null;var b=this.getPreviousNodeImpl(a,a,yo.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= +$.A().getFocusedNode()){return this.getPreviousNodeImpl(a,a,yo.OUT)}getNextNode(a=$.A().getFocusedNode()){var b=this.getNextNodeImpl(a,a,yo.NEXT);return a&&b===null?this.navigateStacks(a,1):b}getInNode(a=$.A().getFocusedNode()){return this.getNextNodeImpl(a,a,yo.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)): +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}getNavigableItems(a= +(Ao=$.A().getFocusedTree())==null?void 0:Ao.getRootFocusableNode()){return a?this.getTopLevelItems(a).filter(b=>this.isNavigable(b)):[]}getFirstNode(){var a,b=(a=$.A().getFocusedTree())==null?void 0:a.getRootFocusableNode();return b?this.getTopLevelItems(b)[0]:null}getLastNode(){var a,b=(a=$.A().getFocusedTree())==null?void 0:a.getRootFocusableNode();return b?this.getTopLevelItems(b).slice(-1)[0]:null}transitionAllowed(a,b,c){switch(c){case yo.IN:case yo.OUT:return this.getRowId(a)===this.getRowId(b); +case yo.NEXT:case yo.PREVIOUS:return this.getRowId(a)!==this.getRowId(b)}}getLeftmostSibling(a){if(!a)return null;for(var b;b=this.getPreviousNodeImpl(a,a,yo.OUT);)a=b;return a}getLastNodeInStack(a,b){for(var c;(c=this.getNextNodeImpl(a,a,yo.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.getNavigableItems(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&&this.getNavigationLoops()&&(b=c[0]);return b}getTopLevelItems(a){return a.getFocusableTree().getTopBoundedElements(!0)}isNavigable(a){var b;return(b=this.get(a))==null?void 0:b.isNavigable(a)}getSourceBlockFromNode(a){return a instanceof Oi?a:a instanceof pf||a instanceof wj||a instanceof Cn?a.getSourceBlock():a instanceof $l?(a=a.getParent(),a instanceof Oi?a:null):null}};var Co=class{getFirstChild(a){return Yh(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())&&Yh(a)?a.isExpanded()&& +this.allParentsExpanded(a):!0}isApplicable(a){return rd(a)}};var Do=class extends Bo{constructor(a){super();this.toolbox=a;this.rules=[new Co]}getInNode(a=$.A().getFocusedNode(),b=!1){var c=Zh(this.toolbox.getWorkspace());if(!b)switch(c){case I.TOP:case I.BOTTOM:return this.getNextNode(a,!0);case I.RIGHT:return this.getOutNode(a,!0)}if(!sd(a)||sd(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!==I.TOP&&c!==I.BOTTOM?a.getFirstNode():a.getLastNode(): +null}getOutNode(a,b=!1){if(!b)switch(Zh(this.toolbox.getWorkspace())){case I.TOP:case I.BOTTOM:return this.getPreviousNode(a,!0);case I.RIGHT:return this.getInNode(a,!0)}return super.getOutNode(a)}getNextNode(a,b=!1){if(!b)switch(Zh(this.toolbox.getWorkspace())){case I.TOP:return this.getInNode(a,!0);case I.BOTTOM:return this.getOutNode(a,!0)}return super.getNextNode(a)}getPreviousNode(a,b=!1){if(!b)switch(Zh(this.toolbox.getWorkspace())){case I.TOP:return this.getOutNode(a,!0);case I.BOTTOM:return this.getInNode(a, +!0)}return super.getPreviousNode(a)}getTopLevelItems(){return this.toolbox.getToolboxItems()}};var Eo=class extends Bo{constructor(a){super();this.flyout=a;this.rules.push(new no,new oo)}getOutNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(Zh(this.flyout.targetWorkspace)){case I.TOP:case I.BOTTOM:return this.flyout.RTL?this.getNextNode(a,!0):this.getPreviousNode(a,!0);case I.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(Zh(this.flyout.targetWorkspace)){case I.TOP:case I.BOTTOM:return this.flyout.RTL? +this.getPreviousNode(a,!0):this.getNextNode(a,!0);case I.RIGHT:return this.getOutNode(a,!0)}return super.getInNode(a)}getNextNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(Zh(this.flyout.targetWorkspace)){case I.TOP:return null;case I.BOTTOM:return this.getOutNode(a,!0)}return super.getNextNode(a)}getPreviousNode(a,b=!1){if(!b&&this.flyout.targetWorkspace)switch(Zh(this.flyout.targetWorkspace)){case I.TOP:return this.getOutNode(a,!0);case I.BOTTOM:return null}return super.getPreviousNode(a)}getTopLevelItems(){return this.flyout.getContents().map(a=> +a.getElement()).filter(a=>this.isNavigable(a))}isNavigable(a){return super.isNavigable(a)&&this.flyout.getContents().map(b=>b.getElement()).includes(a)}};var Ak=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 yi(a,!0,f,d,e));c&&(this.vScroll=new yi(a,!1,f,d,e));f&&(this.corner_=z(x.RECT,{height:yi.scrollbarThickness,width:yi.scrollbarThickness,"class":"blocklyScrollbarBackground"}),gb(this.corner_,a.getBubbleCanvas()))}dispose(){fb(this.corner_);this.oldHostMetrics=this.corner_=null;this.hScroll&&(this.hScroll.dispose(), +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|| +(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{$.Ka++,this.hScroll&&b&&this.hScroll.resize(a),this.vScroll&&c&&this.vScroll.resize(a)}finally{$.Ka--}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==a.viewWidth||this.oldHostMetrics.absoluteLeft!==a.absoluteLeft){let d;(d= +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&& +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()); +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 Fo=class{load(a,b){a=new mo(0,b.horizontalLayout?"x":"y");return new jo(a,"sep")}gapForItem(a,b){a=parseInt(String(a.gap));return!isNaN(a)&&a>=0?a:b}disposeItem(){}getType(){return"sep"}};n(l.FLYOUT_INFLATER,"sep",Fo);var Go=class extends io{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 Gi(a);this.workspace_.setMetricsManager(new lo(this.workspace_,this));this.workspace_.internalIsFlyout= +!0;this.workspace_.setVisible(this.visible);this.workspace_.setNavigator(new Eo(this));this.id=Ca();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_=z(a,{"class":"blocklyFlyout"});this.svgGroup_.style.display="none";this.svgBackground_=z(x.PATH,{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom()); +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"&&($.A().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(); +this.workspace_.scrollbar=new Ak(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(); +a.getComponentManager().addComponent({component:this,weight:co.ComponentWeight.FLYOUT_WEIGHT,capabilities:[co.Capability.AUTOHIDEABLE,co.Capability.DELETE_AREA,co.Capability.DRAG_TARGET]})}dispose(){this.hide();this.targetWorkspace.getComponentManager().removeComponent(this.id);for(let a of this.boundEvents)la(a);this.boundEvents.length=0;this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose());this.svgGroup_&&fb(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(a){this.autoClose= +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= +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_&&hb(this.svgGroup_,"translate("+c+"px,"+d+"px)");if(a=this.workspace_.scrollbar)a.setOrigin(c,d), +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){$.A().getFocusedTree()===this.workspace_&&$.A().getFocusedNode()!==this.workspace_&&$.A().focusNode(this.workspace_);this.workspace_.setResizesEnabled(!1);$.fc=!1;this.hide();this.clearOldBlocks(); +typeof a==="string"&&(a=this.getDynamicCategoryContents(a));this.setVisible(!0);a=eh(a);a=this.createFlyoutInfo(a);bc(this.workspace_);this.setContents(a);this.reflow();this.updateAriaContext();$.fc=!0;this.workspace_.setResizesEnabled(!0);this.reflowWrapper=b=>{this.inhibitReflowWrapper||b.type!==q.BLOCK_CHANGE&&b.type!==q.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()};this.workspace_.addChangeListener(this.reflowWrapper)}updateAriaContext(){var a=this.getContents().map(c=>c.getElement()).filter(c=> +c.canBeFocused()).map(c=>c.getFocusableElement().id);u(this.getWorkspace().getCanvas(),w.OWNS,a.join(" "));this.targetWorkspace.isMutator||this.autoClose?Oa(this.getWorkspace().svgGroup_,ab.NONE):Oa(this.getWorkspace().svgGroup_,ab.REGION);var b=(a=(b=this.targetWorkspace.getToolbox())==null?void 0:b.getSelectedItem())&&sd(a)?a.getName():"";b=$.C.WORKSPACE_LABEL_FLYOUT_WORKSPACE.replace("%1",b).trim();u(this.getWorkspace().getCanvas(),w.LABEL,b);Oa(this.getWorkspace().getCanvas(),ab.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=eh(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 jo(new mo(a,this.horizontalLayout?"x":"y"),"sep"));return this.normalizeSeparators(b)}normalizeSeparators(a){for(let c=a.length-1;c>0;c--){let d=a[c].getType().toLowerCase(),e=a[c-1].getType().toLowerCase();d==="sep"&&e=== +"sep"&&a.splice(c-1,1)}var b;((b=a[a.length-1])==null?void 0:b.getType().toLowerCase())==="sep"&&a.pop();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())== +null||a.clear()}onMouseDown(a){var b=this.targetWorkspace.getGesture(a);b&&b.handleFlyoutStart(a,this)}reflow(){this.layout_(this.getContents());this.horizontalLayout?this.height_=0:this.width_=0;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=ua(l.FLYOUT_INFLATER,a,void 0))? +(b=new b,this.inflaters.set(a,b),b):null}};var Ho,Io=Ho||(Ho={});Io[Io.COMMIT=1]="COMMIT";Io[Io.DELETE=2]="DELETE";Io[Io.REVERT=3]="REVERT";var Jo=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, +a.y);else throw new TypeError("Invalid state.");}};var Ko=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= +this.isPinchZoomEnabled=null;this.mostRecentEvent=a;this.currentDragDeltaXY=new D(0,0)}dispose(){ha=null;Ge=!1;this.creatorWorkspace.clearGesture();for(let a of this.boundEvents)la(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)> +(this.flyout?$.Nf.flyoutDragRadius:$.Nf.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 Jo(this.startWorkspace_),this.workspaceDragger.startDrag()}updateIsDragging(a){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined"); +if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0;var b=Fb();b&&$h(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 (ya(l.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"); +this.isPinchZoomEnabled=this.startWorkspace_.options.zoomOptions&&this.startWorkspace_.options.zoomOptions.pinch;ma(a)?this.cancel():(this.gestureHasStarted=!0,Jh(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=de,this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=a,Se(),oa(a)?this.handleRightClick(a):(a.type.toLowerCase()==="pointerdown"&&a.pointerType!== +"mouse"&&ca(a,this),this.mouseDownXY=new D(a.clientX,a.clientY),da(a),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(); +a.stopPropagation()}handleStart(a){this.isDragging()||(this.handleTouchStart(a),this.isMultiTouch()&&aa())}handleMove(a){if(this.isDragging()&&ea(a)||!this.isMultiTouch()){this.updateFromEvent(a);if(this.workspaceDragger)this.workspaceDragger.drag(this.currentDragDeltaXY);else if(this.dragger)this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY);a.preventDefault();a.stopPropagation()}else this.isMultiTouch()&&(this.handleTouchMove(a),aa())}handleUp(a){this.isDragging()||this.handleTouchEnd(a); +if(!this.isMultiTouch()||this.isDragging()){if(!ea(a))return;this.updateFromEvent(a);aa();if(this.isEnding_){console.log("Trying to end a gesture recursively.");return}this.isEnding_=!0;this.dragger?(zg.setIsActive(!1),this.dragger.onDragEnd(a,this.currentDragDeltaXY)):this.workspaceDragger?(zg.setIsActive(!1),this.workspaceDragger.endDrag(this.currentDragDeltaXY)):this.isBubbleClick()||this.isCommentClick()||(this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()? +this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(a))}a.preventDefault();a.stopPropagation();this.dispose()}handleTouchStart(a){var b=fa(a);this.cachedPoints.set(b,this.getTouchPoint(a));var c=Array.from(this.cachedPoints.keys());c.length===2&&(b=this.cachedPoints.get(c[0]),c=this.cachedPoints.get(c[1]),this.startDistance=D.distance(b,c),this.multiTouch=!0,a.preventDefault())}handleTouchMove(a){var b=fa(a);this.cachedPoints.set(b,this.getTouchPoint(a));if(this.isPinchZoomEnabled&& +this.cachedPoints.size===2)this.handlePinch(a);else{this.updateFromEvent(a);if(this.workspaceDragger)this.workspaceDragger.drag(this.currentDragDeltaXY);else if(this.dragger)this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY);a.preventDefault();a.stopPropagation()}}handlePinch(a){var b=Array.from(this.cachedPoints.keys()),c=this.cachedPoints.get(b[0]);b=this.cachedPoints.get(b[1]);c=D.distance(c,b)/this.startDistance;if(this.previousScale>0&&this.previousScale0?b*5:b*6;if(!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");let d=this.startWorkspace_,e=pa(a,d.getParentSvg(),d.getInverseScreenCTM());d.zoom(e.x,e.y,b)}this.previousScale=c;a.preventDefault()}handleTouchEnd(a){a=fa(a);this.cachedPoints.has(a)&&this.cachedPoints.delete(a);this.cachedPoints.size<2&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(a){return this.startWorkspace_?new D(a.pageX,a.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){if(!this.isEnding_){aa(); +if(this.dragger)this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY);else this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY);this.dispose()}}handleRightClick(a){var b=$.A().getFocusedNode();if(b&&typeof b.showContextMenu==="function"){let c;(c=this.startWorkspace_)==null||c.hideChaff(!!this.flyout);b.showContextMenu(a)}a.preventDefault();a.stopPropagation();zg.setIsActive(!1);this.dispose()}handleWsStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started."); +this.setStartWorkspace(b);this.mostRecentEvent=a;this.targetBlock||this.startBubble||this.startComment||this.startIcon||$.A().focusNode(b);this.doStart(a)}fireWorkspaceClick(a){p(new (t(q.CLICK))(null,a.id,"workspace"))}handleFlyoutStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(b);this.handleWsStart(a,b.getWorkspace())}handleBlockStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started."); +this.setStartBlock(b);this.mostRecentEvent=a}handleBubbleStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(b);this.mostRecentEvent=a}handleCommentStart(a,b){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleCommentStart, but the gesture had already been started.");this.setStartComment(b);this.mostRecentEvent=a}doFieldClick(){if(!this.startField)throw Error("Cannot do a field click because the start field is undefined"); +this.currentDropdownOwner!==this.startField&&this.startField.showEditor(this.mostRecentEvent)}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.startIcon.onClick()}doBlockClick(){if(this.flyout&&this.flyout.autoClose){if(!this.targetBlock)throw Error("Cannot do a block click because the target block is undefined");var a=Ng(this.targetBlock);let c=this.flyout.targetWorkspace;if(a&&c){var b=qd(this.flyout.getWorkspace(),this.targetBlock.getRelativeToSurfaceXY()); +b=pd(c,b);a.x=b.x;a.y=b.y;Mf(a,c,{recordUndo:!0});c.hideChaff(!1)}}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");a=new (t(q.CLICK))(this.startBlock,this.startWorkspace_.id,"block");p(a)}$.r(!1)}doWorkspaceClick(){this.fireWorkspaceClick(this.startWorkspace_||this.creatorWorkspace)}setStartField(a){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField= +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= +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(),$.A().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&& +!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&& +!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=zb();for(let b=0,c;c=a[b];b++)if(c.currentGesture_)return!0;return!1}};var wk=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= +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", +`${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=z(x.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){z(x.LINE,{stroke:b.colour},a);let g;(g=b.length)!=null&&g&&z(x.LINE,{stroke:b.colour},a)}else z(x.LINE,{},a);d&&d.style.setProperty("--blocklyGridPattern", +`url(#${a.id})`);return a}};var Lo=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);v(a,"blocklyBlockCanvas");a=this.createLayer(100);v(a,"blocklyBubbleCanvas")}createDragLayer(a){var b=z(x.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 z(x.G, +{},b)}createAnimationLayer(a){var b=z(x.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 z(x.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= +`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()&&$.A().focusNode(a)}moveOffDragLayer(a,b,c=!0){this.append(a,b);c&&a.canBeFocused()&&$.A().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; +(d=this.layers.get(b))==null||d.appendChild(a)}}createLayer(a){var b=this.workspace.getSvgGroup(),c=z(x.G,{}),d=!1,e=[...this.layers].sort((f,g)=>f[0]-g[0]);for(let [f,g]of e)if(asuper.updateEditable;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){b().call(a); +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;p(new (t(q.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= +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+ +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 Pc((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;ac().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= +this.textInputBubble.getText();this.text!==a&&(p(new (t(q.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= +a,yield ac(),!b.sourceBlock.rendered||b.sourceBlock.isInFlyout||b.sourceBlock.isInsertionMarker()||(a?(b.sourceBlock.isEditable()?b.showEditableBubble():b.showNonEditableBubble(),b.applyColour()):b.hideBubble(),p(new (t(q.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)== +null||b.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();var a;(a=this.textInputBubble)==null||a.setEditable(!1)}createBubble(){this.textInputBubble=new ao(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); +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()? +$.C.ICON_LABEL_COMMENT_OPEN:$.C.ICON_LABEL_COMMENT_CLOSED}};jk.TYPE=Yf.COMMENT;jk.WEIGHT=3;ai(jk.TYPE,jk);var No=class extends Cn{constructor(a){super(a);this.sourceBlock=a;this.textMap=new Map;this.textBubble=null}getType(){return No.TYPE}initView(a){this.svgRoot||(super.initView(a),z(x.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),z(x.PATH,{"class":"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),z(x.RECT,{"class":"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),v(this.svgRoot,"blocklyWarningIcon"))}dispose(){super.dispose(); +var a;(a=this.textBubble)==null||a.dispose()}getWeight(){return No.WEIGHT}getSize(){return new Pc(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= +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 ac();if(a)b.textBubble=new $n(b.getText(),b.sourceBlock.workspace,b.getAnchorLocation(),b.getBubbleOwnerRect(),b), +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}p(new (t(q.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 Zc(a.y,a.y+a.height,a.x,a.x+a.width)}getAriaLabel(){return this.bubbleIsVisible()? +$.C.ICON_LABEL_WARNING_OPEN:$.C.ICON_LABEL_WARNING_CLOSED}};No.TYPE=Yf.WARNING;No.WEIGHT=2;var Oo={};Oo.CommentIcon=jk;Oo.Icon=Cn;Oo.IconType=Yf;Oo.MutatorIcon=$.mh;Oo.WarningIcon=No;Oo.exceptions=Ln;Oo.registry=Mo;var Po,Qo; +$.hi=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= +$.ng(a);for(let b=0;b=1}isHat(a){return(a.type&this.HAT)>=1}isIcon(a){return(a.type&this.ICON)>=1}isSpacer(a){return(a.type& +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)|| +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)>= +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 To;var Uo=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 Vo=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."); +}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let a=0;a=0;a--){let b=this.elements[a];if(Q.isInRowSpacer(b))return b}return null}};var Wo=class extends Vo{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;drect,`,`${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 {`,`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};`, +"stroke: none;","}"]}};var tp=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; +this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let a=1;a0&&this.addAlignmentPadding_(c, +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===$.Mn.LEFT&&d)d.width+=b;else if(a.align===$.Mn.CENTRE&&c&&d)c.width+=b/2,d.width+=b/2;else if(a.align===$.Mn.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- +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=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 zp={CATEGORY_NAME:"VARIABLE_DYNAMIC"};zp.flyoutCategory=wi; +zp.flyoutCategoryBlocks=function(a){a=a.getVariableMap().getAllVariables();var b=[];if(a.length>0){if(Qb.variables_set_dynamic){var c=a[a.length-1];let d=$.mc("block");d.setAttribute("type","variables_set_dynamic");d.setAttribute("gap","24");d.appendChild(Gg(c));b.push(d)}if(Qb.variables_get_dynamic){a.sort(tg);for(let d=0,e;e=a[d];d++)c=$.mc("block"),c.setAttribute("type","variables_get_dynamic"),c.setAttribute("gap","8"),c.appendChild(Gg(e)),b.push(c)}}return b}; +zp.onCreateVariableButtonClick_Colour=vi;zp.onCreateVariableButtonClick_Number=ui;zp.onCreateVariableButtonClick_String=ti;var Ap=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 Ro;this.readOnly=!1;this.potentialVariableMap=null;this.id=Ca();Ab(this);this.options= +a||new xn({});this.RTL=!!this.options.RTL;this.horizontalLayout=!!this.options.horizontalLayout;this.toolboxPosition=this.options.toolboxPosition;this.connectionChecker=new (ya(l.CONNECTION_CHECKER,this.options,!0))(this);this.variableMap=new (this.getVariableMapClass())(this);this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0;this.clear();Bb(this)}sortObjects(a,b){var c=d=>({getBoundingRectangle:()=>{var e=d.getRelativeToSurfaceXY();return new Zc(e.y,e.y,e.x,e.x)},moveBy:()=> +{}});return this.sortByOrigin(c(a),c(b))}sortByOrigin(a,b){var c=Math.sin(Ld(Ap.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(!xh(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)|| +this.typedBlocksDB.set(a.type,[]);this.typedBlocksDB.get(a.type).push(a)}removeTypedBlock(a){xh(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 "'+ +a.id+'"');this.commentDB.set(a.id,a)}removeTopComment(a){if(!xh(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!c.isInsertionMarker())}clear(){this.isClearing=!0;try{let a=$.ec;for(a||$.r(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();$.r(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"); +}remainingCapacity(){return isNaN(this.options.maxBlocks)?Infinity:this.options.maxBlocks-this.getAllBlocks(!1).length}remainingCapacityOfType(a){return this.options.maxInstances?(this.options.maxInstances[a]!==void 0?this.options.maxInstances[a]:Infinity)-this.getBlocksByType(a,!1).length:Infinity}isCapacityAvailable(a){if(!this.hasBlockLimits())return!0;var b=0;for(let c in a){if(a[c]>this.remainingCapacityOfType(c))return!1;b+=a[c]}return!(b>this.remainingCapacity())}hasBlockLimits(){return this.options.maxBlocks!== +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;bthis.MAX_UNDO&&this.MAX_UNDO>=0;)this.undoStack_.shift();for(let b=0;b{c.sounds.set(b,f)})}})}play(a,b){var c=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){if(c.isPlayingAllowed()&& +b!==0){var d=c.sounds.get(a);if(d){if(yield c.prepareToPlay(),c.context.state==="running"){var 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(),c.context.state==="running")){var d=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(zg.getScopeChangeAudioCuesEnabled()){var b= +this.parentWorkspace.getNavigator(),c=b.getSourceBlockFromNode($.A().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)}prepareToPlay(){var a=this;return(0,M.asyncExecutePromiseGeneratorFunction)(function*(){a.lastSound=new Date;a.context.state==="suspended"&&navigator.userActivation.hasBeenActive&& +(yield a.context.resume())})}setMuted(a){this.muted=a}getMuted(){return this.muted}};var Cp=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}showContextMenu(a){this.workspace.showContextMenu(a)}};var zi,Dp=zi||(zi={});Dp[Dp.TOP=0]="TOP";Dp[Dp.BOTTOM=1]="BOTTOM";var xi,Ep=xi||(xi={});Ep[Ep.LEFT=0]="LEFT";Ep[Ep.RIGHT=1]="RIGHT";var Ci,Fp=Ci||(Ci={});Fp[Fp.UP=0]="UP";Fp[Fp.DOWN=1]="DOWN";var Gp={};Gp.bumpDirection=Ci;Gp.bumpPositionRect=Di;Gp.getCornerOppositeToolbox=Bi;Gp.getStartPositionRect=Ai;Gp.horizontalPosition=xi;Gp.verticalPosition=zi;var Hp={width:96,height:124,url:"sprites.svg"};var Ip=class{constructor(a,b){this.workspace=a;this.group=b;this.pointerDownHandler=k(b,"pointerdown",null,this.performAction.bind(this));this.keyDownHandler=ka(b,"keydown",this,this.onKeyDown);Oa(b,ab.BUTTON);this.id=Aa();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 (t(q.CLICK))(null,this.workspace.id,"zoom_controls");p(a)}getGroup(){return this.group}onKeyDown(a){if(a.key=== +"Enter"||a.key===" ")a.preventDefault(),this.performAction(a)}dispose(){la(this.pointerDownHandler);la(this.keyDownHandler)}},Jp=class extends Ip{constructor(a,b){var c=String(Math.random()).substring(2);b=z(x.G,{"class":"blocklyZoom blocklyZoomIn",tabindex:"0"},b);u(b,w.LABEL,$.C.ZOOM_IN);z(x.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=z(x.CLIPPATH,{id:"blocklyZoominClipPath"+c},b);z(x.RECT,{width:32,height:32},d);z(x.IMAGE,{width:Hp.width,height:Hp.height, +x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Hp.url);super(a,b)}performAction(a){this.zoom(1,a)}},Kp=class extends Ip{constructor(a,b){var c=String(Math.random()).substring(2);b=z(x.G,{"class":"blocklyZoom blocklyZoomOut",tabindex:"0"},b);u(b,w.LABEL,$.C.ZOOM_OUT);z(x.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},b);var d=z(x.CLIPPATH,{id:"blocklyZoomoutClipPath"+ +c},b);z(x.RECT,{width:32,height:32},d);z(x.IMAGE,{width:Hp.width,height:Hp.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Hp.url);super(a,b)}performAction(a){this.zoom(-1,a)}},Lp=class extends Ip{constructor(a,b){var c=String(Math.random()).substring(2);b=z(x.G,{"class":"blocklyZoom blocklyZoomReset",tabindex:"0"},b);u(b,w.LABEL,$.C.RESET_ZOOM);z(x.RECT,{width:40,height:40,x:-4,y:-4,rx:2,ry:2, +fill:"none","class":"blocklyFocusRing"},b);var d=z(x.CLIPPATH,{id:"blocklyZoomresetClipPath"+c},b);z(x.RECT,{width:32,height:32},d);z(x.IMAGE,{width:Hp.width,height:Hp.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+c+")"},b).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Hp.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),500);this.fireZoomEvent();ha=null;a.stopPropagation();a.preventDefault()}},Mp=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=z(x.G,{});this.zoomOutControl=new Kp(this.workspace,this.svgGroup);this.zoomInControl=new Jp(this.workspace,this.svgGroup);this.workspace.isMovable()&&(this.zoomResetControl=new Lp(this.workspace,this.svgGroup));return this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:co.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[co.Capability.POSITIONABLE]});this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"); +this.svgGroup&&fb(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 Zc(this.top,this.top+a,this.left,this.left+this.WIDTH)}position(a,b){if(this.initialized){var c=Bi(this.workspace,a),d=this.SMALL_SPACING+2*this.HEIGHT;this.zoomResetControl&&(d+=this.LARGE_SPACING+ +this.HEIGHT);a=Ai(c,new Pc(this.WIDTH,d),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,a,this.workspace);c=c.vertical;b=Di(a,this.MARGIN_VERTICAL,c===zi.TOP?Ci.DOWN:Ci.UP,b);if(c===zi.TOP){var e=this.SMALL_SPACING+this.HEIGHT,f;(f=this.zoomInControl)==null||f.getGroup().setAttribute("transform","translate(0, "+e+")");this.zoomResetControl&&(e=e+this.LARGE_SPACING+this.HEIGHT,this.zoomResetControl.getGroup().setAttribute("transform","translate(0, "+e+")"))}else{f=this.zoomResetControl?this.LARGE_SPACING+ +this.HEIGHT:0;let h;(h=this.zoomInControl)==null||h.getGroup().setAttribute("transform","translate(0, "+f+")");f=f+this.SMALL_SPACING+this.HEIGHT;(e=this.zoomOutControl)==null||e.getGroup().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+")")}}};wc("\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 Gi=class extends Ap{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= +[];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 Bo;this.metricsManager=new (ya(l.METRICS_MANAGER,a,!0))(this);this.getMetrics=a.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager);this.setMetrics=a.setMetrics|| +Gi.setTopLevelWorkspaceMetrics;this.componentManager=new co;this.connectionDBList=go.init(this.connectionChecker);var b;this.audioManager=new Bp((b=a.parentWorkspace)!=null?b:this);this.grid=this.options.gridPattern?new wk(this.options.gridPattern,a.gridOptions):null;ln&&rg&&this.registerToolboxCategoryCallback("VARIABLE",rg);zp&&wi&&this.registerToolboxCategoryCallback("VARIABLE_DYNAMIC",wi);So&&ki&&(this.registerToolboxCategoryCallback("PROCEDURE",ki),this.addChangeListener(ni));this.addChangeListener(this.variableChangeCallback.bind(this)); +this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new yp(this,this.options.theme||un);this.themeManager_.subscribeWorkspace(this);var c;this.renderer=si(this.options.renderer||"geras",this.getTheme(),(c=this.options.rendererOverrides)!=null?c:void 0);this.cachedParentSvgSize=new Pc(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|| +(a=un);this.themeManager_.setTheme(a)}refreshTheme(){if(this.svgGroup_){let c=this.options.parentWorkspace===null;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),c?this.getInjectionDiv():void 0)}var a=[];this.getAllBlocks(!1).forEach(c=>{c.getStyleName()&&a.push(c);c.markDirty();c.queueRender();var d=c.getIcon(Yf.WARNING);if(d==null?0:d.bubbleIsVisible())d=d.getBubble(),d instanceof $n&&d.updateBubbleSize();c=c.getIcon(Yf.MUTATOR);if(c==null?0:c.bubbleIsVisible())c=c.getBubble(),c instanceof +Bn&&c.updateBubbleSize()});this.updateBlockStyles(a);this.refreshToolboxSelection();this.toolbox&&this.toolbox.refreshTheme();this.isVisible()&&this.setVisible(!0);var b;!this.isFlyout||((b=this.targetWorkspace)==null?0:b.getToolbox())||ac().then(()=>{var c,d;(d=(c=this.targetWorkspace)==null?void 0:c.getFlyout())==null||d.reflow()});b=new (t(q.THEME_CHANGE))(this.getTheme().name,this.id);p(b)}updateBlockStyles(a){for(let b=0,c;c=a[b];b++){let d=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=ld(a);if(a===this.getCanvas()||a===this.getBubbleCanvas())d=1;b+=e.x*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 Pc(a.width,a.height)}getOriginOffsetInPixels(){return md(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=a}setInitialAriaContext(){if(!this.svgGroup_)throw Error("Must initialize svgGroup_ by calling `createDom` before calling setAriaContext"); +this.isFlyout||(Oa(this.svgGroup_,ab.REGION),this.isMutator?u(this.svgGroup_,w.LABEL,$.C.WORKSPACE_LABEL_MUTATOR_WORKSPACE):(u(this.svgGroup_,w.LABEL,$.C.WORKSPACE_LABEL_PLAIN),this.workspaceFocusTargetElement&&(Oa(this.workspaceFocusTargetElement,ab.FIGURE),u(this.workspaceFocusTargetElement,w.ROLEDESCRIPTION,$.C.WORKSPACE_ROLEDESCRIPTION),this.updateAriaLabel())))}updateAriaLabel(){if(this.workspaceFocusTargetElement){var a=this.getTopBlocks(!1).length;a==1?u(this.workspaceFocusTargetElement,w.LABEL, +$.C.WORKSPACE_LABEL_1_STACK):u(this.workspaceFocusTargetElement,w.LABEL,$.C.WORKSPACE_LABEL_MANY_STACKS.replace("%1",String(a)))}}createDom(a,b){this.injectionDiv||(this.injectionDiv=b!=null?b:null);this.svgGroup_=z(x.G,{"class":"blocklyWorkspace",id:this.id});a&&(this.svgBackground_=z(x.RECT,{height:"100%",width:"100%","class":a},this.svgGroup_),a==="blocklyMainBackground"&&this.grid?this.svgBackground_.style.fill="var(--blocklyGridPattern)":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour", +"fill"));this.workspaceSelectionRing=a=z(x.RECT,{fill:"none",class:"blocklyWorkspaceSelectionRing"},this.svgGroup_);this.workspaceFocusRing=z(x.RECT,{fill:"none",class:"blocklyWorkspaceFocusRing"},this.svgGroup_);this.isFlyout||this.isMutator||(a.id=`${this.id}_focusTarget`,this.workspaceFocusTargetElement=a,this.workspaceFocusTarget=new Cp(this,a));this.layerManager=new Lo(this);this.svgBlockCanvas_=this.layerManager.getBlockLayer();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 (ya(l.TOOLBOX,this.options,!0))(this));this.grid&&this.grid.update(this.scale);this.recordDragTargets();a=this.options.parentWorkspace===null;this.renderer.createDom(this.svgGroup_,this.getTheme(),a?this.getInjectionDiv(): +void 0);$.A().registerTree(this,!!this.injectionDiv||this.isFlyout);return this.svgGroup_}dispose(){this.rendered=!1;this.currentGesture_&&this.currentGesture_.cancel();this.svgGroup_&&fb(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(),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=this.getParentSvg();c&&c.parentNode&&fb(c.parentNode)}this.resizeHandlerWrapper&&(la(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();$.A().isRegistered(this)&&$.A().unregisterTree(this)}addTrashcan(){this.trashcan=Gi.newTrashcan(this);var a=this.trashcan.createDom();this.svgGroup_.appendChild(a)}static newTrashcan(){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts"); +}addZoomControls(){this.zoomControls_=new Mp(this);var a=this.zoomControls_.createDom();this.svgGroup_.appendChild(a)}copyOptionsForFlyout(){return new xn({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,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 (ya(l.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(b):new (ya(l.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():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;(a=this.getFlyout())==null||a.getWorkspace().resize();a=this.componentManager.getComponents(co.Capability.POSITIONABLE,!0);var b=this.getMetricsManager().getUiMetrics(),c=[];for(let d=0,e;e=a[d];d++){e.position(b,c);let f=e.getBoundingRectangle();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=od();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=this.svgGroup_;for(;a;){if(a.tagName=== +"svg"){this.cachedParentSvg=a;break}a=a.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(La()){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 (t(q.VIEWPORT_CHANGE))(b,c,a,this.id,this.oldScale);this.oldScale=a;this.oldTop=b;this.oldLeft=c;p(d)}}}translate(a,b){var c;(c=this.layerManager)==null||c.translateLayers(new D(a,b),this.scale);var d;(d=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=>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):xh(this.highlightedBlocks,a),a.setHighlighted(b)}variableChangeCallback(a){switch(a.type){case q.VAR_CREATE:case q.VAR_DELETE:case q.VAR_RENAME:case q.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){var a=this.isFlyout? +this.targetWorkspace:this;a&&!a.currentGesture_&&a.toolbox&&a.toolbox.getFlyout()&&a.toolbox.refreshSelection()}recordDragTargets(){var a=this.componentManager.getComponents(co.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"); +}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){Rf(this,a,b)}moveDrag(a){return Sf(this,a)}isDragging(){return Yi.mover.isMoving()||this.currentGesture_!==null&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&& +!!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(Ko.inProgress())a.preventDefault(), +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=qa(a);if(na)var e=a.metaKey;b&&(a.ctrlKey||e||!c)?(d=-d.y/50,b=pa(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 Zc(0, +0,0,0);var b=a[0].getBoundingRectangle();for(let d=1;db.bottom&&(b.bottom=c.bottom);c.leftb.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=$.ec;b||$.r(!0);var c=this.getTopBlocks(!0),d=c.filter(g=>g.isMovable()),e=c.filter(g=> +!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}$.r(b);this.setResizesEnabled(!0)}showContextMenu(a){if(!this.isReadOnly()&&!this.isFlyout){var b= +Xj.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.getMetricsManager().getViewMetrics(!0),c=qd(this,new D(this.RTL?c.left+c.width-5:c.left+5,c.top+5));Ff(a,b,this.RTL,this,c)}}updateToolbox(a){if(a=dh(a)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(fh(a)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode."); +this.options.languageTree=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():(Eb(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?c=this.options.zoomOptions.maxScale/this.scale:dthis.options.zoomOptions.maxScale? +a=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&a{if(c.isFlyout){let d,e=(d=c.targetWorkspace)==null?void 0:d.getFlyout();if(e instanceof Go)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,c=!0){c&&this.hideChaff(!0);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.round(Math.max(a,-(c.scrollLeft+Math.max(0,c.scrollWidth-c.viewWidth))));b=Math.round(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);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){xh(this.topBoundedElements, +a)}getTopBoundedElements(a=!1){var b=[].concat(this.topBoundedElements);a&&b.sort(this.sortByOrigin.bind(this));return b}setResizesEnabled(a){var b=!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!=="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(Yi.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."),this.currentGesture_.cancel());!this.currentGesture_&&b&&(this.currentGesture_=new Ko(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){Ie();uf(this);le();this.hideComponents(a)}hideComponents(a=!1){this.getComponentManager().getComponents(co.Capability.AUTOHIDEABLE,!0).forEach(b=>b.autoHide(a))}static setTopLevelWorkspaceMetrics(a){var b=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&& +v(this.injectionDiv,a)}removeClass(a){this.injectionDiv&&cb(this.injectionDiv,a)}setIsReadOnly(a){super.setIsReadOnly(a);a?this.addClass("blocklyReadOnly"):this.removeClass("blocklyReadOnly")}scrollBoundsIntoView(a,b=10){if(!Ko.inProgress()){var c=this.getScale(),d=this.getMetricsManager().getViewMetrics(!0);d=new Zc(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.leftd.right&&(b=this.RTL?d.right-a.right:Math.max(d.right-a.right,d.left-a.left));a.topd.bottom&&(e=Math.max(d.bottom-a.bottom,d.top-a.top));this.scroll(this.scrollX+b*c,this.scrollY+e*c,!1)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this}onNodeFocus(){this.maybeAnnounceScreenreaderHint()}handleWorkspaceFocusTargetFocus(){this.updateAriaLabel();this.maybeAnnounceScreenreaderHint()}maybeAnnounceScreenreaderHint(){Gi.everFocused|| +this.options.parentWorkspace||($a($.C.SCREENREADER_HINT.replace("%1",gd(K.TOGGLE_SCREENREADER))),Gi.everFocused=!0)}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(a){if(a)return a;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 tb(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=zb().filter(c=>c.isMutator&&c.options.parentWorkspace===this),b=this.getFlyout(!0);b&&a.push(b.getWorkspace());return a}searchForWorkspaceComment(a){for(let b of this.getTopComments())if(b instanceof dg&&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(),tb(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"));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.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(Mc(h)){if((g=h.getBubble())&&g.canBeFocused()&&g.getFocusableElement().id===a)return g;if(g instanceof ao&&g.getEditor().getFocusableElement().id===a)return g.getEditor()}}h=this.getComponentManager().getComponents(co.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){var b= +this.targetWorkspace.getToolbox();b&&a===b||$.A().ephemeralFocusTaken()&&a!==this.targetWorkspace||this.targetWorkspace.hideComponents(!1)}}performAction(){Ri.show(this,{message:$.C.KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT,id:"workspaceNavigationHint"})}getNavigator(){return this.navigator}setNavigator(a){this.navigator=a}};Gi.everFocused=!1;var Ei=null,Fi=null,Hi=void 0,Np={};Np.BlockPaster=Yn;Np.copy=Ii;Np.getLastCopiedData=function(){return Ei};Np.getLastCopiedLocation=function(){return Hi};Np.getLastCopiedWorkspace=function(){return Fi};Np.paste=Ki;Np.registry=Hl;Np.setLastCopiedData=function(a){Ei=a};Np.setLastCopiedLocation=function(a){Hi=a};Np.setLastCopiedWorkspace=function(a){Fi=a};var Op={};Op.CollapseCommentBarButton=Zl;Op.CommentBarButton=Yl;Op.CommentEditor=$l;Op.CommentView=bm;Op.DeleteCommentBarButton=am;Op.RenderedWorkspaceComment=dg;Op.WorkspaceComment=eg;var K,Pp=K||(K={});Pp.ESCAPE="escape";Pp.DELETE="delete";Pp.COPY="copy";Pp.CUT="cut";Pp.PASTE="paste";Pp.UNDO="undo";Pp.REDO="redo";Pp.MENU="menu";Pp.FOCUS_WORKSPACE="focus_workspace";Pp.FOCUS_TOOLBOX="focus_toolbox";Pp.START_MOVE="start_move";Pp.START_MOVE_STACK="start_move_stack";Pp.FINISH_MOVE="finish_move";Pp.ABORT_MOVE="abort_move";Pp.MOVE_UP="move_up";Pp.MOVE_DOWN="move_down";Pp.MOVE_LEFT="move_left";Pp.MOVE_RIGHT="move_right";Pp.NAVIGATE_RIGHT="right";Pp.NAVIGATE_LEFT="left"; +Pp.NAVIGATE_UP="up";Pp.NAVIGATE_DOWN="down";Pp.DISCONNECT="disconnect";Pp.NEXT_STACK="next_stack";Pp.PREVIOUS_STACK="previous_stack";Pp.INFORMATION="information";Pp.EXTENDED_INFORMATION="extended_information";Pp.PERFORM_ACTION="perform_action";Pp.DUPLICATE="duplicate";Pp.CLEANUP="cleanup";Pp.SHOW_TOOLTIP="show_tooltip";Pp.NEXT_HEADING="next_heading";Pp.PREVIOUS_HEADING="previous_heading";Pp.TOGGLE_SCREENREADER="toggle_screenreader";Pp.JUMP_TOP_STACK="jump_to_top_of_stack";Pp.JUMP_BOTTOM_STACK="jump_to_bottom_of_stack"; +Pp.JUMP_BLOCK_START="jump_to_block_start";Pp.JUMP_BLOCK_END="jump_to_block_end";Pp.JUMP_FIRST_BLOCK="jump_to_first_block";Pp.JUMP_LAST_BLOCK="jump_to_last_block";Pp.JUMP_PREVIOUS_PAGE="jump_to_previous_page";Pp.JUMP_NEXT_PAGE="jump_to_next_page";Pp.SCROLL_LEFT="scroll_left";Pp.SCROLL_RIGHT="scroll_right";Pp.SCROLL_UP="scroll_up";Pp.SCROLL_DOWN="scroll_down"; +var $i=B.registry.createSerializedKey(L.LEFT,[L.CTRL_CMD]),aj=B.registry.createSerializedKey(L.RIGHT,[L.CTRL_CMD]),bj=B.registry.createSerializedKey(L.UP,[L.CTRL_CMD]),cj=B.registry.createSerializedKey(L.DOWN,[L.CTRL_CMD]),gj=a=>{if(a.isFlyout){let c=a.targetWorkspace;if(c)return gj(c)}var b;return(b=a.getRootWorkspace())!=null?b:a},uj=(a,b)=>!a.isFlyout&&!!b.focusedNode&&!a.isDragging()&&!$.A().ephemeralFocusTaken()&&!!a.getNavigator().getSourceBlockFromNode(b.focusedNode),Gj=a=>(a=a.getToolbox())&& +$.A().getFocusedTree()===a?a:null,Aj=a=>{var b,c=(b=Gj(a))!=null?b:a.isFlyout&&$.A().getFocusedTree()===a?a:null;return c?c.getNavigator().getNavigableItems(c.getRootFocusableNode()):null},Ij=a=>{var b;if(b=!a.isDragging()&&!$.A().ephemeralFocusTaken())(b=!!Gj(a))||(b=a.isFlyout&&$.A().getFocusedTree()===a);return b},Nj,Qp=Nj||(Nj={});Qp[Qp.LEFT=0]="LEFT";Qp[Qp.RIGHT=1]="RIGHT";Qp[Qp.UP=2]="UP";Qp[Qp.DOWN=3]="DOWN"; +var Rp={[Nj.LEFT]:"ANNOUNCE_SCROLLED_LEFT",[Nj.RIGHT]:"ANNOUNCE_SCROLLED_RIGHT",[Nj.UP]:"ANNOUNCE_SCROLLED_UP",[Nj.DOWN]:"ANNOUNCE_SCROLLED_DOWN"},Lj=a=>{var b;return!a.isDragging()&&a.isMovable()&&!((b=a.targetWorkspace)==null?0:b.isMutator)&&!Yi.mover.isMoving()&&!de&&!mf},Sp=a=>{a.getAudioManager().playErrorBeep();$a($.C.ANNOUNCE_CANT_SCROLL_FURTHER)},Mj=(a,b,c)=>{b.preventDefault();if(c===Nj.LEFT||c===Nj.RIGHT?!a.isMovableHorizontally():!a.isMovableVertically())return Sp(a),!0;var d=b=0;switch(c){case Nj.LEFT:b= +50;break;case Nj.RIGHT:b=-50;break;case Nj.UP:d=50;break;case Nj.DOWN:d=-50}var e=a.scrollX,f=a.scrollY;a.scroll(e+b,f+d);if(a.scrollX===e&&a.scrollY===f)return Sp(a),!0;$a($.C[Rp[c]]);return!0};Pj();Qj();Rj();var Tp={};Tp.names=K;Tp.registerArrowNavigation=fj;Tp.registerCleanup=rj;Tp.registerCopy=Si;Tp.registerCut=Ti;Tp.registerDefaultShortcuts=Pj;Tp.registerDelete=Pi;Tp.registerDisconnectBlock=lj;Tp.registerDuplicate=qj;Tp.registerEscape=Ni;Tp.registerFocusToolbox=ij;Tp.registerFocusWorkspace=hj; +Tp.registerHeadingNavigation=oj;Tp.registerJumpBlockEnd=xj;Tp.registerJumpBlockStart=vj;Tp.registerJumpBottomStack=zj;Tp.registerJumpFirstBlock=Bj;Tp.registerJumpLastBlock=Cj;Tp.registerJumpNextPage=Kj;Tp.registerJumpPreviousPage=Jj;Tp.registerJumpTopStack=yj;Tp.registerKeyboardNavigationShortcuts=Qj;Tp.registerMovementShortcuts=dj;Tp.registerNavigationShortcuts=function(){vj();xj();yj();zj();Bj();Cj();Jj();Kj();Oj()};Tp.registerPaste=Ui;Tp.registerPerformAction=pj; +Tp.registerReadExtendedInformation=kj;Tp.registerReadInformation=jj;Tp.registerRedo=Xi;Tp.registerScreenReaderShortcuts=Rj;Tp.registerShowContextMenu=ej;Tp.registerShowTooltip=sj;Tp.registerStackNavigation=mj;Tp.registerToggleScreenreaderMode=tj;Tp.registerUndo=Wi;Tp.registerWorkspaceScrollShortcuts=Oj;var Up,Vp=Up||(Up={});Vp[Vp.CONSTRAINED=1]="CONSTRAINED";Vp[Vp.UNCONSTRAINED=2]="UNCONSTRAINED"; +var Wp=class{constructor(a){this.block=a;this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null;this.dragging=!1;this.allConnectionPairs=[];this.moveMode=Up.UNCONSTRAINED;this.originalEventGroup="";this.lastAnnouncedNeighbour=this.lastAnnouncedLocal=void 0;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||this.block.isEnabled()&&!((a=this.block.workspace.targetWorkspace)==null?0:a.isReadOnly()))}positionNewBlock(a,b){a=qd(a.workspace,a.getRelativeToSurfaceXY());a=pd(b.workspace,a);b.moveDuringDrag(a);if(this.moveMode===Up.CONSTRAINED){a=b.workspace;var c=a.getMetricsManager().getViewMetrics(!0),d=c.top+this.WORKSPACE_MARGIN,e=a.RTL?c.left+c.width-this.WORKSPACE_MARGIN:c.left+this.WORKSPACE_MARGIN,f=Math.max($.Nf.connectingSnapRadius,$.Nf.snapRadius)+ +2,g=a.getTopBlocks(!0).filter(ja=>ja.id!==b.id).map(ja=>{ja=ja.getBoundingRectangle();return new Zc(ja.top-f,ja.bottom+f,ja.left-f,ja.right+f)}),h=b.getHeightWidth().width,m=function(ja){for(let Xa of g)if(ja.intersects(Xa))return Xa;return null},y=e,F=a.getRenderer().getConstants().MIN_BLOCK_HEIGHT,J=b.getBoundingRectangle();b.moveBy(a.RTL?y-J.right:y-J.left,d-J.top,["cleanup"]);J=b.getBoundingRectangle();for(var V=m(J);V!=null;)y=a.RTL?V.left-80:V.right+80,V=V.top+V.getHeight()+F,(a.RTL?y-h>=c.left: +y+h<=c.left+c.width)||(d=V,y=e),b.moveBy(a.RTL?y-J.right:y-J.left,d-J.top,["cleanup"]),J=b.getBoundingRectangle(),V=m(J)}}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=Ng(a)))return a=Mf(a,this.block.workspace.targetWorkspace,{recordUndo:!0}),$.fc=!1,a.render(),this.positionNewBlock(this.block,a),a.setDragging(!0),$.fc=!0,a;return this.block}announceMove(a=!1){if(this.connectionCandidate)a= +Kd(this.connectionCandidate.local,this.connectionCandidate.neighbour,this.hasMultipleCompatibleConnections.bind(this),a);else{var b=a?this.block.getStackBlocksCountLabel():"";a=$.C.ANNOUNCE_MOVE_WORKSPACE;a=a.replace("%1",b)}var c,d;b=(d=(c=this.connectionCandidate)==null?void 0:c.local)!=null?d:null;var e,f;c=(f=(e=this.connectionCandidate)==null?void 0:e.neighbour)!=null?f:null;if(this.lastAnnouncedLocal===void 0||b!==this.lastAnnouncedLocal||c!==this.lastAnnouncedNeighbour)this.lastAnnouncedLocal= +b,this.lastAnnouncedNeighbour=c,$a(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!==this.block)return b.startDrag(a);this.block.workspace.recordDragTargets(); +this.dragging=!0;this.lastAnnouncedNeighbour=this.lastAnnouncedLocal=void 0;this.fireDragStartEvent();this.startLoc=this.block.getRelativeToSurfaceXY();this.connectionCandidate=null;this.connectionPreviewer=new (ya(l.CONNECTION_PREVIEWER,this.workspace.options))(this.block);kb();this.workspace.setResizesEnabled(!1);Jh();b=this.shouldHealStack(a);this.storeInitialConnections(b);this.shouldDisconnect(b)&&this.disconnectBlock(b);this.block.setDragging(!0);this.enableAllDraggedBlocks(this.block);this.cacheAllConnectionPairs(); +if(a instanceof KeyboardEvent){let d;a=(d=this.getInitialCandidate())!=null?d:void 0;this.updateConnectionPreview(this.block,new D(0,0),a)&&this.block.moveDuringDrag(this.determineConnectionOffset());this.allConnectionPairs.length?Vj(this.workspace):Uj(this.workspace)}else this.block.moveDuringDrag(this.startLoc);var c;(c=this.workspace.getLayerManager())==null||c.moveToDragLayer(this.block);this.getVisibleBubbles(this.block).forEach(d=>{var e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(d, +!1)});this.announceMove(!0);return this.block}cacheAllConnectionPairs(){var a=this.block.workspace.connectionChecker,b=[];this.allConnectionPairs=[];var c=this.getLocalConnections(this.block);for(let d of this.block.workspace.getTopBlocks(!0))b.push(...this.getAllConnections(d));for(let d of b)for(let e of c){let f;!a.canConnect(e,d,!0,Infinity)||((f=d.targetBlock())==null?0:f.isInsertionMarker())||this.allConnectionPairs.push({local:e,neighbour:d})}}getVisibleBubbles(a){return a.getDescendants(!1).flatMap(b=> +b.getIcons()).filter(b=>Mc(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); +Mh(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, +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 (t(q.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));p(a)}fireDragEndEvent(){var a=new (t(q.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));p(a)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var a=new (t(q.BLOCK_MOVE))(this.block);a.setReason(["drag"]);a.oldCoordinate=this.startLoc;a.recordNew();p(a)}}drag(a, +b){this.updateMoveMode(b);this.moveMode===Up.UNCONSTRAINED&&this.block.moveDuringDrag(a);b=!!this.connectionCandidate;this.updateConnectionPreview(this.block,D.difference(a,this.startLoc));if(this.connectionCandidate)this.moveMode===Up.CONSTRAINED&&this.block.moveDuringDrag(this.determineConnectionOffset());else if(this.moveMode===Up.CONSTRAINED&&(this.allConnectionPairs.length||Uj(this.workspace,!0),!b)){this.workspace.getAudioManager().playErrorBeep();return}this.announceMove()}determineConnectionOffset(){var {local:a, +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===E.PREVIOUS_STATEMENT||a.type===E.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===E.OUTPUT_VALUE||f.type===E.PREVIOUS_STATEMENT; +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 F;(F=this.connectionPreviewer)==null||F.previewConnection(f,g)}return g}if(this.moveMode===Up.CONSTRAINED){let F;h=(F=d==null?void 0:d.neighbour.getSourceBlock())!=null?F:null;let J;m=(J=h==null?void 0:h.getRootBlock())!=null?J:h;m===a&&(m=h);if(!m){let V;(V=this.connectionPreviewer)== +null||V.hidePreview();return}h=a.workspace.getTopBlocks().filter(V=>V!==a.getRootBlock()).map(V=>V.getBoundingRectangle());if(!h.length){let V;(V=this.connectionPreviewer)==null||V.hidePreview();return}var y;d=(y=d==null?void 0:d.neighbour.x)!=null?y:a.getRelativeToSurfaceXY().x;y=this.BLOCK_CONNECTION_OFFSET*2;switch(this.getDirectionToNewLocation(D.sum(this.startLoc,b))){case Zi.LEFT:case Zi.UP:b=Math.min(...h.map(V=>V.top))-y-a.getHeightWidth().height;break;default:b=Math.max(...h.map(V=>V.bottom))+ +y}a.moveDuringDrag(new D(d,b))}(e=this.connectionPreviewer)==null||e.hidePreview()}orphanCanConnectAtEnd(a,b,c){return!!Jn.getConnectionForOrphanedConnection(a,c===E.OUTPUT_VALUE?b.outputConnection:b.previousConnection)}currCandidateIsBetter(a,b,c){if(this.moveMode===Up.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-$.Nf.currentConnectionPreference}getConnectionCandidate(a){return this.moveMode===Up.CONSTRAINED? +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===Up.CONSTRAINED?Infinity:this.connectionCandidate?$.Nf.connectingSnapRadius:$.Nf.snapRadius}getLocalConnections(a){var b=a.getConnections_(!1),c=a.lastConnectionInStack(!0);c&&c!==a.nextConnection&& +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===Ho.DELETE&&Hh(this.block);this.originalEventGroup=$.ec;this.fireDragEndEvent();this.fireMoveEvent();lb();Jh();var c;(c=this.connectionPreviewer)==null||c.hidePreview();if(!this.block.isDeadOrDying()&&this.dragging&&b!==Ho.DELETE){let d;(d=this.workspace.getLayerManager())==null||d.moveOffDragLayer(this.block,50);this.getVisibleBubbles(this.block).forEach(e=> +{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&&b!==Ho.DELETE?(this.applyConnections(this.connectionCandidate),this.disposeStep()):(b!==Ho.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=$.ec;$.r(this.originalEventGroup);this.block.snapToGrid();var b;(b=this.connectionPreviewer)==null||b.dispose();this.workspace.setResizesEnabled(!0);$.r(a)}applyConnections(a){var {local:b,neighbour:c}=a;b.connect(c);var d=b.isSuperior()?c:b,e=this.block.getRootBlock();ac().then(()=>{Ih(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)==null||b.connect(this.block.nextConnection)}if(this.startParentConn)switch(this.startParentConn.type){case E.INPUT_VALUE:this.block.outputConnection&&this.startParentConn.connect(this.block.outputConnection);break;case E.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=> +{var d;return(d=this.workspace.getLayerManager())==null?void 0:d.moveOffDragLayer(c,100,!1)});Rh(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;$a($.C.ANNOUNCE_MOVE_CANCELED)}findTraversalCandidate(a){var b=this.getDirectionToNewLocation(D.sum(this.startLoc,a)),c=this.allConnectionPairs;if(b===Zi.NONE||!c.length)return this.connectionCandidate; +b=b===Zi.RIGHT||b===Zi.DOWN;var d=c.findIndex(f=>{var g,h;return((g=this.connectionCandidate)==null?void 0:g.local)===f.local&&((h=this.connectionCandidate)==null?void 0:h.neighbour)===f.neighbour}),e=this.block.workspace.getNavigator();return b?d===-1?this.isInTerminalPosition(this.block,Zi.DOWN)?e.getNavigationLoops()?this.pairToCandidate(c[0]):null:this.getClosestCandidate(this.block,a):d===c.length-1?null:this.pairToCandidate(c[d+1]):d===-1?this.isInTerminalPosition(this.block,Zi.UP)?e.getNavigationLoops()? +this.pairToCandidate(c[c.length-1]):null:this.getClosestCandidate(this.block,a):d===0?null:this.pairToCandidate(c[d-1])}isInTerminalPosition(a,b){if(a.getParent())return!1;var c=a.workspace.getTopBlocks(!0),d=a.getBoundingRectangle(),e=(b=b===Zi.UP)?"top":"bottom",f=b?(g,h)=>g<=h:(g,h)=>g>=h;b=c.filter(g=>g.id!==a.id&&f(g.getBoundingRectangle()[e],d[e]));c=a.getConnections_(!1);for(let g of b){b=this.getAllConnections(g);for(let h of c)for(let m of b)if(a.workspace.connectionChecker.canConnect(h, +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?Zi.LEFT:Zi.RIGHT:Math.abs(d)>0?d<0?Zi.UP:Zi.DOWN:Zi.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&& +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(`.${sb.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); +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= +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?Up.CONSTRAINED:Up.UNCONSTRAINED}enableAllDraggedBlocks(a){var b=$.fc;$.fc=!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))});$.fc=b}redisableAllDraggedBlocks(a){var b= +$.fc;$.fc=!1;a.getDescendants(!1).forEach(c=>{var d;(d=this.lastBlockDisabledReasons.get(c.id))==null||d.forEach(e=>{c.setDisabledReason(!0,e)})});$.fc=b}};var Xp=class extends pf{isLabelField(){return!0}constructor(a,b,c){super(pf.SKIP_SETUP);this.class=null;this.EDITABLE=!1;this.maxDisplayLength=Infinity;a!==pf.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&&v(this.getTextElement(),this.class);this.fieldGroup_&&(v(this.fieldGroup_,"blocklyLabelField"),u(this.fieldGroup_,w.HIDDEN,!0))}computeAriaLabel(a=!0){a=a?this.getAriaTypeName(): +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&&cb(this.textElement_,this.class),a&&v(this.textElement_,a));this.class=a}static fromJson(a){return new this(ef(a.text),void 0,a)}};Xg("field_label",Xp);Xp.prototype.DEFAULT_VALUE="";var Oi=class extends Wn{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 Wp(this);if(!a.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=a;this.svgGroup=z(x.G,{});b&&v(this.svgGroup, +b);this.style=a.getRenderer().getConstants().getBlockStyle(null);this.pathObject=a.getRenderer().makePathObject(this.svgGroup,this.style);a=this.pathObject.svgPath;a.tooltip=this;Ee(a);this.svgGroup.setAttribute("data-id",this.id);a.id=Aa();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); +(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();Gb(this)}unselect(){this.removeSelect();Gb(null)}setParent(a){var b=this.parentBlock_;if(a!==b){kb();super.setParent(a);lb();var c=this.getSvgRoot();if(!this.workspace.isClearing&&c){var d=$.A().getFocusedNode(), +e,f=this.getSvgRoot().contains((e=d==null?void 0:d.getFocusableElement())!=null?e:null);a?(a.getSvgRoot().appendChild(c),f&&d&&$.A().focusNode(d)):b&&(a=this.getRelativeToSurfaceXY(),this.workspace.getCanvas().appendChild(c),this.translate(a.x,a.y));f&&d&&$.A().focusNode(d);this.applyColour();this.recomputeAriaContext()}}}moveBy(a,b,c){if(this.parentBlock_)throw Error("Block has parent");var d=La(),e=null;d&&(e=new (t(q.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(),p(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(); +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, +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 Zc(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; +var b=this.getDescendants(!1);for(let c of b)if(c!==this&&(a==null||!a.has(c))&&c.getIcon(No.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?(v(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText($.C.COLLAPSED_WARNINGS_WARNING,Oi.COLLAPSED_WARNING_ID),a=this.toString(30),(b=this.getField("_TEMP_COLLAPSED_FIELD"))?b.setValue(a): +((this.getInput("_TEMP_COLLAPSED_INPUT")||this.appendDummyInput("_TEMP_COLLAPSED_INPUT")).appendField(new Xp(a),"_TEMP_COLLAPSED_FIELD"),this.recomputeAriaContext())):(this.updateDisabled(),this.removeInput("_TEMP_COLLAPSED_INPUT"),cb(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,Oi.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; +a&&window.open(a)}generateContextMenu(a){if(this.workspace.isReadOnly()||!this.contextMenu)return null;a=Xj.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=qd(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())== +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&&($.A().focusNode(b),b.showContextMenu(a))}else{b=this.generateContextMenu(a);var c=this.calculateContextMenuLocation(a);b&&b.length&&(Ff(a,b,this.RTL,this.workspace,c),Df=this)}}updateComponentLocations(a){this.xy.x=a.x;this.xy.y=a.y;this.dragging||this.updateConnectionLocations(a); +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){v(this.svgGroup,a)}removeClass(a){cb(this.svgGroup,a)}setDragging(a){(this.dragging=a)? +(this.translation="",ol.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(ol.length=0,this.removeClass("blocklyDragging"),this.getFullBlockField()&&this.recomputeAriaContext());for(let b=0;b!e.isDeadOrDying()),b= +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{if(this.workspace.rendered)if(e)c.focusNode(e);else{let f=this.getNearestNeighbour();f?c.focusNode(f):c.focusTree(this.workspace)}},0)}}disposeInternal(){this.disposing=!0;super.disposeInternal();$.A().getFocusedNode()===this&&this.workspace.cancelCurrentGesture();[...this.warningTextDb.values()].forEach(a=>clearTimeout(a)); +this.warningTextDb.clear();this.getIcons().forEach(a=>a.dispose())}checkAndDelete(){this.workspace.isFlyout||($.r(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),$.r(!1))}toCopyData(a=!1){return this.isInsertionMarker_?null:{paster:Yn.TYPE,blockState:Ng(this,{addCoordinates:!0,addNextBlocks:a,saveIds:!1}),typeCounts:Lb(this,!0)}}applyColour(){var a,b;(b=(a=this.pathObject).applyColour)==null||b.call(a,this);a=this.getIcons();for(b=0;b{this.isDeadOrDying()||(this.warningTextDb.delete(b),this.setWarningText(a,b))},100));else if(this.isInFlyout&&(a=null),c=this.getIcon(No.TYPE),a){let d=this.getSurroundParent(),e=null;for(;d;)d.isCollapsed()&&(e=d),d=d.getSurroundParent();e&&e.setWarningText($.C.COLLAPSED_WARNINGS_WARNING,Oi.COLLAPSED_WARNING_ID);c?c.addMessage(a,b):this.addIcon((new No(this)).addMessage(a,b))}else c&&(b?(c.addMessage("", +b),c.getText()||this.removeIcon(No.TYPE)):this.removeIcon(No.TYPE))}setMutator(a){this.removeIcon($.mh.TYPE);a&&this.addIcon(a)}addIcon(a){super.addIcon(a);a instanceof $.mh&&(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),$.A().focusNode(a))}}removeIcon(a){var b=super.removeIcon(a); +a.equals($.mh.TYPE)&&(this.mutator=null);this.queueRender();return b}setDisabledReason(a,b){var c=this.isEnabled();super.setDisabledReason(a,b);this.isEnabled()===c||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(a){super.setDeletable(a);a?cb(this.svgGroup,"blocklyNotDeletable"):v(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); +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_&&cb(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();v(this.svgGroup,a); +this.styleName_=a}else throw Error("Invalid style name: "+a);}getStyle(){return this.style}bringToFront(a=!1){var b=$.A().getFocusedNode();this.moveSvgRootToFront(a);b&&$.A().focusNode(b)}moveSvgRootToFront(a=!1){this.isDeadOrDying()||requestAnimationFrame(()=>{if(!this.dragging){var b=this;do{if(b.isDeadOrDying())break;let c=b.getSvgRoot(),d=c.parentNode;if(!d)break;let e=d.childNodes;if(e[e.length-1]!==c)for(;c.nextSibling;)d.insertBefore(c.nextSibling,c);if(a)break;b=b.getParent()}while(b)}})}setPreviousStatement(a, +b){super.setPreviousStatement(a,b);this.queueRender()}setNextStatement(a,b){super.setNextStatement(a,b);this.queueRender()}setOutput(a,b){super.setOutput(a,b);this.queueRender()}setInputsInline(a){super.setInputsInline(a);this.queueRender()}removeInput(a,b){a=super.removeInput(a,b);this.queueRender();return a}moveNumberedInputBefore(a,b){super.moveNumberedInputBefore(a,b);this.queueRender()}appendInput(a){super.appendInput(a);this.queueRender();return a}setConnectionTracking(a){this.previousConnection&& +this.previousConnection.setTracking(a);this.outputConnection&&this.outputConnection.setTracking(a);if(this.nextConnection){this.nextConnection.setTracking(a);var b=this.nextConnection.targetBlock();b&&b.setConnectionTracking(a)}if(!this.collapsed_)for(b=0;b{this.workspace.scrollBoundsIntoView(this.workspace.isFlyout?this.getBoundingRectangle():this.getBoundingRectangleWithoutChildren())})}onNodeBlur(){this.unselect()}canBeFocused(){return!0}performAction(a){if(this.workspace.isFlyout)Yi.mover.startMove(this, +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=gd(a.RTL?K.NAVIGATE_LEFT:K.NAVIGATE_RIGHT),b=$.C.KEYBOARD_NAV_BLOCK_NAVIGATION_HINT.replace("%1",b),Ri.show(a,{message:b,id:"blockNavigationHint"});else if(a=this.workspace,b=gd("list_shortcuts"))b=$.C.HELP_PROMPT.replace("%1",b),Ri.show(a,{message:b,id:"helpHint"})}}getParents(){for(var a= +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():(a=this.getAriaLabel(td.STANDARD), +!a||fd||a.endsWith(",")||(a+=","),u(this.getFocusableElement(),w.LABEL,a),Oa(this.getSvgRoot(),ab.NONE),a=this.getFocusableElement(),this.isInFlyout||Oa(a,ab.FIGURE),u(a,w.ROLEDESCRIPTION,this.getAriaRoleDescription()))}getAriaLabel(a){return zd(this,a)}getStackBlocksCountLabel(){for(var a=1,b=this.getNextBlock();b;)a++,b=b.getNextBlock();return a<=1?zd(this,td.TERSE):$.C.BLOCK_LABEL_STACK_BLOCKS.replace("%1",a.toString())}};Oi.INLINE=-1;Oi.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var Yp=class{constructor(){this.permanentlyDisabledBlocks=new Set;this.listeners=new Map;this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(a,b){this.setFlyout(b);var c=this.createBlock(a,b.getWorkspace());c.isEnabled()?this.updateStateBasedOnCapacity(c):this.permanentlyDisabledBlocks.add(c);c.getDescendants(!1).forEach(e=>{e.isInFlyout=!0;var f=e.getFocusableElement(),g=e.pathObject.svgPath;g!==f&&(u(g,w.HIDDEN,!0),Oa(g,ab.NONE));e===c?Oa(f,ab.OPTION):(u(f,w.HIDDEN,!0),Oa(f,ab.NONE))}); +a=c.getIcons().filter(e=>{var f;return(f=e.isClickableInFlyout)==null?void 0:f.call(e,b.autoClose)}).map(e=>e.getFocusableElement().id).filter(e=>!!e);var d=c.getConnections_(!0).map(e=>e.id);a=[...a,...d];a.length&&u(c.getFocusableElement(),w.OWNS,a);this.addBlockListeners(c);return new jo(c,"block")}createBlock(a,b){a.blockxml?(a=typeof a.blockxml==="string"?$.pc(a.blockxml):a.blockxml,b=Lf(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"]),"x"in a&&delete a.x,"y"in a&&delete a.y,b=Mf(a,b));return b}gapForItem(a,b){if(a.gap)var c=parseInt(String(a.gap));else a.blockxml&&(a=typeof a.blockxml==="string"?$.pc(a.blockxml):a.blockxml,c=parseInt(a.getAttribute("gap")));return!c||isNaN(c)?b:c}disposeItem(a){a=a.getElement();a instanceof Oi&&(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=> +la(c));this.listeners.delete(a)}setFlyout(a){if(this.flyout!==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(Lb(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,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(ka(a.getSvgRoot(),"pointermove",null,()=>{var c,d;((c=this.flyout)==null?0:(d=c.targetWorkspace)==null?0:d.isDragging())||a.addSelect()}));b.push(ka(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||a&&a.type!==q.BLOCK_CREATE&&a.type!==q.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(b=>{this.permanentlyDisabledBlocks.has(b)||this.updateStateBasedOnCapacity(b)})}getType(){return"block"}};n(l.FLYOUT_INFLATER,"block",Yp);var Zp={};Zp.Bubble=An;Zp.MiniWorkspaceBubble=Bn;Zp.TextBubble=$n;Zp.TextInputBubble=ao;var $p=class{load(a,b){a=new nj(b.getWorkspace(),b.targetWorkspace,a,!1);a.show();return new jo(a,"button")}gapForItem(a,b){return b}disposeItem(a){a=a.getElement();a instanceof nj&&a.dispose()}getType(){return"button"}};n(l.FLYOUT_INFLATER,"button",$p);var aq=class{canConnect(a,b,c,d){return this.canConnectWithReason(a,b,c,d)===Jn.CAN_CONNECT}canConnectWithReason(a,b,c,d){var e=this.doSafetyChecks(a,b);return e!==Jn.CAN_CONNECT?e:this.doTypeChecks(a,b)?c&&!this.doDragChecks(a,b,d||0)?Jn.REASON_DRAG_CHECKS_FAILED:Jn.CAN_CONNECT:Jn.REASON_CHECKS_FAILED}getErrorMessage(a,b,c){switch(a){case Jn.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Jn.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Jn.REASON_WRONG_TYPE:return"Attempt to connect incompatible types."; +case Jn.REASON_TARGET_NULL:return"Target connection is null.";case Jn.REASON_CHECKS_FAILED:return"Connection checks failed. "+(b+" expected "+b.getCheck()+", found "+c.getCheck());case Jn.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Jn.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Jn.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, +b){if(!a||!b)return Jn.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?Jn.REASON_SELF_CONNECTION:e.type!==On[a.type]?Jn.REASON_WRONG_TYPE:c.workspace!==d.workspace?Jn.REASON_DIFFERENT_WORKSPACES:c.isShadow()&&!d.isShadow()?Jn.REASON_SHADOW_PARENT:e.type===E.OUTPUT_VALUE&&d.previousConnection&&d.previousConnection.isConnected()||e.type===E.PREVIOUS_STATEMENT&&d.outputConnection&&d.outputConnection.isConnected()? +Jn.REASON_PREVIOUS_AND_OUTPUT:Jn.CAN_CONNECT}doTypeChecks(a,b){a=a.getCheck();b=b.getCheck();if(!a||!b)return!0;for(let c=0;cc||b.getSourceBlock().isInsertionMarker())return!1;switch(b.type){case E.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(a,b);case E.OUTPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isInsertionMarker()||a.isConnected())return!1;break;case E.INPUT_VALUE:if(b.isConnected()&&!b.targetBlock().isMovable()&& +!b.targetBlock().isShadow())return!1;break;case E.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!ol.includes(b)}canConnectToPrevious_(a,b){if(a.targetConnection||ol.includes(b))return!1;if(!b.targetConnection)return!0;a=b.targetBlock();return a.isInsertionMarker()?!a.getPreviousBlock():!1}}; +n(l.CONNECTION_CHECKER,"default",aq);var bq=class extends sp{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, +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= +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= +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= +6*this.GRID_UNIT;this.CURSOR_WS_WIDTH=20*this.GRID_UNIT;this.FIELD_TEXT_FONTSIZE=3*this.GRID_UNIT;this.FIELD_BORDER_RECT_RADIUS=this.CORNER_RADIUS;this.FIELD_BORDER_RECT_X_PADDING=2*this.GRID_UNIT;this.FIELD_BORDER_RECT_Y_PADDING=1.625*this.GRID_UNIT;this.FIELD_BORDER_RECT_HEIGHT=8*this.GRID_UNIT;this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=8*this.GRID_UNIT;this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING;this.FIELD_COLOUR_DEFAULT_WIDTH=6*this.GRID_UNIT;this.FIELD_COLOUR_DEFAULT_HEIGHT= +8*this.GRID_UNIT;this.FIELD_CHECKBOX_X_OFFSET=1*this.GRID_UNIT;this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH=12*this.GRID_UNIT}setFontConstants_(a){super.setFontConstants_(a);this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+this.FIELD_BORDER_RECT_Y_PADDING*2}init(){super.init();this.HEXAGONAL=this.makeHexagonal();this.ROUNDED=this.makeRounded();this.SQUARED=this.makeSquared();this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(a){super.setDynamicProperties_(a); +this.SELECTED_GLOW_COLOUR=a.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;this.SELECTED_GLOW_SIZE=(a=Number(a.getComponentStyle("selectedGlowSize")))&&!isNaN(a)?a:this.SELECTED_GLOW_SIZE}dispose(){super.dispose();this.selectedGlowFilter&&fb(this.selectedGlowFilter)}makeStartHat(){var a=this.START_HAT_HEIGHT,b=this.START_HAT_WIDTH,c=yh("c",[G(25,-a),G(71,-a),G(b,0)]);return{height:a*.75,width:b,path:c}}makeHexagonal(){function a(c,d,e){var f=c/2;f=f>b?b:f;e=e?-1:1;c=(d?-1:1)*c/ +2;return Bh(-e*f,c)+Bh(e*f,c)}var b=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(c){c/=2;return c>b?b:c},height(c){return c},connectionOffsetY(c){return c/2},connectionOffsetX(c){return-c},pathDown(c){return a(c,!1,!1)},pathUp(c){return a(c,!0,!1)},pathRightDown(c){return a(c,!1,!0)},pathRightUp(c){return a(c,!1,!0)}}}makeRounded(){function a(d,e,f){var g=d>c?d-c:0;d=(d>c?c:d)/2;var h=f===e?"0":"1";return Dh("a","0 0,"+h,d,G((f?1:-1)*d,(e?-1:1)*d))+ +H("v",(e?-1:1)*g)+Dh("a","0 0,"+h,d,G((f?-1:1)*d,(e?-1:1)*d))}var b=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,c=b*2;return{type:this.SHAPES.ROUND,isDynamic:!0,width(d){d/=2;return d>b?b:d},height(d){return d},connectionOffsetY(d){return d/2},connectionOffsetX(d){return-d},pathDown(d){return a(d,!1,!1)},pathUp(d){return a(d,!0,!1)},pathRightDown(d){return a(d,!1,!0)},pathRightUp(d){return a(d,!1,!0)}}}makeSquared(){function a(c,d,e){c-=b*2;var f=e===d?"0":"1";return Dh("a","0 0,"+f,b,G((e?1:-1)*b,(d? +-1:1)*b))+H("v",(d?-1:1)*c)+Dh("a","0 0,"+f,b,G((e?-1:1)*b,(d?-1:1)*b))}var b=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(){return b},height(c){return c},connectionOffsetY(c){return c/2},connectionOffsetX(c){return-c},pathDown(c){return a(c,!1,!1)},pathUp(c){return a(c,!0,!1)},pathRightDown(c){return a(c,!1,!0)},pathRightUp(c){return a(c,!1,!0)}}}shapeFor(a){var b=a.getCheck();!b&&a.targetConnection&&(b=a.targetConnection.getCheck());switch(a.type){case E.INPUT_VALUE:case E.OUTPUT_VALUE:a= +a.getSourceBlock().getOutputShape();if(a!==null)switch(a){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}if(b&&b.includes("Boolean"))return this.HEXAGONAL;if(b&&b.includes("Number"))return this.ROUNDED;b&&b.includes("String");return this.ROUNDED;case E.PREVIOUS_STATEMENT:case E.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type");}}makeNotch(){function a(y){return yh("c",[G(y*e/2,0),G(y*e*3/4, +g/2),G(y*e,g)])+Ch([G(y*e,f)])+yh("c",[G(y*e/4,g/2),G(y*e/2,g),G(y*e,g)])+H("h",y*d)+yh("c",[G(y*e/2,0),G(y*e*3/4,-(g/2)),G(y*e,-g)])+Ch([G(y*e,-f)])+yh("c",[G(y*e/4,-(g/2)),G(y*e/2,-g),G(y*e,-g)])}var b=this.NOTCH_WIDTH,c=this.NOTCH_HEIGHT,d=b/3,e=d/3,f=c/2,g=f/2,h=a(1),m=a(-1);return{type:this.SHAPES.NOTCH,width:b,height:c,pathLeft:h,pathRight:m}}makeInsideCorners(){var a=this.CORNER_RADIUS,b=Dh("a","0 0,0",a,G(-a,a)),c=Dh("a","0 0,1",a,G(-a,a)),d=Dh("a","0 0,0",a,G(a,a)),e=Dh("a","0 0,1",a,G(a, +a));return{width:a,height:a,pathTop:b,pathBottom:d,rightWidth:a,rightHeight:a,pathTopRight:c,pathBottomRight:e}}generateSecondaryColour_(a){return Ze("#000",a,.15)||a}generateTertiaryColour_(a){return Ze("#000",a,.25)||a}createDom(a,b,c){super.createDom(a,b,c);a=z(x.DEFS,{},a);a=z(x.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},a);z(x.FEGAUSSIANBLUR,{"in":"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},a);b=z(x.FECOMPONENTTRANSFER, +{result:"outBlur"},a);z(x.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},b);z(x.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},a);z(x.FECOMPOSITE,{"in":"outColor",in2:"outBlur",operator:"in",result:"outGlow"},a);this.selectedGlowFilterId=a.id;this.selectedGlowFilter=a;c&&c.style.setProperty("--blocklySelectedGlowFilter",`url(#${this.selectedGlowFilterId})`)}getCSS_(a){return[`${a} .blocklyText,`,`${a} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`, +"}",`${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;", +"}",`${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;", +"}",`${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;", +"}",`${a} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}"]}};var cq=class extends tp{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&& +!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: +0);b=b?e.pathBottomRight:"";a=c>0?H("V",a.yPos+c):"";this.outlinePath_+=b+a+(d?e.pathTopRight:"");return}}this.outlinePath_+=H("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"); +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_+=Ah(a.xPos,this.info_.startY);this.outlinePath_+=H("h",a.width)}drawFlatBottom_(){var a=this.info_.bottomRow;this.positionNextConnection_();this.outlinePath_+=H("V",a.baseline);this.outlinePath_+=H("h",-a.width)}drawInlineInput_(a){this.positionInlineInputConnection_(a); +var b=a.input.name;a.connectedBlock||this.info_.isInsertionMarker||(a=zh(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 H("h",b)+a.shape.pathRightDown(c)+H("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+H("h",-(b.notchOffset-d.width))+ +d.pathTop,f=a.height-2*d.height;b=d.pathBottom+H("h",b.notchOffset-d.width)+(b.connectedBottomNextConnection?"":b.shape.pathLeft);this.outlinePath_+=H("H",c)+e+H("v",f)+b+H("H",a.xPos+a.width);this.positionStatementInputConnection_(a)}drawConnectionHighlightPath(a){var b=a.connectionModel;if(b.type===E.NEXT_STATEMENT||b.type===E.PREVIOUS_STATEMENT||b.type===E.OUTPUT_VALUE&&!a.isDynamicShape)return super.drawConnectionHighlightPath(a);a=b.type===E.INPUT_VALUE?zh(a.connectionWidth,-a.height/2)+this.getInlineInputPath(a): +zh(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 dq=class extends pf{constructor(a,b,c,d,e,f,g){super(pf.SKIP_SETUP);this.imageElement=this.clickHandler=null;this.flipRtl=this.isDirty_=this.EDITABLE=!1;this.altText="";c=Number(ef(c));b=Number(ef(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 Pc(b,c+dq.Y_PADDING);this.imageHeight=c;typeof e==="function"&&(this.clickHandler=e); +a!==pf.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"?ef(d)||"":""),this.setValue(ef(a)))}configure_(a){super.configure_(a);a.flipRtl&&(this.flipRtl=a.flipRtl);a.alt&&(this.altText=ef(a.alt))}initView(){this.imageElement=z(x.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_);this.imageElement.setAttributeNS("http://www.w3.org/1999/xlink", +"xlink:href",this.value_);this.fieldGroup_&&v(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&& +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|| +$.C.ARIA_TYPE_FIELD_IMAGE}getAriaValue(){return this.altText||null}computeAriaLabel(a){var b=this.getAriaValue();return this.isClickable()||!b?"":(a=a?this.getAriaTypeName():null)?`${a}: ${b}`:b}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement();if(!this.isClickable())return Oa(a,ab.NONE),Pa(a,w.LABEL),!1;var b=this.getAriaValue()||"";u(a,w.LABEL,b);return!0}};dq.Y_PADDING=1;Xg("field_image",dq);dq.prototype.DEFAULT_VALUE="";var eq=class extends pf{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(pf.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!==pf.SKIP_SETUP&&(c&&this.configure_(c),this.setValue(a),b&&this.setValidator(b))}configure_(a){super.configure_(a); +a.spellcheck!==void 0&&(this.spellcheck_=a.spellcheck)}initView(){if(!this.getSourceBlock())throw new ii;this.isFullBlockField()||this.createBorderRect_();this.createTextElement_();this.fieldGroup_&&v(this.fieldGroup_,"blocklyField");this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot());this.fieldGroup_&&v(this.fieldGroup_,"blocklyInputField");this.recomputeAriaContext()}isFullBlockField(){var a=this.getSourceBlock();if(!a)throw new ii;var b;return this.fullBlockClickTarget_= +!((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=z(x.SVG,{"class":"blocklyInputWarning",viewBox:"-4 0 24 16",x:"0",y:"0",height:`${a}px`,width:`${a}px`});z(x.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);z(x.PATH,{"class":"blocklyInputWarningIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},a); +z(x.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_&&La()&&this.value_!==a&&b&&p(new (t(q.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= +this.getSourceBlock();if(!a)throw new ii;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_(); +var a=this.getSourceBlock();if(!a)throw new ii;if(this.isBeingEdited_){let b=this.htmlInput_;this.renderWarningIcon(a.RTL,this.isTextValid_);this.isTextValid_?(cb(b,"blocklyInvalidInput"),u(b,w.INVALID,!1)):(v(b,"blocklyInvalidInput"),u(b,w.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="",cb(this.warningIcon,"blocklyInputWarningInvalid");else{b=this.getScaledBBox(); +var d=b.bottom-b.top;d=(b=!!this.borderRect_)?this.getConstants().FIELD_BORDER_RECT_X_PADDING:d/2;v(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_= +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&&(Vk||Uk||Sj)?this.showPromptEditor():this.showInlineEditor(b,c)}showPromptEditor(){Kc($.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 ii;sf(this,c.RTL,this.widgetDispose_.bind(this), +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 ii;$.r(!0);var b=kf,c=this.getClickTarget_();if(!c)throw Error("A click target has not been set.");v(c,"blocklyEditing");c=document.createElement("input");c.className="blocklyHtmlInput";c.setAttribute("spellcheck",this.spellcheck_);this.warningIcon= +this.createWarningIcon();var d=this.workspace_.getAbsoluteScale(),e=this.getConstants().FIELD_TEXT_FONTSIZE*d+"pt";b.style.fontSize=e;c.style.fontSize=e;e=eq.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= +"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(); +this.onFinishEditing_(this.value_);this.sourceBlock_&&La()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(p(new (t(q.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null);$.r(!1);this.unbindInputEvents_();var a=kf.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."); +cb(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&&(la(this.onKeyDownWrapper),this.onKeyDownWrapper=null);this.onInputWrapper&&(la(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(a){if(a.key==="Enter")tf(this),le(),a.stopPropagation();else if(a.key==="Escape")this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"), +!1),tf(this),le();else if(a.key==="Tab"){a.preventDefault();var b;let c=(b=this.workspace_)==null?void 0:b.getNavigator(),d=e=>(e instanceof eq||e instanceof Oi&&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 Oi&&b.isSimpleReporter()?b.getFields().next().value:b;b instanceof eq&&(tf(this),le(),a=b.getSourceBlock(),b.isFullBlockField()&&a&&a instanceof Oi?$.A().focusNode(a):$.A().focusNode(b), +b.showEditor())}}onHtmlInputChange(){var a=this.value_;this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1);this.sourceBlock_&&La()&&this.value_!==a&&p(new (t(q.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_(){ac().then(()=>{var a=this.getSourceBlock();if(!a)throw new ii;var b=kf;if(b){var c=this.getScaledBBox(); +b.style.width=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&&({x:a,y:c}=ad(a,c,d));b.style.left=`${a}px`;b.style.top=`${c}px`}})}repositionForWindowResize(){var a=this.getSourceBlock(),b=this.workspace_;if(!(a instanceof Oi))return!1;this.resizeEditor_();a=this.getClickTarget_();if(!a||!b)return!0;a=Zc.from(a.getBoundingClientRect());var c=pd(b,a.getOrigin()),d=b.scale;b.scrollBoundsIntoView(Zc.createFromPoint(c, +a.getWidth()/d,a.getHeight()/d));return!0}positionTextElement_(a,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()&&!((c=this.getSourceBlock())==null?0:c.isInFlyout);if(this.isFullBlockField()){if(c=zd(this.getSourceBlock(),td.STANDARD,b),d){b=c.split(", ");d=ud(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));u(a,w.LABEL,b);return!0}};eq.BORDERRADIUS=4;wc("\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 fq=class extends Wo{constructor(a){super(a)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(a){return!!a.outputConnection}hasRightSquareCorner(a){return!!a.outputConnection&&!a.statementInputCount&&!a.nextConnection}};var lk=class extends mp{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 gq=class extends Uo{constructor(a){super(a);this.width=this.height=0;this.type|=Q.getType("RIGHT_CONNECTION")}};var hq=class extends np{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 iq=class extends up{constructor(a,b){super(a,b);this.isInline=!0;this.renderer_=a;this.constants_=this.renderer_.getConstants();this.topRow=new hq(this.constants_);this.bottomRow=new fq(this.constants_);this.isMultiRow=!b.getInputsInline()||b.isCollapsed();this.hasStatementInput=b.statementInputCount>0;this.rightSide=this.outputConnection?new gq(this.constants_):null;this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_();this.addElemSpacing_(); +this.addRowSpacing_();this.adjustXPosition_();this.computeBounds_();this.alignRowElements_();this.finalize_()}shouldStartNewRow_(a,b){return b?b instanceof Tn||a instanceof Un||b instanceof Un?!0:a instanceof $.Vn||a instanceof Sn||a instanceof Tn?!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|| +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; +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- +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+ +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 Sn||a instanceof Tn)&&b.hasDummyInput&&b.align===$.Mn.LEFT&&a.align===$.Mn.RIGHT)this.rightAlignedDummyInputs.set(b,a);else if(a instanceof Un){b.elements.push(new lk(this.constants_,a));b.hasStatement=!0;b.align===null&&(b.align=a.align);return}super.addInput_(a,b)}addAlignmentPadding_(a, +b){if(this.rightAlignedDummyInputs.get(a)){let c;for(let d=0;d=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;g1)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=Wj(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== +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 eq)return b-2.75*d.GRID_UNIT;let f=e=this.constants_.SHAPE_IN_SHAPE_PADDING[c][0];c===d.SHAPES.ROUND&&(c=Wj(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= +2;d=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 $o&&(c.field instanceof Xp||c.field instanceof dq);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=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 jq=class extends vp{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(); +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=z(x.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:ab.NONE}, +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){if(!this.outlines.has(a)){let b= +z(x.PATH,{"class":"blocklyOutlinePath",d:""},this.svgRoot);u(b,w.HIDDEN,!0);this.outlines.set(a,b)}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 kq=class extends wp{constructor(a){super(a)}makeConstants_(){return new bq}makeRenderInfo_(a){return new iq(this,a)}makeDrawer_(a,b){return new cq(a,b)}makePathObject(a,b){return new jq(a,b,this.getConstants())}getConstants(){return this.constants_}shouldHighlightConnection(a){return super.shouldHighlightConnection(a)||a.type===E.INPUT_VALUE}};ri("zelos",kq);var lq={};lq.BottomRow=fq;lq.ConstantProvider=bq;lq.Drawer=cq;lq.PathObject=jq;lq.RenderInfo=iq;lq.Renderer=kq;lq.RightConnectionShape=gq;lq.StatementInput=lk;lq.TopRow=hq;vk();var mq={};mq.registerCleanup=ak;mq.registerCollapse=ck;mq.registerCollapseExpandBlock=ok;mq.registerComment=kk;mq.registerCommentCreate=uk;mq.registerCommentDelete=sk;mq.registerCommentDuplicate=tk;mq.registerCommentOptions=function(){tk();sk();uk()};mq.registerDefaultOptions=vk;mq.registerDelete=qk;mq.registerDeleteAll=hk;mq.registerDisable=pk;mq.registerDuplicate=ik;mq.registerExpand=dk;mq.registerHelp=rk;mq.registerInline=nk;mq.registerRedo=Zj;mq.registerUndo=Yj;var nq=class{constructor(a){this.draggable=a;this.dragTarget=null;this.revertShouldDelete=!1;a instanceof Oi&&a.workspace.isFlyout&&(this.revertShouldDelete=!0);this.startLoc=a.getRelativeToSurfaceXY()}onDragStart(a){$.ec||$.r(!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),Vh(this.draggable)&&this.draggable.setDeleteStyle(this.wouldDeleteDraggable(a, +this.draggable)),this.updateDragTarget(a)}updateDragTarget(a){a=this.draggable.workspace.getDragTarget(a);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, +co.Capability.DELETE_AREA)?a.wouldDelete(b):!1}onDragEnd(a){var b=$.ec,c=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=Vh(this.draggable)&&this.wouldDeleteDraggable(c,this.draggable))&&Vh(this.draggable)?(this.draggable.endDrag(a,Ho.DELETE),$.r(b),this.draggable.dispose()):this.draggable.endDrag(a, +d?Ho.REVERT:Ho.COMMIT);$.r(!1);!c&&tb(this.draggable)&&$.A().focusNode(this.draggable)}else this.draggable.endDrag(a,Ho.COMMIT),tb(this.draggable)&&$.A().focusNode(this.draggable)}onDragRevert(a){this.revertShouldDelete&&Vh(this.draggable)?(this.draggable.endDrag(a,Ho.DELETE),this.draggable.dispose()):(this.draggable.revertDrag(),tb(this.draggable)&&$.A().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}};n(l.BLOCK_DRAGGER,"default",nq);var oq={};oq.BlockDragStrategy=Wp;oq.BubbleDragStrategy=yn;oq.CommentDragStrategy=Xl;oq.Dragger=nq;var pq=class extends pf{constructor(a,b,c){super(pf.SKIP_SETUP);this.SERIALIZABLE=!0;this.value_=this.value_;this.checkChar=pq.CHECK_CHAR;a!==pf.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(pq);return a!==null?a:this.getValueBoolean()}initView(){super.initView();var a=this.getTextElement();v(this.fieldGroup_,"blocklyCheckboxField");a.style.display= +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||pq.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_&& +(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, +void 0,a)}recomputeAriaContext(){if(!super.recomputeAriaContext())return!1;var a=this.getFocusableElement();u(a,w.HIDDEN,!1);Oa(a,ab.CHECKBOX);var b=this.convertValueToBool(this.value_);u(a,w.CHECKED,b);b=this.getAriaTypeName();u(a,w.LABEL,b);return!0}};pq.CHECK_CHAR="\u2713";Xg("field_checkbox",pq);pq.prototype.DEFAULT_VALUE=!1;var qq=class extends Xp{constructor(a,b,c){super(String(a!=null?a:""),b,c);this.EDITABLE=!1;this.SERIALIZABLE=!0}static fromJson(a){return new this(ef(a.text),void 0,a)}};Xg("field_label_serializable",qq);var rq=class extends eq{constructor(a,b,c,d,e,f){super(pf.SKIP_SETUP);this.min_=-Infinity;this.max_=Infinity;this.precision_=0;this.decimalPlaces=null;this.spellcheck_=!1;a!==pf.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); +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)|| +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_)* +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_Math.max(b,c.getElement().getBoundingRectangle().getHeight()),0);a+=this.MARGIN*1.5;a*=this.workspace_.scale;a+=yi.scrollbarThickness;this.getHeight()!==a&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!== +I.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+a),this.height_=a,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}alignContentsRight(){var a=this.getContents().map(e=>e.getElement().getBoundingRectangle());if(a.length){var b=Math.min(...a.map(e=>e.left));a=Math.max(...a.map(e=>e.right));var c=this.getWidth()/this.workspace_.scale,d=this.MARGIN+this.tabWidth_;a=Math.max(d,c-d-(a-b));for(let e of this.getContents())e.getElement().moveBy(a- +b,0)}}};n(l.FLYOUTS_HORIZONTAL_TOOLBOX,"default",uq);var vq=class extends Go{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(); +return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===I.LEFT?a.width:c.width-this.getWidth():this.toolboxPosition_===I.LEFT?0:c.width:this.toolboxPosition_===I.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, +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_===I.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); +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=qa(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);uf(this.workspace_);le()}a.preventDefault();a.stopPropagation()}layout_(a){this.workspace_.scale=this.targetWorkspace.scale;var b=this.MARGIN,c=this.RTL?b:b+this.tabWidth_; +for(let e of a){var d=e.getElement().getBoundingRectangle();a=c-d.left;d=b-d.top;e.getElement().moveBy(a,d);b+=e.getElement().getBoundingRectangle().getHeight()}}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;var a=this.svgGroup_.getBoundingClientRect(),b=a.left;return this.toolboxPosition_===I.LEFT?new Zc(-1E9,1E9,-1E9,b+a.width):new Zc(-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*1.5+this.tabWidth_;a*=this.workspace_.scale;a+=yi.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_!==I.LEFT|| +this.targetWorkspace.translate(this.targetWorkspace.scrollX+a,this.targetWorkspace.scrollY);this.width_=a;this.position();this.targetWorkspace.resizeContents();this.targetWorkspace.recordDragTargets()}}};vq.registryName="verticalFlyout";n(l.FLYOUTS_VERTICAL_TOOLBOX,"default",vq);$.wq=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|| +(console.warn("No workspace specified in workspaceToCode call. Guessing."),a=Cb);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/, +"");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.blocklyPathLight,`,`${a} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}};var Bq=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_= +this.highlightConstants_.START_HAT;this.jaggedTeethPaths_=this.highlightConstants_.JAGGED_TEETH}getPath(){return this.steps_+"\n"+this.inlineSteps_}drawTopCorner(a){this.steps_+=Ah(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_): +Q.isSpacer(c)&&c.width!==0&&(this.steps_+=H("H",c.xPos+c.width-this.highlightOffset));this.steps_+=H("H",a.xPos+a.width-this.highlightOffset)}drawJaggedEdge_(a){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+H("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_+=zh(b.xPos+b.width-this.highlightOffset,a.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+H("v",c)}else this.steps_+= +zh(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_+=zh(b.xPos,a.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+H("v",c)+this.insideCornerPaths_.pathBottom(this.RTL_)+Bh(a.width-b.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=zh(b.xPos,a.yPos+a.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Bh(a.width-b.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(a){var b= +a.xPos+a.width-this.highlightOffset;a instanceof kp&&a.followsStatement&&(this.steps_+=H("H",b));this.RTL_&&(this.steps_+=H("H",b),a.height>this.highlightOffset&&(this.steps_+=H("V",a.yPos+a.height-this.highlightOffset)))}drawBottomRow(a){if(this.RTL_)this.steps_+=H("V",a.baseline-this.highlightOffset);else{let b=this.info_.bottomRow.elements[0];Q.isLeftSquareCorner(b)?this.steps_+=zh(a.xPos+this.highlightOffset,a.baseline-this.highlightOffset):Q.isLeftRoundedCorner(b)&&(this.steps_+=zh(a.xPos,a.baseline), +this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var a=this.info_.outputConnection;a&&(a=a.connectionOffsetY+a.height,this.RTL_?this.steps_+=zh(this.info_.startX,a):(this.steps_+=zh(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=H("V",a)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_));this.RTL_||(a=this.info_.topRow,Q.isLeftRoundedCorner(a.elements[0])?this.steps_+=H("V",this.outsideCornerPaths_.height):this.steps_+=H("V", +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_+=zh(c-b,f)+H("v",d)+this.puzzleTabPaths_.pathDown(this.RTL_)+H("v",a)+H("h",e)):this.inlineSteps_+=zh(a.xPos+a.width+b,f)+H("v",a.height)+H("h",-e)+zh(c,d+a.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}};var Cq=class extends tp{constructor(a,b){super(a,b);this.highlighter_=new Bq(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); +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_+=H("H",a.xPos+a.width)+H("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); +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, +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 Dq=class{constructor(a){this.OFFSET=.5;this.constantProvider=a;this.START_POINT=Ah(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=Ah(c,c)+Dh("a","0 0,0",a,G(-c-b,a-c)),e=Dh("a","0 0,0", +a+b,G(a+b,a+b)),f=Ah(c,-c)+Dh("a","0 0,0",a+b,G(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=Ah(c,c)+Dh("a","0 0,1",a-b,G(a-c,-c+b)),e=Ah(b,a)+Dh("a","0 0,1",a-b,G(a,-a+b)),f=-c,g=Ah(c,f)+Dh("a","0 0,1",a-b,G(-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, +c=Ah(-2,-b+2.5+.9)+Bh(a*-.45,-2.1),d=H("v",2.5)+Ah(-a*.97,2.5)+yh("q",[G(-a*.05,10),G(a*.3,9.5)])+Ah(a*.67,-1.9)+H("v",2.5),e=H("v",-1.5)+Ah(a*-.92,-.5)+yh("q",[G(a*-.19,-5.5),G(0,-11)])+Ah(a*.92,1),f=Ah(-5,b-.7)+Bh(a*.46,-2.1);return{width:a,height:b,pathUp(g){return g?c:e},pathDown(g){return g?d:f}}}makeNotch(){return{pathLeft:H("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Bh(5.1,2.6)+Ah(-10.2,6.8)+Bh(5.1,2.6),height:12,width:10.2}}makeStartHat(){var a= +this.constantProvider.START_HAT.height,b=Ah(25,-8.7)+yh("c",[G(29.7,-6.2),G(57.2,-.5),G(75,8.7)]),c=yh("c",[G(17.8,-9.2),G(45.3,-14.9),G(75,-8.7)])+zh(100.5,a+.5);return{path(d){return d?b:c}}}};var Eq=class extends dp{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 Fq=class extends mp{constructor(a,b){super(a,b);this.constants_=a;this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}};var Gq=class extends up{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 Un||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(a,b){if(this.isInline&&a instanceof $.Vn)b.elements.push(new Eq(this.constants_,a)),b.hasInlineInput=!0;else if(a instanceof Un)b.elements.push(new Fq(this.constants_, +a)),b.hasStatement=!0;else if(a instanceof $.Vn)b.elements.push(new Zo(this.constants_,a)),b.hasExternalInput=!0;else if(a instanceof Sn||a instanceof Tn)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 cp(this.constants_, +this.getInRowSpacing_(null,b[0])));if(b.length){for(let e=0;e0&&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= +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{if(!d.isDeadOrDying()){$.Ka++;try{d==null||d.positionNearConnection(e,f,g),d==null||d.getSvgRoot().setAttribute("visibility","visible")}finally{$.Ka--}}});return e}serializeBlockToInsertionMarker(a){var b=Ng(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= +this.serializeBlockToInsertionMarker(a);a=Og(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;dEk(b));return a.length?a:null}load(a,b){var c=b.getProcedureMap();for(let d of a)c.add(Fk(this.procedureModelClass,this.parameterModelClass,d,b))}clear(a){a.getProcedureMap().clear()}},Pq={};Pq.ProcedureSerializer=Oq;Pq.loadProcedure=Fk;Pq.saveProcedure=Ek;var Qq=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=ua(l.VARIABLE_MODEL,"default",void 0);a.forEach(d=>{c==null||c.load(d,b)})}clear(a){a.getVariableMap().clear()}};Nc("variables",new Qq);var Rq={};Rq.VariableSerializer=Qq;var Sq={blocks:pn,exceptions:nn,priorities:{BLOCKS:50,PROCEDURES:75,VARIABLES:100,WORKSPACE_COMMENTS:25},procedures:Pq,registry:El,variables:Rq,workspaceComments:Gl,workspaces:{load:function(a,b,{recordUndo:c=!1}={}){var d=xa(l.SERIALIZER,!0);if(d){d=Object.entries(d).sort((f,g)=>g[1].priority-f[1].priority);var e=$.fc;$.fc=c;(c=$.ec)||$.r(!0);kb();b instanceof Gi&&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|| +h.load(a[f],b)}b instanceof Gi&&b.setResizesEnabled(!0);lb();p(new (t(q.FINISHED_LOADING))(b));$.r(c);$.fc=e}},save:function(a){var b=Object.create(null),c=xa(l.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}}};var Tq=new tn("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", +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"}, +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 Uq={Classic:un,Zelos:Tq};var Vq=class{constructor(a,b,c){this.id_=a.toolboxitemid||Aa();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."); +if(!(a instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return a}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){this.getFocusableElement().scrollIntoView({block:"nearest",inline:"nearest"})}onNodeBlur(){}canBeFocused(){return!0}getParentToolbox(){return this.parentToolbox_}};var Wq=class extends Vq{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", +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>>/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("<<>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxSelected .blocklyToolboxCategoryLabel {\n color: #fff;\n}\n'); +n(l.TOOLBOX_ITEM,Wq.registrationName,Wq);var Xq=class extends Vq{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&&v(a,b);Oa(a,ab.NONE);return this.htmlDiv=a}getDiv(){return this.htmlDiv}dispose(){fb(this.htmlDiv)}canBeFocused(){return!1}};Xq.registrationName="sep";wc('\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'); +n(l.TOOLBOX_ITEM,Xq.registrationName,Xq);var Yq=class extends Wq{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;c0){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_}}; +Yq.registrationName="collapsibleCategory";n(l.TOOLBOX_ITEM,Yq.registrationName,Yq);var Zq=class extends io{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 Do(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= +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);v(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, +weight:co.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[co.Capability.AUTOHIDEABLE,co.Capability.DELETE_AREA,co.Capability.DRAG_TARGET]});$.A().registerTree(this,!0)}createDom_(a){a=a.getParentSvg();var b=this.createContainer_();b.id=Aa();this.contentsDiv_=this.createContentsContainer_();Oa(this.contentsDiv_,ab.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"); +a.setAttribute("layout",this.isHorizontal()?"h":"v");v(a,"blocklyToolbox");a.setAttribute("dir",this.RTL?"RTL":"LTR");return a}createContentsContainer_(){var a=document.createElement("div");v(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=ka(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= +()=>{$.A().focusNode(this);this.clearSelection();Cb.hideChaff(!1);a.preventDefault()};this.mouseDown=!0;if(oa(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),Cb.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":$.A().focusTree(this.getWorkspace()), +b=!0}b&&(a.preventDefault(),a.stopPropagation())}createFlyout_(){var a=this.workspace_,b=a.copyOptionsForFlyout();b.toolboxPosition=a.options.toolboxPosition;return new (a.horizontalLayout?ya(l.FLYOUTS_HORIZONTAL_TOOLBOX,a.options,!0):ya(l.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(); +for(let d=0;d{a.refreshTheme&&a.refreshTheme()})}refreshSelection(){if(this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length){let a;(a=this.flyout)==null||a.show(this.selectedItem_.getContents())}}setVisible(a){this.isVisible_!==a&&(this.HtmlDiv&&(this.HtmlDiv.style.display=a?"block":"none"),this.isVisible_=a,this.workspace_.resize(),this.workspace_.recordDragTargets())}autoHide(a){!a&& +this.flyout&&this.flyout.autoClose&&this.clearSelection()}setSelectedItem(a){var b=this.selectedItem_;!a&&!b||a&&!sd(a)||(this.shouldDeselectItem_(b,a)&&b!==null&&this.deselectItem_(b),this.shouldSelectItem_(b,a)&&a!==null&&this.selectItem_(b,a),this.updateFlyout_(b,a),this.fireSelectEvent(b,a))}shouldDeselectItem_(a,b){return a!==null&&(!a.isCollapsible()||a!==b)}shouldSelectItem_(a,b){return b!==null&&b!==a}deselectItem_(a){this.selectedItem_=null;this.previouslySelectedItem_=a;a.setSelected(!1); +u(this.contentsDiv_,w.ACTIVEDESCENDANT,"")}selectItem_(a,b){this.selectedItem_=b;this.previouslySelectedItem_=a;b.setSelected(!0);u(this.contentsDiv_,w.ACTIVEDESCENDANT,b.getId())}selectItemByPosition(a){(a=this.getToolboxItems()[a])&&this.setSelectedItem(a)}updateFlyout_(a,b){if(b&&(a!==b||b.isCollapsible())&&b.getContents().length){let c;(c=this.flyout)==null||c.show(b.getContents());let d;(d=this.flyout)==null||d.scrollToStart()}else{let c;(c=this.flyout)==null||c.hide()}}fireSelectEvent(a,b){var c= +a&&a.getName(),d=b&&b.getName();a===b&&(d=null);a=new (t(q.TOOLBOX_ITEM_SELECT))(c,d,this.workspace_.id);p(a)}toggleSelectedItem(a){var b,c;return Yh(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;ac.isSelectable()))!= +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}};wc('\n.blocklyToolboxDelete {\n cursor: url("<<>>/handdelete.cur"), auto;\n}\n\n.blocklyToolboxGrab {\n cursor: url("<<>>/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'); +n(l.TOOLBOX,"default",Zq);var $q=class extends io{constructor(a){super();this.workspace=a;this.id="trashcan";this.uniqueId=Aa();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===I.TOP?I.BOTTOM:I.TOP,this.flyout=new (ya(l.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(a)):(a.toolboxPosition= +this.workspace.toolboxPosition===I.RIGHT?I.LEFT:I.RIGHT,this.flyout=new (ya(l.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(a)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=z(x.G,{"class":"blocklyTrash",tabindex:"0",id:this.uniqueId});z(x.RECT,{width:55,height:68,x:-4,y:-4,rx:2,ry:2,fill:"none","class":"blocklyFocusRing"},this.svgGroup);Oa(this.svgGroup,ab.BUTTON);u(this.svgGroup,w.LABEL,$.C.ARIA_LABEL_TRASH_EMPTY);u(this.svgGroup,w.DISABLED,!0);var a= +String(Math.random()).substring(2);var b=z(x.CLIPPATH,{id:"blocklyTrashBodyClipPath"+a},this.svgGroup);z(x.RECT,{width:47,height:44,y:16},b);z(x.IMAGE,{width:Hp.width,x:-0,height:Hp.height,y:-32,"clip-path":"url(#blocklyTrashBodyClipPath"+a+")"},this.svgGroup).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.workspace.options.pathToMedia+Hp.url);b=z(x.CLIPPATH,{id:"blocklyTrashLidClipPath"+a},this.svgGroup);z(x.RECT,{width:47,height:16},b);b=z(x.G,{"class":"blocklyTrashLid"},this.svgGroup); +b=z(x.SVG,{viewBox:"0 32 47 16",width:47,height:16},b);z(x.IMAGE,{width:Hp.width,height:Hp.height,href:this.workspace.options.pathToMedia+Hp.url},b);ka(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable);ka(this.svgGroup,"pointerup",this,this.click);ka(this.svgGroup,"keydown",this,this.onKeyDown);return this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){let a=this.flyout.createDom(x.SVG);v(a,"blocklyTrashcanFlyout");gb(a,this.workspace.getParentSvg());this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this, +weight:co.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[co.Capability.AUTOHIDEABLE,co.Capability.DELETE_AREA,co.Capability.DRAG_TARGET,co.Capability.POSITIONABLE]});this.initialized=!0;this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan");var a;(a=this.flyout)==null||a.dispose();this.flyout=null;this.svgGroup&&fb(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)}),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(zg.getIsActive()){let e,f;(c=(f=(e=this.flyout)==null?void 0:e.getWorkspace())==null?void 0:f.getNavigator().getFirstNode())&&$.A().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);this.workspace.recordDragTargets()}}autoHide(a){!a&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&this.svgGroup&&(this.contents.length=0,this.svgGroup.classList.remove("blocklyTrashFull"),u(this.svgGroup,w.LABEL,$.C.ARIA_LABEL_TRASH_EMPTY),u(this.svgGroup,w.DISABLED,!0),this.closeFlyout())}position(a,b){if(this.initialized){var c=Bi(this.workspace,a);a=Ai(c,new Pc(47,60),20,20,a,this.workspace);b=Di(a,20,c.vertical===zi.TOP?Ci.DOWN: +Ci.UP,b);this.top=b.top;this.left=b.left;var d;(d=this.svgGroup)==null||d.setAttribute("transform","translate("+this.left+","+this.top+")");var e;(e=this.flyout)==null||e.position()}}getBoundingRectangle(){return new Zc(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 Zc(b,b+16+44+20,a,a+47+20)}onDragOver(){Yi.mover.isMoving()||this.setLidOpen(this.wouldDelete_)}onDragExit(){Yi.mover.isMoving()|| +this.setLidOpen(!1)}onDrop(){Yi.mover.isMoving()||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()}onKeyDown(a){if(a.key==="Enter"||a.key===" ")a.preventDefault(),this.click()}fireUiEvent(a){a=new (t(q.TRASHCAN_OPEN))(a,this.workspace.id);p(a)}blockMouseDownWhenOpenable(a){!this.contentsIsOpen()&& +this.hasContents()&&a.stopPropagation()}onDelete(a){if(!(this.workspace.options.maxTrashcanContents<=0||a.type!==q.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");u(this.svgGroup,w.LABEL, +$.C.OPEN_TRASH);Pa(this.svgGroup,w.DISABLED)}}}cleanBlockJson(a){function b(c){if(c){delete c.id;delete c.x;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)}};wc("\n .blocklyTrash > image {\n opacity: 0.4;\n transition: opacity 0.08s ease-out;\n }\n\n .blocklyTrashLid {\n opacity: 0.4;\n transition: rotate 0.08s ease-out, opacity 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 > image,\n .blocklyTrash.blocklyTrashOpen > .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:hover > image,\n .blocklyTrash.blocklyTrashFull:hover > .blocklyTrashLid,\n .blocklyTrash.blocklyTrashFull:focus > image,\n .blocklyTrash.blocklyTrashFull:focus > .blocklyTrashLid {\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\n @media (prefers-reduced-motion: reduce) {\n .blocklyTrash > image,\n .blocklyTrashLid {\n transition: none;\n }\n }\n");var ar=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=$.ec)||$.r(!0);try{c&&c.getId()!==a.getId()?this.renameVariableWithConflict(a,b,c,d):this.renameVariableAndUses(a, +b,d)}finally{this.potentialMap||$.r(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);p(new (t(q.VAR_TYPE_CHANGE))(a,c,b));return a}renameVariableAndUses(a,b,c){this.potentialMap||p(new (t(q.VAR_RENAME))(a,b));a.setName(b);for(b= +0;b$.hi.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}};n(l.VARIABLE_MAP,"default",ar);var br=class{constructor(a,b,c,d){this.workspace=a;this.name=b;this.type=c||"";this.id=d||Ca()}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);p(new (t(q.VAR_CREATE))(a))}}; +n(l.VARIABLE_MODEL,"default",br);var cr=E.INPUT_VALUE,dr=E.OUTPUT_VALUE,er=E.NEXT_STATEMENT,fr=E.PREVIOUS_STATEMENT,gr=I.TOP,hr=I.BOTTOM,ir=I.LEFT,jr=I.RIGHT;Ap.prototype.newBlock=function(a,b){return new Wn(this,a,b)};Gi.prototype.newBlock=function(a,b){return new Oi(this,a,b)};Ap.prototype.newComment=function(a){return new eg(this,a)};Gi.prototype.newComment=function(a){return new dg(this,a)};Gi.newTrashcan=function(a){return new $q(a)};Bn.prototype.newWorkspaceSvg=function(a){return new Gi(a)}; +$.hi.prototype.populateProcedures=function(a){a=ei(a);a=a[0].concat(a[1]);for(let b=0;b