diff --git a/blockly/alien.png b/blockly/alien.png new file mode 100644 index 00000000..db9e05c0 Binary files /dev/null and b/blockly/alien.png differ diff --git a/blockly/bubble.png b/blockly/bubble.png new file mode 100644 index 00000000..b826bf31 Binary files /dev/null and b/blockly/bubble.png differ diff --git a/blockly/compile.js b/blockly/compile.js index 05f9384d..94079627 100644 --- a/blockly/compile.js +++ b/blockly/compile.js @@ -4,24 +4,131 @@ const Blockly = require('blockly/core'); const libraryBlocks = require('blockly/blocks'); // not entirely sure if this is necessary const {pythonGenerator} = require('blockly/python'); const en = require('blockly/msg/en'); +const savePixels = require("save-pixels") +const ndarray = require("ndarray"); + Blockly.setLocale(en); +const primaryColor = [54, 61, 128, 255] +const secondaryColor = [194, 60, 30, 255] +const backgroundColor = [0, 0, 0, 0] + + +const pixel_colors = { + 0: backgroundColor, + 1: primaryColor, + 2: secondaryColor +} + +var saveBitmap = (bitmap, size, name) => { + + // old squish approach + + // var squished = []; + // for(var string of bitmap) { + // for(bit of string) { + // squished.push(bit * 255); + // } + // } + + // var d = { + // data: squished, + // shape: size, + // stride: [size[0], 1], + // offset: 0 + // } + + var data = bitmap.map(function(arr) { + return bitmap.slice(); + }); + + var d = new ndarray(data, [size[0], size[1], 4]); + + for(var x in bitmap) { + for(var y in bitmap[x]) { + var color = pixel_colors[bitmap[x][y]]; + + for(var i=0;i<4;i++) { + d.set(y, x, i, color[i]) + } + } + } + + var out = fs.createWriteStream(`${name}.png`); + savePixels(d, "png").pipe(out) +} + +var unrollWorkspaceBlocks = (workspace) => { + var workspaceBlocks = []; + + var saveBlock = (block) => { + workspaceBlocks.push(block) + if(block.next) { + saveBlock(block.next.block) + } + } + + for(var block of workspace.blocks.blocks) { + saveBlock(block); + } + + return workspaceBlocks; +} + +var getVariableName = (block_id, workspace) => { + console.log("looking",block_id); + var variable_match = workspace.variables.filter((variable)=>variable.id == block_id) + console.log(workspace.variables) + if(variable_match.length == 0) { return block_id } + + return variable_match[0].name; +} + +var getBitmapSize = (bitmap_type, definitions) => { + var size = definitions.blocks.filter((definition)=>definition.type==bitmap_type)[0]["args0"][1]; + return [size.width, size.height] +} + try { const file = jsonfile.readFileSync(process.argv[2]); var filename = process.argv[2].replace(/^.*[\\/]/, '') - console.log(process.argv[3]); var output = process.argv[3] || filename.split('.')[0]+".py" + // SAVE BITMAPS + // PROBABLY SHOULD BE IN THEIR OWN GAME FOLDER + var allWorkspaceBlocks = unrollWorkspaceBlocks(file) + // THIS IS HOW WE GET BLOCK DEFINITIONS var definitionsArray = jsonfile.readFileSync('./src/blocks/game.json') var definitions = Blockly.common.createBlockDefinitionsFromJsonArray(definitionsArray.blocks); Blockly.common.defineBlocks(definitions); - // THIS IS HOW WE GET BLOCK GENERATION + for(var block of allWorkspaceBlocks) { + // save orphaned bitmaps + // if(["small_bitmap", "large_bitmap"].includes(block.type)) { + // saveBitmap(block.fields.field, block.id); + // } + if(block.type == "variables_set") { + for(var key in block.inputs) { + var variable_id = block.fields.VAR.id; + var block = block.inputs[key].block; + if(["small_bitmap", "large_bitmap"].includes(block.type)) { + var size = getBitmapSize(block.type, definitionsArray) + var name = getVariableName(variable_id, file) + saveBitmap(block.fields.field, size, name); + } + } + } + } + + + return; + + // THIS IS HOW WE GET BLOCK GENERATION const forBlock = require('./src/generators/python.js') Object.assign(pythonGenerator.forBlock, forBlock); - + try { var workspace = new Blockly.Workspace(); Blockly.serialization.workspaces.load(file, workspace); diff --git a/blockly/dist/bundle.js b/blockly/dist/bundle.js index aa9b9cb3..8d2469ce 100644 --- a/blockly/dist/bundle.js +++ b/blockly/dist/bundle.js @@ -1,2 +1,2 @@ /*! For license information please see bundle.js.LICENSE.txt */ -(()=>{var t={239:function(t,e,s){var i,o,n;o=[s(731)],void 0===(n="function"==typeof(i=function(t){return t})?i.apply(e,o):i)||(t.exports=n)},731:function(t,e,s){var i,o;void 0===(o="function"==typeof(i=function(){var t,e,i,o,n,r,l,a,c,h,u,d,p,g,_,T,m,E,b,f,$,I,S,R,C,k,O,y,A,v,L,w,N,M,D,B,x,P,F,U,H,G,V,W,X,Y,K,z,j,J,q,Z,Q,tt,et,st,it,ot,nt,rt,lt,at,ct,ht,ut,dt,pt,gt,_t,Tt,mt,Et,bt,ft,$t,It,St,Rt,Ct,kt,Ot,yt,At,vt,Lt,wt,Nt,Mt,Dt,Bt,xt,Pt,Ft,Ut,Ht,Gt,Vt,Wt,Xt,Yt,Kt,zt,jt,Jt,qt,Zt,Qt,te,ee,se,ie,oe,ne,re,le,ae,ce,he,ue,de,pe,ge,_e,Te,me,Ee,be,fe,$e,Ie,Se,Re,Ce,ke,Oe,ye,Ae,ve,Le,we,Ne,Me,De,Be,xe,Pe,Fe,Ue,He,Ge,Ve,We,Xe,Ye,Ke,ze,je,Je,qe,Ze,Qe,ts,es,ss,is,os,ns,rs,ls,as,cs,hs,us,ds,ps,gs,_s,Ts,ms,Es,bs,fs,$s,Is,Ss,Rs,Cs,ks,Os,ys,As,vs,Ls,ws,Ns,Ms,Ds,Bs,xs,Ps,Fs,Us,Hs,Gs,Vs,Ws,Xs,Ys,Ks,zs,js,Js,qs,Zs,Qs,ti,ei,si,ii,oi,ni,ri,li,ai,ci,hi,ui,di,pi,gi,_i,Ti,mi,Ei,bi,fi,$i,Ii,Si,Ri,Ci,ki,Oi,yi,Ai,vi,Li,wi,Ni,Mi,Di,Bi,xi,Pi,Fi,Ui,Hi,Gi,Vi,Wi,Xi,Yi,Ki,zi,ji,Ji,qi,Zi,Qi,to,eo,so,io,oo,no,ro,lo,ao,co,ho,uo,po,go,_o,To,mo,Eo,bo,fo,$o,Io,So,Ro,Co,ko,Oo,yo,Ao,vo,Lo,wo,No,Mo,Do,Bo,xo,Po,Fo,Uo,Ho,Go,Vo,Wo,Xo,Yo,Ko,zo,jo,Jo,qo,Zo,Qo,tn,en,sn,on,nn,rn,ln,an,cn,hn,un,dn,pn,gn,_n,Tn,mn,En,bn,fn,$n,In,Sn,Rn,Cn,kn,On,yn,An,vn,Ln,wn,Nn,Mn,Dn,Bn,xn,Pn,Fn,Un,Hn,Gn,Vn,Wn,Xn,Yn,Kn,zn,jn,Jn,qn,Zn,Qn,tr,er,sr,ir,or,nr,rr,lr,ar,cr,hr,ur,dr,pr,gr,_r,Tr,mr,Er,br,fr,$r,Ir,Sr,Rr,Cr,kr,Or,yr,Ar,vr,Lr,wr,Nr={};t=function(t,s,i,o){if(!(t instanceof Pr)&&"string"!=typeof t||""===`${t}`.trim())throw Error('Invalid type "'+t+'". The type must be a non-empty string or a Blockly.registry.Type.');if(t=`${t}`.toLowerCase(),"string"!=typeof s||""===s.trim())throw Error('Invalid name "'+s+'". The name must be a non-empty string.');const n=s.toLowerCase();if(!i)throw Error("Can not register a null value");let r=Mr[t],l=Br[t];if(r||(r=Mr[t]=Object.create(null),l=Br[t]=Object.create(null)),e(t,i),!o&&r[n])throw Error('Name "'+n+'" with type "'+t+'" already registered.');r[n]=i,l[n]=s},e=function(t,e){if(t===String(Pr.FIELD)&&"function"!=typeof e.fromJson)throw Error('Type "'+t+'" must have a fromJson function')},i=function(t,e){t=`${t}`.toLowerCase(),e=e.toLowerCase();const s=Mr[t];s&&s[e]?(delete Mr[t][e],delete Br[t][e]):console.warn("Unable to unregister ["+e+"]["+t+"] from the registry.")},o=function(t,e,s){t=`${t}`.toLowerCase(),e=e.toLowerCase();const i=Mr[t];if(!i||!i[e]){if(e="Unable to find ["+e+"]["+t+"] in the registry.",s)throw Error(e+" You must require or register a "+t+" plugin.");return console.warn(e),null}return i[e]},n=function(t,e){return t=`${t}`.toLowerCase(),e=e.toLowerCase(),!!(t=Mr[t])&&!!t[e]},r=function(t,e,s){return o(t,e,s)},l=function(t,e,s){return o(t,e,s)},a=function(t,e,s){t=`${t}`.toLowerCase();var i=Mr[t];if(!i){if(i=`Unable to find [${t}] in the registry.`,s)throw Error(`${i} You must require or register a ${t} plugin.`);return console.warn(i),null}if(!e)return i;t=Br[t],s=Object.create(null);for(const e of Object.keys(i))s[t[e]]=i[e];return s},c=function(t,e,s){return"function"==typeof(e=e.plugins[String(t)]||xr)?e:r(t,e,s)},h=function(t){return Vr[t]||null},u=function(){const t=[];for(const e in Vr)t.push(Vr[e]);return t},d=function(t){Vr[t.id]=t},p=function(t){delete Vr[t.id]},g=function(){return Ur},_=function(t){Ur=t},T=function(){return Wr},m=function(t){Wr=t},E=function(){return Hr},b=function(t){Hr=t},f=function(t){for(;t.options.parentWorkspace;)t=t.options.parentWorkspace;const e=t.getParentSvg(),s=t.getCachedParentSvgSize();var i=e.parentElement;if(i instanceof HTMLElement){var o=i.offsetWidth;i=i.offsetHeight,s.width!==o&&(e.setAttribute("width",o+"px"),t.setCachedParentSvgSize(o,null)),s.height!==i&&(e.setAttribute("height",i+"px"),t.setCachedParentSvgSize(null,i)),t.resize()}},$=function(t,e){const s=Object.create(null),i=t.getDescendants(!0);e&&(t=t.getNextBlock())&&(t=i.indexOf(t),i.splice(t,i.length-t));for(let t,e=0;t=i[e];e++)s[t.type]?s[t.type]++:s[t.type]=1;return s},I=function(t){return function(){this.jsonInit(t)}},S=function(t){Yr.defineBlocksWithJsonArrayInternal(t)},R=function(t){Nr.defineBlocks$$module$build$src$core$common(Nr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(t))},Nr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(t){const e={};for(let s=0;s{setTimeout(L,0)}))}catch(t){setTimeout(L,0)}ml.push(t)}},L=function(){var t=w(ml,!0);ml.length=0;for(let s,i=0;s=t[i];i++)if(s.workspaceId){var e=h(s.workspaceId);e&&e.fireChangeListener(s)}t=new Set(t.map((t=>t.workspaceId)));for(const s of t){if(!s)continue;if(!(t=h(s)))continue;let i;for(e=(t=t.getUndoStack()).length;0>>/g,t),la="",(t=document.createElement("style")).id="blockly-common-style",e=document.createTextNode(e),t.appendChild(e),document.head.insertBefore(t,document.head.firstChild)))},st=function(t,e,s,i){t=t+" was deprecated in "+e+" and will be deleted in "+s+".",i&&(t+="\nUse "+i+" instead."),console.warn(t)},it=function(t,e,s){t=document.createElementNS(da,`${t}`);for(const s in e)t.setAttribute(s,`${e[s]}`);return s&&s.appendChild(t),t},ot=function(t,e){return!(e=e.split(" ")).every((e=>t.classList.contains(e)))&&(t.classList.add(...e),!0)},nt=function(t,e){t.classList.remove(...e.split(" "))},rt=function(t,e){return!(e=e.split(" ")).every((e=>!t.classList.contains(e)))&&(t.classList.remove(...e),!0)},lt=function(t,e){return t.classList.contains(e)},at=function(t){return t&&t.parentNode?t.parentNode.removeChild(t):null},ct=function(t,e){const s=e.nextSibling;if(!(e=e.parentNode))throw Error("Reference node has no parent.");s?e.insertBefore(t,s):e.appendChild(t)},ht=function(t,e){return st("Blockly.utils.dom.containsNode","version 10","version 11",'Use native "contains" DOM method'),t.contains(e)},ut=function(t,e){t.style.transform=e,t.style["-webkit-transform"]=e},dt=function(){Ta++,_a||(_a=Object.create(null))},pt=function(){--Ta||(_a=null)},gt=function(t){const e=t.textContent+"\n"+t.className.baseVal;let s;if(_a&&(s=_a[e]))return s;try{s=t.getComputedTextLength()}catch(e){return 8*t.textContent.length}return _a&&(_a[e]=s),s},_t=function(t,e,s,i){return Tt(t,e+"pt",s,i)},Tt=function(t,e,s,i){const o=t.textContent;var n;return t=o+"\n"+t.className.baseVal,_a&&(n=_a[t])||(ma||((n=document.createElement("canvas")).className="blocklyComputeCanvas",document.body.appendChild(n),ma=n.getContext("2d")),ma.font=s+" "+e+" "+i,n=o?ma.measureText(o).width:0,_a&&(_a[t]=n)),n},mt=function(t,e,s,i){const o=document.createElement("span");o.style.font=s+" "+e+" "+i,o.textContent=t,(t=document.createElement("div")).style.width="1px",t.style.height="0",(e=document.createElement("div")).style.display="flex",e.style.position="fixed",e.style.top="0",e.style.left="0",e.appendChild(o),e.appendChild(t),document.body.appendChild(e),s={height:0,baseline:0};try{e.style.alignItems="baseline",s.baseline=t.offsetTop-o.offsetTop,e.style.alignItems="flex-end",s.height=t.offsetTop-o.offsetTop}finally{document.body.removeChild(e)}return s},Et=function(t){return Ia.getSizeInternal(t)},bt=function(t){if("none"!==$t(t,"display"))return ft(t);const e=t.style,s=e.display,i=e.visibility,o=e.position;e.visibility="hidden",e.position="absolute",e.display="inline";const n=t.offsetWidth;return t=t.offsetHeight,e.display=s,e.position=o,e.visibility=i,new $a(n,t)},ft=function(t){return new $a(t.offsetWidth,t.offsetHeight)},$t=function(t,e){return(t=window.getComputedStyle(t))[e]||t.getPropertyValue(e)},It=function(t){const e=new ca(0,0);t=t.getBoundingClientRect();var s=document.documentElement;return s=new ca(window.pageXOffset||s.scrollLeft,window.pageYOffset||s.scrollTop),e.x=t.left+s.x,e.y=t.top+s.y,e},St=function(){const t=document.body,e=document.documentElement;return new ca(t.scrollLeft||e.scrollLeft,t.scrollTop||e.scrollTop)},Rt=function(t){const e=parseFloat($t(t,"borderLeftWidth")),s=parseFloat($t(t,"borderRightWidth")),i=parseFloat($t(t,"borderTopWidth"));return t=parseFloat($t(t,"borderBottomWidth")),new fa(i,t,e,s)},Ct=function(t,e,s){t=kt(t,e,s),e.scrollLeft=t.x,e.scrollTop=t.y},kt=function(t,e,s){var i=It(t),o=It(e),n=Rt(e);const r=i.x-o.x-n.left;return i=i.y-o.y-n.top,o=ft(t),t=e.clientWidth-o.width,o=e.clientHeight-o.height,n=e.scrollLeft,e=e.scrollTop,s?(n+=r-t/2,e+=i-o/2):(n+=Math.min(r,Math.max(r-t,0)),e+=Math.min(i,Math.max(i-o,0))),new ca(n,e)},Ot=function(t){const e=new ca(0,0);var s=t.x&&t.getAttribute("x");const i=t.y&&t.getAttribute("y");return s&&(e.x=parseInt(s)),i&&(e.y=parseInt(i)),(s=(s=t.getAttribute("transform"))&&s.match(Ra))&&(e.x+=Number(s[1]),s[3]&&(e.y+=Number(s[3]))),(t=t.getAttribute("style"))&&-1`&#${t.charCodeAt(0)};`))},Bt=function(t){return t?((t instanceof Element||"string"==typeof t)&&(t=Xt(t),t=Gt(t)),xt(t),t):null},xt=function(t){const e=t.kind;if(t=t.contents,e&&e!==Pa&&e!==xa)throw Error("Invalid toolbox kind "+e+". Please supply either "+Pa+" or "+xa);if(!t)throw Error("Toolbox must have a contents attribute.")},Pt=function(t){return t?t.contents?t.contents:Array.isArray(t)&&0 document.")}else t instanceof Element&&(e=t);return e},Yt=function(t,e,s,i,o,n){const r=n.scrollbar&&n.scrollbar.canScrollVertically();return t.horizontal===Ua.LEFT?(s=o.absoluteMetrics.left+s,r&&n.RTL&&(s+=Oa.scrollbarThickness)):(s=o.absoluteMetrics.left+o.viewMetrics.width-e.width-s,r&&!n.RTL&&(s-=Oa.scrollbarThickness)),t.vertical===Fa.TOP?t=o.absoluteMetrics.top+i:(t=o.absoluteMetrics.top+o.viewMetrics.height-e.height-i,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(t-=Oa.scrollbarThickness)),new fa(t,t+e.height,s,s+e.width)},Kt=function(t,e){return{horizontal:e.toolboxMetrics.position===Ba.LEFT||t.horizontalLayout&&!t.RTL?Ua.RIGHT:Ua.LEFT,vertical:e.toolboxMetrics.position===Ba.BOTTOM?Fa.TOP:Fa.BOTTOM}},zt=function(t,e,s,i){const o=t.left,n=t.right-t.left,r=t.bottom-t.top;for(let l=0;l1'),i.appendChild(s),e.push(i)),Gr.variables_get){t.sort(rc.compareByName);for(let i,o=0;i=t[o];o++)(s=Nr.createElement$$module$build$src$core$utils$xml("block")).setAttribute("type","variables_get"),s.setAttribute("gap","8"),s.appendChild(me(i)),e.push(s)}}return e},le=function(t){return cc.generateUniqueNameInternal(t)},ae=function(t){return ce(ac.charAt(0),t.getAllVariableNames())},ce=function(t,e){if(!e.length)return t;const s=ac;let i="",o=s.indexOf(t);for(;;){let n=!1;for(let s=0;st.getVariableModel().name));if(i&&(s=i.some((e=>e.toLowerCase()===t)),i=i.some((t=>t.toLowerCase()===e)),s&&i))return o.getName()}return null},Te=function(t,e,s){t=t.toLowerCase(),e=e.toLowerCase(),s=s.getAllBlocks(!1);for(const o of s){if(!ie(o))continue;var i=(s=o.getProcedureDef())[1];const n=i.some((e=>e.toLowerCase()===t));if(i=i.some((t=>t.toLowerCase()===e)),n&&i)return s[0]}return null},me=function(t){const e=Nr.createElement$$module$build$src$core$utils$xml("field");return e.setAttribute("name","VAR"),e.setAttribute("id",t.getId()),e.setAttribute("variabletype",t.type),t=Nr.createTextNode$$module$build$src$core$utils$xml(t.name),e.appendChild(t),e},Nr.getOrCreateVariablePackage$$module$build$src$core$variables=function(t,e,s,i){let o=Nr.getVariable$$module$build$src$core$variables(t,e,s,i);return o||(o=Ee(t,e,s,i)),o},Nr.getVariable$$module$build$src$core$variables=function(t,e,s,i){const o=t.getPotentialVariableMap();let n=null;if(e&&(n=t.getVariableById(e),!n&&o&&(n=o.getVariableById(e)),n))return n;if(s){if(void 0===i)throw Error("Tried to look up a variable by name without a type");n=t.getVariable(s,i),!n&&o&&(n=o.getVariable(s,i))}return n},Ee=function(t,e,s,i){const o=t.getPotentialVariableMap();return s||(s=le(t.isFlyout?t.targetWorkspace:t)),o?o.createVariable(s,i,e):t.createVariable(s,i,e)},be=function(t,e){t=t.getAllVariables();const s=[];if(e.length!==t.length)for(let i=0;i{bc=t,fc=window.requestAnimationFrame((()=>{Oe(),t()}))}))),Ec)},Se=function(){return Ec||Promise.resolve()},Re=function(t){t||window.cancelAnimationFrame(fc),Oe(t),!t&&bc&&bc()},Ce=function(){return Yl},ke=function(t){mc.add(t);const e=t.getParent();e?ke(e):Tc.add(t)},Oe=function(t){const e=t?new Set([t]):new Set([...Tc].map((t=>t.workspace))),s=[...Tc].filter(Ae).filter((t=>e.has(t.workspace)));for(var i of s)ve(i);for(const t of e)t.resizeContents();for(const t of s)i=t.getRelativeToSurfaceXY(),t.updateComponentLocations(i);for(const t of s)ye(t);t||(Ec=null)},ye=function(t){Tc.delete(t),mc.delete(t);for(const e of t.getChildren(!1))ye(e)},Ae=function(t){return!t.isDisposed()&&!t.getParent()},ve=function(t){if(mc.has(t)){for(const e of t.getChildren(!1))ve(e);t.renderEfficiently()}},Le=function(t,e){const s=Nr.createElement$$module$build$src$core$utils$xml("xml");var i=we(Nr.allUsedVarModels$$module$build$src$core$variables(t));i.hasChildNodes()&&s.appendChild(i),i=t.getTopComments(!0);for(let t=0;t/g,"<$1$2>")},Fe=function(t){t=Pe(t).split("<");let e="";for(let s=1;s"!==i.slice(-2)&&(e+=" ")}return(t=(t=t.join("\n")).replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1")).replace(/^\n/,"")},Ue=function(t,e){return e.setResizesEnabled(!1),e.clear(),t=Nr.domToWorkspace$$module$build$src$core$xml(t,e),e.setResizesEnabled(!0),t},Nr.domToWorkspace$$module$build$src$core$xml=function(t,e){let s=0;e.RTL&&(s=e.getWidth());const i=[];dt();const o=Nr.getGroup$$module$build$src$core$events$utils();o||Nr.setGroup$$module$build$src$core$events$utils(!0),e.setResizesEnabled&&e.setResizesEnabled(!1);let n=!0;try{for(let o,r=0;o=t.childNodes[r];r++){const t=o.nodeName.toLowerCase(),r=o;if("block"===t||"shadow"===t&&!y()){const t=Ge(r,e);let o;i.push(t.id);const l=parseInt(null!=(o=r.getAttribute("x"))?o:"10",10);let a;const c=parseInt(null!=(a=r.getAttribute("y"))?a:"10",10);isNaN(l)||isNaN(c)||t.moveBy(e.RTL?s-l:l,c,["create"]),n=!1}else{if("shadow"===t)throw TypeError("Shadow block cannot be a top-level block.");if("comment"===t)e.rendered?_c.fromXmlRendered(r,e,s):uc.fromXml(r,e);else if("variables"===t){if(!n)throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");Ve(r,e),n=!1}}}}finally{Nr.setGroup$$module$build$src$core$events$utils(o),e.setResizesEnabled&&e.setResizesEnabled(!0),e.rendered&&Re(),pt()}return A(new(P(_l))(e)),i},He=function(t,e){if(!e.getBlocksBoundingBox)return Nr.domToWorkspace$$module$build$src$core$xml(t,e);var s=e.getBlocksBoundingBox();if(t=Nr.domToWorkspace$$module$build$src$core$xml(t,e),s&&s.top!==s.bottom){var i=s.bottom;s=e.RTL?s.right:s.left;var o=1/0;let n=-1/0,r=1/0;for(let s=0;sn&&(n=i.x)}for(i=i-r+10,s=e.RTL?s-n:s-o,o=0;oc.setBubbleVisible(n)),1)}},Ke=function(t,e){for(let s=0;s{t.disposed||t.setConnectionTracking(!0)}),1)}return r},Ts=function(t,e,{parentConnection:s,isShadow:i=!1}={}){if(!t.type)throw new Rc(t);const o=e.newBlock(t.type,t.id);return o.setShadow(i),ms(o,t),Es(o,t),bs(o,t),fs(s,o,t),$s(o,t),Is(o,t),Ss(o,t),Rs(o,t),ks(o,e.rendered),o},ms=function(t,e){let s=void 0===e.x?0:e.x;e=void 0===e.y?0:e.y;const i=t.workspace;s=i.RTL?i.getWidth()-s:s,t.moveBy(s,e)},Es=function(t,e){e.collapsed&&t.setCollapsed(!0),!1===e.deletable&&t.setDeletable(!1),!1===e.movable&&t.setMovable(!1),!1===e.editable&&t.setEditable(!1),!1===e.enabled&&t.setEnabled(!1),void 0!==e.inline&&t.setInputsInline(e.inline),void 0!==e.data&&(t.data=e.data)},bs=function(t,e){e.extraState&&(t.loadExtraState?t.loadExtraState(e.extraState):t.domToMutation&&t.domToMutation(Nr.textToDom$$module$build$src$core$utils$xml(e.extraState)))},fs=function(t,e,s){if(t){if(t.getSourceBlock().isShadow()&&!e.isShadow())throw new Oc(s);if(t.type===Nr.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var i=e.outputConnection;if(!i)throw new Cc("output",e,s)}else if(!(i=e.previousConnection))throw new Cc("previous",e,s);if(!t.connect(i)){const o=e.workspace.connectionChecker;throw new kc(o.getErrorMessage(o.canConnectWithReason(i,t,!1),i,t),t.type===Nr.inputTypes$$module$build$src$core$inputs$input_types.VALUE?"output connection":"previous connection",e,s)}}},$s=function(t,e){if(e.icons){var s=Object.keys(e.icons);for(const o of s){s=e.icons[o];var i=t.getIcon(o);if(!i){if(!(i=r(Pr.ICON,o,!1)))throw new yc(o,t,e);i=new i(t),t.addIcon(i)}ss(i)&&i.loadState(s)}}},Is=function(t,e){if(e.fields){var s=Object.keys(e.fields);for(let i=0;ie.id!=t.id)).map((t=>t.getRelativeToSurfaceXY()));for(;ys(ca.sum(i,o),n)||As(t,o,s);)e.RTL?o.translate(-s,2*s):o.translate(s,2*s);t.moveTo(ca.sum(i,o))},ys=function(t,e){return e.some((e=>1>=Math.abs(e.x-t.x)&&1>=Math.abs(e.y-t.y)))},As=function(t,e,s){return t.getConnections_(!1).some((t=>!!t.closest(s,e).connection))},vs=function(t){return st("Blockly.clipboard.copy","v11","v12","myCopyable.toCopyData()"),Xc.copyInternal(t)},Ls=function(t){const e=t.toCopyData();let s;return Vc=e,Wc=null!=(s=t.workspace)?s:null,e},ws=function(t,e,s){return t&&e?Ns(t,e,s):Vc&&Wc?Ns(Vc,Wc):null},Ns=function(t,e,s){let i,o,n;return e=null!=(i=e.getRootWorkspace())?i:e,null!=(n=null==(o=l(Pr.PASTER,t.paster,!1))?void 0:o.paste(t,e,s))?n:null},Ms=function(t){return st("Blockly.clipboard.duplicate","v11","v12","Blockly.clipboard.paste(myCopyable.toCopyData(), myWorkspace)"),Xc.duplicateInternal(t)},Ds=function(t){const e=t.toCopyData();return e?ws(e,t.workspace):null},Bs=function(t,e){t.setAttribute(Jc,e)},xs=function(t,e,s){Array.isArray(s)&&(s=s.join(" ")),t.setAttribute(jc+e,`${s}`)},Ps=function(){return Zc},Fs=function(t){if(Zc=t,null===t){let t;null==(t=document.querySelector("."+ih))||t.remove()}},Us=function(){document.querySelector("."+ih)||((Zc=document.createElement("div")).className=ih,(E()||document.body).appendChild(Zc))},Hs=function(t,e,s){Gs(),eh=t,sh=s,(t=Zc)&&(t.style.direction=e?"rtl":"ltr",t.style.display="block",e=g(),oh=e.getRenderer().getClassName(),nh=e.getTheme().getClassName(),oh&&ot(t,oh),nh&&ot(t,nh))},Gs=function(){if(Vs()){eh=null;var t=Zc;t&&(t.style.display="none",t.style.left="",t.style.top="",sh&&sh(),sh=null,t.textContent="",oh&&(rt(t,oh),oh=""),nh&&(rt(t,nh),nh=""),g().markFocused())}},Vs=function(){return!!eh},Ws=function(t){eh===t&&Gs()},Xs=function(t,e,s){Zc.style.left=t+"px",Zc.style.top=e+"px",Zc.style.height=s+"px"},Ys=function(t,e,s,i){const o=zs(t,e,s);t=Ks(t,e,s,i),0>o?Xs(t,0,s.height+o):Xs(t,o,s.height)},Ks=function(t,e,s,i){return i?Math.min(Math.max(e.right-s.width,t.left),t.right-s.width):Math.max(Math.min(e.left,t.right-s.width),t.left)},zs=function(t,e,s){return e.bottom+s.height>=t.bottom?e.top-s.height:e.bottom},js=function(t){return!(null==t||!t.repositionForWindowResize)},Js=function(){js(eh)&&eh.repositionForWindowResize()||Gs()},qs=function(){return lh},Zs=function(t){lh=t},Qs=function(t,e,s){if(Hs(ah,s,ni),e.length){var i=ti(e,s);ch=i,ei(i,t,s),setTimeout((function(){i.focus()}),1),lh=null}else oi()},ti=function(t,e){const s=new Qc;s.setRole(Kc.MENU);for(let i=0;i{setTimeout((()=>{o.callback(o.scope)}),0)}))}),{})}return s},ei=function(t,e,s){const i=At();e=new fa(e.clientY+i.top,e.clientY+i.top,e.clientX+i.left,e.clientX+i.left),si(t);const o=t.getSize();s&&(e.left+=o.width,e.right+=o.width,i.left+=o.width,i.right+=o.width),Ys(i,e,o,s),t.focus()},si=function(t){var e=Ps();if(!e)throw Error("Attempting to create a context menu when widget div is null");e=t.render(e),ot(e,"blocklyContextMenu"),Y(e,"contextmenu",null,ii),t.focus()},ii=function(t){t.preventDefault(),t.stopPropagation()},oi=function(){Ws(ah),lh=null},ni=function(){ch&&(ch.dispose(),ch=null)},Nr.callbackFactory$$module$build$src$core$contextmenu=function(t,e){return()=>{let s;Nr.disable$$module$build$src$core$events$utils();try{s=e instanceof Element?Ge(e,t.workspace):_s(e,t.workspace);const i=t.getRelativeToSurfaceXY();i.x=t.RTL?i.x-Nr.config$$module$build$src$core$config.snapRadius:i.x+Nr.config$$module$build$src$core$config.snapRadius,i.y+=2*Nr.config$$module$build$src$core$config.snapRadius,s.moveBy(i.x,i.y)}finally{Nr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&A(new(P(Nr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}},ri=function(t){return{text:Nr.Msg$$module$build$src$core$msg.REMOVE_COMMENT,enabled:!0,callback:function(){Nr.setGroup$$module$build$src$core$events$utils(!0),t.dispose(),Nr.setGroup$$module$build$src$core$events$utils(!1)}}},li=function(t){return{text:Nr.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,enabled:!0,callback:function(){const e=t.toCopyData();e&&ws(e,t.workspace)}}},ai=function(t,e){const s={enabled:!0};return s.text=Nr.Msg$$module$build$src$core$msg.ADD_COMMENT,s.callback=function(){const s=new _c(t,Nr.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT,_c.DEFAULT_SIZE,_c.DEFAULT_SIZE);var i=t.getInjectionDiv().getBoundingClientRect();i=new ca(e.clientX-i.left,e.clientY-i.top);const o=t.getOriginOffsetInPixels();(i=ca.difference(i,o)).scale(1/t.scale),s.moveBy(i.x,i.y),t.rendered&&(s.initSvg(),s.render(),s.select())},s},ci=function(t){return t*Math.PI/180},hi=function(t){return 180*t/Math.PI},ui=function(t,e,s){if(ss)){var i=e.getSvgXY(t.getSvgRoot());t.outputConnection?(i.x+=(t.RTL?3:-3)*s,i.y+=13*s):t.previousConnection&&(i.x+=(t.RTL?-23:23)*s,i.y+=3*s);var o=it(ba.CIRCLE,{cx:i.x,cy:i.y,r:0,fill:"none",stroke:"#888","stroke-width":10},e.getParentSvg());t=it(ba.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*s},o),e=it(ba.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},o),t.beginElement(),e.beginElement(),setTimeout((()=>{at(o)}),150)}},xi=function(t){if(Fi(),t.workspace.getAudioManager().play("disconnect"),!(1>t.workspace.scale)){var e=t.getHeightWidth().height;e=Math.atan(10/e)/Math.PI*180,t.RTL||(e*=-1),Nh=t,Pi(t,e,new Date)}},Pi=function(t,e,s){const i=((new Date).getTime()-s.getTime())/200;let o="";1>=i&&(o=`skewX(${Math.round(Math.sin(i*Math.PI*3)*(1-i)*e)})`,wh=setTimeout(Pi,10,t,e,s)),t.getSvgRoot().setAttribute("transform",`${t.getTranslation()} ${o}`)},Fi=function(){Nh&&(wh&&(clearTimeout(wh),wh=null),Nh.getSvgRoot().setAttribute("transform",Nh.getTranslation()),Nh=null)},Ui=function(t,e){return st("Blockly.utils.string.startsWith()","April 2022","April 2023","Use built-in string.startsWith"),t.startsWith(e)},Hi=function(t){return t.length?t.reduce((function(t,e){return t.lengthe&&(e=s[i].length);var o=-1/0;let n,r=1;do{i=o,n=t,t=[],o=s.length/r;let l=1;for(let e=0;ei);return n},Xi=function(t,e,s){const i=[0],o=[];for(var n=0;no&&(o=l,i=r)}return i?Yi(t,i,s):e},Ki=function(t,e){const s=[];for(let i=0;iZh&&lo()}else jh!==zh&&(clearTimeout(Xh),Yh=t.pageX,Kh=t.pageY,Xh=setTimeout(go,Qh))},ro=function(){jh=zh=null,lo()},lo=function(){Hh&&(Hh=!1,eu&&(eu.style.display="none")),Xh&&(clearTimeout(Xh),Xh=0)},ao=function(){lo(),Gh=!0},co=function(){Gh=!1},ho=function(){eu&&zh&&("function"==typeof Uh?Uh(eu,zh):uo())},uo=function(){var t=Zi(zh);t=(t=Nr.wrap$$module$build$src$core$utils$string(t,Vh)).split("\n");for(let e=0;es+window.scrollY&&(o-=eu.offsetHeight+2*qh),t?i=Math.max(tu-window.scrollX,i):i+eu.offsetWidth>e+window.scrollX-2*tu&&(i=e-eu.offsetWidth-2*tu),{x:i,y:o}},go=function(){if(!Gh&&(jh=zh,eu)){eu.textContent="",ho();var t=zh.RTL;eu.style.direction=t?"rtl":"ltr",eu.style.display="block",Hh=!0;var{x:e,y:s}=po(t);eu.style.left=e+"px",eu.style.top=s+"px"}},_o=function(t,e){for(const s in e)t[s]=null!==e[s]&&"object"==typeof e[s]?_o(t[s]||Object.create(null),e[s]):e[s];return t},To=function(t){return void 0!==t.bubbleIsVisible&&void 0!==t.setBubbleVisible},mo=function(){return du},Eo=function(t){du=t},bo=function(){return pu},fo=function(t){pu=t},$o=function(t){t=`${t}`.toLowerCase().trim();var e=gu[t];if(e)return e;if(e="#"===(e="0x"===t.substring(0,2)?"#"+t.substring(2):t)[0]?e:"#"+e,/^#[0-9a-f]{6}$/.test(e))return e;if(/^#[0-9a-f]{3}$/.test(e))return["#",e[1],e[1],e[2],e[2],e[3],e[3]].join("");var s=t.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return s&&(t=Number(s[1]),e=Number(s[2]),s=Number(s[3]),0<=t&&256>t&&0<=e&&256>e&&0<=s&&256>s)?Io(t,e,s):null},Io=function(t,e,s){return e=t<<16|e<<8|s,16>t?"#"+(16777216|e).toString(16).substr(1):"#"+e.toString(16)},So=function(t){return(t=$o(t))?[(t=parseInt(t.substr(1),16))>>16,t>>8&255,255&t]:[0,0,0]},Ro=function(t,e,s){let i=0,o=0,n=0;if(0===e)n=o=i=s;else{const r=Math.floor(t/60),l=t/60-r;t=s*(1-e);const a=s*(1-e*l);switch(e=s*(1-e*(1-l)),r){case 1:i=a,o=s,n=t;break;case 2:i=t,o=s,n=e;break;case 3:i=t,o=a,n=s;break;case 4:i=e,o=t,n=s;break;case 5:i=s,o=t,n=a;break;case 6:case 0:i=s,o=e,n=t}}return Io(Math.floor(i),Math.floor(o),Math.floor(n))},Co=function(t,e,s){return(t=$o(t))&&(e=$o(e))?(t=So(t),e=So(e),Io(Math.round(e[0]+s*(t[0]-e[0])),Math.round(e[1]+s*(t[1]-e[1])),Math.round(e[2]+s*(t[2]-e[2])))):null},ko=function(t){return Ro(t,du,255*pu)},Oo=function(t,e,s){const i=[];var o=t.split("");o.push("");var n=0;t=[];let r=null;for(let c=0;c=l?(n=2,r=l,(l=t.join(""))&&i.push(l),t.length=0):"{"===l?n=3:(t.push("%",l),n=0);else if(2===n)if("0"<=l&&"9">=l)r+=l;else{var a=void 0;i.push(parseInt(null!=(a=r)?a:"",10)),c--,n=0}else 3===n&&(""===l?(t.splice(0,0,"%{"),c--,n=0):"}"!==l?t.push(l):(n=t.join(""),/[A-Z]\w*/i.test(n)&&(l=(l=n.toUpperCase()).startsWith("BKY_")?l.substring(4):null)&&l in Nr.Msg$$module$build$src$core$msg?"string"==typeof(n=Nr.Msg$$module$build$src$core$msg[l])?Array.prototype.push.apply(i,Oo(n,e,s)):e?i.push(`${n}`):i.push(n):i.push("%{"+n+"}"),n=t.length=0))}for((e=t.join(""))&&i.push(e),a=[],t.length=0,o=0;o=s)return{hue:s,hex:Ro(s,mo(),255*bo())};if(s=$o(e))return{hue:null,hex:s};throw s='Invalid colour: "'+e+'"',t!==e&&(s+=' (from "'+t+'")'),Error(s)},wo=function(t){return void 0!==t.getProcedureModel&&void 0!==t.doProcedureUpdate&&void 0!==t.isProcedureDef},No=function(t){return void 0!==t.startPublishing&&void 0!==t.stopPublishing},Mo=function(e,s){t(Pr.FIELD,e,s)},Do=function(t){i(Pr.FIELD,t)},Nr.fromJson$$module$build$src$core$field_registry=function(t){return Iu.fromJsonInternal(t)},Bo=function(t){const e=l(Pr.FIELD,t.type);if(e){if("function"!=typeof e.fromJson)throw new TypeError("returned Field was not a IRegistrableField");return e.fromJson(t)}return console.warn("Blockly could not create a field of type "+t.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},xo=function(t){let e=!1;const s=t.map((([t,s])=>"string"==typeof t?[Ao(t),s]:(e=!0,[null!==t.alt?Object.assign({},t,{alt:Ao(t.alt)}):Object.assign({},t),s])));if(e||2>t.length)return{options:s};var i=s.map((([t])=>t)),o=Hi(i);t=Gi(i,o);const n=Vi(i,o);return!t&&!n||o<=t+n?{options:s}:(o=t?i[0].substring(0,t-1):void 0,i=n?i[0].substr(1-n):void 0,{options:Po(s,t,n),prefix:o,suffix:i})},Po=function(t,e,s){return t.map((([t,i])=>[t.substring(e,t.length-s),i]))},Fo=function(t){if(!Array.isArray(t))throw TypeError("FieldDropdown options must be an array.");if(!t.length)throw TypeError("FieldDropdown options must not be an empty array.");let e=!1;for(let s=0;s!t.getReturnTypes())).map((t=>[t.getName(),t.getParameters().map((t=>t.getName())),!1]));t.getBlocksByType("procedures_defnoreturn",!1).forEach((t=>{!wo(t)&&ie(t)&&e.push(t.getProcedureDef())}));const s=t.getProcedureMap().getProcedures().filter((t=>!!t.getReturnTypes())).map((t=>[t.getName(),t.getParameters().map((t=>t.getName())),!0]));return t.getBlocksByType("procedures_defreturn",!1).forEach((t=>{!wo(t)&&ie(t)&&s.push(t.getProcedureDef())})),e.sort(dn),s.sort(dn),[e,s]},dn=function(t,e){return t[0].localeCompare(e[0],void 0,{sensitivity:"base"})},Nr.findLegalName$$module$build$src$core$procedures=function(t,e){if(e.isInFlyout)return t;for(t=t||Nr.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed";!pn(t,e.workspace,e);){const e=t.match(/^(.*?)(\d+)$/);t=e?e[1]+(parseInt(e[2])+1):t+"2"}return t},pn=function(t,e,s){return!gn(t,e,s)},gn=function(t,e,s){for(const i of e.getAllBlocks(!1))if(i!==s&&ie(i)&&Nr.Names$$module$build$src$core$names.equals(i.getProcedureDef()[0],t))return!0;s=s&&wo(s)?null==s?void 0:s.getProcedureModel():void 0;for(const i of e.getProcedureMap().getProcedures())if(i!==s&&Nr.Names$$module$build$src$core$names.equals(i.getName(),t))return!0;return!1},Nr.rename$$module$build$src$core$procedures=function(t){var e=this.getSourceBlock();if(!e)throw new Eu;t=t.trim();const s=Nr.findLegalName$$module$build$src$core$procedures(t,e);wo(e)&&!e.isInsertionMarker()&&e.getProcedureModel().setName(s);const i=this.getValue();if(i!==t&&i!==s)for(t=e.workspace.getAllBlocks(!1),e=0;efn(e,t)||oe(e)&&Nr.Names$$module$build$src$core$names.equals(e.getProcedureCall(),t)))},fn=function(t,e){return wo(t)&&!t.isProcedureDef()&&t.getProcedureModel()&&Nr.Names$$module$build$src$core$names.equals(t.getProcedureModel().getName(),e)},Nr.mutateCallers$$module$build$src$core$procedures=function(t){const e=y();var s=t.getProcedureDef()[0];const i=t.mutationToDom(!0);t=bn(s,t.workspace);for(let n,r=0;n=t[r];r++){s=(s=n.mutationToDom())&&Mt(s),n.domToMutation&&n.domToMutation(i);var o=n.mutationToDom();s!==(o=o&&Mt(o))&&(O(!1),A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(n,"mutation",null,s,o)),O(e))}},Nr.getDefinition$$module$build$src$core$procedures=function(t,e){for(const s of e.getAllBlocks(!1))if(wo(s)&&s.isProcedureDef()&&Nr.Names$$module$build$src$core$names.equals(s.getProcedureModel().getName(),t)||ie(s)&&Nr.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],t))return s;return null},$n=function(t){return t.isDynamic},In=function(t){let e=t.outputConnection;return(!e||t.previousConnection&&t.previousConnection.isConnected())&&(e=t.previousConnection),e},Sn=function(t,e){if(!t||!e)throw Error("Cannot connect null connections.");t.targetConnection=e,e.targetConnection=t},Rn=function(t,e){let s=null;const i=null==(e=e.outputConnection)?void 0:e.getConnectionChecker();for(let o,n=0;o=t.inputList[n];n++){const t=o.connection;let n;if(t&&null!=(n=i)&&n.canConnect(e,t,!1)){if(s)return null;s=t}}return s},Cn=function(t,e){let s;for(;s=Rn(t,e);)if(!(t=s.targetBlock())||t.isShadow())return s;return null},kn=function(e,s){t(Pr.RENDERER,e,s)},On=function(t){i(Pr.RENDERER,t)},yn=function(t,e,s){return(t=new(r(Pr.RENDERER,t))(t)).init(e,s),t},An=function(t){he(t.getTargetWorkspace(),void 0,"String")},vn=function(t){he(t.getTargetWorkspace(),void 0,"Number")},Ln=function(t){he(t.getTargetWorkspace(),void 0,"Colour")},wn=function(t){let e=[],s=document.createElement("button");return s.setAttribute("text",Nr.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE),s.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),e.push(s),s=document.createElement("button"),s.setAttribute("text",Nr.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE),s.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),e.push(s),s=document.createElement("button"),s.setAttribute("text",Nr.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE),s.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),e.push(s),t.registerButtonCallback("CREATE_VARIABLE_STRING",An),t.registerButtonCallback("CREATE_VARIABLE_NUMBER",vn),t.registerButtonCallback("CREATE_VARIABLE_COLOUR",Ln),t=Nn(t),e.concat(t)},Nn=function(t){const e=[];if(0<(t=t.getAllVariables()).length){if(Gr.variables_set_dynamic){var s=t[t.length-1];const i=Nr.createElement$$module$build$src$core$utils$xml("block");i.setAttribute("type","variables_set_dynamic"),i.setAttribute("gap","24"),i.appendChild(me(s)),e.push(i)}if(Gr.variables_get_dynamic){t.sort(rc.compareByName);for(let i,o=0;i=t[o];o++)(s=Nr.createElement$$module$build$src$core$utils$xml("block")).setAttribute("type","variables_get_dynamic"),s.setAttribute("gap","8"),s.appendChild(me(i)),e.push(s)}}return e},Mn=function(t){t.resizeContents()},Dn=function(t){return void 0!==t.toCopyData},Bn=function(){Sp.registry.register({name:np.ESCAPE,preconditionFn:t=>!t.options.readOnly,callback:t=>(t.hideChaff(),!0),keyCodes:[Lu.ESC]})},xn=function(){Sp.registry.register({name:np.DELETE,preconditionFn(t){const e=T();return!t.options.readOnly&&null!=e&&e.isDeletable()},callback:(t,e)=>(e.preventDefault(),!ou.inProgress()&&(T().checkAndDelete(),!0)),keyCodes:[Lu.DELETE,Lu.BACKSPACE]})},Pn=function(){const t=Sp.registry.createSerializedKey(Lu.C,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.C,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.C,[Lu.META]);Sp.registry.register({name:np.COPY,preconditionFn(t){const e=T();return!t.options.readOnly&&!ou.inProgress()&&null!=e&&e.isDeletable()&&e.isMovable()&&Dn(e)},callback:(t,e)=>(e.preventDefault(),t.hideChaff(),!(!(e=T())||!Dn(e)||(Rp=e.toCopyData(),Cp=t,!Rp))),keyCodes:[t,e,s]})},Fn=function(){const t=Sp.registry.createSerializedKey(Lu.X,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.X,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.X,[Lu.META]);Sp.registry.register({name:np.CUT,preconditionFn(t){const e=T();return!t.options.readOnly&&!ou.inProgress()&&null!=e&&e instanceof op&&e.isDeletable()&&e.isMovable()&&!e.workspace.isFlyout},callback(t){const e=T();return!(!e||!Dn(e)||(Rp=e.toCopyData(),Cp=t,e.checkAndDelete(),0))},keyCodes:[t,e,s]})},Un=function(){const t=Sp.registry.createSerializedKey(Lu.V,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.V,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.V,[Lu.META]);Sp.registry.register({name:np.PASTE,preconditionFn:t=>!t.options.readOnly&&!ou.inProgress(),callback:()=>!(!Rp||!Cp||!ws(Rp,Cp)),keyCodes:[t,e,s]})},Hn=function(){const t=Sp.registry.createSerializedKey(Lu.Z,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.Z,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.Z,[Lu.META]);Sp.registry.register({name:np.UNDO,preconditionFn:t=>!t.options.readOnly&&!ou.inProgress(),callback:t=>(t.hideChaff(),t.undo(!1),!0),keyCodes:[t,e,s]})},Gn=function(){const t=Sp.registry.createSerializedKey(Lu.Z,[Lu.SHIFT,Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.Z,[Lu.SHIFT,Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.Z,[Lu.SHIFT,Lu.META]),i=Sp.registry.createSerializedKey(Lu.Y,[Lu.CTRL]);Sp.registry.register({name:np.REDO,preconditionFn:t=>!ou.inProgress()&&!t.options.readOnly,callback:t=>(t.hideChaff(),t.undo(!0),!0),keyCodes:[t,e,s,i]})},Vn=function(){Bn(),xn(),Pn(),Fn(),Un(),Hn(),Gn()},Wn=function(t){const e={id:t.getId(),name:t.getName(),returnTypes:t.getReturnTypes()};return t.getParameters().length?(e.parameters=t.getParameters().map((t=>Xn(t))),e):e},Xn=function(t){const e={id:t.getId(),name:t.getName()};return t.getTypes().length?(e.types=t.getTypes(),e):e},Yn=function(t,e,s,i){if(t=new t(i,s.name,s.id).setReturnTypes(s.returnTypes),!s.parameters)return t;for(const[o,n]of s.parameters.entries())t.insertParameter(Kn(e,n,i),o);return t},Kn=function(t,e,s){return t=new t(s,e.name,e.id),e.types&&t.setTypes(e.types),t},zn=function(t){const e=Object.create(null),s=a(Pr.SERIALIZER,!0);for(const i in s){let o;const n=null==(o=s[i])?void 0:o.save(t);n&&(e[i]=n)}return e},jn=function(t,e,{recordUndo:s=!1}={}){var i=a(Pr.SERIALIZER,!0);if(i){i=Object.entries(i).sort(((t,e)=>e[1].priority-t[1].priority));var o=y();O(s),(s=Nr.getGroup$$module$build$src$core$events$utils())||Nr.setGroup$$module$build$src$core$events$utils(!0),dt(),e instanceof Yd&&e.setResizesEnabled(!1);for(const[,t]of i.reverse()){let s;null==(s=t)||s.clear(e)}for(let[s,o]of i.reverse())if(t[s]){let i;null==(i=o)||i.load(t[s],e)}e instanceof Yd&&e.setResizesEnabled(!0),pt(),A(new(P(_l))(e)),Nr.setGroup$$module$build$src$core$events$utils(s),O(o)}},Jn=function(t,e,s){const i=s.getBoundingRectangle(),o=i.right-i.left,n=ui(e.top,i.top,e.top+e.height-(i.bottom-i.top))-i.top;let r=e.left;return e=e.left+e.width-o,t.RTL?r=Math.min(e,r):e=Math.max(r,e),!(!(t=ui(r,i.left,e)-i.left)&&!n||(s.moveBy(t,n,["inbounds"]),0))},qn=function(t){return e=>{var s,i=t.getMetricsManager();if(i.hasFixedEdges()&&!t.isDragging())if(-1!==Tl.indexOf(null!=(s=e.type)?s:"")){s=i.getScrollMetrics(!0);const o=Zn(t,e);o&&(i=Nr.getGroup$$module$build$src$core$events$utils()||!1,Nr.setGroup$$module$build$src$core$events$utils(e.group),Jn(t,s,o)&&!e.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),Nr.setGroup$$module$build$src$core$events$utils(i))}else e.type===hl&&e.scale&&e.oldScale&&e.scale>e.oldScale&&Qn(t)}},Zn=function(t,e){let s=null;switch(e.type){case Nr.CREATE$$module$build$src$core$events$utils:case Nr.MOVE$$module$build$src$core$events$utils:(s=t.getBlockById(e.blockId))&&(s=s.getRootBlock());break;case ul:case gl:s=t.getCommentById(e.commentId)}return s},Qn=function(t){var e=t.getMetricsManager();if(e.hasFixedEdges()&&!t.isDragging()){e=e.getScrollMetrics(!0);var s=t.getTopBoundedElements();for(let i,o=0;i=s[o];o++)Jn(t,e,i)}},tr=function(t,e){const s=[];for(const i of t.getIcons())To(i)&&!i.bubbleIsVisible()||(s.push({location:e,icon:i}),i.onLocationChange(e));for(const i of t.getChildren(!1))s.push(...tr(i,ca.sum(e,i.relativeCoords)));return s},er=function(){uh.registry.register({displayText:()=>Nr.Msg$$module$build$src$core$msg.UNDO,preconditionFn:t=>0Nr.Msg$$module$build$src$core$msg.REDO,preconditionFn:t=>0Nr.Msg$$module$build$src$core$msg.CLEAN_UP,preconditionFn:t=>t.workspace.isMovable()?1Nr.Msg$$module$build$src$core$msg.COLLAPSE_ALL,preconditionFn(t){if(t.workspace.options.collapse){t=t.workspace.getTopBlocks(!1);for(let e=0;eNr.Msg$$module$build$src$core$msg.EXPAND_ALL,preconditionFn(t){if(t.workspace.options.collapse){t=t.workspace.getTopBlocks(!1);for(let e=0;et.workspace?1===(t=ar(t.workspace).length)?Nr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Nr.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${t}`):"",preconditionFn:t=>t.workspace&&0e.length?cr(e):qt(Nr.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(e.length)),(function(t){t&&cr(e)}))}},scopeType:uh.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},ur=function(){er(),sr(),ir(),nr(),rr(),hr()},dr=function(){uh.registry.register({displayText:()=>Nr.Msg$$module$build$src$core$msg.DUPLICATE_BLOCK,preconditionFn:t=>!(t=t.block).isInFlyout&&t.isDeletable()&&t.isMovable()?t.isDuplicatable()?"enabled":"disabled":"hidden",callback(t){if(t.block){var e=t.block.toCopyData();e&&ws(e,t.block.workspace)}},scopeType:uh.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},pr=function(){uh.registry.register({displayText:t=>t.block.hasIcon(Pu.TYPE)?Nr.Msg$$module$build$src$core$msg.REMOVE_COMMENT:Nr.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:t=>!(t=t.block).isInFlyout&&t.workspace.options.comments&&!t.isCollapsed()&&t.isEditable()?"enabled":"hidden",callback(t){(t=t.block).hasIcon(Pu.TYPE)?t.setCommentText(null):t.setCommentText("")},scopeType:uh.ScopeType.BLOCK,id:"blockComment",weight:2})},gr=function(){uh.registry.register({displayText:t=>t.block.getInputsInline()?Nr.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:Nr.Msg$$module$build$src$core$msg.INLINE_INPUTS,preconditionFn(t){if(!(t=t.block).isInFlyout&&t.isMovable()&&!t.isCollapsed())for(let e=1;et.block.isCollapsed()?Nr.Msg$$module$build$src$core$msg.EXPAND_BLOCK:Nr.Msg$$module$build$src$core$msg.COLLAPSE_BLOCK,preconditionFn:t=>!(t=t.block).isInFlyout&&t.isMovable()&&t.workspace.options.collapse?"enabled":"hidden",callback(t){t.block.setCollapsed(!t.block.isCollapsed())},scopeType:uh.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Tr=function(){uh.registry.register({displayText:t=>t.block.isEnabled()?Nr.Msg$$module$build$src$core$msg.DISABLE_BLOCK:Nr.Msg$$module$build$src$core$msg.ENABLE_BLOCK,preconditionFn:t=>!(t=t.block).isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()?"disabled":"enabled":"hidden",callback(t){t=t.block;const e=Nr.getGroup$$module$build$src$core$events$utils();e||Nr.setGroup$$module$build$src$core$events$utils(!0),t.setEnabled(!t.isEnabled()),Nr.setGroup$$module$build$src$core$events$utils(e)},scopeType:uh.ScopeType.BLOCK,id:"blockDisable",weight:5})},mr=function(){uh.registry.register({displayText(t){var e=t.block;return t=e.getDescendants(!1).length,(e=e.getNextBlock())&&(t-=e.getDescendants(!1).length),1===t?Nr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Nr.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${t}`)},preconditionFn:t=>!t.block.isInFlyout&&t.block.isDeletable()?"enabled":"hidden",callback(t){t.block&&t.block.checkAndDelete()},scopeType:uh.ScopeType.BLOCK,id:"blockDelete",weight:6})},Er=function(){uh.registry.register({displayText:()=>Nr.Msg$$module$build$src$core$msg.HELP,preconditionFn:t=>("function"==typeof(t=t.block).helpUrl?t.helpUrl():t.helpUrl)?"enabled":"hidden",callback(t){t.block.showHelp()},scopeType:uh.ScopeType.BLOCK,id:"blockHelp",weight:7})},br=function(){dr(),pr(),gr(),_r(),Tr(),mr(),Er()},fr=function(){ur(),br()},$r=function(t,e){var s=null;let i;if(s="string"==typeof t?document.getElementById(t)||document.querySelector(t):t,!document.contains(s)&&document!==(null==(i=s)?void 0:i.ownerDocument))throw Error("Error: container is not in current document");t=new hu(e||{}),(e=document.createElement("div")).className="injectionDiv",e.tabIndex=0,xs(e,zc.LABEL,Nr.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),s.appendChild(e),s=Ir(e,t);const o=Sr(e,s,t);return Rr(o),_(o),f(o),e.addEventListener("focusin",(function(){_(o)})),o},Ir=function(t,e){t.setAttribute("dir","LTR"),et(e.hasCss,e.pathToMedia),t=it(ba.SVG,{xmlns:da,"xmlns:html":pa,"xmlns:xlink":ga,version:"1.1",class:"blocklySvg",tabindex:"0"},t);const s=it(ba.DEFS,{},t),i=String(Math.random()).substring(2);return e.gridPattern=nu.createDom(i,e.gridOptions,s),t},Sr=function(t,e,s){s.parentWorkspace=null;const i=(s=new Yd(s)).options;s.scale=i.zoomOptions.startScale,e.appendChild(s.createDom("blocklyMainBackground",t));var o=s.getRenderer().getClassName();return o&&ot(t,o),(o=s.getTheme().getClassName())&&ot(t,o),!i.hasCategories&&i.languageTree&&(t=s.addFlyout(ba.SVG),ct(t,e)),i.hasTrashcan&&s.addTrashcan(),i.zoomOptions&&i.zoomOptions.controls&&s.addZoomControls(),s.getThemeManager().subscribe(e,"workspaceBackgroundColour","background-color"),s.translate(0,0),s.addChangeListener(qn(s)),f(s),Us(),di(),to(),s},Rr=function(t){const e=t.options;var s=t.getParentSvg();if(Y(s.parentNode,"contextmenu",null,(function(t){j(t)||t.preventDefault()})),s=Y(window,"resize",null,(function(){lo(),t.hideComponents(!0),Ni(),Js(),f(t),Qn(t)})),t.setResizeHandlerWrapper(s),kr(),e.languageTree){s=t.getToolbox();const i=t.getFlyout(!0);s?s.init():i&&(i.init(t),i.show(e.languageTree),"function"==typeof i.scrollToStart&&i.scrollToStart())}e.hasTrashcan&&t.trashcan.init(),e.zoomOptions&&e.zoomOptions.controls&&t.zoomControls_.init(),e.moveOptions&&e.moveOptions.scrollbars?(t.scrollbar=new wp(t,!0===e.moveOptions.scrollbars||!!e.moveOptions.scrollbars.horizontal,!0===e.moveOptions.scrollbars||!!e.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),t.scrollbar.resize()):t.setMetrics({x:.5,y:.5}),e.hasSounds&&Or(e.pathToMedia,t)},Cr=function(t){const e=g();e&&!(j(t)||e.rendered&&!e.isVisible())&&Sp.registry.onKeyDown(e,t)},kr=function(){Og||(Y(document,"scroll",null,(function(){const t=u();for(let e,s=0;e=t[s];s++)e instanceof Yd&&e.updateInverseScreenCTM()})),Y(document,"keydown",null,Cr),K(document,"touchend",null,H),K(document,"touchcancel",null,H),jl&&Y(window,"orientationchange",document,(function(){f(g())}))),Og=!0},Or=function(t,e){function s(){for(;o.length;){const t=o.pop();t&&z(t)}i.preload()}const i=e.getAudioManager();i.load([t+"click.mp3",t+"click.wav",t+"click.ogg"],"click"),i.load([t+"disconnect.wav",t+"disconnect.mp3",t+"disconnect.ogg"],"disconnect"),i.load([t+"delete.mp3",t+"delete.ogg",t+"delete.wav"],"delete");const o=[];o.push(Y(document,"pointermove",null,s,!0)),o.push(Y(document,"touchstart",null,s,!0))},yr=function(t){return void 0!==t.getType&&void 0!==t.initView&&void 0!==t.dispose&&void 0!==t.getWeight&&void 0!==t.getSize&&void 0!==t.applyColour&&void 0!==t.hideForInsertionMarker&&void 0!==t.updateEditable&&void 0!==t.updateCollapsed&&void 0!==t.isShownWhenCollapsed&&void 0!==t.setOffsetInBlock&&void 0!==t.onLocationChange&&void 0!==t.onClick},Ar=function(t){return void 0!==t.paste},vr=function(t){return t.isSelectable()},Lr=function(t){g().hideChaff(t)},(wr=wr||{}).scope={},wr.ASSUME_ES5=!1,wr.ASSUME_NO_NATIVE_MAP=!1,wr.ASSUME_NO_NATIVE_SET=!1,wr.SIMPLE_FROUND_POLYFILL=!1,wr.ISOLATE_POLYFILLS=!1,wr.FORCE_POLYFILL_PROMISE=!1,wr.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,wr.defineProperty=wr.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,s){return t==Array.prototype||t==Object.prototype||(t[e]=s.value),t},wr.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof s.g&&s.g];for(var e=0;e>>0,wr.propertyToPolyfillSymbol[o]=wr.IS_SYMBOL_NATIVE?wr.global.Symbol(o):wr.POLYFILL_PREFIX+s+"$"+o),wr.defineProperty(i,wr.propertyToPolyfillSymbol[o],{configurable:!0,writable:!0,value:e})))},wr.polyfill("globalThis",(function(t){return t||wr.global}),"es_2020","es3"),wr.arrayIteratorImpl=function(t){var e=0;return function(){return e{const t=[];for(let e=0;20>e;e++)t[e]=fl.charAt(88*Math.random());return t.join("")}},Il=0,Sl={TEST_ONLY:$l};Sl.genUid=k,Sl.getNextUniqueId=C,zr="",jr=!0,Jr=0,Nr.CREATE$$module$build$src$core$events$utils="create",Nr.CREATE$$module$build$src$core$events$utils,Nr.DELETE$$module$build$src$core$events$utils="delete",Nr.DELETE$$module$build$src$core$events$utils,Nr.CHANGE$$module$build$src$core$events$utils="change",Nr.CHANGE$$module$build$src$core$events$utils,qr="block_field_intermediate_change",Nr.MOVE$$module$build$src$core$events$utils="move",Nr.MOVE$$module$build$src$core$events$utils,Zr="var_create",Qr="var_delete",tl="var_rename",el="ui",sl="drag",il="selected",ol="click",nl="marker_move",rl="bubble_open",ll="trashcan_open",al="toolbox_item_select",cl="theme_change",hl="viewport_change",ul="comment_create",dl="comment_delete",pl="comment_change",gl="comment_move",_l="finished_loading",Tl=[Nr.CREATE$$module$build$src$core$events$utils,Nr.MOVE$$module$build$src$core$events$utils,ul,gl],El={FIRE_QUEUE:ml=[],fireNow:L,fireInternal:v,setGroupInternal:D},(bl={BLOCK_CHANGE:Nr.CHANGE$$module$build$src$core$events$utils,BLOCK_CREATE:Nr.CREATE$$module$build$src$core$events$utils,BLOCK_DELETE:Nr.DELETE$$module$build$src$core$events$utils,BLOCK_DRAG:sl,BLOCK_FIELD_INTERMEDIATE_CHANGE:qr,BLOCK_MOVE:Nr.MOVE$$module$build$src$core$events$utils,BUBBLE_OPEN:rl,BUMP_EVENTS:Tl,CHANGE:Nr.CHANGE$$module$build$src$core$events$utils,CLICK:ol,COMMENT_CHANGE:pl,COMMENT_CREATE:ul,COMMENT_DELETE:dl,COMMENT_MOVE:gl,CREATE:Nr.CREATE$$module$build$src$core$events$utils,DELETE:Nr.DELETE$$module$build$src$core$events$utils,FINISHED_LOADING:_l,MARKER_MOVE:nl,MOVE:Nr.MOVE$$module$build$src$core$events$utils,SELECTED:il,TEST_ONLY:El,THEME_CHANGE:cl,TOOLBOX_ITEM_SELECT:al,TRASHCAN_OPEN:ll,UI:el,VAR_CREATE:Zr,VAR_DELETE:Qr,VAR_RENAME:tl,VIEWPORT_CHANGE:hl}).clearPendingUndo=N,bl.disable=Nr.disable$$module$build$src$core$events$utils,bl.disableOrphans=F,bl.enable=Nr.enable$$module$build$src$core$events$utils,bl.filter=w,bl.fire=A,bl.fromJson=x,bl.get=P,bl.getDescendantIds=B,bl.getGroup=Nr.getGroup$$module$build$src$core$events$utils,bl.getRecordUndo=y,bl.isEnabled=M,bl.setGroup=Nr.setGroup$$module$build$src$core$events$utils,bl.setRecordUndo=O;var Rl,Cl,kl=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Nr.getGroup$$module$build$src$core$events$utils(),this.recordUndo=y()}toJson(){return{type:this.type,group:this.group}}static fromJson(t,e,s){return s.isBlank=!1,s.group=t.group||"",s.workspaceId=e.id,s}isNull(){return!1}run(t){}getEventWorkspace_(){let t;if(this.workspaceId&&(t=h(this.workspaceId)),!t)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return t}},Ol=class extends kl{constructor(t){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=void 0===t,this.workspaceId=t||""}},yl=class extends Ol{constructor(t,e,s){null===(e=t?t.workspace.id:e)&&(e=void 0),super(e),this.type=ol,this.blockId=t?t.id:void 0,this.targetType=s}toJson(){const t=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");return t.targetType=this.targetType,t.blockId=this.blockId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new yl)).targetType=t.targetType,e.blockId=t.blockId,e}};(Cl=Rl||(Rl={})).BLOCK="block",Cl.WORKSPACE="workspace",Cl.ZOOM_CONTROLS="zoom_controls",t(Pr.EVENT,ol,yl);var Al={};Al.Click=yl,Al.ClickTarget=Rl;var vl,Ll,wl,Nl,Ml,Dl,Bl,xl,Pl,Fl,Ul=750,Hl="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Gl=null,Vl={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Wl=0,Xl={TOUCH_ENABLED:Hl,TOUCH_MAP:Vl};Xl.checkTouchIdentifier=X,Xl.clearTouchIdentifier=G,Xl.getTouchIdentifierFromEvent=W,Xl.longStart=U,Xl.longStop=H,Xl.shouldHandleEvent=V,function(t){function e(t){return-1!==s.indexOf(t.toUpperCase())}const s=(vl=t).toUpperCase();Ll=e("JavaFX"),wl=e("WebKit"),Nl=e("Gecko")&&!wl,Ml=e("Android"),t=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Dl=e("iPad")||e("Macintosh")&&0{e.push(this.componentData.get(t))})),e.sort((function(t,e){return t.weight-e.weight})),e.forEach((function(t){s.push(t.component)}))}else t.forEach((t=>{s.push(this.componentData.get(t).component)}));return s}};na.Capability=oa;var ra=!1,la='\n.blocklySvg {\n background-color: #fff;\n outline: none;\n overflow: hidden; /* IE overflows by default. */\n position: absolute;\n display: block;\n}\n\n.blocklyWidgetDiv {\n display: none;\n position: absolute;\n z-index: 99999; /* big value for bootstrap3 compatibility */\n}\n\n.injectionDiv {\n height: 100%;\n position: relative;\n overflow: hidden; /* So blocks in drag surface disappear at edges */\n touch-action: none;\n}\n\n.blocklyNonSelectable {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.blocklyBlockCanvas.blocklyCanvasTransitioning,\n.blocklyBubbleCanvas.blocklyCanvasTransitioning {\n transition: transform .5s;\n}\n\n.blocklyTooltipDiv {\n background-color: #ffffc7;\n border: 1px solid #ddc;\n box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);\n color: #000;\n display: none;\n font: 9pt sans-serif;\n opacity: .9;\n padding: 2px;\n position: absolute;\n z-index: 100000; /* big value for bootstrap3 compatibility */\n}\n\n.blocklyDropDownDiv {\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1000;\n display: none;\n border: 1px solid;\n border-color: #dadce0;\n background-color: #fff;\n border-radius: 2px;\n padding: 4px;\n box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv.blocklyFocused {\n box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownContent {\n max-height: 300px; /* @todo: spec for maximum height. */\n overflow: auto;\n overflow-x: hidden;\n position: relative;\n}\n\n.blocklyDropDownArrow {\n position: absolute;\n left: 0;\n top: 0;\n width: 16px;\n height: 16px;\n z-index: -1;\n background-color: inherit;\n border-color: inherit;\n}\n\n.blocklyDropDownButton {\n display: inline-block;\n float: left;\n padding: 0;\n margin: 4px;\n border-radius: 4px;\n outline: none;\n border: 1px solid;\n transition: box-shadow .1s;\n cursor: pointer;\n}\n\n.blocklyArrowTop {\n border-top: 1px solid;\n border-left: 1px solid;\n border-top-left-radius: 4px;\n border-color: inherit;\n}\n\n.blocklyArrowBottom {\n border-bottom: 1px solid;\n border-right: 1px solid;\n border-bottom-right-radius: 4px;\n border-color: inherit;\n}\n\n.blocklyResizeSE {\n cursor: se-resize;\n fill: #aaa;\n}\n\n.blocklyResizeSW {\n cursor: sw-resize;\n fill: #aaa;\n}\n\n.blocklyResizeLine {\n stroke: #515A5A;\n stroke-width: 1;\n}\n\n.blocklyHighlightedConnectionPath {\n fill: none;\n stroke: #fc3;\n stroke-width: 4px;\n}\n\n.blocklyPathLight {\n fill: none;\n stroke-linecap: round;\n stroke-width: 1;\n}\n\n.blocklySelected>.blocklyPathLight {\n display: none;\n}\n\n.blocklyDraggable {\n cursor: grab;\n cursor: -webkit-grab;\n}\n\n.blocklyDragging {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n /* Changes cursor on mouse down. Not effective in Firefox because of\n https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */\n.blocklyDraggable:active {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n.blocklyDragging.blocklyDraggingDelete {\n cursor: url("<<>>/handdelete.cur"), auto;\n}\n\n.blocklyDragging>.blocklyPath,\n.blocklyDragging>.blocklyPathLight {\n fill-opacity: .8;\n stroke-opacity: .8;\n}\n\n.blocklyDragging>.blocklyPathDark {\n display: none;\n}\n\n.blocklyDisabled>.blocklyPath {\n fill-opacity: .5;\n stroke-opacity: .5;\n}\n\n.blocklyDisabled>.blocklyPathLight,\n.blocklyDisabled>.blocklyPathDark {\n display: none;\n}\n\n.blocklyInsertionMarker>.blocklyPath,\n.blocklyInsertionMarker>.blocklyPathLight,\n.blocklyInsertionMarker>.blocklyPathDark {\n fill-opacity: .2;\n stroke: none;\n}\n\n.blocklyMultilineText {\n font-family: monospace;\n}\n\n.blocklyNonEditableText>text {\n pointer-events: none;\n}\n\n.blocklyFlyout {\n position: absolute;\n z-index: 20;\n}\n\n.blocklyText text {\n cursor: default;\n}\n\n/*\n Don\'t allow users to select text. It gets annoying when trying to\n drag a block and selected text moves instead.\n*/\n.blocklySvg text {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n cursor: inherit;\n}\n\n.blocklyHidden {\n display: none;\n}\n\n.blocklyFieldDropdown:not(.blocklyHidden) {\n display: block;\n}\n\n.blocklyIconGroup {\n cursor: default;\n}\n\n.blocklyIconGroup:not(:hover),\n.blocklyIconGroupReadonly {\n opacity: .6;\n}\n\n.blocklyIconShape {\n fill: #00f;\n stroke: #fff;\n stroke-width: 1px;\n}\n\n.blocklyIconSymbol {\n fill: #fff;\n}\n\n.blocklyMinimalBody {\n margin: 0;\n padding: 0;\n}\n\n.blocklyHtmlInput {\n border: none;\n border-radius: 4px;\n height: 100%;\n margin: 0;\n outline: none;\n padding: 0;\n width: 100%;\n text-align: center;\n display: block;\n box-sizing: border-box;\n}\n\n/* Remove the increase and decrease arrows on the field number editor */\ninput.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,\ninput.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ninput[type=number] {\n -moz-appearance: textfield;\n}\n\n.blocklyMainBackground {\n stroke-width: 1;\n stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */\n}\n\n.blocklyMutatorBackground {\n fill: #fff;\n stroke: #ddd;\n stroke-width: 1;\n}\n\n.blocklyFlyoutBackground {\n fill: #ddd;\n fill-opacity: .8;\n}\n\n.blocklyMainWorkspaceScrollbar {\n z-index: 20;\n}\n\n.blocklyFlyoutScrollbar {\n z-index: 30;\n}\n\n.blocklyScrollbarHorizontal,\n.blocklyScrollbarVertical {\n position: absolute;\n outline: none;\n}\n\n.blocklyScrollbarBackground {\n opacity: 0;\n}\n\n.blocklyScrollbarHandle {\n fill: #ccc;\n}\n\n.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyScrollbarHandle:hover {\n fill: #bbb;\n}\n\n/* Darken flyout scrollbars due to being on a grey background. */\n/* By contrast, workspace scrollbars are on a white background. */\n.blocklyFlyout .blocklyScrollbarHandle {\n fill: #bbb;\n}\n\n.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyFlyout .blocklyScrollbarHandle:hover {\n fill: #aaa;\n}\n\n.blocklyInvalidInput {\n background: #faa;\n}\n\n.blocklyVerticalMarker {\n stroke-width: 3px;\n fill: rgba(255,255,255,.5);\n pointer-events: none;\n}\n\n.blocklyComputeCanvas {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n.blocklyNoPointerEvents {\n pointer-events: none;\n}\n\n.blocklyContextMenu {\n border-radius: 4px;\n max-height: 100%;\n}\n\n.blocklyDropdownMenu {\n border-radius: 2px;\n padding: 0 !important;\n}\n\n.blocklyDropdownMenu .blocklyMenuItem {\n /* 28px on the left for icon or checkbox. */\n padding-left: 28px;\n}\n\n/* BiDi override for the resting state. */\n.blocklyDropdownMenu .blocklyMenuItemRtl {\n /* Flip left/right padding for BiDi. */\n padding-left: 5px;\n padding-right: 28px;\n}\n\n.blocklyWidgetDiv .blocklyMenu {\n background: #fff;\n border: 1px solid transparent;\n box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n font: normal 13px Arial, sans-serif;\n margin: 0;\n outline: none;\n padding: 4px 0;\n position: absolute;\n overflow-y: auto;\n overflow-x: hidden;\n max-height: 100%;\n z-index: 20000; /* Arbitrary, but some apps depend on it... */\n}\n\n.blocklyWidgetDiv .blocklyMenu.blocklyFocused {\n box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv .blocklyMenu {\n background: inherit; /* Compatibility with gapi, reset from goog-menu */\n border: inherit; /* Compatibility with gapi, reset from goog-menu */\n font: normal 13px "Helvetica Neue", Helvetica, sans-serif;\n outline: none;\n position: relative; /* Compatibility with gapi, reset from goog-menu */\n z-index: 20000; /* Arbitrary, but some apps depend on it... */\n}\n\n/* State: resting. */\n.blocklyMenuItem {\n border: none;\n color: #000;\n cursor: pointer;\n list-style: none;\n margin: 0;\n /* 7em on the right for shortcut. */\n min-width: 7em;\n padding: 6px 15px;\n white-space: nowrap;\n}\n\n/* State: disabled. */\n.blocklyMenuItemDisabled {\n color: #ccc;\n cursor: inherit;\n}\n\n/* State: hover. */\n.blocklyMenuItemHighlight {\n background-color: rgba(0,0,0,.1);\n}\n\n/* State: selected/checked. */\n.blocklyMenuItemCheckbox {\n height: 16px;\n position: absolute;\n width: 16px;\n}\n\n.blocklyMenuItemSelected .blocklyMenuItemCheckbox {\n background: url(<<>>/sprites.png) no-repeat -48px -16px;\n float: left;\n margin-left: -24px;\n position: static; /* Scroll with the menu. */\n}\n\n.blocklyMenuItemRtl .blocklyMenuItemCheckbox {\n float: right;\n margin-right: -24px;\n}\n\n.blocklyBlockDragSurface {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: visible !important;\n z-index: 80;\n pointer-events: none;\n}\n',aa={};aa.inject=et,aa.register=tt;var ca=class{constructor(t,e){this.x=t,this.y=e}clone(){return new ca(this.x,this.y)}scale(t){return this.x*=t,this.y*=t,this}translate(t,e){return this.x+=t,this.y+=e,this}static equals(t,e){return t===e||!(!t||!e)&&t.x===e.x&&t.y===e.y}static distance(t,e){const s=t.x-e.x;return t=t.y-e.y,Math.sqrt(s*s+t*t)}static magnitude(t){return Math.sqrt(t.x*t.x+t.y*t.y)}static difference(t,e){return new ca(t.x-e.x,t.y-e.y)}static sum(t,e){return new ca(t.x+e.x,t.y+e.y)}},ha={};ha.warn=st;var ua,da="http://www.w3.org/2000/svg",pa="http://www.w3.org/1999/xhtml",ga="http://www.w3.org/1999/xlink";!function(t){t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE"}(ua||(ua={}));var _a=null,Ta=0,ma=null,Ea={HTML_NS:pa};Ea.NodeType=ua,Ea.SVG_NS=da,Ea.XLINK_NS=ga,Ea.addClass=ot,Ea.containsNode=ht,Ea.createSvgElement=it,Ea.getFastTextWidth=_t,Ea.getFastTextWidthWithSizeString=Tt,Ea.getTextWidth=gt,Ea.hasClass=lt,Ea.insertAfter=ct,Ea.measureFontMetrics=mt,Ea.removeClass=rt,Ea.removeClasses=nt,Ea.removeNode=at,Ea.setCssTransform=ut,Ea.startTextWidthCache=dt,Ea.stopTextWidthCache=pt;var ba=class{constructor(t){this.tagName=t}toString(){return this.tagName}};ba.ANIMATE=new ba("animate"),ba.CIRCLE=new ba("circle"),ba.CLIPPATH=new ba("clipPath"),ba.DEFS=new ba("defs"),ba.FECOMPOSITE=new ba("feComposite"),ba.FECOMPONENTTRANSFER=new ba("feComponentTransfer"),ba.FEFLOOD=new ba("feFlood"),ba.FEFUNCA=new ba("feFuncA"),ba.FEGAUSSIANBLUR=new ba("feGaussianBlur"),ba.FEPOINTLIGHT=new ba("fePointLight"),ba.FESPECULARLIGHTING=new ba("feSpecularLighting"),ba.FILTER=new ba("filter"),ba.FOREIGNOBJECT=new ba("foreignObject"),ba.G=new ba("g"),ba.IMAGE=new ba("image"),ba.LINE=new ba("line"),ba.PATH=new ba("path"),ba.PATTERN=new ba("pattern"),ba.POLYGON=new ba("polygon"),ba.RECT=new ba("rect"),ba.SVG=new ba("svg"),ba.TEXT=new ba("text"),ba.TSPAN=new ba("tspan");var fa=class{constructor(t,e,s,i){this.top=t,this.bottom=e,this.left=s,this.right=i}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}intersects(t){return!(this.left>t.right||this.rightt.bottom||this.bottom=t||isNaN(t)?0:Math.min(t,this.scrollbarLength)}setHandleLength(t){this.handleLength=t,this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(t){return 0>=t||isNaN(t)?0:Math.min(t,this.scrollbarLength-this.handleLength)}setHandlePosition(t){this.handlePosition=t,this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(t){this.scrollbarLength=t,this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength)),this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(t,e){this.position.x=t,this.position.y=e,ut(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(t){(t||(t=this.workspace.getMetrics()))&&(this.oldHostMetrics&&Oa.metricsAreEquivalent(t,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(t):this.resizeVertical(t),this.oldHostMetrics=t,this.updateMetrics()))}requiresViewResize(t){return!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==t.viewWidth||this.oldHostMetrics.viewHeight!==t.viewHeight||this.oldHostMetrics.absoluteLeft!==t.absoluteLeft||this.oldHostMetrics.absoluteTop!==t.absoluteTop}resizeHorizontal(t){this.requiresViewResize(t)?this.resizeViewHorizontal(t):this.resizeContentHorizontal(t)}resizeViewHorizontal(t){var e=t.viewWidth-2*this.margin;this.pair&&(e-=Oa.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),e=t.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(e+=Oa.scrollbarThickness),this.setPosition(e,t.absoluteTop+t.viewHeight-Oa.scrollbarThickness-this.margin),this.resizeContentHorizontal(t)}resizeContentHorizontal(t){if(t.viewWidth>=t.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var e=this.scrollbarLength*t.viewWidth/t.scrollWidth;e=this.constrainHandleLength(e),this.setHandleLength(e),e=t.scrollWidth-t.viewWidth;var s=this.scrollbarLength-this.handleLength;t=(t.viewLeft-t.scrollLeft)/e*s,t=this.constrainHandlePosition(t),this.setHandlePosition(t),this.ratio=s/e}}resizeVertical(t){this.requiresViewResize(t)?this.resizeViewVertical(t):this.resizeContentVertical(t)}resizeViewVertical(t){let e=t.viewHeight-2*this.margin;this.pair&&(e-=Oa.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),this.setPosition(this.workspace.RTL?t.absoluteLeft+this.margin:t.absoluteLeft+t.viewWidth-Oa.scrollbarThickness-this.margin,t.absoluteTop+this.margin),this.resizeContentVertical(t)}resizeContentVertical(t){if(t.viewHeight>=t.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var e=this.scrollbarLength*t.viewHeight/t.scrollHeight;e=this.constrainHandleLength(e),this.setHandleLength(e),e=t.scrollHeight-t.viewHeight;var s=this.scrollbarLength-this.handleLength;t=(t.viewTop-t.scrollTop)/e*s,t=this.constrainHandlePosition(t),this.setHandlePosition(t),this.ratio=s/e}}isVisible(){return this.isHandleVisible}setContainerVisible(t){const e=t!==this.containerVisible;this.containerVisible=t,e&&this.updateDisplay_()}setVisible(t){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(t)}setVisibleInternal(t){const e=t!==this.isVisible();this.isHandleVisible=t,e&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(t){if(this.workspace.markFocused(),G(),this.cleanUp(),J(t))t.stopPropagation();else{var e=q(t,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());e=this.horizontal?e.x:e.y;var s=yt(this.svgHandle);s=this.horizontal?s.x:s.y;var i=this.handlePosition,o=.95*this.handleLength;e<=s?i-=o:e>=s+this.handleLength&&(i+=o),this.setHandlePosition(this.constrainHandlePosition(i)),this.updateMetrics(),t.stopPropagation(),t.preventDefault()}}onMouseDownHandle(t){this.workspace.markFocused(),this.cleanUp(),J(t)?t.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?t.clientX:t.clientY,this.onMouseUpWrapper_=Y(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=Y(document,"pointermove",this,this.onMouseMoveHandle),t.stopPropagation(),t.preventDefault())}onMouseMoveHandle(t){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?t.clientX:t.clientY)-this.startDragMouse))),this.updateMetrics()}onMouseUpHandle(){G(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(z(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(z(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){let t=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(t)&&(t=0),t}updateMetrics(){const t=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:t}):this.workspace.setMetrics({y:t})}set(t,e){this.setHandlePosition(this.constrainHandlePosition(t*this.ratio)),(e||void 0===e)&&this.updateMetrics()}setOrigin(t,e){this.origin=new ca(t,e)}static metricsAreEquivalent(t,e){return t.viewWidth===e.viewWidth&&t.viewHeight===e.viewHeight&&t.viewLeft===e.viewLeft&&t.viewTop===e.viewTop&&t.absoluteTop===e.absoluteTop&&t.absoluteLeft===e.absoluteLeft&&t.scrollWidth===e.scrollWidth&&t.scrollHeight===e.scrollHeight&&t.scrollLeft===e.scrollLeft&&t.scrollTop===e.scrollTop}};Oa.scrollbarThickness=Hl?25:15,Oa.DEFAULT_SCROLLBAR_MARGIN=.5;var ya={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},Aa={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:va,DOMParser:La,XMLSerializer:wa}=globalThis;La&&(ya=new La),wa&&(Aa=new wa);var Na="https://developers.google.com/blockly/xml",Ma=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,Da={NAME_SPACE:Na};Da.createElement=Nr.createElement$$module$build$src$core$utils$xml,Da.createTextNode=Nr.createTextNode$$module$build$src$core$utils$xml,Da.domToText=Mt,Da.injectDependencies=Nt,Da.textToDom=Nr.textToDom$$module$build$src$core$utils$xml;var Ba,xa="categoryToolbox",Pa="flyoutToolbox";!function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM",t[t.LEFT=2]="LEFT",t[t.RIGHT=3]="RIGHT"}(Ba||(Ba={}));var Fa,Ua,Ha,Ga={hasCategoriesInternal:Ut},Va={};Va.Position=Ba,Va.TEST_ONLY=Ga,Va.convertFlyoutDefToJsonArray=Pt,Va.convertToolboxDefToJson=Bt,Va.hasCategories=Ft,Va.isCategoryCollapsible=Ht,Va.parseToolboxTree=Xt,function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM"}(Fa||(Fa={})),function(t){t[t.LEFT=0]="LEFT",t[t.RIGHT=1]="RIGHT"}(Ua||(Ua={})),function(t){t[t.UP=0]="UP",t[t.DOWN=1]="DOWN"}(Ha||(Ha={}));var Wa={};Wa.bumpDirection=Ha,Wa.bumpPositionRect=zt,Wa.getCornerOppositeToolbox=Kt,Wa.getStartPositionRect=Yt,Wa.horizontalPosition=Ua,Wa.verticalPosition=Fa;var Xa=96,Ya=124,Ka="sprites.png",za=class{constructor(t){this.workspace=t,this.id="zoomControls",this.boundEvents=[],this.zoomResetGroup=this.zoomOutGroup=this.zoomInGroup=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=it(ba.G,{});const t=String(Math.random()).substring(2);return this.createZoomOutSvg(t),this.createZoomInSvg(t),this.workspace.isMovable()&&this.createZoomResetSvg(t),this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:2,capabilities:[na.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&at(this.svgGroup);for(const t of this.boundEvents)z(t);this.boundEvents.length=0}getBoundingRectangle(){let t=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(t+=this.LARGE_SPACING+this.HEIGHT),new fa(this.top,this.top+t,this.left,this.left+this.WIDTH)}position(t,e){if(this.initialized){var s,i=Kt(this.workspace,t),o=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(o+=this.LARGE_SPACING+this.HEIGHT),t=Yt(i,new $a(this.WIDTH,o),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,t,this.workspace),i=i.vertical,e=zt(t,this.MARGIN_VERTICAL,i===Fa.TOP?Ha.DOWN:Ha.UP,e),i===Fa.TOP){var n,r=this.SMALL_SPACING+this.HEIGHT;null==(n=this.zoomInGroup)||n.setAttribute("transform","translate(0, "+r+")"),this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(r+this.LARGE_SPACING+this.HEIGHT)+")")}else{let t;n=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0,null==(t=this.zoomInGroup)||t.setAttribute("transform","translate(0, "+n+")"),n=n+this.SMALL_SPACING+this.HEIGHT,null==(r=this.zoomOutGroup)||r.setAttribute("transform","translate(0, "+n+")")}this.top=e.top,this.left=e.left,null==(s=this.svgGroup)||s.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(t){this.zoomOutGroup=it(ba.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const e=it(ba.CLIPPATH,{id:"blocklyZoomoutClipPath"+t},this.zoomOutGroup);it(ba.RECT,{width:32,height:32},e),it(ba.IMAGE,{width:Xa,height:Ya,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+t+")"},this.zoomOutGroup).setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),this.boundEvents.push(Y(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(t){this.zoomInGroup=it(ba.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const e=it(ba.CLIPPATH,{id:"blocklyZoominClipPath"+t},this.zoomInGroup);it(ba.RECT,{width:32,height:32},e),it(ba.IMAGE,{width:Xa,height:Ya,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+t+")"},this.zoomInGroup).setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),this.boundEvents.push(Y(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(t,e){this.workspace.markFocused(),this.workspace.zoomCenter(t),this.fireZoomEvent(),G(),e.stopPropagation(),e.preventDefault()}createZoomResetSvg(t){this.zoomResetGroup=it(ba.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const e=it(ba.CLIPPATH,{id:"blocklyZoomresetClipPath"+t},this.zoomResetGroup);it(ba.RECT,{width:32,height:32},e),it(ba.IMAGE,{width:Xa,height:Ya,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+t+")"},this.zoomResetGroup).setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),this.boundEvents.push(Y(this.zoomResetGroup,"pointerdown",null,this.resetZoom.bind(this)))}resetZoom(t){this.workspace.markFocused();const e=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition(),this.workspace.zoomCenter(e),this.workspace.scrollCenter(),setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500),this.fireZoomEvent(),G(),t.stopPropagation(),t.preventDefault()}fireZoomEvent(){const t=new(P(ol))(null,this.workspace.id,"zoom_controls");A(t)}};tt("\n.blocklyZoom>image, .blocklyZoom>svg>image {\n opacity: .4;\n}\n\n.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {\n opacity: .6;\n}\n\n.blocklyZoom>image:active, .blocklyZoom>svg>image:active {\n opacity: .8;\n}\n");var ja=class{constructor(t){this.name=t}toString(){return this.name}equals(t){return this.name===t.toString()}};ja.MUTATOR=new ja("mutator"),ja.WARNING=new ja("warning"),ja.COMMENT=new ja("comment"),function(t){t[t.VALUE=1]="VALUE",t[t.STATEMENT=3]="STATEMENT",t[t.DUMMY=5]="DUMMY",t[t.CUSTOM=6]="CUSTOM",t[t.END_ROW=7]="END_ROW"}(Nr.inputTypes$$module$build$src$core$inputs$input_types||(Nr.inputTypes$$module$build$src$core$inputs$input_types={})),Nr.inputTypes$$module$build$src$core$inputs$input_types;var Ja,qa,Za=function(t,e){window.alert(t),e&&e()},Qa=function(t,e){e(window.confirm(t))},tc=function(t,e,s){s(window.prompt(t,e))},ec={confirmInternal:Zt},sc={TEST_ONLY:ec};sc.alert=jt,sc.confirm=qt,sc.prompt=te,sc.setAlert=Jt,sc.setConfirm=Qt,sc.setPrompt=ee,Nr.Msg$$module$build$src$core$msg=Object.create(null),Ja=function(t){Object.keys(t).forEach((function(e){Nr.Msg$$module$build$src$core$msg[e]=t[e]}))},qa={Msg:Nr.Msg$$module$build$src$core$msg,setLocale:Ja};var ic={};ic.isLegacyProcedureCallBlock=oe,ic.isLegacyProcedureDefBlock=ie;var oc=class extends kl{constructor(t){super(),this.isBlank=void 0===t,t&&(this.varId=t.getId(),this.workspaceId=t.workspace.id)}toJson(){const t=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");return t.varId=this.varId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new oc)).varId=t.varId,e}},nc=class extends oc{constructor(t){super(t),this.type=Zr,t&&(this.varType=t.type,this.varName=t.name)}toJson(){const t=super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return t.varType=this.varType,t.varName=this.varName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new nc)).varType=t.varType,e.varName=t.varName,e}run(t){const e=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t?e.createVariable(this.varName,this.varType,this.varId):e.deleteVariableById(this.varId)}};t(Pr.EVENT,Zr,nc);var rc=class{constructor(t,e,s,i){this.workspace=t,this.name=e,this.type=s||"",this.id_=i||k()}getId(){return this.id_}static compareByName(t,e){return t.name.localeCompare(e.name,void 0,{sensitivity:"base"})}},lc="VARIABLE",ac="ijkmnopqrstuvwxyzabcdefgh",cc={generateUniqueNameInternal:ae},hc={CATEGORY_NAME:lc,TEST_ONLY:cc,VAR_LETTER_OPTIONS:ac};hc.allDeveloperVariables=Nr.allDeveloperVariables$$module$build$src$core$variables,hc.allUsedVarModels=Nr.allUsedVarModels$$module$build$src$core$variables,hc.createVariableButtonHandler=he,hc.flyoutCategory=ne,hc.flyoutCategoryBlocks=re,hc.generateUniqueName=le,hc.generateUniqueNameFromOptions=ce,hc.generateVariableFieldDom=me,hc.getAddedVariables=be,hc.getOrCreateVariablePackage=Nr.getOrCreateVariablePackage$$module$build$src$core$variables,hc.getVariable=Nr.getVariable$$module$build$src$core$variables,hc.nameUsedWithAnyType=pe,hc.nameUsedWithConflictingParam=ge,hc.promptName=ue,hc.renameVariable=Nr.renameVariable$$module$build$src$core$variables;var uc=class{constructor(t,e,s,i,o){this.workspace=t,this.editable=this.movable=this.deletable=!0,this.disposed_=!1,this.isComment=!0,this.id=o&&!t.getCommentById(o)?o:k(),t.addTopComment(this),this.xy_=new ca(0,0),this.height_=s,this.width_=i,this.RTL=t.RTL,this.content_=e,uc.fireCreateEvent(this)}dispose(){this.disposed_||(M()&&A(new(P(dl))(this)),this.workspace.removeTopComment(this),this.disposed_=!0)}getHeight(){return this.height_}setHeight(t){this.height_=t}getWidth(){return this.width_}setWidth(t){this.width_=t}getRelativeToSurfaceXY(){return new ca(this.xy_.x,this.xy_.y)}moveBy(t,e){const s=new(P(gl))(this);this.xy_.translate(t,e),s.recordNew(),A(s)}isDeletable(){return this.deletable&&!(this.workspace&&this.workspace.options.readOnly)}setDeletable(t){this.deletable=t}isMovable(){return this.movable&&!(this.workspace&&this.workspace.options.readOnly)}setMovable(t){this.movable=t}isEditable(){return this.editable&&!(this.workspace&&this.workspace.options.readOnly)}setEditable(t){this.editable=t}getContent(){return this.content_}setContent(t){this.content_!==t&&(A(new(P(pl))(this,this.content_,t)),this.content_=t)}toXmlWithXY(t){return(t=this.toXml(t)).setAttribute("x",String(Math.round(this.xy_.x))),t.setAttribute("y",String(Math.round(this.xy_.y))),t.setAttribute("h",String(this.height_)),t.setAttribute("w",String(this.width_)),t}toXml(t){const e=Nr.createElement$$module$build$src$core$utils$xml("comment");return t||(e.id=this.id),e.textContent=this.getContent(),e}static fireCreateEvent(t){if(M()){const e=Nr.getGroup$$module$build$src$core$events$utils();e||Nr.setGroup$$module$build$src$core$events$utils(!0);try{A(new(P(ul))(t))}finally{Nr.setGroup$$module$build$src$core$events$utils(e)}}}static fromXml(t,e){var s=uc.parseAttributes(t);return e=new uc(e,s.content,s.h,s.w,s.id),s=t.getAttribute("x"),t=t.getAttribute("y"),s=s?parseInt(s,10):NaN,t=t?parseInt(t,10):NaN,isNaN(s)||isNaN(t)||e.moveBy(s,t),uc.fireCreateEvent(e),e}static parseAttributes(t){const e=t.getAttribute("h"),s=t.getAttribute("w"),i=t.getAttribute("x"),o=t.getAttribute("y"),n=t.getAttribute("id");if(!n)throw Error("No ID present in XML comment definition.");let r;return{id:n,h:e?parseInt(e):100,w:s?parseInt(s):100,x:i?parseInt(i):NaN,y:o?parseInt(o):NaN,content:null!=(r=t.textContent)?r:""}}},dc=class extends Ol{constructor(t,e,s){super(s),this.type=il,this.oldElementId=null!=t?t:void 0,this.newElementId=null!=e?e:void 0}toJson(){const t=super.toJson();return t.oldElementId=this.oldElementId,t.newElementId=this.newElementId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new dc)).oldElementId=t.oldElementId,e.newElementId=t.newElementId,e}};t(Pr.EVENT,il,dc);var pc={};pc.register=fe,pc.unregister=$e;var gc=class{paste(t,e,s){const i=t.commentState;if(s)i.setAttribute("x",`${s.x}`),i.setAttribute("y",`${s.y}`);else{var o;let t;s=parseInt(null!=(o=i.getAttribute("x"))?o:"0")+50,o=parseInt(null!=(t=i.getAttribute("y"))?t:"0")+50,i.setAttribute("x",`${s}`),i.setAttribute("y",`${o}`)}return _c.fromXmlRendered(t.commentState,e)}};gc.TYPE="workspace-comment",fe(gc.TYPE,new gc);var _c=class extends uc{constructor(t,e,s,i,o){super(t,e,s,i,o),this.onMouseMoveWrapper=this.onMouseUpWrapper=null,this.eventsInit=!1,this.deleteIconBorder=this.deleteGroup=this.resizeGroup=this.foreignObject=this.svgHandleTarget=this.svgRectTarget=this.textarea=null,this.rendered=this.autoLayout=this.focused=!1,this.svgGroup=it(ba.G,{class:"blocklyComment"}),this.workspace=t,this.svgRect_=it(ba.RECT,{class:"blocklyCommentRect",x:0,y:0,rx:3,ry:3}),this.svgGroup.appendChild(this.svgRect_),this.render()}dispose(){this.disposed_||(T()===this&&(this.unselect(),this.workspace.cancelCurrentGesture()),M()&&A(new(P(dl))(this)),at(this.svgGroup),Nr.disable$$module$build$src$core$events$utils(),super.dispose(),Nr.enable$$module$build$src$core$events$utils())}initSvg(t){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");this.workspace.options.readOnly||this.eventsInit||(Y(this.svgRectTarget,"pointerdown",this,this.pathMouseDown),Y(this.svgHandleTarget,"pointerdown",this,this.pathMouseDown)),this.eventsInit=!0,this.updateMovable(),this.getSvgRoot().parentNode||this.workspace.getBubbleCanvas().appendChild(this.getSvgRoot()),!t&&this.textarea&&this.textarea.select()}pathMouseDown(t){const e=this.workspace.getGesture(t);e&&e.handleBubbleStart(t,this)}showContextMenu(t){throw Error("The implementation of showContextMenu should be monkey-patched in by blockly.ts")}select(){if(T()!==this){var t=null;if(T()){t=T().id,Nr.disable$$module$build$src$core$events$utils();try{T().unselect()}finally{Nr.enable$$module$build$src$core$events$utils()}}t=new(P(il))(t,this.id,this.workspace.id),A(t),m(this),this.addSelect()}}unselect(){if(T()===this){var t=new(P(il))(this.id,null,this.workspace.id);A(t),m(null),this.removeSelect(),this.blurFocus()}}addSelect(){ot(this.svgGroup,"blocklySelected"),this.setFocus()}removeSelect(){ot(this.svgGroup,"blocklySelected"),this.blurFocus()}addFocus(){ot(this.svgGroup,"blocklyFocused")}removeFocus(){rt(this.svgGroup,"blocklyFocused")}getRelativeToSurfaceXY(){const t=this.workspace.getLayerManager();if(!t)throw Error("Cannot calculate position because the workspace has not been appended");let e=0,s=0,i=this.getSvgRoot();if(i)do{const t=Ot(i);e+=t.x,s+=t.y,i=i.parentNode}while(i&&!t.hasLayer(i)&&null!==i);return this.xy_=new ca(e,s)}moveBy(t,e){const s=new(P(gl))(this),i=this.getRelativeToSurfaceXY();this.translate(i.x+t,i.y+e),this.xy_=new ca(i.x+t,i.y+e),s.recordNew(),A(s),this.workspace.resizeContents()}translate(t,e){this.xy_=new ca(t,e),this.getSvgRoot().setAttribute("transform","translate("+t+","+e+")")}moveDuringDrag(t){t=`translate(${t.x}, ${t.y})`,this.getSvgRoot().setAttribute("transform",t)}moveTo(t,e){this.translate(t,e)}clearTransformAttributes(){this.getSvgRoot().removeAttribute("transform")}getBoundingRectangle(){var t=this.getRelativeToSurfaceXY();const e=this.getHeightWidth(),s=t.y,i=t.y+e.height;let o;return this.RTL?(o=t.x-e.width,t=t.x):(o=t.x,t=t.x+e.width),new fa(s,i,o,t)}updateMovable(){this.isMovable()?ot(this.svgGroup,"blocklyDraggable"):rt(this.svgGroup,"blocklyDraggable")}setMovable(t){super.setMovable(t),this.updateMovable()}setEditable(t){super.setEditable(t),this.textarea&&(this.textarea.readOnly=!t)}setDragging(t){t?ot(this.getSvgRoot(),"blocklyDragging"):rt(this.getSvgRoot(),"blocklyDragging")}getSvgRoot(){return this.svgGroup}getContent(){return this.textarea?this.textarea.value:this.content_}setContent(t){super.setContent(t),this.textarea&&(this.textarea.value=t)}setDeleteStyle(t){t?ot(this.svgGroup,"blocklyDraggingDelete"):rt(this.svgGroup,"blocklyDraggingDelete")}setAutoLayout(t){}toXmlWithXY(t){let e=0;this.workspace.RTL&&(e=this.workspace.getWidth()),t=this.toXml(t);const s=this.getRelativeToSurfaceXY();return t.setAttribute("x",String(Math.round(this.workspace.RTL?e-s.x:s.x))),t.setAttribute("y",String(Math.round(s.y))),t.setAttribute("h",String(this.getHeight())),t.setAttribute("w",String(this.getWidth())),t}toCopyData(){return{paster:gc.TYPE,commentState:this.toXmlWithXY()}}getHeightWidth(){return{width:this.getWidth(),height:this.getHeight()}}render(){if(!this.rendered){var t=this.getHeightWidth(),e=this.createEditor();this.svgGroup.appendChild(e),this.svgHandleTarget=it(ba.RECT,{class:"blocklyCommentHandleTarget",x:0,y:0}),this.svgGroup.appendChild(this.svgHandleTarget),this.svgRectTarget=it(ba.RECT,{class:"blocklyCommentTarget",x:0,y:0,rx:3,ry:3}),this.svgGroup.appendChild(this.svgRectTarget),this.addResizeDom(),this.isDeletable()&&this.addDeleteDom(),this.setSize(t.width,t.height),this.textarea.value=this.content_,this.rendered=!0,this.resizeGroup&&Y(this.resizeGroup,"pointerdown",this,this.resizeMouseDown),this.isDeletable()&&(Y(this.deleteGroup,"pointerdown",this,this.deleteMouseDown),Y(this.deleteGroup,"pointerout",this,this.deleteMouseOut),Y(this.deleteGroup,"pointerup",this,this.deleteMouseUp))}}createEditor(){this.foreignObject=it(ba.FOREIGNOBJECT,{x:0,y:_c.TOP_OFFSET,class:"blocklyCommentForeignObject"});const t=document.createElementNS(pa,"body");t.setAttribute("xmlns",pa),t.className="blocklyMinimalBody";const e=document.createElementNS(pa,"textarea");return e.className="blocklyCommentTextarea",e.setAttribute("dir",this.RTL?"RTL":"LTR"),e.readOnly=!this.isEditable(),t.appendChild(e),this.textarea=e,this.foreignObject.appendChild(t),Y(e,"wheel",this,(function(t){t.stopPropagation()})),Y(e,"change",this,(function(t){this.setContent(e.value)})),this.foreignObject}addResizeDom(){this.resizeGroup=it(ba.G,{class:this.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.svgGroup),it(ba.POLYGON,{points:"0,8 8,8 8,0"},this.resizeGroup),it(ba.LINE,{class:"blocklyResizeLine",x1:8/3,y1:7,x2:7,y2:8/3},this.resizeGroup),it(ba.LINE,{class:"blocklyResizeLine",x1:16/3,y1:7,x2:7,y2:16/3},this.resizeGroup)}addDeleteDom(){this.deleteGroup=it(ba.G,{class:"blocklyCommentDeleteIcon"},this.svgGroup),this.deleteIconBorder=it(ba.CIRCLE,{class:"blocklyDeleteIconShape",r:"7",cx:"7.5",cy:"7.5"},this.deleteGroup),it(ba.LINE,{x1:"5",y1:"10",x2:"10",y2:"5",stroke:"#fff","stroke-width":"2"},this.deleteGroup),it(ba.LINE,{x1:"5",y1:"5",x2:"10",y2:"10",stroke:"#fff","stroke-width":"2"},this.deleteGroup)}resizeMouseDown(t){this.unbindDragEvents(),J(t)||(this.workspace.startDrag(t,new ca(this.workspace.RTL?-this.width_:this.width_,this.height_)),this.onMouseUpWrapper=Y(document,"pointerup",this,this.resizeMouseUp),this.onMouseMoveWrapper=Y(document,"pointermove",this,this.resizeMouseMove),this.workspace.hideChaff()),t.stopPropagation()}deleteMouseDown(t){this.deleteIconBorder&&ot(this.deleteIconBorder,"blocklyDeleteIconHighlighted"),t.stopPropagation()}deleteMouseOut(t){this.deleteIconBorder&&rt(this.deleteIconBorder,"blocklyDeleteIconHighlighted")}deleteMouseUp(t){this.dispose(),t.stopPropagation()}unbindDragEvents(){this.onMouseUpWrapper&&(z(this.onMouseUpWrapper),this.onMouseUpWrapper=null),this.onMouseMoveWrapper&&(z(this.onMouseMoveWrapper),this.onMouseMoveWrapper=null)}resizeMouseUp(t){G(),this.unbindDragEvents()}resizeMouseMove(t){this.autoLayout=!1,t=this.workspace.moveDrag(t),this.setSize(this.RTL?-t.x:t.x,t.y)}resizeComment(){const t=this.getHeightWidth(),e=_c.TOP_OFFSET;let s,i;if(null==(s=this.foreignObject)||s.setAttribute("width",String(t.width)),null==(i=this.foreignObject)||i.setAttribute("height",String(t.height-e)),this.RTL){let e;null==(e=this.foreignObject)||e.setAttribute("x",String(-t.width))}this.textarea&&(this.textarea.style.width=t.width-4+"px",this.textarea.style.height=t.height-4-e+"px")}setSize(t,e){let s,i,o,n;if(t=Math.max(t,45),e=Math.max(e,20+_c.TOP_OFFSET),this.width_=t,this.height_=e,this.svgRect_.setAttribute("width",`${t}`),this.svgRect_.setAttribute("height",`${e}`),null==(s=this.svgRectTarget)||s.setAttribute("width",`${t}`),null==(i=this.svgRectTarget)||i.setAttribute("height",`${e}`),null==(o=this.svgHandleTarget)||o.setAttribute("width",`${t}`),null==(n=this.svgHandleTarget)||n.setAttribute("height",String(_c.TOP_OFFSET)),this.RTL){let t;this.svgRect_.setAttribute("transform","scale(-1 1)"),null==(t=this.svgRectTarget)||t.setAttribute("transform","scale(-1 1)")}if(this.resizeGroup)if(this.RTL){let s;this.resizeGroup.setAttribute("transform","translate("+(8-t)+","+(e-8)+") scale(-1 1)"),null==(s=this.deleteGroup)||s.setAttribute("transform","translate("+(8-t)+","+"-8) scale(-1 1)")}else{let s;this.resizeGroup.setAttribute("transform","translate("+(t-8)+","+(e-8)+")"),null==(s=this.deleteGroup)||s.setAttribute("transform","translate("+(t-8)+","+"-8)")}this.resizeComment()}setFocus(){this.focused=!0,setTimeout((()=>{this.disposed_||(this.textarea.focus(),this.addFocus(),this.svgRectTarget&&ot(this.svgRectTarget,"blocklyCommentTargetFocused"),this.svgHandleTarget&&ot(this.svgHandleTarget,"blocklyCommentHandleTargetFocused"))}),0)}blurFocus(){this.focused=!1,setTimeout((()=>{this.disposed_||(this.textarea.blur(),this.removeFocus(),this.svgRectTarget&&rt(this.svgRectTarget,"blocklyCommentTargetFocused"),this.svgHandleTarget&&rt(this.svgHandleTarget,"blocklyCommentHandleTargetFocused"))}),0)}static fromXmlRendered(t,e,s){let i;Nr.disable$$module$build$src$core$events$utils();try{const o=uc.parseAttributes(t);if(i=new _c(e,o.content,o.h,o.w,o.id),e.rendered&&(i.initSvg(!0),i.render()),!isNaN(o.x)&&!isNaN(o.y))if(e.RTL){const t=s||e.getWidth();i.moveBy(t-o.x,o.y)}else i.moveBy(o.x,o.y)}finally{Nr.enable$$module$build$src$core$events$utils()}return uc.fireCreateEvent(i),i}};_c.DEFAULT_SIZE=100,_c.TOP_OFFSET=10,tt("\n.blocklyCommentForeignObject {\n position: relative;\n z-index: 0;\n}\n\n.blocklyCommentRect {\n fill: #E7DE8E;\n stroke: #bcA903;\n stroke-width: 1px;\n}\n\n.blocklyCommentTarget {\n fill: transparent;\n stroke: #bcA903;\n}\n\n.blocklyCommentTargetFocused {\n fill: none;\n}\n\n.blocklyCommentHandleTarget {\n fill: none;\n}\n\n.blocklyCommentHandleTargetFocused {\n fill: transparent;\n}\n\n.blocklyFocused>.blocklyCommentRect {\n fill: #B9B272;\n stroke: #B9B272;\n}\n\n.blocklySelected>.blocklyCommentTarget {\n stroke: #fc3;\n stroke-width: 3px;\n}\n\n.blocklyCommentDeleteIcon {\n cursor: pointer;\n fill: #000;\n display: none;\n}\n\n.blocklySelected > .blocklyCommentDeleteIcon {\n display: block;\n}\n\n.blocklyDeleteIconShape {\n fill: #000;\n stroke: #000;\n stroke-width: 1px;\n}\n\n.blocklyDeleteIconShape.blocklyDeleteIconHighlighted {\n stroke: #fc3;\n}\n");var Tc=new Set,mc=new WeakSet,Ec=null,bc=null,fc=0,$c={};$c.finishQueuedRenders=Se,$c.queueRender=Ie,$c.triggerQueuedRenders=Re;var Ic={};Ic.appendDomToWorkspace=He,Ic.blockToDom=Be,Ic.blockToDomWithXY=Ne,Ic.clearWorkspaceAndLoadFromXml=Ue,Ic.deleteNext=ts,Ic.domToBlock=Nr.domToBlock$$module$build$src$core$xml,Ic.domToBlockInternal=Ge,Ic.domToPrettyText=Fe,Ic.domToText=Pe,Ic.domToVariables=Ve,Ic.domToWorkspace=Nr.domToWorkspace$$module$build$src$core$xml,Ic.variablesToDom=we,Ic.workspaceToDom=Le;var Sc=class extends Error{},Rc=class extends Sc{constructor(t){super("Expected to find a 'type' property, defining the block type"),this.state=t}},Cc=class extends Sc{constructor(t,e,s){super(`The block ${e.toDevString()} is missing a(n) ${t}\nconnection`),this.block=e,this.state=s}},kc=class extends Sc{constructor(t,e,s,i){super(`The block ${s.toDevString()} could not connect its\n${e} to its parent, because: ${t}`),this.childBlock=s,this.childState=i}},Oc=class extends Sc{constructor(t){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=t}},yc=class extends Sc{constructor(t,e,s){super(`Cannot add an icon of type '${t}' to the block ${e.toDevString()}, because there is no icon registered with type '${t}'. Make sure that all of your icons have been registered.`),this.block=e,this.state=s}},Ac={};Ac.BadConnectionCheck=kc,Ac.DeserializationError=Sc,Ac.MissingBlockType=Rc,Ac.MissingConnection=Cc,Ac.RealChildOfShadow=Oc,Ac.UnregisteredIcon=yc;var vc={BLOCKS:50,PROCEDURES:75,VARIABLES:100},Lc={};Lc.register=is,Lc.unregister=os;var wc=class{constructor(){this.priority=50}save(t){const e=[];for(const s of t.getTopBlocks(!1))(t=ns(s,{addCoordinates:!0,doFullSerialization:!1}))&&e.push(t);return e.length?{languageVersion:0,blocks:e}:null}load(t,e){t=t.blocks;for(const s of t)gs(s,e,{recordUndo:y()})}clear(t){for(const e of t.getTopBlocks(!1))e.dispose(!1)}};is("blocks",new wc);var Nc={};Nc.BlockSerializer=wc,Nc.append=gs,Nc.appendInternal=_s,Nc.save=ns;var Mc=class extends kl{constructor(t){super(),this.isBlank=!t,t&&(this.blockId=t.id,this.workspaceId=t.workspace.id)}toJson(){const t=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return t.blockId=this.blockId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Mc)).blockId=t.blockId,e}},Dc=class extends Mc{constructor(t){super(t),this.type=Nr.CREATE$$module$build$src$core$events$utils,t&&(t.isShadow()&&(this.recordUndo=!1),this.xml=Ne(t),this.ids=B(t),this.json=ns(t,{addCoordinates:!0}))}toJson(){const t=super.toJson();if(!this.xml)throw Error("The block XML 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(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");return t.xml=Pe(this.xml),t.ids=this.ids,t.json=this.json,this.recordUndo||(t.recordUndo=this.recordUndo),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Dc)).xml=Nr.textToDom$$module$build$src$core$utils$xml(t.xml),e.ids=t.ids,e.json=t.json,void 0!==t.recordUndo&&(e.recordUndo=t.recordUndo),e}run(t){const e=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(!Bc(e,this.ids))if(t)gs(this.json,e);else for(t=0;tt.getBlockById(e))).filter((t=>t&&t.isShadow())).length===e.length};t(Pr.EVENT,Nr.CREATE$$module$build$src$core$events$utils,Dc);var xc=class extends Ol{constructor(t,e){super(e),this.type=cl,this.themeName=t}toJson(){const t=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");return t.themeName=this.themeName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new xc)).themeName=t.themeName,e}};t(Pr.EVENT,cl,xc);var Pc,Fc=class extends Ol{constructor(t,e,s,i,o){super(i),this.type=hl,this.viewTop=t,this.viewLeft=e,this.scale=s,this.oldScale=o}toJson(){const t=super.toJson();if(void 0===this.viewTop)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.viewLeft)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.scale)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.oldScale)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");return t.viewTop=this.viewTop,t.viewLeft=this.viewLeft,t.scale=this.scale,t.oldScale=this.oldScale,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Fc)).viewTop=t.viewTop,e.viewLeft=t.viewLeft,e.scale=t.scale,e.oldScale=t.oldScale,e}};t(Pr.EVENT,hl,Fc),Nr.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250},Nr.config$$module$build$src$core$config,function(t){t[t.INPUT_VALUE=1]="INPUT_VALUE",t[t.OUTPUT_VALUE=2]="OUTPUT_VALUE",t[t.NEXT_STATEMENT=3]="NEXT_STATEMENT",t[t.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT"}(Pc||(Pc={}));var Uc=class{constructor(t){this.connectionChecker=t,this.connections=[]}addConnection(t,e){e=this.calculateIndexForYPos(e),this.connections.splice(e,0,t)}findIndexOfConnection(t,e){if(!this.connections.length)return-1;const s=this.calculateIndexForYPos(e);if(s>=this.connections.length)return-1;e=t.y;let i=s;for(;0<=i&&this.connections[i].y===e;){if(this.connections[i]===t)return i;i--}for(i=s;it)){e=i;break}s=i}}return e}removeConnection(t,e){if(-1===(t=this.findIndexOfConnection(t,e)))throw Error("Unable to find connection in connectionDB.");this.connections.splice(t,1)}getNeighbours(t,e){function s(t){const s=o-i[t].x,r=n-i[t].y;return Math.sqrt(s*s+r*r)<=e&&a.push(i[t]),rt?this.menuItems.length:t,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(t,e){let s;for(t+=e;s=this.menuItems[t];){if(s.isEnabled()){this.setHighlighted(s);break}t+=e}}handleMouseOver(t){(t=this.getMenuItem(t.target))&&(t.isEnabled()?this.highlightedItem!==t&&this.setHighlighted(t):this.setHighlighted(null))}handleClick(t){const e=this.openingCoords;if(this.openingCoords=null,e&&"number"==typeof t.clientX){const s=new ca(t.clientX,t.clientY);if(1>ca.distance(e,s))return}(t=this.getMenuItem(t.target))&&t.performAction()}handleMouseEnter(t){this.focus()}handleMouseLeave(t){this.getElement()&&(this.blur(),this.setHighlighted(null))}handleKeyEvent(t){if(this.menuItems.length&&!(t.shiftKey||t.ctrlKey||t.metaKey||t.altKey)){var e=this.highlightedItem;switch(t.key){case"Enter":case" ":e&&e.performAction();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}t.preventDefault(),t.stopPropagation()}}getSize(){const t=this.getElement(),e=Et(t);return e.height=t.scrollHeight,e}},th=class{constructor(t,e){this.content=t,this.opt_value=e,this.enabled=!0,this.element=null,this.rightToLeft=!1,this.roleName=null,this.highlight=this.checked=this.checkable=!1,this.actionHandler=null}createDom(){const t=document.createElement("div");t.id=C(),this.element=t,t.className="blocklyMenuItem goog-menuitem "+(this.enabled?"":"blocklyMenuItemDisabled goog-menuitem-disabled ")+(this.checked?"blocklyMenuItemSelected goog-option-selected ":"")+(this.highlight?"blocklyMenuItemHighlight goog-menuitem-highlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl goog-menuitem-rtl ":"");const e=document.createElement("div");if(e.className="blocklyMenuItemContent goog-menuitem-content",this.checkable){var s=document.createElement("div");s.className="blocklyMenuItemCheckbox goog-menuitem-checkbox",e.appendChild(s)}return s=this.content,"string"==typeof this.content&&(s=document.createTextNode(this.content)),e.appendChild(s),t.appendChild(e),this.roleName&&Bs(t,this.roleName),xs(t,zc.SELECTED,this.checkable&&this.checked||!1),xs(t,zc.DISABLED,!this.enabled),t}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){let t;return null!=(t=this.opt_value)?t:null}setRightToLeft(t){this.rightToLeft=t}setRole(t){this.roleName=t}setCheckable(t){this.checkable=t}setChecked(t){this.checked=t}setHighlighted(t){this.highlight=t;const e=this.getElement();e&&this.isEnabled()&&(t?(ot(e,"blocklyMenuItemHighlight"),ot(e,"goog-menuitem-highlight")):(rt(e,"blocklyMenuItemHighlight"),rt(e,"goog-menuitem-highlight")))}isEnabled(){return this.enabled}setEnabled(t){this.enabled=t}performAction(){this.isEnabled()&&this.actionHandler&&this.actionHandler(this)}onAction(t,e){this.actionHandler=t.bind(e)}},eh=null,sh=null,ih="blocklyWidgetDiv",oh="",nh="",rh={};rh.createDom=Us,rh.getDiv=Ps,rh.hide=Gs,rh.hideIfOwner=Ws,rh.isVisible=Vs,rh.positionWithAnchor=Ys,rh.repositionForWindowResize=Js,rh.show=Hs,rh.testOnly_setDiv=Fs;var lh=null,ah={},ch=null,hh={};hh.callbackFactory=Nr.callbackFactory$$module$build$src$core$contextmenu,hh.commentDeleteOption=ri,hh.commentDuplicateOption=li,hh.dispose=ni,hh.getCurrentBlock=qs,hh.hide=oi,hh.setCurrentBlock=Zs,hh.show=Qs,hh.workspaceCommentOption=ai;var uh=class{constructor(){this.registry_=new Map,this.reset()}reset(){this.registry_.clear()}register(t){if(this.registry_.has(t.id))throw Error('Menu item with ID "'+t.id+'" is already registered.');this.registry_.set(t.id,t)}unregister(t){if(!this.registry_.has(t))throw Error('Menu item with ID "'+t+'" not found.');this.registry_.delete(t)}getItem(t){let e;return null!=(e=this.registry_.get(t))?e:null}getContextMenuOptions(t,e){const s=[];for(const o of this.registry_.values())if(t===o.scopeType){var i=o.preconditionFn(e);"hidden"!==i&&(i={text:"function"==typeof o.displayText?o.displayText(e):o.displayText,enabled:"enabled"===i,callback:o.callback,scope:e,weight:o.weight},s.push(i))}return s.sort((function(t,e){return t.weight-e.weight})),s}};!function(t){var e=t.ScopeType||(t.ScopeType={});e.BLOCK="block",e.WORKSPACE="workspace",t.registry=new t}(uh||(uh={}));var dh=uh.ScopeType,ph={};ph.ContextMenuRegistry=uh,ph.ScopeType=dh;var gh={};gh.clamp=ui,gh.toDegrees=hi,gh.toRadians=ci;var _h,Th,mh,Eh=16,bh=1,fh=12,$h=16,Ih=.25,Sh=null,Rh=null,Ch="",kh="",Oh=null,yh=null,Ah=null,vh={getBoundsInfo:function(){const t=It(Oh),e=Et(Oh);return{left:t.x,right:t.x+e.width,top:t.y,bottom:t.y+e.height,width:e.width,height:e.height}},getPositionMetrics:function(t,e,s,i){const o=vh.getBoundsInfo(),n=Et(_h);return e+n.heighto.top?Ci(s,i,o,n):e+n.heightdocument.documentElement.clientTop?Ci(s,i,o,n):ki(t,o,n)}},Lh={ANIMATION_TIME:Ih,ARROW_HORIZONTAL_PADDING:fh,ARROW_SIZE:Eh,BORDER_SIZE:bh,PADDING_Y:$h,TEST_ONLY:vh};Lh.clearContent=Ti,Lh.createDom=di,Lh.getContentDiv=_i,Lh.getOwner=gi,Lh.getPositionX=Oi,Lh.hide=vi,Lh.hideIfOwner=Ai,Lh.hideWithoutAnimation=Li,Lh.isVisible=yi,Lh.repositionForWindowResize=Ni,Lh.setBoundsElement=pi,Lh.setColour=mi,Lh.show=Si,Lh.showPositionedByBlock=Ei,Lh.showPositionedByField=bi;var wh=null,Nh=null,Mh={};Mh.connectionUiEffect=Bi,Mh.disconnectUiEffect=xi,Mh.disconnectUiStop=Fi,Mh.disposeUiEffect=Mi;var Dh=class{constructor(t,e){this.bubble=t,this.workspace=e,this.dragTarget_=null,this.wouldDeleteBubble_=!1,this.startXY_=this.bubble.getRelativeToSurfaceXY()}startBubbleDrag(){let t;Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.workspace.setResizesEnabled(!1),this.bubble.setAutoLayout&&this.bubble.setAutoLayout(!1),null==(t=this.workspace.getLayerManager())||t.moveToDragLayer(this.bubble),this.bubble.setDragging&&this.bubble.setDragging(!0)}dragBubble(t,e){e=this.pixelsToWorkspaceUnits_(e),e=ca.sum(this.startXY_,e),this.bubble.moveDuringDrag(e),e=this.dragTarget_,this.dragTarget_=this.workspace.getDragTarget(t),t=this.wouldDeleteBubble_,this.wouldDeleteBubble_=this.shouldDelete_(this.dragTarget_),t!==this.wouldDeleteBubble_&&this.updateCursorDuringBubbleDrag_(),this.dragTarget_!==e&&(e&&e.onDragExit(this.bubble),this.dragTarget_&&this.dragTarget_.onDragEnter(this.bubble)),this.dragTarget_&&this.dragTarget_.onDragOver(this.bubble)}shouldDelete_(t){return!(!t||!this.workspace.getComponentManager().hasCapability(t.id,na.Capability.DELETE_AREA))&&t.wouldDelete(this.bubble,!1)}updateCursorDuringBubbleDrag_(){this.bubble.setDeleteStyle(this.wouldDeleteBubble_)}endBubbleDrag(t,e){if(this.dragBubble(t,e),this.dragTarget_&&this.dragTarget_.shouldPreventMove(this.bubble)?t=this.startXY_:(t=this.pixelsToWorkspaceUnits_(e),t=ca.sum(this.startXY_,t)),this.bubble.moveTo(t.x,t.y),this.dragTarget_&&this.dragTarget_.onDrop(this.bubble),this.wouldDeleteBubble_)this.fireMoveEvent_(),this.bubble.dispose();else{if(this.bubble.setDragging){let t;this.bubble.setDragging(!1),null==(t=this.workspace.getLayerManager())||t.moveOffDragLayer(this.bubble,100)}this.fireMoveEvent_()}this.workspace.setResizesEnabled(!0),Nr.setGroup$$module$build$src$core$events$utils(!1)}fireMoveEvent_(){if(this.bubble instanceof _c){const t=new(P(gl))(this.bubble);t.setOldCoordinate(this.startXY_),t.recordNew(),A(t)}}pixelsToWorkspaceUnits_(t){return t=new ca(t.x/this.workspace.scale,t.y/this.workspace.scale),this.workspace.isMutator&&t.scale(1/this.workspace.options.parentWorkspace.scale),t}},Bh=[];Bh[Pc.INPUT_VALUE]=Pc.OUTPUT_VALUE,Bh[Pc.OUTPUT_VALUE]=Pc.INPUT_VALUE,Bh[Pc.NEXT_STATEMENT]=Pc.PREVIOUS_STATEMENT,Bh[Pc.PREVIOUS_STATEMENT]=Pc.NEXT_STATEMENT;var xh="RENAME_VARIABLE_ID",Ph="DELETE_VARIABLE_ID",Fh={};Fh.commonWordPrefix=Gi,Fh.commonWordSuffix=Vi,Fh.isNumber=Nr.isNumber$$module$build$src$core$utils$string,Fh.shortestStringLength=Hi,Fh.startsWith=Ui,Fh.wrap=Nr.wrap$$module$build$src$core$utils$string;var Uh=void 0,Hh=!1,Gh=!1,Vh=50,Wh=0,Xh=0,Yh=0,Kh=0,zh=null,jh=null,Jh=0,qh=10,Zh=10,Qh=750,tu=5,eu=null,su={HOVER_MS:Qh,LIMIT:Vh,MARGINS:tu,OFFSET_X:Jh,OFFSET_Y:qh,RADIUS_OK:Zh};su.bindMouseEvents=eo,su.block=ao,su.createDom=to,su.dispose=ro,su.getCustomTooltip=ji,su.getDiv=qi,su.getTooltipOfObject=Zi,su.hide=lo,su.isVisible=Ji,su.setCustomTooltip=zi,su.unbindMouseEvents=so,su.unblock=co;var iu=class{constructor(t){this.workspace=t,this.horizontalScrollEnabled_=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled_=this.workspace.isMovableVertically(),this.startScrollXY_=new ca(t.scrollX,t.scrollY)}dispose(){this.workspace=null}startDrag(){T()&&T().unselect()}endDrag(t){this.drag(t)}drag(t){if(t=ca.sum(this.startScrollXY_,t),this.horizontalScrollEnabled_&&this.verticalScrollEnabled_)this.workspace.scroll(t.x,t.y);else if(this.horizontalScrollEnabled_)this.workspace.scroll(t.x,this.workspace.scrollY);else{if(!this.verticalScrollEnabled_)throw new TypeError("Invalid state.");this.workspace.scroll(this.workspace.scrollX,t.y)}}},ou=class{constructor(t,e){this.creatorWorkspace=e,this.mouseDownXY=new ca(0,0),this.startWorkspace_=this.targetBlock=this.startBlock=this.startIcon=this.startField=this.startBubble=null,this.hasExceededDragRadius=!1,this.boundEvents=[],this.flyout=this.workspaceDragger=this.blockDragger=this.bubbleDragger=null,this.isMultiTouch_=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1,this.cachedPoints=new Map,this.startDistance=this.previousScale=0,this.currentDropdownOwner=this.isPinchZoomEnabled=null,this.mostRecentEvent=t,this.currentDragDeltaXY=new ca(0,0),this.healStack=!1}dispose(){G(),co(),this.creatorWorkspace.clearGesture();for(const t of this.boundEvents)z(t);this.boundEvents.length=0,this.blockDragger&&this.blockDragger.dispose(),this.workspaceDragger&&this.workspaceDragger.dispose()}updateFromEvent(t){const e=new ca(t.clientX,t.clientY);this.updateDragDelta(e)&&(this.updateIsDragging(),H()),this.mostRecentEvent=t}updateDragDelta(t){return this.currentDragDeltaXY=ca.difference(t,this.mouseDownXY),!this.hasExceededDragRadius&&(this.hasExceededDragRadius=ca.magnitude(this.currentDragDeltaXY)>(this.flyout?Nr.config$$module$build$src$core$config.flyoutDragRadius:Nr.config$$module$build$src$core$config.dragRadius))}updateIsDraggingFromFlyout(){let t;if(!this.targetBlock||null==(t=this.flyout)||!t.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error("Cannot update dragging from the flyout because the ' +\n 'flyout's target workspace is undefined");return!(this.flyout.isScrollable()&&!this.flyout.isDragTowardWorkspace(this.currentDragDeltaXY)||(this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),this.targetBlock.select(),0))}updateIsDraggingBubble(){return!!this.startBubble&&(this.startDraggingBubble(),!0)}updateIsDraggingBlock(){if(!this.targetBlock)return!1;if(this.flyout){if(this.updateIsDraggingFromFlyout())return this.startDraggingBlock(),!0}else if(this.targetBlock.isMovable())return this.startDraggingBlock(),!0;return!1}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())&&(this.workspaceDragger=new iu(this.startWorkspace_),this.workspaceDragger.startDrag())}updateIsDragging(){if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0,this.updateIsDraggingBubble()||this.updateIsDraggingBlock()||this.updateIsDraggingWorkspace()}startDraggingBlock(){this.blockDragger=new(c(Pr.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(this.targetBlock,this.startWorkspace_),this.blockDragger.startDrag(this.currentDragDeltaXY,this.healStack),this.blockDragger.drag(this.mostRecentEvent,this.currentDragDeltaXY)}startDraggingBubble(){if(!this.startBubble)throw Error("Cannot update dragging the bubble because the start bubble is undefined");if(!this.startWorkspace_)throw Error("Cannot update dragging the bubble because the start workspace is undefined");this.bubbleDragger=new Dh(this.startBubble,this.startWorkspace_),this.bubbleDragger.startBubbleDrag(),this.bubbleDragger.dragBubble(this.mostRecentEvent,this.currentDragDeltaXY)}doStart(t){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,j(t)?this.cancel():(this.gestureHasStarted=!0,Fi(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=gi(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=t,ao(),this.targetBlock&&this.targetBlock.select(),J(t)?this.handleRightClick(t):("pointerdown"===t.type.toLowerCase()&&"mouse"!==t.pointerType&&U(t,this),this.mouseDownXY=new ca(t.clientX,t.clientY),this.healStack=t.altKey||t.ctrlKey||t.metaKey,this.bindMouseEvents(t),this.isEnding_||this.handleTouchStart(t)))}bindMouseEvents(t){this.boundEvents.push(Y(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(Y(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(Y(document,"pointerup",null,this.handleUp.bind(this),!0)),t.preventDefault(),t.stopPropagation()}handleStart(t){this.isDragging()||(this.handleTouchStart(t),this.isMultiTouch()&&H())}handleMove(t){this.isDragging()&&V(t)||!this.isMultiTouch()?(this.updateFromEvent(t),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.blockDragger?this.blockDragger.drag(this.mostRecentEvent,this.currentDragDeltaXY):this.bubbleDragger&&this.bubbleDragger.dragBubble(this.mostRecentEvent,this.currentDragDeltaXY),t.preventDefault(),t.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(t),H())}handleUp(t){if(this.isDragging()||this.handleTouchEnd(t),!this.isMultiTouch()||this.isDragging()){if(!V(t))return;if(this.updateFromEvent(t),H(),this.isEnding_)return void console.log("Trying to end a gesture recursively.");this.isEnding_=!0,this.bubbleDragger?this.bubbleDragger.endBubbleDrag(t,this.currentDragDeltaXY):this.blockDragger?this.blockDragger.endDrag(t,this.currentDragDeltaXY):this.workspaceDragger?this.workspaceDragger.endDrag(this.currentDragDeltaXY):this.isBubbleClick()?this.doBubbleClick():this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(t)}t.preventDefault(),t.stopPropagation(),this.dispose()}handleTouchStart(t){var e=W(t);this.cachedPoints.set(e,this.getTouchPoint(t));var s=Array.from(this.cachedPoints.keys());2===s.length&&(e=this.cachedPoints.get(s[0]),s=this.cachedPoints.get(s[1]),this.startDistance=ca.distance(e,s),this.isMultiTouch_=!0,t.preventDefault())}handleTouchMove(t){const e=W(t);this.cachedPoints.set(e,this.getTouchPoint(t)),this.isPinchZoomEnabled&&2===this.cachedPoints.size?this.handlePinch(t):this.handleMove(t)}handlePinch(t){var e=Array.from(this.cachedPoints.keys()),s=this.cachedPoints.get(e[0]);if(e=this.cachedPoints.get(e[1]),s=ca.distance(s,e)/this.startDistance,0this.previousScale){if(e=0<(e=s-this.previousScale)?5*e:6*e,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const i=this.startWorkspace_,o=q(t,i.getParentSvg(),i.getInverseScreenCTM());i.zoom(o.x,o.y,e)}this.previousScale=s,t.preventDefault()}handleTouchEnd(t){t=W(t),this.cachedPoints.has(t)&&this.cachedPoints.delete(t),2>this.cachedPoints.size&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(t){return this.startWorkspace_?new ca(t.pageX,t.pageY):null}isMultiTouch(){return this.isMultiTouch_}cancel(){this.isEnding_||(H(),this.bubbleDragger?this.bubbleDragger.endBubbleDrag(this.mostRecentEvent,this.currentDragDeltaXY):this.blockDragger?this.blockDragger.endDrag(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(t){this.targetBlock?(this.bringBlockToFront(),this.targetBlock.workspace.hideChaff(!!this.flyout),this.targetBlock.showContextMenu(t)):this.startBubble?this.startBubble.showContextMenu(t):this.startWorkspace_&&!this.flyout&&(this.startWorkspace_.hideChaff(),this.startWorkspace_.showContextMenu(t)),t.preventDefault(),t.stopPropagation(),this.dispose()}handleWsStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace(e),this.mostRecentEvent=t,this.doStart(t)}fireWorkspaceClick(t){A(new(P(ol))(null,t.id,"workspace"))}handleFlyoutStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(e),this.handleWsStart(t,e.getWorkspace())}handleBlockStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(e),this.mostRecentEvent=t}handleBubbleStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(e),this.mostRecentEvent=t}doBubbleClick(){this.startBubble instanceof _c&&(this.startBubble.setFocus(),this.startBubble.select())}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),this.bringBlockToFront()}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.bringBlockToFront(),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");this.targetBlock.isEnabled()&&(Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.flyout.createBlock(this.targetBlock).scheduleSnapAndBump())}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");const t=new(P(ol))(this.startBlock,this.startWorkspace_.id,"block");A(t)}this.bringBlockToFront(),Nr.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(t){t=this.creatorWorkspace,T()&&T().unselect(),this.fireWorkspaceClick(this.startWorkspace_||t)}bringBlockToFront(){this.targetBlock&&!this.flyout&&this.targetBlock.bringToFront()}setStartField(t){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=t)}setStartIcon(t){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=t)}setStartBubble(t){this.startBubble||(this.startBubble=t)}setStartBlock(t){this.startBlock||this.startBubble||(this.startBlock=t,t.isInFlyout&&t!==t.getRootBlock()?this.setTargetBlock(t.getRootBlock()):this.setTargetBlock(t))}setTargetBlock(t){t.isShadow()?this.setTargetBlock(t.getParent()):this.targetBlock=t}setStartWorkspace(t){this.startWorkspace_||(this.startWorkspace_=t)}setStartFlyout(t){this.flyout||(this.flyout=t)}isBubbleClick(){return!!this.startBubble&&!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))}isIconClick(){if(!this.startIcon)return!1;const t=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&t}isWorkspaceClick(){return!(this.startBlock||this.startBubble||this.startField||this.hasExceededDragRadius)}isDragging(){return!!this.workspaceDragger||!!this.blockDragger||!!this.bubbleDragger}hasStarted(){return this.gestureHasStarted}getInsertionMarkers(){return this.blockDragger?this.blockDragger.getInsertionMarkers():[]}getCurrentDragger(){let t,e;return null!=(e=null!=(t=this.blockDragger)?t:this.workspaceDragger)?e:this.bubbleDragger}static inProgress(){const t=u();for(let e,s=0;e=t[s];s++)if(e.currentGesture_)return!0;return!1}},nu=class{constructor(t,e){let s,i,o;this.pattern=t,this.spacing=null!=(s=e.spacing)?s:0,this.length=null!=(i=e.length)?i:1,this.line2=(this.line1=t.firstChild)&&this.line1.nextSibling,this.snapToGrid=null!=(o=e.snap)&&o}shouldSnap(){return this.snapToGrid}getSpacing(){return this.spacing}getPatternId(){return this.pattern.id}update(t){var e=this.spacing*t;this.pattern.setAttribute("width",`${e}`),this.pattern.setAttribute("height",`${e}`);let s=(e=Math.floor(this.spacing/2)+.5)-this.length/2,i=e+this.length/2;e*=t,s*=t,i*=t,this.setLineAttributes(this.line1,t,s,i,e,e),this.setLineAttributes(this.line2,t,e,e,s,i)}setLineAttributes(t,e,s,i,o,n){t&&(t.setAttribute("stroke-width",`${e}`),t.setAttribute("x1",`${s}`),t.setAttribute("y1",`${o}`),t.setAttribute("x2",`${i}`),t.setAttribute("y2",`${n}`))}moveTo(t,e){this.pattern.setAttribute("x",`${t}`),this.pattern.setAttribute("y",`${e}`)}static createDom(t,e,s){let i,o;if(t=it(ba.PATTERN,{id:"blocklyGridPattern"+t,patternUnits:"userSpaceOnUse"},s),0<(null!=(i=e.length)?i:1)&&0<(null!=(o=e.spacing)?o:0)){let s;it(ba.LINE,{stroke:e.colour},t),null!=(s=e.length)&&s&&it(ba.LINE,{stroke:e.colour},t)}else it(ba.LINE,{},t);return t}},ru=class{constructor(t){this.workspace=t,this.cursorSvg_=this.cursor_=null,this.markers=new Map,this.markerSvg_=null}registerMarker(t,e){this.markers.has(t)&&this.unregisterMarker(t),e.setDrawer(this.workspace.getRenderer().makeMarkerDrawer(this.workspace,e)),this.setMarkerSvg(e.getDrawer().createDom()),this.markers.set(t,e)}unregisterMarker(t){const e=this.markers.get(t);if(!e)throw Error("Marker with ID "+t+" does not exist. Can only unregister markers that exist.");e.dispose(),this.markers.delete(t)}getCursor(){return this.cursor_}getMarker(t){return this.markers.get(t)||null}setCursor(t){this.cursor_&&this.cursor_.getDrawer()&&this.cursor_.getDrawer().dispose(),(this.cursor_=t)&&(t=this.workspace.getRenderer().makeMarkerDrawer(this.workspace,this.cursor_),this.cursor_.setDrawer(t),this.setCursorSvg(this.cursor_.getDrawer().createDom()))}setCursorSvg(t){t?(this.workspace.getBlockCanvas().appendChild(t),this.cursorSvg_=t):this.cursorSvg_=null}setMarkerSvg(t){t?this.workspace.getBlockCanvas()&&(this.cursorSvg_?this.workspace.getBlockCanvas().insertBefore(t,this.cursorSvg_):this.workspace.getBlockCanvas().appendChild(t)):this.markerSvg_=null}updateMarkers(){this.workspace.keyboardAccessibilityMode&&this.cursorSvg_&&this.workspace.getCursor().draw()}dispose(){const t=Object.keys(this.markers);for(let e,s=0;e=t[s];s++)this.unregisterMarker(e);this.markers.clear(),this.cursor_&&(this.cursor_.dispose(),this.cursor_=null)}};ru.LOCAL_MARKER="local_marker_1";var lu={};lu.deepMerge=_o;var au=class{constructor(e,s,i,o){this.name=e,this.startHats=!1,this.blockStyles=s||Object.create(null),this.categoryStyles=i||Object.create(null),this.componentStyles=o||Object.create(null),this.fontStyle=Object.create(null),t(Pr.THEME,e,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(t,e){this.blockStyles[t]=e}setCategoryStyle(t,e){this.categoryStyles[t]=e}getComponentStyle(t){if(!(t=this.componentStyles[t]))return null;if("string"==typeof t){const e=this.getComponentStyle(t);if(e)return e}return`${t}`}setComponentStyle(t,e){this.componentStyles[t]=e}setFontStyle(t){this.fontStyle=t}setStartHats(t){this.startHats=t}static defineTheme(t,e){t=t.toLowerCase();const s=new au(t);let i=e.base;if(i){if("string"==typeof i){let t;i=null!=(t=l(Pr.THEME,i))?t:void 0}i instanceof au&&(_o(s,i),s.name=t)}return _o(s.blockStyles,e.blockStyles),_o(s.categoryStyles,e.categoryStyles),_o(s.componentStyles,e.componentStyles),_o(s.fontStyle,e.fontStyle),null!==e.startHats&&(s.startHats=e.startHats),s}},cu=new au("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"}}),hu=class{constructor(t){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let e=null,s=!1;var i=!1,o=!1,n=!1,r=!1,l=!1;const a=!!t.readOnly;var c;a||(e=Bt(null!=(c=t.toolbox)?c:null),s=Ft(e),i=void 0===(i=t.trashcan)?s:i,o=void 0===(o=t.collapse)?s:o,n=void 0===(n=t.comments)?s:n,r=void 0===(r=t.disable)?s:r,l=void 0===(l=t.sounds)||l),c=t.maxTrashcanContents,i?void 0===c&&(c=32):c=0;const h=!!t.rtl;let u=t.horizontalLayout;void 0===u&&(u=!1);var d="end"!==t.toolboxPosition;d=u?d?Ba.TOP:Ba.BOTTOM:d===h?Ba.RIGHT:Ba.LEFT;let p=t.css;void 0===p&&(p=!0);let g="https://blockly-demo.appspot.com/static/media/";t.media?g=t.media.endsWith("/")?t.media:t.media+"/":"path"in t&&(st("path","Nov 2014","Jul 2023","media"),g=t.path+"media/");const _=t.oneBasedIndex,T=t.renderer||"geras",m=t.plugins||{};let E,b,f,$=t.modalInputs;void 0===$&&($=!0),this.RTL=h,this.oneBasedIndex=void 0===_||_,this.collapse=o,this.comments=n,this.disable=r,this.readOnly=a,this.maxBlocks=t.maxBlocks||1/0,this.maxInstances=null!=(E=t.maxInstances)?E:null,this.modalInputs=$,this.pathToMedia=g,this.hasCategories=s,this.moveOptions=hu.parseMoveOptions_(t,s),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=i,this.maxTrashcanContents=c,this.hasSounds=l,this.hasCss=p,this.horizontalLayout=u,this.languageTree=e,this.gridOptions=hu.parseGridOptions_(t),this.zoomOptions=hu.parseZoomOptions_(t),this.toolboxPosition=d,this.theme=hu.parseThemeOptions_(t),this.renderer=T,this.rendererOverrides=null!=(b=t.rendererOverrides)?b:null,this.parentWorkspace=null!=(f=t.parentWorkspace)?f:null,this.plugins=m}static parseMoveOptions_(t,e){const s=t.move||{},i={};return void 0===s.scrollbars&&void 0===t.scrollbars?i.scrollbars=e:"object"==typeof s.scrollbars?(i.scrollbars={horizontal:!!s.scrollbars.horizontal,vertical:!!s.scrollbars.vertical},i.scrollbars.horizontal&&i.scrollbars.vertical?i.scrollbars=!0:i.scrollbars.horizontal||i.scrollbars.vertical||(i.scrollbars=!1)):i.scrollbars=!!s.scrollbars||!!t.scrollbars,i.wheel=i.scrollbars&&void 0!==s.wheel?!!s.wheel:"object"==typeof i.scrollbars,i.drag=!(!i.scrollbars||void 0!==s.drag&&!s.drag),i}static parseZoomOptions_(t){t=t.zoom||{};const e={};return e.controls=void 0!==t.controls&&!!t.controls,e.wheel=void 0!==t.wheel&&!!t.wheel,e.startScale=void 0===t.startScale?1:Number(t.startScale),e.maxScale=void 0===t.maxScale?3:Number(t.maxScale),e.minScale=void 0===t.minScale?.3:Number(t.minScale),e.scaleSpeed=void 0===t.scaleSpeed?1.2:Number(t.scaleSpeed),e.pinch=void 0===t.pinch?e.wheel||e.controls:!!t.pinch,e}static parseGridOptions_(t){t=t.grid||{};const e={};return e.spacing=Number(t.spacing)||0,e.colour=t.colour||"#888",e.length=void 0===t.length?1:Number(t.length),e.snap=0")),A(new uu(e,"mutation",null,s,t));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(t){return t.saveExtraState?(t=t.saveExtraState(!0))?JSON.stringify(t):"":t.mutationToDom&&(t=t.mutationToDom())?Pe(t):""}};t(Pr.EVENT,Nr.CHANGE$$module$build$src$core$events$utils,uu);var du=.45,pu=.65,gu={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"},_u={};_u.blend=Co,_u.getHsvSaturation=mo,_u.getHsvValue=bo,_u.hexToRgb=So,_u.hsvToHex=Ro,_u.hueToHex=ko,_u.names=gu,_u.parse=$o,_u.rgbToHex=Io,_u.setHsvSaturation=Eo,_u.setHsvValue=fo;var Tu={};Tu.checkMessageReferences=vo,Tu.parseBlockColour=Lo,Tu.replaceMessageReferences=Ao,Tu.tokenizeInterpolation=yo;var mu=class{constructor(t,e,s){this.DEFAULT_VALUE=null,this.name=void 0,this.constants_=this.mouseDownWrapper_=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=this.markerSvg_=this.cursorSvg_=this.tooltip_=this.validator_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.CURSOR="",this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new $a(0,0),t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){t.tooltip&&this.setTooltip(Ao(t.tooltip))}setSourceBlock(t){if(this.sourceBlock_)throw Error("Field already bound to a block");this.sourceBlock_=t}getConstants(){return!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants()),this.constants_}getSourceBlock(){return this.sourceBlock_}init(){this.fieldGroup_||(this.fieldGroup_=it(ba.G,{}),this.isVisible()||(this.fieldGroup_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip_),this.bindEvents_(),this.initModel())}initView(){this.createBorderRect_(),this.createTextElement_()}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=it(ba.RECT,{rx:this.getConstants().FIELD_BORDER_RECT_RADIUS,ry:this.getConstants().FIELD_BORDER_RECT_RADIUS,x:0,y:0,height:this.size_.height,width:this.size_.width,class:"blocklyFieldRect"},this.fieldGroup_)}createTextElement_(){this.textElement_=it(ba.TEXT,{class:"blocklyText"},this.fieldGroup_),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.textElement_.setAttribute("dominant-baseline","central"),this.textContent_=document.createTextNode(""),this.textElement_.appendChild(this.textContent_)}bindEvents_(){const t=this.getClickTarget_();if(!t)throw Error("A click target has not been set.");eo(t),this.mouseDownWrapper_=Y(t,"pointerdown",this,this.onMouseDown_)}fromXml(t){this.setValue(t.textContent)}toXml(t){return t.textContent=this.getValue(),t}saveState(t){return null!==(t=this.saveLegacyState(mu))?t:this.getValue()}loadState(t){this.loadLegacyState(mu,t)||this.setValue(t)}saveLegacyState(t){return t.prototype.saveState===this.saveState&&t.prototype.toXml!==this.toXml?((t=Nr.createElement$$module$build$src$core$utils$xml("field")).setAttribute("name",this.name||""),Mt(this.toXml(t)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(t,e){return t.prototype.loadState===this.loadState&&t.prototype.fromXml!==this.fromXml&&(this.fromXml(Nr.textToDom$$module$build$src$core$utils$xml(e)),!0)}dispose(){let t;Ai(this),Ws(this),null!=(t=this.getSourceBlock())&&t.isDeadOrDying()||at(this.fieldGroup_),this.disposed=!0}updateEditable(){const t=this.fieldGroup_,e=this.getSourceBlock();this.EDITABLE&&t&&e&&(this.enabled_&&e.isEditable()?(ot(t,"blocklyEditableText"),rt(t,"blocklyNonEditableText"),t.style.cursor=this.CURSOR):(ot(t,"blocklyNonEditableText"),rt(t,"blocklyEditableText"),t.style.cursor=""))}setEnabled(t){this.enabled_=t,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==mu.prototype.showEditor_}isClickableInFlyout(t){return!t}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){let t=!1;return this.name&&(this.SERIALIZABLE?t=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),t=!0)),t}isVisible(){return this.visible_}setVisible(t){if(this.visible_!==t){this.visible_=t;var e=this.fieldGroup_;e&&(e.style.display=t?"block":"none")}}setValidator(t){this.validator_=t}getValidator(){return this.validator_}getSvgRoot(){return this.fieldGroup_}getBorderRect(){if(!this.borderRect_)throw Error(`The border rectangle is ${this.borderRect_}.`);return this.borderRect_}getTextElement(){if(!this.textElement_)throw Error(`The text element is ${this.textElement_}.`);return this.textElement_}getTextContent(){if(!this.textContent_)throw Error(`The text content is ${this.textContent_}.`);return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_()}showEditor(t){this.isClickable()&&this.showEditor_(t)}showEditor_(t){}repositionForWindowResize(){return!1}updateSize_(t){const e=this.getConstants();let s=2*(t=void 0!==t?t:this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING),i=e.FIELD_TEXT_HEIGHT,o=0;this.textElement_&&(o=_t(this.textElement_,e.FIELD_TEXT_FONTSIZE,e.FIELD_TEXT_FONTWEIGHT,e.FIELD_TEXT_FONTFAMILY),s+=o),this.isFullBlockField()||(i=Math.max(i,e.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=i,this.size_.width=s,this.positionTextElement_(t,o),this.positionBorderRect_()}positionTextElement_(t,e){if(this.textElement_){var s,i=this.getConstants(),o=this.size_.height/2;this.textElement_.setAttribute("x",String(null!=(s=this.getSourceBlock())&&s.RTL?this.size_.width-e-t:t)),this.textElement_.setAttribute("y",String(i.FIELD_TEXT_BASELINE_CENTER?o:o-i.FIELD_TEXT_HEIGHT/2+i.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_?(this.render_(),this.isDirty_=!1):this.visible_&&0===this.size_.width&&(this.render_(),0!==this.size_.width&&console.warn("Deprecated use of setting size_.width to 0 to rerender a field. Set field.isDirty_ to true instead.")),this.size_):new $a(0,0)}getScaledBBox(){let t;var e=this.getSourceBlock();if(!e)throw new Eu;if(this.isFullBlockField()){var s=this.sourceBlock_.getHeightWidth();const i=e.workspace.scale;t=this.getAbsoluteXY_(),e=(s.width+1)*i,s=(s.height+1)*i,Kl?(t.x+=1.5*i,t.y+=1.5*i):(t.x-=.5*i,t.y-=.5*i)}else s=this.borderRect_.getBoundingClientRect(),t=It(this.borderRect_),e=s.width,s=s.height;return new fa(t.y,t.y+s,t.x,t.x+e)}onLocationChange(t){}getDisplayText_(){let t=this.getText();return t?(t.length>this.maxDisplayLength&&(t=t.substring(0,this.maxDisplayLength-2)+"…"),t=t.replace(/\s/g,mu.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(t+="‏"),t):mu.NBSP}getText(){const t=this.getText_();return String(null!==t?t:this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.queueRender(),this.sourceBlock_.bumpNeighbours())}setValue(t,e=!0){if(null!==t){var s,i=this.doClassValidation_(t);(t=this.processValidation_(t,i))instanceof Error||(i=null==(s=this.getValidator())?void 0:s.call(this,t),(s=this.processValidation_(t,i))instanceof Error||(t=this.sourceBlock_)&&t.disposed||((i=this.getValue())===s?this.doValueUpdate_(s):(this.doValueUpdate_(s),e&&t&&M()&&A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(t,"field",this.name||null,i,s)),this.isDirty_&&this.forceRerender())))}}processValidation_(t,e){return null===e?(this.doValueInvalid_(t),this.isDirty_&&this.forceRerender(),Error()):void 0===e?t:e}getValue(){return this.value_}doClassValidation_(t){return null==t?null:t}doValueUpdate_(t){this.value_=t,this.isDirty_=!0}doValueInvalid_(t){}onMouseDown_(t){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(t=this.sourceBlock_.workspace.getGesture(t))&&t.setStartField(this)}setTooltip(t){t||""===t||(t=this.sourceBlock_);const e=this.getClickTarget_();e?e.tooltip=t:this.tooltip_=t}getTooltip(){const t=this.getClickTarget_();return Zi(t||{tooltip:this.tooltip_})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return It(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let t=null;const e=this.getSourceBlock();if(!e)throw new Eu;const s=e.inputList;for(let i=0;ie[1]===t))?t:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+t),null)}doValueUpdate_(t){super.doValueUpdate_(t),t=this.getOptions(!0);for(let e,s=0;e=t[s];s++)e[1]===this.value_&&(this.selectedOption=e)}applyColour(){const t=this.sourceBlock_.style;this.borderRect_&&(this.borderRect_.setAttribute("stroke",t.colourTertiary),this.menu_?this.borderRect_.setAttribute("fill",t.colourTertiary):this.borderRect_.setAttribute("fill","transparent")),this.sourceBlock_&&this.arrow&&(this.sourceBlock_.isShadow()?this.arrow.style.fill=t.colourSecondary:this.arrow.style.fill=t.colourPrimary)}render_(){this.getTextContent().nodeValue="",this.imageElement.style.display="none";const t=this.selectedOption&&this.selectedOption[0];t&&"object"==typeof t?this.renderSelectedImage(t):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(t){const e=this.getSourceBlock();if(!e)throw new Eu;this.imageElement.style.display="",this.imageElement.setAttributeNS(ga,"xlink:href",t.src),this.imageElement.setAttribute("height",String(t.height)),this.imageElement.setAttribute("width",String(t.width));const s=Number(t.height);t=Number(t.width);var i=!!this.borderRect_;const o=Math.max(i?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,s+Cu);let n;i=i?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,n=this.svgArrow?this.positionSVGArrow(t+i,o/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):_t(this.arrow,this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY),this.size_.width=t+n+2*i,this.size_.height=o;let r=0;e.RTL?this.imageElement.setAttribute("x",`${i+n}`):(r=t+n,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${i}`)),this.imageElement.setAttribute("y",String(o/2-s/2)),this.positionTextElement_(r+i,t+n)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var t=this.getTextElement();ot(t,"blocklyDropdownText"),t.setAttribute("text-anchor","start");var e=!!this.borderRect_;t=Math.max(e?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);const s=_t(this.getTextElement(),this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY);e=e?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let i=0;this.svgArrow&&(i=this.positionSVGArrow(s+e,t/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=s+i+2*e,this.size_.height=t,this.positionTextElement_(e,s)}positionSVGArrow(t,e){if(!this.svgArrow)return 0;const s=this.getSourceBlock();if(!s)throw new Eu;const i=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,o=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,n=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute("transform","translate("+(s.RTL?i:t+o)+","+e+")"),n+o}getText_(){if(!this.selectedOption)return null;const t=this.selectedOption[0];return"object"==typeof t?t.alt:t}static fromJson(t){if(!t.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(t.options,void 0,t)}};Ru.CHECKMARK_OVERHANG=25,Ru.MAX_MENU_HEIGHT_VH=.45,Ru.ARROW_CHAR="▾";var Cu=10;Mo("field_dropdown",Ru);var ku,Ou=class{constructor(t,e,s){this.workspace=t,this.anchor=e,this.ownerRect=s,this.size=new $a(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.svgRoot=it(ba.G,{},t.getBubbleCanvas()),t=it(ba.G,{filter:`url(#${this.workspace.getRenderer().getConstants().embossFilterId})`},this.svgRoot),this.tail=it(ba.PATH,{},t),this.background=it(ba.RECT,{class:"blocklyDraggable",x:0,y:0,rx:ku.BORDER_WIDTH,ry:ku.BORDER_WIDTH},t),this.contentContainer=it(ba.G,{},this.svgRoot),Y(this.background,"pointerdown",this,this.onMouseDown)}dispose(){at(this.svgRoot),this.disposed=!0}setAnchorLocation(t,e=!1){this.anchor=t,e?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}setPositionRelativeToAnchor(t,e){this.relativeLeft=t,this.relativeTop=e,this.positionRelativeToAnchor(),this.renderTail()}getSize(){return this.size}setSize(t,e=!1){t.width=Math.max(t.width,ku.MIN_SIZE),t.height=Math.max(t.height,ku.MIN_SIZE),this.size=t,this.background.setAttribute("width",`${t.width}`),this.background.setAttribute("height",`${t.height}`),e?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}getColour(){return this.colour}setColour(t){this.colour=t,this.tail.setAttribute("fill",t),this.background.setAttribute("fill",t)}onMouseDown(t){let e;null==(e=this.workspace.getGesture(t))||e.handleBubbleStart(t,this)}positionRelativeToAnchor(){let t=this.anchor.x;t=this.workspace.RTL?t-(this.relativeLeft+this.size.width):t+this.relativeLeft,this.moveTo(t,this.relativeTop+this.anchor.y)}moveTo(t,e){this.svgRoot.setAttribute("transform",`translate(${t}, ${e})`)}positionByRect(t=new fa(0,0,0,0)){var e=this.workspace.getMetricsManager().getViewMetrics(!0),s=this.getOptimalRelativeLeft(e),i=this.getOptimalRelativeTop(e);const o={x:s,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},n={x:-this.size.width-30,y:i};i={x:t.getWidth(),y:i};var r={x:s,y:t.getHeight()};s=t.getWidth()t.width)return e;if(t=this.getWorkspaceViewRect(t),this.workspace.RTL){var s=this.anchor.x-e;s-this.size.widtht.right&&(e=-(t.right-this.anchor.x))}else{const i=(s=e+this.anchor.x)+this.size.width;st.right&&(e=t.right-this.anchor.x-this.size.width)}return e}getOptimalRelativeTop(t){let e=-this.size.height/4;if(this.size.height>t.height)return e;const s=this.anchor.y+e,i=s+this.size.height;return s<(t=this.getWorkspaceViewRect(t)).top?e=t.top-this.anchor.y:i>t.bottom&&(e=t.bottom-this.anchor.y-this.size.height),e}getWorkspaceViewRect(t){const e=t.top;let s=t.top+t.height,i=t.left;return t=t.left+t.width,s-=this.getScrollbarThickness(),this.workspace.RTL?i-=this.getScrollbarThickness():t-=this.getScrollbarThickness(),new fa(e,s,i,t)}getScrollbarThickness(){return Oa.scrollbarThickness/this.workspace.scale}renderTail(){const t=[];var e=this.size.width/2,s=this.size.height/2,i=-this.relativeLeft,o=-this.relativeTop;if(e===i&&s===o)t.push("M "+e+","+s);else{o-=s,i-=e,this.workspace.RTL&&(i*=-1);var n=Math.sqrt(o*o+i*i),r=Math.acos(i/n);0>o&&(r=2*Math.PI-r);var l=r+Math.PI/2;l>2*Math.PI&&(l-=2*Math.PI);var a=Math.sin(l);const c=Math.cos(l);let h=(this.size.width+this.size.height)/ku.TAIL_THICKNESS;h=Math.min(h,this.size.width,this.size.height)/4,i=e+(l=1-ku.ANCHOR_RADIUS/n)*i,o=s+l*o,l=e+h*c;const u=s+h*a;e-=h*c,s-=h*a,(a=r+(a=ci(this.workspace.RTL?-ku.TAIL_ANGLE:ku.TAIL_ANGLE)))>2*Math.PI&&(a-=2*Math.PI),r=Math.sin(a)*n/ku.TAIL_BEND,n=Math.cos(a)*n/ku.TAIL_BEND,t.push("M"+l+","+u),t.push("C"+(l+n)+","+(u+r)+" "+i+","+o+" "+i+","+o),t.push("C"+i+","+o+" "+(e+n)+","+(s+r)+" "+e+","+s)}let c;t.push("z"),null==(c=this.tail)||c.setAttribute("d",t.join(" "))}bringToFront(){let t;const e=null==(t=this.svgRoot)?void 0:t.parentNode;return!(!this.svgRoot||(null==e?void 0:e.lastChild)===this.svgRoot||(null==e||e.appendChild(this.svgRoot),0))}getRelativeToSurfaceXY(){return new ca(this.workspace.RTL?-this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getSvgRoot(){return this.svgRoot}moveDuringDrag(t){this.moveTo(t.x,t.y),this.relativeLeft=this.workspace.RTL?this.anchor.x-t.x-this.size.width:t.x-this.anchor.x,this.relativeTop=t.y-this.anchor.y,this.renderTail()}setDragging(t){}setDeleteStyle(t){}isDeletable(){return!1}showContextMenu(t){}};ku=Ou,Ou.BORDER_WIDTH=6,Ou.DOUBLE_BORDER=2*ku.BORDER_WIDTH,Ou.MIN_SIZE=ku.DOUBLE_BORDER,Ou.TAIL_THICKNESS=1,Ou.TAIL_ANGLE=20,Ou.TAIL_BEND=4,Ou.ANCHOR_RADIUS=8;var yu=class extends Ou{constructor(t,e,s,i){let o,n;super(e,s,i),this.workspace=e,this.anchor=s,this.ownerRect=i,this.autoLayout=!0,e=new hu(t),this.validateWorkspaceOptions(e),this.svgDialog=it(ba.SVG,{x:Ou.BORDER_WIDTH,y:Ou.BORDER_WIDTH},this.contentContainer),t.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new hu(t)),this.miniWorkspace.internalIsMutator=!0,t=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(t),e.languageTree&&(t.insertBefore(this.miniWorkspace.addFlyout(ba.G),this.miniWorkspace.getCanvas()),null==(t=this.miniWorkspace.getFlyout())||t.init(this.miniWorkspace),null==t||t.show(e.languageTree)),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this)),null==(o=this.miniWorkspace.getFlyout())||null==(n=o.getWorkspace())||n.addChangeListener(this.onWorkspaceChange.bind(this)),this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose(),super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(t){this.miniWorkspace.addChangeListener(t)}validateWorkspaceOptions(t){if(t.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");if(t.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(t.zoomOptions.controls||t.zoomOptions.wheel||t.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(t.moveOptions.scrollbars||t.moveOptions.wheel||t.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(t.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts")}onWorkspaceChange(){this.bumpBlocksIntoBounds(),this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging())for(const t of this.miniWorkspace.getTopBlocks(!1)){const e=t.getRelativeToSurfaceXY();if(20>e.y&&t.moveBy(0,20-e.y),t.RTL){let s=-20;const i=this.miniWorkspace.getFlyout();i&&(s-=i.getWidth()),e.x>s&&t.moveBy(s-e.x,0)}else 20>e.x&&t.moveBy(20-e.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()){var t=this.getSize(),e=this.calculateWorkspaceSize();Math.abs(t.width-e.width)({kind:"block",type:t})))}),e}getAnchorLocation(){return ca.sum(this.workspaceLocation,new ca(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new fa(t.y,t.y+t.height,t.x,t.x+t.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");for(var t of(this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace()),this.rootBlock.getDescendants(!1)))t.queueRender();let e,s,i,o;this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1),t=null!=(o=null==(e=this.miniWorkspaceBubble)||null==(s=e.getWorkspace())||null==(i=s.getFlyout())?void 0:i.getWidth())?o:0,this.rootBlock.moveBy(this.rootBlock.RTL?-(t+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 t=>{Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(t)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout((()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()}),0))}}static isIgnorableMutatorEvent(t){return t.isUiEvent||t.type===Nr.CREATE$$module$build$src$core$events$utils||t.type===Nr.CHANGE$$module$build$src$core$events$utils&&"disabled"===t.element}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var t=Nr.getGroup$$module$build$src$core$events$utils();t||Nr.setGroup$$module$build$src$core$events$utils(!0);var e=uu.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var s=uu.getExtraBlockState_(this.sourceBlock);e!==s&&A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"mutation",null,e,s)),Nr.setGroup$$module$build$src$core$events$utils(t)}}getWorkspace(){let t;return null==(t=this.miniWorkspaceBubble)?void 0:t.getWorkspace()}static reconnect(t,e,s){return st("MutatorIcon.reconnect","v10","v11","connection.reconnect"),!!t&&t.reconnect(e,s)}static findParentWs(t){return st("MutatorIcon.findParentWs","v10","v11","workspace.getRootWorkspace"),t.getRootWorkspace()}},Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=ja.MUTATOR,Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon;var Au=Object.create(null),vu={allExtensions:Au};Nr.register$$module$build$src$core$extensions("parent_tooltip_when_inline",Qo);var Lu,wu={TEST_ONLY:vu};wu.apply=Go,wu.buildTooltipForDropdown=Nr.buildTooltipForDropdown$$module$build$src$core$extensions,wu.buildTooltipWithFieldText=Nr.buildTooltipWithFieldText$$module$build$src$core$extensions,wu.isRegistered=Ho,wu.register=Nr.register$$module$build$src$core$extensions,wu.registerMixin=Nr.registerMixin$$module$build$src$core$extensions,wu.registerMutator=Nr.registerMutator$$module$build$src$core$extensions,wu.runAfterPageLoad=qo,wu.unregister=Uo,function(t){t[t.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX",t[t.MAC_ENTER=3]="MAC_ENTER",t[t.BACKSPACE=8]="BACKSPACE",t[t.TAB=9]="TAB",t[t.NUM_CENTER=12]="NUM_CENTER",t[t.ENTER=13]="ENTER",t[t.SHIFT=16]="SHIFT",t[t.CTRL=17]="CTRL",t[t.ALT=18]="ALT",t[t.PAUSE=19]="PAUSE",t[t.CAPS_LOCK=20]="CAPS_LOCK",t[t.ESC=27]="ESC",t[t.SPACE=32]="SPACE",t[t.PAGE_UP=33]="PAGE_UP",t[t.PAGE_DOWN=34]="PAGE_DOWN",t[t.END=35]="END",t[t.HOME=36]="HOME",t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN",t[t.PLUS_SIGN=43]="PLUS_SIGN",t[t.PRINT_SCREEN=44]="PRINT_SCREEN",t[t.INSERT=45]="INSERT",t[t.DELETE=46]="DELETE",t[t.ZERO=48]="ZERO",t[t.ONE=49]="ONE",t[t.TWO=50]="TWO",t[t.THREE=51]="THREE",t[t.FOUR=52]="FOUR",t[t.FIVE=53]="FIVE",t[t.SIX=54]="SIX",t[t.SEVEN=55]="SEVEN",t[t.EIGHT=56]="EIGHT",t[t.NINE=57]="NINE",t[t.FF_SEMICOLON=59]="FF_SEMICOLON",t[t.FF_EQUALS=61]="FF_EQUALS",t[t.FF_DASH=173]="FF_DASH",t[t.FF_HASH=163]="FF_HASH",t[t.QUESTION_MARK=63]="QUESTION_MARK",t[t.AT_SIGN=64]="AT_SIGN",t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.J=74]="J",t[t.K=75]="K",t[t.L=76]="L",t[t.M=77]="M",t[t.N=78]="N",t[t.O=79]="O",t[t.P=80]="P",t[t.Q=81]="Q",t[t.R=82]="R",t[t.S=83]="S",t[t.T=84]="T",t[t.U=85]="U",t[t.V=86]="V",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.Z=90]="Z",t[t.META=91]="META",t[t.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT",t[t.CONTEXT_MENU=93]="CONTEXT_MENU",t[t.NUM_ZERO=96]="NUM_ZERO",t[t.NUM_ONE=97]="NUM_ONE",t[t.NUM_TWO=98]="NUM_TWO",t[t.NUM_THREE=99]="NUM_THREE",t[t.NUM_FOUR=100]="NUM_FOUR",t[t.NUM_FIVE=101]="NUM_FIVE",t[t.NUM_SIX=102]="NUM_SIX",t[t.NUM_SEVEN=103]="NUM_SEVEN",t[t.NUM_EIGHT=104]="NUM_EIGHT",t[t.NUM_NINE=105]="NUM_NINE",t[t.NUM_MULTIPLY=106]="NUM_MULTIPLY",t[t.NUM_PLUS=107]="NUM_PLUS",t[t.NUM_MINUS=109]="NUM_MINUS",t[t.NUM_PERIOD=110]="NUM_PERIOD",t[t.NUM_DIVISION=111]="NUM_DIVISION",t[t.F1=112]="F1",t[t.F2=113]="F2",t[t.F3=114]="F3",t[t.F4=115]="F4",t[t.F5=116]="F5",t[t.F6=117]="F6",t[t.F7=118]="F7",t[t.F8=119]="F8",t[t.F9=120]="F9",t[t.F10=121]="F10",t[t.F11=122]="F11",t[t.F12=123]="F12",t[t.NUMLOCK=144]="NUMLOCK",t[t.SCROLL_LOCK=145]="SCROLL_LOCK",t[t.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY",t[t.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY",t[t.SEMICOLON=186]="SEMICOLON",t[t.DASH=189]="DASH",t[t.EQUALS=187]="EQUALS",t[t.COMMA=188]="COMMA",t[t.PERIOD=190]="PERIOD",t[t.SLASH=191]="SLASH",t[t.APOSTROPHE=192]="APOSTROPHE",t[t.TILDE=192]="TILDE",t[t.SINGLE_QUOTE=222]="SINGLE_QUOTE",t[t.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET",t[t.BACKSLASH=220]="BACKSLASH",t[t.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET",t[t.WIN_KEY=224]="WIN_KEY",t[t.MAC_FF_META=224]="MAC_FF_META",t[t.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT",t[t.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT",t[t.WIN_IME=229]="WIN_IME",t[t.VK_NONAME=252]="VK_NONAME",t[t.PHANTOM=255]="PHANTOM"}(Lu||(Lu={}));var Nu={};Nu.arc=an,Nu.curve=en,Nu.line=rn,Nu.lineOnAxis=ln,Nu.lineTo=nn,Nu.moveBy=on,Nu.moveTo=sn,Nu.point=tn;var Mu={};Mu.Coordinate=ca,Mu.KeyCodes=Lu,Mu.Rect=fa,Mu.Size=$a,Mu.Svg=ba,Mu.aria=qc,Mu.array=ia,Mu.browserEvents=sa,Mu.colour=_u,Mu.deprecation=ha,Mu.dom=Ea,Mu.extensions=wu,Mu.idGenerator=Sl,Mu.math=gh,Mu.object=lu,Mu.parsing=Tu,Mu.string=Fh,Mu.style=Sa,Mu.svgMath=ka,Mu.svgPaths=Nu,Mu.toolbox=Va,Mu.userAgent=Ql,Mu.xml=Da;var Du={};Du.register=cn,Du.unregister=hn;var Bu=class extends Ou{constructor(t,e,s,i){super(e,s,i),this.text=t,this.workspace=e,this.anchor=s,this.ownerRect=i,this.paragraph=this.stringToSvg(t,this.contentContainer),this.updateBubbleSize()}getText(){return this.text}setText(t){this.text=t,at(this.paragraph),this.paragraph=this.stringToSvg(t,this.contentContainer),this.updateBubbleSize()}stringToSvg(t,e){return e=this.createParagraph(e),t=this.createSpans(e,t),this.workspace.RTL&&this.rightAlignSpans(e.getBBox().width,t),e}createParagraph(t){return it(ba.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:Ou.BORDER_WIDTH},t)}createSpans(t,e){return e.split("\n").map((e=>{const s=it(ba.TSPAN,{dy:"1em",x:Ou.BORDER_WIDTH},t);return e=document.createTextNode(e),s.appendChild(e),s}))}rightAlignSpans(t,e){for(const s of e)s.setAttribute("text-anchor","end"),s.setAttribute("x",`${t+Ou.BORDER_WIDTH}`)}updateBubbleSize(){const t=this.paragraph.getBBox();this.setSize(new $a(t.width+2*Ou.BORDER_WIDTH,t.height+2*Ou.BORDER_WIDTH),!0)}},xu=class extends Ou{constructor(t,e,s){super(t,e,s),this.workspace=t,this.anchor=e,this.ownerRect=s,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.textChangeListeners=[],this.sizeChangeListeners=[],this.text="",this.DEFAULT_SIZE=new $a(160+Ou.DOUBLE_BORDER,80+Ou.DOUBLE_BORDER),this.MIN_SIZE=new $a(45+Ou.DOUBLE_BORDER,20+Ou.DOUBLE_BORDER),({inputRoot:this.inputRoot,textArea:this.textArea}=this.createEditor(this.contentContainer)),this.resizeGroup=this.createResizeHandle(this.svgRoot),this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.text}setText(t){this.text=t,this.textArea.value=t,this.onTextChange()}addTextChangeListener(t){this.textChangeListeners.push(t)}addSizeChangeListener(t){this.sizeChangeListeners.push(t)}createEditor(t){t=it(ba.FOREIGNOBJECT,{x:Ou.BORDER_WIDTH,y:Ou.BORDER_WIDTH},t);const e=document.createElementNS(pa,"body");e.setAttribute("xmlns",pa),e.className="blocklyMinimalBody";const s=document.createElementNS(pa,"textarea");return s.className="blocklyCommentTextarea",s.setAttribute("dir",this.workspace.RTL?"RTL":"LTR"),e.appendChild(s),t.appendChild(e),this.bindTextAreaEvents(s),setTimeout((()=>{s.focus()}),0),{inputRoot:t,textArea:s}}bindTextAreaEvents(t){Y(t,"wheel",this,(t=>{t.stopPropagation()})),Y(t,"focus",this,this.onStartEdit,!0),Y(t,"change",this,this.onTextChange)}createResizeHandle(t){t=it(ba.G,{class:this.workspace.RTL?"blocklyResizeSW":"blocklyResizeSE"},t);const e=2*Ou.BORDER_WIDTH;return it(ba.POLYGON,{points:`0,${e} ${e},${e} ${e},0`},t),it(ba.LINE,{class:"blocklyResizeLine",x1:e/3,y1:e-1,x2:e-1,y2:e/3},t),it(ba.LINE,{class:"blocklyResizeLine",x1:2*e/3,y1:e-1,x2:e-1,y2:2*e/3},t),Y(t,"pointerdown",this,this.onResizePointerDown),t}setSize(t,e=!1){t.width=Math.max(t.width,this.MIN_SIZE.width),t.height=Math.max(t.height,this.MIN_SIZE.height);const s=t.width-Ou.DOUBLE_BORDER,i=t.height-Ou.DOUBLE_BORDER;this.inputRoot.setAttribute("width",`${s}`),this.inputRoot.setAttribute("height",`${i}`),this.textArea.style.width=s-4+"px",this.textArea.style.height=i-4+"px",this.workspace.RTL?this.resizeGroup.setAttribute("transform",`translate(${Ou.DOUBLE_BORDER}, ${i}) scale(-1 1)`):this.resizeGroup.setAttribute("transform",`translate(${s}, ${i})`),super.setSize(t,e),this.onSizeChange()}getSize(){return super.getSize()}onResizePointerDown(t){this.bringToFront(),J(t)||(this.workspace.startDrag(t,new ca(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=Y(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=Y(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),t.stopPropagation()}onResizePointerUp(t){G(),this.resizePointerUpListener&&(z(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(z(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(t){t=this.workspace.moveDrag(t),this.setSize(new $a(this.workspace.RTL?-t.x:t.x,t.y),!1),this.onSizeChange()}onStartEdit(){this.bringToFront()&&this.textArea.focus()}onTextChange(){this.text=this.textArea.value;for(const t of this.textChangeListeners)t()}onSizeChange(){for(const t of this.sizeChangeListeners)t()}};tt("\n.blocklyCommentTextarea {\n background-color: #fef49c;\n border: 0;\n display: block;\n margin: 0;\n outline: 0;\n padding: 3px;\n resize: none;\n text-overflow: hidden;\n}\n");var Pu=class extends $u{constructor(t){super(t),this.sourceBlock=t,this.textBubble=this.textInputBubble=null,this.text="",this.bubbleSize=new $a(160,80),this.bubbleVisiblity=!1}getType(){return Pu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(ba.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),it(ba.PATH,{class:"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},this.svgRoot),it(ba.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),ot(this.svgRoot,"blockly-icon-comment"))}dispose(){let t,e;super.dispose(),null==(t=this.textInputBubble)||t.dispose(),null==(e=this.textBubble)||e.dispose()}getWeight(){return Pu.WEIGHT}getSize(){return new $a(17,17)}applyColour(){super.applyColour();const t=this.sourceBlock.style.colourPrimary;let e,s;null==(e=this.textInputBubble)||e.setColour(t),null==(s=this.textBubble)||s.setColour(t)}updateEditable(){super.updateEditable(),this.bubbleIsVisible()&&(this.setBubbleVisible(!1),this.setBubbleVisible(!0))}onLocationChange(t){let e,s;super.onLocationChange(t),t=this.getAnchorLocation(),null==(e=this.textInputBubble)||e.setAnchorLocation(t),null==(s=this.textBubble)||s.setAnchorLocation(t)}setText(t){const e=this.text;let s,i;A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"comment",null,e,t)),this.text=t,null==(s=this.textInputBubble)||s.setText(this.text),null==(i=this.textBubble)||i.setText(this.text)}getText(){return this.text}setBubbleSize(t){let e;this.bubbleSize=t,null==(e=this.textInputBubble)||e.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}saveState(){return this.text?{text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width}:null}loadState(t){let e,s,i,o;this.text=null!=(e=t.text)?e:"",this.bubbleSize=new $a(null!=(s=t.width)?s:160,null!=(i=t.height)?i:80),this.bubbleVisiblity=null!=(o=t.pinned)&&o,setTimeout((()=>this.setBubbleVisible(this.bubbleVisiblity)),1)}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var t=this.textInputBubble.getText();this.text!==t&&(A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"comment",null,this.text,t)),this.text=t)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(t){t&&(this.textBubble||this.textInputBubble)||(t||this.textBubble||this.textInputBubble)&&(this.bubbleVisiblity=t,this.sourceBlock.rendered&&!this.sourceBlock.isInFlyout&&(t?(this.sourceBlock.isEditable()?this.showEditableBubble():this.showNonEditableBubble(),this.applyColour()):this.hideBubble(),A(new(P(rl))(this.sourceBlock,t,"comment"))))}showEditableBubble(){this.textInputBubble=new xu(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.textInputBubble.setText(this.getText()),this.textInputBubble.setSize(this.bubbleSize,!0),this.textInputBubble.addTextChangeListener((()=>this.onTextChange())),this.textInputBubble.addSizeChangeListener((()=>this.onSizeChange()))}showNonEditableBubble(){this.textBubble=new Bu(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect())}hideBubble(){let t,e;null==(t=this.textInputBubble)||t.dispose(),this.textInputBubble=null,null==(e=this.textBubble)||e.dispose(),this.textBubble=null}getAnchorLocation(){return ca.sum(this.workspaceLocation,new ca(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new fa(t.y,t.y+t.height,t.x,t.x+t.width)}};Pu.TYPE=ja.COMMENT,Pu.WEIGHT=3,cn(Pu.TYPE,Pu);var Fu=class extends $u{constructor(t){super(t),this.sourceBlock=t,this.textMap=new Map,this.textBubble=null}getType(){return Fu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(ba.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),it(ba.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),it(ba.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),ot(this.svgRoot,"blockly-icon-warning"))}dispose(){let t;super.dispose(),null==(t=this.textBubble)||t.dispose()}getWeight(){return Fu.WEIGHT}getSize(){return new $a(17,17)}applyColour(){let t;super.applyColour(),null==(t=this.textBubble)||t.setColour(this.sourceBlock.style.colourPrimary)}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(t){let e;super.onLocationChange(t),null==(e=this.textBubble)||e.setAnchorLocation(this.getAnchorLocation())}addMessage(t,e){if(this.textMap.get(e)===t)return this;let s;return t?this.textMap.set(e,t):this.textMap.delete(e),null==(s=this.textBubble)||s.setText(this.getText()),this}getText(){return[...this.textMap.values()].join("\n")}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(t){if(this.bubbleIsVisible()!==t){if(t)this.textBubble=new Bu(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.applyColour();else{let t;null==(t=this.textBubble)||t.dispose(),this.textBubble=null}A(new(P(rl))(this.sourceBlock,t,"warning"))}}getAnchorLocation(){return ca.sum(this.workspaceLocation,new ca(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new fa(t.y,t.y+t.height,t.x,t.x+t.width)}};Fu.TYPE=ja.WARNING,Fu.WEIGHT=2;var Uu=class extends Error{constructor(t){super(`Tried to append an icon of type ${t.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`),this.icon=t}},Hu={};Hu.DuplicateIconType=Uu;var Gu,Vu,Wu={};Wu.CommentIcon=Pu,Wu.Icon=$u,Wu.IconType=ja,Wu.MutatorIcon=Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon,Wu.WarningIcon=Fu,Wu.exceptions=Hu,Wu.registry=Du,Gu="PROCEDURE",Nr.DEFAULT_ARG$$module$build$src$core$procedures="x",(Vu={CATEGORY_NAME:Gu,DEFAULT_ARG:Nr.DEFAULT_ARG$$module$build$src$core$procedures}).ObservableProcedureMap=fu,Vu.allProcedures=un,Vu.findLegalName=Nr.findLegalName$$module$build$src$core$procedures,Vu.flyoutCategory=_n,Vu.getCallers=bn,Vu.getDefinition=Nr.getDefinition$$module$build$src$core$procedures,Vu.isNameUsed=gn,Vu.isProcedureBlock=wo,Vu.mutateCallers=Nr.mutateCallers$$module$build$src$core$procedures,Vu.mutatorOpenListener=mn,Vu.rename=Nr.rename$$module$build$src$core$procedures;var Xu=new class{constructor(){this.NONE=0,this.FIELD=1,this.HAT=2,this.ICON=4,this.SPACER=8,this.BETWEEN_ROW_SPACER=16,this.IN_ROW_SPACER=32,this.EXTERNAL_VALUE_INPUT=64,this.INPUT=128,this.INLINE_INPUT=256,this.STATEMENT_INPUT=512,this.CONNECTION=1024,this.PREVIOUS_CONNECTION=2048,this.NEXT_CONNECTION=4096,this.OUTPUT_CONNECTION=8192,this.CORNER=16384,this.LEFT_SQUARE_CORNER=32768,this.LEFT_ROUND_CORNER=65536,this.RIGHT_SQUARE_CORNER=131072,this.RIGHT_ROUND_CORNER=262144,this.JAGGED_EDGE=524288,this.ROW=1048576,this.TOP_ROW=2097152,this.BOTTOM_ROW=4194304,this.INPUT_ROW=8388608,this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|this.LEFT_ROUND_CORNER,this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER,this.nextTypeValue_=16777216}getType(t){return Object.prototype.hasOwnProperty.call(this,t)||(this[t]=this.nextTypeValue_,this.nextTypeValue_<<=1),this[t]}isField(t){return t.type&this.FIELD}isHat(t){return t.type&this.HAT}isIcon(t){return t.type&this.ICON}isSpacer(t){return t.type&this.SPACER}isInRowSpacer(t){return t.type&this.IN_ROW_SPACER}isInput(t){return t.type&this.INPUT}isExternalInput(t){return t.type&this.EXTERNAL_VALUE_INPUT}isInlineInput(t){return t.type&this.INLINE_INPUT}isStatementInput(t){return t.type&this.STATEMENT_INPUT}isPreviousConnection(t){return t.type&this.PREVIOUS_CONNECTION}isNextConnection(t){return t.type&this.NEXT_CONNECTION}isPreviousOrNextConnection(t){return t.type&(this.PREVIOUS_CONNECTION|this.NEXT_CONNECTION)}isLeftRoundedCorner(t){return t.type&this.LEFT_ROUND_CORNER}isRightRoundedCorner(t){return t.type&this.RIGHT_ROUND_CORNER}isLeftSquareCorner(t){return t.type&this.LEFT_SQUARE_CORNER}isRightSquareCorner(t){return t.type&this.RIGHT_SQUARE_CORNER}isCorner(t){return t.type&this.CORNER}isJaggedEdge(t){return t.type&this.JAGGED_EDGE}isRow(t){return t.type&this.ROW}isBetweenRowSpacer(t){return t.type&this.BETWEEN_ROW_SPACER}isTopRow(t){return t.type&this.TOP_ROW}isBottomRow(t){return t.type&this.BOTTOM_ROW}isTopOrBottomRow(t){return t.type&(this.TOP_ROW|this.BOTTOM_ROW)}isInputRow(t){return t.type&this.INPUT_ROW}},Yu=class{constructor(t){this.centerline=this.xPos=this.height=this.width=0,this.constants_=t,this.type=Xu.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},Ku=class{constructor(t){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_=t,this.type=Xu.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let t=this.elements.length-1;0<=t;t--){const e=this.elements[t];if(Xu.isInput(e))return e}return null}measure(){throw Error("Unexpected attempt to measure a base Row.")}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let t=0;trect,`,`${t} .blocklyEditableText>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${t} .blocklyNonEditableText>text,`,`${t} .blocklyEditableText>text {`,"fill: #000;","}",`${t} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${t} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${t} .blocklyEditableText:not(.editing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${t} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${t} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${t} .blocklyHighlightedConnectionPath {`,"stroke: #fc3;","}",`${t} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${t} .blocklyReplaceable .blocklyPathLight,`,`${t} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${t} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},gd={};gd.ConstantProvider=pd,gd.isDynamicShape=$n;var _d=class{constructor(t,e){this.inlinePath_=this.outlinePath_="",this.block_=t,this.info_=e,this.topLeft_=t.getRelativeToSurfaceXY(),this.constants_=e.getRenderer().getConstants()}draw(){this.drawOutline_(),this.drawInternals_(),this.block_.pathObject.setPath(this.outlinePath_+"\n"+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),this.recordSizeOnBlock_()}hideHiddenIcons_(){st("hideHiddenIcons_","v10","v11")}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren}drawOutline_(){this.drawTop_();for(let t=1;tt||t>this.fieldRow.length)throw Error("index "+t+" out of bounds.");return e||""===e&&s?("string"==typeof e&&(e=Nr.fromJson$$module$build$src$core$field_registry({type:"field_label",text:e})),e.setSourceBlock(this.sourceBlock),this.sourceBlock.rendered&&(e.init(),e.applyColour()),e.name=s,e.setVisible(this.isVisible()),e.prefixField&&(t=this.insertFieldAt(t,e.prefixField)),this.fieldRow.splice(t,0,e),t++,e.suffixField&&(t=this.insertFieldAt(t,e.suffixField)),this.sourceBlock.rendered&&(this.sourceBlock.queueRender(),this.sourceBlock.bumpNeighbours()),t):t}removeField(t,e){for(let e,s=0;e=this.fieldRow[s];s++)if(e.name===t)return e.dispose(),this.fieldRow.splice(s,1),this.sourceBlock.rendered&&(this.sourceBlock.queueRender(),this.sourceBlock.bumpNeighbours()),!0;if(e)return!1;throw Error('Field "'+t+'" not found.')}isVisible(){return this.visible}setVisible(t){let e=[];if(this.visible===t)return e;this.visible=t;for(let e,s=0;e=this.fieldRow[s];s++)e.setVisible(t);if(this.connection){var s=this.connection;t?e=s.startTrackingAll():s.stopTrackingAll(),(s=s.targetBlock())&&(s.getSvgRoot().style.display=t?"block":"none")}return e}markDirty(){for(let t,e=0;t=this.fieldRow[e];e++)t.markDirty()}setCheck(t){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setCheck(t),this}setAlign(t){return this.align=t,this.sourceBlock.rendered&&this.sourceBlock.queueRender(),this}setShadowDom(t){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setShadowDom(t),this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){if(this.sourceBlock.workspace.rendered)for(let t=0;t{Bi(s.getSourceBlock()),setTimeout((()=>{i.bringToFront()}),0)}))}}}update(t,e){const s=this.getCandidate(t);((this.wouldDeleteBlock=this.shouldDelete(!!s,e))||this.shouldUpdatePreviews(s,t))&&(Nr.disable$$module$build$src$core$events$utils(),this.maybeHidePreview(s),this.maybeShowPreview(s),Nr.enable$$module$build$src$core$events$utils())}createMarkerBlock(t){var e=t.type;let s;Nr.disable$$module$build$src$core$events$utils();try{if(s=this.workspace.newBlock(e),s.setInsertionMarker(!0),t.saveExtraState){var i=t.saveExtraState(!0);i&&s.loadExtraState&&s.loadExtraState(i)}else if(t.mutationToDom){const e=t.mutationToDom();e&&s.domToMutation&&s.domToMutation(e)}for(e=0;e{let t,e;null==(t=o)||t.positionNearConnection(l,n,r),null==(e=o)||e.getSvgRoot().setAttribute("visibility","visible")})),this.markerConnection=i}hideInsertionMarker(){if(this.markerConnection){var t,e=this.markerConnection,s=e.getSourceBlock(),i=s.outputConnection;if(null!=(t=s.previousConnection)&&t.targetConnection||null!=i&&i.targetConnection)s.unplug(!0);else{let t;null==(t=e.targetBlock())||t.unplug(!1)}if(e.targetConnection)throw Error("markerConnection still connected at the end of disconnectInsertionMarker");this.markerConnection=null,(e=s.getSvgRoot())&&e.setAttribute("visibility","hidden")}}showInsertionInputOutline(t){t=t.closest,this.highlightedBlock=t.getSourceBlock(),this.highlightedBlock.highlightShapeForInput(t,!0)}hideInsertionInputOutline(){if(this.highlightedBlock){if(!this.activeCandidate)throw Error("Cannot hide the insertion marker outline because there is no active candidate");this.highlightedBlock.highlightShapeForInput(this.activeCandidate.closest,!1),this.highlightedBlock=null}}showReplacementFade(t){if(this.fadedBlock=t.closest.targetBlock(),!this.fadedBlock)throw Error("Cannot show the replacement fade because the closest connection does not have a target block");this.fadedBlock.fadeForReplacement(!0)}hideReplacementFade(){this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null)}getInsertionMarkers(){const t=[];return this.firstMarker&&t.push(this.firstMarker),this.lastMarker&&t.push(this.lastMarker),t}disposeInsertionMarker(t){if(t){Nr.disable$$module$build$src$core$events$utils();try{t.dispose()}finally{Nr.enable$$module$build$src$core$events$utils()}}}};!function(t){(t=t.PREVIEW_TYPE||(t.PREVIEW_TYPE={}))[t.INSERTION_MARKER=0]="INSERTION_MARKER",t[t.INPUT_OUTLINE=1]="INPUT_OUTLINE",t[t.REPLACEMENT_FADE=2]="REPLACEMENT_FADE"}(Ld||(Ld={}));var wd=Ld.PREVIEW_TYPE,Nd={};Nd.InsertionMarkerManager=Ld,Nd.PreviewType=wd;var Md=class{constructor(t){this.overrides=null,this.name=t}getClassName(){return this.name+"-renderer"}init(t,e){this.constants_=this.makeConstants_(),e&&(this.overrides=e,Object.assign(this.constants_,e)),this.constants_.setTheme(t),this.constants_.init()}createDom(t,e){this.constants_.createDom(t,this.name+"-"+e.name,"."+this.getClassName()+"."+e.getClassName())}refreshDom(t,e){const s=this.getConstants();s.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=s.randomIdentifier,this.constants_.setTheme(e),this.constants_.init(),this.createDom(t,e)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new pd}makeRenderInfo_(t){return new $d(this,t)}makeDrawer_(t,e){return new _d(t,e)}makeMarkerDrawer(t,e){return new Rd(t,this.getConstants(),e)}makePathObject(t,e){return new Cd(t,e,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(t){return!0}orphanCanConnectAtEnd(t,e,s){return!!kd.getConnectionForOrphanedConnection(t,s===Pc.OUTPUT_VALUE?e.outputConnection:e.previousConnection)}getConnectionPreviewMethod(t,e,s){return e.type===Pc.OUTPUT_VALUE||e.type===Pc.PREVIOUS_STATEMENT?!t.isConnected()||this.orphanCanConnectAtEnd(s,t.targetBlock(),e.type)?Ld.PREVIEW_TYPE.INSERTION_MARKER:Ld.PREVIEW_TYPE.REPLACEMENT_FADE:Ld.PREVIEW_TYPE.INSERTION_MARKER}render(t){const e=this.makeRenderInfo_(t);e.measure(),this.makeDrawer_(t,e).draw()}},Dd={};Dd.BottomRow=zu,Dd.Connection=ju,Dd.ConstantProvider=pd,Dd.Drawer=_d,Dd.ExternalValueInput=qu,Dd.Field=Zu,Dd.Hat=Qu,Dd.Icon=td,Dd.InRowSpacer=ed,Dd.InlineInput=sd,Dd.InputConnection=Ju,Dd.InputRow=od,Dd.JaggedEdge=nd,Dd.MarkerSvg=Rd,Dd.Measurable=Yu,Dd.NextConnection=rd,Dd.OutputConnection=ld,Dd.PathObject=Cd,Dd.PreviousConnection=ad,Dd.RenderInfo=$d,Dd.Renderer=Md,Dd.RoundCorner=cd,Dd.Row=Ku,Dd.SpacerRow=hd,Dd.SquareCorner=ud,Dd.StatementInput=id,Dd.TopRow=dd,Dd.Types=Xu,Dd.init=yn,Dd.register=kn,Dd.unregister=On;var Bd=class{constructor(t,e){this.workspace=t,this.theme=e,this.subscribedWorkspaces_=[],this.componentDB=new Map}getTheme(){return this.theme}setTheme(t){var e=this.theme;this.theme=t,(t=this.workspace.getInjectionDiv())&&(e&&(e=e.getClassName())&&rt(t,e),(e=this.theme.getClassName())&&ot(t,e));for(let t,e=0;t=this.subscribedWorkspaces_[e];e++)t.refreshTheme();for(const[s,i]of this.componentDB)for(const o of i){t=o.element,e=o.propertyName;const i=this.theme&&this.theme.getComponentStyle(s);t.style.setProperty(e,i||"")}for(const t of this.subscribedWorkspaces_)t.hideChaff()}subscribeWorkspace(t){this.subscribedWorkspaces_.push(t)}unsubscribeWorkspace(t){if(!Q(this.subscribedWorkspaces_,t))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.")}subscribe(t,e,s){this.componentDB.has(e)||this.componentDB.set(e,[]),this.componentDB.get(e).push({element:t,propertyName:s}),e=this.theme&&this.theme.getComponentStyle(e),t.style.setProperty(s,e||"")}unsubscribe(t){if(t)for(const[e,s]of this.componentDB){for(let e=s.length-1;0<=e;e--)s[e].element===t&&s.splice(e,1);s.length||this.componentDB.delete(e)}}dispose(){this.subscribedWorkspaces_.length=0,this.componentDB.clear()}},xd="VARIABLE_DYNAMIC",Pd={CATEGORY_NAME:xd};Pd.flyoutCategory=wn,Pd.flyoutCategoryBlocks=Nn,Pd.onCreateVariableButtonClick_Colour=Ln,Pd.onCreateVariableButtonClick_Number=vn,Pd.onCreateVariableButtonClick_String=An;var Fd=class{canConnect(t,e,s,i){return this.canConnectWithReason(t,e,s,i)===kd.CAN_CONNECT}canConnectWithReason(t,e,s,i){const o=this.doSafetyChecks(t,e);return o!==kd.CAN_CONNECT?o:this.doTypeChecks(t,e)?s&&!this.doDragChecks(t,e,i||0)?kd.REASON_DRAG_CHECKS_FAILED:kd.CAN_CONNECT:kd.REASON_CHECKS_FAILED}getErrorMessage(t,e,s){switch(t){case kd.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case kd.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case kd.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case kd.REASON_TARGET_NULL:return"Target connection is null.";case kd.REASON_CHECKS_FAILED:return"Connection checks failed. "+e+" expected "+e.getCheck()+", found "+s.getCheck();case kd.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case kd.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case kd.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(t,e){if(!t||!e)return kd.REASON_TARGET_NULL;let s,i,o;return t.isSuperior()?(s=t.getSourceBlock(),i=e.getSourceBlock(),o=e):(i=t.getSourceBlock(),s=e.getSourceBlock(),o=t,t=e),s===i?kd.REASON_SELF_CONNECTION:o.type!==Bh[t.type]?kd.REASON_WRONG_TYPE:s.workspace!==i.workspace?kd.REASON_DIFFERENT_WORKSPACES:s.isShadow()&&!i.isShadow()?kd.REASON_SHADOW_PARENT:o.type===Pc.OUTPUT_VALUE&&i.previousConnection&&i.previousConnection.isConnected()||o.type===Pc.PREVIOUS_STATEMENT&&i.outputConnection&&i.outputConnection.isConnected()?kd.REASON_PREVIOUS_AND_OUTPUT:kd.CAN_CONNECT}doTypeChecks(t,e){if(t=t.getCheck(),e=e.getCheck(),!t||!e)return!0;for(let s=0;ss||e.getSourceBlock().isInsertionMarker())return!1;switch(e.type){case Pc.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(t,e);case Pc.OUTPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isInsertionMarker()||t.isConnected())return!1;break;case Pc.INPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isMovable()&&!e.targetBlock().isShadow())return!1;break;case Pc.NEXT_STATEMENT:if(e.isConnected()&&!t.getSourceBlock().nextConnection&&!e.targetBlock().isShadow()&&e.targetBlock().nextConnection||e.targetBlock()&&!e.targetBlock().isMovable()&&!e.targetBlock().isShadow())return!1;break;default:return!1}return-1===Xr.indexOf(e)}canConnectToPrevious_(t,e){return!(t.targetConnection||-1!==Xr.indexOf(e)||e.targetConnection&&(!(t=e.targetBlock()).isInsertionMarker()||t.getPreviousBlock()))}};t(Pr.CONNECTION_CHECKER,xr,Fd);var Ud=class extends oc{constructor(t){super(t),this.type=Qr,t&&(this.varType=t.type,this.varName=t.name)}toJson(){const t=super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return t.varType=this.varType,t.varName=this.varName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Ud)).varType=t.varType,e.varName=t.varName,e}run(t){const e=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t?e.deleteVariableById(this.varId):e.createVariable(this.varName,this.varType,this.varId)}};t(Pr.EVENT,Qr,Ud);var Hd=class extends oc{constructor(t,e){super(t),this.type=tl,t&&(this.oldName=t.name,this.newName=void 0===e?"":e)}toJson(){const t=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");return t.oldName=this.oldName,t.newName=this.newName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Hd)).oldName=t.oldName,e.newName=t.newName,e}run(t){const e=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");t?e.renameVariableById(this.varId,this.newName):e.renameVariableById(this.varId,this.oldName)}};t(Pr.EVENT,tl,Hd);var Gd=class{constructor(t){this.workspace=t,this.variableMap=new Map}clear(){for(const t of this.variableMap.values())for(;0{t&&e&&this.deleteVariableInternal(e,i)}))):this.deleteVariableInternal(e,i)}else console.warn("Can't delete non-existent variable: "+t)}deleteVariableInternal(t,e){const s=Nr.getGroup$$module$build$src$core$events$utils();s||Nr.setGroup$$module$build$src$core$events$utils(!0);try{for(let t=0;tt.name))}getVariableUsesById(t){const e=[],s=this.workspace.getAllBlocks(!1);for(let i=0;ithis.remainingCapacityOfType(s))return!1;e+=t[s]}return!(e>this.remainingCapacity())}hasBlockLimits(){return 1/0!==this.options.maxBlocks||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(t){var e=t?this.redoStack_:this.undoStack_,s=t?this.undoStack_:this.redoStack_;const i=e.pop();if(i){for(var o=[i];e.length&&i.group&&i.group===e[e.length-1].group;){const t=e.pop();t&&o.push(t)}for(e=0;ethis.MAX_UNDO&&0<=this.MAX_UNDO;)this.undoStack_.shift();for(let e=0;et[0]-e[0]));for(const[n,r]of o)if(t{},document.body.addEventListener("wheel",this.dummyWheelListener),Y(this.svgGroup_,"wheel",this,this.onMouseWheel_)),this.options.hasCategories&&(this.toolbox_=new(c(Pr.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(t=c(Pr.CURSOR,this.options))&&this.markerManager.setCursor(new t),this.renderer.createDom(this.svgGroup_,this.getTheme()),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&at(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(),this.markerManager&&this.markerManager.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(),!this.options.parentWorkspace){const t=this.getParentSvg();t&&t.parentNode&&at(t.parentNode)}this.resizeHandlerWrapper&&(z(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null)}addTrashcan(){this.trashcan=Yd.newTrashcan(this);const t=this.trashcan.createDom();this.svgGroup_.insertBefore(t,this.getCanvas())}static newTrashcan(t){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new za(this);const t=this.zoomControls_.createDom();this.svgGroup_.appendChild(t)}addFlyout(t){const e=new hu({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,move:{scrollbars:!0}});return e.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(c(Pr.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(e):new(c(Pr.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(e),this.flyout.autoClose=!1,this.flyout.getWorkspace().setVisible(!0),this.flyout.createDom(t)}getFlyout(t){return this.flyout||t?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();const t=this.componentManager.getComponents(na.Capability.POSITIONABLE,!0),e=this.getMetricsManager().getUiMetrics(),s=[];for(let i,o=0;i=t[o];o++){i.position(e,s);const t=i.getBoundingRectangle();t&&s.push(t)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations_()}updateScreenCalculationsIfScrolled(){const t=vt();ca.equals(this.lastRecordedPageScroll,t)||(this.lastRecordedPageScroll=t,this.updateScreenCalculations_())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(t,e){const s=this.getParentSvg();null!=t&&(this.cachedParentSvgSize.width=t,s.setAttribute("data-cached-width",`${t}`)),null!=e&&(this.cachedParentSvgSize.height=e,s.setAttribute("data-cached-height",`${e}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let t=this.svgGroup_;for(;t;){if("svg"===t.tagName){this.cachedParentSvg=t;break}t=t.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(M()){var t=this.scale,e=-this.scrollY,s=-this.scrollX;if(!(t===this.oldScale&&1>Math.abs(e-this.oldTop)&&1>Math.abs(s-this.oldLeft))){var i=new(P(hl))(e,s,t,this.id,this.oldScale);this.oldScale=t,this.oldTop=e,this.oldLeft=s,A(i)}}}translate(t,e){let s,i;null==(s=this.layerManager)||s.translateLayers(new ca(t,e),this.scale),null==(i=this.grid)||i.moveTo(t,e),this.maybeFireViewportChangeEvent()}getWidth(){const t=this.getMetrics();return t?t.viewWidth/this.scale:0}setVisible(t){this.isVisible_=t,this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(t),this.getFlyout()&&this.getFlyout().setContainerVisible(t),this.getParentSvg().style.display=t?"block":"none",this.toolbox_&&this.toolbox_.setVisible(t),t||this.hideChaff(!0))}render(){for(var t=this.getAllBlocks(!1),e=t.length-1;0<=e;e--)t[e].queueRender();if(this.currentGesture_)for(t=this.currentGesture_.getInsertionMarkers(),e=0;e{this.markerManager.updateMarkers()}))}highlightBlock(t,e){if(void 0===e){for(let t,e=0;t=this.highlightedBlocks[e];e++)t.setHighlighted(!1);this.highlightedBlocks.length=0}(t=t?this.getBlockById(t):null)&&((e=void 0===e||e)?-1===this.highlightedBlocks.indexOf(t)&&this.highlightedBlocks.push(t):Q(this.highlightedBlocks,t),t.setHighlighted(e))}paste(t){if(st("Blockly.WorkspaceSvg.prototype.paste","v10","v11","Blockly.clipboard.paste"),!this.rendered||!t.type&&!t.tagName)return null;this.currentGesture_&&this.currentGesture_.cancel();const e=Nr.getGroup$$module$build$src$core$events$utils();let s;e||Nr.setGroup$$module$build$src$core$events$utils(!0);try{s=t.type?this.pasteBlock_(null,t):"comment"===t.tagName.toLowerCase()?this.pasteWorkspaceComment_(t):this.pasteBlock_(t,null)}finally{Nr.setGroup$$module$build$src$core$events$utils(e)}return s}pasteBlock_(t,e){let s;Nr.disable$$module$build$src$core$events$utils();try{let i=0,o=0;if(t){let e,n;s=Ge(t,this),i=parseInt(null!=(e=t.getAttribute("x"))?e:"0"),this.RTL&&(i=-i),o=parseInt(null!=(n=t.getAttribute("y"))?n:"0")}else e&&(s=gs(e,this),i=e.x||10,this.RTL&&(i=this.getWidth()-i),o=e.y||10);if(!isNaN(i)&&!isNaN(o)){let t;do{t=!1;const e=this.getAllBlocks(!1);for(let s,n=0;s=e[n];n++){const e=s.getRelativeToSurfaceXY();if(1>=Math.abs(i-e.x)&&1>=Math.abs(o-e.y)){t=!0;break}}if(!t){const e=s.getConnections_(!1);for(let s,n=0;s=e[n];n++)if(s.closest(Nr.config$$module$build$src$core$config.snapRadius,new ca(i,o)).connection){t=!0;break}}t&&(i=this.RTL?i-Nr.config$$module$build$src$core$config.snapRadius:i+Nr.config$$module$build$src$core$config.snapRadius,o+=2*Nr.config$$module$build$src$core$config.snapRadius)}while(t);s.moveTo(new ca(i,o))}}finally{Nr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&A(new(P(Nr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}pasteWorkspaceComment_(t){let e;Nr.disable$$module$build$src$core$events$utils();try{e=_c.fromXmlRendered(t,this);let s,i,o=parseInt(null!=(s=t.getAttribute("x"))?s:"0"),n=parseInt(null!=(i=t.getAttribute("y"))?i:"0");isNaN(o)||isNaN(n)||(this.RTL&&(o=-o),e.moveBy(o+50,n+50))}finally{Nr.enable$$module$build$src$core$events$utils()}return M()&&uc.fireCreateEvent(e),e.select(),e}refreshToolboxSelection(){const t=this.isFlyout?this.targetWorkspace:this;t&&!t.currentGesture_&&t.toolbox_&&t.toolbox_.getFlyout()&&t.toolbox_.refreshSelection()}renameVariableById(t,e){super.renameVariableById(t,e),this.refreshToolboxSelection()}deleteVariableById(t){super.deleteVariableById(t),this.refreshToolboxSelection()}createVariable(t,e,s){return t=super.createVariable(t,e,s),this.refreshToolboxSelection(),t}recordDragTargets(){const t=this.componentManager.getComponents(na.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let e,s=0;e=t[s];s++){const t=e.getClientRect();t&&this.dragTargetAreas.push({component:e,clientRect:t})}}newBlock(t,e){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}getDragTarget(t){for(let e,s=0;e=this.dragTargetAreas[s];s++)if(e.clientRect.contains(t.clientX,t.clientY))return e.component;return null}onMouseDown_(t){const e=this.getGesture(t);e&&e.handleWsStart(t,this)}startDrag(t,e){(t=q(t,this.getParentSvg(),this.getInverseScreenCTM())).x/=this.scale,t.y/=this.scale,this.dragDeltaXY=ca.difference(e,t)}moveDrag(t){return(t=q(t,this.getParentSvg(),this.getInverseScreenCTM())).x/=this.scale,t.y/=this.scale,ca.sum(this.dragDeltaXY,t)}isDragging(){return null!==this.currentGesture_&&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(){const t=!!this.scrollbar;return this.isMovable()&&(!t||t&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){const t=!!this.scrollbar;return this.isMovable()&&(!t||t&&this.scrollbar.canScrollVertically())}onMouseWheel_(t){if(ou.inProgress())t.preventDefault(),t.stopPropagation();else{var e=this.options.zoomOptions&&this.options.zoomOptions.wheel,s=this.options.moveOptions&&this.options.moveOptions.wheel;if(e||s){var i=Z(t);if(ql)var o=t.metaKey;e&&(t.ctrlKey||o||!s)?(i=-i.y/50,e=q(t,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(e.x,e.y,i)):(e=this.scrollX-i.x,s=this.scrollY-i.y,t.shiftKey&&!i.x&&(e=this.scrollX-i.y,s=this.scrollY),this.scroll(e,s)),t.preventDefault()}}}getBlocksBoundingBox(){const t=this.getTopBoundedElements();if(!t.length)return new fa(0,0,0,0);const e=t[0].getBoundingRectangle();for(let i=1;ie.bottom&&(e.bottom=s.bottom),s.lefte.right&&(e.right=s.right))}return e}cleanUp(){this.setResizesEnabled(!1),Nr.setGroup$$module$build$src$core$events$utils(!0);const t=this.getTopBlocks(!0);let e=0;for(let s,i=0;s=t[i];i++){if(!s.isMovable())continue;const t=s.getRelativeToSurfaceXY();s.moveBy(-t.x,e-t.y,["cleanup"]),s.snapToGrid(),e=s.getRelativeToSurfaceXY().y+s.getHeightWidth().height+this.renderer.getConstants().MIN_BLOCK_HEIGHT}Nr.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(t){if(!this.options.readOnly&&!this.isFlyout){var e=uh.registry.getContextMenuOptions(uh.ScopeType.WORKSPACE,{workspace:this});this.configureContextMenu&&this.configureContextMenu(e,t),Qs(t,e,this.RTL)}}updateToolbox(t){if(t=Bt(t)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Ft(t)){if(!this.toolbox_)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=t,this.toolbox_.render(t)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=t,this.flyout.show(t)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.")}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(_(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(t,e,s){s=Math.pow(this.options.zoomOptions.scaleSpeed,s);const i=this.scale*s;if(this.scale!==i){i>this.options.zoomOptions.maxScale?s=this.options.zoomOptions.maxScale/this.scale:ithis.options.zoomOptions.maxScale?t=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&te.autoHide(t)))}static setTopLevelWorkspaceMetrics_(t){const e=this.getMetrics();"number"==typeof t.x&&(this.scrollX=-(e.scrollLeft+(e.scrollWidth-e.viewWidth)*t.x)),"number"==typeof t.y&&(this.scrollY=-(e.scrollTop+(e.scrollHeight-e.viewHeight)*t.y)),this.translate(this.scrollX+e.absoluteLeft,this.scrollY+e.absoluteTop)}},Kd={};Kd.WorkspaceSvg=Yd,Kd.resizeSvgContents=Mn;var zd=class extends Ol{constructor(t,e){super(e),this.type=ll,this.isOpen=t}toJson(){const t=super.toJson();if(void 0===this.isOpen)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");return t.isOpen=this.isOpen,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new zd)).isOpen=t.isOpen,e}};t(Pr.EVENT,ll,zd);var jd=class extends Mc{constructor(t){if(super(t),this.type=Nr.DELETE$$module$build$src$core$events$utils,t){if(t.getParent())throw Error("Connected blocks cannot be deleted.");t.isShadow()&&(this.recordUndo=!1),this.oldXml=Ne(t),this.ids=B(t),this.wasShadow=t.isShadow(),this.oldJson=ns(t,{addCoordinates:!0})}}toJson(){const t=super.toJson();if(!this.oldXml)throw Error("The old block XML 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(void 0===this.wasShadow)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");return t.oldXml=Pe(this.oldXml),t.ids=this.ids,t.wasShadow=this.wasShadow,t.oldJson=this.oldJson,this.recordUndo||(t.recordUndo=this.recordUndo),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new jd)).oldXml=Nr.textToDom$$module$build$src$core$utils$xml(t.oldXml),e.ids=t.ids,e.wasShadow=t.wasShadow||"shadow"===e.oldXml.tagName.toLowerCase(),e.oldJson=t.oldJson,void 0!==t.recordUndo&&(e.recordUndo=t.recordUndo),e}run(t){const e=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(t)for(t=0;tt.disposeInternal())),this.inputList.forEach((t=>t.dispose())),this.inputList.length=0,this.getConnections_(!0).forEach((t=>t.dispose())),this.disposed=!0)}isDeadOrDying(){return this.disposing||this.disposed}initModel(){for(const t of this.inputList)for(const e of t.fieldRow)e.initModel&&e.initModel()}unplug(t){this.outputConnection&&this.unplugFromRow_(t),this.previousConnection&&this.unplugFromStack_(t)}unplugFromRow_(t){let e,s=null;null!=(e=this.outputConnection)&&e.isConnected()&&(s=this.outputConnection.targetConnection,this.outputConnection.disconnect()),s&&t&&(t=this.getOnlyValueConnection_())&&t.isConnected()&&!t.targetBlock().isShadow()&&(null==(t=t.targetConnection)||t.disconnect(),this.workspace.connectionChecker.canConnect(t,s,!1)?s.connect(t):null==t||t.onFailedConnect(s))}getOnlyValueConnection_(){let t=null;for(let e=0;e(t=t+("("===s||")"===e?"":" ")+e,s=e[e.length-1],t)),"")).trim()||"???",t&&e.length>t&&(e=e.substring(0,t-3)+"..."),e}toTokens(t="?"){const e=[];for(const i of this.inputList)if(i.name!=Od){for(const t of i.fieldRow)e.push(t.getText());if(i.connection){const o=i.connection.targetBlock();if(o){var s=i.connection;let n=s.getCheck();!n&&s.targetConnection&&(n=s.targetConnection.getCheck()),(s=!!n&&(-1!==n.indexOf("Boolean")||-1!==n.indexOf("Number")))&&e.push("("),e.push(...o.toTokens(t)),s&&e.push(")")}else e.push(t)}}return e}appendValueInput(t){return this.appendInput(new Nr.ValueInput$$module$build$src$core$inputs$value_input(t,this))}appendStatementInput(t){return this.statementInputCount++,this.appendInput(new fd(t,this))}appendDummyInput(t=""){return this.appendInput(new Ed(t,this))}appendEndRowInput(t=""){return this.appendInput(new bd(t,this))}appendInput(t){return this.inputList.push(t),t}appendInputFromRegistry(t,e){return(t=r(Pr.INPUT,t,!1))?this.appendInput(new t(e,this)):null}jsonInit(t){var e=t.type?'Block "'+t.type+'": ':"";if(t.output&&t.previousStatement)throw Error(e+"Must not have both an output and a previousStatement.");for(var s=0;t["args"+s];){if(void 0===t["message"+s])throw Error(e+`args${s} must have a corresponding message (message${s}).`);s++}if(t.style&&t.style.hat&&(this.hat=t.style.hat,t.style=null),t.style&&t.colour)throw Error(e+"Must not have both a colour and a style.");for(t.style?this.jsonInitStyle_(t,e):this.jsonInitColour_(t,e),s=0;void 0!==t["message"+s];)this.interpolate_(t["message"+s],t["args"+s]||[],t["implicitAlign"+s]||t["lastDummyAlign"+s],e),s++;if(void 0!==t.inputsInline&&(Nr.disable$$module$build$src$core$events$utils(),this.setInputsInline(t.inputsInline),Nr.enable$$module$build$src$core$events$utils()),void 0!==t.output&&this.setOutput(!0,t.output),void 0!==t.outputShape&&this.setOutputShape(t.outputShape),void 0!==t.previousStatement&&this.setPreviousStatement(!0,t.previousStatement),void 0!==t.nextStatement&&this.setNextStatement(!0,t.nextStatement),void 0!==t.tooltip&&(s=Ao(t.tooltip),this.setTooltip(s)),void 0!==t.enableContextMenu&&(this.contextMenu=!!t.enableContextMenu),void 0!==t.suppressPrefixSuffix&&(this.suppressPrefixSuffix=!!t.suppressPrefixSuffix),void 0!==t.helpUrl&&(s=Ao(t.helpUrl),this.setHelpUrl(s)),"string"==typeof t.extensions&&(console.warn(e+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+t.type+"' block."),t.extensions=[t.extensions]),void 0!==t.mutator&&Go(t.mutator,this,!0),t=t.extensions,Array.isArray(t))for(e=0;en||n>e)throw Error('Block "'+this.type+'": Message index %'+n+" out of range.");if(s[n])throw Error('Block "'+this.type+'": Message index %'+n+" duplicated.");s[n]=!0,i++}}if(i!==e)throw Error('Block "'+this.type+'": Message does not reference all '+e+" arg(s).")}interpolateArguments_(t,e,s){const i=[];for(let n=0;n=this.inputList.length)throw RangeError("Input index "+t+" out of bounds.");if(e>this.inputList.length)throw RangeError("Reference input "+e+" out of bounds.");const s=this.inputList[t];this.inputList.splice(t,1),tt.getWeight()-e.getWeight())),t}removeIcon(t){if(!this.hasIcon(t))return!1;let e;return null==(e=this.getIcon(t))||e.dispose(),this.icons=this.icons.filter((e=>!e.getType().equals(t))),!0}hasIcon(t){return this.icons.some((e=>e.getType().equals(t)))}getIcon(t){return t instanceof ja?this.icons.find((e=>e.getType().equals(t))):this.icons.find((e=>e.getType().toString()===t))}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy_}moveBy(t,e,s){if(this.parentBlock_)throw Error("Block has parent");const i=new(P(Nr.MOVE$$module$build$src$core$events$utils))(this);s&&i.setReason(s),this.xy_.translate(t,e),i.recordNew(),A(i)}makeConnection_(t){return new kd(this,t)}allInputsFilled(t){if(void 0===t&&(t=!0),!t&&this.isShadow())return!1;for(let s,i=0;s=this.inputList[i];i++)if(s.connection){var e=s.connection.targetBlock();if(!e||!e.allInputsFilled(t))return!1}return!(e=this.getNextBlock())||e.allInputsFilled(t)}toDevString(){let t=this.type?'"'+this.type+'" block':"Block";return this.id&&(t+=' (id="'+this.id+'")'),t}};Jd.COLLAPSED_INPUT_NAME=Od,Jd.COLLAPSED_FIELD_NAME=yd;var qd=class{constructor(){this.drawer=this.curNode=this.colour=null,this.type="marker"}setDrawer(t){this.drawer=t}getDrawer(){return this.drawer}getCurNode(){return this.curNode}setCurNode(t){const e=this.curNode;this.curNode=t,this.drawer&&this.drawer.draw(e,this.curNode)}draw(){this.drawer&&this.drawer.draw(this.curNode,this.curNode)}hide(){this.drawer&&this.drawer.hide()}dispose(){this.getDrawer()&&this.getDrawer().dispose()}},Zd=class extends qd{constructor(){super(),this.type="cursor"}next(){var t=this.getCurNode();if(!t)return null;for(t=t.next();t&&t.next()&&(t.getType()===Id.types.NEXT||t.getType()===Id.types.BLOCK);)t=t.next();return t&&this.setCurNode(t),t}in(){var t=this.getCurNode();if(!t)return null;let e,s;return t.getType()!==Id.types.PREVIOUS&&t.getType()!==Id.types.OUTPUT||(t=t.next()),(t=null!=(s=null==(e=t)?void 0:e.in())?s:null)&&this.setCurNode(t),t}prev(){var t=this.getCurNode();if(!t)return null;for(t=t.prev();t&&t.prev()&&(t.getType()===Id.types.NEXT||t.getType()===Id.types.BLOCK);)t=t.prev();return t&&this.setCurNode(t),t}out(){var t=this.getCurNode();return t?((t=t.out())&&t.getType()===Id.types.BLOCK&&(t=t.prev()||t),t&&this.setCurNode(t),t):null}};t(Pr.CURSOR,xr,Zd);var Qd=class extends Zd{constructor(){super()}next(){var t=this.getCurNode();return t?((t=this.getNextNode_(t,this.validNode_))&&this.setCurNode(t),t):null}in(){return this.next()}prev(){var t=this.getCurNode();return t?((t=this.getPreviousNode_(t,this.validNode_))&&this.setCurNode(t),t):null}out(){return this.prev()}getNextNode_(t,e){if(!t)return null;const s=t.in()||t.next();return e(s)?s:s?this.getNextNode_(s,e):e(t=this.findSiblingOrParent(t.out()))?t:t?this.getNextNode_(t,e):null}getPreviousNode_(t,e){if(!t)return null;let s=t.prev();return s=s?this.getRightMostChild(s):t.out(),e(s)?s:s?this.getPreviousNode_(s,e):null}validNode_(t){let e=!1;return(t=t&&t.getType())!==Id.types.OUTPUT&&t!==Id.types.INPUT&&t!==Id.types.FIELD&&t!==Id.types.NEXT&&t!==Id.types.PREVIOUS&&t!==Id.types.WORKSPACE||(e=!0),e}findSiblingOrParent(t){if(!t)return null;return t.next()||this.findSiblingOrParent(t.out())}getRightMostChild(t){if(!t.in())return t;for(t=t.in();t&&t.next();)t=t.next();return this.getRightMostChild(t)}};Qd.registrationName="basicCursor",t(Pr.CURSOR,Qd.registrationName,Qd);var tp=class extends Qd{validNode_(t){let e=!1;const s=t&&t.getType();return t&&(t=t.getLocation(),s===Id.types.FIELD&&t&&t.isTabNavigable()&&t.isClickable()&&(e=!0)),e}},ep=class extends kd{constructor(t,e){super(t,e),this.targetConnection=this.highlightPath=null,this.db=t.workspace.connectionDBList[e],this.dbOpposite=t.workspace.connectionDBList[Bh[e]],this.offsetInBlock=new ca(0,0),this.trackedState=ep.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState===ep.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.highlightPath&&(at(this.highlightPath),this.highlightPath=null)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(t){const e=this.x-t.x;return t=this.y-t.y,Math.sqrt(e*e+t*t)}bumpAwayFrom(t){if(!this.sourceBlock_.workspace.isDragging()){var e=this.sourceBlock_.getRootBlock();if(!e.isInFlyout){var s=!1;if(!e.isMovable()){if(!(e=t.getSourceBlock().getRootBlock()).isMovable())return;t=this,s=!0}var i=T()==e;i||e.addSelect();var o=t.x+Nr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.x,n=t.y+Nr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.y;s&&(n=-n),e.RTL&&(o=t.x-Nr.config$$module$build$src$core$config.snapRadius-Math.floor(10*Math.random())-this.x),e.moveBy(o,n,["bump"]),i||e.removeSelect()}}}moveTo(t,e){let s=!1;return this.trackedState===ep.TrackedState.WILL_TRACK?(this.db.addConnection(this,e),this.trackedState=ep.TrackedState.TRACKED,s=!0):this.trackedState===ep.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,e),s=!0),this.x=t,this.y=e,s}moveBy(t,e){return this.moveTo(this.x+t,this.y+e)}moveToOffset(t){return this.moveTo(t.x+this.offsetInBlock.x,t.y+this.offsetInBlock.y)}setOffsetInBlock(t,e){this.offsetInBlock.x=t,this.offsetInBlock.y=e}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var t=this.targetConnection;const e=this.targetBlock();t&&e&&(t=ca.difference(this.offsetInBlock,t.offsetInBlock),e.translate(t.x,t.y))}closest(t,e){return this.dbOpposite.searchForClosest(this,t,e)}highlight(){if(!this.highlightPath){var t=this.sourceBlock_.workspace.getRenderer().getConstants(),e=t.shapeFor(this);this.type===Pc.INPUT_VALUE||this.type===Pc.OUTPUT_VALUE?(t=t.TAB_OFFSET_FROM_TOP,e=on(0,-t)+ln("v",t)+e.pathDown+ln("v",t)):(t=t.NOTCH_OFFSET_LEFT-t.CORNER_RADIUS,e=on(-t,0)+ln("h",t)+e.pathLeft+ln("h",t)),t=this.offsetInBlock,this.highlightPath=it(ba.PATH,{class:"blocklyHighlightedConnectionPath",d:e,transform:`translate(${t.x}, ${t.y})`+(this.sourceBlock_.RTL?" scale(-1 1)":"")},this.sourceBlock_.getSvgRoot())}}unhighlight(){this.highlightPath&&(at(this.highlightPath),this.highlightPath=null)}setTracking(t){t&&this.trackedState===ep.TrackedState.TRACKED||!t&&this.trackedState===ep.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(t?(this.db.addConnection(this,this.y),this.trackedState=ep.TrackedState.TRACKED):(this.trackedState===ep.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=ep.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){const t=this.targetBlock().getDescendants(!1);for(let e=0;eclearTimeout(t))),this.warningTextDb.clear(),this.getIcons().forEach((t=>t.dispose())))}checkAndDelete(){this.workspace.isFlyout||(Nr.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),Nr.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:Hc.TYPE,blockState:ns(this,{addCoordinates:!0,addNextBlocks:!1}),typeCounts:$(this,!0)}}applyColour(){this.pathObject.applyColour(this);const t=this.getIcons();for(let e=0;e{this.isDeadOrDying()||(this.warningTextDb.delete(e),this.setWarningText(t,e))}),100));else if(this.isInFlyout&&(t=null),s=this.getIcon(Fu.TYPE),t){let i=this.getSurroundParent(),o=null;for(;i;)i.isCollapsed()&&(o=i),i=i.getSurroundParent();o&&o.setWarningText(Nr.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,op.COLLAPSED_WARNING_ID),s?s.addMessage(t,e):this.addIcon(new Fu(this).addMessage(t,e))}else s&&(e?(s.addMessage("",e),s.getText()||this.removeIcon(Fu.TYPE)):this.removeIcon(Fu.TYPE))}setMutator(t){this.removeIcon(Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),t&&this.addIcon(t)}addIcon(t){return super.addIcon(t),t instanceof Fu&&(this.warning=t),t instanceof Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=t),this.rendered&&(t.initView(this.createIconPointerDownListener(t)),t.applyColour(),t.updateEditable(),this.queueRender(),Re(),this.bumpNeighbours()),t}createIconPointerDownListener(t){return e=>{this.isDeadOrDying()||(e=this.workspace.getGesture(e))&&e.setStartIcon(t)}}removeIcon(t){const e=super.removeIcon(t);return t.equals(Fu.TYPE)&&(this.warning=null),t.equals(Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.rendered&&(this.queueRender(),Re(),this.bumpNeighbours()),e}setEnabled(t){this.isEnabled()!==t&&(super.setEnabled(t),this.rendered&&!this.getInheritedDisabled()&&this.updateDisabled())}setHighlighted(t){this.rendered&&this.pathObject.updateHighlighted(t)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(t){this.pathObject.updateDraggingDelete(t)}getColour(){return this.style.colourPrimary}setColour(t){super.setColour(t),t=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_),this.pathObject.setStyle(t.style),this.style=t.style,this.styleName_=t.name,this.applyColour()}setStyle(t){const e=this.workspace.getRenderer().getConstants().getBlockStyle(t);if(this.styleName_=t,!e)throw Error("Invalid style name: "+t);this.hat=e.hat,this.pathObject.setStyle(e),this.colour_=e.colourPrimary,this.style=e,this.applyColour()}bringToFront(t=!1){let e=this;if(!e.isDeadOrDying())do{const s=e.getSvgRoot(),i=s.parentNode,o=i.childNodes;if(o[o.length-1]!==s&&i.appendChild(s),t)break;e=e.getParent()}while(e)}setPreviousStatement(t,e){super.setPreviousStatement(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setNextStatement(t,e){super.setNextStatement(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setOutput(t,e){super.setOutput(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setInputsInline(t){super.setInputsInline(t),this.rendered&&(this.queueRender(),this.bumpNeighbours())}removeInput(t,e){return t=super.removeInput(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours()),t}moveNumberedInputBefore(t,e){super.moveNumberedInputBefore(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}appendInput(t){return super.appendInput(t),this.rendered&&(this.queueRender(),this.bumpNeighbours()),t}setConnectionTracking(t){if(this.previousConnection&&this.previousConnection.setTracking(t),this.outputConnection&&this.outputConnection.setTracking(t),this.nextConnection){this.nextConnection.setTracking(t);var e=this.nextConnection.targetBlock();e&&e.setConnectionTracking(t)}if(!this.collapsed_)for(e=0;e{const e=Nr.getGroup$$module$build$src$core$events$utils();Nr.setGroup$$module$build$src$core$events$utils(t),this.getRootBlock().bumpNeighboursInternal(),Nr.setGroup$$module$build$src$core$events$utils(e),this.bumpNeighboursPid=0}),Nr.config$$module$build$src$core$config.bumpDelay)}}bumpNeighboursInternal(){const t=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||t.isInFlyout))for(const e of this.getConnections_(!1)){if(e.isSuperior()){let t;null==(t=e.targetBlock())||t.bumpNeighboursInternal()}for(const s of e.neighbours(Nr.config$$module$build$src$core$config.snapRadius))s.getSourceBlock().getRootBlock()!==t&&(e.isConnected()&&s.isConnected()||(e.isSuperior()?s.bumpAwayFrom(e):e.bumpAwayFrom(s)))}}scheduleSnapAndBump(){const t=Nr.getGroup$$module$build$src$core$events$utils();setTimeout((()=>{Nr.setGroup$$module$build$src$core$events$utils(t),this.snapToGrid(),Nr.setGroup$$module$build$src$core$events$utils(!1)}),Nr.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(t,e,s){if(t.type===Pc.NEXT_STATEMENT||t.type===Pc.INPUT_VALUE){let i=e.x;e=e.y,i+=s.x-t.getOffsetInBlock().x,e+=s.y-t.getOffsetInBlock().y,this.moveBy(i,e)}}getChildren(t){return super.getChildren(t)}queueRender(){return Ie(this)}render(){this.queueRender(),Re()}renderEfficiently(){this.rendered=!0,dt(),this.isCollapsed()&&this.updateCollapsed_(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),pt(),this.updateMarkers_()}tightenChildrenEfficiently(){for(const t of this.inputList){const e=t.connection;e&&e.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}updateMarkers_(){this.workspace.keyboardAccessibilityMode&&this.pathObject.cursorSvg&&this.workspace.getCursor().draw(),this.workspace.keyboardAccessibilityMode&&this.pathObject.markerSvg&&this.workspace.getMarker(ru.LOCAL_MARKER).draw();for(const t of this.inputList)for(const e of t.fieldRow)e.updateMarkers_()}setCursorSvg(t){this.pathObject.setCursorSvg(t)}setMarkerSvg(t){this.pathObject.setMarkerSvg(t)}getHeightWidth(){let t=this.height,e=this.width;var s=this.getNextBlock();if(s){s=s.getHeightWidth();const i=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;t+=s.height-i,e=Math.max(e,s.width)}return{height:t,width:e}}fadeForReplacement(t){this.pathObject.updateReplacementFade(t)}highlightShapeForInput(t,e){this.pathObject.updateShapeForInputHighlight(t,e)}};op.INLINE=-1,op.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var np,rp=class{constructor(){}onDragEnter(t){}onDragOver(t){}onDragExit(t){}onDrop(t){}getClientRect(){return null}shouldPreventMove(t){return!1}},lp=class extends rp{constructor(){super(),this.wouldDelete_=!1}wouldDelete(t,e){return t instanceof op?(t=!t.getParent()&&t.isDeletable(),this.updateWouldDelete_(t&&!e)):this.updateWouldDelete_(t.isDeletable()),this.wouldDelete_}updateWouldDelete_(t){this.wouldDelete_=t}},ap=class extends lp{constructor(t){super(),this.workspace=t,this.id="trashcan",this.contents=[],this.flyout=null,this.isLidOpen=!1,this.minOpenness=0,this.lidTask=this.svgLid=this.svgGroup=null,this.top=this.left=this.lidOpen=0,this.initialized=!1,0>=this.workspace.options.maxTrashcanContents||(t=new hu({scrollbars:!0,parentWorkspace:this.workspace,rtl:this.workspace.RTL,oneBasedIndex:this.workspace.options.oneBasedIndex,renderer:this.workspace.options.renderer,rendererOverrides:this.workspace.options.rendererOverrides,move:{scrollbars:!0}}),this.workspace.horizontalLayout?(t.toolboxPosition=this.workspace.toolboxPosition===Ba.TOP?Ba.BOTTOM:Ba.TOP,this.flyout=new(c(Pr.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(t)):(t.toolboxPosition=this.workspace.toolboxPosition===Ba.RIGHT?Ba.LEFT:Ba.RIGHT,this.flyout=new(c(Pr.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(t)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){let t;this.svgGroup=it(ba.G,{class:"blocklyTrash"});const e=String(Math.random()).substring(2);t=it(ba.CLIPPATH,{id:"blocklyTrashBodyClipPath"+e},this.svgGroup),it(ba.RECT,{width:cp,height:hp,y:up},t);const s=it(ba.IMAGE,{width:Xa,x:-_p,height:Ya,y:-Tp,"clip-path":"url(#blocklyTrashBodyClipPath"+e+")"},this.svgGroup);return s.setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),t=it(ba.CLIPPATH,{id:"blocklyTrashLidClipPath"+e},this.svgGroup),it(ba.RECT,{width:cp,height:up},t),this.svgLid=it(ba.IMAGE,{width:Xa,x:-_p,height:Ya,y:-Tp,"clip-path":"url(#blocklyTrashLidClipPath"+e+")"},this.svgGroup),this.svgLid.setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),K(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),K(this.svgGroup,"pointerup",this,this.click),K(s,"pointerover",this,this.mouseOver),K(s,"pointerout",this,this.mouseOut),this.animateLid(),this.svgGroup}init(){0{let s,i;null==(s=this.flyout)||s.show(t),e.cursor="",null==(i=this.workspace.scrollbar)||i.setVisible(!1)}),10),this.fireUiEvent(!0)}}closeFlyout(){var t,e;this.contentsIsOpen()&&(null==(t=this.flyout)||t.hide(),null==(e=this.workspace.scrollbar)||e.setVisible(!0),this.fireUiEvent(!1),this.workspace.recordDragTargets())}autoHide(t){!t&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&(this.contents.length=0,this.setMinOpenness(0),this.closeFlyout())}position(t,e){if(this.initialized){var s,i=Kt(this.workspace,t);t=Yt(i,new $a(cp,hp+up),pp,dp,t,this.workspace),e=zt(t,dp,i.vertical===Fa.TOP?Ha.DOWN:Ha.UP,e),this.top=e.top,this.left=e.left,null==(s=this.svgGroup)||s.setAttribute("transform","translate("+this.left+","+this.top+")")}}getBoundingRectangle(){return new fa(this.top,this.top+hp+up,this.left,this.left+cp)}getClientRect(){if(!this.svgGroup)return null;var t=this.svgGroup.getBoundingClientRect();const e=t.top+Tp-gp;return t=t.left+_p-gp,new fa(e,e+up+hp+2*gp,t,t+cp+2*gp)}onDragOver(t){this.setLidOpen(this.wouldDelete_)}onDragExit(t){this.setLidOpen(!1)}onDrop(t){setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(t){this.isLidOpen!==t&&(this.lidTask&&clearTimeout(this.lidTask),this.isLidOpen=t,this.animateLid())}animateLid(){const t=bp;var e=1/(t+1);this.lidOpen+=this.isLidOpen?e:-e,this.lidOpen=Math.min(Math.max(this.lidOpen,this.minOpenness),1),this.setLidAngle(this.lidOpen*Ip),e=fp+this.lidOpen*($p-fp),this.svgGroup&&(this.svgGroup.style.opacity=`${e}`),this.lidOpen>this.minOpenness&&1>this.lidOpen&&(this.lidTask=setTimeout(this.animateLid.bind(this),Ep/t))}setLidAngle(t){const e=this.workspace.toolboxPosition===Ba.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let s;null==(s=this.svgLid)||s.setAttribute("transform","rotate("+(e?-t:t)+","+(e?4:cp-4)+","+(up-2)+")")}setMinOpenness(t){this.minOpenness=t,this.isLidOpen||this.setLidAngle(t*Ip)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(t){t=new(P(ll))(t,this.workspace.id),A(t)}blockMouseDownWhenOpenable(t){!this.contentsIsOpen()&&this.hasContents()&&t.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(t){if(!(0>=this.workspace.options.maxTrashcanContents||t.type!==Nr.DELETE$$module$build$src$core$events$utils||t.type!==Nr.DELETE$$module$build$src$core$events$utils||t.wasShadow)){if(!t.oldJson)throw Error("Encountered a delete event without proper oldJson");if(t=JSON.stringify(this.cleanBlockJson(t.oldJson)),-1===this.contents.indexOf(t)){for(this.contents.unshift(t);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(mp)}}}cleanBlockJson(t){return function t(e){if(e){if(delete e.id,delete e.x,delete e.y,delete e.enabled,e.icons&&e.icons.comment){var s=e.icons.comment;delete s.height,delete s.width,delete s.pinned}for(var i in s=e.inputs){var o=s[i];const e=o.block;o=o.shadow,e&&t(e),o&&t(o)}e.next&&(e=(i=e.next).block,i=i.shadow,e&&t(e),i&&t(i))}}(t=JSON.parse(JSON.stringify(t))),Object.assign({},{kind:"BLOCK"},t)}},cp=47,hp=44,up=16,dp=20,pp=20,gp=10,_p=0,Tp=32,mp=.1,Ep=80,bp=4,fp=.4,$p=.8,Ip=45,Sp=class{constructor(){this.shortcuts=new Map,this.keyMap=new Map,this.reset()}reset(){this.shortcuts.clear(),this.keyMap.clear()}register(t,e){if(this.shortcuts.get(t.name)&&!e)throw Error(`Shortcut named "${t.name}" already exists.`);if(this.shortcuts.set(t.name,t),(e=t.keyCodes)&&0Wn(t)))).length?t:null}load(t,e){const s=e.getProcedureMap();for(const i of t)s.add(Yn(this.procedureModelClass,this.parameterModelClass,i,e))}clear(t){t.getProcedureMap().clear()}}};Op.loadParameter=Kn,Op.loadProcedure=Yn,Op.saveParameter=Xn,Op.saveProcedure=Wn;var yp=class{constructor(){this.priority=100}save(t){const e=[];for(const s of t.getAllVariables())t={name:s.name,id:s.getId()},s.type&&(t.type=s.type),e.push(t);return e.length?e:null}load(t,e){for(const s of t)e.createVariable(s.name,s.type,s.id)}clear(t){t.getVariableMap().clear()}};is("variables",new yp);var Ap={};Ap.VariableSerializer=yp;var vp={};vp.load=jn,vp.save=zn;var Lp={blocks:Nc,exceptions:Ac,priorities:vc,procedures:Op,registry:Lc,variables:Ap,workspaces:vp},wp=class{constructor(t,e,s,i,o){this.workspace=t,this.oldHostMetrics_=this.corner_=this.vScroll=this.hScroll=null,s=void 0===s||s;const n=(e=void 0===e||e)&&s;e&&(this.hScroll=new Oa(t,!0,n,i,o)),s&&(this.vScroll=new Oa(t,!1,n,i,o)),n&&(this.corner_=it(ba.RECT,{height:Oa.scrollbarThickness,width:Oa.scrollbarThickness,class:"blocklyScrollbarBackground"}),ct(this.corner_,t.getBubbleCanvas()))}dispose(){at(this.corner_),this.oldHostMetrics_=this.corner_=null,this.hScroll&&(this.hScroll.dispose(),this.hScroll=null),this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){const t=this.workspace.getMetrics();if(t){var e=!1,s=!1;if(this.oldHostMetrics_&&this.oldHostMetrics_.viewWidth===t.viewWidth&&this.oldHostMetrics_.viewHeight===t.viewHeight&&this.oldHostMetrics_.absoluteTop===t.absoluteTop&&this.oldHostMetrics_.absoluteLeft===t.absoluteLeft?(this.oldHostMetrics_&&this.oldHostMetrics_.scrollWidth===t.scrollWidth&&this.oldHostMetrics_.viewLeft===t.viewLeft&&this.oldHostMetrics_.scrollLeft===t.scrollLeft||(e=!0),this.oldHostMetrics_&&this.oldHostMetrics_.scrollHeight===t.scrollHeight&&this.oldHostMetrics_.viewTop===t.viewTop&&this.oldHostMetrics_.scrollTop===t.scrollTop||(s=!0)):s=e=!0,e||s){try{Nr.disable$$module$build$src$core$events$utils(),this.hScroll&&e&&this.hScroll.resize(t),this.vScroll&&s&&this.vScroll.resize(t)}finally{Nr.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics_||this.oldHostMetrics_.viewWidth!==t.viewWidth||this.oldHostMetrics_.absoluteLeft!==t.absoluteLeft){let t;null==(t=this.corner_)||t.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics_||this.oldHostMetrics_.viewHeight!==t.viewHeight||this.oldHostMetrics_.absoluteTop!==t.absoluteTop){let t;null==(t=this.corner_)||t.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics_=t}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(t,e){this.hScroll&&this.hScroll.setOrigin(t,e),this.vScroll&&this.vScroll.setOrigin(t,e)}set(t,e,s){this.hScroll&&this.hScroll.set(t,!1),this.vScroll&&this.vScroll.set(e,!1),(s||void 0===s)&&(t={},this.hScroll&&(t.x=this.hScroll.getRatio_()),this.vScroll&&(t.y=this.vScroll.getRatio_()),this.workspace.setMetrics(t))}setX(t){this.hScroll&&this.hScroll.set(t,!0)}setY(t){this.vScroll&&this.vScroll.set(t,!0)}setContainerVisible(t){this.hScroll&&this.hScroll.setContainerVisible(t),this.vScroll&&this.vScroll.setContainerVisible(t)}isVisible(){let t=!1;return this.hScroll&&(t=this.hScroll.isVisible()),this.vScroll&&(t=t||this.vScroll.isVisible()),t}setVisible(t){this.hScroll&&this.hScroll.setVisibleInternal(t),this.vScroll&&this.vScroll.setVisibleInternal(t)}resizeContent(t){this.hScroll&&this.hScroll.resizeContentHorizontal(t),this.vScroll&&this.vScroll.resizeContentVertical(t)}resizeView(t){this.hScroll&&this.hScroll.resizeViewHorizontal(t),this.vScroll&&this.vScroll.resizeViewVertical(t)}},Np=class{constructor(t){this.workspace_=t}getDimensionsPx_(t){let e=0,s=0;return t&&(e=t.getWidth(),s=t.getHeight()),new $a(e,s)}getFlyoutMetrics(t){return{width:(t=this.getDimensionsPx_(this.workspace_.getFlyout(t))).width,height:t.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){const t=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:t.width,height:t.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){let t=0,e=0;const s=this.getToolboxMetrics(),i=this.getFlyoutMetrics(),o=!!this.workspace_.getToolbox();var n;const r=!(null!=(n=this.workspace_.getFlyout())&&n.autoClose),l=(n=o?s.position:i.position)===Ba.TOP;return n===Ba.LEFT&&(o&&(t+=s.width),r&&(t+=i.width)),l&&(o&&(e+=s.height),r&&(e+=i.height)),{top:e,left:t}}getViewMetrics(t){t=t?this.workspace_.scale:1;const e=this.getSvgMetrics(),s=this.getToolboxMetrics(),i=this.getFlyoutMetrics(),o=!!this.workspace_.getToolbox();var n;const r=!(null!=(n=this.workspace_.getFlyout())&&n.autoClose),l=(n=o?s.position:i.position)===Ba.LEFT||n===Ba.RIGHT;return n!==Ba.TOP&&n!==Ba.BOTTOM||(o&&(e.height-=s.height),r&&(e.height-=i.height)),l&&(o&&(e.width-=s.width),r&&(e.width-=i.width)),{height:e.height/t,width:e.width/t,top:-this.workspace_.scrollY/t,left:-this.workspace_.scrollX/t}}getContentMetrics(t){t=t?1:this.workspace_.scale;const e=this.workspace_.getBlocksBoundingBox();return{height:(e.bottom-e.top)*t,width:(e.right-e.left)*t,top:e.top*t,left:e.left*t}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||!this.workspace_.isMovableVertically()}getComputedFixedEdges_(t){if(!this.hasFixedEdges())return{};const e=this.workspace_.isMovableHorizontally(),s=this.workspace_.isMovableVertically();t=t||this.getViewMetrics(!1);const i={};return s||(i.top=t.top,i.bottom=t.top+t.height),e||(i.left=t.left,i.right=t.left+t.width),i}getPaddedContent_(t,e){const s=e.top+e.height,i=e.left+e.width,o=t.width,n=o/2,r=(t=t.height)/2;return{top:Math.min(e.top-r,s-t),bottom:Math.max(s+r,e.top+t),left:Math.min(e.left-n,i-o),right:Math.max(i+n,e.left+o)}}getScrollMetrics(t,e,s){t=t?this.workspace_.scale:1,e=e||this.getViewMetrics(!1);var i=s||this.getContentMetrics();s=this.getComputedFixedEdges_(e),e=this.getPaddedContent_(e,i),i=void 0!==s.top?s.top:e.top;const o=void 0!==s.left?s.left:e.left;return{top:i/t,left:o/t,width:((void 0!==s.right?s.right:e.right)-o)/t,height:((void 0!==s.bottom?s.bottom:e.bottom)-i)/t}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){const t=this.getToolboxMetrics(),e=this.getFlyoutMetrics(!0),s=this.getSvgMetrics(),i=this.getAbsoluteMetrics(),o=this.getViewMetrics(),n=this.getContentMetrics(),r=this.getScrollMetrics(!1,o,n);return{contentHeight:n.height,contentWidth:n.width,contentTop:n.top,contentLeft:n.left,scrollHeight:r.height,scrollWidth:r.width,scrollTop:r.top,scrollLeft:r.left,viewHeight:o.height,viewWidth:o.width,viewTop:o.top,viewLeft:o.left,absoluteTop:i.top,absoluteLeft:i.left,svgHeight:s.height,svgWidth:s.width,toolboxWidth:t.width,toolboxHeight:t.height,toolboxPosition:t.position,flyoutWidth:e.width,flyoutHeight:e.height}}};t(Pr.METRICS_MANAGER,xr,Np);var Mp=class extends kl{constructor(t){super(),this.isBlank=!0,this.recordUndo=!1,this.type=_l,this.isBlank=!!t,t&&(this.workspaceId=t.id)}};t(Pr.EVENT,_l,Mp);var Dp=class extends Ol{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=sl,t&&(this.blockId=t.id,this.isStart=e,this.blocks=s)}toJson(){const t=super.toJson();if(void 0===this.isStart)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(void 0===this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return t.isStart=this.isStart,t.blockId=this.blockId,t.blocks=this.blocks,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Dp)).isStart=t.isStart,e.blockId=t.blockId,e.blocks=t.blocks,e}};t(Pr.EVENT,sl,Dp);var Bp={};Bp.bumpIntoBounds=Jn,Bp.bumpIntoBoundsHandler=qn,Bp.bumpTopObjectsIntoBounds=Qn;var xp=class{constructor(t,e){this.dragTarget_=null,this.wouldDeleteBlock_=!1,this.dragIconData_=[],this.draggingBlock_=t,this.draggedConnectionManager_=new Ld(this.draggingBlock_),this.workspace_=e,this.startXY_=this.draggingBlock_.getRelativeToSurfaceXY(),this.dragIconData_=tr(t,this.startXY_)}dispose(){this.dragIconData_.length=0,this.draggedConnectionManager_&&this.draggedConnectionManager_.dispose()}startDrag(t,e){let s;Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.fireDragStartEvent_(),this.draggingBlock_.bringToFront(!0),dt(),this.workspace_.setResizesEnabled(!1),Fi(),this.shouldDisconnect_(e)&&this.disconnectBlock_(e,t),this.draggingBlock_.setDragging(!0),null==(s=this.workspace_.getLayerManager())||s.moveToDragLayer(this.draggingBlock_)}shouldDisconnect_(t){return!!(this.draggingBlock_.getParent()||t&&this.draggingBlock_.nextConnection&&this.draggingBlock_.nextConnection.targetBlock())}disconnectBlock_(t,e){this.draggingBlock_.unplug(t),t=this.pixelsToWorkspaceUnits_(e),t=ca.sum(this.startXY_,t),this.draggingBlock_.translate(t.x,t.y),xi(this.draggingBlock_),this.draggedConnectionManager_.updateAvailableConnections()}fireDragStartEvent_(){const t=new(P(sl))(this.draggingBlock_,!0,this.draggingBlock_.getDescendants(!1));A(t)}drag(t,e){e=this.pixelsToWorkspaceUnits_(e);var s=ca.sum(this.startXY_,e);this.draggingBlock_.moveDuringDrag(s),s=this.dragTarget_,this.dragTarget_=this.workspace_.getDragTarget(t),this.draggedConnectionManager_.update(e,this.dragTarget_),t=this.wouldDeleteBlock_,this.wouldDeleteBlock_=this.draggedConnectionManager_.wouldDeleteBlock,t!==this.wouldDeleteBlock_&&this.updateCursorDuringBlockDrag_(),this.dragTarget_!==s&&(s&&s.onDragExit(this.draggingBlock_),this.dragTarget_&&this.dragTarget_.onDragEnter(this.draggingBlock_)),this.dragTarget_&&this.dragTarget_.onDragOver(this.draggingBlock_)}endDrag(t,e){if(this.drag(t,e),this.fireDragEndEvent_(),pt(),Fi(),t=null,this.dragTarget_&&this.dragTarget_.shouldPreventMove(this.draggingBlock_)||(t=this.getNewLocationAfterDrag_(e).delta),this.dragTarget_&&this.dragTarget_.onDrop(this.draggingBlock_),!this.maybeDeleteBlock_()){let e;null==(e=this.workspace_.getLayerManager())||e.moveOffDragLayer(this.draggingBlock_,50),this.draggingBlock_.setDragging(!1),t?this.updateBlockAfterMove_():Jn(this.draggingBlock_.workspace,this.workspace_.getMetricsManager().getScrollMetrics(!0),this.draggingBlock_)}this.workspace_.setResizesEnabled(!0),Nr.setGroup$$module$build$src$core$events$utils(!1)}getNewLocationAfterDrag_(t){return{delta:t=this.pixelsToWorkspaceUnits_(t),newLocation:ca.sum(this.startXY_,t)}}maybeDeleteBlock_(){return!!this.wouldDeleteBlock_&&(this.fireMoveEvent_(),this.draggingBlock_.dispose(!1,!0),Xr.length=0,!0)}updateBlockAfterMove_(){this.fireMoveEvent_(),this.draggedConnectionManager_.wouldConnectBlock()?this.draggedConnectionManager_.applyConnections():this.draggingBlock_.queueRender(),this.draggingBlock_.scheduleSnapAndBump()}fireDragEndEvent_(){const t=new(P(sl))(this.draggingBlock_,!1,this.draggingBlock_.getDescendants(!1));A(t)}updateToolboxStyle_(t){const e=this.workspace_.getToolbox();if(e){const s=this.draggingBlock_.isDeletable()?"blocklyToolboxDelete":"blocklyToolboxGrab";t&&"function"==typeof e.removeStyle?e.removeStyle(s):t||"function"!=typeof e.addStyle||e.addStyle(s)}}fireMoveEvent_(){if(!this.draggingBlock_.isDeadOrDying()){var t=new(P(Nr.MOVE$$module$build$src$core$events$utils))(this.draggingBlock_);t.setReason(["drag"]),t.oldCoordinate=this.startXY_,t.recordNew(),A(t)}}updateCursorDuringBlockDrag_(){this.draggingBlock_.setDeleteStyle(this.wouldDeleteBlock_)}pixelsToWorkspaceUnits_(t){return t=new ca(t.x/this.workspace_.scale,t.y/this.workspace_.scale),this.workspace_.isMutator&&t.scale(1/this.workspace_.options.parentWorkspace.scale),t}dragIcons_(){st("Blockly.BlockDragger.prototype.dragIcons_","v10","v11")}getInsertionMarkers(){return this.draggedConnectionManager_&&this.draggedConnectionManager_.getInsertionMarkers?this.draggedConnectionManager_.getInsertionMarkers():[]}};t(Pr.BLOCK_DRAGGER,xr,xp);var Pp={};Pp.Bubble=Ou,Pp.MiniWorkspaceBubble=yu,Pp.TextBubble=Bu,Pp.TextInputBubble=xu;var Fp=class extends Mc{constructor(t,e,s,i){super(t),this.type=qr,this.recordUndo=!1,t&&(this.name=e,this.oldValue=s,this.newValue=i)}toJson(){const t=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");return t.name=this.name,t.oldValue=this.oldValue,t.newValue=this.newValue,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Fp)).name=t.name,e.oldValue=t.oldValue,e.newValue=t.newValue,e}isNull(){return this.oldValue===this.newValue}run(t){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(!(e=e.getBlockById(this.blockId)))throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");t=t?this.newValue:this.oldValue,(e=e.getField(this.name))?e.setValue(t):console.warn("Can't set non-existent field: "+this.name)}};t(Pr.EVENT,qr,Fp);var Up=class extends Mc{constructor(t){super(t),this.type=Nr.MOVE$$module$build$src$core$events$utils,t&&(t.isShadow()&&(this.recordUndo=!1),t=this.currentLocation_(),this.oldParentId=t.parentId,this.oldInputName=t.inputName,this.oldCoordinate=t.coordinate)}toJson(){const t=super.toJson();return t.oldParentId=this.oldParentId,t.oldInputName=this.oldInputName,this.oldCoordinate&&(t.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`),t.newParentId=this.newParentId,t.newInputName=this.newInputName,this.newCoordinate&&(t.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`),this.reason&&(t.reason=this.reason),this.recordUndo||(t.recordUndo=this.recordUndo),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Up)).oldParentId=t.oldParentId,e.oldInputName=t.oldInputName,t.oldCoordinate&&(s=t.oldCoordinate.split(","),e.oldCoordinate=new ca(Number(s[0]),Number(s[1]))),e.newParentId=t.newParentId,e.newInputName=t.newInputName,t.newCoordinate&&(s=t.newCoordinate.split(","),e.newCoordinate=new ca(Number(s[0]),Number(s[1]))),void 0!==t.reason&&(e.reason=t.reason),void 0!==t.recordUndo&&(e.recordUndo=t.recordUndo),e}recordNew(){const t=this.currentLocation_();this.newParentId=t.parentId,this.newInputName=t.inputName,this.newCoordinate=t.coordinate}setReason(t){this.reason=t}currentLocation_(){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var e=t.getBlockById(this.blockId);if(!e)throw Error("The block associated with the block move event could not be found");t={};const s=e.getParent();return s?(t.parentId=s.id,(e=s.getInputWithBlock(e))&&(t.inputName=e.name)):t.coordinate=e.getRelativeToSurfaceXY(),t}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&ca.equals(this.oldCoordinate,this.newCoordinate)}run(t){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var s=e.getBlockById(this.blockId);if(s){var i=t?this.newParentId:this.oldParentId,o=t?this.newInputName:this.oldInputName;if(t=t?this.newCoordinate:this.oldCoordinate,i){var n=e.getBlockById(i);if(!n)return void console.warn("Can't connect to non-existent block: "+i)}if(s.getParent()&&s.unplug(),t)o=s.getRelativeToSurfaceXY(),s.moveBy(t.x-o.x,t.y-o.y,this.reason);else{let t,i;(!(e=s.outputConnection)||s.previousConnection&&s.previousConnection.isConnected())&&(e=s.previousConnection),s=null==(i=e)?void 0:i.type,o?(s=n.getInput(o))&&(t=s.connection):s===Pc.PREVIOUS_STATEMENT&&(t=n.nextConnection),t&&e?e.connect(t):console.warn("Can't connect to non-existent input: "+o)}}else console.warn("Can't move non-existent block: "+this.blockId)}};t(Pr.EVENT,Nr.MOVE$$module$build$src$core$events$utils,Up);var Hp,Gp=class extends Ol{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=rl,t&&(this.blockId=t.id,this.isOpen=e,this.bubbleType=s)}toJson(){const t=super.toJson();if(void 0===this.isOpen)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");return t.isOpen=this.isOpen,t.bubbleType=this.bubbleType,t.blockId=this.blockId||"",t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Gp)).isOpen=t.isOpen,e.bubbleType=t.bubbleType,e.blockId=t.blockId,e}};(function(t){t.MUTATOR="mutator",t.COMMENT="comment",t.WARNING="warning"})(Hp||(Hp={})),t(Pr.EVENT,rl,Gp);var Vp={};Vp.BubbleOpen=Gp,Vp.BubbleType=Hp;var Wp=class extends kl{constructor(t){super(),this.isBlank=!t,t&&(this.commentId=t.id,this.workspaceId=t.workspace.id,this.group=Nr.getGroup$$module$build$src$core$events$utils(),this.recordUndo=y())}toJson(){const t=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return t.commentId=this.commentId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Wp)).commentId=t.commentId,e}static CommentCreateDeleteHelper(t,e){var s=t.getEventWorkspace_();if(e){if(e=Nr.createElement$$module$build$src$core$utils$xml("xml"),!t.xml)throw Error("Ecountered a comment event without proper xml");e.appendChild(t.xml),Nr.domToWorkspace$$module$build$src$core$xml(e,s)}else{if(!t.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(s=s.getCommentById(t.commentId))?s.dispose():console.warn("Can't uncreate non-existent comment: "+t.commentId)}}},Xp=class extends Wp{constructor(t,e,s){super(t),this.type=pl,t&&(this.oldContents_=void 0===e?"":e,this.newContents_=void 0===s?"":s)}toJson(){const t=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");return t.oldContents=this.oldContents_,t.newContents=this.newContents_,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Xp)).oldContents_=t.oldContents,e.newContents_=t.newContents,e}isNull(){return this.oldContents_===this.newContents_}run(t){var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(e=e.getCommentById(this.commentId)){var s=t?this.newContents_:this.oldContents_;if(!s){if(t)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson")}e.setContent(s)}else console.warn("Can't change non-existent comment: "+this.commentId)}};t(Pr.EVENT,pl,Xp);var Yp=class extends Wp{constructor(t){super(t),this.type=ul,t&&(this.xml=t.toXmlWithXY())}toJson(){const t=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");return t.xml=Pe(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Yp)).xml=Nr.textToDom$$module$build$src$core$utils$xml(t.xml),e}run(t){Wp.CommentCreateDeleteHelper(this,t)}};t(Pr.EVENT,ul,Yp);var Kp=class extends Wp{constructor(t){super(t),this.type=dl,t&&(this.xml=t.toXmlWithXY())}run(t){Wp.CommentCreateDeleteHelper(this,!t)}toJson(){const t=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");return t.xml=Pe(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Kp)).xml=Nr.textToDom$$module$build$src$core$utils$xml(t.xml),e}};t(Pr.EVENT,dl,Kp);var zp=class extends Wp{constructor(t){super(t),this.type=gl,t&&(this.comment_=t,this.oldCoordinate_=t.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setOldCoordinate(t){this.oldCoordinate_=t}toJson(){const t=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");return t.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`,t.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y),t}static fromJson(t,e,s){return e=super.fromJson(t,e,null!=s?s:new zp),s=t.oldCoordinate.split(","),e.oldCoordinate_=new ca(Number(s[0]),Number(s[1])),s=t.newCoordinate.split(","),e.newCoordinate_=new ca(Number(s[0]),Number(s[1])),e}isNull(){return ca.equals(this.oldCoordinate_,this.newCoordinate_)}run(t){var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(e=e.getCommentById(this.commentId)){if(!(t=t?this.newCoordinate_:this.oldCoordinate_))throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");var s=e.getRelativeToSurfaceXY();e.moveBy(t.x-s.x,t.y-s.y)}else console.warn("Can't move non-existent comment: "+this.commentId)}};t(Pr.EVENT,gl,zp);var jp=class extends Ol{constructor(t,e,s){super(s),this.type=al,this.oldItem=null!=t?t:void 0,this.newItem=null!=e?e:void 0}toJson(){const t=super.toJson();return t.oldItem=this.oldItem,t.newItem=this.newItem,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new jp)).oldItem=t.oldItem,e.newItem=t.newItem,e}};t(Pr.EVENT,al,jp),Nr.CHANGE$$module$build$src$core$events$utils,Nr.CREATE$$module$build$src$core$events$utils,Nr.DELETE$$module$build$src$core$events$utils,Nr.MOVE$$module$build$src$core$events$utils,Nr.CHANGE$$module$build$src$core$events$utils,Nr.CREATE$$module$build$src$core$events$utils,Nr.DELETE$$module$build$src$core$events$utils,Nr.MOVE$$module$build$src$core$events$utils,Nr.disable$$module$build$src$core$events$utils,Nr.enable$$module$build$src$core$events$utils,Nr.getGroup$$module$build$src$core$events$utils,Nr.setGroup$$module$build$src$core$events$utils;var Jp={};Jp.Abstract=kl,Jp.BLOCK_CHANGE=Nr.CHANGE$$module$build$src$core$events$utils,Jp.BLOCK_CREATE=Nr.CREATE$$module$build$src$core$events$utils,Jp.BLOCK_DELETE=Nr.DELETE$$module$build$src$core$events$utils,Jp.BLOCK_DRAG=sl,Jp.BLOCK_FIELD_INTERMEDIATE_CHANGE=qr,Jp.BLOCK_MOVE=Nr.MOVE$$module$build$src$core$events$utils,Jp.BUBBLE_OPEN=rl,Jp.BUMP_EVENTS=Tl,Jp.BlockBase=Mc,Jp.BlockChange=uu,Jp.BlockCreate=Dc,Jp.BlockDelete=jd,Jp.BlockDrag=Dp,Jp.BlockFieldIntermediateChange=Fp,Jp.BlockMove=Up,Jp.BubbleOpen=Gp,Jp.BubbleType=Hp,Jp.CHANGE=Nr.CHANGE$$module$build$src$core$events$utils,Jp.CLICK=ol,Jp.COMMENT_CHANGE=pl,Jp.COMMENT_CREATE=ul,Jp.COMMENT_DELETE=dl,Jp.COMMENT_MOVE=gl,Jp.CREATE=Nr.CREATE$$module$build$src$core$events$utils,Jp.Click=yl,Jp.ClickTarget=Rl,Jp.CommentBase=Wp,Jp.CommentChange=Xp,Jp.CommentCreate=Yp,Jp.CommentDelete=Kp,Jp.CommentMove=zp,Jp.DELETE=Nr.DELETE$$module$build$src$core$events$utils,Jp.FINISHED_LOADING=_l,Jp.FinishedLoading=Mp,Jp.MARKER_MOVE=nl,Jp.MOVE=Nr.MOVE$$module$build$src$core$events$utils,Jp.MarkerMove=Sd,Jp.SELECTED=il,Jp.Selected=dc,Jp.THEME_CHANGE=cl,Jp.TOOLBOX_ITEM_SELECT=al,Jp.TRASHCAN_OPEN=ll,Jp.ThemeChange=xc,Jp.ToolboxItemSelect=jp,Jp.TrashcanOpen=zd,Jp.UI=el,Jp.UiBase=Ol,Jp.VAR_CREATE=Zr,Jp.VAR_DELETE=Qr,Jp.VAR_RENAME=tl,Jp.VIEWPORT_CHANGE=hl,Jp.VarBase=oc,Jp.VarCreate=nc,Jp.VarDelete=Ud,Jp.VarRename=Hd,Jp.ViewportChange=Fc,Jp.clearPendingUndo=N,Jp.disable=Nr.disable$$module$build$src$core$events$utils,Jp.disableOrphans=F,Jp.enable=Nr.enable$$module$build$src$core$events$utils,Jp.filter=w,Jp.fire=A,Jp.fromJson=x,Jp.get=P,Jp.getDescendantIds=B,Jp.getGroup=Nr.getGroup$$module$build$src$core$events$utils,Jp.getRecordUndo=y,Jp.isEnabled=M,Jp.setGroup=Nr.setGroup$$module$build$src$core$events$utils,Jp.setRecordUndo=O;var qp=class extends pd{constructor(){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.REPLACEMENT_GLOW_COLOUR="#fff200",this.REPLACEMENT_GLOW_SIZE=2,this.selectedGlowFilterId="",this.selectedGlowFilter=null,this.replacementGlowFilterId="",this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.replacementGlowFilter=null,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_(t){super.setFontConstants_(t),this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+2*this.FIELD_BORDER_RECT_Y_PADDING}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_(t){super.setDynamicProperties_(t),this.SELECTED_GLOW_COLOUR=t.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;const e=Number(t.getComponentStyle("selectedGlowSize"));this.SELECTED_GLOW_SIZE=e&&!isNaN(e)?e:this.SELECTED_GLOW_SIZE,this.REPLACEMENT_GLOW_COLOUR=t.getComponentStyle("replacementGlowColour")||this.REPLACEMENT_GLOW_COLOUR,this.REPLACEMENT_GLOW_SIZE=(t=Number(t.getComponentStyle("replacementGlowSize")))&&!isNaN(t)?t:this.REPLACEMENT_GLOW_SIZE}dispose(){super.dispose(),this.selectedGlowFilter&&at(this.selectedGlowFilter),this.replacementGlowFilter&&at(this.replacementGlowFilter)}makeStartHat(){const t=this.START_HAT_HEIGHT,e=this.START_HAT_WIDTH;return{height:t,width:e,path:en("c",[tn(25,-t),tn(71,-t),tn(e,0)])}}makeHexagonal(){function t(t,s,i){var o=t/2;return nn(-(i=i?-1:1)*(o=o>e?e:o),t=(s?-1:1)*t/2)+nn(i*o,t)}const e=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width:t=>(t/=2)>e?e:t,height:t=>t,connectionOffsetY:t=>t/2,connectionOffsetX:t=>-t,pathDown:e=>t(e,!1,!1),pathUp:e=>t(e,!0,!1),pathRightDown:e=>t(e,!1,!0),pathRightUp:e=>t(e,!1,!0)}}makeRounded(){function t(t,e,i){const o=t>s?t-s:0;return an("a","0 0,1",t=(t>s?s:t)/2,tn((e?-1:1)*t,(e?-1:1)*t))+ln("v",(i?1:-1)*o)+an("a","0 0,1",t,tn((e?1:-1)*t,(e?-1:1)*t))}const e=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,s=2*e;return{type:this.SHAPES.ROUND,isDynamic:!0,width:t=>(t/=2)>e?e:t,height:t=>t,connectionOffsetY:t=>t/2,connectionOffsetX:t=>-t,pathDown:e=>t(e,!1,!1),pathUp:e=>t(e,!0,!1),pathRightDown:e=>t(e,!1,!0),pathRightUp:e=>t(e,!1,!0)}}makeSquared(){function t(t,s,i){return t-=2*e,an("a","0 0,1",e,tn((s?-1:1)*e,(s?-1:1)*e))+ln("v",(i?1:-1)*t)+an("a","0 0,1",e,tn((s?1:-1)*e,(s?-1:1)*e))}const e=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width:t=>e,height:t=>t,connectionOffsetY:t=>t/2,connectionOffsetX:t=>-t,pathDown:e=>t(e,!1,!1),pathUp:e=>t(e,!0,!1),pathRightDown:e=>t(e,!1,!0),pathRightUp:e=>t(e,!1,!0)}}shapeFor(t){let e=t.getCheck();switch(!e&&t.targetConnection&&(e=t.targetConnection.getCheck()),t.type){case Pc.INPUT_VALUE:case Pc.OUTPUT_VALUE:if(null!==(t=t.getSourceBlock().getOutputShape()))switch(t){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return e&&-1!==e.indexOf("Boolean")?this.HEXAGONAL:(e&&-1!==e.indexOf("Number")||e&&e.indexOf("String"),this.ROUNDED);case Pc.PREVIOUS_STATEMENT:case Pc.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function t(t){return en("c",[tn(t*o/2,0),tn(t*o*3/4,r/2),tn(t*o,r)])+rn([tn(t*o,n)])+en("c",[tn(t*o/4,r/2),tn(t*o/2,r),tn(t*o,r)])+ln("h",t*i)+en("c",[tn(t*o/2,0),tn(t*o*3/4,-r/2),tn(t*o,-r)])+rn([tn(t*o,-n)])+en("c",[tn(t*o/4,-r/2),tn(t*o/2,-r),tn(t*o,-r)])}const e=this.NOTCH_WIDTH,s=this.NOTCH_HEIGHT,i=e/3,o=i/3,n=s/2,r=n/2,l=t(1),a=t(-1);return{type:this.SHAPES.NOTCH,width:e,height:s,pathLeft:l,pathRight:a}}makeInsideCorners(){const t=this.CORNER_RADIUS,e=an("a","0 0,0",t,tn(-t,t)),s=an("a","0 0,1",t,tn(-t,t));return{width:t,height:t,pathTop:e,pathBottom:an("a","0 0,0",t,tn(t,t)),rightWidth:t,rightHeight:t,pathTopRight:s,pathBottomRight:an("a","0 0,1",t,tn(t,t))}}generateSecondaryColour_(t){return Co("#000",t,.15)||t}generateTertiaryColour_(t){return Co("#000",t,.25)||t}createDom(t,e,s){super.createDom(t,e,s),t=it(ba.DEFS,{},t),e=it(ba.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(ba.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},e),s=it(ba.FECOMPONENTTRANSFER,{result:"outBlur"},e),it(ba.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},s),it(ba.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),it(ba.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.selectedGlowFilterId=e.id,this.selectedGlowFilter=e,t=it(ba.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(ba.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},t),e=it(ba.FECOMPONENTTRANSFER,{result:"outBlur"},t),it(ba.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},e),it(ba.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),it(ba.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),it(ba.FECOMPOSITE,{in:"SourceGraphic",in2:"outGlow",operator:"over"},t),this.replacementGlowFilterId=t.id,this.replacementGlowFilter=t}getCSS_(t){return[`${t} .blocklyText,`,`${t} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${t} .blocklyText {`,"fill: #fff;","}",`${t} .blocklyNonEditableText>rect:not(.blocklyDropdownRect),`,`${t} .blocklyEditableText>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${t} .blocklyNonEditableText>text,`,`${t} .blocklyEditableText>text,`,`${t} .blocklyNonEditableText>g>text,`,`${t} .blocklyEditableText>g>text {`,"fill: #575E75;","}",`${t} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${t} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${t} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>rect,",`${t} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${t} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${t} .blocklyDropdownText {`,"fill: #fff !important;","}",`${t}.blocklyWidgetDiv .goog-menuitem,`,`${t}.blocklyDropDownDiv .goog-menuitem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${t}.blocklyDropDownDiv .goog-menuitem-content {`,"color: #fff;","}",`${t} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${t} .blocklyDisabled > .blocklyOutlinePath {`,`fill: url(#blocklyDisabledPattern${this.randomIdentifier})`,"}",`${t} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},Zp=class extends _d{constructor(t,e){super(t,e)}draw(){const t=this.block_.pathObject;t.beginDrawing(),this.drawOutline_(),this.drawInternals_(),t.setPath(this.outlinePath_+"\n"+this.inlinePath_),this.info_.RTL&&t.flipRTL(),this.recordSizeOnBlock_(),this.info_.outputConnection&&(t.outputShapeType=this.info_.outputConnection.shape.type),t.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_(t){if(!(0>=t.height)){if(Xu.isSpacer(t)){const i=t.precedesStatement;var e=t.followsStatement;if(i||e){const o=this.constants_.INSIDE_CORNERS;var s=o.rightHeight;return s=t.height-(i?s:0),e=e?o.pathBottomRight:"",t=0=s||0>=e)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new $a(e,s+Qp.Y_PADDING),this.imageHeight=s,"function"==typeof o&&(this.clickHandler=o),t!==mu.SKIP_SETUP&&(r?this.configure_(r):(this.flipRtl=!!n,this.altText=Ao(i)||""),this.setValue(Ao(t)))}configure_(t){super.configure_(t),t.flipRtl&&(this.flipRtl=t.flipRtl),t.alt&&(this.altText=Ao(t.alt))}initView(){this.imageElement=it(ba.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(ga,"xlink:href",this.value_),this.clickHandler&&(this.imageElement.style.cursor="pointer")}updateSize_(){}doClassValidation_(t){return"string"!=typeof t?null:t}doValueUpdate_(t){this.value_=t,this.imageElement&&this.imageElement.setAttributeNS(ga,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl}setAlt(t){t!==this.altText&&(this.altText=t||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(t){this.clickHandler=t}getText_(){return this.altText}static fromJson(t){if(!t.src||!t.width||!t.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(t.src,t.width,t.height,void 0,void 0,void 0,t)}};Qp.Y_PADDING=1,Mo("field_image",Qp),Qp.prototype.DEFAULT_VALUE="";var tg=class extends mu{constructor(t,e,s){super(mu.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onKeyInputWrapper_=this.onKeyDownWrapper_=this.valueWhenEditorWasOpened_=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,this.CURSOR="text",t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),void 0!==t.spellcheck&&(this.spellcheck_=t.spellcheck)}initView(){if(!this.getSourceBlock())throw new Eu;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const t=this.getSourceBlock();if(!t)throw new Eu;let e;return this.fullBlockClickTarget_=!(null==(e=this.getConstants())||!e.FULL_BLOCK_FIELDS)&&t.isSimpleReporter()}doValueInvalid_(t){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,t=this.value_,this.value_=this.htmlInput_.getAttribute("data-untyped-default-value"),this.sourceBlock_&&M()&&A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock_,"field",this.name||null,t,this.value_)))}doValueUpdate_(t){this.isTextValid_=this.isDirty_=!0,this.value_=t}applyColour(){const t=this.getSourceBlock();if(!t)throw new Eu;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",t.style.colourTertiary)):(this.borderRect_.style.display="none",t.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR)))}getSize(){let t;return null!=(t=this.getConstants())&&t.FULL_BLOCK_FIELDS&&(this.render_(),this.isDirty_=!1),super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){if(super.render_(),this.isBeingEdited_){var t=this.htmlInput_;this.isTextValid_?(rt(t,"blocklyInvalidInput"),xs(t,zc.INVALID,!1)):(ot(t,"blocklyInvalidInput"),xs(t,zc.INVALID,!0))}if(!(t=this.getSourceBlock()))throw new Eu;this.getConstants().FULL_BLOCK_FIELDS&&t.applyColour()}setSpellcheck(t){t!==this.spellcheck_&&(this.spellcheck_=t,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(t,e=!1){this.workspace_=this.sourceBlock_.workspace,!e&&this.workspace_.options.modalInputs&&(Zl||zl||jl)?this.showPromptEditor_():this.showInlineEditor_(e)}showPromptEditor_(){te(Nr.Msg$$module$build$src$core$msg.CHANGE_VALUE_TITLE,this.getText(),(t=>{null!==t&&this.setValue(this.getValueFromEditorText_(t)),this.onFinishEditing_(this.value_)}))}showInlineEditor_(t){const e=this.getSourceBlock();if(!e)throw new Eu;Hs(this,e.RTL,this.widgetDispose_.bind(this)),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,this.valueWhenEditorWasOpened_=this.value_,t||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var t=this.getSourceBlock();if(!t)throw new Eu;Nr.setGroup$$module$build$src$core$events$utils(!0);const e=Ps();var s=this.getClickTarget_();if(!s)throw Error("A click target has not been set.");ot(s,"editing"),(s=document.createElement("input")).className="blocklyHtmlInput",s.setAttribute("spellcheck",this.spellcheck_);const i=this.workspace_.getScale();var o=this.getConstants().FIELD_TEXT_FONTSIZE*i+"pt";return e.style.fontSize=o,s.style.fontSize=o,o=tg.BORDERRADIUS*i+"px",this.isFullBlockField()&&(o=((o=this.getScaledBBox()).bottom-o.top)/2+"px",t=t.getParent()?t.getParent().style.colourTertiary:this.sourceBlock_.style.colourTertiary,s.style.border=1*i+"px solid "+t,e.style.borderRadius=o,e.style.transition="box-shadow 0.25s ease 0s",this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(e.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*i+"px")),s.style.borderRadius=o,e.appendChild(s),s.value=s.defaultValue=this.getEditorText_(this.value_),s.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(s),s}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&M()&&null!==this.valueWhenEditorWasOpened_&&this.valueWhenEditorWasOpened_!==this.value_&&(A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),Nr.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var t=Ps().style;if(t.width="auto",t.height="auto",t.fontSize="",t.transition="",t.boxShadow="",this.htmlInput_=null,!(t=this.getClickTarget_()))throw Error("A click target has not been set.");rt(t,"editing")}onFinishEditing_(t){}bindInputEvents_(t){this.onKeyDownWrapper_=Y(t,"keydown",this,this.onHtmlInputKeyDown_),this.onKeyInputWrapper_=Y(t,"input",this,this.onHtmlInputChange_)}unbindInputEvents_(){this.onKeyDownWrapper_&&(z(this.onKeyDownWrapper_),this.onKeyDownWrapper_=null),this.onKeyInputWrapper_&&(z(this.onKeyInputWrapper_),this.onKeyInputWrapper_=null)}onHtmlInputKeyDown_(t){"Enter"===t.key?(Gs(),Li()):"Escape"===t.key?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value")),Gs(),Li()):"Tab"===t.key&&(Gs(),Li(),this.sourceBlock_.tab(this,!t.shiftKey),t.preventDefault())}onHtmlInputChange_(t){t=this.value_,this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&M()&&this.value_!==t&&A(new(P(qr))(this.sourceBlock_,this.name||null,t,this.value_))}setEditorValue_(t,e=!0){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(t)),this.setValue(t,e)}resizeEditor_(){var t=this.getSourceBlock();if(!t)throw new Eu;const e=Ps(),s=this.getScaledBBox();e.style.width=s.right-s.left+"px",e.style.height=s.bottom-s.top+"px",t=new ca(t.RTL?s.right-e.offsetWidth:s.left,s.top),e.style.left=t.x+"px",e.style.top=t.y+"px"}repositionForWindowResize(){const t=this.getSourceBlock();return t instanceof op&&(Jn(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),t)||this.resizeEditor_(),!0)}isTabNavigable(){return!0}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(t){return`${t}`}getValueFromEditorText_(t){return t}};tg.BORDERRADIUS=4;var eg=class extends tg{constructor(t,e,s){super(t,e,s)}doClassValidation_(t){return void 0===t?null:`${t}`}static fromJson(t){return new this(Ao(t.text),void 0,t)}};Mo("field_input",eg),eg.prototype.DEFAULT_VALUE="";var sg=class extends zu{constructor(t){super(t)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(t){return!!t.outputConnection}hasRightSquareCorner(t){return!!t.outputConnection&&!t.statementInputCount&&!t.nextConnection}},ig=class extends id{constructor(t,e){if(super(t,e),this.connectedBottomNextConnection=!1,this.connectedBlock){for(t=this.connectedBlock;e=t.getNextBlock();)t=e;t.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},og=class extends Yu{constructor(t){super(t),this.width=this.height=0,this.type|=Xu.getType("RIGHT_CONNECTION")}},ng=class extends dd{constructor(t){super(t)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(t){const e=(t.hat?"cap"===t.hat:this.constants_.ADD_START_HATS)&&!t.outputConnection&&!t.previousConnection;return!!t.outputConnection||e}hasRightSquareCorner(t){return!!t.outputConnection&&!t.statementInputCount&&!t.nextConnection}},rg=class extends $d{constructor(t,e){super(t,e),this.isInline=!0,this.renderer_=t,this.constants_=this.renderer_.getConstants(),this.topRow=new ng(this.constants_),this.bottomRow=new sg(this.constants_),this.isMultiRow=!e.getInputsInline()||e.isCollapsed(),this.hasStatementInput=0=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!i.precedesStatement,Xu.isInputRow(n)&&n.hasStatement){let s,i;n.measure(),e=n.width-(null!=(i=null==(s=n.getLastInput())?void 0:s.width)?i:0)+t}else if(s&&(2===o||i)&&Xu.isInputRow(n)&&!n.hasStatement){i=n.xPos,s=null;for(let t=0;ts?s:this.height/2)*(1-Math.sin(Math.acos((s-this.constants_.SMALL_PADDING)/s)))):0;if(Xu.isInlineInput(t)&&t instanceof Ju){const o=t.connectedBlock;return null==(t=o?o.pathObject.outputShapeType:t.shape.type)||o&&o.outputConnection&&(o.statementInputCount||o.nextConnection)||s===i.SHAPES.HEXAGONAL&&s!==t?0:e-this.constants_.SHAPE_IN_SHAPE_PADDING[s][t]}return Xu.isField(t)&&t instanceof Zu?s===i.SHAPES.ROUND&&t.field instanceof eg?e-2.75*i.GRID_UNIT:e-this.constants_.SHAPE_IN_SHAPE_PADDING[s][0]:Xu.isIcon(t)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let i=2;i=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!r.precedesStatement;if(t?this.topRow.hasPreviousConnection:o.followsStatement){var s=n.elements[1];if(s=3===n.elements.length&&s instanceof Zu&&(s.field instanceof Td||s.field instanceof Qp),!t&&s)o.height-=this.constants_.SMALL_PADDING,r.height-=this.constants_.SMALL_PADDING,n.height-=this.constants_.MEDIUM_PADDING;else if(t||e){if(e){for(t=!1,e=0;ee;e+=15)it(ba.LINE,{x1:pg.HALF+pg.RADIUS,y1:pg.HALF,x2:pg.HALF+pg.RADIUS-(0==e%45?10:5),y2:pg.HALF,class:"blocklyAngleMarks",transform:"rotate("+e+","+pg.HALF+","+pg.HALF+")"},t);return this.boundEvents.push(Y(t,"click",this,this.hide)),this.boundEvents.push(Y(e,"pointerdown",this,this.onMouseMove_,!0)),this.boundEvents.push(Y(e,"pointermove",this,this.onMouseMove_,!0)),t}dropdownDispose(){for(const t of this.boundEvents)z(t);this.boundEvents.length=0,this.line=this.gauge=null}hide(){Ai(this),Gs()}onMouseMove_(t){var e=this.gauge.ownerSVGElement.getBoundingClientRect();const s=t.clientX-e.left-pg.HALF;t=t.clientY-e.top-pg.HALF,e=Math.atan(-t/s),isNaN(e)||(e=hi(e),0>s?e+=180:0(t%=360)&&(t+=360),t>this.wrap&&(t-=360),t}static fromJson(t){return new this(t.angle,void 0,t)}};pg.HALF=50,pg.RADIUS=pg.HALF-1,pg.CLOCKWISE=!1,pg.OFFSET=0,pg.WRAP=360,pg.ROUND=15,Mo("field_angle",pg),pg.prototype.DEFAULT_VALUE=0,tt("\n.blocklyAngleCircle {\n stroke: #444;\n stroke-width: 1;\n fill: #ddd;\n fill-opacity: 0.8;\n}\n\n.blocklyAngleMarks {\n stroke: #444;\n stroke-width: 1;\n}\n\n.blocklyAngleGauge {\n fill: #f88;\n fill-opacity: 0.8;\n pointer-events: none;\n}\n\n.blocklyAngleLine {\n stroke: #f00;\n stroke-width: 2;\n stroke-linecap: round;\n pointer-events: none;\n}\n"),function(t){t.COMPASS="compass",t.PROTRACTOR="protractor"}(dg||(dg={}));var gg={};gg.FieldAngle=pg,gg.Mode=dg;var _g=class extends mu{constructor(t,e,s){super(mu.SKIP_SETUP),this.SERIALIZABLE=!0,this.CURSOR="default",this.value_=this.value_,this.checkChar=_g.CHECK_CHAR,t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),t.checkCharacter&&(this.checkChar=t.checkCharacter)}saveState(){const t=this.saveLegacyState(_g);return null!==t?t:this.getValueBoolean()}initView(){super.initView();const t=this.getTextElement();ot(t,"blocklyCheckbox"),t.style.display=this.value_?"block":"none"}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(t){this.checkChar=t||_g.CHECK_CHAR,this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(t){return!0===t||"TRUE"===t?"TRUE":!1===t||"FALSE"===t?"FALSE":null}doValueUpdate_(t){this.value_=this.convertValueToBool_(t),this.textElement_&&(this.textElement_.style.display=this.value_?"block":"none")}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool_(this.value_))}convertValueToBool_(t){return"string"==typeof t?"TRUE"===t:!!t}static fromJson(t){return new this(t.checked,void 0,t)}};_g.CHECK_CHAR="✓",Mo("field_checkbox",_g),_g.prototype.DEFAULT_VALUE=!1;var Tg=class extends mu{constructor(t,e,s){super(mu.SKIP_SETUP),this.highlightedIndex=this.picker=null,this.boundEvents=[],this.SERIALIZABLE=!0,this.CURSOR="default",this.isDirty_=!1,this.titles=this.colours=null,this.columns=0,t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),t.colourOptions&&(this.colours=t.colourOptions),t.colourTitles&&(this.titles=t.colourTitles),t.columns&&(this.columns=t.columns)}initView(){this.size_=new $a(this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT),this.createBorderRect_(),this.getBorderRect().style.fillOpacity="1",this.getBorderRect().setAttribute("stroke","#fff"),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const t=this.getSourceBlock();if(!t)throw new Eu;const e=this.getConstants();return t.isSimpleReporter()&&!(null==e||!e.FIELD_COLOUR_FULL_BLOCK)}applyColour(){const t=this.getSourceBlock();if(!t)throw new Eu;if(this.fieldGroup_){var e=this.borderRect_;if(!e)throw Error("The border rect has not been initialized");this.isFullBlockField()?(e.style.display="none",t.pathObject.svgPath.setAttribute("fill",this.getValue()),t.pathObject.svgPath.setAttribute("stroke","#fff")):(e.style.display="block",e.style.fill=this.getValue())}}getSize(){let t;return null!=(t=this.getConstants())&&t.FIELD_COLOUR_FULL_BLOCK&&(this.render_(),this.isDirty_=!1),super.getSize()}render_(){super.render_();const t=this.getSourceBlock();if(!t)throw new Eu;t.applyColour()}updateSize_(t){var e=this.getConstants();this.isFullBlockField()?(t=2*(null!=t?t:0),e=e.FIELD_TEXT_HEIGHT):(t=e.FIELD_COLOUR_DEFAULT_WIDTH,e=e.FIELD_COLOUR_DEFAULT_HEIGHT),this.size_.height=e,this.size_.width=t,this.positionBorderRect_()}doClassValidation_(t){return"string"!=typeof t?null:$o(t)}getText(){let t=this.value_;return/^#(.)\1(.)\2(.)\3$/.test(t)&&(t="#"+t[1]+t[3]+t[5]),t}setColours(t,e){return this.colours=t,e&&(this.titles=e),this}setColumns(t){return this.columns=t,this}showEditor_(){this.dropdownCreate(),_i().appendChild(this.picker),bi(this,this.dropdownDispose.bind(this)),this.picker.focus({preventScroll:!0})}onClick(t){null!==(t=(t=t.target)&&t.getAttribute("data-colour"))&&(this.setValue(t),Ai(this))}onKeyDown(t){let e=!0;var s;switch(t.key){case"ArrowUp":this.moveHighlightBy(0,-1);break;case"ArrowDown":this.moveHighlightBy(0,1);break;case"ArrowLeft":this.moveHighlightBy(-1,0);break;case"ArrowRight":this.moveHighlightBy(1,0);break;case"Enter":(s=this.getHighlighted())&&null!==(s=s.getAttribute("data-colour"))&&this.setValue(s),Li();break;default:e=!1}e&&t.stopPropagation()}moveHighlightBy(t,e){if(this.highlightedIndex){var s=this.colours||Tg.COLOURS,i=this.columns||Tg.COLUMNS,o=this.highlightedIndex%i,n=Math.floor(this.highlightedIndex/i);o+=t,n+=e,0>t?0>o&&0o&&(o=0):0i-1&&ni-1&&o--:0>e?0>n&&(n=0):0Math.floor(s.length/i)-1&&(n=Math.floor(s.length/i)-1),this.setHighlightedCell(this.picker.childNodes[n].childNodes[o],n*i+o)}}onMouseMove(t){const e=(t=t.target)&&Number(t.getAttribute("data-index"));null!==e&&e!==this.highlightedIndex&&this.setHighlightedCell(t,e)}onMouseEnter(){let t;null==(t=this.picker)||t.focus({preventScroll:!0})}onMouseLeave(){var t;null==(t=this.picker)||t.blur(),(t=this.getHighlighted())&&rt(t,"blocklyColourHighlighted")}getHighlighted(){if(!this.highlightedIndex)return null;const t=this.columns||Tg.COLUMNS,e=this.picker.childNodes[Math.floor(this.highlightedIndex/t)];return e?e.childNodes[this.highlightedIndex%t]:null}setHighlightedCell(t,e){const s=this.getHighlighted();s&&rt(s,"blocklyColourHighlighted"),ot(t,"blocklyColourHighlighted"),this.highlightedIndex=e,(t=t.getAttribute("id"))&&this.picker&&xs(this.picker,zc.ACTIVEDESCENDANT,t)}dropdownCreate(){const t=this.columns||Tg.COLUMNS,e=this.colours||Tg.COLOURS,s=this.titles||Tg.TITLES,i=this.getValue(),o=document.createElement("table");let n;o.className="blocklyColourTable",o.tabIndex=0,o.dir="ltr",Bs(o,Kc.GRID),xs(o,zc.EXPANDED,!0),xs(o,zc.ROWCOUNT,Math.floor(e.length/t)),xs(o,zc.COLCOUNT,t);for(let r=0;rtr>td {\n border: 0.5px solid #888;\n box-sizing: border-box;\n cursor: pointer;\n display: inline-block;\n height: 20px;\n padding: 0;\n width: 20px;\n}\n\n.blocklyColourTable>tr>td.blocklyColourHighlighted {\n border-color: #eee;\n box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);\n position: relative;\n}\n\n.blocklyColourSelected, .blocklyColourSelected:hover {\n border-color: #eee !important;\n outline: 1px solid #333;\n position: relative;\n}\n");var mg=class extends Td{constructor(t,e,s){super(String(null!=t?t:""),e,s),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(t){return new this(Ao(t.text),void 0,t)}};Mo("field_label_serializable",mg);var Eg=class extends eg{constructor(t,e,s){super(mu.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),t.maxLines&&this.setMaxLines(t.maxLines)}toXml(t){return t.textContent=this.getValue().replace(/\n/g," "),t}fromXml(t){this.setValue(t.textContent.replace(/ /g,"\n"))}saveState(){const t=this.saveLegacyState(Eg);return null!==t?t:this.getValue()}loadState(t){this.loadLegacyState(mu,t)||this.setValue(t)}initView(){this.createBorderRect_(),this.textGroup=it(ba.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const t=this.getSourceBlock();if(!t)throw new Eu;let e=this.getText();if(!e)return mu.NBSP;const s=e.split("\n");e="";const i=this.isOverflowedY_?this.maxLines_:s.length;for(let t=0;tthis.maxDisplayLength?o=o.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&t===i-1&&(o=o.substring(0,o.length-3)+"..."),o=o.replace(/\s/g,mu.NBSP),e+=o,t!==i-1&&(e+="\n")}return t.RTL&&(e+="‏"),e}doValueUpdate_(t){super.doValueUpdate_(t),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){var t=this.getSourceBlock();if(!t)throw new Eu;for(var e,s=this.textGroup;e=s.firstChild;)s.removeChild(e);e=this.getDisplayText_().split("\n");let i=0;for(let t=0;to&&(o=l),n+=this.getConstants().FIELD_TEXT_HEIGHT+(0this.maxDisplayLength&&(t[l]=t[l].substring(0,this.maxDisplayLength)),r.textContent=t[l];const n=_t(r,e,s,i);n>o&&(o=n)}o+=this.htmlInput_.offsetWidth-this.htmlInput_.clientWidth}this.borderRect_&&(n+=2*this.getConstants().FIELD_BORDER_RECT_Y_PADDING,o+=2*this.getConstants().FIELD_BORDER_RECT_X_PADDING,this.borderRect_.setAttribute("width",`${o}`),this.borderRect_.setAttribute("height",`${n}`)),this.size_.width=o,this.size_.height=n,this.positionBorderRect_()}showEditor_(t,e){super.showEditor_(t,e),this.forceRerender()}widgetCreate_(){const t=Ps(),e=this.workspace_.getScale(),s=document.createElement("textarea");s.className="blocklyHtmlInput blocklyHtmlTextAreaInput",s.setAttribute("spellcheck",String(this.spellcheck_));var i=this.getConstants().FIELD_TEXT_FONTSIZE*e+"pt";t.style.fontSize=i,s.style.fontSize=i,s.style.borderRadius=eg.BORDERRADIUS*e+"px",i=this.getConstants().FIELD_BORDER_RECT_X_PADDING*e;const o=this.getConstants().FIELD_BORDER_RECT_Y_PADDING*e/2;return s.style.padding=o+"px "+i+"px "+o+"px "+i+"px",i=this.getConstants().FIELD_TEXT_HEIGHT+this.getConstants().FIELD_BORDER_RECT_Y_PADDING,s.style.lineHeight=i*e+"px",t.appendChild(s),s.value=s.defaultValue=this.getEditorText_(this.value_),s.setAttribute("data-untyped-default-value",String(this.value_)),s.setAttribute("data-old-value",""),Kl?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(s),s}setMaxLines(t){"number"==typeof t&&0this.max_&&(t.max=`${this.max_}`,xs(t,zc.VALUEMAX,this.max_)),t}static fromJson(t){return new this(t.value,void 0,void 0,void 0,void 0,t)}};Mo("field_number",bg),bg.prototype.DEFAULT_VALUE=0;var fg=class extends Ru{constructor(t,e,s,i,o){super(mu.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=fg.dropdownCreate,this.defaultVariableName="string"==typeof t?t:"",this.size_=new $a(0,0),t!==mu.SKIP_SETUP&&(o?this.configure_(o):this.setTypes(s,i),e&&this.setValidator(e))}configure_(t){super.configure_(t),this.setTypes(t.variableTypes,t.defaultType)}initModel(){var t=this.getSourceBlock();if(!t)throw new Eu;this.variable||(t=Nr.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(t.getId()))}shouldAddBorderRect_(){const t=this.getSourceBlock();if(!t)throw new Eu;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||"variables_get"!==t.type)}fromXml(t){var e=this.getSourceBlock();if(!e)throw new Eu;const s=t.getAttribute("id"),i=t.textContent,o=t.getAttribute("variabletype")||t.getAttribute("variableType")||"";if(e=Nr.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,s,i,o),null!==o&&o!==e.type)throw Error("Serialized variable type with id '"+e.getId()+"' had type "+e.type+", and does not match variable field that references it: "+Pe(t)+".");this.setValue(e.getId())}toXml(t){return this.initModel(),t.id=this.variable.getId(),t.textContent=this.variable.name,this.variable.type&&t.setAttribute("variabletype",this.variable.type),t}saveState(t){var e=this.saveLegacyState(fg);return null!==e||(this.initModel(),e={id:this.variable.getId()},t&&(e.name=this.variable.name,e.type=this.variable.type)),e}loadState(t){const e=this.getSourceBlock();if(!e)throw new Eu;this.loadLegacyState(fg,t)||(t=Nr.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,t.id||null,t.name,t.type||""),this.setValue(t.getId()))}setSourceBlock(t){if(t.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(t)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.name:""}getVariable(){return this.variable}getValidator(){return this.variable?this.validator_:null}doClassValidation_(t){if(null===t)return null;var e=this.getSourceBlock();if(!e)throw new Eu;return(e=Nr.getVariable$$module$build$src$core$variables(e.workspace,t))?(e=e.type,this.typeIsAllowed(e)?t:(console.warn("Variable type doesn't match this field! Type was "+e),null)):(console.warn("Variable id doesn't point to a real variable! ID was "+t),null)}doValueUpdate_(t){const e=this.getSourceBlock();if(!e)throw new Eu;this.variable=Nr.getVariable$$module$build$src$core$variables(e.workspace,t),super.doValueUpdate_(t)}typeIsAllowed(t){const e=this.getVariableTypes();if(!e)return!0;for(let s=0;s{const s=this.targetWorkspace.getGesture(e);s&&(s.setStartBlock(t),s.handleFlyoutStart(e,this))}}onMouseDown(t){const e=this.targetWorkspace.getGesture(t);e&&e.handleFlyoutStart(t,this)}isBlockCreatable(t){return t.isEnabled()}createBlock(t){let e=null;Nr.disable$$module$build$src$core$events$utils();var s=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{e=this.placeNewBlock(t)}finally{Nr.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),t=be(this.targetWorkspace,s),M()){for(Nr.setGroup$$module$build$src$core$events$utils(!0),s=0;s90-e||t>-90-e&&t<-90+e}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const t=this.svgGroup_.getBoundingClientRect(),e=t.top;return this.toolboxPosition_===Ba.TOP?new fa(-1e9,e+t.height,-1e9,1e9):new fa(e,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let t=0;const e=this.workspace_.getTopBlocks(!1);for(let s,i=0;s=e[i];i++)t=Math.max(t,s.getHeightWidth().height);const s=this.buttons_;for(let e,i=0;e=s[i];i++)t=Math.max(t,e.height);if(t+=1.5*this.MARGIN,t*=this.workspace_.scale,t+=Oa.scrollbarThickness,this.height_!==t){for(let t,s=0;t=e[s];s++)this.rectMap_.has(t)&&this.moveRectToBlock_(this.rectMap_.get(t),t);this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==Ba.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+t),this.height_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};t(Pr.FLYOUTS_HORIZONTAL_TOOLBOX,xr,Cg);var kg=class extends Rg{constructor(t){super(t)}setMetrics_(t){if(this.isVisible()){var e=this.workspace_.getMetricsManager(),s=e.getScrollMetrics(),i=e.getViewMetrics();e=e.getAbsoluteMetrics(),"number"==typeof t.y&&(this.workspace_.scrollY=-(s.top+(s.height-i.height)*t.y)),this.workspace_.translate(this.workspace_.scrollX+e.left,this.workspace_.scrollY+e.top)}}getX(){if(!this.isVisible())return 0;var t=this.targetWorkspace.getMetricsManager();const e=t.getAbsoluteMetrics(),s=t.getViewMetrics();return t=t.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===Ba.LEFT?t.width:s.width-this.width_:this.toolboxPosition_===Ba.LEFT?0:s.width:this.toolboxPosition_===Ba.LEFT?0:s.width+e.left-this.width_}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var t=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=t.height,this.setBackgroundPath(this.width_-this.CORNER_RADIUS,t.height-2*this.CORNER_RADIUS),t=this.getX();var e=this.getY();this.positionAt_(this.width_,this.height_,t,e)}}setBackgroundPath(t,e){const s=this.toolboxPosition_===Ba.RIGHT;var i=t+this.CORNER_RADIUS;(i=["M "+(s?i:0)+",0"]).push("h",s?-t:t),i.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,s?0:1,s?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),i.push("v",Math.max(0,e)),i.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,s?0:1,s?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),i.push("h",s?t:-t),i.push("z"),this.svgBackground_.setAttribute("d",i.join(" "))}scrollToStart(){let t;null==(t=this.workspace_.scrollbar)||t.setY(0)}wheel_(t){var e=Z(t);if(e.y){const t=this.workspace_.getMetricsManager(),s=t.getScrollMetrics();let i;e=t.getViewMetrics().top-s.top+e.y,null==(i=this.workspace_.scrollbar)||i.setY(e),Gs(),Li()}t.preventDefault(),t.stopPropagation()}layout_(t,e){this.workspace_.scale=this.targetWorkspace.scale;var s=this.MARGIN;const i=this.RTL?s:s+this.tabWidth_;for(let l,a=0;l=t[a];a++)if("block"===l.type){var o=l.block,n=o.getDescendants(!1);for(let t,e=0;t=n[e];e++)t.isInFlyout=!0;n=o.getSvgRoot();const t=o.getHeightWidth();var r=o.outputConnection?i-this.tabWidth_:i;o.moveBy(r,s),r=this.createRect_(o,this.RTL?r-t.width:r,s,t,a),this.addBlockListeners_(n,o,r),s+=t.height+e[a]}else"button"===l.type&&(o=l.button,this.initFlyoutButton_(o,i,s),s+=o.height+e[a])}isDragTowardWorkspace(t){t=Math.atan2(t.y,t.x)/Math.PI*180;const e=this.dragAngleRange_;return t-e||t<-180+e||t>180-e}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const t=this.svgGroup_.getBoundingClientRect(),e=t.left;return this.toolboxPosition_===Ba.LEFT?new fa(-1e9,1e9,-1e9,e+t.width):new fa(-1e9,1e9,e,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let t=0;var e=this.workspace_.getTopBlocks(!1);for(let i,o=0;i=e[o];o++){var s=i.getHeightWidth().width;i.outputConnection&&(s-=this.tabWidth_),t=Math.max(t,s)}for(let e,s=0;e=this.buttons_[s];s++)t=Math.max(t,e.width);if(t+=1.5*this.MARGIN+this.tabWidth_,t*=this.workspace_.scale,t+=Oa.scrollbarThickness,this.width_!==t){for(let i,o=0;i=e[o];o++){if(this.RTL){s=i.getRelativeToSurfaceXY().x;let e=t/this.workspace_.scale-this.MARGIN;i.outputConnection||(e-=this.tabWidth_),i.moveBy(e-s,0)}this.rectMap_.has(i)&&this.moveRectToBlock_(this.rectMap_.get(i),i)}if(this.RTL)for(let s,i=0;s=this.buttons_[i];i++)e=s.getPosition().y,s.moveTo(t/this.workspace_.scale-s.width-this.MARGIN-this.tabWidth_,e);this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==Ba.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+t,this.targetWorkspace.scrollY),this.width_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};kg.registryName="verticalFlyout",t(Pr.FLYOUTS_VERTICAL_TOOLBOX,xr,kg),Nr.CodeGenerator$$module$build$src$core$generator=class{constructor(t){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_=t,this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(t){t||(console.warn("No workspace specified in workspaceToCode call. Guessing."),t=g());var e=[];this.init(t),t=t.getTopBlocks(!0);for(let s,i=0;s=t[i];i++){let t=this.blockToCode(s);Array.isArray(t)&&(t=t[0]),t&&(s.outputConnection&&(t=this.scrubNakedValue(t),this.STATEMENT_PREFIX&&!s.suppressPrefixSuffix&&(t=this.injectId(this.STATEMENT_PREFIX,s)+t),this.STATEMENT_SUFFIX&&!s.suppressPrefixSuffix&&(t+=this.injectId(this.STATEMENT_SUFFIX,s))),e.push(t))}return e=e.join("\n"),(e=(e=(e=this.finish(e)).replace(/^\s+\n/,"")).replace(/\n\s+$/,"\n")).replace(/[ \t]+\n/g,"\n")}prefixLines(t,e){return e+t.replace(/(?!\n$)\n/g,"\n"+e)}allNestedComments(t){const e=[];t=t.getDescendants(!0);for(let s=0;s.blocklyPathLight,`,`${t} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},vg=class{constructor(t){this.inlineSteps_=this.steps_="",this.info_=t,this.RTL_=this.info_.RTL,t=t.getRenderer(),this.constants_=t.getConstants(),this.highlightConstants_=t.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(t){this.steps_+=on(t.xPos,this.info_.startY);for(let e,s=0;e=t.elements[s];s++)Xu.isLeftSquareCorner(e)?this.steps_+=this.highlightConstants_.START_POINT:Xu.isLeftRoundedCorner(e)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):Xu.isPreviousConnection(e)?this.steps_+=this.notchPaths_.pathLeft:Xu.isHat(e)?this.steps_+=this.startPaths_.path(this.RTL_):Xu.isSpacer(e)&&0!==e.width&&(this.steps_+=ln("H",e.xPos+e.width-this.highlightOffset));this.steps_+=ln("H",t.xPos+t.width-this.highlightOffset)}drawJaggedEdge_(t){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+ln("v",t.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(t){const e=t.getLastInput();if(this.RTL_){const s=t.height-e.connectionHeight;this.steps_+=sn(e.xPos+e.width-this.highlightOffset,t.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+ln("v",s)}else this.steps_+=sn(e.xPos+e.width,t.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(t){const e=t.getLastInput();if(e)if(this.RTL_){const s=t.height-2*this.insideCornerPaths_.height;this.steps_+=sn(e.xPos,t.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+ln("v",s)+this.insideCornerPaths_.pathBottom(this.RTL_)+nn(t.width-e.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=sn(e.xPos,t.yPos+t.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+nn(t.width-e.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(t){const e=t.xPos+t.width-this.highlightOffset;t instanceof hd&&t.followsStatement&&(this.steps_+=ln("H",e)),this.RTL_&&(this.steps_+=ln("H",e),t.height>this.highlightOffset&&(this.steps_+=ln("V",t.yPos+t.height-this.highlightOffset)))}drawBottomRow(t){if(this.RTL_)this.steps_+=ln("V",t.baseline-this.highlightOffset);else{const e=this.info_.bottomRow.elements[0];Xu.isLeftSquareCorner(e)?this.steps_+=sn(t.xPos+this.highlightOffset,t.baseline-this.highlightOffset):Xu.isLeftRoundedCorner(e)&&(this.steps_+=sn(t.xPos,t.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var t=this.info_.outputConnection;t&&(t=t.connectionOffsetY+t.height,this.RTL_?this.steps_+=sn(this.info_.startX,t):(this.steps_+=sn(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=ln("V",t)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(t=this.info_.topRow,Xu.isLeftRoundedCorner(t.elements[0])?this.steps_+=ln("V",this.outsideCornerPaths_.height):this.steps_+=ln("V",t.capline+this.highlightOffset))}drawInlineInput(t){const e=this.highlightOffset,s=t.xPos+t.connectionWidth;var i=t.centerline-t.height/2;const o=t.width-t.connectionWidth,n=i+e;this.RTL_?(i=t.connectionOffsetY-e,t=t.height-(t.connectionOffsetY+t.connectionHeight)+e,this.inlineSteps_+=sn(s-e,n)+ln("v",i)+this.puzzleTabPaths_.pathDown(this.RTL_)+ln("v",t)+ln("h",o)):this.inlineSteps_+=sn(t.xPos+t.width+e,n)+ln("v",t.height)+ln("h",-o)+sn(s,i+t.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Lg=class extends _d{constructor(t,e){super(t,e),this.highlighter_=new vg(e)}draw(){this.drawOutline_(),this.drawInternals_();const t=this.block_.pathObject;t.setPath(this.outlinePath_+"\n"+this.inlinePath_),t.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&t.flipRTL(),this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow),this.highlighter_.drawRightSideRow(this.info_.topRow),super.drawTop_()}drawJaggedEdge_(t){this.highlighter_.drawJaggedEdge_(t),super.drawJaggedEdge_(t)}drawValueInput_(t){this.highlighter_.drawValueInput(t),super.drawValueInput_(t)}drawStatementInput_(t){this.highlighter_.drawStatementInput(t),super.drawStatementInput_(t)}drawRightSideRow_(t){this.highlighter_.drawRightSideRow(t),this.outlinePath_+=ln("H",t.xPos+t.width)+ln("V",t.yPos+t.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow),super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft(),super.drawLeft_()}drawInlineInput_(t){this.highlighter_.drawInlineInput(t),super.drawInlineInput_(t)}positionInlineInputConnection_(t){const e=t.centerline-t.height/2;if(t.connectionModel){let s=t.xPos+t.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(s*=-1),t.connectionModel.setOffsetInBlock(s,e+t.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(t){const e=t.getLastInput();if(null!=e&&e.connectionModel){let s=t.xPos+t.statementEdge+e.notchOffset;s=this.info_.RTL?-1*s:s+this.constants_.DARK_PATH_OFFSET,e.connectionModel.setOffsetInBlock(s,t.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(t){const e=t.getLastInput();if(e&&e.connectionModel){let s=t.xPos+t.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(s*=-1),e.connectionModel.setOffsetInBlock(s,t.yPos)}}positionNextConnection_(){const t=this.info_.bottomRow;if(t.connection){const e=t.connection,s=e.xPos;e.connectionModel.setOffsetInBlock((this.info_.RTL?-s:s)+this.constants_.DARK_PATH_OFFSET/2,t.baseline+this.constants_.DARK_PATH_OFFSET)}}},wg=class{constructor(t){this.OFFSET=.5,this.constantProvider=t,this.START_POINT=on(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(){const t=this.constantProvider.CORNER_RADIUS,e=this.OFFSET,s=(1-Math.SQRT1_2)*(t+e)-e,i=on(s,s)+an("a","0 0,0",t,tn(-s-e,t-s)),o=an("a","0 0,0",t+e,tn(t+e,t+e)),n=on(s,-s)+an("a","0 0,0",t+e,tn(t-s,s+e));return{width:t+e,height:t,pathTop:t=>t?i:"",pathBottom:t=>t?o:n}}makeOutsideCorner(){const t=this.constantProvider.CORNER_RADIUS,e=this.OFFSET,s=(1-Math.SQRT1_2)*(t-e)+e,i=on(s,s)+an("a","0 0,1",t-e,tn(t-s,-s+e)),o=on(e,t)+an("a","0 0,1",t-e,tn(t,-t+e)),n=-s,r=on(s,n)+an("a","0 0,1",t-e,tn(-s+e,-n-t));return{height:t,topLeft:t=>t?i:o,bottomLeft:()=>r}}makePuzzleTab(){const t=this.constantProvider.TAB_WIDTH,e=this.constantProvider.TAB_HEIGHT,s=on(-2,3.4-e)+nn(-.45*t,-2.1),i=ln("v",2.5)+on(.97*-t,2.5)+en("q",[tn(.05*-t,10),tn(.3*t,9.5)])+on(.67*t,-1.9)+ln("v",2.5),o=ln("v",-1.5)+on(-.92*t,-.5)+en("q",[tn(-.19*t,-5.5),tn(0,-11)])+on(.92*t,1),n=on(-5,e-.7)+nn(.46*t,-2.1);return{width:t,height:e,pathUp:t=>t?s:o,pathDown:t=>t?i:n}}makeNotch(){return{pathLeft:ln("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:nn(5.1,2.6)+on(-10.2,6.8)+nn(5.1,2.6),height:12,width:10.2}}makeStartHat(){const t=this.constantProvider.START_HAT.height,e=on(25,-8.7)+en("c",[tn(29.7,-6.2),tn(57.2,-.5),tn(75,8.7)]),s=en("c",[tn(17.8,-9.2),tn(45.3,-14.9),tn(75,-8.7)])+sn(100.5,t+.5);return{path:t=>t?e:s}}},Ng=class extends sd{constructor(t,e){super(t,e),this.constants_=t,this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},Mg=class extends id{constructor(t,e){super(t,e),this.constants_=t,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Dg=class extends $d{constructor(t,e){super(t,e),this.renderer_=t}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_(),this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof fd||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(t,e){this.isInline&&t instanceof Nr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new Ng(this.constants_,t)),e.hasInlineInput=!0):t instanceof fd?(e.elements.push(new Mg(this.constants_,t)),e.hasStatement=!0):t instanceof Nr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new qu(this.constants_,t)),e.hasExternalInput=!0):(t instanceof Ed||t instanceof bd)&&(e.minHeight=Math.max(e.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),e.hasDummyInput=!0),this.isInline||null!==e.align||(e.align=t.align)}addElemSpacing_(){let t=!1;for(let e,s=0;e=this.rows[s];s++)e.hasExternalInput&&(t=!0);for(let s,i=0;s=this.rows[i];i++){var e=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new ed(this.constants_,this.getInRowSpacing_(null,e[0]))),e.length){for(let t=0;t>>/sprites.png);\n height: 16px;\n vertical-align: middle;\n visibility: hidden;\n width: 16px;\n}\n\n.blocklyTreeIconClosed {\n background-position: -32px -1px;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeIconClosed {\n background-position: 0 -1px;\n}\n\n.blocklyTreeSelected>.blocklyTreeIconClosed {\n background-position: -32px -17px;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeSelected>.blocklyTreeIconClosed {\n background-position: 0 -17px;\n}\n\n.blocklyTreeIconOpen {\n background-position: -16px -1px;\n}\n\n.blocklyTreeSelected>.blocklyTreeIconOpen {\n background-position: -16px -17px;\n}\n\n.blocklyTreeLabel {\n cursor: default;\n font: 16px sans-serif;\n padding: 0 3px;\n vertical-align: middle;\n}\n\n.blocklyToolboxDelete .blocklyTreeLabel {\n cursor: url("<<>>/handdelete.cur"), auto;\n}\n\n.blocklyTreeSelected .blocklyTreeLabel {\n color: #fff;\n}\n'),t(Pr.TOOLBOX_ITEM,Jg.registrationName,Jg);var qg=class extends jg{constructor(t,e){super(t,e),this.cssConfig_={container:"blocklyTreeSeparator"},this.htmlDiv_=null,Object.assign(this.cssConfig_,t.cssconfig||t.cssConfig)}init(){this.createDom_()}createDom_(){const t=document.createElement("div"),e=this.cssConfig_.container;return e&&ot(t,e),this.htmlDiv_=t}getDiv(){return this.htmlDiv_}dispose(){at(this.htmlDiv_)}};qg.registrationName="sep",tt('\n.blocklyTreeSeparator {\n border-bottom: solid #e5e5e5 1px;\n height: 0;\n margin: 5px 0;\n}\n\n.blocklyToolboxDiv[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'),t(Pr.TOOLBOX_ITEM,qg.registrationName,qg);var Zg=class extends Jg{constructor(t,e,s){super(t,e,s),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){const t=super.makeDefaultCssConfig_();return t.contents="blocklyToolboxContents",t}parseContents_(t){if("custom"in t)this.flyoutItems_=t.custom;else{const e=t.contents;if(e){this.flyoutItems_=[],t=!0;for(let s=0;s>>/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.blocklyToolboxDiv {\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.blocklyToolboxContents {\n display: flex;\n flex-wrap: wrap;\n flex-direction: column;\n}\n\n.blocklyToolboxContents:focus {\n outline: none;\n}\n'),t(Pr.TOOLBOX,xr,Qg);var t_=Nr.Align$$module$build$src$core$inputs$align.LEFT,e_=Nr.Align$$module$build$src$core$inputs$align.CENTRE,s_=Nr.Align$$module$build$src$core$inputs$align.RIGHT,i_=Pc.INPUT_VALUE,o_=Pc.OUTPUT_VALUE,n_=Pc.NEXT_STATEMENT,r_=Pc.PREVIOUS_STATEMENT,l_=Nr.inputTypes$$module$build$src$core$inputs$input_types.DUMMY,a_=Ba.TOP,c_=Ba.BOTTOM,h_=Ba.LEFT,u_=Ba.RIGHT;Vd.prototype.newBlock=function(t,e){return new Jd(this,t,e)},Yd.prototype.newBlock=function(t,e){return new op(this,t,e)},Yd.newTrashcan=function(t){return new ap(t)},_c.prototype.showContextMenu=function(t){if(!this.workspace.options.readOnly){var e=[];this.isDeletable()&&this.isMovable()&&(e.push(li(this)),e.push(ri(this))),Qs(t,e,this.RTL)}},yu.prototype.newWorkspaceSvg=function(t){return new Yd(t)},Nr.Names$$module$build$src$core$names.prototype.populateProcedures=function(t){t=(t=un(t))[0].concat(t[1]);for(let e=0;e{this.updateType_(t)})),this.appendValueInput("TEXT").appendField(t,"TYPE"),this.setOutput(!0,"String"),this.setTooltip((()=>"TEXT"===this.getFieldValue("TYPE")?e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER))}});var _=Object.assign({},g,{init:function(){this.mixin(T);var t=[[e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(e.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),(t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:t})).setValidator((t=>{this.updateType_(t)})),this.appendDummyInput().appendField(t,"TYPE").appendField(this.newQuote_(!0)).appendField(e.fromJson$$module$build$src$core$field_registry({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),this.setTooltip((()=>"TEXT"===this.getFieldValue("TYPE")?e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER))}});d.text_prompt=_,d.text_count={init:function(){this.jsonInit({message0:e.Msg$$module$build$src$core$msg.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:e.Msg$$module$build$src$core$msg.TEXT_COUNT_TOOLTIP,helpUrl:e.Msg$$module$build$src$core$msg.TEXT_COUNT_HELPURL})}},d.text_replace={init:function(){this.jsonInit({message0:e.Msg$$module$build$src$core$msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:e.Msg$$module$build$src$core$msg.TEXT_REPLACE_TOOLTIP,helpUrl:e.Msg$$module$build$src$core$msg.TEXT_REPLACE_HELPURL})}},d.text_reverse={init:function(){this.jsonInit({message0:e.Msg$$module$build$src$core$msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:e.Msg$$module$build$src$core$msg.TEXT_REVERSE_TOOLTIP,helpUrl:e.Msg$$module$build$src$core$msg.TEXT_REVERSE_HELPURL})}};var T={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(t){for(let e,s=0;e=this.inputList[s];s++)for(let s,i=0;s=e.fieldRow[i];i++)if(t===s.name)return e.insertFieldAt(i,this.newQuote_(!0)),void e.insertFieldAt(i+2,this.newQuote_(!1));console.warn('field named "'+t+'" not found in '+this.toDevString())},newQuote_:function(t){return t=this.RTL?!t:t,e.fromJson$$module$build$src$core$field_registry({type:"field_image",src:t?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,width:this.QUOTE_IMAGE_WIDTH,height:this.QUOTE_IMAGE_HEIGHT,alt:t?"“":"”"})}},m={itemCount_:0,mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");return t.setAttribute("items",`${this.itemCount_}`),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(t){this.itemCount_=t.itemCount,this.updateShape_()},decompose:function(t){const e=t.newBlock("text_create_join_container");e.initSvg();let s=e.getInput("STACK").connection;for(let e=0;ee.Msg$$module$build$src$core$msg.TEXT_INDEXOF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1")))})),e.register$$module$build$src$core$extensions("text_quotes",(function(){this.mixin(T),this.quoteField_("TEXT")})),e.registerMixin$$module$build$src$core$extensions("quote_image_mixin",T),e.registerMutator$$module$build$src$core$extensions("text_join_mutator",m,(function(){this.mixin(T),this.itemCount_=2,this.updateShape_(),this.setMutator(new e.MutatorIcon$$module$build$src$core$icons$mutator_icon(["text_create_join_item"],this))})),e.registerMutator$$module$build$src$core$extensions("text_charAt_mutator",E,(function(){this.getField("WHERE").setValidator((function(t){t="FROM_START"===t||"FROM_END"===t;const e=this.getSourceBlock();t!==e.isAt_&&e.updateAt_(t)})),this.updateAt_(!0),this.setTooltip((()=>{var t=this.getFieldValue("WHERE");let s=e.Msg$$module$build$src$core$msg.TEXT_CHARAT_TOOLTIP;return("FROM_START"===t||"FROM_END"===t)&&(t="FROM_START"===t?e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP)&&(s+=" "+t.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),s}))})),e.defineBlocks$$module$build$src$core$common(d);var b={blocks:d},f={},$={setStatements_:function(t){this.hasStatements_!==t&&(t?(this.appendStatementInput("STACK").appendField(e.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=t)},updateParams_:function(){let t="";this.arguments_.length&&(t=e.Msg$$module$build$src$core$msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),e.disable$$module$build$src$core$events$utils();try{this.setFieldValue(t,"PARAMS")}finally{e.enable$$module$build$src$core$events$utils()}},mutationToDom:function(t){const s=e.createElement$$module$build$src$core$utils$xml("mutation");t&&s.setAttribute("name",this.getFieldValue("NAME"));for(let i=0;i","GT"],["‏≥","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);e.register$$module$build$src$core$extensions("logic_op_tooltip",e.buildTooltipForDropdown$$module$build$src$core$extensions("OP",{EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"}));var x={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const t=e.createElement$$module$build$src$core$utils$xml("mutation");return this.elseifCount_&&t.setAttribute("elseif",String(this.elseifCount_)),this.elseCount_&&t.setAttribute("else","1"),t},domToMutation:function(t){this.elseifCount_=parseInt(t.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(t.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const t=Object.create(null);return this.elseifCount_&&(t.elseIfCount=this.elseifCount_),this.elseCount_&&(t.hasElse=!0),t},loadExtraState:function(t){this.elseifCount_=t.elseIfCount||0,this.elseCount_=t.hasElse?1:0,this.updateShape_()},decompose:function(t){const e=t.newBlock("controls_if_if");e.initSvg();let s=e.nextConnection;for(let e=1;e<=this.elseifCount_;e++){const e=t.newBlock("controls_if_elseif");e.initSvg(),s.connect(e.previousConnection),s=e.nextConnection}return this.elseCount_&&((t=t.newBlock("controls_if_else")).initSvg(),s.connect(t.previousConnection)),e},compose:function(t){t=t.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const e=[null],s=[null];let i=null;for(;t;){if(!t.isInsertionMarker())switch(t.type){case"controls_if_elseif":this.elseifCount_++,e.push(t.valueConnection_),s.push(t.statementConnection_);break;case"controls_if_else":this.elseCount_++,i=t.statementConnection_;break;default:throw TypeError("Unknown block type: "+t.type)}t=t.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(e,s,i)},saveConnections:function(t){t=t.nextConnection.targetBlock();let e=1;for(;t;){if(!t.isInsertionMarker())switch(t.type){case"controls_if_elseif":var s=this.getInput("IF"+e);const i=this.getInput("DO"+e);t.valueConnection_=s&&s.connection.targetConnection,t.statementConnection_=i&&i.connection.targetConnection,e++;break;case"controls_if_else":s=this.getInput("ELSE"),t.statementConnection_=s&&s.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+t.type)}t=t.getNextBlock()}},rebuildShape_:function(){const t=[null],e=[null];let s=null;this.getInput("ELSE")&&(s=this.getInput("ELSE").connection.targetConnection);for(let s=1;this.getInput("IF"+s);s++){const i=this.getInput("IF"+s),o=this.getInput("DO"+s);t.push(i.connection.targetConnection),e.push(o.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(t,e,s)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var t=1;this.getInput("IF"+t);t++)this.removeInput("IF"+t),this.removeInput("DO"+t);for(t=1;t<=this.elseifCount_;t++)this.appendValueInput("IF"+t).setCheck("Boolean").appendField(e.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+t).appendField(e.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(e.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(t,e,s){for(let s=1;s<=this.elseifCount_;s++){let i,o;null==(i=t[s])||i.reconnect(this,"IF"+s),null==(o=e[s])||o.reconnect(this,"DO"+s)}null==s||s.reconnect(this,"ELSE")}};e.registerMutator$$module$build$src$core$extensions("controls_if_mutator",x,null,["controls_if_elseif","controls_if_else"]);e.register$$module$build$src$core$extensions("controls_if_tooltip",(function(){this.setTooltip(function(){return this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_4:"":e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_1}.bind(this))}));var P={onchange:function(t){this.prevBlocks_||(this.prevBlocks_=[null,null]);var s=this.getInputTargetBlock("A");const i=this.getInputTargetBlock("B");s&&i&&!this.workspace.connectionChecker.doTypeChecks(s.outputConnection,i.outputConnection)&&(e.setGroup$$module$build$src$core$events$utils(t.group),(t=this.prevBlocks_[0])!==s&&(s.unplug(),!t||t.isDisposed()||t.isShadow()||this.getInput("A").connection.connect(t.outputConnection)),(s=this.prevBlocks_[1])!==i&&(i.unplug(),!s||s.isDisposed()||s.isShadow()||this.getInput("B").connection.connect(s.outputConnection)),this.bumpNeighbours(),e.setGroup$$module$build$src$core$events$utils(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}};e.register$$module$build$src$core$extensions("logic_compare",(function(){this.mixin(P)}));var F={prevParentConnection_:null,onchange:function(t){const s=this.getInputTargetBlock("THEN"),i=this.getInputTargetBlock("ELSE"),o=this.outputConnection.targetConnection;if((s||i)&&o)for(let n=0;2>n;n++){const r=1===n?s:i;r&&!r.workspace.connectionChecker.doTypeChecks(r.outputConnection,o)&&(e.setGroup$$module$build$src$core$events$utils(t.group),o===this.prevParentConnection_?(this.unplug(),o.getSourceBlock().bumpNeighbours()):(r.unplug(),r.bumpNeighbours()),e.setGroup$$module$build$src$core$events$utils(!1))}this.prevParentConnection_=o}};e.registerMixin$$module$build$src$core$extensions("logic_ternary",F),e.defineBlocks$$module$build$src$core$common(B);var U=e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]),H={init:function(){this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_HELPURL),this.setStyle("list_blocks"),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new e.MutatorIcon$$module$build$src$core$icons$mutator_icon(["lists_create_with_item"],this)),this.setTooltip(e.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");return t.setAttribute("items",String(this.itemCount_)),t},domToMutation:function(t){if(!(t=t.getAttribute("items")))throw new TypeError("element did not have items");this.itemCount_=parseInt(t,10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(t){this.itemCount_=t.itemCount,this.updateShape_()},decompose:function(t){const e=t.newBlock("lists_create_with_container");e.initSvg();let s=e.getInput("STACK").connection;for(let e=0;ee.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1")))}};U.lists_indexOf=W;var X={init:function(){var t=[[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET,"GET"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_HELPURL),this.setStyle("list_blocks"),(t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:t})).setValidator((function(t){t="REMOVE"===t,this.getSourceBlock().updateStatement_(t)})),this.appendValueInput("VALUE").setCheck("Array").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(t,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0),this.setTooltip((()=>{const t=this.getFieldValue("MODE"),s=this.getFieldValue("WHERE");let i="";switch(t+" "+s){case"GET FROM_START":case"GET FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case"GET LAST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case"GET RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case"GET_REMOVE LAST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case"GET_REMOVE RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case"REMOVE FROM_START":case"REMOVE FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case"REMOVE FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case"REMOVE LAST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case"REMOVE RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}return"FROM_START"!==s&&"FROM_END"!==s||(i+=" "+("FROM_START"===s?e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),i}))},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");t.setAttribute("statement",String(!this.outputConnection));const s=this.getInput("AT")instanceof e.ValueInput$$module$build$src$core$inputs$value_input;return t.setAttribute("at",String(s)),t},domToMutation:function(t){const e="true"===t.getAttribute("statement");this.updateStatement_(e),t="false"!==t.getAttribute("at"),this.updateAt_(t)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(t){t.isStatement?this.updateStatement_(!0):"string"==typeof t&&this.domToMutation(e.textToDom$$module$build$src$core$utils$xml(t))},updateStatement_:function(t){t!==!this.outputConnection&&(this.unplug(!0,!0),t?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(t){this.removeInput("AT"),this.removeInput("ORDINAL",!0),t?(this.appendValueInput("AT").setCheck("Number"),e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const s=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS});s.setValidator((function(e){const s="FROM_START"===e||"FROM_END"===e;if(s!==t){const t=this.getSourceBlock();return t.updateAt_(s),t.setFieldValue(e,"WHERE"),null}})),this.getInput("AT").appendField(s,"WHERE"),e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};U.lists_getIndex=X;var Y={init:function(){var t=[[e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_SET,"SET"],[e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_IN_LIST),t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:t}),this.appendDummyInput().appendField(t,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0),this.setTooltip((()=>{const t=this.getFieldValue("MODE"),s=this.getFieldValue("WHERE");let i="";switch(t+" "+s){case"SET FROM_START":case"SET FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case"SET FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case"SET LAST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case"SET RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case"INSERT FROM_START":case"INSERT FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case"INSERT FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case"INSERT LAST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case"INSERT RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}return"FROM_START"!==s&&"FROM_END"!==s||(i+=" "+e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),i}))},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation"),s=this.getInput("AT")instanceof e.ValueInput$$module$build$src$core$inputs$value_input;return t.setAttribute("at",String(s)),t},domToMutation:function(t){t="false"!==t.getAttribute("at"),this.updateAt_(t)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(t){this.removeInput("AT"),this.removeInput("ORDINAL",!0),t?(this.appendValueInput("AT").setCheck("Number"),e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const s=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS});s.setValidator((function(e){const s="FROM_START"===e||"FROM_END"===e;if(s!==t){const t=this.getSourceBlock();return t.updateAt_(s),t.setFieldValue(e,"WHERE"),null}})),this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO"),this.getInput("AT").appendField(s,"WHERE")}};U.lists_setIndex=Y;var K={init:function(){this.WHERE_OPTIONS_1=[[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_INPUT_IN_LIST),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");var s=this.getInput("AT1")instanceof e.ValueInput$$module$build$src$core$inputs$value_input;return t.setAttribute("at1",String(s)),s=this.getInput("AT2")instanceof e.ValueInput$$module$build$src$core$inputs$value_input,t.setAttribute("at2",String(s)),t},domToMutation:function(t){const e="true"===t.getAttribute("at1");t="true"===t.getAttribute("at2"),this.updateAt_(1,e),this.updateAt_(2,t)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(t,s){this.removeInput("AT"+t),this.removeInput("ORDINAL"+t,!0),s?(this.appendValueInput("AT"+t).setCheck("Number"),e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+t).appendField(e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+t);const i=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this["WHERE_OPTIONS_"+t]});i.setValidator((function(e){const i="FROM_START"===e||"FROM_END"===e;if(i!==s){const s=this.getSourceBlock();return s.updateAt_(t,i),s.setFieldValue(e,"WHERE"+t),null}})),this.getInput("AT"+t).appendField(i,"WHERE"+t),1===t&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2")),e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};U.lists_getSublist=K,U.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}},U.lists_split={init:function(){const t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:[[e.Msg$$module$build$src$core$msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[e.Msg$$module$build$src$core$msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});if(!t)throw Error("field_dropdown not found");t.setValidator((t=>{this.updateType_(t)})),this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_SPLIT_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("INPUT").setCheck("String").appendField(t,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(e.Msg$$module$build$src$core$msg.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip((()=>{const t=this.getFieldValue("MODE");if("SPLIT"===t)return e.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"===t)return e.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+t)}))},updateType_:function(t){if(this.getFieldValue("MODE")!==t){const t=this.getInput("INPUT").connection;t.setShadowDom(null);const e=t.targetBlock();e&&(t.disconnect(),e.isShadow()?e.dispose(!1):this.bumpNeighbours())}"SPLIT"===t?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");return t.setAttribute("mode",this.getFieldValue("MODE")),t},domToMutation:function(t){this.updateType_(t.getAttribute("mode"))},saveExtraState:function(){return null},loadExtraState:function(){}},e.defineBlocks$$module$build$src$core$common(U);var z={blocks:U},j=e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"colour_picker",message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",helpUrl:"%{BKY_COLOUR_PICKER_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_PICKER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"colour_random",message0:"%{BKY_COLOUR_RANDOM_TITLE}",output:"Colour",helpUrl:"%{BKY_COLOUR_RANDOM_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RANDOM_TOOLTIP}"},{type:"colour_rgb",message0:"%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",args0:[{type:"input_value",name:"RED",check:"Number",align:"RIGHT"},{type:"input_value",name:"GREEN",check:"Number",align:"RIGHT"},{type:"input_value",name:"BLUE",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_RGB_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RGB_TOOLTIP}"},{type:"colour_blend",message0:"%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",args0:[{type:"input_value",name:"COLOUR1",check:"Colour",align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"},{type:"input_value",name:"RATIO",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_BLEND_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_BLEND_TOOLTIP}"}]);e.defineBlocks$$module$build$src$core$common(j);var J={blocks:j},q={blocks:Object.assign({},j,U,B,L,O,f,l,s),colour:J,lists:z,loops:D,math:v,procedures:k,texts:b,variables:u,variablesDynamic:r};return q.__namespace__=e,q})?i.apply(e,o):i)||(t.exports=n)},225:function(t,e,s){var i,o,n;o=[s(983),s(808),s(499),s(986)],void 0===(n="function"==typeof(i=function(t,e,s,i){"use strict";return t.setLocale(e),t})?i.apply(e,o):i)||(t.exports=n)},983:function(t,e,s){var i,o,n;o=[s(239)],void 0===(n="function"==typeof(i=function(t){"use strict";return t})?i.apply(e,o):i)||(t.exports=n)},369:function(t,e,s){var i,o,n;o=[s(225)],void 0===(n="function"==typeof(i=function(t){return t})?i.apply(e,o):i)||(t.exports=n)},986:function(t,e,s){var i,o,n;o=[s(983),s(824)],void 0===(n="function"==typeof(i=function(t,e){return e})?i.apply(e,o):i)||(t.exports=n)},824:function(t,e,s){var i,o,n;o=[s(731)],void 0===(n="function"==typeof(i=function(t){var e,s,i=t.__namespace__,o=function(t,s){var i=0;let o="";s.STATEMENT_PREFIX&&(o+=s.injectId(s.STATEMENT_PREFIX,t));do{const n=s.valueToCode(t,"IF"+i,e.NONE)||"false";let r=s.statementToCode(t,"DO"+i);s.STATEMENT_SUFFIX&&(r=s.prefixLines(s.injectId(s.STATEMENT_SUFFIX,t),s.INDENT)+r),o+=(0o?a=e.SUBTRACTION:n&&(a=e.UNARY_NEGATION),t=this.valueToCode(t,s,a)||l,0!==o||n?i.isNumber$$module$build$src$core$utils$string(t)?(t=String(Number(t)+o),n&&(t=String(-Number(t))),t):(0o&&(t=`${t} - ${-o}`),n&&(t=o?`-(${t})`:`-${t}`),Math.floor(r)>=Math.floor(a)&&(t=`(${t})`),t):t}},d={};d.JavascriptGenerator=u,d.Order=e;var p={colour_blend:function(t,s){const i=s.valueToCode(t,"COLOUR1",e.NONE)||"'#000000'",o=s.valueToCode(t,"COLOUR2",e.NONE)||"'#000000'";return t=s.valueToCode(t,"RATIO",e.NONE)||.5,[s.provideFunction_("colourBlend",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {\n ratio = Math.max(Math.min(Number(ratio), 1), 0);\n var r1 = parseInt(c1.substring(1, 3), 16);\n var g1 = parseInt(c1.substring(3, 5), 16);\n var b1 = parseInt(c1.substring(5, 7), 16);\n var r2 = parseInt(c2.substring(1, 3), 16);\n var g2 = parseInt(c2.substring(3, 5), 16);\n var b2 = parseInt(c2.substring(5, 7), 16);\n var r = Math.round(r1 * (1 - ratio) + r2 * ratio);\n var g = Math.round(g1 * (1 - ratio) + g2 * ratio);\n var b = Math.round(b1 * (1 - ratio) + b2 * ratio);\n r = ('0' + (r || 0).toString(16)).slice(-2);\n g = ('0' + (g || 0).toString(16)).slice(-2);\n b = ('0' + (b || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n`)+"("+i+", "+o+", "+t+")",e.FUNCTION_CALL]},colour_picker:function(t,s){return[s.quote_(t.getFieldValue("COLOUR")),e.ATOMIC]},colour_random:function(t,s){return[s.provideFunction_("colourRandom",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}() {\n var num = Math.floor(Math.random() * Math.pow(2, 24));\n return '#' + ('00000' + num.toString(16)).substr(-6);\n}\n`)+"()",e.FUNCTION_CALL]},colour_rgb:function(t,s){const i=s.valueToCode(t,"RED",e.NONE)||0,o=s.valueToCode(t,"GREEN",e.NONE)||0;return t=s.valueToCode(t,"BLUE",e.NONE)||0,[s.provideFunction_("colourRgb",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {\n r = Math.max(Math.min(Number(r), 100), 0) * 2.55;\n g = Math.max(Math.min(Number(g), 100), 0) * 2.55;\n b = Math.max(Math.min(Number(b), 100), 0) * 2.55;\n r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);\n g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);\n b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n`)+"("+i+", "+o+", "+t+")",e.FUNCTION_CALL]}},g=function(t,e,s){return"FIRST"===e?"0":"FROM_END"===e?t+".length - 1 - "+s:"LAST"===e?t+".length - 1":s},_={lists_create_empty:function(t,s){return["[]",e.ATOMIC]},lists_create_with:function(t,s){const i=Array(t.itemCount_);for(let o=0;o String(b) ? 1 : -1; },\n 'IGNORE_CASE': function(a, b) {\n return String(a).toLowerCase() > String(b).toLowerCase() ? 1 : -1; },\n };\n var compare = compareFuncs[type];\n return function(a, b) { return compare(a, b) * direction; };\n}\n `))+'("'+t+'", '+o+"))",e.FUNCTION_CALL]},lists_split:function(t,s){let i=s.valueToCode(t,"INPUT",e.MEMBER);if(s=s.valueToCode(t,"DELIM",e.NONE)||"''","SPLIT"===(t=t.getFieldValue("MODE")))i||(i="''"),t="split";else{if("JOIN"!==t)throw Error("Unknown mode: "+t);i||(i="[]"),t="join"}return[i+"."+t+"("+s+")",e.FUNCTION_CALL]}},T={};T.controls_if=o,T.controls_ifelse=o,T.logic_boolean=function(t,s){return["TRUE"===t.getFieldValue("BOOL")?"true":"false",e.ATOMIC]},T.logic_compare=function(t,s){const i={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[t.getFieldValue("OP")],o="=="===i||"!="===i?e.EQUALITY:e.RELATIONAL;return[(s.valueToCode(t,"A",o)||"0")+" "+i+" "+(t=s.valueToCode(t,"B",o)||"0"),o]},T.logic_negate=function(t,s){const i=e.LOGICAL_NOT;return["!"+(s.valueToCode(t,"BOOL",i)||"true"),i]},T.logic_null=function(t,s){return["null",e.ATOMIC]},T.logic_operation=function(t,s){const i="AND"===t.getFieldValue("OP")?"&&":"||",o="&&"===i?e.LOGICAL_AND:e.LOGICAL_OR;let n=s.valueToCode(t,"A",o);return t=s.valueToCode(t,"B",o),n||t?(s="&&"===i?"true":"false",n||(n=s),t||(t=s)):t=n="false",[n+" "+i+" "+t,o]},T.logic_ternary=function(t,s){return[(s.valueToCode(t,"IF",e.CONDITIONAL)||"false")+" ? "+(s.valueToCode(t,"THEN",e.CONDITIONAL)||"null")+" : "+(t=s.valueToCode(t,"ELSE",e.CONDITIONAL)||"null"),e.CONDITIONAL]};var m={controls_flow_statements:function(t,e){let s="";if(e.STATEMENT_PREFIX&&(s+=e.injectId(e.STATEMENT_PREFIX,t)),e.STATEMENT_SUFFIX&&(s+=e.injectId(e.STATEMENT_SUFFIX,t)),e.STATEMENT_PREFIX){const i=t.getSurroundLoop();i&&!i.suppressPrefixSuffix&&(s+=e.injectId(e.STATEMENT_PREFIX,i))}switch(t.getFieldValue("FLOW")){case"BREAK":return s+"break;\n";case"CONTINUE":return s+"continue;\n"}throw Error("Unknown flow statement.")},controls_for:function(t,s){var o=s.getVariableName(t.getFieldValue("VAR")),n=s.valueToCode(t,"FROM",e.ASSIGNMENT)||"0",r=s.valueToCode(t,"TO",e.ASSIGNMENT)||"0";const l=s.valueToCode(t,"BY",e.ASSIGNMENT)||"1";let a=s.statementToCode(t,"DO");if(a=s.addLoopTrap(a,t),i.isNumber$$module$build$src$core$utils$string(n)&&i.isNumber$$module$build$src$core$utils$string(r)&&i.isNumber$$module$build$src$core$utils$string(l))t="for ("+o+" = "+n+"; "+o+((s=Number(n)<=Number(r))?" <= ":" >= ")+r+"; "+o,t=1===(o=Math.abs(Number(l)))?t+(s?"++":"--"):t+(s?" += ":" -= ")+o,t+=") {\n"+a+"}\n";else{t="";let e=n;n.match(/^\w+$/)||i.isNumber$$module$build$src$core$utils$string(n)||(e=s.nameDB_.getDistinctName(o+"_start",i.NameType$$module$build$src$core$names.VARIABLE),t+="var "+e+" = "+n+";\n"),n=r,r.match(/^\w+$/)||i.isNumber$$module$build$src$core$utils$string(r)||(t+="var "+(n=s.nameDB_.getDistinctName(o+"_end",i.NameType$$module$build$src$core$names.VARIABLE))+" = "+r+";\n"),t+="var "+(r=s.nameDB_.getDistinctName(o+"_inc",i.NameType$$module$build$src$core$names.VARIABLE))+" = ",t=i.isNumber$$module$build$src$core$utils$string(l)?t+(Math.abs(Number(l))+";\n"):t+"Math.abs("+l+");\n",t+="if ("+e+" > "+n+") {\n",t=(t+=s.INDENT+r+" = -"+r+";\n")+"}\nfor ("+o+" = "+e+"; "+r+" >= 0 ? "+o+" <= "+n+" : "+o+" >= "+n+"; "+o+" += "+r+") {\n"+a+"}\n"}return t},controls_forEach:function(t,s){const o=s.getVariableName(t.getFieldValue("VAR"));var n=s.valueToCode(t,"LIST",e.ASSIGNMENT)||"[]";let r=s.statementToCode(t,"DO");r=s.addLoopTrap(r,t),t="";let l=n;return n.match(/^\w+$/)||(l=s.nameDB_.getDistinctName(o+"_list",i.NameType$$module$build$src$core$names.VARIABLE),t+="var "+l+" = "+n+";\n"),n=s.nameDB_.getDistinctName(o+"_index",i.NameType$$module$build$src$core$names.VARIABLE),r=s.INDENT+o+" = "+l+"["+n+"];\n"+r,t+"for (var "+n+" in "+l+") {\n"+r+"}\n"}};m.controls_repeat=n,m.controls_repeat_ext=n,m.controls_whileUntil=function(t,s){const i="UNTIL"===t.getFieldValue("MODE");let o=s.valueToCode(t,"BOOL",i?e.LOGICAL_NOT:e.NONE)||"false",n=s.statementToCode(t,"DO");return n=s.addLoopTrap(n,t),i&&(o="!"+o),"while ("+o+") {\n"+n+"}\n"};var E={math_arithmetic:function(t,s){var i={ADD:[" + ",e.ADDITION],MINUS:[" - ",e.SUBTRACTION],MULTIPLY:[" * ",e.MULTIPLICATION],DIVIDE:[" / ",e.DIVISION],POWER:[null,e.NONE]}[t.getFieldValue("OP")];const o=i[0];i=i[1];const n=s.valueToCode(t,"A",i)||"0";return t=s.valueToCode(t,"B",i)||"0",o?[n+o+t,i]:["Math.pow("+n+", "+t+")",e.FUNCTION_CALL]},math_atan2:function(t,s){const i=s.valueToCode(t,"X",e.NONE)||"0";return["Math.atan2("+(s.valueToCode(t,"Y",e.NONE)||"0")+", "+i+") / Math.PI * 180",e.DIVISION]},math_change:function(t,s){const i=s.valueToCode(t,"DELTA",e.ADDITION)||"0";return(t=s.getVariableName(t.getFieldValue("VAR")))+" = (typeof "+t+" === 'number' ? "+t+" : 0) + "+i+";\n"},math_constant:function(t,s){return{PI:["Math.PI",e.MEMBER],E:["Math.E",e.MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",e.DIVISION],SQRT2:["Math.SQRT2",e.MEMBER],SQRT1_2:["Math.SQRT1_2",e.MEMBER],INFINITY:["Infinity",e.ATOMIC]}[t.getFieldValue("CONSTANT")]},math_constrain:function(t,s){return["Math.min(Math.max("+(s.valueToCode(t,"VALUE",e.NONE)||"0")+", "+(s.valueToCode(t,"LOW",e.NONE)||"0")+"), "+(t=s.valueToCode(t,"HIGH",e.NONE)||"Infinity")+")",e.FUNCTION_CALL]},math_modulo:function(t,s){return[(s.valueToCode(t,"DIVIDEND",e.MODULUS)||"0")+" % "+(t=s.valueToCode(t,"DIVISOR",e.MODULUS)||"0"),e.MODULUS]},math_number:function(t,s){return t=Number(t.getFieldValue("NUM")),[String(t),0<=t?e.ATOMIC:e.UNARY_NEGATION]},math_number_property:function(t,s){var i={EVEN:[" % 2 === 0",e.MODULUS,e.EQUALITY],ODD:[" % 2 === 1",e.MODULUS,e.EQUALITY],WHOLE:[" % 1 === 0",e.MODULUS,e.EQUALITY],POSITIVE:[" > 0",e.RELATIONAL,e.RELATIONAL],NEGATIVE:[" < 0",e.RELATIONAL,e.RELATIONAL],DIVISIBLE_BY:[null,e.MODULUS,e.EQUALITY],PRIME:[null,e.NONE,e.FUNCTION_CALL]};const o=t.getFieldValue("PROPERTY"),[n,r,l]=i[o];return i=s.valueToCode(t,"NUMBER_TO_CHECK",r)||"0",[t="PRIME"===o?s.provideFunction_("mathIsPrime",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) === 0 || n % (x + 1) === 0) {\n return false;\n }\n }\n return true;\n}\n`)+"("+i+")":"DIVISIBLE_BY"===o?i+" % "+(t=s.valueToCode(t,"DIVISOR",e.MODULUS)||"0")+" === 0":i+n,l]},math_on_list:function(t,s){var i=t.getFieldValue("OP");switch(i){case"SUM":t=s.valueToCode(t,"LIST",e.MEMBER)||"[]",t+=".reduce(function(x, y) {return x + y;}, 0)";break;case"MIN":t="Math.min.apply(null, "+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"MAX":t="Math.max.apply(null, "+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"AVERAGE":t=(i=s.provideFunction_("mathMean",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(myList) {\n return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"MEDIAN":t=(i=s.provideFunction_("mathMedian",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(myList) {\n var localList = myList.filter(function (x) {return typeof x === 'number';});\n if (!localList.length) return null;\n localList.sort(function(a, b) {return b - a;});\n if (localList.length % 2 === 0) {\n return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;\n } else {\n return localList[(localList.length - 1) / 2];\n }\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"MODE":t=(i=s.provideFunction_("mathModes",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(values) {\n var modes = [];\n var counts = [];\n var maxCount = 0;\n for (var i = 0; i < values.length; i++) {\n var value = values[i];\n var found = false;\n var thisCount;\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][0] === value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.push([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][1] === maxCount) {\n modes.push(counts[j][0]);\n }\n }\n return modes;\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"STD_DEV":t=(i=s.provideFunction_("mathStandardDeviation",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(numbers) {\n var n = numbers.length;\n if (!n) return null;\n var mean = numbers.reduce(function(x, y) {return x + y;}) / n;\n var variance = 0;\n for (var j = 0; j < n; j++) {\n variance += Math.pow(numbers[j] - mean, 2);\n }\n variance = variance / n;\n return Math.sqrt(variance);\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"RANDOM":t=(i=s.provideFunction_("mathRandomList",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(list) {\n var x = Math.floor(Math.random() * list.length);\n return list[x];\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;default:throw Error("Unknown operator: "+i)}return[t,e.FUNCTION_CALL]},math_random_float:function(t,s){return["Math.random()",e.FUNCTION_CALL]},math_random_int:function(t,s){const i=s.valueToCode(t,"FROM",e.NONE)||"0";return t=s.valueToCode(t,"TO",e.NONE)||"0",[s.provideFunction_("mathRandomInt",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(a, b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n var c = a;\n a = b;\n b = c;\n }\n return Math.floor(Math.random() * (b - a + 1) + a);\n}\n`)+"("+i+", "+t+")",e.FUNCTION_CALL]}};E.math_round=r,E.math_single=r,E.math_trig=r;var b={procedures_callnoreturn:function(t,e){return e.forBlock.procedures_callreturn(t,e)[0]+";\n"},procedures_callreturn:function(t,s){const i=s.getProcedureName(t.getFieldValue("NAME")),o=[],n=t.getVars();for(let i=0;i{"use strict";s.d(e,{A:()=>l});var i=s(601),o=s.n(i),n=s(314),r=s.n(n)()(o());r.push([t.id,"body {\n margin: 0;\n max-width: 100vw;\n}\n\npre, code {\n overflow: auto;\n}\n\n#pageContainer {\n display: flex;\n width: 100%;\n max-width: 100vw;\n height: 100vh;\n}\n\n.hidden {\n display: none;\n opacity: 0;\n}\n\n#blocklyDiv {\n flex-basis: 100%;\n height: 100%;\n min-width: 600px;\n}\n\n#outputPane {\n display: flex;\n flex-direction: column;\n width: 400px;\n flex: 0 0 400px;\n overflow: auto;\n margin: 1rem;\n}\n\n#generatedCode {\n height: 50%;\n background-color: rgb(247, 240, 228);\n}\n\n#output {\n height: 50%;\n}",""]);const l=r},314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s="",i=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),i&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),i&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,i,o,n){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var l=0;l0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=n),s&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=s):h[2]=s),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},601:t=>{"use strict";t.exports=function(t){return t[1]}},72:t=>{"use strict";var e=[];function s(t){for(var s=-1,i=0;i{"use strict";var e={};t.exports=function(t,s){var i=function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(s)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},56:(t,e,s)=>{"use strict";t.exports=function(t){var e=s.nc;e&&t.setAttribute("nonce",e)}},825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(s){!function(t,e,s){var i="";s.supports&&(i+="@supports (".concat(s.supports,") {")),s.media&&(i+="@media ".concat(s.media," {"));var o=void 0!==s.layer;o&&(i+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),i+=s.css,o&&(i+="}"),s.media&&(i+="}"),s.supports&&(i+="}");var n=s.sourceMap;n&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(n))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,s)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function s(i){var o=e[i];if(void 0!==o)return o.exports;var n=e[i]={id:i,exports:{}};return t[i].call(n.exports,n,n.exports,s),n.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.nc=void 0,(()=>{"use strict";var t=s(369);const e=JSON.parse('{"B":[{"type":"metadata","message0":"Project Metadata %1 Game Name %2 Author %3 Description %4","args0":[{"type":"input_dummy"},{"type":"input_value","name":"game name","check":"String"},{"type":"input_value","name":"author name","check":"String"},{"type":"input_value","name":"description","check":"String"}],"colour":230,"tooltip":"Project Metadata","helpUrl":""},{"type":"game_loop","message0":"Game Loop","message1":"DO %1 End of Game","args0":[],"args1":[{"type":"input_statement","name":"DO"}],"previousStatement":null,"nextStatement":null,"tooltip":"Your Game Loop!","helpUrl":"","style":"loop_blocks"}]}');var i=s(983);var o=s(72),n=s.n(o),r=s(825),l=s.n(r),a=s(659),c=s.n(a),h=s(56),u=s.n(h),d=s(540),p=s.n(d),g=s(113),_=s.n(g),T=s(523),m={};m.styleTagTransform=_(),m.setAttributes=u(),m.insert=c().bind(null,"head"),m.domAPI=l(),m.insertStyleElement=p(),n()(T.A,m),T.A&&T.A.locals&&T.A.locals;const E=t.common.createBlockDefinitionsFromJsonArray(e.B);t.common.defineBlocks(E);const b=document.getElementById("blocklyDiv"),f=document.getElementById("saveGame"),$=document.getElementById("selectionContainer"),I=document.getElementById("gamesContainer"),S=document.getElementById("pageContainer"),R=t.inject(b,{toolbox:{kind:"categoryToolbox",contents:[{kind:"category",name:"Logic",categorystyle:"logic_category",contents:[{kind:"block",type:"controls_if"},{kind:"block",type:"logic_compare"},{kind:"block",type:"logic_operation"},{kind:"block",type:"logic_negate"},{kind:"block",type:"logic_boolean"},{kind:"block",type:"logic_null"},{kind:"block",type:"logic_ternary"}]},{kind:"category",name:"Loops",categorystyle:"loop_category",contents:[{kind:"block",type:"controls_repeat_ext",inputs:{TIMES:{shadow:{type:"math_number",fields:{NUM:10}}}}},{kind:"block",type:"controls_whileUntil"},{kind:"block",type:"controls_for",inputs:{FROM:{shadow:{type:"math_number",fields:{NUM:1}}},TO:{shadow:{type:"math_number",fields:{NUM:10}}},BY:{shadow:{type:"math_number",fields:{NUM:1}}}}},{kind:"block",type:"controls_forEach"},{kind:"block",type:"controls_flow_statements"}]},{kind:"category",name:"Math",categorystyle:"math_category",contents:[{kind:"block",type:"math_number",fields:{NUM:123}},{kind:"block",type:"math_arithmetic",inputs:{A:{shadow:{type:"math_number",fields:{NUM:1}}},B:{shadow:{type:"math_number",fields:{NUM:1}}}}},{kind:"block",type:"math_single",inputs:{NUM:{shadow:{type:"math_number",fields:{NUM:9}}}}},{kind:"block",type:"math_trig",inputs:{NUM:{shadow:{type:"math_number",fields:{NUM:45}}}}},{kind:"block",type:"math_constant"},{kind:"block",type:"math_number_property",inputs:{NUMBER_TO_CHECK:{shadow:{type:"math_number",fields:{NUM:0}}}}},{kind:"block",type:"math_round",fields:{OP:"ROUND"},inputs:{NUM:{shadow:{type:"math_number",fields:{NUM:3.1}}}}},{kind:"block",type:"math_on_list",fields:{OP:"SUM"}},{kind:"block",type:"math_modulo",inputs:{DIVIDEND:{shadow:{type:"math_number",fields:{NUM:64}}},DIVISOR:{shadow:{type:"math_number",fields:{NUM:10}}}}},{kind:"block",type:"math_constrain",inputs:{VALUE:{shadow:{type:"math_number",fields:{NUM:50}}},LOW:{shadow:{type:"math_number",fields:{NUM:1}}},HIGH:{shadow:{type:"math_number",fields:{NUM:100}}}}},{kind:"block",type:"math_random_int",inputs:{FROM:{shadow:{type:"math_number",fields:{NUM:1}}},TO:{shadow:{type:"math_number",fields:{NUM:100}}}}},{kind:"block",type:"math_random_float"},{kind:"block",type:"math_atan2",inputs:{X:{shadow:{type:"math_number",fields:{NUM:1}}},Y:{shadow:{type:"math_number",fields:{NUM:1}}}}}]},{kind:"category",name:"Text",categorystyle:"text_category",contents:[{kind:"block",type:"text"},{kind:"block",type:"text_multiline"},{kind:"block",type:"text_join"},{kind:"block",type:"text_append",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:""}}}}},{kind:"block",type:"text_length",inputs:{VALUE:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"text_isEmpty",inputs:{VALUE:{shadow:{type:"text",fields:{TEXT:""}}}}},{kind:"block",type:"text_indexOf",inputs:{VALUE:{block:{type:"variables_get"}},FIND:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"text_charAt",inputs:{VALUE:{block:{type:"variables_get"}}}},{kind:"block",type:"text_getSubstring",inputs:{STRING:{block:{type:"variables_get"}}}},{kind:"block",type:"text_changeCase",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"text_trim",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"text_count",inputs:{SUB:{shadow:{type:"text"}},TEXT:{shadow:{type:"text"}}}},{kind:"block",type:"text_replace",inputs:{FROM:{shadow:{type:"text"}},TO:{shadow:{type:"text"}},TEXT:{shadow:{type:"text"}}}},{kind:"block",type:"text_reverse",inputs:{TEXT:{shadow:{type:"text"}}}},{kind:"block",type:"game_loop"},{kind:"block",type:"metadata",inputs:{"game name":{shadow:{type:"text",fields:{TEXT:"Game Name"}}},"author name":{shadow:{type:"text",fields:{TEXT:"Author"}}},description:{shadow:{type:"text",fields:{TEXT:"Description"}}}}}]},{kind:"category",name:"Lists",categorystyle:"list_category",contents:[{kind:"block",type:"lists_create_with"},{kind:"block",type:"lists_create_with"},{kind:"block",type:"lists_repeat",inputs:{NUM:{shadow:{type:"math_number",fields:{NUM:5}}}}},{kind:"block",type:"lists_length"},{kind:"block",type:"lists_isEmpty"},{kind:"block",type:"lists_indexOf",inputs:{VALUE:{block:{type:"variables_get"}}}},{kind:"block",type:"lists_getIndex",inputs:{VALUE:{block:{type:"variables_get"}}}},{kind:"block",type:"lists_setIndex",inputs:{LIST:{block:{type:"variables_get"}}}},{kind:"block",type:"lists_getSublist",inputs:{LIST:{block:{type:"variables_get"}}}},{kind:"block",type:"lists_split",inputs:{DELIM:{shadow:{type:"text",fields:{TEXT:","}}}}},{kind:"block",type:"lists_sort"},{kind:"block",type:"lists_reverse"}]},{kind:"category",name:"Color",categorystyle:"colour_category",contents:[{kind:"block",type:"colour_picker"},{kind:"block",type:"colour_random"},{kind:"block",type:"colour_rgb",inputs:{RED:{shadow:{type:"math_number",fields:{NUM:100}}},GREEN:{shadow:{type:"math_number",fields:{NUM:50}}},BLUE:{shadow:{type:"math_number",fields:{NUM:0}}}}},{kind:"block",type:"colour_blend",inputs:{COLOUR1:{shadow:{type:"colour_picker",fields:{COLOUR:"#ff0000"}}},COLOUR2:{shadow:{type:"colour_picker",fields:{COLOUR:"#3333ff"}}},RATIO:{shadow:{type:"math_number",fields:{NUM:.5}}}}}]},{kind:"sep"},{kind:"category",name:"Variables",categorystyle:"variable_category",custom:"VARIABLE"},{kind:"category",name:"Functions",categorystyle:"procedure_category",custom:"PROCEDURE"}]}});f.addEventListener("click",(async e=>{const s=t.serialization.workspaces.save(R);var i=await fetch("http://localhost:5000/save/game",{method:"POST",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});console.log(i)})),R.addChangeListener((t=>{t.isUiEvent||function(t){const e=i.serialization.workspaces.save(t);window.localStorage?.setItem("mainWorkspace",JSON.stringify(e))}(R)})),R.addChangeListener((e=>{!e.isUiEvent&&e.type!=t.Events.FINISHED_LOADING&&R.isDragging()})),$.classList.remove("hidden"),S.classList.add("hidden"),fetch("http://localhost:5000/games").then((function(t){return t.json()})).then((e=>{for(var s of(console.log(e),e.games)){var i=document.createElement("h2");i.innerHTML=s,i.setAttribute("gameName",s),i.addEventListener("click",(e=>{var s=e.target.getAttribute("gameName");fetch(`http://localhost:5000/games/${s}`).then((function(t){return t.json()})).then((e=>{t.Events.disable(),t.serialization.workspaces.load(e,R,!1),t.Events.enable(),$.classList.add("hidden"),S.classList.remove("hidden")})).catch((e=>{console.log("No games found, loading empty workspace."),t.serialization.workspaces.load({},R,!1),$.classList.add("hidden"),S.classList.remove("hidden")}))})),I.appendChild(i)}})).catch((e=>{console.log(e),console.log("No games found, loading empty workspace."),t.serialization.workspaces.load({},R,!1),$.classList.add("hidden"),S.classList.remove("hidden")}))})()})(); \ No newline at end of file +(()=>{var t={239:function(t,e,s){var i,o,n;o=[s(731)],void 0===(n="function"==typeof(i=function(t){return t})?i.apply(e,o):i)||(t.exports=n)},731:function(t,e,s){var i,o;void 0===(o="function"==typeof(i=function(){var t,e,i,o,n,r,l,a,c,h,u,d,p,g,_,T,m,E,b,f,$,I,S,R,C,k,O,y,A,v,L,w,N,M,D,x,B,P,F,U,H,G,V,W,X,Y,K,z,j,J,q,Z,Q,tt,et,st,it,ot,nt,rt,lt,at,ct,ht,ut,dt,pt,gt,_t,Tt,mt,Et,bt,ft,$t,It,St,Rt,Ct,kt,Ot,yt,At,vt,Lt,wt,Nt,Mt,Dt,xt,Bt,Pt,Ft,Ut,Ht,Gt,Vt,Wt,Xt,Yt,Kt,zt,jt,Jt,qt,Zt,Qt,te,ee,se,ie,oe,ne,re,le,ae,ce,he,ue,de,pe,ge,_e,Te,me,Ee,be,fe,$e,Ie,Se,Re,Ce,ke,Oe,ye,Ae,ve,Le,we,Ne,Me,De,xe,Be,Pe,Fe,Ue,He,Ge,Ve,We,Xe,Ye,Ke,ze,je,Je,qe,Ze,Qe,ts,es,ss,is,os,ns,rs,ls,as,cs,hs,us,ds,ps,gs,_s,Ts,ms,Es,bs,fs,$s,Is,Ss,Rs,Cs,ks,Os,ys,As,vs,Ls,ws,Ns,Ms,Ds,xs,Bs,Ps,Fs,Us,Hs,Gs,Vs,Ws,Xs,Ys,Ks,zs,js,Js,qs,Zs,Qs,ti,ei,si,ii,oi,ni,ri,li,ai,ci,hi,ui,di,pi,gi,_i,Ti,mi,Ei,bi,fi,$i,Ii,Si,Ri,Ci,ki,Oi,yi,Ai,vi,Li,wi,Ni,Mi,Di,xi,Bi,Pi,Fi,Ui,Hi,Gi,Vi,Wi,Xi,Yi,Ki,zi,ji,Ji,qi,Zi,Qi,to,eo,so,io,oo,no,ro,lo,ao,co,ho,uo,po,go,_o,To,mo,Eo,bo,fo,$o,Io,So,Ro,Co,ko,Oo,yo,Ao,vo,Lo,wo,No,Mo,Do,xo,Bo,Po,Fo,Uo,Ho,Go,Vo,Wo,Xo,Yo,Ko,zo,jo,Jo,qo,Zo,Qo,tn,en,sn,on,nn,rn,ln,an,cn,hn,un,dn,pn,gn,_n,Tn,mn,En,bn,fn,$n,In,Sn,Rn,Cn,kn,On,yn,An,vn,Ln,wn,Nn,Mn,Dn,xn,Bn,Pn,Fn,Un,Hn,Gn,Vn,Wn,Xn,Yn,Kn,zn,jn,Jn,qn,Zn,Qn,tr,er,sr,ir,or,nr,rr,lr,ar,cr,hr,ur,dr,pr,gr,_r,Tr,mr,Er,br,fr,$r,Ir,Sr,Rr,Cr,kr,Or,yr,Ar,vr,Lr,wr,Nr={};t=function(t,s,i,o){if(!(t instanceof Pr)&&"string"!=typeof t||""===`${t}`.trim())throw Error('Invalid type "'+t+'". The type must be a non-empty string or a Blockly.registry.Type.');if(t=`${t}`.toLowerCase(),"string"!=typeof s||""===s.trim())throw Error('Invalid name "'+s+'". The name must be a non-empty string.');const n=s.toLowerCase();if(!i)throw Error("Can not register a null value");let r=Mr[t],l=xr[t];if(r||(r=Mr[t]=Object.create(null),l=xr[t]=Object.create(null)),e(t,i),!o&&r[n])throw Error('Name "'+n+'" with type "'+t+'" already registered.');r[n]=i,l[n]=s},e=function(t,e){if(t===String(Pr.FIELD)&&"function"!=typeof e.fromJson)throw Error('Type "'+t+'" must have a fromJson function')},i=function(t,e){t=`${t}`.toLowerCase(),e=e.toLowerCase();const s=Mr[t];s&&s[e]?(delete Mr[t][e],delete xr[t][e]):console.warn("Unable to unregister ["+e+"]["+t+"] from the registry.")},o=function(t,e,s){t=`${t}`.toLowerCase(),e=e.toLowerCase();const i=Mr[t];if(!i||!i[e]){if(e="Unable to find ["+e+"]["+t+"] in the registry.",s)throw Error(e+" You must require or register a "+t+" plugin.");return console.warn(e),null}return i[e]},n=function(t,e){return t=`${t}`.toLowerCase(),e=e.toLowerCase(),!!(t=Mr[t])&&!!t[e]},r=function(t,e,s){return o(t,e,s)},l=function(t,e,s){return o(t,e,s)},a=function(t,e,s){t=`${t}`.toLowerCase();var i=Mr[t];if(!i){if(i=`Unable to find [${t}] in the registry.`,s)throw Error(`${i} You must require or register a ${t} plugin.`);return console.warn(i),null}if(!e)return i;t=xr[t],s=Object.create(null);for(const e of Object.keys(i))s[t[e]]=i[e];return s},c=function(t,e,s){return"function"==typeof(e=e.plugins[String(t)]||Br)?e:r(t,e,s)},h=function(t){return Vr[t]||null},u=function(){const t=[];for(const e in Vr)t.push(Vr[e]);return t},d=function(t){Vr[t.id]=t},p=function(t){delete Vr[t.id]},g=function(){return Ur},_=function(t){Ur=t},T=function(){return Wr},m=function(t){Wr=t},E=function(){return Hr},b=function(t){Hr=t},f=function(t){for(;t.options.parentWorkspace;)t=t.options.parentWorkspace;const e=t.getParentSvg(),s=t.getCachedParentSvgSize();var i=e.parentElement;if(i instanceof HTMLElement){var o=i.offsetWidth;i=i.offsetHeight,s.width!==o&&(e.setAttribute("width",o+"px"),t.setCachedParentSvgSize(o,null)),s.height!==i&&(e.setAttribute("height",i+"px"),t.setCachedParentSvgSize(null,i)),t.resize()}},$=function(t,e){const s=Object.create(null),i=t.getDescendants(!0);e&&(t=t.getNextBlock())&&(t=i.indexOf(t),i.splice(t,i.length-t));for(let t,e=0;t=i[e];e++)s[t.type]?s[t.type]++:s[t.type]=1;return s},I=function(t){return function(){this.jsonInit(t)}},S=function(t){Yr.defineBlocksWithJsonArrayInternal(t)},R=function(t){Nr.defineBlocks$$module$build$src$core$common(Nr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(t))},Nr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(t){const e={};for(let s=0;s{setTimeout(L,0)}))}catch(t){setTimeout(L,0)}ml.push(t)}},L=function(){var t=w(ml,!0);ml.length=0;for(let s,i=0;s=t[i];i++)if(s.workspaceId){var e=h(s.workspaceId);e&&e.fireChangeListener(s)}t=new Set(t.map((t=>t.workspaceId)));for(const s of t){if(!s)continue;if(!(t=h(s)))continue;let i;for(e=(t=t.getUndoStack()).length;0>>/g,t),la="",(t=document.createElement("style")).id="blockly-common-style",e=document.createTextNode(e),t.appendChild(e),document.head.insertBefore(t,document.head.firstChild)))},st=function(t,e,s,i){t=t+" was deprecated in "+e+" and will be deleted in "+s+".",i&&(t+="\nUse "+i+" instead."),console.warn(t)},it=function(t,e,s){t=document.createElementNS(da,`${t}`);for(const s in e)t.setAttribute(s,`${e[s]}`);return s&&s.appendChild(t),t},ot=function(t,e){return!(e=e.split(" ")).every((e=>t.classList.contains(e)))&&(t.classList.add(...e),!0)},nt=function(t,e){t.classList.remove(...e.split(" "))},rt=function(t,e){return!(e=e.split(" ")).every((e=>!t.classList.contains(e)))&&(t.classList.remove(...e),!0)},lt=function(t,e){return t.classList.contains(e)},at=function(t){return t&&t.parentNode?t.parentNode.removeChild(t):null},ct=function(t,e){const s=e.nextSibling;if(!(e=e.parentNode))throw Error("Reference node has no parent.");s?e.insertBefore(t,s):e.appendChild(t)},ht=function(t,e){return st("Blockly.utils.dom.containsNode","version 10","version 11",'Use native "contains" DOM method'),t.contains(e)},ut=function(t,e){t.style.transform=e,t.style["-webkit-transform"]=e},dt=function(){Ta++,_a||(_a=Object.create(null))},pt=function(){--Ta||(_a=null)},gt=function(t){const e=t.textContent+"\n"+t.className.baseVal;let s;if(_a&&(s=_a[e]))return s;try{s=t.getComputedTextLength()}catch(e){return 8*t.textContent.length}return _a&&(_a[e]=s),s},_t=function(t,e,s,i){return Tt(t,e+"pt",s,i)},Tt=function(t,e,s,i){const o=t.textContent;var n;return t=o+"\n"+t.className.baseVal,_a&&(n=_a[t])||(ma||((n=document.createElement("canvas")).className="blocklyComputeCanvas",document.body.appendChild(n),ma=n.getContext("2d")),ma.font=s+" "+e+" "+i,n=o?ma.measureText(o).width:0,_a&&(_a[t]=n)),n},mt=function(t,e,s,i){const o=document.createElement("span");o.style.font=s+" "+e+" "+i,o.textContent=t,(t=document.createElement("div")).style.width="1px",t.style.height="0",(e=document.createElement("div")).style.display="flex",e.style.position="fixed",e.style.top="0",e.style.left="0",e.appendChild(o),e.appendChild(t),document.body.appendChild(e),s={height:0,baseline:0};try{e.style.alignItems="baseline",s.baseline=t.offsetTop-o.offsetTop,e.style.alignItems="flex-end",s.height=t.offsetTop-o.offsetTop}finally{document.body.removeChild(e)}return s},Et=function(t){return Ia.getSizeInternal(t)},bt=function(t){if("none"!==$t(t,"display"))return ft(t);const e=t.style,s=e.display,i=e.visibility,o=e.position;e.visibility="hidden",e.position="absolute",e.display="inline";const n=t.offsetWidth;return t=t.offsetHeight,e.display=s,e.position=o,e.visibility=i,new $a(n,t)},ft=function(t){return new $a(t.offsetWidth,t.offsetHeight)},$t=function(t,e){return(t=window.getComputedStyle(t))[e]||t.getPropertyValue(e)},It=function(t){const e=new ca(0,0);t=t.getBoundingClientRect();var s=document.documentElement;return s=new ca(window.pageXOffset||s.scrollLeft,window.pageYOffset||s.scrollTop),e.x=t.left+s.x,e.y=t.top+s.y,e},St=function(){const t=document.body,e=document.documentElement;return new ca(t.scrollLeft||e.scrollLeft,t.scrollTop||e.scrollTop)},Rt=function(t){const e=parseFloat($t(t,"borderLeftWidth")),s=parseFloat($t(t,"borderRightWidth")),i=parseFloat($t(t,"borderTopWidth"));return t=parseFloat($t(t,"borderBottomWidth")),new fa(i,t,e,s)},Ct=function(t,e,s){t=kt(t,e,s),e.scrollLeft=t.x,e.scrollTop=t.y},kt=function(t,e,s){var i=It(t),o=It(e),n=Rt(e);const r=i.x-o.x-n.left;return i=i.y-o.y-n.top,o=ft(t),t=e.clientWidth-o.width,o=e.clientHeight-o.height,n=e.scrollLeft,e=e.scrollTop,s?(n+=r-t/2,e+=i-o/2):(n+=Math.min(r,Math.max(r-t,0)),e+=Math.min(i,Math.max(i-o,0))),new ca(n,e)},Ot=function(t){const e=new ca(0,0);var s=t.x&&t.getAttribute("x");const i=t.y&&t.getAttribute("y");return s&&(e.x=parseInt(s)),i&&(e.y=parseInt(i)),(s=(s=t.getAttribute("transform"))&&s.match(Ra))&&(e.x+=Number(s[1]),s[3]&&(e.y+=Number(s[3]))),(t=t.getAttribute("style"))&&-1`&#${t.charCodeAt(0)};`))},xt=function(t){return t?((t instanceof Element||"string"==typeof t)&&(t=Xt(t),t=Gt(t)),Bt(t),t):null},Bt=function(t){const e=t.kind;if(t=t.contents,e&&e!==Pa&&e!==Ba)throw Error("Invalid toolbox kind "+e+". Please supply either "+Pa+" or "+Ba);if(!t)throw Error("Toolbox must have a contents attribute.")},Pt=function(t){return t?t.contents?t.contents:Array.isArray(t)&&0 document.")}else t instanceof Element&&(e=t);return e},Yt=function(t,e,s,i,o,n){const r=n.scrollbar&&n.scrollbar.canScrollVertically();return t.horizontal===Ua.LEFT?(s=o.absoluteMetrics.left+s,r&&n.RTL&&(s+=Oa.scrollbarThickness)):(s=o.absoluteMetrics.left+o.viewMetrics.width-e.width-s,r&&!n.RTL&&(s-=Oa.scrollbarThickness)),t.vertical===Fa.TOP?t=o.absoluteMetrics.top+i:(t=o.absoluteMetrics.top+o.viewMetrics.height-e.height-i,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(t-=Oa.scrollbarThickness)),new fa(t,t+e.height,s,s+e.width)},Kt=function(t,e){return{horizontal:e.toolboxMetrics.position===xa.LEFT||t.horizontalLayout&&!t.RTL?Ua.RIGHT:Ua.LEFT,vertical:e.toolboxMetrics.position===xa.BOTTOM?Fa.TOP:Fa.BOTTOM}},zt=function(t,e,s,i){const o=t.left,n=t.right-t.left,r=t.bottom-t.top;for(let l=0;l1'),i.appendChild(s),e.push(i)),Gr.variables_get){t.sort(rc.compareByName);for(let i,o=0;i=t[o];o++)(s=Nr.createElement$$module$build$src$core$utils$xml("block")).setAttribute("type","variables_get"),s.setAttribute("gap","8"),s.appendChild(me(i)),e.push(s)}}return e},le=function(t){return cc.generateUniqueNameInternal(t)},ae=function(t){return ce(ac.charAt(0),t.getAllVariableNames())},ce=function(t,e){if(!e.length)return t;const s=ac;let i="",o=s.indexOf(t);for(;;){let n=!1;for(let s=0;st.getVariableModel().name));if(i&&(s=i.some((e=>e.toLowerCase()===t)),i=i.some((t=>t.toLowerCase()===e)),s&&i))return o.getName()}return null},Te=function(t,e,s){t=t.toLowerCase(),e=e.toLowerCase(),s=s.getAllBlocks(!1);for(const o of s){if(!ie(o))continue;var i=(s=o.getProcedureDef())[1];const n=i.some((e=>e.toLowerCase()===t));if(i=i.some((t=>t.toLowerCase()===e)),n&&i)return s[0]}return null},me=function(t){const e=Nr.createElement$$module$build$src$core$utils$xml("field");return e.setAttribute("name","VAR"),e.setAttribute("id",t.getId()),e.setAttribute("variabletype",t.type),t=Nr.createTextNode$$module$build$src$core$utils$xml(t.name),e.appendChild(t),e},Nr.getOrCreateVariablePackage$$module$build$src$core$variables=function(t,e,s,i){let o=Nr.getVariable$$module$build$src$core$variables(t,e,s,i);return o||(o=Ee(t,e,s,i)),o},Nr.getVariable$$module$build$src$core$variables=function(t,e,s,i){const o=t.getPotentialVariableMap();let n=null;if(e&&(n=t.getVariableById(e),!n&&o&&(n=o.getVariableById(e)),n))return n;if(s){if(void 0===i)throw Error("Tried to look up a variable by name without a type");n=t.getVariable(s,i),!n&&o&&(n=o.getVariable(s,i))}return n},Ee=function(t,e,s,i){const o=t.getPotentialVariableMap();return s||(s=le(t.isFlyout?t.targetWorkspace:t)),o?o.createVariable(s,i,e):t.createVariable(s,i,e)},be=function(t,e){t=t.getAllVariables();const s=[];if(e.length!==t.length)for(let i=0;i{bc=t,fc=window.requestAnimationFrame((()=>{Oe(),t()}))}))),Ec)},Se=function(){return Ec||Promise.resolve()},Re=function(t){t||window.cancelAnimationFrame(fc),Oe(t),!t&&bc&&bc()},Ce=function(){return Yl},ke=function(t){mc.add(t);const e=t.getParent();e?ke(e):Tc.add(t)},Oe=function(t){const e=t?new Set([t]):new Set([...Tc].map((t=>t.workspace))),s=[...Tc].filter(Ae).filter((t=>e.has(t.workspace)));for(var i of s)ve(i);for(const t of e)t.resizeContents();for(const t of s)i=t.getRelativeToSurfaceXY(),t.updateComponentLocations(i);for(const t of s)ye(t);t||(Ec=null)},ye=function(t){Tc.delete(t),mc.delete(t);for(const e of t.getChildren(!1))ye(e)},Ae=function(t){return!t.isDisposed()&&!t.getParent()},ve=function(t){if(mc.has(t)){for(const e of t.getChildren(!1))ve(e);t.renderEfficiently()}},Le=function(t,e){const s=Nr.createElement$$module$build$src$core$utils$xml("xml");var i=we(Nr.allUsedVarModels$$module$build$src$core$variables(t));i.hasChildNodes()&&s.appendChild(i),i=t.getTopComments(!0);for(let t=0;t/g,"<$1$2>")},Fe=function(t){t=Pe(t).split("<");let e="";for(let s=1;s"!==i.slice(-2)&&(e+=" ")}return(t=(t=t.join("\n")).replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1")).replace(/^\n/,"")},Ue=function(t,e){return e.setResizesEnabled(!1),e.clear(),t=Nr.domToWorkspace$$module$build$src$core$xml(t,e),e.setResizesEnabled(!0),t},Nr.domToWorkspace$$module$build$src$core$xml=function(t,e){let s=0;e.RTL&&(s=e.getWidth());const i=[];dt();const o=Nr.getGroup$$module$build$src$core$events$utils();o||Nr.setGroup$$module$build$src$core$events$utils(!0),e.setResizesEnabled&&e.setResizesEnabled(!1);let n=!0;try{for(let o,r=0;o=t.childNodes[r];r++){const t=o.nodeName.toLowerCase(),r=o;if("block"===t||"shadow"===t&&!y()){const t=Ge(r,e);let o;i.push(t.id);const l=parseInt(null!=(o=r.getAttribute("x"))?o:"10",10);let a;const c=parseInt(null!=(a=r.getAttribute("y"))?a:"10",10);isNaN(l)||isNaN(c)||t.moveBy(e.RTL?s-l:l,c,["create"]),n=!1}else{if("shadow"===t)throw TypeError("Shadow block cannot be a top-level block.");if("comment"===t)e.rendered?_c.fromXmlRendered(r,e,s):uc.fromXml(r,e);else if("variables"===t){if(!n)throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");Ve(r,e),n=!1}}}}finally{Nr.setGroup$$module$build$src$core$events$utils(o),e.setResizesEnabled&&e.setResizesEnabled(!0),e.rendered&&Re(),pt()}return A(new(P(_l))(e)),i},He=function(t,e){if(!e.getBlocksBoundingBox)return Nr.domToWorkspace$$module$build$src$core$xml(t,e);var s=e.getBlocksBoundingBox();if(t=Nr.domToWorkspace$$module$build$src$core$xml(t,e),s&&s.top!==s.bottom){var i=s.bottom;s=e.RTL?s.right:s.left;var o=1/0;let n=-1/0,r=1/0;for(let s=0;sn&&(n=i.x)}for(i=i-r+10,s=e.RTL?s-n:s-o,o=0;oc.setBubbleVisible(n)),1)}},Ke=function(t,e){for(let s=0;s{t.disposed||t.setConnectionTracking(!0)}),1)}return r},Ts=function(t,e,{parentConnection:s,isShadow:i=!1}={}){if(!t.type)throw new Rc(t);const o=e.newBlock(t.type,t.id);return o.setShadow(i),ms(o,t),Es(o,t),bs(o,t),fs(s,o,t),$s(o,t),Is(o,t),Ss(o,t),Rs(o,t),ks(o,e.rendered),o},ms=function(t,e){let s=void 0===e.x?0:e.x;e=void 0===e.y?0:e.y;const i=t.workspace;s=i.RTL?i.getWidth()-s:s,t.moveBy(s,e)},Es=function(t,e){e.collapsed&&t.setCollapsed(!0),!1===e.deletable&&t.setDeletable(!1),!1===e.movable&&t.setMovable(!1),!1===e.editable&&t.setEditable(!1),!1===e.enabled&&t.setEnabled(!1),void 0!==e.inline&&t.setInputsInline(e.inline),void 0!==e.data&&(t.data=e.data)},bs=function(t,e){e.extraState&&(t.loadExtraState?t.loadExtraState(e.extraState):t.domToMutation&&t.domToMutation(Nr.textToDom$$module$build$src$core$utils$xml(e.extraState)))},fs=function(t,e,s){if(t){if(t.getSourceBlock().isShadow()&&!e.isShadow())throw new Oc(s);if(t.type===Nr.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var i=e.outputConnection;if(!i)throw new Cc("output",e,s)}else if(!(i=e.previousConnection))throw new Cc("previous",e,s);if(!t.connect(i)){const o=e.workspace.connectionChecker;throw new kc(o.getErrorMessage(o.canConnectWithReason(i,t,!1),i,t),t.type===Nr.inputTypes$$module$build$src$core$inputs$input_types.VALUE?"output connection":"previous connection",e,s)}}},$s=function(t,e){if(e.icons){var s=Object.keys(e.icons);for(const o of s){s=e.icons[o];var i=t.getIcon(o);if(!i){if(!(i=r(Pr.ICON,o,!1)))throw new yc(o,t,e);i=new i(t),t.addIcon(i)}ss(i)&&i.loadState(s)}}},Is=function(t,e){if(e.fields){var s=Object.keys(e.fields);for(let i=0;ie.id!=t.id)).map((t=>t.getRelativeToSurfaceXY()));for(;ys(ca.sum(i,o),n)||As(t,o,s);)e.RTL?o.translate(-s,2*s):o.translate(s,2*s);t.moveTo(ca.sum(i,o))},ys=function(t,e){return e.some((e=>1>=Math.abs(e.x-t.x)&&1>=Math.abs(e.y-t.y)))},As=function(t,e,s){return t.getConnections_(!1).some((t=>!!t.closest(s,e).connection))},vs=function(t){return st("Blockly.clipboard.copy","v11","v12","myCopyable.toCopyData()"),Xc.copyInternal(t)},Ls=function(t){const e=t.toCopyData();let s;return Vc=e,Wc=null!=(s=t.workspace)?s:null,e},ws=function(t,e,s){return t&&e?Ns(t,e,s):Vc&&Wc?Ns(Vc,Wc):null},Ns=function(t,e,s){let i,o,n;return e=null!=(i=e.getRootWorkspace())?i:e,null!=(n=null==(o=l(Pr.PASTER,t.paster,!1))?void 0:o.paste(t,e,s))?n:null},Ms=function(t){return st("Blockly.clipboard.duplicate","v11","v12","Blockly.clipboard.paste(myCopyable.toCopyData(), myWorkspace)"),Xc.duplicateInternal(t)},Ds=function(t){const e=t.toCopyData();return e?ws(e,t.workspace):null},xs=function(t,e){t.setAttribute(Jc,e)},Bs=function(t,e,s){Array.isArray(s)&&(s=s.join(" ")),t.setAttribute(jc+e,`${s}`)},Ps=function(){return Zc},Fs=function(t){if(Zc=t,null===t){let t;null==(t=document.querySelector("."+ih))||t.remove()}},Us=function(){document.querySelector("."+ih)||((Zc=document.createElement("div")).className=ih,(E()||document.body).appendChild(Zc))},Hs=function(t,e,s){Gs(),eh=t,sh=s,(t=Zc)&&(t.style.direction=e?"rtl":"ltr",t.style.display="block",e=g(),oh=e.getRenderer().getClassName(),nh=e.getTheme().getClassName(),oh&&ot(t,oh),nh&&ot(t,nh))},Gs=function(){if(Vs()){eh=null;var t=Zc;t&&(t.style.display="none",t.style.left="",t.style.top="",sh&&sh(),sh=null,t.textContent="",oh&&(rt(t,oh),oh=""),nh&&(rt(t,nh),nh=""),g().markFocused())}},Vs=function(){return!!eh},Ws=function(t){eh===t&&Gs()},Xs=function(t,e,s){Zc.style.left=t+"px",Zc.style.top=e+"px",Zc.style.height=s+"px"},Ys=function(t,e,s,i){const o=zs(t,e,s);t=Ks(t,e,s,i),0>o?Xs(t,0,s.height+o):Xs(t,o,s.height)},Ks=function(t,e,s,i){return i?Math.min(Math.max(e.right-s.width,t.left),t.right-s.width):Math.max(Math.min(e.left,t.right-s.width),t.left)},zs=function(t,e,s){return e.bottom+s.height>=t.bottom?e.top-s.height:e.bottom},js=function(t){return!(null==t||!t.repositionForWindowResize)},Js=function(){js(eh)&&eh.repositionForWindowResize()||Gs()},qs=function(){return lh},Zs=function(t){lh=t},Qs=function(t,e,s){if(Hs(ah,s,ni),e.length){var i=ti(e,s);ch=i,ei(i,t,s),setTimeout((function(){i.focus()}),1),lh=null}else oi()},ti=function(t,e){const s=new Qc;s.setRole(Kc.MENU);for(let i=0;i{setTimeout((()=>{o.callback(o.scope)}),0)}))}),{})}return s},ei=function(t,e,s){const i=At();e=new fa(e.clientY+i.top,e.clientY+i.top,e.clientX+i.left,e.clientX+i.left),si(t);const o=t.getSize();s&&(e.left+=o.width,e.right+=o.width,i.left+=o.width,i.right+=o.width),Ys(i,e,o,s),t.focus()},si=function(t){var e=Ps();if(!e)throw Error("Attempting to create a context menu when widget div is null");e=t.render(e),ot(e,"blocklyContextMenu"),Y(e,"contextmenu",null,ii),t.focus()},ii=function(t){t.preventDefault(),t.stopPropagation()},oi=function(){Ws(ah),lh=null},ni=function(){ch&&(ch.dispose(),ch=null)},Nr.callbackFactory$$module$build$src$core$contextmenu=function(t,e){return()=>{let s;Nr.disable$$module$build$src$core$events$utils();try{s=e instanceof Element?Ge(e,t.workspace):_s(e,t.workspace);const i=t.getRelativeToSurfaceXY();i.x=t.RTL?i.x-Nr.config$$module$build$src$core$config.snapRadius:i.x+Nr.config$$module$build$src$core$config.snapRadius,i.y+=2*Nr.config$$module$build$src$core$config.snapRadius,s.moveBy(i.x,i.y)}finally{Nr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&A(new(P(Nr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}},ri=function(t){return{text:Nr.Msg$$module$build$src$core$msg.REMOVE_COMMENT,enabled:!0,callback:function(){Nr.setGroup$$module$build$src$core$events$utils(!0),t.dispose(),Nr.setGroup$$module$build$src$core$events$utils(!1)}}},li=function(t){return{text:Nr.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,enabled:!0,callback:function(){const e=t.toCopyData();e&&ws(e,t.workspace)}}},ai=function(t,e){const s={enabled:!0};return s.text=Nr.Msg$$module$build$src$core$msg.ADD_COMMENT,s.callback=function(){const s=new _c(t,Nr.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT,_c.DEFAULT_SIZE,_c.DEFAULT_SIZE);var i=t.getInjectionDiv().getBoundingClientRect();i=new ca(e.clientX-i.left,e.clientY-i.top);const o=t.getOriginOffsetInPixels();(i=ca.difference(i,o)).scale(1/t.scale),s.moveBy(i.x,i.y),t.rendered&&(s.initSvg(),s.render(),s.select())},s},ci=function(t){return t*Math.PI/180},hi=function(t){return 180*t/Math.PI},ui=function(t,e,s){if(ss)){var i=e.getSvgXY(t.getSvgRoot());t.outputConnection?(i.x+=(t.RTL?3:-3)*s,i.y+=13*s):t.previousConnection&&(i.x+=(t.RTL?-23:23)*s,i.y+=3*s);var o=it(ba.CIRCLE,{cx:i.x,cy:i.y,r:0,fill:"none",stroke:"#888","stroke-width":10},e.getParentSvg());t=it(ba.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*s},o),e=it(ba.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},o),t.beginElement(),e.beginElement(),setTimeout((()=>{at(o)}),150)}},Bi=function(t){if(Fi(),t.workspace.getAudioManager().play("disconnect"),!(1>t.workspace.scale)){var e=t.getHeightWidth().height;e=Math.atan(10/e)/Math.PI*180,t.RTL||(e*=-1),Nh=t,Pi(t,e,new Date)}},Pi=function(t,e,s){const i=((new Date).getTime()-s.getTime())/200;let o="";1>=i&&(o=`skewX(${Math.round(Math.sin(i*Math.PI*3)*(1-i)*e)})`,wh=setTimeout(Pi,10,t,e,s)),t.getSvgRoot().setAttribute("transform",`${t.getTranslation()} ${o}`)},Fi=function(){Nh&&(wh&&(clearTimeout(wh),wh=null),Nh.getSvgRoot().setAttribute("transform",Nh.getTranslation()),Nh=null)},Ui=function(t,e){return st("Blockly.utils.string.startsWith()","April 2022","April 2023","Use built-in string.startsWith"),t.startsWith(e)},Hi=function(t){return t.length?t.reduce((function(t,e){return t.lengthe&&(e=s[i].length);var o=-1/0;let n,r=1;do{i=o,n=t,t=[],o=s.length/r;let l=1;for(let e=0;ei);return n},Xi=function(t,e,s){const i=[0],o=[];for(var n=0;no&&(o=l,i=r)}return i?Yi(t,i,s):e},Ki=function(t,e){const s=[];for(let i=0;iZh&&lo()}else jh!==zh&&(clearTimeout(Xh),Yh=t.pageX,Kh=t.pageY,Xh=setTimeout(go,Qh))},ro=function(){jh=zh=null,lo()},lo=function(){Hh&&(Hh=!1,eu&&(eu.style.display="none")),Xh&&(clearTimeout(Xh),Xh=0)},ao=function(){lo(),Gh=!0},co=function(){Gh=!1},ho=function(){eu&&zh&&("function"==typeof Uh?Uh(eu,zh):uo())},uo=function(){var t=Zi(zh);t=(t=Nr.wrap$$module$build$src$core$utils$string(t,Vh)).split("\n");for(let e=0;es+window.scrollY&&(o-=eu.offsetHeight+2*qh),t?i=Math.max(tu-window.scrollX,i):i+eu.offsetWidth>e+window.scrollX-2*tu&&(i=e-eu.offsetWidth-2*tu),{x:i,y:o}},go=function(){if(!Gh&&(jh=zh,eu)){eu.textContent="",ho();var t=zh.RTL;eu.style.direction=t?"rtl":"ltr",eu.style.display="block",Hh=!0;var{x:e,y:s}=po(t);eu.style.left=e+"px",eu.style.top=s+"px"}},_o=function(t,e){for(const s in e)t[s]=null!==e[s]&&"object"==typeof e[s]?_o(t[s]||Object.create(null),e[s]):e[s];return t},To=function(t){return void 0!==t.bubbleIsVisible&&void 0!==t.setBubbleVisible},mo=function(){return du},Eo=function(t){du=t},bo=function(){return pu},fo=function(t){pu=t},$o=function(t){t=`${t}`.toLowerCase().trim();var e=gu[t];if(e)return e;if(e="#"===(e="0x"===t.substring(0,2)?"#"+t.substring(2):t)[0]?e:"#"+e,/^#[0-9a-f]{6}$/.test(e))return e;if(/^#[0-9a-f]{3}$/.test(e))return["#",e[1],e[1],e[2],e[2],e[3],e[3]].join("");var s=t.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return s&&(t=Number(s[1]),e=Number(s[2]),s=Number(s[3]),0<=t&&256>t&&0<=e&&256>e&&0<=s&&256>s)?Io(t,e,s):null},Io=function(t,e,s){return e=t<<16|e<<8|s,16>t?"#"+(16777216|e).toString(16).substr(1):"#"+e.toString(16)},So=function(t){return(t=$o(t))?[(t=parseInt(t.substr(1),16))>>16,t>>8&255,255&t]:[0,0,0]},Ro=function(t,e,s){let i=0,o=0,n=0;if(0===e)n=o=i=s;else{const r=Math.floor(t/60),l=t/60-r;t=s*(1-e);const a=s*(1-e*l);switch(e=s*(1-e*(1-l)),r){case 1:i=a,o=s,n=t;break;case 2:i=t,o=s,n=e;break;case 3:i=t,o=a,n=s;break;case 4:i=e,o=t,n=s;break;case 5:i=s,o=t,n=a;break;case 6:case 0:i=s,o=e,n=t}}return Io(Math.floor(i),Math.floor(o),Math.floor(n))},Co=function(t,e,s){return(t=$o(t))&&(e=$o(e))?(t=So(t),e=So(e),Io(Math.round(e[0]+s*(t[0]-e[0])),Math.round(e[1]+s*(t[1]-e[1])),Math.round(e[2]+s*(t[2]-e[2])))):null},ko=function(t){return Ro(t,du,255*pu)},Oo=function(t,e,s){const i=[];var o=t.split("");o.push("");var n=0;t=[];let r=null;for(let c=0;c=l?(n=2,r=l,(l=t.join(""))&&i.push(l),t.length=0):"{"===l?n=3:(t.push("%",l),n=0);else if(2===n)if("0"<=l&&"9">=l)r+=l;else{var a=void 0;i.push(parseInt(null!=(a=r)?a:"",10)),c--,n=0}else 3===n&&(""===l?(t.splice(0,0,"%{"),c--,n=0):"}"!==l?t.push(l):(n=t.join(""),/[A-Z]\w*/i.test(n)&&(l=(l=n.toUpperCase()).startsWith("BKY_")?l.substring(4):null)&&l in Nr.Msg$$module$build$src$core$msg?"string"==typeof(n=Nr.Msg$$module$build$src$core$msg[l])?Array.prototype.push.apply(i,Oo(n,e,s)):e?i.push(`${n}`):i.push(n):i.push("%{"+n+"}"),n=t.length=0))}for((e=t.join(""))&&i.push(e),a=[],t.length=0,o=0;o=s)return{hue:s,hex:Ro(s,mo(),255*bo())};if(s=$o(e))return{hue:null,hex:s};throw s='Invalid colour: "'+e+'"',t!==e&&(s+=' (from "'+t+'")'),Error(s)},wo=function(t){return void 0!==t.getProcedureModel&&void 0!==t.doProcedureUpdate&&void 0!==t.isProcedureDef},No=function(t){return void 0!==t.startPublishing&&void 0!==t.stopPublishing},Mo=function(e,s){t(Pr.FIELD,e,s)},Do=function(t){i(Pr.FIELD,t)},Nr.fromJson$$module$build$src$core$field_registry=function(t){return Iu.fromJsonInternal(t)},xo=function(t){const e=l(Pr.FIELD,t.type);if(e){if("function"!=typeof e.fromJson)throw new TypeError("returned Field was not a IRegistrableField");return e.fromJson(t)}return console.warn("Blockly could not create a field of type "+t.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},Bo=function(t){let e=!1;const s=t.map((([t,s])=>"string"==typeof t?[Ao(t),s]:(e=!0,[null!==t.alt?Object.assign({},t,{alt:Ao(t.alt)}):Object.assign({},t),s])));if(e||2>t.length)return{options:s};var i=s.map((([t])=>t)),o=Hi(i);t=Gi(i,o);const n=Vi(i,o);return!t&&!n||o<=t+n?{options:s}:(o=t?i[0].substring(0,t-1):void 0,i=n?i[0].substr(1-n):void 0,{options:Po(s,t,n),prefix:o,suffix:i})},Po=function(t,e,s){return t.map((([t,i])=>[t.substring(e,t.length-s),i]))},Fo=function(t){if(!Array.isArray(t))throw TypeError("FieldDropdown options must be an array.");if(!t.length)throw TypeError("FieldDropdown options must not be an empty array.");let e=!1;for(let s=0;s!t.getReturnTypes())).map((t=>[t.getName(),t.getParameters().map((t=>t.getName())),!1]));t.getBlocksByType("procedures_defnoreturn",!1).forEach((t=>{!wo(t)&&ie(t)&&e.push(t.getProcedureDef())}));const s=t.getProcedureMap().getProcedures().filter((t=>!!t.getReturnTypes())).map((t=>[t.getName(),t.getParameters().map((t=>t.getName())),!0]));return t.getBlocksByType("procedures_defreturn",!1).forEach((t=>{!wo(t)&&ie(t)&&s.push(t.getProcedureDef())})),e.sort(dn),s.sort(dn),[e,s]},dn=function(t,e){return t[0].localeCompare(e[0],void 0,{sensitivity:"base"})},Nr.findLegalName$$module$build$src$core$procedures=function(t,e){if(e.isInFlyout)return t;for(t=t||Nr.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed";!pn(t,e.workspace,e);){const e=t.match(/^(.*?)(\d+)$/);t=e?e[1]+(parseInt(e[2])+1):t+"2"}return t},pn=function(t,e,s){return!gn(t,e,s)},gn=function(t,e,s){for(const i of e.getAllBlocks(!1))if(i!==s&&ie(i)&&Nr.Names$$module$build$src$core$names.equals(i.getProcedureDef()[0],t))return!0;s=s&&wo(s)?null==s?void 0:s.getProcedureModel():void 0;for(const i of e.getProcedureMap().getProcedures())if(i!==s&&Nr.Names$$module$build$src$core$names.equals(i.getName(),t))return!0;return!1},Nr.rename$$module$build$src$core$procedures=function(t){var e=this.getSourceBlock();if(!e)throw new Eu;t=t.trim();const s=Nr.findLegalName$$module$build$src$core$procedures(t,e);wo(e)&&!e.isInsertionMarker()&&e.getProcedureModel().setName(s);const i=this.getValue();if(i!==t&&i!==s)for(t=e.workspace.getAllBlocks(!1),e=0;efn(e,t)||oe(e)&&Nr.Names$$module$build$src$core$names.equals(e.getProcedureCall(),t)))},fn=function(t,e){return wo(t)&&!t.isProcedureDef()&&t.getProcedureModel()&&Nr.Names$$module$build$src$core$names.equals(t.getProcedureModel().getName(),e)},Nr.mutateCallers$$module$build$src$core$procedures=function(t){const e=y();var s=t.getProcedureDef()[0];const i=t.mutationToDom(!0);t=bn(s,t.workspace);for(let n,r=0;n=t[r];r++){s=(s=n.mutationToDom())&&Mt(s),n.domToMutation&&n.domToMutation(i);var o=n.mutationToDom();s!==(o=o&&Mt(o))&&(O(!1),A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(n,"mutation",null,s,o)),O(e))}},Nr.getDefinition$$module$build$src$core$procedures=function(t,e){for(const s of e.getAllBlocks(!1))if(wo(s)&&s.isProcedureDef()&&Nr.Names$$module$build$src$core$names.equals(s.getProcedureModel().getName(),t)||ie(s)&&Nr.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],t))return s;return null},$n=function(t){return t.isDynamic},In=function(t){let e=t.outputConnection;return(!e||t.previousConnection&&t.previousConnection.isConnected())&&(e=t.previousConnection),e},Sn=function(t,e){if(!t||!e)throw Error("Cannot connect null connections.");t.targetConnection=e,e.targetConnection=t},Rn=function(t,e){let s=null;const i=null==(e=e.outputConnection)?void 0:e.getConnectionChecker();for(let o,n=0;o=t.inputList[n];n++){const t=o.connection;let n;if(t&&null!=(n=i)&&n.canConnect(e,t,!1)){if(s)return null;s=t}}return s},Cn=function(t,e){let s;for(;s=Rn(t,e);)if(!(t=s.targetBlock())||t.isShadow())return s;return null},kn=function(e,s){t(Pr.RENDERER,e,s)},On=function(t){i(Pr.RENDERER,t)},yn=function(t,e,s){return(t=new(r(Pr.RENDERER,t))(t)).init(e,s),t},An=function(t){he(t.getTargetWorkspace(),void 0,"String")},vn=function(t){he(t.getTargetWorkspace(),void 0,"Number")},Ln=function(t){he(t.getTargetWorkspace(),void 0,"Colour")},wn=function(t){let e=[],s=document.createElement("button");return s.setAttribute("text",Nr.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE),s.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),e.push(s),s=document.createElement("button"),s.setAttribute("text",Nr.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE),s.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),e.push(s),s=document.createElement("button"),s.setAttribute("text",Nr.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE),s.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),e.push(s),t.registerButtonCallback("CREATE_VARIABLE_STRING",An),t.registerButtonCallback("CREATE_VARIABLE_NUMBER",vn),t.registerButtonCallback("CREATE_VARIABLE_COLOUR",Ln),t=Nn(t),e.concat(t)},Nn=function(t){const e=[];if(0<(t=t.getAllVariables()).length){if(Gr.variables_set_dynamic){var s=t[t.length-1];const i=Nr.createElement$$module$build$src$core$utils$xml("block");i.setAttribute("type","variables_set_dynamic"),i.setAttribute("gap","24"),i.appendChild(me(s)),e.push(i)}if(Gr.variables_get_dynamic){t.sort(rc.compareByName);for(let i,o=0;i=t[o];o++)(s=Nr.createElement$$module$build$src$core$utils$xml("block")).setAttribute("type","variables_get_dynamic"),s.setAttribute("gap","8"),s.appendChild(me(i)),e.push(s)}}return e},Mn=function(t){t.resizeContents()},Dn=function(t){return void 0!==t.toCopyData},xn=function(){Sp.registry.register({name:np.ESCAPE,preconditionFn:t=>!t.options.readOnly,callback:t=>(t.hideChaff(),!0),keyCodes:[Lu.ESC]})},Bn=function(){Sp.registry.register({name:np.DELETE,preconditionFn(t){const e=T();return!t.options.readOnly&&null!=e&&e.isDeletable()},callback:(t,e)=>(e.preventDefault(),!ou.inProgress()&&(T().checkAndDelete(),!0)),keyCodes:[Lu.DELETE,Lu.BACKSPACE]})},Pn=function(){const t=Sp.registry.createSerializedKey(Lu.C,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.C,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.C,[Lu.META]);Sp.registry.register({name:np.COPY,preconditionFn(t){const e=T();return!t.options.readOnly&&!ou.inProgress()&&null!=e&&e.isDeletable()&&e.isMovable()&&Dn(e)},callback:(t,e)=>(e.preventDefault(),t.hideChaff(),!(!(e=T())||!Dn(e)||(Rp=e.toCopyData(),Cp=t,!Rp))),keyCodes:[t,e,s]})},Fn=function(){const t=Sp.registry.createSerializedKey(Lu.X,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.X,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.X,[Lu.META]);Sp.registry.register({name:np.CUT,preconditionFn(t){const e=T();return!t.options.readOnly&&!ou.inProgress()&&null!=e&&e instanceof op&&e.isDeletable()&&e.isMovable()&&!e.workspace.isFlyout},callback(t){const e=T();return!(!e||!Dn(e)||(Rp=e.toCopyData(),Cp=t,e.checkAndDelete(),0))},keyCodes:[t,e,s]})},Un=function(){const t=Sp.registry.createSerializedKey(Lu.V,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.V,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.V,[Lu.META]);Sp.registry.register({name:np.PASTE,preconditionFn:t=>!t.options.readOnly&&!ou.inProgress(),callback:()=>!(!Rp||!Cp||!ws(Rp,Cp)),keyCodes:[t,e,s]})},Hn=function(){const t=Sp.registry.createSerializedKey(Lu.Z,[Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.Z,[Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.Z,[Lu.META]);Sp.registry.register({name:np.UNDO,preconditionFn:t=>!t.options.readOnly&&!ou.inProgress(),callback:t=>(t.hideChaff(),t.undo(!1),!0),keyCodes:[t,e,s]})},Gn=function(){const t=Sp.registry.createSerializedKey(Lu.Z,[Lu.SHIFT,Lu.CTRL]),e=Sp.registry.createSerializedKey(Lu.Z,[Lu.SHIFT,Lu.ALT]),s=Sp.registry.createSerializedKey(Lu.Z,[Lu.SHIFT,Lu.META]),i=Sp.registry.createSerializedKey(Lu.Y,[Lu.CTRL]);Sp.registry.register({name:np.REDO,preconditionFn:t=>!ou.inProgress()&&!t.options.readOnly,callback:t=>(t.hideChaff(),t.undo(!0),!0),keyCodes:[t,e,s,i]})},Vn=function(){xn(),Bn(),Pn(),Fn(),Un(),Hn(),Gn()},Wn=function(t){const e={id:t.getId(),name:t.getName(),returnTypes:t.getReturnTypes()};return t.getParameters().length?(e.parameters=t.getParameters().map((t=>Xn(t))),e):e},Xn=function(t){const e={id:t.getId(),name:t.getName()};return t.getTypes().length?(e.types=t.getTypes(),e):e},Yn=function(t,e,s,i){if(t=new t(i,s.name,s.id).setReturnTypes(s.returnTypes),!s.parameters)return t;for(const[o,n]of s.parameters.entries())t.insertParameter(Kn(e,n,i),o);return t},Kn=function(t,e,s){return t=new t(s,e.name,e.id),e.types&&t.setTypes(e.types),t},zn=function(t){const e=Object.create(null),s=a(Pr.SERIALIZER,!0);for(const i in s){let o;const n=null==(o=s[i])?void 0:o.save(t);n&&(e[i]=n)}return e},jn=function(t,e,{recordUndo:s=!1}={}){var i=a(Pr.SERIALIZER,!0);if(i){i=Object.entries(i).sort(((t,e)=>e[1].priority-t[1].priority));var o=y();O(s),(s=Nr.getGroup$$module$build$src$core$events$utils())||Nr.setGroup$$module$build$src$core$events$utils(!0),dt(),e instanceof Yd&&e.setResizesEnabled(!1);for(const[,t]of i.reverse()){let s;null==(s=t)||s.clear(e)}for(let[s,o]of i.reverse())if(t[s]){let i;null==(i=o)||i.load(t[s],e)}e instanceof Yd&&e.setResizesEnabled(!0),pt(),A(new(P(_l))(e)),Nr.setGroup$$module$build$src$core$events$utils(s),O(o)}},Jn=function(t,e,s){const i=s.getBoundingRectangle(),o=i.right-i.left,n=ui(e.top,i.top,e.top+e.height-(i.bottom-i.top))-i.top;let r=e.left;return e=e.left+e.width-o,t.RTL?r=Math.min(e,r):e=Math.max(r,e),!(!(t=ui(r,i.left,e)-i.left)&&!n||(s.moveBy(t,n,["inbounds"]),0))},qn=function(t){return e=>{var s,i=t.getMetricsManager();if(i.hasFixedEdges()&&!t.isDragging())if(-1!==Tl.indexOf(null!=(s=e.type)?s:"")){s=i.getScrollMetrics(!0);const o=Zn(t,e);o&&(i=Nr.getGroup$$module$build$src$core$events$utils()||!1,Nr.setGroup$$module$build$src$core$events$utils(e.group),Jn(t,s,o)&&!e.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),Nr.setGroup$$module$build$src$core$events$utils(i))}else e.type===hl&&e.scale&&e.oldScale&&e.scale>e.oldScale&&Qn(t)}},Zn=function(t,e){let s=null;switch(e.type){case Nr.CREATE$$module$build$src$core$events$utils:case Nr.MOVE$$module$build$src$core$events$utils:(s=t.getBlockById(e.blockId))&&(s=s.getRootBlock());break;case ul:case gl:s=t.getCommentById(e.commentId)}return s},Qn=function(t){var e=t.getMetricsManager();if(e.hasFixedEdges()&&!t.isDragging()){e=e.getScrollMetrics(!0);var s=t.getTopBoundedElements();for(let i,o=0;i=s[o];o++)Jn(t,e,i)}},tr=function(t,e){const s=[];for(const i of t.getIcons())To(i)&&!i.bubbleIsVisible()||(s.push({location:e,icon:i}),i.onLocationChange(e));for(const i of t.getChildren(!1))s.push(...tr(i,ca.sum(e,i.relativeCoords)));return s},er=function(){uh.registry.register({displayText:()=>Nr.Msg$$module$build$src$core$msg.UNDO,preconditionFn:t=>0Nr.Msg$$module$build$src$core$msg.REDO,preconditionFn:t=>0Nr.Msg$$module$build$src$core$msg.CLEAN_UP,preconditionFn:t=>t.workspace.isMovable()?1Nr.Msg$$module$build$src$core$msg.COLLAPSE_ALL,preconditionFn(t){if(t.workspace.options.collapse){t=t.workspace.getTopBlocks(!1);for(let e=0;eNr.Msg$$module$build$src$core$msg.EXPAND_ALL,preconditionFn(t){if(t.workspace.options.collapse){t=t.workspace.getTopBlocks(!1);for(let e=0;et.workspace?1===(t=ar(t.workspace).length)?Nr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Nr.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${t}`):"",preconditionFn:t=>t.workspace&&0e.length?cr(e):qt(Nr.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(e.length)),(function(t){t&&cr(e)}))}},scopeType:uh.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},ur=function(){er(),sr(),ir(),nr(),rr(),hr()},dr=function(){uh.registry.register({displayText:()=>Nr.Msg$$module$build$src$core$msg.DUPLICATE_BLOCK,preconditionFn:t=>!(t=t.block).isInFlyout&&t.isDeletable()&&t.isMovable()?t.isDuplicatable()?"enabled":"disabled":"hidden",callback(t){if(t.block){var e=t.block.toCopyData();e&&ws(e,t.block.workspace)}},scopeType:uh.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},pr=function(){uh.registry.register({displayText:t=>t.block.hasIcon(Pu.TYPE)?Nr.Msg$$module$build$src$core$msg.REMOVE_COMMENT:Nr.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:t=>!(t=t.block).isInFlyout&&t.workspace.options.comments&&!t.isCollapsed()&&t.isEditable()?"enabled":"hidden",callback(t){(t=t.block).hasIcon(Pu.TYPE)?t.setCommentText(null):t.setCommentText("")},scopeType:uh.ScopeType.BLOCK,id:"blockComment",weight:2})},gr=function(){uh.registry.register({displayText:t=>t.block.getInputsInline()?Nr.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:Nr.Msg$$module$build$src$core$msg.INLINE_INPUTS,preconditionFn(t){if(!(t=t.block).isInFlyout&&t.isMovable()&&!t.isCollapsed())for(let e=1;et.block.isCollapsed()?Nr.Msg$$module$build$src$core$msg.EXPAND_BLOCK:Nr.Msg$$module$build$src$core$msg.COLLAPSE_BLOCK,preconditionFn:t=>!(t=t.block).isInFlyout&&t.isMovable()&&t.workspace.options.collapse?"enabled":"hidden",callback(t){t.block.setCollapsed(!t.block.isCollapsed())},scopeType:uh.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Tr=function(){uh.registry.register({displayText:t=>t.block.isEnabled()?Nr.Msg$$module$build$src$core$msg.DISABLE_BLOCK:Nr.Msg$$module$build$src$core$msg.ENABLE_BLOCK,preconditionFn:t=>!(t=t.block).isInFlyout&&t.workspace.options.disable&&t.isEditable()?t.getInheritedDisabled()?"disabled":"enabled":"hidden",callback(t){t=t.block;const e=Nr.getGroup$$module$build$src$core$events$utils();e||Nr.setGroup$$module$build$src$core$events$utils(!0),t.setEnabled(!t.isEnabled()),Nr.setGroup$$module$build$src$core$events$utils(e)},scopeType:uh.ScopeType.BLOCK,id:"blockDisable",weight:5})},mr=function(){uh.registry.register({displayText(t){var e=t.block;return t=e.getDescendants(!1).length,(e=e.getNextBlock())&&(t-=e.getDescendants(!1).length),1===t?Nr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Nr.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${t}`)},preconditionFn:t=>!t.block.isInFlyout&&t.block.isDeletable()?"enabled":"hidden",callback(t){t.block&&t.block.checkAndDelete()},scopeType:uh.ScopeType.BLOCK,id:"blockDelete",weight:6})},Er=function(){uh.registry.register({displayText:()=>Nr.Msg$$module$build$src$core$msg.HELP,preconditionFn:t=>("function"==typeof(t=t.block).helpUrl?t.helpUrl():t.helpUrl)?"enabled":"hidden",callback(t){t.block.showHelp()},scopeType:uh.ScopeType.BLOCK,id:"blockHelp",weight:7})},br=function(){dr(),pr(),gr(),_r(),Tr(),mr(),Er()},fr=function(){ur(),br()},$r=function(t,e){var s=null;let i;if(s="string"==typeof t?document.getElementById(t)||document.querySelector(t):t,!document.contains(s)&&document!==(null==(i=s)?void 0:i.ownerDocument))throw Error("Error: container is not in current document");t=new hu(e||{}),(e=document.createElement("div")).className="injectionDiv",e.tabIndex=0,Bs(e,zc.LABEL,Nr.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),s.appendChild(e),s=Ir(e,t);const o=Sr(e,s,t);return Rr(o),_(o),f(o),e.addEventListener("focusin",(function(){_(o)})),o},Ir=function(t,e){t.setAttribute("dir","LTR"),et(e.hasCss,e.pathToMedia),t=it(ba.SVG,{xmlns:da,"xmlns:html":pa,"xmlns:xlink":ga,version:"1.1",class:"blocklySvg",tabindex:"0"},t);const s=it(ba.DEFS,{},t),i=String(Math.random()).substring(2);return e.gridPattern=nu.createDom(i,e.gridOptions,s),t},Sr=function(t,e,s){s.parentWorkspace=null;const i=(s=new Yd(s)).options;s.scale=i.zoomOptions.startScale,e.appendChild(s.createDom("blocklyMainBackground",t));var o=s.getRenderer().getClassName();return o&&ot(t,o),(o=s.getTheme().getClassName())&&ot(t,o),!i.hasCategories&&i.languageTree&&(t=s.addFlyout(ba.SVG),ct(t,e)),i.hasTrashcan&&s.addTrashcan(),i.zoomOptions&&i.zoomOptions.controls&&s.addZoomControls(),s.getThemeManager().subscribe(e,"workspaceBackgroundColour","background-color"),s.translate(0,0),s.addChangeListener(qn(s)),f(s),Us(),di(),to(),s},Rr=function(t){const e=t.options;var s=t.getParentSvg();if(Y(s.parentNode,"contextmenu",null,(function(t){j(t)||t.preventDefault()})),s=Y(window,"resize",null,(function(){lo(),t.hideComponents(!0),Ni(),Js(),f(t),Qn(t)})),t.setResizeHandlerWrapper(s),kr(),e.languageTree){s=t.getToolbox();const i=t.getFlyout(!0);s?s.init():i&&(i.init(t),i.show(e.languageTree),"function"==typeof i.scrollToStart&&i.scrollToStart())}e.hasTrashcan&&t.trashcan.init(),e.zoomOptions&&e.zoomOptions.controls&&t.zoomControls_.init(),e.moveOptions&&e.moveOptions.scrollbars?(t.scrollbar=new wp(t,!0===e.moveOptions.scrollbars||!!e.moveOptions.scrollbars.horizontal,!0===e.moveOptions.scrollbars||!!e.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),t.scrollbar.resize()):t.setMetrics({x:.5,y:.5}),e.hasSounds&&Or(e.pathToMedia,t)},Cr=function(t){const e=g();e&&!(j(t)||e.rendered&&!e.isVisible())&&Sp.registry.onKeyDown(e,t)},kr=function(){Og||(Y(document,"scroll",null,(function(){const t=u();for(let e,s=0;e=t[s];s++)e instanceof Yd&&e.updateInverseScreenCTM()})),Y(document,"keydown",null,Cr),K(document,"touchend",null,H),K(document,"touchcancel",null,H),jl&&Y(window,"orientationchange",document,(function(){f(g())}))),Og=!0},Or=function(t,e){function s(){for(;o.length;){const t=o.pop();t&&z(t)}i.preload()}const i=e.getAudioManager();i.load([t+"click.mp3",t+"click.wav",t+"click.ogg"],"click"),i.load([t+"disconnect.wav",t+"disconnect.mp3",t+"disconnect.ogg"],"disconnect"),i.load([t+"delete.mp3",t+"delete.ogg",t+"delete.wav"],"delete");const o=[];o.push(Y(document,"pointermove",null,s,!0)),o.push(Y(document,"touchstart",null,s,!0))},yr=function(t){return void 0!==t.getType&&void 0!==t.initView&&void 0!==t.dispose&&void 0!==t.getWeight&&void 0!==t.getSize&&void 0!==t.applyColour&&void 0!==t.hideForInsertionMarker&&void 0!==t.updateEditable&&void 0!==t.updateCollapsed&&void 0!==t.isShownWhenCollapsed&&void 0!==t.setOffsetInBlock&&void 0!==t.onLocationChange&&void 0!==t.onClick},Ar=function(t){return void 0!==t.paste},vr=function(t){return t.isSelectable()},Lr=function(t){g().hideChaff(t)},(wr=wr||{}).scope={},wr.ASSUME_ES5=!1,wr.ASSUME_NO_NATIVE_MAP=!1,wr.ASSUME_NO_NATIVE_SET=!1,wr.SIMPLE_FROUND_POLYFILL=!1,wr.ISOLATE_POLYFILLS=!1,wr.FORCE_POLYFILL_PROMISE=!1,wr.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,wr.defineProperty=wr.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,s){return t==Array.prototype||t==Object.prototype||(t[e]=s.value),t},wr.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof s.g&&s.g];for(var e=0;e>>0,wr.propertyToPolyfillSymbol[o]=wr.IS_SYMBOL_NATIVE?wr.global.Symbol(o):wr.POLYFILL_PREFIX+s+"$"+o),wr.defineProperty(i,wr.propertyToPolyfillSymbol[o],{configurable:!0,writable:!0,value:e})))},wr.polyfill("globalThis",(function(t){return t||wr.global}),"es_2020","es3"),wr.arrayIteratorImpl=function(t){var e=0;return function(){return e{const t=[];for(let e=0;20>e;e++)t[e]=fl.charAt(88*Math.random());return t.join("")}},Il=0,Sl={TEST_ONLY:$l};Sl.genUid=k,Sl.getNextUniqueId=C,zr="",jr=!0,Jr=0,Nr.CREATE$$module$build$src$core$events$utils="create",Nr.CREATE$$module$build$src$core$events$utils,Nr.DELETE$$module$build$src$core$events$utils="delete",Nr.DELETE$$module$build$src$core$events$utils,Nr.CHANGE$$module$build$src$core$events$utils="change",Nr.CHANGE$$module$build$src$core$events$utils,qr="block_field_intermediate_change",Nr.MOVE$$module$build$src$core$events$utils="move",Nr.MOVE$$module$build$src$core$events$utils,Zr="var_create",Qr="var_delete",tl="var_rename",el="ui",sl="drag",il="selected",ol="click",nl="marker_move",rl="bubble_open",ll="trashcan_open",al="toolbox_item_select",cl="theme_change",hl="viewport_change",ul="comment_create",dl="comment_delete",pl="comment_change",gl="comment_move",_l="finished_loading",Tl=[Nr.CREATE$$module$build$src$core$events$utils,Nr.MOVE$$module$build$src$core$events$utils,ul,gl],El={FIRE_QUEUE:ml=[],fireNow:L,fireInternal:v,setGroupInternal:D},(bl={BLOCK_CHANGE:Nr.CHANGE$$module$build$src$core$events$utils,BLOCK_CREATE:Nr.CREATE$$module$build$src$core$events$utils,BLOCK_DELETE:Nr.DELETE$$module$build$src$core$events$utils,BLOCK_DRAG:sl,BLOCK_FIELD_INTERMEDIATE_CHANGE:qr,BLOCK_MOVE:Nr.MOVE$$module$build$src$core$events$utils,BUBBLE_OPEN:rl,BUMP_EVENTS:Tl,CHANGE:Nr.CHANGE$$module$build$src$core$events$utils,CLICK:ol,COMMENT_CHANGE:pl,COMMENT_CREATE:ul,COMMENT_DELETE:dl,COMMENT_MOVE:gl,CREATE:Nr.CREATE$$module$build$src$core$events$utils,DELETE:Nr.DELETE$$module$build$src$core$events$utils,FINISHED_LOADING:_l,MARKER_MOVE:nl,MOVE:Nr.MOVE$$module$build$src$core$events$utils,SELECTED:il,TEST_ONLY:El,THEME_CHANGE:cl,TOOLBOX_ITEM_SELECT:al,TRASHCAN_OPEN:ll,UI:el,VAR_CREATE:Zr,VAR_DELETE:Qr,VAR_RENAME:tl,VIEWPORT_CHANGE:hl}).clearPendingUndo=N,bl.disable=Nr.disable$$module$build$src$core$events$utils,bl.disableOrphans=F,bl.enable=Nr.enable$$module$build$src$core$events$utils,bl.filter=w,bl.fire=A,bl.fromJson=B,bl.get=P,bl.getDescendantIds=x,bl.getGroup=Nr.getGroup$$module$build$src$core$events$utils,bl.getRecordUndo=y,bl.isEnabled=M,bl.setGroup=Nr.setGroup$$module$build$src$core$events$utils,bl.setRecordUndo=O;var Rl,Cl,kl=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Nr.getGroup$$module$build$src$core$events$utils(),this.recordUndo=y()}toJson(){return{type:this.type,group:this.group}}static fromJson(t,e,s){return s.isBlank=!1,s.group=t.group||"",s.workspaceId=e.id,s}isNull(){return!1}run(t){}getEventWorkspace_(){let t;if(this.workspaceId&&(t=h(this.workspaceId)),!t)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return t}},Ol=class extends kl{constructor(t){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=void 0===t,this.workspaceId=t||""}},yl=class extends Ol{constructor(t,e,s){null===(e=t?t.workspace.id:e)&&(e=void 0),super(e),this.type=ol,this.blockId=t?t.id:void 0,this.targetType=s}toJson(){const t=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");return t.targetType=this.targetType,t.blockId=this.blockId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new yl)).targetType=t.targetType,e.blockId=t.blockId,e}};(Cl=Rl||(Rl={})).BLOCK="block",Cl.WORKSPACE="workspace",Cl.ZOOM_CONTROLS="zoom_controls",t(Pr.EVENT,ol,yl);var Al={};Al.Click=yl,Al.ClickTarget=Rl;var vl,Ll,wl,Nl,Ml,Dl,xl,Bl,Pl,Fl,Ul=750,Hl="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Gl=null,Vl={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Wl=0,Xl={TOUCH_ENABLED:Hl,TOUCH_MAP:Vl};Xl.checkTouchIdentifier=X,Xl.clearTouchIdentifier=G,Xl.getTouchIdentifierFromEvent=W,Xl.longStart=U,Xl.longStop=H,Xl.shouldHandleEvent=V,function(t){function e(t){return-1!==s.indexOf(t.toUpperCase())}const s=(vl=t).toUpperCase();Ll=e("JavaFX"),wl=e("WebKit"),Nl=e("Gecko")&&!wl,Ml=e("Android"),t=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Dl=e("iPad")||e("Macintosh")&&0{e.push(this.componentData.get(t))})),e.sort((function(t,e){return t.weight-e.weight})),e.forEach((function(t){s.push(t.component)}))}else t.forEach((t=>{s.push(this.componentData.get(t).component)}));return s}};na.Capability=oa;var ra=!1,la='\n.blocklySvg {\n background-color: #fff;\n outline: none;\n overflow: hidden; /* IE overflows by default. */\n position: absolute;\n display: block;\n}\n\n.blocklyWidgetDiv {\n display: none;\n position: absolute;\n z-index: 99999; /* big value for bootstrap3 compatibility */\n}\n\n.injectionDiv {\n height: 100%;\n position: relative;\n overflow: hidden; /* So blocks in drag surface disappear at edges */\n touch-action: none;\n}\n\n.blocklyNonSelectable {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.blocklyBlockCanvas.blocklyCanvasTransitioning,\n.blocklyBubbleCanvas.blocklyCanvasTransitioning {\n transition: transform .5s;\n}\n\n.blocklyTooltipDiv {\n background-color: #ffffc7;\n border: 1px solid #ddc;\n box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);\n color: #000;\n display: none;\n font: 9pt sans-serif;\n opacity: .9;\n padding: 2px;\n position: absolute;\n z-index: 100000; /* big value for bootstrap3 compatibility */\n}\n\n.blocklyDropDownDiv {\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1000;\n display: none;\n border: 1px solid;\n border-color: #dadce0;\n background-color: #fff;\n border-radius: 2px;\n padding: 4px;\n box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv.blocklyFocused {\n box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownContent {\n max-height: 300px; /* @todo: spec for maximum height. */\n overflow: auto;\n overflow-x: hidden;\n position: relative;\n}\n\n.blocklyDropDownArrow {\n position: absolute;\n left: 0;\n top: 0;\n width: 16px;\n height: 16px;\n z-index: -1;\n background-color: inherit;\n border-color: inherit;\n}\n\n.blocklyDropDownButton {\n display: inline-block;\n float: left;\n padding: 0;\n margin: 4px;\n border-radius: 4px;\n outline: none;\n border: 1px solid;\n transition: box-shadow .1s;\n cursor: pointer;\n}\n\n.blocklyArrowTop {\n border-top: 1px solid;\n border-left: 1px solid;\n border-top-left-radius: 4px;\n border-color: inherit;\n}\n\n.blocklyArrowBottom {\n border-bottom: 1px solid;\n border-right: 1px solid;\n border-bottom-right-radius: 4px;\n border-color: inherit;\n}\n\n.blocklyResizeSE {\n cursor: se-resize;\n fill: #aaa;\n}\n\n.blocklyResizeSW {\n cursor: sw-resize;\n fill: #aaa;\n}\n\n.blocklyResizeLine {\n stroke: #515A5A;\n stroke-width: 1;\n}\n\n.blocklyHighlightedConnectionPath {\n fill: none;\n stroke: #fc3;\n stroke-width: 4px;\n}\n\n.blocklyPathLight {\n fill: none;\n stroke-linecap: round;\n stroke-width: 1;\n}\n\n.blocklySelected>.blocklyPathLight {\n display: none;\n}\n\n.blocklyDraggable {\n cursor: grab;\n cursor: -webkit-grab;\n}\n\n.blocklyDragging {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n /* Changes cursor on mouse down. Not effective in Firefox because of\n https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */\n.blocklyDraggable:active {\n cursor: grabbing;\n cursor: -webkit-grabbing;\n}\n\n.blocklyDragging.blocklyDraggingDelete {\n cursor: url("<<>>/handdelete.cur"), auto;\n}\n\n.blocklyDragging>.blocklyPath,\n.blocklyDragging>.blocklyPathLight {\n fill-opacity: .8;\n stroke-opacity: .8;\n}\n\n.blocklyDragging>.blocklyPathDark {\n display: none;\n}\n\n.blocklyDisabled>.blocklyPath {\n fill-opacity: .5;\n stroke-opacity: .5;\n}\n\n.blocklyDisabled>.blocklyPathLight,\n.blocklyDisabled>.blocklyPathDark {\n display: none;\n}\n\n.blocklyInsertionMarker>.blocklyPath,\n.blocklyInsertionMarker>.blocklyPathLight,\n.blocklyInsertionMarker>.blocklyPathDark {\n fill-opacity: .2;\n stroke: none;\n}\n\n.blocklyMultilineText {\n font-family: monospace;\n}\n\n.blocklyNonEditableText>text {\n pointer-events: none;\n}\n\n.blocklyFlyout {\n position: absolute;\n z-index: 20;\n}\n\n.blocklyText text {\n cursor: default;\n}\n\n/*\n Don\'t allow users to select text. It gets annoying when trying to\n drag a block and selected text moves instead.\n*/\n.blocklySvg text {\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n cursor: inherit;\n}\n\n.blocklyHidden {\n display: none;\n}\n\n.blocklyFieldDropdown:not(.blocklyHidden) {\n display: block;\n}\n\n.blocklyIconGroup {\n cursor: default;\n}\n\n.blocklyIconGroup:not(:hover),\n.blocklyIconGroupReadonly {\n opacity: .6;\n}\n\n.blocklyIconShape {\n fill: #00f;\n stroke: #fff;\n stroke-width: 1px;\n}\n\n.blocklyIconSymbol {\n fill: #fff;\n}\n\n.blocklyMinimalBody {\n margin: 0;\n padding: 0;\n}\n\n.blocklyHtmlInput {\n border: none;\n border-radius: 4px;\n height: 100%;\n margin: 0;\n outline: none;\n padding: 0;\n width: 100%;\n text-align: center;\n display: block;\n box-sizing: border-box;\n}\n\n/* Remove the increase and decrease arrows on the field number editor */\ninput.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,\ninput.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\ninput[type=number] {\n -moz-appearance: textfield;\n}\n\n.blocklyMainBackground {\n stroke-width: 1;\n stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */\n}\n\n.blocklyMutatorBackground {\n fill: #fff;\n stroke: #ddd;\n stroke-width: 1;\n}\n\n.blocklyFlyoutBackground {\n fill: #ddd;\n fill-opacity: .8;\n}\n\n.blocklyMainWorkspaceScrollbar {\n z-index: 20;\n}\n\n.blocklyFlyoutScrollbar {\n z-index: 30;\n}\n\n.blocklyScrollbarHorizontal,\n.blocklyScrollbarVertical {\n position: absolute;\n outline: none;\n}\n\n.blocklyScrollbarBackground {\n opacity: 0;\n}\n\n.blocklyScrollbarHandle {\n fill: #ccc;\n}\n\n.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyScrollbarHandle:hover {\n fill: #bbb;\n}\n\n/* Darken flyout scrollbars due to being on a grey background. */\n/* By contrast, workspace scrollbars are on a white background. */\n.blocklyFlyout .blocklyScrollbarHandle {\n fill: #bbb;\n}\n\n.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,\n.blocklyFlyout .blocklyScrollbarHandle:hover {\n fill: #aaa;\n}\n\n.blocklyInvalidInput {\n background: #faa;\n}\n\n.blocklyVerticalMarker {\n stroke-width: 3px;\n fill: rgba(255,255,255,.5);\n pointer-events: none;\n}\n\n.blocklyComputeCanvas {\n position: absolute;\n width: 0;\n height: 0;\n}\n\n.blocklyNoPointerEvents {\n pointer-events: none;\n}\n\n.blocklyContextMenu {\n border-radius: 4px;\n max-height: 100%;\n}\n\n.blocklyDropdownMenu {\n border-radius: 2px;\n padding: 0 !important;\n}\n\n.blocklyDropdownMenu .blocklyMenuItem {\n /* 28px on the left for icon or checkbox. */\n padding-left: 28px;\n}\n\n/* BiDi override for the resting state. */\n.blocklyDropdownMenu .blocklyMenuItemRtl {\n /* Flip left/right padding for BiDi. */\n padding-left: 5px;\n padding-right: 28px;\n}\n\n.blocklyWidgetDiv .blocklyMenu {\n background: #fff;\n border: 1px solid transparent;\n box-shadow: 0 0 3px 1px rgba(0,0,0,.3);\n font: normal 13px Arial, sans-serif;\n margin: 0;\n outline: none;\n padding: 4px 0;\n position: absolute;\n overflow-y: auto;\n overflow-x: hidden;\n max-height: 100%;\n z-index: 20000; /* Arbitrary, but some apps depend on it... */\n}\n\n.blocklyWidgetDiv .blocklyMenu.blocklyFocused {\n box-shadow: 0 0 6px 1px rgba(0,0,0,.3);\n}\n\n.blocklyDropDownDiv .blocklyMenu {\n background: inherit; /* Compatibility with gapi, reset from goog-menu */\n border: inherit; /* Compatibility with gapi, reset from goog-menu */\n font: normal 13px "Helvetica Neue", Helvetica, sans-serif;\n outline: none;\n position: relative; /* Compatibility with gapi, reset from goog-menu */\n z-index: 20000; /* Arbitrary, but some apps depend on it... */\n}\n\n/* State: resting. */\n.blocklyMenuItem {\n border: none;\n color: #000;\n cursor: pointer;\n list-style: none;\n margin: 0;\n /* 7em on the right for shortcut. */\n min-width: 7em;\n padding: 6px 15px;\n white-space: nowrap;\n}\n\n/* State: disabled. */\n.blocklyMenuItemDisabled {\n color: #ccc;\n cursor: inherit;\n}\n\n/* State: hover. */\n.blocklyMenuItemHighlight {\n background-color: rgba(0,0,0,.1);\n}\n\n/* State: selected/checked. */\n.blocklyMenuItemCheckbox {\n height: 16px;\n position: absolute;\n width: 16px;\n}\n\n.blocklyMenuItemSelected .blocklyMenuItemCheckbox {\n background: url(<<>>/sprites.png) no-repeat -48px -16px;\n float: left;\n margin-left: -24px;\n position: static; /* Scroll with the menu. */\n}\n\n.blocklyMenuItemRtl .blocklyMenuItemCheckbox {\n float: right;\n margin-right: -24px;\n}\n\n.blocklyBlockDragSurface {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: visible !important;\n z-index: 80;\n pointer-events: none;\n}\n',aa={};aa.inject=et,aa.register=tt;var ca=class{constructor(t,e){this.x=t,this.y=e}clone(){return new ca(this.x,this.y)}scale(t){return this.x*=t,this.y*=t,this}translate(t,e){return this.x+=t,this.y+=e,this}static equals(t,e){return t===e||!(!t||!e)&&t.x===e.x&&t.y===e.y}static distance(t,e){const s=t.x-e.x;return t=t.y-e.y,Math.sqrt(s*s+t*t)}static magnitude(t){return Math.sqrt(t.x*t.x+t.y*t.y)}static difference(t,e){return new ca(t.x-e.x,t.y-e.y)}static sum(t,e){return new ca(t.x+e.x,t.y+e.y)}},ha={};ha.warn=st;var ua,da="http://www.w3.org/2000/svg",pa="http://www.w3.org/1999/xhtml",ga="http://www.w3.org/1999/xlink";!function(t){t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE"}(ua||(ua={}));var _a=null,Ta=0,ma=null,Ea={HTML_NS:pa};Ea.NodeType=ua,Ea.SVG_NS=da,Ea.XLINK_NS=ga,Ea.addClass=ot,Ea.containsNode=ht,Ea.createSvgElement=it,Ea.getFastTextWidth=_t,Ea.getFastTextWidthWithSizeString=Tt,Ea.getTextWidth=gt,Ea.hasClass=lt,Ea.insertAfter=ct,Ea.measureFontMetrics=mt,Ea.removeClass=rt,Ea.removeClasses=nt,Ea.removeNode=at,Ea.setCssTransform=ut,Ea.startTextWidthCache=dt,Ea.stopTextWidthCache=pt;var ba=class{constructor(t){this.tagName=t}toString(){return this.tagName}};ba.ANIMATE=new ba("animate"),ba.CIRCLE=new ba("circle"),ba.CLIPPATH=new ba("clipPath"),ba.DEFS=new ba("defs"),ba.FECOMPOSITE=new ba("feComposite"),ba.FECOMPONENTTRANSFER=new ba("feComponentTransfer"),ba.FEFLOOD=new ba("feFlood"),ba.FEFUNCA=new ba("feFuncA"),ba.FEGAUSSIANBLUR=new ba("feGaussianBlur"),ba.FEPOINTLIGHT=new ba("fePointLight"),ba.FESPECULARLIGHTING=new ba("feSpecularLighting"),ba.FILTER=new ba("filter"),ba.FOREIGNOBJECT=new ba("foreignObject"),ba.G=new ba("g"),ba.IMAGE=new ba("image"),ba.LINE=new ba("line"),ba.PATH=new ba("path"),ba.PATTERN=new ba("pattern"),ba.POLYGON=new ba("polygon"),ba.RECT=new ba("rect"),ba.SVG=new ba("svg"),ba.TEXT=new ba("text"),ba.TSPAN=new ba("tspan");var fa=class{constructor(t,e,s,i){this.top=t,this.bottom=e,this.left=s,this.right=i}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}contains(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom}intersects(t){return!(this.left>t.right||this.rightt.bottom||this.bottom=t||isNaN(t)?0:Math.min(t,this.scrollbarLength)}setHandleLength(t){this.handleLength=t,this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(t){return 0>=t||isNaN(t)?0:Math.min(t,this.scrollbarLength-this.handleLength)}setHandlePosition(t){this.handlePosition=t,this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(t){this.scrollbarLength=t,this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength)),this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(t,e){this.position.x=t,this.position.y=e,ut(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(t){(t||(t=this.workspace.getMetrics()))&&(this.oldHostMetrics&&Oa.metricsAreEquivalent(t,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(t):this.resizeVertical(t),this.oldHostMetrics=t,this.updateMetrics()))}requiresViewResize(t){return!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==t.viewWidth||this.oldHostMetrics.viewHeight!==t.viewHeight||this.oldHostMetrics.absoluteLeft!==t.absoluteLeft||this.oldHostMetrics.absoluteTop!==t.absoluteTop}resizeHorizontal(t){this.requiresViewResize(t)?this.resizeViewHorizontal(t):this.resizeContentHorizontal(t)}resizeViewHorizontal(t){var e=t.viewWidth-2*this.margin;this.pair&&(e-=Oa.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),e=t.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(e+=Oa.scrollbarThickness),this.setPosition(e,t.absoluteTop+t.viewHeight-Oa.scrollbarThickness-this.margin),this.resizeContentHorizontal(t)}resizeContentHorizontal(t){if(t.viewWidth>=t.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var e=this.scrollbarLength*t.viewWidth/t.scrollWidth;e=this.constrainHandleLength(e),this.setHandleLength(e),e=t.scrollWidth-t.viewWidth;var s=this.scrollbarLength-this.handleLength;t=(t.viewLeft-t.scrollLeft)/e*s,t=this.constrainHandlePosition(t),this.setHandlePosition(t),this.ratio=s/e}}resizeVertical(t){this.requiresViewResize(t)?this.resizeViewVertical(t):this.resizeContentVertical(t)}resizeViewVertical(t){let e=t.viewHeight-2*this.margin;this.pair&&(e-=Oa.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),this.setPosition(this.workspace.RTL?t.absoluteLeft+this.margin:t.absoluteLeft+t.viewWidth-Oa.scrollbarThickness-this.margin,t.absoluteTop+this.margin),this.resizeContentVertical(t)}resizeContentVertical(t){if(t.viewHeight>=t.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var e=this.scrollbarLength*t.viewHeight/t.scrollHeight;e=this.constrainHandleLength(e),this.setHandleLength(e),e=t.scrollHeight-t.viewHeight;var s=this.scrollbarLength-this.handleLength;t=(t.viewTop-t.scrollTop)/e*s,t=this.constrainHandlePosition(t),this.setHandlePosition(t),this.ratio=s/e}}isVisible(){return this.isHandleVisible}setContainerVisible(t){const e=t!==this.containerVisible;this.containerVisible=t,e&&this.updateDisplay_()}setVisible(t){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(t)}setVisibleInternal(t){const e=t!==this.isVisible();this.isHandleVisible=t,e&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(t){if(this.workspace.markFocused(),G(),this.cleanUp(),J(t))t.stopPropagation();else{var e=q(t,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());e=this.horizontal?e.x:e.y;var s=yt(this.svgHandle);s=this.horizontal?s.x:s.y;var i=this.handlePosition,o=.95*this.handleLength;e<=s?i-=o:e>=s+this.handleLength&&(i+=o),this.setHandlePosition(this.constrainHandlePosition(i)),this.updateMetrics(),t.stopPropagation(),t.preventDefault()}}onMouseDownHandle(t){this.workspace.markFocused(),this.cleanUp(),J(t)?t.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?t.clientX:t.clientY,this.onMouseUpWrapper_=Y(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=Y(document,"pointermove",this,this.onMouseMoveHandle),t.stopPropagation(),t.preventDefault())}onMouseMoveHandle(t){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?t.clientX:t.clientY)-this.startDragMouse))),this.updateMetrics()}onMouseUpHandle(){G(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(z(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(z(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){let t=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(t)&&(t=0),t}updateMetrics(){const t=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:t}):this.workspace.setMetrics({y:t})}set(t,e){this.setHandlePosition(this.constrainHandlePosition(t*this.ratio)),(e||void 0===e)&&this.updateMetrics()}setOrigin(t,e){this.origin=new ca(t,e)}static metricsAreEquivalent(t,e){return t.viewWidth===e.viewWidth&&t.viewHeight===e.viewHeight&&t.viewLeft===e.viewLeft&&t.viewTop===e.viewTop&&t.absoluteTop===e.absoluteTop&&t.absoluteLeft===e.absoluteLeft&&t.scrollWidth===e.scrollWidth&&t.scrollHeight===e.scrollHeight&&t.scrollLeft===e.scrollLeft&&t.scrollTop===e.scrollTop}};Oa.scrollbarThickness=Hl?25:15,Oa.DEFAULT_SCROLLBAR_MARGIN=.5;var ya={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},Aa={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:va,DOMParser:La,XMLSerializer:wa}=globalThis;La&&(ya=new La),wa&&(Aa=new wa);var Na="https://developers.google.com/blockly/xml",Ma=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,Da={NAME_SPACE:Na};Da.createElement=Nr.createElement$$module$build$src$core$utils$xml,Da.createTextNode=Nr.createTextNode$$module$build$src$core$utils$xml,Da.domToText=Mt,Da.injectDependencies=Nt,Da.textToDom=Nr.textToDom$$module$build$src$core$utils$xml;var xa,Ba="categoryToolbox",Pa="flyoutToolbox";!function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM",t[t.LEFT=2]="LEFT",t[t.RIGHT=3]="RIGHT"}(xa||(xa={}));var Fa,Ua,Ha,Ga={hasCategoriesInternal:Ut},Va={};Va.Position=xa,Va.TEST_ONLY=Ga,Va.convertFlyoutDefToJsonArray=Pt,Va.convertToolboxDefToJson=xt,Va.hasCategories=Ft,Va.isCategoryCollapsible=Ht,Va.parseToolboxTree=Xt,function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM"}(Fa||(Fa={})),function(t){t[t.LEFT=0]="LEFT",t[t.RIGHT=1]="RIGHT"}(Ua||(Ua={})),function(t){t[t.UP=0]="UP",t[t.DOWN=1]="DOWN"}(Ha||(Ha={}));var Wa={};Wa.bumpDirection=Ha,Wa.bumpPositionRect=zt,Wa.getCornerOppositeToolbox=Kt,Wa.getStartPositionRect=Yt,Wa.horizontalPosition=Ua,Wa.verticalPosition=Fa;var Xa=96,Ya=124,Ka="sprites.png",za=class{constructor(t){this.workspace=t,this.id="zoomControls",this.boundEvents=[],this.zoomResetGroup=this.zoomOutGroup=this.zoomInGroup=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=it(ba.G,{});const t=String(Math.random()).substring(2);return this.createZoomOutSvg(t),this.createZoomInSvg(t),this.workspace.isMovable()&&this.createZoomResetSvg(t),this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:2,capabilities:[na.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&at(this.svgGroup);for(const t of this.boundEvents)z(t);this.boundEvents.length=0}getBoundingRectangle(){let t=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(t+=this.LARGE_SPACING+this.HEIGHT),new fa(this.top,this.top+t,this.left,this.left+this.WIDTH)}position(t,e){if(this.initialized){var s,i=Kt(this.workspace,t),o=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(o+=this.LARGE_SPACING+this.HEIGHT),t=Yt(i,new $a(this.WIDTH,o),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,t,this.workspace),i=i.vertical,e=zt(t,this.MARGIN_VERTICAL,i===Fa.TOP?Ha.DOWN:Ha.UP,e),i===Fa.TOP){var n,r=this.SMALL_SPACING+this.HEIGHT;null==(n=this.zoomInGroup)||n.setAttribute("transform","translate(0, "+r+")"),this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(r+this.LARGE_SPACING+this.HEIGHT)+")")}else{let t;n=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0,null==(t=this.zoomInGroup)||t.setAttribute("transform","translate(0, "+n+")"),n=n+this.SMALL_SPACING+this.HEIGHT,null==(r=this.zoomOutGroup)||r.setAttribute("transform","translate(0, "+n+")")}this.top=e.top,this.left=e.left,null==(s=this.svgGroup)||s.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(t){this.zoomOutGroup=it(ba.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const e=it(ba.CLIPPATH,{id:"blocklyZoomoutClipPath"+t},this.zoomOutGroup);it(ba.RECT,{width:32,height:32},e),it(ba.IMAGE,{width:Xa,height:Ya,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+t+")"},this.zoomOutGroup).setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),this.boundEvents.push(Y(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(t){this.zoomInGroup=it(ba.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const e=it(ba.CLIPPATH,{id:"blocklyZoominClipPath"+t},this.zoomInGroup);it(ba.RECT,{width:32,height:32},e),it(ba.IMAGE,{width:Xa,height:Ya,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+t+")"},this.zoomInGroup).setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),this.boundEvents.push(Y(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(t,e){this.workspace.markFocused(),this.workspace.zoomCenter(t),this.fireZoomEvent(),G(),e.stopPropagation(),e.preventDefault()}createZoomResetSvg(t){this.zoomResetGroup=it(ba.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const e=it(ba.CLIPPATH,{id:"blocklyZoomresetClipPath"+t},this.zoomResetGroup);it(ba.RECT,{width:32,height:32},e),it(ba.IMAGE,{width:Xa,height:Ya,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+t+")"},this.zoomResetGroup).setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),this.boundEvents.push(Y(this.zoomResetGroup,"pointerdown",null,this.resetZoom.bind(this)))}resetZoom(t){this.workspace.markFocused();const e=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition(),this.workspace.zoomCenter(e),this.workspace.scrollCenter(),setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500),this.fireZoomEvent(),G(),t.stopPropagation(),t.preventDefault()}fireZoomEvent(){const t=new(P(ol))(null,this.workspace.id,"zoom_controls");A(t)}};tt("\n.blocklyZoom>image, .blocklyZoom>svg>image {\n opacity: .4;\n}\n\n.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {\n opacity: .6;\n}\n\n.blocklyZoom>image:active, .blocklyZoom>svg>image:active {\n opacity: .8;\n}\n");var ja=class{constructor(t){this.name=t}toString(){return this.name}equals(t){return this.name===t.toString()}};ja.MUTATOR=new ja("mutator"),ja.WARNING=new ja("warning"),ja.COMMENT=new ja("comment"),function(t){t[t.VALUE=1]="VALUE",t[t.STATEMENT=3]="STATEMENT",t[t.DUMMY=5]="DUMMY",t[t.CUSTOM=6]="CUSTOM",t[t.END_ROW=7]="END_ROW"}(Nr.inputTypes$$module$build$src$core$inputs$input_types||(Nr.inputTypes$$module$build$src$core$inputs$input_types={})),Nr.inputTypes$$module$build$src$core$inputs$input_types;var Ja,qa,Za=function(t,e){window.alert(t),e&&e()},Qa=function(t,e){e(window.confirm(t))},tc=function(t,e,s){s(window.prompt(t,e))},ec={confirmInternal:Zt},sc={TEST_ONLY:ec};sc.alert=jt,sc.confirm=qt,sc.prompt=te,sc.setAlert=Jt,sc.setConfirm=Qt,sc.setPrompt=ee,Nr.Msg$$module$build$src$core$msg=Object.create(null),Ja=function(t){Object.keys(t).forEach((function(e){Nr.Msg$$module$build$src$core$msg[e]=t[e]}))},qa={Msg:Nr.Msg$$module$build$src$core$msg,setLocale:Ja};var ic={};ic.isLegacyProcedureCallBlock=oe,ic.isLegacyProcedureDefBlock=ie;var oc=class extends kl{constructor(t){super(),this.isBlank=void 0===t,t&&(this.varId=t.getId(),this.workspaceId=t.workspace.id)}toJson(){const t=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");return t.varId=this.varId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new oc)).varId=t.varId,e}},nc=class extends oc{constructor(t){super(t),this.type=Zr,t&&(this.varType=t.type,this.varName=t.name)}toJson(){const t=super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return t.varType=this.varType,t.varName=this.varName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new nc)).varType=t.varType,e.varName=t.varName,e}run(t){const e=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t?e.createVariable(this.varName,this.varType,this.varId):e.deleteVariableById(this.varId)}};t(Pr.EVENT,Zr,nc);var rc=class{constructor(t,e,s,i){this.workspace=t,this.name=e,this.type=s||"",this.id_=i||k()}getId(){return this.id_}static compareByName(t,e){return t.name.localeCompare(e.name,void 0,{sensitivity:"base"})}},lc="VARIABLE",ac="ijkmnopqrstuvwxyzabcdefgh",cc={generateUniqueNameInternal:ae},hc={CATEGORY_NAME:lc,TEST_ONLY:cc,VAR_LETTER_OPTIONS:ac};hc.allDeveloperVariables=Nr.allDeveloperVariables$$module$build$src$core$variables,hc.allUsedVarModels=Nr.allUsedVarModels$$module$build$src$core$variables,hc.createVariableButtonHandler=he,hc.flyoutCategory=ne,hc.flyoutCategoryBlocks=re,hc.generateUniqueName=le,hc.generateUniqueNameFromOptions=ce,hc.generateVariableFieldDom=me,hc.getAddedVariables=be,hc.getOrCreateVariablePackage=Nr.getOrCreateVariablePackage$$module$build$src$core$variables,hc.getVariable=Nr.getVariable$$module$build$src$core$variables,hc.nameUsedWithAnyType=pe,hc.nameUsedWithConflictingParam=ge,hc.promptName=ue,hc.renameVariable=Nr.renameVariable$$module$build$src$core$variables;var uc=class{constructor(t,e,s,i,o){this.workspace=t,this.editable=this.movable=this.deletable=!0,this.disposed_=!1,this.isComment=!0,this.id=o&&!t.getCommentById(o)?o:k(),t.addTopComment(this),this.xy_=new ca(0,0),this.height_=s,this.width_=i,this.RTL=t.RTL,this.content_=e,uc.fireCreateEvent(this)}dispose(){this.disposed_||(M()&&A(new(P(dl))(this)),this.workspace.removeTopComment(this),this.disposed_=!0)}getHeight(){return this.height_}setHeight(t){this.height_=t}getWidth(){return this.width_}setWidth(t){this.width_=t}getRelativeToSurfaceXY(){return new ca(this.xy_.x,this.xy_.y)}moveBy(t,e){const s=new(P(gl))(this);this.xy_.translate(t,e),s.recordNew(),A(s)}isDeletable(){return this.deletable&&!(this.workspace&&this.workspace.options.readOnly)}setDeletable(t){this.deletable=t}isMovable(){return this.movable&&!(this.workspace&&this.workspace.options.readOnly)}setMovable(t){this.movable=t}isEditable(){return this.editable&&!(this.workspace&&this.workspace.options.readOnly)}setEditable(t){this.editable=t}getContent(){return this.content_}setContent(t){this.content_!==t&&(A(new(P(pl))(this,this.content_,t)),this.content_=t)}toXmlWithXY(t){return(t=this.toXml(t)).setAttribute("x",String(Math.round(this.xy_.x))),t.setAttribute("y",String(Math.round(this.xy_.y))),t.setAttribute("h",String(this.height_)),t.setAttribute("w",String(this.width_)),t}toXml(t){const e=Nr.createElement$$module$build$src$core$utils$xml("comment");return t||(e.id=this.id),e.textContent=this.getContent(),e}static fireCreateEvent(t){if(M()){const e=Nr.getGroup$$module$build$src$core$events$utils();e||Nr.setGroup$$module$build$src$core$events$utils(!0);try{A(new(P(ul))(t))}finally{Nr.setGroup$$module$build$src$core$events$utils(e)}}}static fromXml(t,e){var s=uc.parseAttributes(t);return e=new uc(e,s.content,s.h,s.w,s.id),s=t.getAttribute("x"),t=t.getAttribute("y"),s=s?parseInt(s,10):NaN,t=t?parseInt(t,10):NaN,isNaN(s)||isNaN(t)||e.moveBy(s,t),uc.fireCreateEvent(e),e}static parseAttributes(t){const e=t.getAttribute("h"),s=t.getAttribute("w"),i=t.getAttribute("x"),o=t.getAttribute("y"),n=t.getAttribute("id");if(!n)throw Error("No ID present in XML comment definition.");let r;return{id:n,h:e?parseInt(e):100,w:s?parseInt(s):100,x:i?parseInt(i):NaN,y:o?parseInt(o):NaN,content:null!=(r=t.textContent)?r:""}}},dc=class extends Ol{constructor(t,e,s){super(s),this.type=il,this.oldElementId=null!=t?t:void 0,this.newElementId=null!=e?e:void 0}toJson(){const t=super.toJson();return t.oldElementId=this.oldElementId,t.newElementId=this.newElementId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new dc)).oldElementId=t.oldElementId,e.newElementId=t.newElementId,e}};t(Pr.EVENT,il,dc);var pc={};pc.register=fe,pc.unregister=$e;var gc=class{paste(t,e,s){const i=t.commentState;if(s)i.setAttribute("x",`${s.x}`),i.setAttribute("y",`${s.y}`);else{var o;let t;s=parseInt(null!=(o=i.getAttribute("x"))?o:"0")+50,o=parseInt(null!=(t=i.getAttribute("y"))?t:"0")+50,i.setAttribute("x",`${s}`),i.setAttribute("y",`${o}`)}return _c.fromXmlRendered(t.commentState,e)}};gc.TYPE="workspace-comment",fe(gc.TYPE,new gc);var _c=class extends uc{constructor(t,e,s,i,o){super(t,e,s,i,o),this.onMouseMoveWrapper=this.onMouseUpWrapper=null,this.eventsInit=!1,this.deleteIconBorder=this.deleteGroup=this.resizeGroup=this.foreignObject=this.svgHandleTarget=this.svgRectTarget=this.textarea=null,this.rendered=this.autoLayout=this.focused=!1,this.svgGroup=it(ba.G,{class:"blocklyComment"}),this.workspace=t,this.svgRect_=it(ba.RECT,{class:"blocklyCommentRect",x:0,y:0,rx:3,ry:3}),this.svgGroup.appendChild(this.svgRect_),this.render()}dispose(){this.disposed_||(T()===this&&(this.unselect(),this.workspace.cancelCurrentGesture()),M()&&A(new(P(dl))(this)),at(this.svgGroup),Nr.disable$$module$build$src$core$events$utils(),super.dispose(),Nr.enable$$module$build$src$core$events$utils())}initSvg(t){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");this.workspace.options.readOnly||this.eventsInit||(Y(this.svgRectTarget,"pointerdown",this,this.pathMouseDown),Y(this.svgHandleTarget,"pointerdown",this,this.pathMouseDown)),this.eventsInit=!0,this.updateMovable(),this.getSvgRoot().parentNode||this.workspace.getBubbleCanvas().appendChild(this.getSvgRoot()),!t&&this.textarea&&this.textarea.select()}pathMouseDown(t){const e=this.workspace.getGesture(t);e&&e.handleBubbleStart(t,this)}showContextMenu(t){throw Error("The implementation of showContextMenu should be monkey-patched in by blockly.ts")}select(){if(T()!==this){var t=null;if(T()){t=T().id,Nr.disable$$module$build$src$core$events$utils();try{T().unselect()}finally{Nr.enable$$module$build$src$core$events$utils()}}t=new(P(il))(t,this.id,this.workspace.id),A(t),m(this),this.addSelect()}}unselect(){if(T()===this){var t=new(P(il))(this.id,null,this.workspace.id);A(t),m(null),this.removeSelect(),this.blurFocus()}}addSelect(){ot(this.svgGroup,"blocklySelected"),this.setFocus()}removeSelect(){ot(this.svgGroup,"blocklySelected"),this.blurFocus()}addFocus(){ot(this.svgGroup,"blocklyFocused")}removeFocus(){rt(this.svgGroup,"blocklyFocused")}getRelativeToSurfaceXY(){const t=this.workspace.getLayerManager();if(!t)throw Error("Cannot calculate position because the workspace has not been appended");let e=0,s=0,i=this.getSvgRoot();if(i)do{const t=Ot(i);e+=t.x,s+=t.y,i=i.parentNode}while(i&&!t.hasLayer(i)&&null!==i);return this.xy_=new ca(e,s)}moveBy(t,e){const s=new(P(gl))(this),i=this.getRelativeToSurfaceXY();this.translate(i.x+t,i.y+e),this.xy_=new ca(i.x+t,i.y+e),s.recordNew(),A(s),this.workspace.resizeContents()}translate(t,e){this.xy_=new ca(t,e),this.getSvgRoot().setAttribute("transform","translate("+t+","+e+")")}moveDuringDrag(t){t=`translate(${t.x}, ${t.y})`,this.getSvgRoot().setAttribute("transform",t)}moveTo(t,e){this.translate(t,e)}clearTransformAttributes(){this.getSvgRoot().removeAttribute("transform")}getBoundingRectangle(){var t=this.getRelativeToSurfaceXY();const e=this.getHeightWidth(),s=t.y,i=t.y+e.height;let o;return this.RTL?(o=t.x-e.width,t=t.x):(o=t.x,t=t.x+e.width),new fa(s,i,o,t)}updateMovable(){this.isMovable()?ot(this.svgGroup,"blocklyDraggable"):rt(this.svgGroup,"blocklyDraggable")}setMovable(t){super.setMovable(t),this.updateMovable()}setEditable(t){super.setEditable(t),this.textarea&&(this.textarea.readOnly=!t)}setDragging(t){t?ot(this.getSvgRoot(),"blocklyDragging"):rt(this.getSvgRoot(),"blocklyDragging")}getSvgRoot(){return this.svgGroup}getContent(){return this.textarea?this.textarea.value:this.content_}setContent(t){super.setContent(t),this.textarea&&(this.textarea.value=t)}setDeleteStyle(t){t?ot(this.svgGroup,"blocklyDraggingDelete"):rt(this.svgGroup,"blocklyDraggingDelete")}setAutoLayout(t){}toXmlWithXY(t){let e=0;this.workspace.RTL&&(e=this.workspace.getWidth()),t=this.toXml(t);const s=this.getRelativeToSurfaceXY();return t.setAttribute("x",String(Math.round(this.workspace.RTL?e-s.x:s.x))),t.setAttribute("y",String(Math.round(s.y))),t.setAttribute("h",String(this.getHeight())),t.setAttribute("w",String(this.getWidth())),t}toCopyData(){return{paster:gc.TYPE,commentState:this.toXmlWithXY()}}getHeightWidth(){return{width:this.getWidth(),height:this.getHeight()}}render(){if(!this.rendered){var t=this.getHeightWidth(),e=this.createEditor();this.svgGroup.appendChild(e),this.svgHandleTarget=it(ba.RECT,{class:"blocklyCommentHandleTarget",x:0,y:0}),this.svgGroup.appendChild(this.svgHandleTarget),this.svgRectTarget=it(ba.RECT,{class:"blocklyCommentTarget",x:0,y:0,rx:3,ry:3}),this.svgGroup.appendChild(this.svgRectTarget),this.addResizeDom(),this.isDeletable()&&this.addDeleteDom(),this.setSize(t.width,t.height),this.textarea.value=this.content_,this.rendered=!0,this.resizeGroup&&Y(this.resizeGroup,"pointerdown",this,this.resizeMouseDown),this.isDeletable()&&(Y(this.deleteGroup,"pointerdown",this,this.deleteMouseDown),Y(this.deleteGroup,"pointerout",this,this.deleteMouseOut),Y(this.deleteGroup,"pointerup",this,this.deleteMouseUp))}}createEditor(){this.foreignObject=it(ba.FOREIGNOBJECT,{x:0,y:_c.TOP_OFFSET,class:"blocklyCommentForeignObject"});const t=document.createElementNS(pa,"body");t.setAttribute("xmlns",pa),t.className="blocklyMinimalBody";const e=document.createElementNS(pa,"textarea");return e.className="blocklyCommentTextarea",e.setAttribute("dir",this.RTL?"RTL":"LTR"),e.readOnly=!this.isEditable(),t.appendChild(e),this.textarea=e,this.foreignObject.appendChild(t),Y(e,"wheel",this,(function(t){t.stopPropagation()})),Y(e,"change",this,(function(t){this.setContent(e.value)})),this.foreignObject}addResizeDom(){this.resizeGroup=it(ba.G,{class:this.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.svgGroup),it(ba.POLYGON,{points:"0,8 8,8 8,0"},this.resizeGroup),it(ba.LINE,{class:"blocklyResizeLine",x1:8/3,y1:7,x2:7,y2:8/3},this.resizeGroup),it(ba.LINE,{class:"blocklyResizeLine",x1:16/3,y1:7,x2:7,y2:16/3},this.resizeGroup)}addDeleteDom(){this.deleteGroup=it(ba.G,{class:"blocklyCommentDeleteIcon"},this.svgGroup),this.deleteIconBorder=it(ba.CIRCLE,{class:"blocklyDeleteIconShape",r:"7",cx:"7.5",cy:"7.5"},this.deleteGroup),it(ba.LINE,{x1:"5",y1:"10",x2:"10",y2:"5",stroke:"#fff","stroke-width":"2"},this.deleteGroup),it(ba.LINE,{x1:"5",y1:"5",x2:"10",y2:"10",stroke:"#fff","stroke-width":"2"},this.deleteGroup)}resizeMouseDown(t){this.unbindDragEvents(),J(t)||(this.workspace.startDrag(t,new ca(this.workspace.RTL?-this.width_:this.width_,this.height_)),this.onMouseUpWrapper=Y(document,"pointerup",this,this.resizeMouseUp),this.onMouseMoveWrapper=Y(document,"pointermove",this,this.resizeMouseMove),this.workspace.hideChaff()),t.stopPropagation()}deleteMouseDown(t){this.deleteIconBorder&&ot(this.deleteIconBorder,"blocklyDeleteIconHighlighted"),t.stopPropagation()}deleteMouseOut(t){this.deleteIconBorder&&rt(this.deleteIconBorder,"blocklyDeleteIconHighlighted")}deleteMouseUp(t){this.dispose(),t.stopPropagation()}unbindDragEvents(){this.onMouseUpWrapper&&(z(this.onMouseUpWrapper),this.onMouseUpWrapper=null),this.onMouseMoveWrapper&&(z(this.onMouseMoveWrapper),this.onMouseMoveWrapper=null)}resizeMouseUp(t){G(),this.unbindDragEvents()}resizeMouseMove(t){this.autoLayout=!1,t=this.workspace.moveDrag(t),this.setSize(this.RTL?-t.x:t.x,t.y)}resizeComment(){const t=this.getHeightWidth(),e=_c.TOP_OFFSET;let s,i;if(null==(s=this.foreignObject)||s.setAttribute("width",String(t.width)),null==(i=this.foreignObject)||i.setAttribute("height",String(t.height-e)),this.RTL){let e;null==(e=this.foreignObject)||e.setAttribute("x",String(-t.width))}this.textarea&&(this.textarea.style.width=t.width-4+"px",this.textarea.style.height=t.height-4-e+"px")}setSize(t,e){let s,i,o,n;if(t=Math.max(t,45),e=Math.max(e,20+_c.TOP_OFFSET),this.width_=t,this.height_=e,this.svgRect_.setAttribute("width",`${t}`),this.svgRect_.setAttribute("height",`${e}`),null==(s=this.svgRectTarget)||s.setAttribute("width",`${t}`),null==(i=this.svgRectTarget)||i.setAttribute("height",`${e}`),null==(o=this.svgHandleTarget)||o.setAttribute("width",`${t}`),null==(n=this.svgHandleTarget)||n.setAttribute("height",String(_c.TOP_OFFSET)),this.RTL){let t;this.svgRect_.setAttribute("transform","scale(-1 1)"),null==(t=this.svgRectTarget)||t.setAttribute("transform","scale(-1 1)")}if(this.resizeGroup)if(this.RTL){let s;this.resizeGroup.setAttribute("transform","translate("+(8-t)+","+(e-8)+") scale(-1 1)"),null==(s=this.deleteGroup)||s.setAttribute("transform","translate("+(8-t)+","+"-8) scale(-1 1)")}else{let s;this.resizeGroup.setAttribute("transform","translate("+(t-8)+","+(e-8)+")"),null==(s=this.deleteGroup)||s.setAttribute("transform","translate("+(t-8)+","+"-8)")}this.resizeComment()}setFocus(){this.focused=!0,setTimeout((()=>{this.disposed_||(this.textarea.focus(),this.addFocus(),this.svgRectTarget&&ot(this.svgRectTarget,"blocklyCommentTargetFocused"),this.svgHandleTarget&&ot(this.svgHandleTarget,"blocklyCommentHandleTargetFocused"))}),0)}blurFocus(){this.focused=!1,setTimeout((()=>{this.disposed_||(this.textarea.blur(),this.removeFocus(),this.svgRectTarget&&rt(this.svgRectTarget,"blocklyCommentTargetFocused"),this.svgHandleTarget&&rt(this.svgHandleTarget,"blocklyCommentHandleTargetFocused"))}),0)}static fromXmlRendered(t,e,s){let i;Nr.disable$$module$build$src$core$events$utils();try{const o=uc.parseAttributes(t);if(i=new _c(e,o.content,o.h,o.w,o.id),e.rendered&&(i.initSvg(!0),i.render()),!isNaN(o.x)&&!isNaN(o.y))if(e.RTL){const t=s||e.getWidth();i.moveBy(t-o.x,o.y)}else i.moveBy(o.x,o.y)}finally{Nr.enable$$module$build$src$core$events$utils()}return uc.fireCreateEvent(i),i}};_c.DEFAULT_SIZE=100,_c.TOP_OFFSET=10,tt("\n.blocklyCommentForeignObject {\n position: relative;\n z-index: 0;\n}\n\n.blocklyCommentRect {\n fill: #E7DE8E;\n stroke: #bcA903;\n stroke-width: 1px;\n}\n\n.blocklyCommentTarget {\n fill: transparent;\n stroke: #bcA903;\n}\n\n.blocklyCommentTargetFocused {\n fill: none;\n}\n\n.blocklyCommentHandleTarget {\n fill: none;\n}\n\n.blocklyCommentHandleTargetFocused {\n fill: transparent;\n}\n\n.blocklyFocused>.blocklyCommentRect {\n fill: #B9B272;\n stroke: #B9B272;\n}\n\n.blocklySelected>.blocklyCommentTarget {\n stroke: #fc3;\n stroke-width: 3px;\n}\n\n.blocklyCommentDeleteIcon {\n cursor: pointer;\n fill: #000;\n display: none;\n}\n\n.blocklySelected > .blocklyCommentDeleteIcon {\n display: block;\n}\n\n.blocklyDeleteIconShape {\n fill: #000;\n stroke: #000;\n stroke-width: 1px;\n}\n\n.blocklyDeleteIconShape.blocklyDeleteIconHighlighted {\n stroke: #fc3;\n}\n");var Tc=new Set,mc=new WeakSet,Ec=null,bc=null,fc=0,$c={};$c.finishQueuedRenders=Se,$c.queueRender=Ie,$c.triggerQueuedRenders=Re;var Ic={};Ic.appendDomToWorkspace=He,Ic.blockToDom=xe,Ic.blockToDomWithXY=Ne,Ic.clearWorkspaceAndLoadFromXml=Ue,Ic.deleteNext=ts,Ic.domToBlock=Nr.domToBlock$$module$build$src$core$xml,Ic.domToBlockInternal=Ge,Ic.domToPrettyText=Fe,Ic.domToText=Pe,Ic.domToVariables=Ve,Ic.domToWorkspace=Nr.domToWorkspace$$module$build$src$core$xml,Ic.variablesToDom=we,Ic.workspaceToDom=Le;var Sc=class extends Error{},Rc=class extends Sc{constructor(t){super("Expected to find a 'type' property, defining the block type"),this.state=t}},Cc=class extends Sc{constructor(t,e,s){super(`The block ${e.toDevString()} is missing a(n) ${t}\nconnection`),this.block=e,this.state=s}},kc=class extends Sc{constructor(t,e,s,i){super(`The block ${s.toDevString()} could not connect its\n${e} to its parent, because: ${t}`),this.childBlock=s,this.childState=i}},Oc=class extends Sc{constructor(t){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=t}},yc=class extends Sc{constructor(t,e,s){super(`Cannot add an icon of type '${t}' to the block ${e.toDevString()}, because there is no icon registered with type '${t}'. Make sure that all of your icons have been registered.`),this.block=e,this.state=s}},Ac={};Ac.BadConnectionCheck=kc,Ac.DeserializationError=Sc,Ac.MissingBlockType=Rc,Ac.MissingConnection=Cc,Ac.RealChildOfShadow=Oc,Ac.UnregisteredIcon=yc;var vc={BLOCKS:50,PROCEDURES:75,VARIABLES:100},Lc={};Lc.register=is,Lc.unregister=os;var wc=class{constructor(){this.priority=50}save(t){const e=[];for(const s of t.getTopBlocks(!1))(t=ns(s,{addCoordinates:!0,doFullSerialization:!1}))&&e.push(t);return e.length?{languageVersion:0,blocks:e}:null}load(t,e){t=t.blocks;for(const s of t)gs(s,e,{recordUndo:y()})}clear(t){for(const e of t.getTopBlocks(!1))e.dispose(!1)}};is("blocks",new wc);var Nc={};Nc.BlockSerializer=wc,Nc.append=gs,Nc.appendInternal=_s,Nc.save=ns;var Mc=class extends kl{constructor(t){super(),this.isBlank=!t,t&&(this.blockId=t.id,this.workspaceId=t.workspace.id)}toJson(){const t=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return t.blockId=this.blockId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Mc)).blockId=t.blockId,e}},Dc=class extends Mc{constructor(t){super(t),this.type=Nr.CREATE$$module$build$src$core$events$utils,t&&(t.isShadow()&&(this.recordUndo=!1),this.xml=Ne(t),this.ids=x(t),this.json=ns(t,{addCoordinates:!0}))}toJson(){const t=super.toJson();if(!this.xml)throw Error("The block XML 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(!this.json)throw Error("The block JSON is undefined. Either pass a block to the constructor, or call fromJson");return t.xml=Pe(this.xml),t.ids=this.ids,t.json=this.json,this.recordUndo||(t.recordUndo=this.recordUndo),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Dc)).xml=Nr.textToDom$$module$build$src$core$utils$xml(t.xml),e.ids=t.ids,e.json=t.json,void 0!==t.recordUndo&&(e.recordUndo=t.recordUndo),e}run(t){const e=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(!xc(e,this.ids))if(t)gs(this.json,e);else for(t=0;tt.getBlockById(e))).filter((t=>t&&t.isShadow())).length===e.length};t(Pr.EVENT,Nr.CREATE$$module$build$src$core$events$utils,Dc);var Bc=class extends Ol{constructor(t,e){super(e),this.type=cl,this.themeName=t}toJson(){const t=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");return t.themeName=this.themeName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Bc)).themeName=t.themeName,e}};t(Pr.EVENT,cl,Bc);var Pc,Fc=class extends Ol{constructor(t,e,s,i,o){super(i),this.type=hl,this.viewTop=t,this.viewLeft=e,this.scale=s,this.oldScale=o}toJson(){const t=super.toJson();if(void 0===this.viewTop)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.viewLeft)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.scale)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(void 0===this.oldScale)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");return t.viewTop=this.viewTop,t.viewLeft=this.viewLeft,t.scale=this.scale,t.oldScale=this.oldScale,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Fc)).viewTop=t.viewTop,e.viewLeft=t.viewLeft,e.scale=t.scale,e.oldScale=t.oldScale,e}};t(Pr.EVENT,hl,Fc),Nr.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250},Nr.config$$module$build$src$core$config,function(t){t[t.INPUT_VALUE=1]="INPUT_VALUE",t[t.OUTPUT_VALUE=2]="OUTPUT_VALUE",t[t.NEXT_STATEMENT=3]="NEXT_STATEMENT",t[t.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT"}(Pc||(Pc={}));var Uc=class{constructor(t){this.connectionChecker=t,this.connections=[]}addConnection(t,e){e=this.calculateIndexForYPos(e),this.connections.splice(e,0,t)}findIndexOfConnection(t,e){if(!this.connections.length)return-1;const s=this.calculateIndexForYPos(e);if(s>=this.connections.length)return-1;e=t.y;let i=s;for(;0<=i&&this.connections[i].y===e;){if(this.connections[i]===t)return i;i--}for(i=s;it)){e=i;break}s=i}}return e}removeConnection(t,e){if(-1===(t=this.findIndexOfConnection(t,e)))throw Error("Unable to find connection in connectionDB.");this.connections.splice(t,1)}getNeighbours(t,e){function s(t){const s=o-i[t].x,r=n-i[t].y;return Math.sqrt(s*s+r*r)<=e&&a.push(i[t]),rt?this.menuItems.length:t,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(t,e){let s;for(t+=e;s=this.menuItems[t];){if(s.isEnabled()){this.setHighlighted(s);break}t+=e}}handleMouseOver(t){(t=this.getMenuItem(t.target))&&(t.isEnabled()?this.highlightedItem!==t&&this.setHighlighted(t):this.setHighlighted(null))}handleClick(t){const e=this.openingCoords;if(this.openingCoords=null,e&&"number"==typeof t.clientX){const s=new ca(t.clientX,t.clientY);if(1>ca.distance(e,s))return}(t=this.getMenuItem(t.target))&&t.performAction()}handleMouseEnter(t){this.focus()}handleMouseLeave(t){this.getElement()&&(this.blur(),this.setHighlighted(null))}handleKeyEvent(t){if(this.menuItems.length&&!(t.shiftKey||t.ctrlKey||t.metaKey||t.altKey)){var e=this.highlightedItem;switch(t.key){case"Enter":case" ":e&&e.performAction();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}t.preventDefault(),t.stopPropagation()}}getSize(){const t=this.getElement(),e=Et(t);return e.height=t.scrollHeight,e}},th=class{constructor(t,e){this.content=t,this.opt_value=e,this.enabled=!0,this.element=null,this.rightToLeft=!1,this.roleName=null,this.highlight=this.checked=this.checkable=!1,this.actionHandler=null}createDom(){const t=document.createElement("div");t.id=C(),this.element=t,t.className="blocklyMenuItem goog-menuitem "+(this.enabled?"":"blocklyMenuItemDisabled goog-menuitem-disabled ")+(this.checked?"blocklyMenuItemSelected goog-option-selected ":"")+(this.highlight?"blocklyMenuItemHighlight goog-menuitem-highlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl goog-menuitem-rtl ":"");const e=document.createElement("div");if(e.className="blocklyMenuItemContent goog-menuitem-content",this.checkable){var s=document.createElement("div");s.className="blocklyMenuItemCheckbox goog-menuitem-checkbox",e.appendChild(s)}return s=this.content,"string"==typeof this.content&&(s=document.createTextNode(this.content)),e.appendChild(s),t.appendChild(e),this.roleName&&xs(t,this.roleName),Bs(t,zc.SELECTED,this.checkable&&this.checked||!1),Bs(t,zc.DISABLED,!this.enabled),t}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){let t;return null!=(t=this.opt_value)?t:null}setRightToLeft(t){this.rightToLeft=t}setRole(t){this.roleName=t}setCheckable(t){this.checkable=t}setChecked(t){this.checked=t}setHighlighted(t){this.highlight=t;const e=this.getElement();e&&this.isEnabled()&&(t?(ot(e,"blocklyMenuItemHighlight"),ot(e,"goog-menuitem-highlight")):(rt(e,"blocklyMenuItemHighlight"),rt(e,"goog-menuitem-highlight")))}isEnabled(){return this.enabled}setEnabled(t){this.enabled=t}performAction(){this.isEnabled()&&this.actionHandler&&this.actionHandler(this)}onAction(t,e){this.actionHandler=t.bind(e)}},eh=null,sh=null,ih="blocklyWidgetDiv",oh="",nh="",rh={};rh.createDom=Us,rh.getDiv=Ps,rh.hide=Gs,rh.hideIfOwner=Ws,rh.isVisible=Vs,rh.positionWithAnchor=Ys,rh.repositionForWindowResize=Js,rh.show=Hs,rh.testOnly_setDiv=Fs;var lh=null,ah={},ch=null,hh={};hh.callbackFactory=Nr.callbackFactory$$module$build$src$core$contextmenu,hh.commentDeleteOption=ri,hh.commentDuplicateOption=li,hh.dispose=ni,hh.getCurrentBlock=qs,hh.hide=oi,hh.setCurrentBlock=Zs,hh.show=Qs,hh.workspaceCommentOption=ai;var uh=class{constructor(){this.registry_=new Map,this.reset()}reset(){this.registry_.clear()}register(t){if(this.registry_.has(t.id))throw Error('Menu item with ID "'+t.id+'" is already registered.');this.registry_.set(t.id,t)}unregister(t){if(!this.registry_.has(t))throw Error('Menu item with ID "'+t+'" not found.');this.registry_.delete(t)}getItem(t){let e;return null!=(e=this.registry_.get(t))?e:null}getContextMenuOptions(t,e){const s=[];for(const o of this.registry_.values())if(t===o.scopeType){var i=o.preconditionFn(e);"hidden"!==i&&(i={text:"function"==typeof o.displayText?o.displayText(e):o.displayText,enabled:"enabled"===i,callback:o.callback,scope:e,weight:o.weight},s.push(i))}return s.sort((function(t,e){return t.weight-e.weight})),s}};!function(t){var e=t.ScopeType||(t.ScopeType={});e.BLOCK="block",e.WORKSPACE="workspace",t.registry=new t}(uh||(uh={}));var dh=uh.ScopeType,ph={};ph.ContextMenuRegistry=uh,ph.ScopeType=dh;var gh={};gh.clamp=ui,gh.toDegrees=hi,gh.toRadians=ci;var _h,Th,mh,Eh=16,bh=1,fh=12,$h=16,Ih=.25,Sh=null,Rh=null,Ch="",kh="",Oh=null,yh=null,Ah=null,vh={getBoundsInfo:function(){const t=It(Oh),e=Et(Oh);return{left:t.x,right:t.x+e.width,top:t.y,bottom:t.y+e.height,width:e.width,height:e.height}},getPositionMetrics:function(t,e,s,i){const o=vh.getBoundsInfo(),n=Et(_h);return e+n.heighto.top?Ci(s,i,o,n):e+n.heightdocument.documentElement.clientTop?Ci(s,i,o,n):ki(t,o,n)}},Lh={ANIMATION_TIME:Ih,ARROW_HORIZONTAL_PADDING:fh,ARROW_SIZE:Eh,BORDER_SIZE:bh,PADDING_Y:$h,TEST_ONLY:vh};Lh.clearContent=Ti,Lh.createDom=di,Lh.getContentDiv=_i,Lh.getOwner=gi,Lh.getPositionX=Oi,Lh.hide=vi,Lh.hideIfOwner=Ai,Lh.hideWithoutAnimation=Li,Lh.isVisible=yi,Lh.repositionForWindowResize=Ni,Lh.setBoundsElement=pi,Lh.setColour=mi,Lh.show=Si,Lh.showPositionedByBlock=Ei,Lh.showPositionedByField=bi;var wh=null,Nh=null,Mh={};Mh.connectionUiEffect=xi,Mh.disconnectUiEffect=Bi,Mh.disconnectUiStop=Fi,Mh.disposeUiEffect=Mi;var Dh=class{constructor(t,e){this.bubble=t,this.workspace=e,this.dragTarget_=null,this.wouldDeleteBubble_=!1,this.startXY_=this.bubble.getRelativeToSurfaceXY()}startBubbleDrag(){let t;Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.workspace.setResizesEnabled(!1),this.bubble.setAutoLayout&&this.bubble.setAutoLayout(!1),null==(t=this.workspace.getLayerManager())||t.moveToDragLayer(this.bubble),this.bubble.setDragging&&this.bubble.setDragging(!0)}dragBubble(t,e){e=this.pixelsToWorkspaceUnits_(e),e=ca.sum(this.startXY_,e),this.bubble.moveDuringDrag(e),e=this.dragTarget_,this.dragTarget_=this.workspace.getDragTarget(t),t=this.wouldDeleteBubble_,this.wouldDeleteBubble_=this.shouldDelete_(this.dragTarget_),t!==this.wouldDeleteBubble_&&this.updateCursorDuringBubbleDrag_(),this.dragTarget_!==e&&(e&&e.onDragExit(this.bubble),this.dragTarget_&&this.dragTarget_.onDragEnter(this.bubble)),this.dragTarget_&&this.dragTarget_.onDragOver(this.bubble)}shouldDelete_(t){return!(!t||!this.workspace.getComponentManager().hasCapability(t.id,na.Capability.DELETE_AREA))&&t.wouldDelete(this.bubble,!1)}updateCursorDuringBubbleDrag_(){this.bubble.setDeleteStyle(this.wouldDeleteBubble_)}endBubbleDrag(t,e){if(this.dragBubble(t,e),this.dragTarget_&&this.dragTarget_.shouldPreventMove(this.bubble)?t=this.startXY_:(t=this.pixelsToWorkspaceUnits_(e),t=ca.sum(this.startXY_,t)),this.bubble.moveTo(t.x,t.y),this.dragTarget_&&this.dragTarget_.onDrop(this.bubble),this.wouldDeleteBubble_)this.fireMoveEvent_(),this.bubble.dispose();else{if(this.bubble.setDragging){let t;this.bubble.setDragging(!1),null==(t=this.workspace.getLayerManager())||t.moveOffDragLayer(this.bubble,100)}this.fireMoveEvent_()}this.workspace.setResizesEnabled(!0),Nr.setGroup$$module$build$src$core$events$utils(!1)}fireMoveEvent_(){if(this.bubble instanceof _c){const t=new(P(gl))(this.bubble);t.setOldCoordinate(this.startXY_),t.recordNew(),A(t)}}pixelsToWorkspaceUnits_(t){return t=new ca(t.x/this.workspace.scale,t.y/this.workspace.scale),this.workspace.isMutator&&t.scale(1/this.workspace.options.parentWorkspace.scale),t}},xh=[];xh[Pc.INPUT_VALUE]=Pc.OUTPUT_VALUE,xh[Pc.OUTPUT_VALUE]=Pc.INPUT_VALUE,xh[Pc.NEXT_STATEMENT]=Pc.PREVIOUS_STATEMENT,xh[Pc.PREVIOUS_STATEMENT]=Pc.NEXT_STATEMENT;var Bh="RENAME_VARIABLE_ID",Ph="DELETE_VARIABLE_ID",Fh={};Fh.commonWordPrefix=Gi,Fh.commonWordSuffix=Vi,Fh.isNumber=Nr.isNumber$$module$build$src$core$utils$string,Fh.shortestStringLength=Hi,Fh.startsWith=Ui,Fh.wrap=Nr.wrap$$module$build$src$core$utils$string;var Uh=void 0,Hh=!1,Gh=!1,Vh=50,Wh=0,Xh=0,Yh=0,Kh=0,zh=null,jh=null,Jh=0,qh=10,Zh=10,Qh=750,tu=5,eu=null,su={HOVER_MS:Qh,LIMIT:Vh,MARGINS:tu,OFFSET_X:Jh,OFFSET_Y:qh,RADIUS_OK:Zh};su.bindMouseEvents=eo,su.block=ao,su.createDom=to,su.dispose=ro,su.getCustomTooltip=ji,su.getDiv=qi,su.getTooltipOfObject=Zi,su.hide=lo,su.isVisible=Ji,su.setCustomTooltip=zi,su.unbindMouseEvents=so,su.unblock=co;var iu=class{constructor(t){this.workspace=t,this.horizontalScrollEnabled_=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled_=this.workspace.isMovableVertically(),this.startScrollXY_=new ca(t.scrollX,t.scrollY)}dispose(){this.workspace=null}startDrag(){T()&&T().unselect()}endDrag(t){this.drag(t)}drag(t){if(t=ca.sum(this.startScrollXY_,t),this.horizontalScrollEnabled_&&this.verticalScrollEnabled_)this.workspace.scroll(t.x,t.y);else if(this.horizontalScrollEnabled_)this.workspace.scroll(t.x,this.workspace.scrollY);else{if(!this.verticalScrollEnabled_)throw new TypeError("Invalid state.");this.workspace.scroll(this.workspace.scrollX,t.y)}}},ou=class{constructor(t,e){this.creatorWorkspace=e,this.mouseDownXY=new ca(0,0),this.startWorkspace_=this.targetBlock=this.startBlock=this.startIcon=this.startField=this.startBubble=null,this.hasExceededDragRadius=!1,this.boundEvents=[],this.flyout=this.workspaceDragger=this.blockDragger=this.bubbleDragger=null,this.isMultiTouch_=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1,this.cachedPoints=new Map,this.startDistance=this.previousScale=0,this.currentDropdownOwner=this.isPinchZoomEnabled=null,this.mostRecentEvent=t,this.currentDragDeltaXY=new ca(0,0),this.healStack=!1}dispose(){G(),co(),this.creatorWorkspace.clearGesture();for(const t of this.boundEvents)z(t);this.boundEvents.length=0,this.blockDragger&&this.blockDragger.dispose(),this.workspaceDragger&&this.workspaceDragger.dispose()}updateFromEvent(t){const e=new ca(t.clientX,t.clientY);this.updateDragDelta(e)&&(this.updateIsDragging(),H()),this.mostRecentEvent=t}updateDragDelta(t){return this.currentDragDeltaXY=ca.difference(t,this.mouseDownXY),!this.hasExceededDragRadius&&(this.hasExceededDragRadius=ca.magnitude(this.currentDragDeltaXY)>(this.flyout?Nr.config$$module$build$src$core$config.flyoutDragRadius:Nr.config$$module$build$src$core$config.dragRadius))}updateIsDraggingFromFlyout(){let t;if(!this.targetBlock||null==(t=this.flyout)||!t.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error("Cannot update dragging from the flyout because the ' +\n 'flyout's target workspace is undefined");return!(this.flyout.isScrollable()&&!this.flyout.isDragTowardWorkspace(this.currentDragDeltaXY)||(this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),this.targetBlock.select(),0))}updateIsDraggingBubble(){return!!this.startBubble&&(this.startDraggingBubble(),!0)}updateIsDraggingBlock(){if(!this.targetBlock)return!1;if(this.flyout){if(this.updateIsDraggingFromFlyout())return this.startDraggingBlock(),!0}else if(this.targetBlock.isMovable())return this.startDraggingBlock(),!0;return!1}updateIsDraggingWorkspace(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");(this.flyout?this.flyout.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())&&(this.workspaceDragger=new iu(this.startWorkspace_),this.workspaceDragger.startDrag())}updateIsDragging(){if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0,this.updateIsDraggingBubble()||this.updateIsDraggingBlock()||this.updateIsDraggingWorkspace()}startDraggingBlock(){this.blockDragger=new(c(Pr.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(this.targetBlock,this.startWorkspace_),this.blockDragger.startDrag(this.currentDragDeltaXY,this.healStack),this.blockDragger.drag(this.mostRecentEvent,this.currentDragDeltaXY)}startDraggingBubble(){if(!this.startBubble)throw Error("Cannot update dragging the bubble because the start bubble is undefined");if(!this.startWorkspace_)throw Error("Cannot update dragging the bubble because the start workspace is undefined");this.bubbleDragger=new Dh(this.startBubble,this.startWorkspace_),this.bubbleDragger.startBubbleDrag(),this.bubbleDragger.dragBubble(this.mostRecentEvent,this.currentDragDeltaXY)}doStart(t){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,j(t)?this.cancel():(this.gestureHasStarted=!0,Fi(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=gi(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=t,ao(),this.targetBlock&&this.targetBlock.select(),J(t)?this.handleRightClick(t):("pointerdown"===t.type.toLowerCase()&&"mouse"!==t.pointerType&&U(t,this),this.mouseDownXY=new ca(t.clientX,t.clientY),this.healStack=t.altKey||t.ctrlKey||t.metaKey,this.bindMouseEvents(t),this.isEnding_||this.handleTouchStart(t)))}bindMouseEvents(t){this.boundEvents.push(Y(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(Y(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(Y(document,"pointerup",null,this.handleUp.bind(this),!0)),t.preventDefault(),t.stopPropagation()}handleStart(t){this.isDragging()||(this.handleTouchStart(t),this.isMultiTouch()&&H())}handleMove(t){this.isDragging()&&V(t)||!this.isMultiTouch()?(this.updateFromEvent(t),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.blockDragger?this.blockDragger.drag(this.mostRecentEvent,this.currentDragDeltaXY):this.bubbleDragger&&this.bubbleDragger.dragBubble(this.mostRecentEvent,this.currentDragDeltaXY),t.preventDefault(),t.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(t),H())}handleUp(t){if(this.isDragging()||this.handleTouchEnd(t),!this.isMultiTouch()||this.isDragging()){if(!V(t))return;if(this.updateFromEvent(t),H(),this.isEnding_)return void console.log("Trying to end a gesture recursively.");this.isEnding_=!0,this.bubbleDragger?this.bubbleDragger.endBubbleDrag(t,this.currentDragDeltaXY):this.blockDragger?this.blockDragger.endDrag(t,this.currentDragDeltaXY):this.workspaceDragger?this.workspaceDragger.endDrag(this.currentDragDeltaXY):this.isBubbleClick()?this.doBubbleClick():this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(t)}t.preventDefault(),t.stopPropagation(),this.dispose()}handleTouchStart(t){var e=W(t);this.cachedPoints.set(e,this.getTouchPoint(t));var s=Array.from(this.cachedPoints.keys());2===s.length&&(e=this.cachedPoints.get(s[0]),s=this.cachedPoints.get(s[1]),this.startDistance=ca.distance(e,s),this.isMultiTouch_=!0,t.preventDefault())}handleTouchMove(t){const e=W(t);this.cachedPoints.set(e,this.getTouchPoint(t)),this.isPinchZoomEnabled&&2===this.cachedPoints.size?this.handlePinch(t):this.handleMove(t)}handlePinch(t){var e=Array.from(this.cachedPoints.keys()),s=this.cachedPoints.get(e[0]);if(e=this.cachedPoints.get(e[1]),s=ca.distance(s,e)/this.startDistance,0this.previousScale){if(e=0<(e=s-this.previousScale)?5*e:6*e,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const i=this.startWorkspace_,o=q(t,i.getParentSvg(),i.getInverseScreenCTM());i.zoom(o.x,o.y,e)}this.previousScale=s,t.preventDefault()}handleTouchEnd(t){t=W(t),this.cachedPoints.has(t)&&this.cachedPoints.delete(t),2>this.cachedPoints.size&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(t){return this.startWorkspace_?new ca(t.pageX,t.pageY):null}isMultiTouch(){return this.isMultiTouch_}cancel(){this.isEnding_||(H(),this.bubbleDragger?this.bubbleDragger.endBubbleDrag(this.mostRecentEvent,this.currentDragDeltaXY):this.blockDragger?this.blockDragger.endDrag(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(t){this.targetBlock?(this.bringBlockToFront(),this.targetBlock.workspace.hideChaff(!!this.flyout),this.targetBlock.showContextMenu(t)):this.startBubble?this.startBubble.showContextMenu(t):this.startWorkspace_&&!this.flyout&&(this.startWorkspace_.hideChaff(),this.startWorkspace_.showContextMenu(t)),t.preventDefault(),t.stopPropagation(),this.dispose()}handleWsStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace(e),this.mostRecentEvent=t,this.doStart(t)}fireWorkspaceClick(t){A(new(P(ol))(null,t.id,"workspace"))}handleFlyoutStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(e),this.handleWsStart(t,e.getWorkspace())}handleBlockStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(e),this.mostRecentEvent=t}handleBubbleStart(t,e){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(e),this.mostRecentEvent=t}doBubbleClick(){this.startBubble instanceof _c&&(this.startBubble.setFocus(),this.startBubble.select())}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),this.bringBlockToFront()}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.bringBlockToFront(),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");this.targetBlock.isEnabled()&&(Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.flyout.createBlock(this.targetBlock).scheduleSnapAndBump())}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");const t=new(P(ol))(this.startBlock,this.startWorkspace_.id,"block");A(t)}this.bringBlockToFront(),Nr.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(t){t=this.creatorWorkspace,T()&&T().unselect(),this.fireWorkspaceClick(this.startWorkspace_||t)}bringBlockToFront(){this.targetBlock&&!this.flyout&&this.targetBlock.bringToFront()}setStartField(t){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=t)}setStartIcon(t){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=t)}setStartBubble(t){this.startBubble||(this.startBubble=t)}setStartBlock(t){this.startBlock||this.startBubble||(this.startBlock=t,t.isInFlyout&&t!==t.getRootBlock()?this.setTargetBlock(t.getRootBlock()):this.setTargetBlock(t))}setTargetBlock(t){t.isShadow()?this.setTargetBlock(t.getParent()):this.targetBlock=t}setStartWorkspace(t){this.startWorkspace_||(this.startWorkspace_=t)}setStartFlyout(t){this.flyout||(this.flyout=t)}isBubbleClick(){return!!this.startBubble&&!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))}isIconClick(){if(!this.startIcon)return!1;const t=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&t}isWorkspaceClick(){return!(this.startBlock||this.startBubble||this.startField||this.hasExceededDragRadius)}isDragging(){return!!this.workspaceDragger||!!this.blockDragger||!!this.bubbleDragger}hasStarted(){return this.gestureHasStarted}getInsertionMarkers(){return this.blockDragger?this.blockDragger.getInsertionMarkers():[]}getCurrentDragger(){let t,e;return null!=(e=null!=(t=this.blockDragger)?t:this.workspaceDragger)?e:this.bubbleDragger}static inProgress(){const t=u();for(let e,s=0;e=t[s];s++)if(e.currentGesture_)return!0;return!1}},nu=class{constructor(t,e){let s,i,o;this.pattern=t,this.spacing=null!=(s=e.spacing)?s:0,this.length=null!=(i=e.length)?i:1,this.line2=(this.line1=t.firstChild)&&this.line1.nextSibling,this.snapToGrid=null!=(o=e.snap)&&o}shouldSnap(){return this.snapToGrid}getSpacing(){return this.spacing}getPatternId(){return this.pattern.id}update(t){var e=this.spacing*t;this.pattern.setAttribute("width",`${e}`),this.pattern.setAttribute("height",`${e}`);let s=(e=Math.floor(this.spacing/2)+.5)-this.length/2,i=e+this.length/2;e*=t,s*=t,i*=t,this.setLineAttributes(this.line1,t,s,i,e,e),this.setLineAttributes(this.line2,t,e,e,s,i)}setLineAttributes(t,e,s,i,o,n){t&&(t.setAttribute("stroke-width",`${e}`),t.setAttribute("x1",`${s}`),t.setAttribute("y1",`${o}`),t.setAttribute("x2",`${i}`),t.setAttribute("y2",`${n}`))}moveTo(t,e){this.pattern.setAttribute("x",`${t}`),this.pattern.setAttribute("y",`${e}`)}static createDom(t,e,s){let i,o;if(t=it(ba.PATTERN,{id:"blocklyGridPattern"+t,patternUnits:"userSpaceOnUse"},s),0<(null!=(i=e.length)?i:1)&&0<(null!=(o=e.spacing)?o:0)){let s;it(ba.LINE,{stroke:e.colour},t),null!=(s=e.length)&&s&&it(ba.LINE,{stroke:e.colour},t)}else it(ba.LINE,{},t);return t}},ru=class{constructor(t){this.workspace=t,this.cursorSvg_=this.cursor_=null,this.markers=new Map,this.markerSvg_=null}registerMarker(t,e){this.markers.has(t)&&this.unregisterMarker(t),e.setDrawer(this.workspace.getRenderer().makeMarkerDrawer(this.workspace,e)),this.setMarkerSvg(e.getDrawer().createDom()),this.markers.set(t,e)}unregisterMarker(t){const e=this.markers.get(t);if(!e)throw Error("Marker with ID "+t+" does not exist. Can only unregister markers that exist.");e.dispose(),this.markers.delete(t)}getCursor(){return this.cursor_}getMarker(t){return this.markers.get(t)||null}setCursor(t){this.cursor_&&this.cursor_.getDrawer()&&this.cursor_.getDrawer().dispose(),(this.cursor_=t)&&(t=this.workspace.getRenderer().makeMarkerDrawer(this.workspace,this.cursor_),this.cursor_.setDrawer(t),this.setCursorSvg(this.cursor_.getDrawer().createDom()))}setCursorSvg(t){t?(this.workspace.getBlockCanvas().appendChild(t),this.cursorSvg_=t):this.cursorSvg_=null}setMarkerSvg(t){t?this.workspace.getBlockCanvas()&&(this.cursorSvg_?this.workspace.getBlockCanvas().insertBefore(t,this.cursorSvg_):this.workspace.getBlockCanvas().appendChild(t)):this.markerSvg_=null}updateMarkers(){this.workspace.keyboardAccessibilityMode&&this.cursorSvg_&&this.workspace.getCursor().draw()}dispose(){const t=Object.keys(this.markers);for(let e,s=0;e=t[s];s++)this.unregisterMarker(e);this.markers.clear(),this.cursor_&&(this.cursor_.dispose(),this.cursor_=null)}};ru.LOCAL_MARKER="local_marker_1";var lu={};lu.deepMerge=_o;var au=class{constructor(e,s,i,o){this.name=e,this.startHats=!1,this.blockStyles=s||Object.create(null),this.categoryStyles=i||Object.create(null),this.componentStyles=o||Object.create(null),this.fontStyle=Object.create(null),t(Pr.THEME,e,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(t,e){this.blockStyles[t]=e}setCategoryStyle(t,e){this.categoryStyles[t]=e}getComponentStyle(t){if(!(t=this.componentStyles[t]))return null;if("string"==typeof t){const e=this.getComponentStyle(t);if(e)return e}return`${t}`}setComponentStyle(t,e){this.componentStyles[t]=e}setFontStyle(t){this.fontStyle=t}setStartHats(t){this.startHats=t}static defineTheme(t,e){t=t.toLowerCase();const s=new au(t);let i=e.base;if(i){if("string"==typeof i){let t;i=null!=(t=l(Pr.THEME,i))?t:void 0}i instanceof au&&(_o(s,i),s.name=t)}return _o(s.blockStyles,e.blockStyles),_o(s.categoryStyles,e.categoryStyles),_o(s.componentStyles,e.componentStyles),_o(s.fontStyle,e.fontStyle),null!==e.startHats&&(s.startHats=e.startHats),s}},cu=new au("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"}}),hu=class{constructor(t){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let e=null,s=!1;var i=!1,o=!1,n=!1,r=!1,l=!1;const a=!!t.readOnly;var c;a||(e=xt(null!=(c=t.toolbox)?c:null),s=Ft(e),i=void 0===(i=t.trashcan)?s:i,o=void 0===(o=t.collapse)?s:o,n=void 0===(n=t.comments)?s:n,r=void 0===(r=t.disable)?s:r,l=void 0===(l=t.sounds)||l),c=t.maxTrashcanContents,i?void 0===c&&(c=32):c=0;const h=!!t.rtl;let u=t.horizontalLayout;void 0===u&&(u=!1);var d="end"!==t.toolboxPosition;d=u?d?xa.TOP:xa.BOTTOM:d===h?xa.RIGHT:xa.LEFT;let p=t.css;void 0===p&&(p=!0);let g="https://blockly-demo.appspot.com/static/media/";t.media?g=t.media.endsWith("/")?t.media:t.media+"/":"path"in t&&(st("path","Nov 2014","Jul 2023","media"),g=t.path+"media/");const _=t.oneBasedIndex,T=t.renderer||"geras",m=t.plugins||{};let E,b,f,$=t.modalInputs;void 0===$&&($=!0),this.RTL=h,this.oneBasedIndex=void 0===_||_,this.collapse=o,this.comments=n,this.disable=r,this.readOnly=a,this.maxBlocks=t.maxBlocks||1/0,this.maxInstances=null!=(E=t.maxInstances)?E:null,this.modalInputs=$,this.pathToMedia=g,this.hasCategories=s,this.moveOptions=hu.parseMoveOptions_(t,s),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=i,this.maxTrashcanContents=c,this.hasSounds=l,this.hasCss=p,this.horizontalLayout=u,this.languageTree=e,this.gridOptions=hu.parseGridOptions_(t),this.zoomOptions=hu.parseZoomOptions_(t),this.toolboxPosition=d,this.theme=hu.parseThemeOptions_(t),this.renderer=T,this.rendererOverrides=null!=(b=t.rendererOverrides)?b:null,this.parentWorkspace=null!=(f=t.parentWorkspace)?f:null,this.plugins=m}static parseMoveOptions_(t,e){const s=t.move||{},i={};return void 0===s.scrollbars&&void 0===t.scrollbars?i.scrollbars=e:"object"==typeof s.scrollbars?(i.scrollbars={horizontal:!!s.scrollbars.horizontal,vertical:!!s.scrollbars.vertical},i.scrollbars.horizontal&&i.scrollbars.vertical?i.scrollbars=!0:i.scrollbars.horizontal||i.scrollbars.vertical||(i.scrollbars=!1)):i.scrollbars=!!s.scrollbars||!!t.scrollbars,i.wheel=i.scrollbars&&void 0!==s.wheel?!!s.wheel:"object"==typeof i.scrollbars,i.drag=!(!i.scrollbars||void 0!==s.drag&&!s.drag),i}static parseZoomOptions_(t){t=t.zoom||{};const e={};return e.controls=void 0!==t.controls&&!!t.controls,e.wheel=void 0!==t.wheel&&!!t.wheel,e.startScale=void 0===t.startScale?1:Number(t.startScale),e.maxScale=void 0===t.maxScale?3:Number(t.maxScale),e.minScale=void 0===t.minScale?.3:Number(t.minScale),e.scaleSpeed=void 0===t.scaleSpeed?1.2:Number(t.scaleSpeed),e.pinch=void 0===t.pinch?e.wheel||e.controls:!!t.pinch,e}static parseGridOptions_(t){t=t.grid||{};const e={};return e.spacing=Number(t.spacing)||0,e.colour=t.colour||"#888",e.length=void 0===t.length?1:Number(t.length),e.snap=0")),A(new uu(e,"mutation",null,s,t));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(t){return t.saveExtraState?(t=t.saveExtraState(!0))?JSON.stringify(t):"":t.mutationToDom&&(t=t.mutationToDom())?Pe(t):""}};t(Pr.EVENT,Nr.CHANGE$$module$build$src$core$events$utils,uu);var du=.45,pu=.65,gu={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"},_u={};_u.blend=Co,_u.getHsvSaturation=mo,_u.getHsvValue=bo,_u.hexToRgb=So,_u.hsvToHex=Ro,_u.hueToHex=ko,_u.names=gu,_u.parse=$o,_u.rgbToHex=Io,_u.setHsvSaturation=Eo,_u.setHsvValue=fo;var Tu={};Tu.checkMessageReferences=vo,Tu.parseBlockColour=Lo,Tu.replaceMessageReferences=Ao,Tu.tokenizeInterpolation=yo;var mu=class{constructor(t,e,s){this.DEFAULT_VALUE=null,this.name=void 0,this.constants_=this.mouseDownWrapper_=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=this.markerSvg_=this.cursorSvg_=this.tooltip_=this.validator_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.CURSOR="",this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new $a(0,0),t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){t.tooltip&&this.setTooltip(Ao(t.tooltip))}setSourceBlock(t){if(this.sourceBlock_)throw Error("Field already bound to a block");this.sourceBlock_=t}getConstants(){return!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants()),this.constants_}getSourceBlock(){return this.sourceBlock_}init(){this.fieldGroup_||(this.fieldGroup_=it(ba.G,{}),this.isVisible()||(this.fieldGroup_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip_),this.bindEvents_(),this.initModel())}initView(){this.createBorderRect_(),this.createTextElement_()}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=it(ba.RECT,{rx:this.getConstants().FIELD_BORDER_RECT_RADIUS,ry:this.getConstants().FIELD_BORDER_RECT_RADIUS,x:0,y:0,height:this.size_.height,width:this.size_.width,class:"blocklyFieldRect"},this.fieldGroup_)}createTextElement_(){this.textElement_=it(ba.TEXT,{class:"blocklyText"},this.fieldGroup_),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.textElement_.setAttribute("dominant-baseline","central"),this.textContent_=document.createTextNode(""),this.textElement_.appendChild(this.textContent_)}bindEvents_(){const t=this.getClickTarget_();if(!t)throw Error("A click target has not been set.");eo(t),this.mouseDownWrapper_=Y(t,"pointerdown",this,this.onMouseDown_)}fromXml(t){this.setValue(t.textContent)}toXml(t){return t.textContent=this.getValue(),t}saveState(t){return null!==(t=this.saveLegacyState(mu))?t:this.getValue()}loadState(t){this.loadLegacyState(mu,t)||this.setValue(t)}saveLegacyState(t){return t.prototype.saveState===this.saveState&&t.prototype.toXml!==this.toXml?((t=Nr.createElement$$module$build$src$core$utils$xml("field")).setAttribute("name",this.name||""),Mt(this.toXml(t)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(t,e){return t.prototype.loadState===this.loadState&&t.prototype.fromXml!==this.fromXml&&(this.fromXml(Nr.textToDom$$module$build$src$core$utils$xml(e)),!0)}dispose(){let t;Ai(this),Ws(this),null!=(t=this.getSourceBlock())&&t.isDeadOrDying()||at(this.fieldGroup_),this.disposed=!0}updateEditable(){const t=this.fieldGroup_,e=this.getSourceBlock();this.EDITABLE&&t&&e&&(this.enabled_&&e.isEditable()?(ot(t,"blocklyEditableText"),rt(t,"blocklyNonEditableText"),t.style.cursor=this.CURSOR):(ot(t,"blocklyNonEditableText"),rt(t,"blocklyEditableText"),t.style.cursor=""))}setEnabled(t){this.enabled_=t,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==mu.prototype.showEditor_}isClickableInFlyout(t){return!t}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){let t=!1;return this.name&&(this.SERIALIZABLE?t=!0:this.EDITABLE&&(console.warn("Detected an editable field that was not serializable. Please define SERIALIZABLE property as true on all editable custom fields. Proceeding with serialization."),t=!0)),t}isVisible(){return this.visible_}setVisible(t){if(this.visible_!==t){this.visible_=t;var e=this.fieldGroup_;e&&(e.style.display=t?"block":"none")}}setValidator(t){this.validator_=t}getValidator(){return this.validator_}getSvgRoot(){return this.fieldGroup_}getBorderRect(){if(!this.borderRect_)throw Error(`The border rectangle is ${this.borderRect_}.`);return this.borderRect_}getTextElement(){if(!this.textElement_)throw Error(`The text element is ${this.textElement_}.`);return this.textElement_}getTextContent(){if(!this.textContent_)throw Error(`The text content is ${this.textContent_}.`);return this.textContent_}applyColour(){}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_()}showEditor(t){this.isClickable()&&this.showEditor_(t)}showEditor_(t){}repositionForWindowResize(){return!1}updateSize_(t){const e=this.getConstants();let s=2*(t=void 0!==t?t:this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING),i=e.FIELD_TEXT_HEIGHT,o=0;this.textElement_&&(o=_t(this.textElement_,e.FIELD_TEXT_FONTSIZE,e.FIELD_TEXT_FONTWEIGHT,e.FIELD_TEXT_FONTFAMILY),s+=o),this.isFullBlockField()||(i=Math.max(i,e.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=i,this.size_.width=s,this.positionTextElement_(t,o),this.positionBorderRect_()}positionTextElement_(t,e){if(this.textElement_){var s,i=this.getConstants(),o=this.size_.height/2;this.textElement_.setAttribute("x",String(null!=(s=this.getSourceBlock())&&s.RTL?this.size_.width-e-t:t)),this.textElement_.setAttribute("y",String(i.FIELD_TEXT_BASELINE_CENTER?o:o-i.FIELD_TEXT_HEIGHT/2+i.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_?(this.render_(),this.isDirty_=!1):this.visible_&&0===this.size_.width&&(this.render_(),0!==this.size_.width&&console.warn("Deprecated use of setting size_.width to 0 to rerender a field. Set field.isDirty_ to true instead.")),this.size_):new $a(0,0)}getScaledBBox(){let t;var e=this.getSourceBlock();if(!e)throw new Eu;if(this.isFullBlockField()){var s=this.sourceBlock_.getHeightWidth();const i=e.workspace.scale;t=this.getAbsoluteXY_(),e=(s.width+1)*i,s=(s.height+1)*i,Kl?(t.x+=1.5*i,t.y+=1.5*i):(t.x-=.5*i,t.y-=.5*i)}else s=this.borderRect_.getBoundingClientRect(),t=It(this.borderRect_),e=s.width,s=s.height;return new fa(t.y,t.y+s,t.x,t.x+e)}onLocationChange(t){}getDisplayText_(){let t=this.getText();return t?(t.length>this.maxDisplayLength&&(t=t.substring(0,this.maxDisplayLength-2)+"…"),t=t.replace(/\s/g,mu.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(t+="‏"),t):mu.NBSP}getText(){const t=this.getText_();return String(null!==t?t:this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.queueRender(),this.sourceBlock_.bumpNeighbours())}setValue(t,e=!0){if(null!==t){var s,i=this.doClassValidation_(t);(t=this.processValidation_(t,i))instanceof Error||(i=null==(s=this.getValidator())?void 0:s.call(this,t),(s=this.processValidation_(t,i))instanceof Error||(t=this.sourceBlock_)&&t.disposed||((i=this.getValue())===s?this.doValueUpdate_(s):(this.doValueUpdate_(s),e&&t&&M()&&A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(t,"field",this.name||null,i,s)),this.isDirty_&&this.forceRerender())))}}processValidation_(t,e){return null===e?(this.doValueInvalid_(t),this.isDirty_&&this.forceRerender(),Error()):void 0===e?t:e}getValue(){return this.value_}doClassValidation_(t){return null==t?null:t}doValueUpdate_(t){this.value_=t,this.isDirty_=!0}doValueInvalid_(t){}onMouseDown_(t){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(t=this.sourceBlock_.workspace.getGesture(t))&&t.setStartField(this)}setTooltip(t){t||""===t||(t=this.sourceBlock_);const e=this.getClickTarget_();e?e.tooltip=t:this.tooltip_=t}getTooltip(){const t=this.getClickTarget_();return Zi(t||{tooltip:this.tooltip_})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return It(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let t=null;const e=this.getSourceBlock();if(!e)throw new Eu;const s=e.inputList;for(let i=0;ie[1]===t))?t:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+t),null)}doValueUpdate_(t){super.doValueUpdate_(t),t=this.getOptions(!0);for(let e,s=0;e=t[s];s++)e[1]===this.value_&&(this.selectedOption=e)}applyColour(){const t=this.sourceBlock_.style;this.borderRect_&&(this.borderRect_.setAttribute("stroke",t.colourTertiary),this.menu_?this.borderRect_.setAttribute("fill",t.colourTertiary):this.borderRect_.setAttribute("fill","transparent")),this.sourceBlock_&&this.arrow&&(this.sourceBlock_.isShadow()?this.arrow.style.fill=t.colourSecondary:this.arrow.style.fill=t.colourPrimary)}render_(){this.getTextContent().nodeValue="",this.imageElement.style.display="none";const t=this.selectedOption&&this.selectedOption[0];t&&"object"==typeof t?this.renderSelectedImage(t):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(t){const e=this.getSourceBlock();if(!e)throw new Eu;this.imageElement.style.display="",this.imageElement.setAttributeNS(ga,"xlink:href",t.src),this.imageElement.setAttribute("height",String(t.height)),this.imageElement.setAttribute("width",String(t.width));const s=Number(t.height);t=Number(t.width);var i=!!this.borderRect_;const o=Math.max(i?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,s+Cu);let n;i=i?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,n=this.svgArrow?this.positionSVGArrow(t+i,o/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):_t(this.arrow,this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY),this.size_.width=t+n+2*i,this.size_.height=o;let r=0;e.RTL?this.imageElement.setAttribute("x",`${i+n}`):(r=t+n,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${i}`)),this.imageElement.setAttribute("y",String(o/2-s/2)),this.positionTextElement_(r+i,t+n)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var t=this.getTextElement();ot(t,"blocklyDropdownText"),t.setAttribute("text-anchor","start");var e=!!this.borderRect_;t=Math.max(e?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);const s=_t(this.getTextElement(),this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY);e=e?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let i=0;this.svgArrow&&(i=this.positionSVGArrow(s+e,t/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=s+i+2*e,this.size_.height=t,this.positionTextElement_(e,s)}positionSVGArrow(t,e){if(!this.svgArrow)return 0;const s=this.getSourceBlock();if(!s)throw new Eu;const i=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,o=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,n=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute("transform","translate("+(s.RTL?i:t+o)+","+e+")"),n+o}getText_(){if(!this.selectedOption)return null;const t=this.selectedOption[0];return"object"==typeof t?t.alt:t}static fromJson(t){if(!t.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(t.options,void 0,t)}};Ru.CHECKMARK_OVERHANG=25,Ru.MAX_MENU_HEIGHT_VH=.45,Ru.ARROW_CHAR="▾";var Cu=10;Mo("field_dropdown",Ru);var ku,Ou=class{constructor(t,e,s){this.workspace=t,this.anchor=e,this.ownerRect=s,this.size=new $a(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.svgRoot=it(ba.G,{},t.getBubbleCanvas()),t=it(ba.G,{filter:`url(#${this.workspace.getRenderer().getConstants().embossFilterId})`},this.svgRoot),this.tail=it(ba.PATH,{},t),this.background=it(ba.RECT,{class:"blocklyDraggable",x:0,y:0,rx:ku.BORDER_WIDTH,ry:ku.BORDER_WIDTH},t),this.contentContainer=it(ba.G,{},this.svgRoot),Y(this.background,"pointerdown",this,this.onMouseDown)}dispose(){at(this.svgRoot),this.disposed=!0}setAnchorLocation(t,e=!1){this.anchor=t,e?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}setPositionRelativeToAnchor(t,e){this.relativeLeft=t,this.relativeTop=e,this.positionRelativeToAnchor(),this.renderTail()}getSize(){return this.size}setSize(t,e=!1){t.width=Math.max(t.width,ku.MIN_SIZE),t.height=Math.max(t.height,ku.MIN_SIZE),this.size=t,this.background.setAttribute("width",`${t.width}`),this.background.setAttribute("height",`${t.height}`),e?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}getColour(){return this.colour}setColour(t){this.colour=t,this.tail.setAttribute("fill",t),this.background.setAttribute("fill",t)}onMouseDown(t){let e;null==(e=this.workspace.getGesture(t))||e.handleBubbleStart(t,this)}positionRelativeToAnchor(){let t=this.anchor.x;t=this.workspace.RTL?t-(this.relativeLeft+this.size.width):t+this.relativeLeft,this.moveTo(t,this.relativeTop+this.anchor.y)}moveTo(t,e){this.svgRoot.setAttribute("transform",`translate(${t}, ${e})`)}positionByRect(t=new fa(0,0,0,0)){var e=this.workspace.getMetricsManager().getViewMetrics(!0),s=this.getOptimalRelativeLeft(e),i=this.getOptimalRelativeTop(e);const o={x:s,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},n={x:-this.size.width-30,y:i};i={x:t.getWidth(),y:i};var r={x:s,y:t.getHeight()};s=t.getWidth()t.width)return e;if(t=this.getWorkspaceViewRect(t),this.workspace.RTL){var s=this.anchor.x-e;s-this.size.widtht.right&&(e=-(t.right-this.anchor.x))}else{const i=(s=e+this.anchor.x)+this.size.width;st.right&&(e=t.right-this.anchor.x-this.size.width)}return e}getOptimalRelativeTop(t){let e=-this.size.height/4;if(this.size.height>t.height)return e;const s=this.anchor.y+e,i=s+this.size.height;return s<(t=this.getWorkspaceViewRect(t)).top?e=t.top-this.anchor.y:i>t.bottom&&(e=t.bottom-this.anchor.y-this.size.height),e}getWorkspaceViewRect(t){const e=t.top;let s=t.top+t.height,i=t.left;return t=t.left+t.width,s-=this.getScrollbarThickness(),this.workspace.RTL?i-=this.getScrollbarThickness():t-=this.getScrollbarThickness(),new fa(e,s,i,t)}getScrollbarThickness(){return Oa.scrollbarThickness/this.workspace.scale}renderTail(){const t=[];var e=this.size.width/2,s=this.size.height/2,i=-this.relativeLeft,o=-this.relativeTop;if(e===i&&s===o)t.push("M "+e+","+s);else{o-=s,i-=e,this.workspace.RTL&&(i*=-1);var n=Math.sqrt(o*o+i*i),r=Math.acos(i/n);0>o&&(r=2*Math.PI-r);var l=r+Math.PI/2;l>2*Math.PI&&(l-=2*Math.PI);var a=Math.sin(l);const c=Math.cos(l);let h=(this.size.width+this.size.height)/ku.TAIL_THICKNESS;h=Math.min(h,this.size.width,this.size.height)/4,i=e+(l=1-ku.ANCHOR_RADIUS/n)*i,o=s+l*o,l=e+h*c;const u=s+h*a;e-=h*c,s-=h*a,(a=r+(a=ci(this.workspace.RTL?-ku.TAIL_ANGLE:ku.TAIL_ANGLE)))>2*Math.PI&&(a-=2*Math.PI),r=Math.sin(a)*n/ku.TAIL_BEND,n=Math.cos(a)*n/ku.TAIL_BEND,t.push("M"+l+","+u),t.push("C"+(l+n)+","+(u+r)+" "+i+","+o+" "+i+","+o),t.push("C"+i+","+o+" "+(e+n)+","+(s+r)+" "+e+","+s)}let c;t.push("z"),null==(c=this.tail)||c.setAttribute("d",t.join(" "))}bringToFront(){let t;const e=null==(t=this.svgRoot)?void 0:t.parentNode;return!(!this.svgRoot||(null==e?void 0:e.lastChild)===this.svgRoot||(null==e||e.appendChild(this.svgRoot),0))}getRelativeToSurfaceXY(){return new ca(this.workspace.RTL?-this.relativeLeft+this.anchor.x-this.size.width:this.anchor.x+this.relativeLeft,this.anchor.y+this.relativeTop)}getSvgRoot(){return this.svgRoot}moveDuringDrag(t){this.moveTo(t.x,t.y),this.relativeLeft=this.workspace.RTL?this.anchor.x-t.x-this.size.width:t.x-this.anchor.x,this.relativeTop=t.y-this.anchor.y,this.renderTail()}setDragging(t){}setDeleteStyle(t){}isDeletable(){return!1}showContextMenu(t){}};ku=Ou,Ou.BORDER_WIDTH=6,Ou.DOUBLE_BORDER=2*ku.BORDER_WIDTH,Ou.MIN_SIZE=ku.DOUBLE_BORDER,Ou.TAIL_THICKNESS=1,Ou.TAIL_ANGLE=20,Ou.TAIL_BEND=4,Ou.ANCHOR_RADIUS=8;var yu=class extends Ou{constructor(t,e,s,i){let o,n;super(e,s,i),this.workspace=e,this.anchor=s,this.ownerRect=i,this.autoLayout=!0,e=new hu(t),this.validateWorkspaceOptions(e),this.svgDialog=it(ba.SVG,{x:Ou.BORDER_WIDTH,y:Ou.BORDER_WIDTH},this.contentContainer),t.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new hu(t)),this.miniWorkspace.internalIsMutator=!0,t=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(t),e.languageTree&&(t.insertBefore(this.miniWorkspace.addFlyout(ba.G),this.miniWorkspace.getCanvas()),null==(t=this.miniWorkspace.getFlyout())||t.init(this.miniWorkspace),null==t||t.show(e.languageTree)),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this)),null==(o=this.miniWorkspace.getFlyout())||null==(n=o.getWorkspace())||n.addChangeListener(this.onWorkspaceChange.bind(this)),this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose(),super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(t){this.miniWorkspace.addChangeListener(t)}validateWorkspaceOptions(t){if(t.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");if(t.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(t.zoomOptions.controls||t.zoomOptions.wheel||t.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(t.moveOptions.scrollbars||t.moveOptions.wheel||t.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(t.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts")}onWorkspaceChange(){this.bumpBlocksIntoBounds(),this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging())for(const t of this.miniWorkspace.getTopBlocks(!1)){const e=t.getRelativeToSurfaceXY();if(20>e.y&&t.moveBy(0,20-e.y),t.RTL){let s=-20;const i=this.miniWorkspace.getFlyout();i&&(s-=i.getWidth()),e.x>s&&t.moveBy(s-e.x,0)}else 20>e.x&&t.moveBy(20-e.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()){var t=this.getSize(),e=this.calculateWorkspaceSize();Math.abs(t.width-e.width)({kind:"block",type:t})))}),e}getAnchorLocation(){return ca.sum(this.workspaceLocation,new ca(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new fa(t.y,t.y+t.height,t.x,t.x+t.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");for(var t of(this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace()),this.rootBlock.getDescendants(!1)))t.queueRender();let e,s,i,o;this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1),t=null!=(o=null==(e=this.miniWorkspaceBubble)||null==(s=e.getWorkspace())||null==(i=s.getFlyout())?void 0:i.getWidth())?o:0,this.rootBlock.moveBy(this.rootBlock.RTL?-(t+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 t=>{Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(t)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout((()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()}),0))}}static isIgnorableMutatorEvent(t){return t.isUiEvent||t.type===Nr.CREATE$$module$build$src$core$events$utils||t.type===Nr.CHANGE$$module$build$src$core$events$utils&&"disabled"===t.element}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var t=Nr.getGroup$$module$build$src$core$events$utils();t||Nr.setGroup$$module$build$src$core$events$utils(!0);var e=uu.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var s=uu.getExtraBlockState_(this.sourceBlock);e!==s&&A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"mutation",null,e,s)),Nr.setGroup$$module$build$src$core$events$utils(t)}}getWorkspace(){let t;return null==(t=this.miniWorkspaceBubble)?void 0:t.getWorkspace()}static reconnect(t,e,s){return st("MutatorIcon.reconnect","v10","v11","connection.reconnect"),!!t&&t.reconnect(e,s)}static findParentWs(t){return st("MutatorIcon.findParentWs","v10","v11","workspace.getRootWorkspace"),t.getRootWorkspace()}},Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=ja.MUTATOR,Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon;var Au=Object.create(null),vu={allExtensions:Au};Nr.register$$module$build$src$core$extensions("parent_tooltip_when_inline",Qo);var Lu,wu={TEST_ONLY:vu};wu.apply=Go,wu.buildTooltipForDropdown=Nr.buildTooltipForDropdown$$module$build$src$core$extensions,wu.buildTooltipWithFieldText=Nr.buildTooltipWithFieldText$$module$build$src$core$extensions,wu.isRegistered=Ho,wu.register=Nr.register$$module$build$src$core$extensions,wu.registerMixin=Nr.registerMixin$$module$build$src$core$extensions,wu.registerMutator=Nr.registerMutator$$module$build$src$core$extensions,wu.runAfterPageLoad=qo,wu.unregister=Uo,function(t){t[t.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX",t[t.MAC_ENTER=3]="MAC_ENTER",t[t.BACKSPACE=8]="BACKSPACE",t[t.TAB=9]="TAB",t[t.NUM_CENTER=12]="NUM_CENTER",t[t.ENTER=13]="ENTER",t[t.SHIFT=16]="SHIFT",t[t.CTRL=17]="CTRL",t[t.ALT=18]="ALT",t[t.PAUSE=19]="PAUSE",t[t.CAPS_LOCK=20]="CAPS_LOCK",t[t.ESC=27]="ESC",t[t.SPACE=32]="SPACE",t[t.PAGE_UP=33]="PAGE_UP",t[t.PAGE_DOWN=34]="PAGE_DOWN",t[t.END=35]="END",t[t.HOME=36]="HOME",t[t.LEFT=37]="LEFT",t[t.UP=38]="UP",t[t.RIGHT=39]="RIGHT",t[t.DOWN=40]="DOWN",t[t.PLUS_SIGN=43]="PLUS_SIGN",t[t.PRINT_SCREEN=44]="PRINT_SCREEN",t[t.INSERT=45]="INSERT",t[t.DELETE=46]="DELETE",t[t.ZERO=48]="ZERO",t[t.ONE=49]="ONE",t[t.TWO=50]="TWO",t[t.THREE=51]="THREE",t[t.FOUR=52]="FOUR",t[t.FIVE=53]="FIVE",t[t.SIX=54]="SIX",t[t.SEVEN=55]="SEVEN",t[t.EIGHT=56]="EIGHT",t[t.NINE=57]="NINE",t[t.FF_SEMICOLON=59]="FF_SEMICOLON",t[t.FF_EQUALS=61]="FF_EQUALS",t[t.FF_DASH=173]="FF_DASH",t[t.FF_HASH=163]="FF_HASH",t[t.QUESTION_MARK=63]="QUESTION_MARK",t[t.AT_SIGN=64]="AT_SIGN",t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.J=74]="J",t[t.K=75]="K",t[t.L=76]="L",t[t.M=77]="M",t[t.N=78]="N",t[t.O=79]="O",t[t.P=80]="P",t[t.Q=81]="Q",t[t.R=82]="R",t[t.S=83]="S",t[t.T=84]="T",t[t.U=85]="U",t[t.V=86]="V",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.Z=90]="Z",t[t.META=91]="META",t[t.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT",t[t.CONTEXT_MENU=93]="CONTEXT_MENU",t[t.NUM_ZERO=96]="NUM_ZERO",t[t.NUM_ONE=97]="NUM_ONE",t[t.NUM_TWO=98]="NUM_TWO",t[t.NUM_THREE=99]="NUM_THREE",t[t.NUM_FOUR=100]="NUM_FOUR",t[t.NUM_FIVE=101]="NUM_FIVE",t[t.NUM_SIX=102]="NUM_SIX",t[t.NUM_SEVEN=103]="NUM_SEVEN",t[t.NUM_EIGHT=104]="NUM_EIGHT",t[t.NUM_NINE=105]="NUM_NINE",t[t.NUM_MULTIPLY=106]="NUM_MULTIPLY",t[t.NUM_PLUS=107]="NUM_PLUS",t[t.NUM_MINUS=109]="NUM_MINUS",t[t.NUM_PERIOD=110]="NUM_PERIOD",t[t.NUM_DIVISION=111]="NUM_DIVISION",t[t.F1=112]="F1",t[t.F2=113]="F2",t[t.F3=114]="F3",t[t.F4=115]="F4",t[t.F5=116]="F5",t[t.F6=117]="F6",t[t.F7=118]="F7",t[t.F8=119]="F8",t[t.F9=120]="F9",t[t.F10=121]="F10",t[t.F11=122]="F11",t[t.F12=123]="F12",t[t.NUMLOCK=144]="NUMLOCK",t[t.SCROLL_LOCK=145]="SCROLL_LOCK",t[t.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY",t[t.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY",t[t.SEMICOLON=186]="SEMICOLON",t[t.DASH=189]="DASH",t[t.EQUALS=187]="EQUALS",t[t.COMMA=188]="COMMA",t[t.PERIOD=190]="PERIOD",t[t.SLASH=191]="SLASH",t[t.APOSTROPHE=192]="APOSTROPHE",t[t.TILDE=192]="TILDE",t[t.SINGLE_QUOTE=222]="SINGLE_QUOTE",t[t.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET",t[t.BACKSLASH=220]="BACKSLASH",t[t.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET",t[t.WIN_KEY=224]="WIN_KEY",t[t.MAC_FF_META=224]="MAC_FF_META",t[t.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT",t[t.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT",t[t.WIN_IME=229]="WIN_IME",t[t.VK_NONAME=252]="VK_NONAME",t[t.PHANTOM=255]="PHANTOM"}(Lu||(Lu={}));var Nu={};Nu.arc=an,Nu.curve=en,Nu.line=rn,Nu.lineOnAxis=ln,Nu.lineTo=nn,Nu.moveBy=on,Nu.moveTo=sn,Nu.point=tn;var Mu={};Mu.Coordinate=ca,Mu.KeyCodes=Lu,Mu.Rect=fa,Mu.Size=$a,Mu.Svg=ba,Mu.aria=qc,Mu.array=ia,Mu.browserEvents=sa,Mu.colour=_u,Mu.deprecation=ha,Mu.dom=Ea,Mu.extensions=wu,Mu.idGenerator=Sl,Mu.math=gh,Mu.object=lu,Mu.parsing=Tu,Mu.string=Fh,Mu.style=Sa,Mu.svgMath=ka,Mu.svgPaths=Nu,Mu.toolbox=Va,Mu.userAgent=Ql,Mu.xml=Da;var Du={};Du.register=cn,Du.unregister=hn;var xu=class extends Ou{constructor(t,e,s,i){super(e,s,i),this.text=t,this.workspace=e,this.anchor=s,this.ownerRect=i,this.paragraph=this.stringToSvg(t,this.contentContainer),this.updateBubbleSize()}getText(){return this.text}setText(t){this.text=t,at(this.paragraph),this.paragraph=this.stringToSvg(t,this.contentContainer),this.updateBubbleSize()}stringToSvg(t,e){return e=this.createParagraph(e),t=this.createSpans(e,t),this.workspace.RTL&&this.rightAlignSpans(e.getBBox().width,t),e}createParagraph(t){return it(ba.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:Ou.BORDER_WIDTH},t)}createSpans(t,e){return e.split("\n").map((e=>{const s=it(ba.TSPAN,{dy:"1em",x:Ou.BORDER_WIDTH},t);return e=document.createTextNode(e),s.appendChild(e),s}))}rightAlignSpans(t,e){for(const s of e)s.setAttribute("text-anchor","end"),s.setAttribute("x",`${t+Ou.BORDER_WIDTH}`)}updateBubbleSize(){const t=this.paragraph.getBBox();this.setSize(new $a(t.width+2*Ou.BORDER_WIDTH,t.height+2*Ou.BORDER_WIDTH),!0)}},Bu=class extends Ou{constructor(t,e,s){super(t,e,s),this.workspace=t,this.anchor=e,this.ownerRect=s,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.textChangeListeners=[],this.sizeChangeListeners=[],this.text="",this.DEFAULT_SIZE=new $a(160+Ou.DOUBLE_BORDER,80+Ou.DOUBLE_BORDER),this.MIN_SIZE=new $a(45+Ou.DOUBLE_BORDER,20+Ou.DOUBLE_BORDER),({inputRoot:this.inputRoot,textArea:this.textArea}=this.createEditor(this.contentContainer)),this.resizeGroup=this.createResizeHandle(this.svgRoot),this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.text}setText(t){this.text=t,this.textArea.value=t,this.onTextChange()}addTextChangeListener(t){this.textChangeListeners.push(t)}addSizeChangeListener(t){this.sizeChangeListeners.push(t)}createEditor(t){t=it(ba.FOREIGNOBJECT,{x:Ou.BORDER_WIDTH,y:Ou.BORDER_WIDTH},t);const e=document.createElementNS(pa,"body");e.setAttribute("xmlns",pa),e.className="blocklyMinimalBody";const s=document.createElementNS(pa,"textarea");return s.className="blocklyCommentTextarea",s.setAttribute("dir",this.workspace.RTL?"RTL":"LTR"),e.appendChild(s),t.appendChild(e),this.bindTextAreaEvents(s),setTimeout((()=>{s.focus()}),0),{inputRoot:t,textArea:s}}bindTextAreaEvents(t){Y(t,"wheel",this,(t=>{t.stopPropagation()})),Y(t,"focus",this,this.onStartEdit,!0),Y(t,"change",this,this.onTextChange)}createResizeHandle(t){t=it(ba.G,{class:this.workspace.RTL?"blocklyResizeSW":"blocklyResizeSE"},t);const e=2*Ou.BORDER_WIDTH;return it(ba.POLYGON,{points:`0,${e} ${e},${e} ${e},0`},t),it(ba.LINE,{class:"blocklyResizeLine",x1:e/3,y1:e-1,x2:e-1,y2:e/3},t),it(ba.LINE,{class:"blocklyResizeLine",x1:2*e/3,y1:e-1,x2:e-1,y2:2*e/3},t),Y(t,"pointerdown",this,this.onResizePointerDown),t}setSize(t,e=!1){t.width=Math.max(t.width,this.MIN_SIZE.width),t.height=Math.max(t.height,this.MIN_SIZE.height);const s=t.width-Ou.DOUBLE_BORDER,i=t.height-Ou.DOUBLE_BORDER;this.inputRoot.setAttribute("width",`${s}`),this.inputRoot.setAttribute("height",`${i}`),this.textArea.style.width=s-4+"px",this.textArea.style.height=i-4+"px",this.workspace.RTL?this.resizeGroup.setAttribute("transform",`translate(${Ou.DOUBLE_BORDER}, ${i}) scale(-1 1)`):this.resizeGroup.setAttribute("transform",`translate(${s}, ${i})`),super.setSize(t,e),this.onSizeChange()}getSize(){return super.getSize()}onResizePointerDown(t){this.bringToFront(),J(t)||(this.workspace.startDrag(t,new ca(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=Y(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=Y(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),t.stopPropagation()}onResizePointerUp(t){G(),this.resizePointerUpListener&&(z(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(z(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(t){t=this.workspace.moveDrag(t),this.setSize(new $a(this.workspace.RTL?-t.x:t.x,t.y),!1),this.onSizeChange()}onStartEdit(){this.bringToFront()&&this.textArea.focus()}onTextChange(){this.text=this.textArea.value;for(const t of this.textChangeListeners)t()}onSizeChange(){for(const t of this.sizeChangeListeners)t()}};tt("\n.blocklyCommentTextarea {\n background-color: #fef49c;\n border: 0;\n display: block;\n margin: 0;\n outline: 0;\n padding: 3px;\n resize: none;\n text-overflow: hidden;\n}\n");var Pu=class extends $u{constructor(t){super(t),this.sourceBlock=t,this.textBubble=this.textInputBubble=null,this.text="",this.bubbleSize=new $a(160,80),this.bubbleVisiblity=!1}getType(){return Pu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(ba.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),it(ba.PATH,{class:"blocklyIconSymbol",d:"m6.8,10h2c0.003,-0.617 0.271,-0.962 0.633,-1.266 2.875,-2.4050.607,-5.534 -3.765,-3.874v1.7c3.12,-1.657 3.698,0.118 2.336,1.25-1.201,0.998 -1.201,1.528 -1.204,2.19z"},this.svgRoot),it(ba.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),ot(this.svgRoot,"blockly-icon-comment"))}dispose(){let t,e;super.dispose(),null==(t=this.textInputBubble)||t.dispose(),null==(e=this.textBubble)||e.dispose()}getWeight(){return Pu.WEIGHT}getSize(){return new $a(17,17)}applyColour(){super.applyColour();const t=this.sourceBlock.style.colourPrimary;let e,s;null==(e=this.textInputBubble)||e.setColour(t),null==(s=this.textBubble)||s.setColour(t)}updateEditable(){super.updateEditable(),this.bubbleIsVisible()&&(this.setBubbleVisible(!1),this.setBubbleVisible(!0))}onLocationChange(t){let e,s;super.onLocationChange(t),t=this.getAnchorLocation(),null==(e=this.textInputBubble)||e.setAnchorLocation(t),null==(s=this.textBubble)||s.setAnchorLocation(t)}setText(t){const e=this.text;let s,i;A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"comment",null,e,t)),this.text=t,null==(s=this.textInputBubble)||s.setText(this.text),null==(i=this.textBubble)||i.setText(this.text)}getText(){return this.text}setBubbleSize(t){let e;this.bubbleSize=t,null==(e=this.textInputBubble)||e.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}saveState(){return this.text?{text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width}:null}loadState(t){let e,s,i,o;this.text=null!=(e=t.text)?e:"",this.bubbleSize=new $a(null!=(s=t.width)?s:160,null!=(i=t.height)?i:80),this.bubbleVisiblity=null!=(o=t.pinned)&&o,setTimeout((()=>this.setBubbleVisible(this.bubbleVisiblity)),1)}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var t=this.textInputBubble.getText();this.text!==t&&(A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"comment",null,this.text,t)),this.text=t)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(t){t&&(this.textBubble||this.textInputBubble)||(t||this.textBubble||this.textInputBubble)&&(this.bubbleVisiblity=t,this.sourceBlock.rendered&&!this.sourceBlock.isInFlyout&&(t?(this.sourceBlock.isEditable()?this.showEditableBubble():this.showNonEditableBubble(),this.applyColour()):this.hideBubble(),A(new(P(rl))(this.sourceBlock,t,"comment"))))}showEditableBubble(){this.textInputBubble=new Bu(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.textInputBubble.setText(this.getText()),this.textInputBubble.setSize(this.bubbleSize,!0),this.textInputBubble.addTextChangeListener((()=>this.onTextChange())),this.textInputBubble.addSizeChangeListener((()=>this.onSizeChange()))}showNonEditableBubble(){this.textBubble=new xu(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect())}hideBubble(){let t,e;null==(t=this.textInputBubble)||t.dispose(),this.textInputBubble=null,null==(e=this.textBubble)||e.dispose(),this.textBubble=null}getAnchorLocation(){return ca.sum(this.workspaceLocation,new ca(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new fa(t.y,t.y+t.height,t.x,t.x+t.width)}};Pu.TYPE=ja.COMMENT,Pu.WEIGHT=3,cn(Pu.TYPE,Pu);var Fu=class extends $u{constructor(t){super(t),this.sourceBlock=t,this.textMap=new Map,this.textBubble=null}getType(){return Fu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(ba.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),it(ba.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),it(ba.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),ot(this.svgRoot,"blockly-icon-warning"))}dispose(){let t;super.dispose(),null==(t=this.textBubble)||t.dispose()}getWeight(){return Fu.WEIGHT}getSize(){return new $a(17,17)}applyColour(){let t;super.applyColour(),null==(t=this.textBubble)||t.setColour(this.sourceBlock.style.colourPrimary)}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(t){let e;super.onLocationChange(t),null==(e=this.textBubble)||e.setAnchorLocation(this.getAnchorLocation())}addMessage(t,e){if(this.textMap.get(e)===t)return this;let s;return t?this.textMap.set(e,t):this.textMap.delete(e),null==(s=this.textBubble)||s.setText(this.getText()),this}getText(){return[...this.textMap.values()].join("\n")}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(t){if(this.bubbleIsVisible()!==t){if(t)this.textBubble=new xu(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.applyColour();else{let t;null==(t=this.textBubble)||t.dispose(),this.textBubble=null}A(new(P(rl))(this.sourceBlock,t,"warning"))}}getAnchorLocation(){return ca.sum(this.workspaceLocation,new ca(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new fa(t.y,t.y+t.height,t.x,t.x+t.width)}};Fu.TYPE=ja.WARNING,Fu.WEIGHT=2;var Uu=class extends Error{constructor(t){super(`Tried to append an icon of type ${t.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`),this.icon=t}},Hu={};Hu.DuplicateIconType=Uu;var Gu,Vu,Wu={};Wu.CommentIcon=Pu,Wu.Icon=$u,Wu.IconType=ja,Wu.MutatorIcon=Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon,Wu.WarningIcon=Fu,Wu.exceptions=Hu,Wu.registry=Du,Gu="PROCEDURE",Nr.DEFAULT_ARG$$module$build$src$core$procedures="x",(Vu={CATEGORY_NAME:Gu,DEFAULT_ARG:Nr.DEFAULT_ARG$$module$build$src$core$procedures}).ObservableProcedureMap=fu,Vu.allProcedures=un,Vu.findLegalName=Nr.findLegalName$$module$build$src$core$procedures,Vu.flyoutCategory=_n,Vu.getCallers=bn,Vu.getDefinition=Nr.getDefinition$$module$build$src$core$procedures,Vu.isNameUsed=gn,Vu.isProcedureBlock=wo,Vu.mutateCallers=Nr.mutateCallers$$module$build$src$core$procedures,Vu.mutatorOpenListener=mn,Vu.rename=Nr.rename$$module$build$src$core$procedures;var Xu=new class{constructor(){this.NONE=0,this.FIELD=1,this.HAT=2,this.ICON=4,this.SPACER=8,this.BETWEEN_ROW_SPACER=16,this.IN_ROW_SPACER=32,this.EXTERNAL_VALUE_INPUT=64,this.INPUT=128,this.INLINE_INPUT=256,this.STATEMENT_INPUT=512,this.CONNECTION=1024,this.PREVIOUS_CONNECTION=2048,this.NEXT_CONNECTION=4096,this.OUTPUT_CONNECTION=8192,this.CORNER=16384,this.LEFT_SQUARE_CORNER=32768,this.LEFT_ROUND_CORNER=65536,this.RIGHT_SQUARE_CORNER=131072,this.RIGHT_ROUND_CORNER=262144,this.JAGGED_EDGE=524288,this.ROW=1048576,this.TOP_ROW=2097152,this.BOTTOM_ROW=4194304,this.INPUT_ROW=8388608,this.LEFT_CORNER=this.LEFT_SQUARE_CORNER|this.LEFT_ROUND_CORNER,this.RIGHT_CORNER=this.RIGHT_SQUARE_CORNER|this.RIGHT_ROUND_CORNER,this.nextTypeValue_=16777216}getType(t){return Object.prototype.hasOwnProperty.call(this,t)||(this[t]=this.nextTypeValue_,this.nextTypeValue_<<=1),this[t]}isField(t){return t.type&this.FIELD}isHat(t){return t.type&this.HAT}isIcon(t){return t.type&this.ICON}isSpacer(t){return t.type&this.SPACER}isInRowSpacer(t){return t.type&this.IN_ROW_SPACER}isInput(t){return t.type&this.INPUT}isExternalInput(t){return t.type&this.EXTERNAL_VALUE_INPUT}isInlineInput(t){return t.type&this.INLINE_INPUT}isStatementInput(t){return t.type&this.STATEMENT_INPUT}isPreviousConnection(t){return t.type&this.PREVIOUS_CONNECTION}isNextConnection(t){return t.type&this.NEXT_CONNECTION}isPreviousOrNextConnection(t){return t.type&(this.PREVIOUS_CONNECTION|this.NEXT_CONNECTION)}isLeftRoundedCorner(t){return t.type&this.LEFT_ROUND_CORNER}isRightRoundedCorner(t){return t.type&this.RIGHT_ROUND_CORNER}isLeftSquareCorner(t){return t.type&this.LEFT_SQUARE_CORNER}isRightSquareCorner(t){return t.type&this.RIGHT_SQUARE_CORNER}isCorner(t){return t.type&this.CORNER}isJaggedEdge(t){return t.type&this.JAGGED_EDGE}isRow(t){return t.type&this.ROW}isBetweenRowSpacer(t){return t.type&this.BETWEEN_ROW_SPACER}isTopRow(t){return t.type&this.TOP_ROW}isBottomRow(t){return t.type&this.BOTTOM_ROW}isTopOrBottomRow(t){return t.type&(this.TOP_ROW|this.BOTTOM_ROW)}isInputRow(t){return t.type&this.INPUT_ROW}},Yu=class{constructor(t){this.centerline=this.xPos=this.height=this.width=0,this.constants_=t,this.type=Xu.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},Ku=class{constructor(t){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_=t,this.type=Xu.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let t=this.elements.length-1;0<=t;t--){const e=this.elements[t];if(Xu.isInput(e))return e}return null}measure(){throw Error("Unexpected attempt to measure a base Row.")}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let t=0;trect,`,`${t} .blocklyEditableText>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${t} .blocklyNonEditableText>text,`,`${t} .blocklyEditableText>text {`,"fill: #000;","}",`${t} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${t} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${t} .blocklyEditableText:not(.editing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${t} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${t} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${t} .blocklyHighlightedConnectionPath {`,"stroke: #fc3;","}",`${t} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${t} .blocklyReplaceable .blocklyPathLight,`,`${t} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${t} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},gd={};gd.ConstantProvider=pd,gd.isDynamicShape=$n;var _d=class{constructor(t,e){this.inlinePath_=this.outlinePath_="",this.block_=t,this.info_=e,this.topLeft_=t.getRelativeToSurfaceXY(),this.constants_=e.getRenderer().getConstants()}draw(){this.drawOutline_(),this.drawInternals_(),this.block_.pathObject.setPath(this.outlinePath_+"\n"+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),this.recordSizeOnBlock_()}hideHiddenIcons_(){st("hideHiddenIcons_","v10","v11")}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren}drawOutline_(){this.drawTop_();for(let t=1;tt||t>this.fieldRow.length)throw Error("index "+t+" out of bounds.");return e||""===e&&s?("string"==typeof e&&(e=Nr.fromJson$$module$build$src$core$field_registry({type:"field_label",text:e})),e.setSourceBlock(this.sourceBlock),this.sourceBlock.rendered&&(e.init(),e.applyColour()),e.name=s,e.setVisible(this.isVisible()),e.prefixField&&(t=this.insertFieldAt(t,e.prefixField)),this.fieldRow.splice(t,0,e),t++,e.suffixField&&(t=this.insertFieldAt(t,e.suffixField)),this.sourceBlock.rendered&&(this.sourceBlock.queueRender(),this.sourceBlock.bumpNeighbours()),t):t}removeField(t,e){for(let e,s=0;e=this.fieldRow[s];s++)if(e.name===t)return e.dispose(),this.fieldRow.splice(s,1),this.sourceBlock.rendered&&(this.sourceBlock.queueRender(),this.sourceBlock.bumpNeighbours()),!0;if(e)return!1;throw Error('Field "'+t+'" not found.')}isVisible(){return this.visible}setVisible(t){let e=[];if(this.visible===t)return e;this.visible=t;for(let e,s=0;e=this.fieldRow[s];s++)e.setVisible(t);if(this.connection){var s=this.connection;t?e=s.startTrackingAll():s.stopTrackingAll(),(s=s.targetBlock())&&(s.getSvgRoot().style.display=t?"block":"none")}return e}markDirty(){for(let t,e=0;t=this.fieldRow[e];e++)t.markDirty()}setCheck(t){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setCheck(t),this}setAlign(t){return this.align=t,this.sourceBlock.rendered&&this.sourceBlock.queueRender(),this}setShadowDom(t){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setShadowDom(t),this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){if(this.sourceBlock.workspace.rendered)for(let t=0;t{xi(s.getSourceBlock()),setTimeout((()=>{i.bringToFront()}),0)}))}}}update(t,e){const s=this.getCandidate(t);((this.wouldDeleteBlock=this.shouldDelete(!!s,e))||this.shouldUpdatePreviews(s,t))&&(Nr.disable$$module$build$src$core$events$utils(),this.maybeHidePreview(s),this.maybeShowPreview(s),Nr.enable$$module$build$src$core$events$utils())}createMarkerBlock(t){var e=t.type;let s;Nr.disable$$module$build$src$core$events$utils();try{if(s=this.workspace.newBlock(e),s.setInsertionMarker(!0),t.saveExtraState){var i=t.saveExtraState(!0);i&&s.loadExtraState&&s.loadExtraState(i)}else if(t.mutationToDom){const e=t.mutationToDom();e&&s.domToMutation&&s.domToMutation(e)}for(e=0;e{let t,e;null==(t=o)||t.positionNearConnection(l,n,r),null==(e=o)||e.getSvgRoot().setAttribute("visibility","visible")})),this.markerConnection=i}hideInsertionMarker(){if(this.markerConnection){var t,e=this.markerConnection,s=e.getSourceBlock(),i=s.outputConnection;if(null!=(t=s.previousConnection)&&t.targetConnection||null!=i&&i.targetConnection)s.unplug(!0);else{let t;null==(t=e.targetBlock())||t.unplug(!1)}if(e.targetConnection)throw Error("markerConnection still connected at the end of disconnectInsertionMarker");this.markerConnection=null,(e=s.getSvgRoot())&&e.setAttribute("visibility","hidden")}}showInsertionInputOutline(t){t=t.closest,this.highlightedBlock=t.getSourceBlock(),this.highlightedBlock.highlightShapeForInput(t,!0)}hideInsertionInputOutline(){if(this.highlightedBlock){if(!this.activeCandidate)throw Error("Cannot hide the insertion marker outline because there is no active candidate");this.highlightedBlock.highlightShapeForInput(this.activeCandidate.closest,!1),this.highlightedBlock=null}}showReplacementFade(t){if(this.fadedBlock=t.closest.targetBlock(),!this.fadedBlock)throw Error("Cannot show the replacement fade because the closest connection does not have a target block");this.fadedBlock.fadeForReplacement(!0)}hideReplacementFade(){this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null)}getInsertionMarkers(){const t=[];return this.firstMarker&&t.push(this.firstMarker),this.lastMarker&&t.push(this.lastMarker),t}disposeInsertionMarker(t){if(t){Nr.disable$$module$build$src$core$events$utils();try{t.dispose()}finally{Nr.enable$$module$build$src$core$events$utils()}}}};!function(t){(t=t.PREVIEW_TYPE||(t.PREVIEW_TYPE={}))[t.INSERTION_MARKER=0]="INSERTION_MARKER",t[t.INPUT_OUTLINE=1]="INPUT_OUTLINE",t[t.REPLACEMENT_FADE=2]="REPLACEMENT_FADE"}(Ld||(Ld={}));var wd=Ld.PREVIEW_TYPE,Nd={};Nd.InsertionMarkerManager=Ld,Nd.PreviewType=wd;var Md=class{constructor(t){this.overrides=null,this.name=t}getClassName(){return this.name+"-renderer"}init(t,e){this.constants_=this.makeConstants_(),e&&(this.overrides=e,Object.assign(this.constants_,e)),this.constants_.setTheme(t),this.constants_.init()}createDom(t,e){this.constants_.createDom(t,this.name+"-"+e.name,"."+this.getClassName()+"."+e.getClassName())}refreshDom(t,e){const s=this.getConstants();s.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=s.randomIdentifier,this.constants_.setTheme(e),this.constants_.init(),this.createDom(t,e)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new pd}makeRenderInfo_(t){return new $d(this,t)}makeDrawer_(t,e){return new _d(t,e)}makeMarkerDrawer(t,e){return new Rd(t,this.getConstants(),e)}makePathObject(t,e){return new Cd(t,e,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(t){return!0}orphanCanConnectAtEnd(t,e,s){return!!kd.getConnectionForOrphanedConnection(t,s===Pc.OUTPUT_VALUE?e.outputConnection:e.previousConnection)}getConnectionPreviewMethod(t,e,s){return e.type===Pc.OUTPUT_VALUE||e.type===Pc.PREVIOUS_STATEMENT?!t.isConnected()||this.orphanCanConnectAtEnd(s,t.targetBlock(),e.type)?Ld.PREVIEW_TYPE.INSERTION_MARKER:Ld.PREVIEW_TYPE.REPLACEMENT_FADE:Ld.PREVIEW_TYPE.INSERTION_MARKER}render(t){const e=this.makeRenderInfo_(t);e.measure(),this.makeDrawer_(t,e).draw()}},Dd={};Dd.BottomRow=zu,Dd.Connection=ju,Dd.ConstantProvider=pd,Dd.Drawer=_d,Dd.ExternalValueInput=qu,Dd.Field=Zu,Dd.Hat=Qu,Dd.Icon=td,Dd.InRowSpacer=ed,Dd.InlineInput=sd,Dd.InputConnection=Ju,Dd.InputRow=od,Dd.JaggedEdge=nd,Dd.MarkerSvg=Rd,Dd.Measurable=Yu,Dd.NextConnection=rd,Dd.OutputConnection=ld,Dd.PathObject=Cd,Dd.PreviousConnection=ad,Dd.RenderInfo=$d,Dd.Renderer=Md,Dd.RoundCorner=cd,Dd.Row=Ku,Dd.SpacerRow=hd,Dd.SquareCorner=ud,Dd.StatementInput=id,Dd.TopRow=dd,Dd.Types=Xu,Dd.init=yn,Dd.register=kn,Dd.unregister=On;var xd=class{constructor(t,e){this.workspace=t,this.theme=e,this.subscribedWorkspaces_=[],this.componentDB=new Map}getTheme(){return this.theme}setTheme(t){var e=this.theme;this.theme=t,(t=this.workspace.getInjectionDiv())&&(e&&(e=e.getClassName())&&rt(t,e),(e=this.theme.getClassName())&&ot(t,e));for(let t,e=0;t=this.subscribedWorkspaces_[e];e++)t.refreshTheme();for(const[s,i]of this.componentDB)for(const o of i){t=o.element,e=o.propertyName;const i=this.theme&&this.theme.getComponentStyle(s);t.style.setProperty(e,i||"")}for(const t of this.subscribedWorkspaces_)t.hideChaff()}subscribeWorkspace(t){this.subscribedWorkspaces_.push(t)}unsubscribeWorkspace(t){if(!Q(this.subscribedWorkspaces_,t))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.")}subscribe(t,e,s){this.componentDB.has(e)||this.componentDB.set(e,[]),this.componentDB.get(e).push({element:t,propertyName:s}),e=this.theme&&this.theme.getComponentStyle(e),t.style.setProperty(s,e||"")}unsubscribe(t){if(t)for(const[e,s]of this.componentDB){for(let e=s.length-1;0<=e;e--)s[e].element===t&&s.splice(e,1);s.length||this.componentDB.delete(e)}}dispose(){this.subscribedWorkspaces_.length=0,this.componentDB.clear()}},Bd="VARIABLE_DYNAMIC",Pd={CATEGORY_NAME:Bd};Pd.flyoutCategory=wn,Pd.flyoutCategoryBlocks=Nn,Pd.onCreateVariableButtonClick_Colour=Ln,Pd.onCreateVariableButtonClick_Number=vn,Pd.onCreateVariableButtonClick_String=An;var Fd=class{canConnect(t,e,s,i){return this.canConnectWithReason(t,e,s,i)===kd.CAN_CONNECT}canConnectWithReason(t,e,s,i){const o=this.doSafetyChecks(t,e);return o!==kd.CAN_CONNECT?o:this.doTypeChecks(t,e)?s&&!this.doDragChecks(t,e,i||0)?kd.REASON_DRAG_CHECKS_FAILED:kd.CAN_CONNECT:kd.REASON_CHECKS_FAILED}getErrorMessage(t,e,s){switch(t){case kd.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case kd.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case kd.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case kd.REASON_TARGET_NULL:return"Target connection is null.";case kd.REASON_CHECKS_FAILED:return"Connection checks failed. "+e+" expected "+e.getCheck()+", found "+s.getCheck();case kd.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case kd.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case kd.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(t,e){if(!t||!e)return kd.REASON_TARGET_NULL;let s,i,o;return t.isSuperior()?(s=t.getSourceBlock(),i=e.getSourceBlock(),o=e):(i=t.getSourceBlock(),s=e.getSourceBlock(),o=t,t=e),s===i?kd.REASON_SELF_CONNECTION:o.type!==xh[t.type]?kd.REASON_WRONG_TYPE:s.workspace!==i.workspace?kd.REASON_DIFFERENT_WORKSPACES:s.isShadow()&&!i.isShadow()?kd.REASON_SHADOW_PARENT:o.type===Pc.OUTPUT_VALUE&&i.previousConnection&&i.previousConnection.isConnected()||o.type===Pc.PREVIOUS_STATEMENT&&i.outputConnection&&i.outputConnection.isConnected()?kd.REASON_PREVIOUS_AND_OUTPUT:kd.CAN_CONNECT}doTypeChecks(t,e){if(t=t.getCheck(),e=e.getCheck(),!t||!e)return!0;for(let s=0;ss||e.getSourceBlock().isInsertionMarker())return!1;switch(e.type){case Pc.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(t,e);case Pc.OUTPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isInsertionMarker()||t.isConnected())return!1;break;case Pc.INPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isMovable()&&!e.targetBlock().isShadow())return!1;break;case Pc.NEXT_STATEMENT:if(e.isConnected()&&!t.getSourceBlock().nextConnection&&!e.targetBlock().isShadow()&&e.targetBlock().nextConnection||e.targetBlock()&&!e.targetBlock().isMovable()&&!e.targetBlock().isShadow())return!1;break;default:return!1}return-1===Xr.indexOf(e)}canConnectToPrevious_(t,e){return!(t.targetConnection||-1!==Xr.indexOf(e)||e.targetConnection&&(!(t=e.targetBlock()).isInsertionMarker()||t.getPreviousBlock()))}};t(Pr.CONNECTION_CHECKER,Br,Fd);var Ud=class extends oc{constructor(t){super(t),this.type=Qr,t&&(this.varType=t.type,this.varName=t.name)}toJson(){const t=super.toJson();if(void 0===this.varType)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return t.varType=this.varType,t.varName=this.varName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Ud)).varType=t.varType,e.varName=t.varName,e}run(t){const e=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");t?e.deleteVariableById(this.varId):e.createVariable(this.varName,this.varType,this.varId)}};t(Pr.EVENT,Qr,Ud);var Hd=class extends oc{constructor(t,e){super(t),this.type=tl,t&&(this.oldName=t.name,this.newName=void 0===e?"":e)}toJson(){const t=super.toJson();if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");return t.oldName=this.oldName,t.newName=this.newName,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Hd)).oldName=t.oldName,e.newName=t.newName,e}run(t){const e=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldName)throw Error("The old var name is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.newName)throw Error("The new var name is undefined. Either pass a value to the constructor, or call fromJson");t?e.renameVariableById(this.varId,this.newName):e.renameVariableById(this.varId,this.oldName)}};t(Pr.EVENT,tl,Hd);var Gd=class{constructor(t){this.workspace=t,this.variableMap=new Map}clear(){for(const t of this.variableMap.values())for(;0{t&&e&&this.deleteVariableInternal(e,i)}))):this.deleteVariableInternal(e,i)}else console.warn("Can't delete non-existent variable: "+t)}deleteVariableInternal(t,e){const s=Nr.getGroup$$module$build$src$core$events$utils();s||Nr.setGroup$$module$build$src$core$events$utils(!0);try{for(let t=0;tt.name))}getVariableUsesById(t){const e=[],s=this.workspace.getAllBlocks(!1);for(let i=0;ithis.remainingCapacityOfType(s))return!1;e+=t[s]}return!(e>this.remainingCapacity())}hasBlockLimits(){return 1/0!==this.options.maxBlocks||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(t){var e=t?this.redoStack_:this.undoStack_,s=t?this.undoStack_:this.redoStack_;const i=e.pop();if(i){for(var o=[i];e.length&&i.group&&i.group===e[e.length-1].group;){const t=e.pop();t&&o.push(t)}for(e=0;ethis.MAX_UNDO&&0<=this.MAX_UNDO;)this.undoStack_.shift();for(let e=0;et[0]-e[0]));for(const[n,r]of o)if(t{},document.body.addEventListener("wheel",this.dummyWheelListener),Y(this.svgGroup_,"wheel",this,this.onMouseWheel_)),this.options.hasCategories&&(this.toolbox_=new(c(Pr.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(t=c(Pr.CURSOR,this.options))&&this.markerManager.setCursor(new t),this.renderer.createDom(this.svgGroup_,this.getTheme()),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&at(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(),this.markerManager&&this.markerManager.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(),!this.options.parentWorkspace){const t=this.getParentSvg();t&&t.parentNode&&at(t.parentNode)}this.resizeHandlerWrapper&&(z(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null)}addTrashcan(){this.trashcan=Yd.newTrashcan(this);const t=this.trashcan.createDom();this.svgGroup_.insertBefore(t,this.getCanvas())}static newTrashcan(t){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new za(this);const t=this.zoomControls_.createDom();this.svgGroup_.appendChild(t)}addFlyout(t){const e=new hu({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,move:{scrollbars:!0}});return e.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(c(Pr.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(e):new(c(Pr.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(e),this.flyout.autoClose=!1,this.flyout.getWorkspace().setVisible(!0),this.flyout.createDom(t)}getFlyout(t){return this.flyout||t?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();const t=this.componentManager.getComponents(na.Capability.POSITIONABLE,!0),e=this.getMetricsManager().getUiMetrics(),s=[];for(let i,o=0;i=t[o];o++){i.position(e,s);const t=i.getBoundingRectangle();t&&s.push(t)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations_()}updateScreenCalculationsIfScrolled(){const t=vt();ca.equals(this.lastRecordedPageScroll,t)||(this.lastRecordedPageScroll=t,this.updateScreenCalculations_())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(t,e){const s=this.getParentSvg();null!=t&&(this.cachedParentSvgSize.width=t,s.setAttribute("data-cached-width",`${t}`)),null!=e&&(this.cachedParentSvgSize.height=e,s.setAttribute("data-cached-height",`${e}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let t=this.svgGroup_;for(;t;){if("svg"===t.tagName){this.cachedParentSvg=t;break}t=t.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(M()){var t=this.scale,e=-this.scrollY,s=-this.scrollX;if(!(t===this.oldScale&&1>Math.abs(e-this.oldTop)&&1>Math.abs(s-this.oldLeft))){var i=new(P(hl))(e,s,t,this.id,this.oldScale);this.oldScale=t,this.oldTop=e,this.oldLeft=s,A(i)}}}translate(t,e){let s,i;null==(s=this.layerManager)||s.translateLayers(new ca(t,e),this.scale),null==(i=this.grid)||i.moveTo(t,e),this.maybeFireViewportChangeEvent()}getWidth(){const t=this.getMetrics();return t?t.viewWidth/this.scale:0}setVisible(t){this.isVisible_=t,this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(t),this.getFlyout()&&this.getFlyout().setContainerVisible(t),this.getParentSvg().style.display=t?"block":"none",this.toolbox_&&this.toolbox_.setVisible(t),t||this.hideChaff(!0))}render(){for(var t=this.getAllBlocks(!1),e=t.length-1;0<=e;e--)t[e].queueRender();if(this.currentGesture_)for(t=this.currentGesture_.getInsertionMarkers(),e=0;e{this.markerManager.updateMarkers()}))}highlightBlock(t,e){if(void 0===e){for(let t,e=0;t=this.highlightedBlocks[e];e++)t.setHighlighted(!1);this.highlightedBlocks.length=0}(t=t?this.getBlockById(t):null)&&((e=void 0===e||e)?-1===this.highlightedBlocks.indexOf(t)&&this.highlightedBlocks.push(t):Q(this.highlightedBlocks,t),t.setHighlighted(e))}paste(t){if(st("Blockly.WorkspaceSvg.prototype.paste","v10","v11","Blockly.clipboard.paste"),!this.rendered||!t.type&&!t.tagName)return null;this.currentGesture_&&this.currentGesture_.cancel();const e=Nr.getGroup$$module$build$src$core$events$utils();let s;e||Nr.setGroup$$module$build$src$core$events$utils(!0);try{s=t.type?this.pasteBlock_(null,t):"comment"===t.tagName.toLowerCase()?this.pasteWorkspaceComment_(t):this.pasteBlock_(t,null)}finally{Nr.setGroup$$module$build$src$core$events$utils(e)}return s}pasteBlock_(t,e){let s;Nr.disable$$module$build$src$core$events$utils();try{let i=0,o=0;if(t){let e,n;s=Ge(t,this),i=parseInt(null!=(e=t.getAttribute("x"))?e:"0"),this.RTL&&(i=-i),o=parseInt(null!=(n=t.getAttribute("y"))?n:"0")}else e&&(s=gs(e,this),i=e.x||10,this.RTL&&(i=this.getWidth()-i),o=e.y||10);if(!isNaN(i)&&!isNaN(o)){let t;do{t=!1;const e=this.getAllBlocks(!1);for(let s,n=0;s=e[n];n++){const e=s.getRelativeToSurfaceXY();if(1>=Math.abs(i-e.x)&&1>=Math.abs(o-e.y)){t=!0;break}}if(!t){const e=s.getConnections_(!1);for(let s,n=0;s=e[n];n++)if(s.closest(Nr.config$$module$build$src$core$config.snapRadius,new ca(i,o)).connection){t=!0;break}}t&&(i=this.RTL?i-Nr.config$$module$build$src$core$config.snapRadius:i+Nr.config$$module$build$src$core$config.snapRadius,o+=2*Nr.config$$module$build$src$core$config.snapRadius)}while(t);s.moveTo(new ca(i,o))}}finally{Nr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&A(new(P(Nr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}pasteWorkspaceComment_(t){let e;Nr.disable$$module$build$src$core$events$utils();try{e=_c.fromXmlRendered(t,this);let s,i,o=parseInt(null!=(s=t.getAttribute("x"))?s:"0"),n=parseInt(null!=(i=t.getAttribute("y"))?i:"0");isNaN(o)||isNaN(n)||(this.RTL&&(o=-o),e.moveBy(o+50,n+50))}finally{Nr.enable$$module$build$src$core$events$utils()}return M()&&uc.fireCreateEvent(e),e.select(),e}refreshToolboxSelection(){const t=this.isFlyout?this.targetWorkspace:this;t&&!t.currentGesture_&&t.toolbox_&&t.toolbox_.getFlyout()&&t.toolbox_.refreshSelection()}renameVariableById(t,e){super.renameVariableById(t,e),this.refreshToolboxSelection()}deleteVariableById(t){super.deleteVariableById(t),this.refreshToolboxSelection()}createVariable(t,e,s){return t=super.createVariable(t,e,s),this.refreshToolboxSelection(),t}recordDragTargets(){const t=this.componentManager.getComponents(na.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let e,s=0;e=t[s];s++){const t=e.getClientRect();t&&this.dragTargetAreas.push({component:e,clientRect:t})}}newBlock(t,e){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}getDragTarget(t){for(let e,s=0;e=this.dragTargetAreas[s];s++)if(e.clientRect.contains(t.clientX,t.clientY))return e.component;return null}onMouseDown_(t){const e=this.getGesture(t);e&&e.handleWsStart(t,this)}startDrag(t,e){(t=q(t,this.getParentSvg(),this.getInverseScreenCTM())).x/=this.scale,t.y/=this.scale,this.dragDeltaXY=ca.difference(e,t)}moveDrag(t){return(t=q(t,this.getParentSvg(),this.getInverseScreenCTM())).x/=this.scale,t.y/=this.scale,ca.sum(this.dragDeltaXY,t)}isDragging(){return null!==this.currentGesture_&&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(){const t=!!this.scrollbar;return this.isMovable()&&(!t||t&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){const t=!!this.scrollbar;return this.isMovable()&&(!t||t&&this.scrollbar.canScrollVertically())}onMouseWheel_(t){if(ou.inProgress())t.preventDefault(),t.stopPropagation();else{var e=this.options.zoomOptions&&this.options.zoomOptions.wheel,s=this.options.moveOptions&&this.options.moveOptions.wheel;if(e||s){var i=Z(t);if(ql)var o=t.metaKey;e&&(t.ctrlKey||o||!s)?(i=-i.y/50,e=q(t,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(e.x,e.y,i)):(e=this.scrollX-i.x,s=this.scrollY-i.y,t.shiftKey&&!i.x&&(e=this.scrollX-i.y,s=this.scrollY),this.scroll(e,s)),t.preventDefault()}}}getBlocksBoundingBox(){const t=this.getTopBoundedElements();if(!t.length)return new fa(0,0,0,0);const e=t[0].getBoundingRectangle();for(let i=1;ie.bottom&&(e.bottom=s.bottom),s.lefte.right&&(e.right=s.right))}return e}cleanUp(){this.setResizesEnabled(!1),Nr.setGroup$$module$build$src$core$events$utils(!0);const t=this.getTopBlocks(!0);let e=0;for(let s,i=0;s=t[i];i++){if(!s.isMovable())continue;const t=s.getRelativeToSurfaceXY();s.moveBy(-t.x,e-t.y,["cleanup"]),s.snapToGrid(),e=s.getRelativeToSurfaceXY().y+s.getHeightWidth().height+this.renderer.getConstants().MIN_BLOCK_HEIGHT}Nr.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(t){if(!this.options.readOnly&&!this.isFlyout){var e=uh.registry.getContextMenuOptions(uh.ScopeType.WORKSPACE,{workspace:this});this.configureContextMenu&&this.configureContextMenu(e,t),Qs(t,e,this.RTL)}}updateToolbox(t){if(t=xt(t)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Ft(t)){if(!this.toolbox_)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=t,this.toolbox_.render(t)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=t,this.flyout.show(t)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.")}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(_(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(t,e,s){s=Math.pow(this.options.zoomOptions.scaleSpeed,s);const i=this.scale*s;if(this.scale!==i){i>this.options.zoomOptions.maxScale?s=this.options.zoomOptions.maxScale/this.scale:ithis.options.zoomOptions.maxScale?t=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&te.autoHide(t)))}static setTopLevelWorkspaceMetrics_(t){const e=this.getMetrics();"number"==typeof t.x&&(this.scrollX=-(e.scrollLeft+(e.scrollWidth-e.viewWidth)*t.x)),"number"==typeof t.y&&(this.scrollY=-(e.scrollTop+(e.scrollHeight-e.viewHeight)*t.y)),this.translate(this.scrollX+e.absoluteLeft,this.scrollY+e.absoluteTop)}},Kd={};Kd.WorkspaceSvg=Yd,Kd.resizeSvgContents=Mn;var zd=class extends Ol{constructor(t,e){super(e),this.type=ll,this.isOpen=t}toJson(){const t=super.toJson();if(void 0===this.isOpen)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");return t.isOpen=this.isOpen,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new zd)).isOpen=t.isOpen,e}};t(Pr.EVENT,ll,zd);var jd=class extends Mc{constructor(t){if(super(t),this.type=Nr.DELETE$$module$build$src$core$events$utils,t){if(t.getParent())throw Error("Connected blocks cannot be deleted.");t.isShadow()&&(this.recordUndo=!1),this.oldXml=Ne(t),this.ids=x(t),this.wasShadow=t.isShadow(),this.oldJson=ns(t,{addCoordinates:!0})}}toJson(){const t=super.toJson();if(!this.oldXml)throw Error("The old block XML 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(void 0===this.wasShadow)throw Error("Whether the block was a shadow is undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");return t.oldXml=Pe(this.oldXml),t.ids=this.ids,t.wasShadow=this.wasShadow,t.oldJson=this.oldJson,this.recordUndo||(t.recordUndo=this.recordUndo),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new jd)).oldXml=Nr.textToDom$$module$build$src$core$utils$xml(t.oldXml),e.ids=t.ids,e.wasShadow=t.wasShadow||"shadow"===e.oldXml.tagName.toLowerCase(),e.oldJson=t.oldJson,void 0!==t.recordUndo&&(e.recordUndo=t.recordUndo),e}run(t){const e=this.getEventWorkspace_();if(!this.ids)throw Error("The block IDs are undefined. Either pass a block to the constructor, or call fromJson");if(!this.oldJson)throw Error("The old block JSON is undefined. Either pass a block to the constructor, or call fromJson");if(t)for(t=0;tt.disposeInternal())),this.inputList.forEach((t=>t.dispose())),this.inputList.length=0,this.getConnections_(!0).forEach((t=>t.dispose())),this.disposed=!0)}isDeadOrDying(){return this.disposing||this.disposed}initModel(){for(const t of this.inputList)for(const e of t.fieldRow)e.initModel&&e.initModel()}unplug(t){this.outputConnection&&this.unplugFromRow_(t),this.previousConnection&&this.unplugFromStack_(t)}unplugFromRow_(t){let e,s=null;null!=(e=this.outputConnection)&&e.isConnected()&&(s=this.outputConnection.targetConnection,this.outputConnection.disconnect()),s&&t&&(t=this.getOnlyValueConnection_())&&t.isConnected()&&!t.targetBlock().isShadow()&&(null==(t=t.targetConnection)||t.disconnect(),this.workspace.connectionChecker.canConnect(t,s,!1)?s.connect(t):null==t||t.onFailedConnect(s))}getOnlyValueConnection_(){let t=null;for(let e=0;e(t=t+("("===s||")"===e?"":" ")+e,s=e[e.length-1],t)),"")).trim()||"???",t&&e.length>t&&(e=e.substring(0,t-3)+"..."),e}toTokens(t="?"){const e=[];for(const i of this.inputList)if(i.name!=Od){for(const t of i.fieldRow)e.push(t.getText());if(i.connection){const o=i.connection.targetBlock();if(o){var s=i.connection;let n=s.getCheck();!n&&s.targetConnection&&(n=s.targetConnection.getCheck()),(s=!!n&&(-1!==n.indexOf("Boolean")||-1!==n.indexOf("Number")))&&e.push("("),e.push(...o.toTokens(t)),s&&e.push(")")}else e.push(t)}}return e}appendValueInput(t){return this.appendInput(new Nr.ValueInput$$module$build$src$core$inputs$value_input(t,this))}appendStatementInput(t){return this.statementInputCount++,this.appendInput(new fd(t,this))}appendDummyInput(t=""){return this.appendInput(new Ed(t,this))}appendEndRowInput(t=""){return this.appendInput(new bd(t,this))}appendInput(t){return this.inputList.push(t),t}appendInputFromRegistry(t,e){return(t=r(Pr.INPUT,t,!1))?this.appendInput(new t(e,this)):null}jsonInit(t){var e=t.type?'Block "'+t.type+'": ':"";if(t.output&&t.previousStatement)throw Error(e+"Must not have both an output and a previousStatement.");for(var s=0;t["args"+s];){if(void 0===t["message"+s])throw Error(e+`args${s} must have a corresponding message (message${s}).`);s++}if(t.style&&t.style.hat&&(this.hat=t.style.hat,t.style=null),t.style&&t.colour)throw Error(e+"Must not have both a colour and a style.");for(t.style?this.jsonInitStyle_(t,e):this.jsonInitColour_(t,e),s=0;void 0!==t["message"+s];)this.interpolate_(t["message"+s],t["args"+s]||[],t["implicitAlign"+s]||t["lastDummyAlign"+s],e),s++;if(void 0!==t.inputsInline&&(Nr.disable$$module$build$src$core$events$utils(),this.setInputsInline(t.inputsInline),Nr.enable$$module$build$src$core$events$utils()),void 0!==t.output&&this.setOutput(!0,t.output),void 0!==t.outputShape&&this.setOutputShape(t.outputShape),void 0!==t.previousStatement&&this.setPreviousStatement(!0,t.previousStatement),void 0!==t.nextStatement&&this.setNextStatement(!0,t.nextStatement),void 0!==t.tooltip&&(s=Ao(t.tooltip),this.setTooltip(s)),void 0!==t.enableContextMenu&&(this.contextMenu=!!t.enableContextMenu),void 0!==t.suppressPrefixSuffix&&(this.suppressPrefixSuffix=!!t.suppressPrefixSuffix),void 0!==t.helpUrl&&(s=Ao(t.helpUrl),this.setHelpUrl(s)),"string"==typeof t.extensions&&(console.warn(e+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+t.type+"' block."),t.extensions=[t.extensions]),void 0!==t.mutator&&Go(t.mutator,this,!0),t=t.extensions,Array.isArray(t))for(e=0;en||n>e)throw Error('Block "'+this.type+'": Message index %'+n+" out of range.");if(s[n])throw Error('Block "'+this.type+'": Message index %'+n+" duplicated.");s[n]=!0,i++}}if(i!==e)throw Error('Block "'+this.type+'": Message does not reference all '+e+" arg(s).")}interpolateArguments_(t,e,s){const i=[];for(let n=0;n=this.inputList.length)throw RangeError("Input index "+t+" out of bounds.");if(e>this.inputList.length)throw RangeError("Reference input "+e+" out of bounds.");const s=this.inputList[t];this.inputList.splice(t,1),tt.getWeight()-e.getWeight())),t}removeIcon(t){if(!this.hasIcon(t))return!1;let e;return null==(e=this.getIcon(t))||e.dispose(),this.icons=this.icons.filter((e=>!e.getType().equals(t))),!0}hasIcon(t){return this.icons.some((e=>e.getType().equals(t)))}getIcon(t){return t instanceof ja?this.icons.find((e=>e.getType().equals(t))):this.icons.find((e=>e.getType().toString()===t))}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy_}moveBy(t,e,s){if(this.parentBlock_)throw Error("Block has parent");const i=new(P(Nr.MOVE$$module$build$src$core$events$utils))(this);s&&i.setReason(s),this.xy_.translate(t,e),i.recordNew(),A(i)}makeConnection_(t){return new kd(this,t)}allInputsFilled(t){if(void 0===t&&(t=!0),!t&&this.isShadow())return!1;for(let s,i=0;s=this.inputList[i];i++)if(s.connection){var e=s.connection.targetBlock();if(!e||!e.allInputsFilled(t))return!1}return!(e=this.getNextBlock())||e.allInputsFilled(t)}toDevString(){let t=this.type?'"'+this.type+'" block':"Block";return this.id&&(t+=' (id="'+this.id+'")'),t}};Jd.COLLAPSED_INPUT_NAME=Od,Jd.COLLAPSED_FIELD_NAME=yd;var qd=class{constructor(){this.drawer=this.curNode=this.colour=null,this.type="marker"}setDrawer(t){this.drawer=t}getDrawer(){return this.drawer}getCurNode(){return this.curNode}setCurNode(t){const e=this.curNode;this.curNode=t,this.drawer&&this.drawer.draw(e,this.curNode)}draw(){this.drawer&&this.drawer.draw(this.curNode,this.curNode)}hide(){this.drawer&&this.drawer.hide()}dispose(){this.getDrawer()&&this.getDrawer().dispose()}},Zd=class extends qd{constructor(){super(),this.type="cursor"}next(){var t=this.getCurNode();if(!t)return null;for(t=t.next();t&&t.next()&&(t.getType()===Id.types.NEXT||t.getType()===Id.types.BLOCK);)t=t.next();return t&&this.setCurNode(t),t}in(){var t=this.getCurNode();if(!t)return null;let e,s;return t.getType()!==Id.types.PREVIOUS&&t.getType()!==Id.types.OUTPUT||(t=t.next()),(t=null!=(s=null==(e=t)?void 0:e.in())?s:null)&&this.setCurNode(t),t}prev(){var t=this.getCurNode();if(!t)return null;for(t=t.prev();t&&t.prev()&&(t.getType()===Id.types.NEXT||t.getType()===Id.types.BLOCK);)t=t.prev();return t&&this.setCurNode(t),t}out(){var t=this.getCurNode();return t?((t=t.out())&&t.getType()===Id.types.BLOCK&&(t=t.prev()||t),t&&this.setCurNode(t),t):null}};t(Pr.CURSOR,Br,Zd);var Qd=class extends Zd{constructor(){super()}next(){var t=this.getCurNode();return t?((t=this.getNextNode_(t,this.validNode_))&&this.setCurNode(t),t):null}in(){return this.next()}prev(){var t=this.getCurNode();return t?((t=this.getPreviousNode_(t,this.validNode_))&&this.setCurNode(t),t):null}out(){return this.prev()}getNextNode_(t,e){if(!t)return null;const s=t.in()||t.next();return e(s)?s:s?this.getNextNode_(s,e):e(t=this.findSiblingOrParent(t.out()))?t:t?this.getNextNode_(t,e):null}getPreviousNode_(t,e){if(!t)return null;let s=t.prev();return s=s?this.getRightMostChild(s):t.out(),e(s)?s:s?this.getPreviousNode_(s,e):null}validNode_(t){let e=!1;return(t=t&&t.getType())!==Id.types.OUTPUT&&t!==Id.types.INPUT&&t!==Id.types.FIELD&&t!==Id.types.NEXT&&t!==Id.types.PREVIOUS&&t!==Id.types.WORKSPACE||(e=!0),e}findSiblingOrParent(t){if(!t)return null;return t.next()||this.findSiblingOrParent(t.out())}getRightMostChild(t){if(!t.in())return t;for(t=t.in();t&&t.next();)t=t.next();return this.getRightMostChild(t)}};Qd.registrationName="basicCursor",t(Pr.CURSOR,Qd.registrationName,Qd);var tp=class extends Qd{validNode_(t){let e=!1;const s=t&&t.getType();return t&&(t=t.getLocation(),s===Id.types.FIELD&&t&&t.isTabNavigable()&&t.isClickable()&&(e=!0)),e}},ep=class extends kd{constructor(t,e){super(t,e),this.targetConnection=this.highlightPath=null,this.db=t.workspace.connectionDBList[e],this.dbOpposite=t.workspace.connectionDBList[xh[e]],this.offsetInBlock=new ca(0,0),this.trackedState=ep.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState===ep.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.highlightPath&&(at(this.highlightPath),this.highlightPath=null)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(t){const e=this.x-t.x;return t=this.y-t.y,Math.sqrt(e*e+t*t)}bumpAwayFrom(t){if(!this.sourceBlock_.workspace.isDragging()){var e=this.sourceBlock_.getRootBlock();if(!e.isInFlyout){var s=!1;if(!e.isMovable()){if(!(e=t.getSourceBlock().getRootBlock()).isMovable())return;t=this,s=!0}var i=T()==e;i||e.addSelect();var o=t.x+Nr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.x,n=t.y+Nr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.y;s&&(n=-n),e.RTL&&(o=t.x-Nr.config$$module$build$src$core$config.snapRadius-Math.floor(10*Math.random())-this.x),e.moveBy(o,n,["bump"]),i||e.removeSelect()}}}moveTo(t,e){let s=!1;return this.trackedState===ep.TrackedState.WILL_TRACK?(this.db.addConnection(this,e),this.trackedState=ep.TrackedState.TRACKED,s=!0):this.trackedState===ep.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,e),s=!0),this.x=t,this.y=e,s}moveBy(t,e){return this.moveTo(this.x+t,this.y+e)}moveToOffset(t){return this.moveTo(t.x+this.offsetInBlock.x,t.y+this.offsetInBlock.y)}setOffsetInBlock(t,e){this.offsetInBlock.x=t,this.offsetInBlock.y=e}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var t=this.targetConnection;const e=this.targetBlock();t&&e&&(t=ca.difference(this.offsetInBlock,t.offsetInBlock),e.translate(t.x,t.y))}closest(t,e){return this.dbOpposite.searchForClosest(this,t,e)}highlight(){if(!this.highlightPath){var t=this.sourceBlock_.workspace.getRenderer().getConstants(),e=t.shapeFor(this);this.type===Pc.INPUT_VALUE||this.type===Pc.OUTPUT_VALUE?(t=t.TAB_OFFSET_FROM_TOP,e=on(0,-t)+ln("v",t)+e.pathDown+ln("v",t)):(t=t.NOTCH_OFFSET_LEFT-t.CORNER_RADIUS,e=on(-t,0)+ln("h",t)+e.pathLeft+ln("h",t)),t=this.offsetInBlock,this.highlightPath=it(ba.PATH,{class:"blocklyHighlightedConnectionPath",d:e,transform:`translate(${t.x}, ${t.y})`+(this.sourceBlock_.RTL?" scale(-1 1)":"")},this.sourceBlock_.getSvgRoot())}}unhighlight(){this.highlightPath&&(at(this.highlightPath),this.highlightPath=null)}setTracking(t){t&&this.trackedState===ep.TrackedState.TRACKED||!t&&this.trackedState===ep.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(t?(this.db.addConnection(this,this.y),this.trackedState=ep.TrackedState.TRACKED):(this.trackedState===ep.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=ep.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){const t=this.targetBlock().getDescendants(!1);for(let e=0;eclearTimeout(t))),this.warningTextDb.clear(),this.getIcons().forEach((t=>t.dispose())))}checkAndDelete(){this.workspace.isFlyout||(Nr.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),Nr.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:Hc.TYPE,blockState:ns(this,{addCoordinates:!0,addNextBlocks:!1}),typeCounts:$(this,!0)}}applyColour(){this.pathObject.applyColour(this);const t=this.getIcons();for(let e=0;e{this.isDeadOrDying()||(this.warningTextDb.delete(e),this.setWarningText(t,e))}),100));else if(this.isInFlyout&&(t=null),s=this.getIcon(Fu.TYPE),t){let i=this.getSurroundParent(),o=null;for(;i;)i.isCollapsed()&&(o=i),i=i.getSurroundParent();o&&o.setWarningText(Nr.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,op.COLLAPSED_WARNING_ID),s?s.addMessage(t,e):this.addIcon(new Fu(this).addMessage(t,e))}else s&&(e?(s.addMessage("",e),s.getText()||this.removeIcon(Fu.TYPE)):this.removeIcon(Fu.TYPE))}setMutator(t){this.removeIcon(Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),t&&this.addIcon(t)}addIcon(t){return super.addIcon(t),t instanceof Fu&&(this.warning=t),t instanceof Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=t),this.rendered&&(t.initView(this.createIconPointerDownListener(t)),t.applyColour(),t.updateEditable(),this.queueRender(),Re(),this.bumpNeighbours()),t}createIconPointerDownListener(t){return e=>{this.isDeadOrDying()||(e=this.workspace.getGesture(e))&&e.setStartIcon(t)}}removeIcon(t){const e=super.removeIcon(t);return t.equals(Fu.TYPE)&&(this.warning=null),t.equals(Nr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.rendered&&(this.queueRender(),Re(),this.bumpNeighbours()),e}setEnabled(t){this.isEnabled()!==t&&(super.setEnabled(t),this.rendered&&!this.getInheritedDisabled()&&this.updateDisabled())}setHighlighted(t){this.rendered&&this.pathObject.updateHighlighted(t)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(t){this.pathObject.updateDraggingDelete(t)}getColour(){return this.style.colourPrimary}setColour(t){super.setColour(t),t=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_),this.pathObject.setStyle(t.style),this.style=t.style,this.styleName_=t.name,this.applyColour()}setStyle(t){const e=this.workspace.getRenderer().getConstants().getBlockStyle(t);if(this.styleName_=t,!e)throw Error("Invalid style name: "+t);this.hat=e.hat,this.pathObject.setStyle(e),this.colour_=e.colourPrimary,this.style=e,this.applyColour()}bringToFront(t=!1){let e=this;if(!e.isDeadOrDying())do{const s=e.getSvgRoot(),i=s.parentNode,o=i.childNodes;if(o[o.length-1]!==s&&i.appendChild(s),t)break;e=e.getParent()}while(e)}setPreviousStatement(t,e){super.setPreviousStatement(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setNextStatement(t,e){super.setNextStatement(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setOutput(t,e){super.setOutput(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setInputsInline(t){super.setInputsInline(t),this.rendered&&(this.queueRender(),this.bumpNeighbours())}removeInput(t,e){return t=super.removeInput(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours()),t}moveNumberedInputBefore(t,e){super.moveNumberedInputBefore(t,e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}appendInput(t){return super.appendInput(t),this.rendered&&(this.queueRender(),this.bumpNeighbours()),t}setConnectionTracking(t){if(this.previousConnection&&this.previousConnection.setTracking(t),this.outputConnection&&this.outputConnection.setTracking(t),this.nextConnection){this.nextConnection.setTracking(t);var e=this.nextConnection.targetBlock();e&&e.setConnectionTracking(t)}if(!this.collapsed_)for(e=0;e{const e=Nr.getGroup$$module$build$src$core$events$utils();Nr.setGroup$$module$build$src$core$events$utils(t),this.getRootBlock().bumpNeighboursInternal(),Nr.setGroup$$module$build$src$core$events$utils(e),this.bumpNeighboursPid=0}),Nr.config$$module$build$src$core$config.bumpDelay)}}bumpNeighboursInternal(){const t=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||t.isInFlyout))for(const e of this.getConnections_(!1)){if(e.isSuperior()){let t;null==(t=e.targetBlock())||t.bumpNeighboursInternal()}for(const s of e.neighbours(Nr.config$$module$build$src$core$config.snapRadius))s.getSourceBlock().getRootBlock()!==t&&(e.isConnected()&&s.isConnected()||(e.isSuperior()?s.bumpAwayFrom(e):e.bumpAwayFrom(s)))}}scheduleSnapAndBump(){const t=Nr.getGroup$$module$build$src$core$events$utils();setTimeout((()=>{Nr.setGroup$$module$build$src$core$events$utils(t),this.snapToGrid(),Nr.setGroup$$module$build$src$core$events$utils(!1)}),Nr.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(t,e,s){if(t.type===Pc.NEXT_STATEMENT||t.type===Pc.INPUT_VALUE){let i=e.x;e=e.y,i+=s.x-t.getOffsetInBlock().x,e+=s.y-t.getOffsetInBlock().y,this.moveBy(i,e)}}getChildren(t){return super.getChildren(t)}queueRender(){return Ie(this)}render(){this.queueRender(),Re()}renderEfficiently(){this.rendered=!0,dt(),this.isCollapsed()&&this.updateCollapsed_(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),pt(),this.updateMarkers_()}tightenChildrenEfficiently(){for(const t of this.inputList){const e=t.connection;e&&e.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}updateMarkers_(){this.workspace.keyboardAccessibilityMode&&this.pathObject.cursorSvg&&this.workspace.getCursor().draw(),this.workspace.keyboardAccessibilityMode&&this.pathObject.markerSvg&&this.workspace.getMarker(ru.LOCAL_MARKER).draw();for(const t of this.inputList)for(const e of t.fieldRow)e.updateMarkers_()}setCursorSvg(t){this.pathObject.setCursorSvg(t)}setMarkerSvg(t){this.pathObject.setMarkerSvg(t)}getHeightWidth(){let t=this.height,e=this.width;var s=this.getNextBlock();if(s){s=s.getHeightWidth();const i=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;t+=s.height-i,e=Math.max(e,s.width)}return{height:t,width:e}}fadeForReplacement(t){this.pathObject.updateReplacementFade(t)}highlightShapeForInput(t,e){this.pathObject.updateShapeForInputHighlight(t,e)}};op.INLINE=-1,op.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var np,rp=class{constructor(){}onDragEnter(t){}onDragOver(t){}onDragExit(t){}onDrop(t){}getClientRect(){return null}shouldPreventMove(t){return!1}},lp=class extends rp{constructor(){super(),this.wouldDelete_=!1}wouldDelete(t,e){return t instanceof op?(t=!t.getParent()&&t.isDeletable(),this.updateWouldDelete_(t&&!e)):this.updateWouldDelete_(t.isDeletable()),this.wouldDelete_}updateWouldDelete_(t){this.wouldDelete_=t}},ap=class extends lp{constructor(t){super(),this.workspace=t,this.id="trashcan",this.contents=[],this.flyout=null,this.isLidOpen=!1,this.minOpenness=0,this.lidTask=this.svgLid=this.svgGroup=null,this.top=this.left=this.lidOpen=0,this.initialized=!1,0>=this.workspace.options.maxTrashcanContents||(t=new hu({scrollbars:!0,parentWorkspace:this.workspace,rtl:this.workspace.RTL,oneBasedIndex:this.workspace.options.oneBasedIndex,renderer:this.workspace.options.renderer,rendererOverrides:this.workspace.options.rendererOverrides,move:{scrollbars:!0}}),this.workspace.horizontalLayout?(t.toolboxPosition=this.workspace.toolboxPosition===xa.TOP?xa.BOTTOM:xa.TOP,this.flyout=new(c(Pr.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(t)):(t.toolboxPosition=this.workspace.toolboxPosition===xa.RIGHT?xa.LEFT:xa.RIGHT,this.flyout=new(c(Pr.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(t)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){let t;this.svgGroup=it(ba.G,{class:"blocklyTrash"});const e=String(Math.random()).substring(2);t=it(ba.CLIPPATH,{id:"blocklyTrashBodyClipPath"+e},this.svgGroup),it(ba.RECT,{width:cp,height:hp,y:up},t);const s=it(ba.IMAGE,{width:Xa,x:-_p,height:Ya,y:-Tp,"clip-path":"url(#blocklyTrashBodyClipPath"+e+")"},this.svgGroup);return s.setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),t=it(ba.CLIPPATH,{id:"blocklyTrashLidClipPath"+e},this.svgGroup),it(ba.RECT,{width:cp,height:up},t),this.svgLid=it(ba.IMAGE,{width:Xa,x:-_p,height:Ya,y:-Tp,"clip-path":"url(#blocklyTrashLidClipPath"+e+")"},this.svgGroup),this.svgLid.setAttributeNS(ga,"xlink:href",this.workspace.options.pathToMedia+Ka),K(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),K(this.svgGroup,"pointerup",this,this.click),K(s,"pointerover",this,this.mouseOver),K(s,"pointerout",this,this.mouseOut),this.animateLid(),this.svgGroup}init(){0{let s,i;null==(s=this.flyout)||s.show(t),e.cursor="",null==(i=this.workspace.scrollbar)||i.setVisible(!1)}),10),this.fireUiEvent(!0)}}closeFlyout(){var t,e;this.contentsIsOpen()&&(null==(t=this.flyout)||t.hide(),null==(e=this.workspace.scrollbar)||e.setVisible(!0),this.fireUiEvent(!1),this.workspace.recordDragTargets())}autoHide(t){!t&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&(this.contents.length=0,this.setMinOpenness(0),this.closeFlyout())}position(t,e){if(this.initialized){var s,i=Kt(this.workspace,t);t=Yt(i,new $a(cp,hp+up),pp,dp,t,this.workspace),e=zt(t,dp,i.vertical===Fa.TOP?Ha.DOWN:Ha.UP,e),this.top=e.top,this.left=e.left,null==(s=this.svgGroup)||s.setAttribute("transform","translate("+this.left+","+this.top+")")}}getBoundingRectangle(){return new fa(this.top,this.top+hp+up,this.left,this.left+cp)}getClientRect(){if(!this.svgGroup)return null;var t=this.svgGroup.getBoundingClientRect();const e=t.top+Tp-gp;return t=t.left+_p-gp,new fa(e,e+up+hp+2*gp,t,t+cp+2*gp)}onDragOver(t){this.setLidOpen(this.wouldDelete_)}onDragExit(t){this.setLidOpen(!1)}onDrop(t){setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(t){this.isLidOpen!==t&&(this.lidTask&&clearTimeout(this.lidTask),this.isLidOpen=t,this.animateLid())}animateLid(){const t=bp;var e=1/(t+1);this.lidOpen+=this.isLidOpen?e:-e,this.lidOpen=Math.min(Math.max(this.lidOpen,this.minOpenness),1),this.setLidAngle(this.lidOpen*Ip),e=fp+this.lidOpen*($p-fp),this.svgGroup&&(this.svgGroup.style.opacity=`${e}`),this.lidOpen>this.minOpenness&&1>this.lidOpen&&(this.lidTask=setTimeout(this.animateLid.bind(this),Ep/t))}setLidAngle(t){const e=this.workspace.toolboxPosition===xa.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let s;null==(s=this.svgLid)||s.setAttribute("transform","rotate("+(e?-t:t)+","+(e?4:cp-4)+","+(up-2)+")")}setMinOpenness(t){this.minOpenness=t,this.isLidOpen||this.setLidAngle(t*Ip)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(t){t=new(P(ll))(t,this.workspace.id),A(t)}blockMouseDownWhenOpenable(t){!this.contentsIsOpen()&&this.hasContents()&&t.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(t){if(!(0>=this.workspace.options.maxTrashcanContents||t.type!==Nr.DELETE$$module$build$src$core$events$utils||t.type!==Nr.DELETE$$module$build$src$core$events$utils||t.wasShadow)){if(!t.oldJson)throw Error("Encountered a delete event without proper oldJson");if(t=JSON.stringify(this.cleanBlockJson(t.oldJson)),-1===this.contents.indexOf(t)){for(this.contents.unshift(t);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(mp)}}}cleanBlockJson(t){return function t(e){if(e){if(delete e.id,delete e.x,delete e.y,delete e.enabled,e.icons&&e.icons.comment){var s=e.icons.comment;delete s.height,delete s.width,delete s.pinned}for(var i in s=e.inputs){var o=s[i];const e=o.block;o=o.shadow,e&&t(e),o&&t(o)}e.next&&(e=(i=e.next).block,i=i.shadow,e&&t(e),i&&t(i))}}(t=JSON.parse(JSON.stringify(t))),Object.assign({},{kind:"BLOCK"},t)}},cp=47,hp=44,up=16,dp=20,pp=20,gp=10,_p=0,Tp=32,mp=.1,Ep=80,bp=4,fp=.4,$p=.8,Ip=45,Sp=class{constructor(){this.shortcuts=new Map,this.keyMap=new Map,this.reset()}reset(){this.shortcuts.clear(),this.keyMap.clear()}register(t,e){if(this.shortcuts.get(t.name)&&!e)throw Error(`Shortcut named "${t.name}" already exists.`);if(this.shortcuts.set(t.name,t),(e=t.keyCodes)&&0Wn(t)))).length?t:null}load(t,e){const s=e.getProcedureMap();for(const i of t)s.add(Yn(this.procedureModelClass,this.parameterModelClass,i,e))}clear(t){t.getProcedureMap().clear()}}};Op.loadParameter=Kn,Op.loadProcedure=Yn,Op.saveParameter=Xn,Op.saveProcedure=Wn;var yp=class{constructor(){this.priority=100}save(t){const e=[];for(const s of t.getAllVariables())t={name:s.name,id:s.getId()},s.type&&(t.type=s.type),e.push(t);return e.length?e:null}load(t,e){for(const s of t)e.createVariable(s.name,s.type,s.id)}clear(t){t.getVariableMap().clear()}};is("variables",new yp);var Ap={};Ap.VariableSerializer=yp;var vp={};vp.load=jn,vp.save=zn;var Lp={blocks:Nc,exceptions:Ac,priorities:vc,procedures:Op,registry:Lc,variables:Ap,workspaces:vp},wp=class{constructor(t,e,s,i,o){this.workspace=t,this.oldHostMetrics_=this.corner_=this.vScroll=this.hScroll=null,s=void 0===s||s;const n=(e=void 0===e||e)&&s;e&&(this.hScroll=new Oa(t,!0,n,i,o)),s&&(this.vScroll=new Oa(t,!1,n,i,o)),n&&(this.corner_=it(ba.RECT,{height:Oa.scrollbarThickness,width:Oa.scrollbarThickness,class:"blocklyScrollbarBackground"}),ct(this.corner_,t.getBubbleCanvas()))}dispose(){at(this.corner_),this.oldHostMetrics_=this.corner_=null,this.hScroll&&(this.hScroll.dispose(),this.hScroll=null),this.vScroll&&(this.vScroll.dispose(),this.vScroll=null)}resize(){const t=this.workspace.getMetrics();if(t){var e=!1,s=!1;if(this.oldHostMetrics_&&this.oldHostMetrics_.viewWidth===t.viewWidth&&this.oldHostMetrics_.viewHeight===t.viewHeight&&this.oldHostMetrics_.absoluteTop===t.absoluteTop&&this.oldHostMetrics_.absoluteLeft===t.absoluteLeft?(this.oldHostMetrics_&&this.oldHostMetrics_.scrollWidth===t.scrollWidth&&this.oldHostMetrics_.viewLeft===t.viewLeft&&this.oldHostMetrics_.scrollLeft===t.scrollLeft||(e=!0),this.oldHostMetrics_&&this.oldHostMetrics_.scrollHeight===t.scrollHeight&&this.oldHostMetrics_.viewTop===t.viewTop&&this.oldHostMetrics_.scrollTop===t.scrollTop||(s=!0)):s=e=!0,e||s){try{Nr.disable$$module$build$src$core$events$utils(),this.hScroll&&e&&this.hScroll.resize(t),this.vScroll&&s&&this.vScroll.resize(t)}finally{Nr.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics_||this.oldHostMetrics_.viewWidth!==t.viewWidth||this.oldHostMetrics_.absoluteLeft!==t.absoluteLeft){let t;null==(t=this.corner_)||t.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics_||this.oldHostMetrics_.viewHeight!==t.viewHeight||this.oldHostMetrics_.absoluteTop!==t.absoluteTop){let t;null==(t=this.corner_)||t.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics_=t}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(t,e){this.hScroll&&this.hScroll.setOrigin(t,e),this.vScroll&&this.vScroll.setOrigin(t,e)}set(t,e,s){this.hScroll&&this.hScroll.set(t,!1),this.vScroll&&this.vScroll.set(e,!1),(s||void 0===s)&&(t={},this.hScroll&&(t.x=this.hScroll.getRatio_()),this.vScroll&&(t.y=this.vScroll.getRatio_()),this.workspace.setMetrics(t))}setX(t){this.hScroll&&this.hScroll.set(t,!0)}setY(t){this.vScroll&&this.vScroll.set(t,!0)}setContainerVisible(t){this.hScroll&&this.hScroll.setContainerVisible(t),this.vScroll&&this.vScroll.setContainerVisible(t)}isVisible(){let t=!1;return this.hScroll&&(t=this.hScroll.isVisible()),this.vScroll&&(t=t||this.vScroll.isVisible()),t}setVisible(t){this.hScroll&&this.hScroll.setVisibleInternal(t),this.vScroll&&this.vScroll.setVisibleInternal(t)}resizeContent(t){this.hScroll&&this.hScroll.resizeContentHorizontal(t),this.vScroll&&this.vScroll.resizeContentVertical(t)}resizeView(t){this.hScroll&&this.hScroll.resizeViewHorizontal(t),this.vScroll&&this.vScroll.resizeViewVertical(t)}},Np=class{constructor(t){this.workspace_=t}getDimensionsPx_(t){let e=0,s=0;return t&&(e=t.getWidth(),s=t.getHeight()),new $a(e,s)}getFlyoutMetrics(t){return{width:(t=this.getDimensionsPx_(this.workspace_.getFlyout(t))).width,height:t.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){const t=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:t.width,height:t.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){let t=0,e=0;const s=this.getToolboxMetrics(),i=this.getFlyoutMetrics(),o=!!this.workspace_.getToolbox();var n;const r=!(null!=(n=this.workspace_.getFlyout())&&n.autoClose),l=(n=o?s.position:i.position)===xa.TOP;return n===xa.LEFT&&(o&&(t+=s.width),r&&(t+=i.width)),l&&(o&&(e+=s.height),r&&(e+=i.height)),{top:e,left:t}}getViewMetrics(t){t=t?this.workspace_.scale:1;const e=this.getSvgMetrics(),s=this.getToolboxMetrics(),i=this.getFlyoutMetrics(),o=!!this.workspace_.getToolbox();var n;const r=!(null!=(n=this.workspace_.getFlyout())&&n.autoClose),l=(n=o?s.position:i.position)===xa.LEFT||n===xa.RIGHT;return n!==xa.TOP&&n!==xa.BOTTOM||(o&&(e.height-=s.height),r&&(e.height-=i.height)),l&&(o&&(e.width-=s.width),r&&(e.width-=i.width)),{height:e.height/t,width:e.width/t,top:-this.workspace_.scrollY/t,left:-this.workspace_.scrollX/t}}getContentMetrics(t){t=t?1:this.workspace_.scale;const e=this.workspace_.getBlocksBoundingBox();return{height:(e.bottom-e.top)*t,width:(e.right-e.left)*t,top:e.top*t,left:e.left*t}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||!this.workspace_.isMovableVertically()}getComputedFixedEdges_(t){if(!this.hasFixedEdges())return{};const e=this.workspace_.isMovableHorizontally(),s=this.workspace_.isMovableVertically();t=t||this.getViewMetrics(!1);const i={};return s||(i.top=t.top,i.bottom=t.top+t.height),e||(i.left=t.left,i.right=t.left+t.width),i}getPaddedContent_(t,e){const s=e.top+e.height,i=e.left+e.width,o=t.width,n=o/2,r=(t=t.height)/2;return{top:Math.min(e.top-r,s-t),bottom:Math.max(s+r,e.top+t),left:Math.min(e.left-n,i-o),right:Math.max(i+n,e.left+o)}}getScrollMetrics(t,e,s){t=t?this.workspace_.scale:1,e=e||this.getViewMetrics(!1);var i=s||this.getContentMetrics();s=this.getComputedFixedEdges_(e),e=this.getPaddedContent_(e,i),i=void 0!==s.top?s.top:e.top;const o=void 0!==s.left?s.left:e.left;return{top:i/t,left:o/t,width:((void 0!==s.right?s.right:e.right)-o)/t,height:((void 0!==s.bottom?s.bottom:e.bottom)-i)/t}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){const t=this.getToolboxMetrics(),e=this.getFlyoutMetrics(!0),s=this.getSvgMetrics(),i=this.getAbsoluteMetrics(),o=this.getViewMetrics(),n=this.getContentMetrics(),r=this.getScrollMetrics(!1,o,n);return{contentHeight:n.height,contentWidth:n.width,contentTop:n.top,contentLeft:n.left,scrollHeight:r.height,scrollWidth:r.width,scrollTop:r.top,scrollLeft:r.left,viewHeight:o.height,viewWidth:o.width,viewTop:o.top,viewLeft:o.left,absoluteTop:i.top,absoluteLeft:i.left,svgHeight:s.height,svgWidth:s.width,toolboxWidth:t.width,toolboxHeight:t.height,toolboxPosition:t.position,flyoutWidth:e.width,flyoutHeight:e.height}}};t(Pr.METRICS_MANAGER,Br,Np);var Mp=class extends kl{constructor(t){super(),this.isBlank=!0,this.recordUndo=!1,this.type=_l,this.isBlank=!!t,t&&(this.workspaceId=t.id)}};t(Pr.EVENT,_l,Mp);var Dp=class extends Ol{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=sl,t&&(this.blockId=t.id,this.isStart=e,this.blocks=s)}toJson(){const t=super.toJson();if(void 0===this.isStart)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(void 0===this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return t.isStart=this.isStart,t.blockId=this.blockId,t.blocks=this.blocks,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Dp)).isStart=t.isStart,e.blockId=t.blockId,e.blocks=t.blocks,e}};t(Pr.EVENT,sl,Dp);var xp={};xp.bumpIntoBounds=Jn,xp.bumpIntoBoundsHandler=qn,xp.bumpTopObjectsIntoBounds=Qn;var Bp=class{constructor(t,e){this.dragTarget_=null,this.wouldDeleteBlock_=!1,this.dragIconData_=[],this.draggingBlock_=t,this.draggedConnectionManager_=new Ld(this.draggingBlock_),this.workspace_=e,this.startXY_=this.draggingBlock_.getRelativeToSurfaceXY(),this.dragIconData_=tr(t,this.startXY_)}dispose(){this.dragIconData_.length=0,this.draggedConnectionManager_&&this.draggedConnectionManager_.dispose()}startDrag(t,e){let s;Nr.getGroup$$module$build$src$core$events$utils()||Nr.setGroup$$module$build$src$core$events$utils(!0),this.fireDragStartEvent_(),this.draggingBlock_.bringToFront(!0),dt(),this.workspace_.setResizesEnabled(!1),Fi(),this.shouldDisconnect_(e)&&this.disconnectBlock_(e,t),this.draggingBlock_.setDragging(!0),null==(s=this.workspace_.getLayerManager())||s.moveToDragLayer(this.draggingBlock_)}shouldDisconnect_(t){return!!(this.draggingBlock_.getParent()||t&&this.draggingBlock_.nextConnection&&this.draggingBlock_.nextConnection.targetBlock())}disconnectBlock_(t,e){this.draggingBlock_.unplug(t),t=this.pixelsToWorkspaceUnits_(e),t=ca.sum(this.startXY_,t),this.draggingBlock_.translate(t.x,t.y),Bi(this.draggingBlock_),this.draggedConnectionManager_.updateAvailableConnections()}fireDragStartEvent_(){const t=new(P(sl))(this.draggingBlock_,!0,this.draggingBlock_.getDescendants(!1));A(t)}drag(t,e){e=this.pixelsToWorkspaceUnits_(e);var s=ca.sum(this.startXY_,e);this.draggingBlock_.moveDuringDrag(s),s=this.dragTarget_,this.dragTarget_=this.workspace_.getDragTarget(t),this.draggedConnectionManager_.update(e,this.dragTarget_),t=this.wouldDeleteBlock_,this.wouldDeleteBlock_=this.draggedConnectionManager_.wouldDeleteBlock,t!==this.wouldDeleteBlock_&&this.updateCursorDuringBlockDrag_(),this.dragTarget_!==s&&(s&&s.onDragExit(this.draggingBlock_),this.dragTarget_&&this.dragTarget_.onDragEnter(this.draggingBlock_)),this.dragTarget_&&this.dragTarget_.onDragOver(this.draggingBlock_)}endDrag(t,e){if(this.drag(t,e),this.fireDragEndEvent_(),pt(),Fi(),t=null,this.dragTarget_&&this.dragTarget_.shouldPreventMove(this.draggingBlock_)||(t=this.getNewLocationAfterDrag_(e).delta),this.dragTarget_&&this.dragTarget_.onDrop(this.draggingBlock_),!this.maybeDeleteBlock_()){let e;null==(e=this.workspace_.getLayerManager())||e.moveOffDragLayer(this.draggingBlock_,50),this.draggingBlock_.setDragging(!1),t?this.updateBlockAfterMove_():Jn(this.draggingBlock_.workspace,this.workspace_.getMetricsManager().getScrollMetrics(!0),this.draggingBlock_)}this.workspace_.setResizesEnabled(!0),Nr.setGroup$$module$build$src$core$events$utils(!1)}getNewLocationAfterDrag_(t){return{delta:t=this.pixelsToWorkspaceUnits_(t),newLocation:ca.sum(this.startXY_,t)}}maybeDeleteBlock_(){return!!this.wouldDeleteBlock_&&(this.fireMoveEvent_(),this.draggingBlock_.dispose(!1,!0),Xr.length=0,!0)}updateBlockAfterMove_(){this.fireMoveEvent_(),this.draggedConnectionManager_.wouldConnectBlock()?this.draggedConnectionManager_.applyConnections():this.draggingBlock_.queueRender(),this.draggingBlock_.scheduleSnapAndBump()}fireDragEndEvent_(){const t=new(P(sl))(this.draggingBlock_,!1,this.draggingBlock_.getDescendants(!1));A(t)}updateToolboxStyle_(t){const e=this.workspace_.getToolbox();if(e){const s=this.draggingBlock_.isDeletable()?"blocklyToolboxDelete":"blocklyToolboxGrab";t&&"function"==typeof e.removeStyle?e.removeStyle(s):t||"function"!=typeof e.addStyle||e.addStyle(s)}}fireMoveEvent_(){if(!this.draggingBlock_.isDeadOrDying()){var t=new(P(Nr.MOVE$$module$build$src$core$events$utils))(this.draggingBlock_);t.setReason(["drag"]),t.oldCoordinate=this.startXY_,t.recordNew(),A(t)}}updateCursorDuringBlockDrag_(){this.draggingBlock_.setDeleteStyle(this.wouldDeleteBlock_)}pixelsToWorkspaceUnits_(t){return t=new ca(t.x/this.workspace_.scale,t.y/this.workspace_.scale),this.workspace_.isMutator&&t.scale(1/this.workspace_.options.parentWorkspace.scale),t}dragIcons_(){st("Blockly.BlockDragger.prototype.dragIcons_","v10","v11")}getInsertionMarkers(){return this.draggedConnectionManager_&&this.draggedConnectionManager_.getInsertionMarkers?this.draggedConnectionManager_.getInsertionMarkers():[]}};t(Pr.BLOCK_DRAGGER,Br,Bp);var Pp={};Pp.Bubble=Ou,Pp.MiniWorkspaceBubble=yu,Pp.TextBubble=xu,Pp.TextInputBubble=Bu;var Fp=class extends Mc{constructor(t,e,s,i){super(t),this.type=qr,this.recordUndo=!1,t&&(this.name=e,this.oldValue=s,this.newValue=i)}toJson(){const t=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");return t.name=this.name,t.oldValue=this.oldValue,t.newValue=this.newValue,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Fp)).name=t.name,e.oldValue=t.oldValue,e.newValue=t.newValue,e}isNull(){return this.oldValue===this.newValue}run(t){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(!(e=e.getBlockById(this.blockId)))throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");t=t?this.newValue:this.oldValue,(e=e.getField(this.name))?e.setValue(t):console.warn("Can't set non-existent field: "+this.name)}};t(Pr.EVENT,qr,Fp);var Up=class extends Mc{constructor(t){super(t),this.type=Nr.MOVE$$module$build$src$core$events$utils,t&&(t.isShadow()&&(this.recordUndo=!1),t=this.currentLocation_(),this.oldParentId=t.parentId,this.oldInputName=t.inputName,this.oldCoordinate=t.coordinate)}toJson(){const t=super.toJson();return t.oldParentId=this.oldParentId,t.oldInputName=this.oldInputName,this.oldCoordinate&&(t.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`),t.newParentId=this.newParentId,t.newInputName=this.newInputName,this.newCoordinate&&(t.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`),this.reason&&(t.reason=this.reason),this.recordUndo||(t.recordUndo=this.recordUndo),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Up)).oldParentId=t.oldParentId,e.oldInputName=t.oldInputName,t.oldCoordinate&&(s=t.oldCoordinate.split(","),e.oldCoordinate=new ca(Number(s[0]),Number(s[1]))),e.newParentId=t.newParentId,e.newInputName=t.newInputName,t.newCoordinate&&(s=t.newCoordinate.split(","),e.newCoordinate=new ca(Number(s[0]),Number(s[1]))),void 0!==t.reason&&(e.reason=t.reason),void 0!==t.recordUndo&&(e.recordUndo=t.recordUndo),e}recordNew(){const t=this.currentLocation_();this.newParentId=t.parentId,this.newInputName=t.inputName,this.newCoordinate=t.coordinate}setReason(t){this.reason=t}currentLocation_(){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var e=t.getBlockById(this.blockId);if(!e)throw Error("The block associated with the block move event could not be found");t={};const s=e.getParent();return s?(t.parentId=s.id,(e=s.getInputWithBlock(e))&&(t.inputName=e.name)):t.coordinate=e.getRelativeToSurfaceXY(),t}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&ca.equals(this.oldCoordinate,this.newCoordinate)}run(t){var e=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");var s=e.getBlockById(this.blockId);if(s){var i=t?this.newParentId:this.oldParentId,o=t?this.newInputName:this.oldInputName;if(t=t?this.newCoordinate:this.oldCoordinate,i){var n=e.getBlockById(i);if(!n)return void console.warn("Can't connect to non-existent block: "+i)}if(s.getParent()&&s.unplug(),t)o=s.getRelativeToSurfaceXY(),s.moveBy(t.x-o.x,t.y-o.y,this.reason);else{let t,i;(!(e=s.outputConnection)||s.previousConnection&&s.previousConnection.isConnected())&&(e=s.previousConnection),s=null==(i=e)?void 0:i.type,o?(s=n.getInput(o))&&(t=s.connection):s===Pc.PREVIOUS_STATEMENT&&(t=n.nextConnection),t&&e?e.connect(t):console.warn("Can't connect to non-existent input: "+o)}}else console.warn("Can't move non-existent block: "+this.blockId)}};t(Pr.EVENT,Nr.MOVE$$module$build$src$core$events$utils,Up);var Hp,Gp=class extends Ol{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=rl,t&&(this.blockId=t.id,this.isOpen=e,this.bubbleType=s)}toJson(){const t=super.toJson();if(void 0===this.isOpen)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");return t.isOpen=this.isOpen,t.bubbleType=this.bubbleType,t.blockId=this.blockId||"",t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Gp)).isOpen=t.isOpen,e.bubbleType=t.bubbleType,e.blockId=t.blockId,e}};(function(t){t.MUTATOR="mutator",t.COMMENT="comment",t.WARNING="warning"})(Hp||(Hp={})),t(Pr.EVENT,rl,Gp);var Vp={};Vp.BubbleOpen=Gp,Vp.BubbleType=Hp;var Wp=class extends kl{constructor(t){super(),this.isBlank=!t,t&&(this.commentId=t.id,this.workspaceId=t.workspace.id,this.group=Nr.getGroup$$module$build$src$core$events$utils(),this.recordUndo=y())}toJson(){const t=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return t.commentId=this.commentId,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Wp)).commentId=t.commentId,e}static CommentCreateDeleteHelper(t,e){var s=t.getEventWorkspace_();if(e){if(e=Nr.createElement$$module$build$src$core$utils$xml("xml"),!t.xml)throw Error("Ecountered a comment event without proper xml");e.appendChild(t.xml),Nr.domToWorkspace$$module$build$src$core$xml(e,s)}else{if(!t.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(s=s.getCommentById(t.commentId))?s.dispose():console.warn("Can't uncreate non-existent comment: "+t.commentId)}}},Xp=class extends Wp{constructor(t,e,s){super(t),this.type=pl,t&&(this.oldContents_=void 0===e?"":e,this.newContents_=void 0===s?"":s)}toJson(){const t=super.toJson();if(!this.oldContents_)throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newContents_)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");return t.oldContents=this.oldContents_,t.newContents=this.newContents_,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Xp)).oldContents_=t.oldContents,e.newContents_=t.newContents,e}isNull(){return this.oldContents_===this.newContents_}run(t){var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(e=e.getCommentById(this.commentId)){var s=t?this.newContents_:this.oldContents_;if(!s){if(t)throw Error("The new contents is undefined. Either pass a value to the constructor, or call fromJson");throw Error("The old contents is undefined. Either pass a value to the constructor, or call fromJson")}e.setContent(s)}else console.warn("Can't change non-existent comment: "+this.commentId)}};t(Pr.EVENT,pl,Xp);var Yp=class extends Wp{constructor(t){super(t),this.type=ul,t&&(this.xml=t.toXmlWithXY())}toJson(){const t=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");return t.xml=Pe(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Yp)).xml=Nr.textToDom$$module$build$src$core$utils$xml(t.xml),e}run(t){Wp.CommentCreateDeleteHelper(this,t)}};t(Pr.EVENT,ul,Yp);var Kp=class extends Wp{constructor(t){super(t),this.type=dl,t&&(this.xml=t.toXmlWithXY())}run(t){Wp.CommentCreateDeleteHelper(this,!t)}toJson(){const t=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");return t.xml=Pe(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Kp)).xml=Nr.textToDom$$module$build$src$core$utils$xml(t.xml),e}};t(Pr.EVENT,dl,Kp);var zp=class extends Wp{constructor(t){super(t),this.type=gl,t&&(this.comment_=t,this.oldCoordinate_=t.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setOldCoordinate(t){this.oldCoordinate_=t}toJson(){const t=super.toJson();if(!this.oldCoordinate_)throw Error("The old comment position is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newCoordinate_)throw Error("The new comment position is undefined. Either call recordNew, or call fromJson");return t.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`,t.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y),t}static fromJson(t,e,s){return e=super.fromJson(t,e,null!=s?s:new zp),s=t.oldCoordinate.split(","),e.oldCoordinate_=new ca(Number(s[0]),Number(s[1])),s=t.newCoordinate.split(","),e.newCoordinate_=new ca(Number(s[0]),Number(s[1])),e}isNull(){return ca.equals(this.oldCoordinate_,this.newCoordinate_)}run(t){var e=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(e=e.getCommentById(this.commentId)){if(!(t=t?this.newCoordinate_:this.oldCoordinate_))throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");var s=e.getRelativeToSurfaceXY();e.moveBy(t.x-s.x,t.y-s.y)}else console.warn("Can't move non-existent comment: "+this.commentId)}};t(Pr.EVENT,gl,zp);var jp=class extends Ol{constructor(t,e,s){super(s),this.type=al,this.oldItem=null!=t?t:void 0,this.newItem=null!=e?e:void 0}toJson(){const t=super.toJson();return t.oldItem=this.oldItem,t.newItem=this.newItem,t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new jp)).oldItem=t.oldItem,e.newItem=t.newItem,e}};t(Pr.EVENT,al,jp),Nr.CHANGE$$module$build$src$core$events$utils,Nr.CREATE$$module$build$src$core$events$utils,Nr.DELETE$$module$build$src$core$events$utils,Nr.MOVE$$module$build$src$core$events$utils,Nr.CHANGE$$module$build$src$core$events$utils,Nr.CREATE$$module$build$src$core$events$utils,Nr.DELETE$$module$build$src$core$events$utils,Nr.MOVE$$module$build$src$core$events$utils,Nr.disable$$module$build$src$core$events$utils,Nr.enable$$module$build$src$core$events$utils,Nr.getGroup$$module$build$src$core$events$utils,Nr.setGroup$$module$build$src$core$events$utils;var Jp={};Jp.Abstract=kl,Jp.BLOCK_CHANGE=Nr.CHANGE$$module$build$src$core$events$utils,Jp.BLOCK_CREATE=Nr.CREATE$$module$build$src$core$events$utils,Jp.BLOCK_DELETE=Nr.DELETE$$module$build$src$core$events$utils,Jp.BLOCK_DRAG=sl,Jp.BLOCK_FIELD_INTERMEDIATE_CHANGE=qr,Jp.BLOCK_MOVE=Nr.MOVE$$module$build$src$core$events$utils,Jp.BUBBLE_OPEN=rl,Jp.BUMP_EVENTS=Tl,Jp.BlockBase=Mc,Jp.BlockChange=uu,Jp.BlockCreate=Dc,Jp.BlockDelete=jd,Jp.BlockDrag=Dp,Jp.BlockFieldIntermediateChange=Fp,Jp.BlockMove=Up,Jp.BubbleOpen=Gp,Jp.BubbleType=Hp,Jp.CHANGE=Nr.CHANGE$$module$build$src$core$events$utils,Jp.CLICK=ol,Jp.COMMENT_CHANGE=pl,Jp.COMMENT_CREATE=ul,Jp.COMMENT_DELETE=dl,Jp.COMMENT_MOVE=gl,Jp.CREATE=Nr.CREATE$$module$build$src$core$events$utils,Jp.Click=yl,Jp.ClickTarget=Rl,Jp.CommentBase=Wp,Jp.CommentChange=Xp,Jp.CommentCreate=Yp,Jp.CommentDelete=Kp,Jp.CommentMove=zp,Jp.DELETE=Nr.DELETE$$module$build$src$core$events$utils,Jp.FINISHED_LOADING=_l,Jp.FinishedLoading=Mp,Jp.MARKER_MOVE=nl,Jp.MOVE=Nr.MOVE$$module$build$src$core$events$utils,Jp.MarkerMove=Sd,Jp.SELECTED=il,Jp.Selected=dc,Jp.THEME_CHANGE=cl,Jp.TOOLBOX_ITEM_SELECT=al,Jp.TRASHCAN_OPEN=ll,Jp.ThemeChange=Bc,Jp.ToolboxItemSelect=jp,Jp.TrashcanOpen=zd,Jp.UI=el,Jp.UiBase=Ol,Jp.VAR_CREATE=Zr,Jp.VAR_DELETE=Qr,Jp.VAR_RENAME=tl,Jp.VIEWPORT_CHANGE=hl,Jp.VarBase=oc,Jp.VarCreate=nc,Jp.VarDelete=Ud,Jp.VarRename=Hd,Jp.ViewportChange=Fc,Jp.clearPendingUndo=N,Jp.disable=Nr.disable$$module$build$src$core$events$utils,Jp.disableOrphans=F,Jp.enable=Nr.enable$$module$build$src$core$events$utils,Jp.filter=w,Jp.fire=A,Jp.fromJson=B,Jp.get=P,Jp.getDescendantIds=x,Jp.getGroup=Nr.getGroup$$module$build$src$core$events$utils,Jp.getRecordUndo=y,Jp.isEnabled=M,Jp.setGroup=Nr.setGroup$$module$build$src$core$events$utils,Jp.setRecordUndo=O;var qp=class extends pd{constructor(){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.REPLACEMENT_GLOW_COLOUR="#fff200",this.REPLACEMENT_GLOW_SIZE=2,this.selectedGlowFilterId="",this.selectedGlowFilter=null,this.replacementGlowFilterId="",this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.replacementGlowFilter=null,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_(t){super.setFontConstants_(t),this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+2*this.FIELD_BORDER_RECT_Y_PADDING}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_(t){super.setDynamicProperties_(t),this.SELECTED_GLOW_COLOUR=t.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;const e=Number(t.getComponentStyle("selectedGlowSize"));this.SELECTED_GLOW_SIZE=e&&!isNaN(e)?e:this.SELECTED_GLOW_SIZE,this.REPLACEMENT_GLOW_COLOUR=t.getComponentStyle("replacementGlowColour")||this.REPLACEMENT_GLOW_COLOUR,this.REPLACEMENT_GLOW_SIZE=(t=Number(t.getComponentStyle("replacementGlowSize")))&&!isNaN(t)?t:this.REPLACEMENT_GLOW_SIZE}dispose(){super.dispose(),this.selectedGlowFilter&&at(this.selectedGlowFilter),this.replacementGlowFilter&&at(this.replacementGlowFilter)}makeStartHat(){const t=this.START_HAT_HEIGHT,e=this.START_HAT_WIDTH;return{height:t,width:e,path:en("c",[tn(25,-t),tn(71,-t),tn(e,0)])}}makeHexagonal(){function t(t,s,i){var o=t/2;return nn(-(i=i?-1:1)*(o=o>e?e:o),t=(s?-1:1)*t/2)+nn(i*o,t)}const e=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width:t=>(t/=2)>e?e:t,height:t=>t,connectionOffsetY:t=>t/2,connectionOffsetX:t=>-t,pathDown:e=>t(e,!1,!1),pathUp:e=>t(e,!0,!1),pathRightDown:e=>t(e,!1,!0),pathRightUp:e=>t(e,!1,!0)}}makeRounded(){function t(t,e,i){const o=t>s?t-s:0;return an("a","0 0,1",t=(t>s?s:t)/2,tn((e?-1:1)*t,(e?-1:1)*t))+ln("v",(i?1:-1)*o)+an("a","0 0,1",t,tn((e?1:-1)*t,(e?-1:1)*t))}const e=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,s=2*e;return{type:this.SHAPES.ROUND,isDynamic:!0,width:t=>(t/=2)>e?e:t,height:t=>t,connectionOffsetY:t=>t/2,connectionOffsetX:t=>-t,pathDown:e=>t(e,!1,!1),pathUp:e=>t(e,!0,!1),pathRightDown:e=>t(e,!1,!0),pathRightUp:e=>t(e,!1,!0)}}makeSquared(){function t(t,s,i){return t-=2*e,an("a","0 0,1",e,tn((s?-1:1)*e,(s?-1:1)*e))+ln("v",(i?1:-1)*t)+an("a","0 0,1",e,tn((s?1:-1)*e,(s?-1:1)*e))}const e=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width:t=>e,height:t=>t,connectionOffsetY:t=>t/2,connectionOffsetX:t=>-t,pathDown:e=>t(e,!1,!1),pathUp:e=>t(e,!0,!1),pathRightDown:e=>t(e,!1,!0),pathRightUp:e=>t(e,!1,!0)}}shapeFor(t){let e=t.getCheck();switch(!e&&t.targetConnection&&(e=t.targetConnection.getCheck()),t.type){case Pc.INPUT_VALUE:case Pc.OUTPUT_VALUE:if(null!==(t=t.getSourceBlock().getOutputShape()))switch(t){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return e&&-1!==e.indexOf("Boolean")?this.HEXAGONAL:(e&&-1!==e.indexOf("Number")||e&&e.indexOf("String"),this.ROUNDED);case Pc.PREVIOUS_STATEMENT:case Pc.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function t(t){return en("c",[tn(t*o/2,0),tn(t*o*3/4,r/2),tn(t*o,r)])+rn([tn(t*o,n)])+en("c",[tn(t*o/4,r/2),tn(t*o/2,r),tn(t*o,r)])+ln("h",t*i)+en("c",[tn(t*o/2,0),tn(t*o*3/4,-r/2),tn(t*o,-r)])+rn([tn(t*o,-n)])+en("c",[tn(t*o/4,-r/2),tn(t*o/2,-r),tn(t*o,-r)])}const e=this.NOTCH_WIDTH,s=this.NOTCH_HEIGHT,i=e/3,o=i/3,n=s/2,r=n/2,l=t(1),a=t(-1);return{type:this.SHAPES.NOTCH,width:e,height:s,pathLeft:l,pathRight:a}}makeInsideCorners(){const t=this.CORNER_RADIUS,e=an("a","0 0,0",t,tn(-t,t)),s=an("a","0 0,1",t,tn(-t,t));return{width:t,height:t,pathTop:e,pathBottom:an("a","0 0,0",t,tn(t,t)),rightWidth:t,rightHeight:t,pathTopRight:s,pathBottomRight:an("a","0 0,1",t,tn(t,t))}}generateSecondaryColour_(t){return Co("#000",t,.15)||t}generateTertiaryColour_(t){return Co("#000",t,.25)||t}createDom(t,e,s){super.createDom(t,e,s),t=it(ba.DEFS,{},t),e=it(ba.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(ba.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},e),s=it(ba.FECOMPONENTTRANSFER,{result:"outBlur"},e),it(ba.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},s),it(ba.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),it(ba.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.selectedGlowFilterId=e.id,this.selectedGlowFilter=e,t=it(ba.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(ba.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},t),e=it(ba.FECOMPONENTTRANSFER,{result:"outBlur"},t),it(ba.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},e),it(ba.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),it(ba.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),it(ba.FECOMPOSITE,{in:"SourceGraphic",in2:"outGlow",operator:"over"},t),this.replacementGlowFilterId=t.id,this.replacementGlowFilter=t}getCSS_(t){return[`${t} .blocklyText,`,`${t} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${t} .blocklyText {`,"fill: #fff;","}",`${t} .blocklyNonEditableText>rect:not(.blocklyDropdownRect),`,`${t} .blocklyEditableText>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${t} .blocklyNonEditableText>text,`,`${t} .blocklyEditableText>text,`,`${t} .blocklyNonEditableText>g>text,`,`${t} .blocklyEditableText>g>text {`,"fill: #575E75;","}",`${t} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${t} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${t} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>rect,",`${t} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${t} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${t} .blocklyDropdownText {`,"fill: #fff !important;","}",`${t}.blocklyWidgetDiv .goog-menuitem,`,`${t}.blocklyDropDownDiv .goog-menuitem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${t}.blocklyDropDownDiv .goog-menuitem-content {`,"color: #fff;","}",`${t} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${t} .blocklyDisabled > .blocklyOutlinePath {`,`fill: url(#blocklyDisabledPattern${this.randomIdentifier})`,"}",`${t} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},Zp=class extends _d{constructor(t,e){super(t,e)}draw(){const t=this.block_.pathObject;t.beginDrawing(),this.drawOutline_(),this.drawInternals_(),t.setPath(this.outlinePath_+"\n"+this.inlinePath_),this.info_.RTL&&t.flipRTL(),this.recordSizeOnBlock_(),this.info_.outputConnection&&(t.outputShapeType=this.info_.outputConnection.shape.type),t.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_(t){if(!(0>=t.height)){if(Xu.isSpacer(t)){const i=t.precedesStatement;var e=t.followsStatement;if(i||e){const o=this.constants_.INSIDE_CORNERS;var s=o.rightHeight;return s=t.height-(i?s:0),e=e?o.pathBottomRight:"",t=0=s||0>=e)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new $a(e,s+Qp.Y_PADDING),this.imageHeight=s,"function"==typeof o&&(this.clickHandler=o),t!==mu.SKIP_SETUP&&(r?this.configure_(r):(this.flipRtl=!!n,this.altText=Ao(i)||""),this.setValue(Ao(t)))}configure_(t){super.configure_(t),t.flipRtl&&(this.flipRtl=t.flipRtl),t.alt&&(this.altText=Ao(t.alt))}initView(){this.imageElement=it(ba.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(ga,"xlink:href",this.value_),this.clickHandler&&(this.imageElement.style.cursor="pointer")}updateSize_(){}doClassValidation_(t){return"string"!=typeof t?null:t}doValueUpdate_(t){this.value_=t,this.imageElement&&this.imageElement.setAttributeNS(ga,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl}setAlt(t){t!==this.altText&&(this.altText=t||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(t){this.clickHandler=t}getText_(){return this.altText}static fromJson(t){if(!t.src||!t.width||!t.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(t.src,t.width,t.height,void 0,void 0,void 0,t)}};Qp.Y_PADDING=1,Mo("field_image",Qp),Qp.prototype.DEFAULT_VALUE="";var tg=class extends mu{constructor(t,e,s){super(mu.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onKeyInputWrapper_=this.onKeyDownWrapper_=this.valueWhenEditorWasOpened_=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,this.CURSOR="text",t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),void 0!==t.spellcheck&&(this.spellcheck_=t.spellcheck)}initView(){if(!this.getSourceBlock())throw new Eu;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const t=this.getSourceBlock();if(!t)throw new Eu;let e;return this.fullBlockClickTarget_=!(null==(e=this.getConstants())||!e.FULL_BLOCK_FIELDS)&&t.isSimpleReporter()}doValueInvalid_(t){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,t=this.value_,this.value_=this.htmlInput_.getAttribute("data-untyped-default-value"),this.sourceBlock_&&M()&&A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock_,"field",this.name||null,t,this.value_)))}doValueUpdate_(t){this.isTextValid_=this.isDirty_=!0,this.value_=t}applyColour(){const t=this.getSourceBlock();if(!t)throw new Eu;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",t.style.colourTertiary)):(this.borderRect_.style.display="none",t.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR)))}getSize(){let t;return null!=(t=this.getConstants())&&t.FULL_BLOCK_FIELDS&&(this.render_(),this.isDirty_=!1),super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){if(super.render_(),this.isBeingEdited_){var t=this.htmlInput_;this.isTextValid_?(rt(t,"blocklyInvalidInput"),Bs(t,zc.INVALID,!1)):(ot(t,"blocklyInvalidInput"),Bs(t,zc.INVALID,!0))}if(!(t=this.getSourceBlock()))throw new Eu;this.getConstants().FULL_BLOCK_FIELDS&&t.applyColour()}setSpellcheck(t){t!==this.spellcheck_&&(this.spellcheck_=t,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(t,e=!1){this.workspace_=this.sourceBlock_.workspace,!e&&this.workspace_.options.modalInputs&&(Zl||zl||jl)?this.showPromptEditor_():this.showInlineEditor_(e)}showPromptEditor_(){te(Nr.Msg$$module$build$src$core$msg.CHANGE_VALUE_TITLE,this.getText(),(t=>{null!==t&&this.setValue(this.getValueFromEditorText_(t)),this.onFinishEditing_(this.value_)}))}showInlineEditor_(t){const e=this.getSourceBlock();if(!e)throw new Eu;Hs(this,e.RTL,this.widgetDispose_.bind(this)),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,this.valueWhenEditorWasOpened_=this.value_,t||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var t=this.getSourceBlock();if(!t)throw new Eu;Nr.setGroup$$module$build$src$core$events$utils(!0);const e=Ps();var s=this.getClickTarget_();if(!s)throw Error("A click target has not been set.");ot(s,"editing"),(s=document.createElement("input")).className="blocklyHtmlInput",s.setAttribute("spellcheck",this.spellcheck_);const i=this.workspace_.getScale();var o=this.getConstants().FIELD_TEXT_FONTSIZE*i+"pt";return e.style.fontSize=o,s.style.fontSize=o,o=tg.BORDERRADIUS*i+"px",this.isFullBlockField()&&(o=((o=this.getScaledBBox()).bottom-o.top)/2+"px",t=t.getParent()?t.getParent().style.colourTertiary:this.sourceBlock_.style.colourTertiary,s.style.border=1*i+"px solid "+t,e.style.borderRadius=o,e.style.transition="box-shadow 0.25s ease 0s",this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(e.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*i+"px")),s.style.borderRadius=o,e.appendChild(s),s.value=s.defaultValue=this.getEditorText_(this.value_),s.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(s),s}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&M()&&null!==this.valueWhenEditorWasOpened_&&this.valueWhenEditorWasOpened_!==this.value_&&(A(new(P(Nr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),Nr.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var t=Ps().style;if(t.width="auto",t.height="auto",t.fontSize="",t.transition="",t.boxShadow="",this.htmlInput_=null,!(t=this.getClickTarget_()))throw Error("A click target has not been set.");rt(t,"editing")}onFinishEditing_(t){}bindInputEvents_(t){this.onKeyDownWrapper_=Y(t,"keydown",this,this.onHtmlInputKeyDown_),this.onKeyInputWrapper_=Y(t,"input",this,this.onHtmlInputChange_)}unbindInputEvents_(){this.onKeyDownWrapper_&&(z(this.onKeyDownWrapper_),this.onKeyDownWrapper_=null),this.onKeyInputWrapper_&&(z(this.onKeyInputWrapper_),this.onKeyInputWrapper_=null)}onHtmlInputKeyDown_(t){"Enter"===t.key?(Gs(),Li()):"Escape"===t.key?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value")),Gs(),Li()):"Tab"===t.key&&(Gs(),Li(),this.sourceBlock_.tab(this,!t.shiftKey),t.preventDefault())}onHtmlInputChange_(t){t=this.value_,this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&M()&&this.value_!==t&&A(new(P(qr))(this.sourceBlock_,this.name||null,t,this.value_))}setEditorValue_(t,e=!0){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(t)),this.setValue(t,e)}resizeEditor_(){var t=this.getSourceBlock();if(!t)throw new Eu;const e=Ps(),s=this.getScaledBBox();e.style.width=s.right-s.left+"px",e.style.height=s.bottom-s.top+"px",t=new ca(t.RTL?s.right-e.offsetWidth:s.left,s.top),e.style.left=t.x+"px",e.style.top=t.y+"px"}repositionForWindowResize(){const t=this.getSourceBlock();return t instanceof op&&(Jn(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),t)||this.resizeEditor_(),!0)}isTabNavigable(){return!0}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(t){return`${t}`}getValueFromEditorText_(t){return t}};tg.BORDERRADIUS=4;var eg=class extends tg{constructor(t,e,s){super(t,e,s)}doClassValidation_(t){return void 0===t?null:`${t}`}static fromJson(t){return new this(Ao(t.text),void 0,t)}};Mo("field_input",eg),eg.prototype.DEFAULT_VALUE="";var sg=class extends zu{constructor(t){super(t)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(t){return!!t.outputConnection}hasRightSquareCorner(t){return!!t.outputConnection&&!t.statementInputCount&&!t.nextConnection}},ig=class extends id{constructor(t,e){if(super(t,e),this.connectedBottomNextConnection=!1,this.connectedBlock){for(t=this.connectedBlock;e=t.getNextBlock();)t=e;t.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},og=class extends Yu{constructor(t){super(t),this.width=this.height=0,this.type|=Xu.getType("RIGHT_CONNECTION")}},ng=class extends dd{constructor(t){super(t)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(t){const e=(t.hat?"cap"===t.hat:this.constants_.ADD_START_HATS)&&!t.outputConnection&&!t.previousConnection;return!!t.outputConnection||e}hasRightSquareCorner(t){return!!t.outputConnection&&!t.statementInputCount&&!t.nextConnection}},rg=class extends $d{constructor(t,e){super(t,e),this.isInline=!0,this.renderer_=t,this.constants_=this.renderer_.getConstants(),this.topRow=new ng(this.constants_),this.bottomRow=new sg(this.constants_),this.isMultiRow=!e.getInputsInline()||e.isCollapsed(),this.hasStatementInput=0=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!i.precedesStatement,Xu.isInputRow(n)&&n.hasStatement){let s,i;n.measure(),e=n.width-(null!=(i=null==(s=n.getLastInput())?void 0:s.width)?i:0)+t}else if(s&&(2===o||i)&&Xu.isInputRow(n)&&!n.hasStatement){i=n.xPos,s=null;for(let t=0;ts?s:this.height/2)*(1-Math.sin(Math.acos((s-this.constants_.SMALL_PADDING)/s)))):0;if(Xu.isInlineInput(t)&&t instanceof Ju){const o=t.connectedBlock;return null==(t=o?o.pathObject.outputShapeType:t.shape.type)||o&&o.outputConnection&&(o.statementInputCount||o.nextConnection)||s===i.SHAPES.HEXAGONAL&&s!==t?0:e-this.constants_.SHAPE_IN_SHAPE_PADDING[s][t]}return Xu.isField(t)&&t instanceof Zu?s===i.SHAPES.ROUND&&t.field instanceof eg?e-2.75*i.GRID_UNIT:e-this.constants_.SHAPE_IN_SHAPE_PADDING[s][0]:Xu.isIcon(t)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let i=2;i=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!r.precedesStatement;if(t?this.topRow.hasPreviousConnection:o.followsStatement){var s=n.elements[1];if(s=3===n.elements.length&&s instanceof Zu&&(s.field instanceof Td||s.field instanceof Qp),!t&&s)o.height-=this.constants_.SMALL_PADDING,r.height-=this.constants_.SMALL_PADDING,n.height-=this.constants_.MEDIUM_PADDING;else if(t||e){if(e){for(t=!1,e=0;ee;e+=15)it(ba.LINE,{x1:pg.HALF+pg.RADIUS,y1:pg.HALF,x2:pg.HALF+pg.RADIUS-(0==e%45?10:5),y2:pg.HALF,class:"blocklyAngleMarks",transform:"rotate("+e+","+pg.HALF+","+pg.HALF+")"},t);return this.boundEvents.push(Y(t,"click",this,this.hide)),this.boundEvents.push(Y(e,"pointerdown",this,this.onMouseMove_,!0)),this.boundEvents.push(Y(e,"pointermove",this,this.onMouseMove_,!0)),t}dropdownDispose(){for(const t of this.boundEvents)z(t);this.boundEvents.length=0,this.line=this.gauge=null}hide(){Ai(this),Gs()}onMouseMove_(t){var e=this.gauge.ownerSVGElement.getBoundingClientRect();const s=t.clientX-e.left-pg.HALF;t=t.clientY-e.top-pg.HALF,e=Math.atan(-t/s),isNaN(e)||(e=hi(e),0>s?e+=180:0(t%=360)&&(t+=360),t>this.wrap&&(t-=360),t}static fromJson(t){return new this(t.angle,void 0,t)}};pg.HALF=50,pg.RADIUS=pg.HALF-1,pg.CLOCKWISE=!1,pg.OFFSET=0,pg.WRAP=360,pg.ROUND=15,Mo("field_angle",pg),pg.prototype.DEFAULT_VALUE=0,tt("\n.blocklyAngleCircle {\n stroke: #444;\n stroke-width: 1;\n fill: #ddd;\n fill-opacity: 0.8;\n}\n\n.blocklyAngleMarks {\n stroke: #444;\n stroke-width: 1;\n}\n\n.blocklyAngleGauge {\n fill: #f88;\n fill-opacity: 0.8;\n pointer-events: none;\n}\n\n.blocklyAngleLine {\n stroke: #f00;\n stroke-width: 2;\n stroke-linecap: round;\n pointer-events: none;\n}\n"),function(t){t.COMPASS="compass",t.PROTRACTOR="protractor"}(dg||(dg={}));var gg={};gg.FieldAngle=pg,gg.Mode=dg;var _g=class extends mu{constructor(t,e,s){super(mu.SKIP_SETUP),this.SERIALIZABLE=!0,this.CURSOR="default",this.value_=this.value_,this.checkChar=_g.CHECK_CHAR,t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),t.checkCharacter&&(this.checkChar=t.checkCharacter)}saveState(){const t=this.saveLegacyState(_g);return null!==t?t:this.getValueBoolean()}initView(){super.initView();const t=this.getTextElement();ot(t,"blocklyCheckbox"),t.style.display=this.value_?"block":"none"}render_(){this.textContent_&&(this.textContent_.nodeValue=this.getDisplayText_()),this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET)}getDisplayText_(){return this.checkChar}setCheckCharacter(t){this.checkChar=t||_g.CHECK_CHAR,this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(t){return!0===t||"TRUE"===t?"TRUE":!1===t||"FALSE"===t?"FALSE":null}doValueUpdate_(t){this.value_=this.convertValueToBool_(t),this.textElement_&&(this.textElement_.style.display=this.value_?"block":"none")}getValue(){return this.value_?"TRUE":"FALSE"}getValueBoolean(){return this.value_}getText(){return String(this.convertValueToBool_(this.value_))}convertValueToBool_(t){return"string"==typeof t?"TRUE"===t:!!t}static fromJson(t){return new this(t.checked,void 0,t)}};_g.CHECK_CHAR="✓",Mo("field_checkbox",_g),_g.prototype.DEFAULT_VALUE=!1;var Tg=class extends mu{constructor(t,e,s){super(mu.SKIP_SETUP),this.highlightedIndex=this.picker=null,this.boundEvents=[],this.SERIALIZABLE=!0,this.CURSOR="default",this.isDirty_=!1,this.titles=this.colours=null,this.columns=0,t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),t.colourOptions&&(this.colours=t.colourOptions),t.colourTitles&&(this.titles=t.colourTitles),t.columns&&(this.columns=t.columns)}initView(){this.size_=new $a(this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT),this.createBorderRect_(),this.getBorderRect().style.fillOpacity="1",this.getBorderRect().setAttribute("stroke","#fff"),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const t=this.getSourceBlock();if(!t)throw new Eu;const e=this.getConstants();return t.isSimpleReporter()&&!(null==e||!e.FIELD_COLOUR_FULL_BLOCK)}applyColour(){const t=this.getSourceBlock();if(!t)throw new Eu;if(this.fieldGroup_){var e=this.borderRect_;if(!e)throw Error("The border rect has not been initialized");this.isFullBlockField()?(e.style.display="none",t.pathObject.svgPath.setAttribute("fill",this.getValue()),t.pathObject.svgPath.setAttribute("stroke","#fff")):(e.style.display="block",e.style.fill=this.getValue())}}getSize(){let t;return null!=(t=this.getConstants())&&t.FIELD_COLOUR_FULL_BLOCK&&(this.render_(),this.isDirty_=!1),super.getSize()}render_(){super.render_();const t=this.getSourceBlock();if(!t)throw new Eu;t.applyColour()}updateSize_(t){var e=this.getConstants();this.isFullBlockField()?(t=2*(null!=t?t:0),e=e.FIELD_TEXT_HEIGHT):(t=e.FIELD_COLOUR_DEFAULT_WIDTH,e=e.FIELD_COLOUR_DEFAULT_HEIGHT),this.size_.height=e,this.size_.width=t,this.positionBorderRect_()}doClassValidation_(t){return"string"!=typeof t?null:$o(t)}getText(){let t=this.value_;return/^#(.)\1(.)\2(.)\3$/.test(t)&&(t="#"+t[1]+t[3]+t[5]),t}setColours(t,e){return this.colours=t,e&&(this.titles=e),this}setColumns(t){return this.columns=t,this}showEditor_(){this.dropdownCreate(),_i().appendChild(this.picker),bi(this,this.dropdownDispose.bind(this)),this.picker.focus({preventScroll:!0})}onClick(t){null!==(t=(t=t.target)&&t.getAttribute("data-colour"))&&(this.setValue(t),Ai(this))}onKeyDown(t){let e=!0;var s;switch(t.key){case"ArrowUp":this.moveHighlightBy(0,-1);break;case"ArrowDown":this.moveHighlightBy(0,1);break;case"ArrowLeft":this.moveHighlightBy(-1,0);break;case"ArrowRight":this.moveHighlightBy(1,0);break;case"Enter":(s=this.getHighlighted())&&null!==(s=s.getAttribute("data-colour"))&&this.setValue(s),Li();break;default:e=!1}e&&t.stopPropagation()}moveHighlightBy(t,e){if(this.highlightedIndex){var s=this.colours||Tg.COLOURS,i=this.columns||Tg.COLUMNS,o=this.highlightedIndex%i,n=Math.floor(this.highlightedIndex/i);o+=t,n+=e,0>t?0>o&&0o&&(o=0):0i-1&&ni-1&&o--:0>e?0>n&&(n=0):0Math.floor(s.length/i)-1&&(n=Math.floor(s.length/i)-1),this.setHighlightedCell(this.picker.childNodes[n].childNodes[o],n*i+o)}}onMouseMove(t){const e=(t=t.target)&&Number(t.getAttribute("data-index"));null!==e&&e!==this.highlightedIndex&&this.setHighlightedCell(t,e)}onMouseEnter(){let t;null==(t=this.picker)||t.focus({preventScroll:!0})}onMouseLeave(){var t;null==(t=this.picker)||t.blur(),(t=this.getHighlighted())&&rt(t,"blocklyColourHighlighted")}getHighlighted(){if(!this.highlightedIndex)return null;const t=this.columns||Tg.COLUMNS,e=this.picker.childNodes[Math.floor(this.highlightedIndex/t)];return e?e.childNodes[this.highlightedIndex%t]:null}setHighlightedCell(t,e){const s=this.getHighlighted();s&&rt(s,"blocklyColourHighlighted"),ot(t,"blocklyColourHighlighted"),this.highlightedIndex=e,(t=t.getAttribute("id"))&&this.picker&&Bs(this.picker,zc.ACTIVEDESCENDANT,t)}dropdownCreate(){const t=this.columns||Tg.COLUMNS,e=this.colours||Tg.COLOURS,s=this.titles||Tg.TITLES,i=this.getValue(),o=document.createElement("table");let n;o.className="blocklyColourTable",o.tabIndex=0,o.dir="ltr",xs(o,Kc.GRID),Bs(o,zc.EXPANDED,!0),Bs(o,zc.ROWCOUNT,Math.floor(e.length/t)),Bs(o,zc.COLCOUNT,t);for(let r=0;rtr>td {\n border: 0.5px solid #888;\n box-sizing: border-box;\n cursor: pointer;\n display: inline-block;\n height: 20px;\n padding: 0;\n width: 20px;\n}\n\n.blocklyColourTable>tr>td.blocklyColourHighlighted {\n border-color: #eee;\n box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);\n position: relative;\n}\n\n.blocklyColourSelected, .blocklyColourSelected:hover {\n border-color: #eee !important;\n outline: 1px solid #333;\n position: relative;\n}\n");var mg=class extends Td{constructor(t,e,s){super(String(null!=t?t:""),e,s),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(t){return new this(Ao(t.text),void 0,t)}};Mo("field_label_serializable",mg);var Eg=class extends eg{constructor(t,e,s){super(mu.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,t!==mu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){super.configure_(t),t.maxLines&&this.setMaxLines(t.maxLines)}toXml(t){return t.textContent=this.getValue().replace(/\n/g," "),t}fromXml(t){this.setValue(t.textContent.replace(/ /g,"\n"))}saveState(){const t=this.saveLegacyState(Eg);return null!==t?t:this.getValue()}loadState(t){this.loadLegacyState(mu,t)||this.setValue(t)}initView(){this.createBorderRect_(),this.textGroup=it(ba.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const t=this.getSourceBlock();if(!t)throw new Eu;let e=this.getText();if(!e)return mu.NBSP;const s=e.split("\n");e="";const i=this.isOverflowedY_?this.maxLines_:s.length;for(let t=0;tthis.maxDisplayLength?o=o.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&t===i-1&&(o=o.substring(0,o.length-3)+"..."),o=o.replace(/\s/g,mu.NBSP),e+=o,t!==i-1&&(e+="\n")}return t.RTL&&(e+="‏"),e}doValueUpdate_(t){super.doValueUpdate_(t),null!==this.value_&&(this.isOverflowedY_=this.value_.split("\n").length>this.maxLines_)}render_(){var t=this.getSourceBlock();if(!t)throw new Eu;for(var e,s=this.textGroup;e=s.firstChild;)s.removeChild(e);e=this.getDisplayText_().split("\n");let i=0;for(let t=0;to&&(o=l),n+=this.getConstants().FIELD_TEXT_HEIGHT+(0this.maxDisplayLength&&(t[l]=t[l].substring(0,this.maxDisplayLength)),r.textContent=t[l];const n=_t(r,e,s,i);n>o&&(o=n)}o+=this.htmlInput_.offsetWidth-this.htmlInput_.clientWidth}this.borderRect_&&(n+=2*this.getConstants().FIELD_BORDER_RECT_Y_PADDING,o+=2*this.getConstants().FIELD_BORDER_RECT_X_PADDING,this.borderRect_.setAttribute("width",`${o}`),this.borderRect_.setAttribute("height",`${n}`)),this.size_.width=o,this.size_.height=n,this.positionBorderRect_()}showEditor_(t,e){super.showEditor_(t,e),this.forceRerender()}widgetCreate_(){const t=Ps(),e=this.workspace_.getScale(),s=document.createElement("textarea");s.className="blocklyHtmlInput blocklyHtmlTextAreaInput",s.setAttribute("spellcheck",String(this.spellcheck_));var i=this.getConstants().FIELD_TEXT_FONTSIZE*e+"pt";t.style.fontSize=i,s.style.fontSize=i,s.style.borderRadius=eg.BORDERRADIUS*e+"px",i=this.getConstants().FIELD_BORDER_RECT_X_PADDING*e;const o=this.getConstants().FIELD_BORDER_RECT_Y_PADDING*e/2;return s.style.padding=o+"px "+i+"px "+o+"px "+i+"px",i=this.getConstants().FIELD_TEXT_HEIGHT+this.getConstants().FIELD_BORDER_RECT_Y_PADDING,s.style.lineHeight=i*e+"px",t.appendChild(s),s.value=s.defaultValue=this.getEditorText_(this.value_),s.setAttribute("data-untyped-default-value",String(this.value_)),s.setAttribute("data-old-value",""),Kl?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(s),s}setMaxLines(t){"number"==typeof t&&0this.max_&&(t.max=`${this.max_}`,Bs(t,zc.VALUEMAX,this.max_)),t}static fromJson(t){return new this(t.value,void 0,void 0,void 0,void 0,t)}};Mo("field_number",bg),bg.prototype.DEFAULT_VALUE=0;var fg=class extends Ru{constructor(t,e,s,i,o){super(mu.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=fg.dropdownCreate,this.defaultVariableName="string"==typeof t?t:"",this.size_=new $a(0,0),t!==mu.SKIP_SETUP&&(o?this.configure_(o):this.setTypes(s,i),e&&this.setValidator(e))}configure_(t){super.configure_(t),this.setTypes(t.variableTypes,t.defaultType)}initModel(){var t=this.getSourceBlock();if(!t)throw new Eu;this.variable||(t=Nr.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(t.getId()))}shouldAddBorderRect_(){const t=this.getSourceBlock();if(!t)throw new Eu;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||"variables_get"!==t.type)}fromXml(t){var e=this.getSourceBlock();if(!e)throw new Eu;const s=t.getAttribute("id"),i=t.textContent,o=t.getAttribute("variabletype")||t.getAttribute("variableType")||"";if(e=Nr.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,s,i,o),null!==o&&o!==e.type)throw Error("Serialized variable type with id '"+e.getId()+"' had type "+e.type+", and does not match variable field that references it: "+Pe(t)+".");this.setValue(e.getId())}toXml(t){return this.initModel(),t.id=this.variable.getId(),t.textContent=this.variable.name,this.variable.type&&t.setAttribute("variabletype",this.variable.type),t}saveState(t){var e=this.saveLegacyState(fg);return null!==e||(this.initModel(),e={id:this.variable.getId()},t&&(e.name=this.variable.name,e.type=this.variable.type)),e}loadState(t){const e=this.getSourceBlock();if(!e)throw new Eu;this.loadLegacyState(fg,t)||(t=Nr.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,t.id||null,t.name,t.type||""),this.setValue(t.getId()))}setSourceBlock(t){if(t.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(t)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.name:""}getVariable(){return this.variable}getValidator(){return this.variable?this.validator_:null}doClassValidation_(t){if(null===t)return null;var e=this.getSourceBlock();if(!e)throw new Eu;return(e=Nr.getVariable$$module$build$src$core$variables(e.workspace,t))?(e=e.type,this.typeIsAllowed(e)?t:(console.warn("Variable type doesn't match this field! Type was "+e),null)):(console.warn("Variable id doesn't point to a real variable! ID was "+t),null)}doValueUpdate_(t){const e=this.getSourceBlock();if(!e)throw new Eu;this.variable=Nr.getVariable$$module$build$src$core$variables(e.workspace,t),super.doValueUpdate_(t)}typeIsAllowed(t){const e=this.getVariableTypes();if(!e)return!0;for(let s=0;s{const s=this.targetWorkspace.getGesture(e);s&&(s.setStartBlock(t),s.handleFlyoutStart(e,this))}}onMouseDown(t){const e=this.targetWorkspace.getGesture(t);e&&e.handleFlyoutStart(t,this)}isBlockCreatable(t){return t.isEnabled()}createBlock(t){let e=null;Nr.disable$$module$build$src$core$events$utils();var s=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{e=this.placeNewBlock(t)}finally{Nr.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),t=be(this.targetWorkspace,s),M()){for(Nr.setGroup$$module$build$src$core$events$utils(!0),s=0;s90-e||t>-90-e&&t<-90+e}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const t=this.svgGroup_.getBoundingClientRect(),e=t.top;return this.toolboxPosition_===xa.TOP?new fa(-1e9,e+t.height,-1e9,1e9):new fa(e,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let t=0;const e=this.workspace_.getTopBlocks(!1);for(let s,i=0;s=e[i];i++)t=Math.max(t,s.getHeightWidth().height);const s=this.buttons_;for(let e,i=0;e=s[i];i++)t=Math.max(t,e.height);if(t+=1.5*this.MARGIN,t*=this.workspace_.scale,t+=Oa.scrollbarThickness,this.height_!==t){for(let t,s=0;t=e[s];s++)this.rectMap_.has(t)&&this.moveRectToBlock_(this.rectMap_.get(t),t);this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==xa.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+t),this.height_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};t(Pr.FLYOUTS_HORIZONTAL_TOOLBOX,Br,Cg);var kg=class extends Rg{constructor(t){super(t)}setMetrics_(t){if(this.isVisible()){var e=this.workspace_.getMetricsManager(),s=e.getScrollMetrics(),i=e.getViewMetrics();e=e.getAbsoluteMetrics(),"number"==typeof t.y&&(this.workspace_.scrollY=-(s.top+(s.height-i.height)*t.y)),this.workspace_.translate(this.workspace_.scrollX+e.left,this.workspace_.scrollY+e.top)}}getX(){if(!this.isVisible())return 0;var t=this.targetWorkspace.getMetricsManager();const e=t.getAbsoluteMetrics(),s=t.getViewMetrics();return t=t.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===xa.LEFT?t.width:s.width-this.width_:this.toolboxPosition_===xa.LEFT?0:s.width:this.toolboxPosition_===xa.LEFT?0:s.width+e.left-this.width_}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var t=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=t.height,this.setBackgroundPath(this.width_-this.CORNER_RADIUS,t.height-2*this.CORNER_RADIUS),t=this.getX();var e=this.getY();this.positionAt_(this.width_,this.height_,t,e)}}setBackgroundPath(t,e){const s=this.toolboxPosition_===xa.RIGHT;var i=t+this.CORNER_RADIUS;(i=["M "+(s?i:0)+",0"]).push("h",s?-t:t),i.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,s?0:1,s?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),i.push("v",Math.max(0,e)),i.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,s?0:1,s?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),i.push("h",s?t:-t),i.push("z"),this.svgBackground_.setAttribute("d",i.join(" "))}scrollToStart(){let t;null==(t=this.workspace_.scrollbar)||t.setY(0)}wheel_(t){var e=Z(t);if(e.y){const t=this.workspace_.getMetricsManager(),s=t.getScrollMetrics();let i;e=t.getViewMetrics().top-s.top+e.y,null==(i=this.workspace_.scrollbar)||i.setY(e),Gs(),Li()}t.preventDefault(),t.stopPropagation()}layout_(t,e){this.workspace_.scale=this.targetWorkspace.scale;var s=this.MARGIN;const i=this.RTL?s:s+this.tabWidth_;for(let l,a=0;l=t[a];a++)if("block"===l.type){var o=l.block,n=o.getDescendants(!1);for(let t,e=0;t=n[e];e++)t.isInFlyout=!0;n=o.getSvgRoot();const t=o.getHeightWidth();var r=o.outputConnection?i-this.tabWidth_:i;o.moveBy(r,s),r=this.createRect_(o,this.RTL?r-t.width:r,s,t,a),this.addBlockListeners_(n,o,r),s+=t.height+e[a]}else"button"===l.type&&(o=l.button,this.initFlyoutButton_(o,i,s),s+=o.height+e[a])}isDragTowardWorkspace(t){t=Math.atan2(t.y,t.x)/Math.PI*180;const e=this.dragAngleRange_;return t-e||t<-180+e||t>180-e}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const t=this.svgGroup_.getBoundingClientRect(),e=t.left;return this.toolboxPosition_===xa.LEFT?new fa(-1e9,1e9,-1e9,e+t.width):new fa(-1e9,1e9,e,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let t=0;var e=this.workspace_.getTopBlocks(!1);for(let i,o=0;i=e[o];o++){var s=i.getHeightWidth().width;i.outputConnection&&(s-=this.tabWidth_),t=Math.max(t,s)}for(let e,s=0;e=this.buttons_[s];s++)t=Math.max(t,e.width);if(t+=1.5*this.MARGIN+this.tabWidth_,t*=this.workspace_.scale,t+=Oa.scrollbarThickness,this.width_!==t){for(let i,o=0;i=e[o];o++){if(this.RTL){s=i.getRelativeToSurfaceXY().x;let e=t/this.workspace_.scale-this.MARGIN;i.outputConnection||(e-=this.tabWidth_),i.moveBy(e-s,0)}this.rectMap_.has(i)&&this.moveRectToBlock_(this.rectMap_.get(i),i)}if(this.RTL)for(let s,i=0;s=this.buttons_[i];i++)e=s.getPosition().y,s.moveTo(t/this.workspace_.scale-s.width-this.MARGIN-this.tabWidth_,e);this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==xa.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+t,this.targetWorkspace.scrollY),this.width_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};kg.registryName="verticalFlyout",t(Pr.FLYOUTS_VERTICAL_TOOLBOX,Br,kg),Nr.CodeGenerator$$module$build$src$core$generator=class{constructor(t){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_=t,this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(t){t||(console.warn("No workspace specified in workspaceToCode call. Guessing."),t=g());var e=[];this.init(t),t=t.getTopBlocks(!0);for(let s,i=0;s=t[i];i++){let t=this.blockToCode(s);Array.isArray(t)&&(t=t[0]),t&&(s.outputConnection&&(t=this.scrubNakedValue(t),this.STATEMENT_PREFIX&&!s.suppressPrefixSuffix&&(t=this.injectId(this.STATEMENT_PREFIX,s)+t),this.STATEMENT_SUFFIX&&!s.suppressPrefixSuffix&&(t+=this.injectId(this.STATEMENT_SUFFIX,s))),e.push(t))}return e=e.join("\n"),(e=(e=(e=this.finish(e)).replace(/^\s+\n/,"")).replace(/\n\s+$/,"\n")).replace(/[ \t]+\n/g,"\n")}prefixLines(t,e){return e+t.replace(/(?!\n$)\n/g,"\n"+e)}allNestedComments(t){const e=[];t=t.getDescendants(!0);for(let s=0;s.blocklyPathLight,`,`${t} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},vg=class{constructor(t){this.inlineSteps_=this.steps_="",this.info_=t,this.RTL_=this.info_.RTL,t=t.getRenderer(),this.constants_=t.getConstants(),this.highlightConstants_=t.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(t){this.steps_+=on(t.xPos,this.info_.startY);for(let e,s=0;e=t.elements[s];s++)Xu.isLeftSquareCorner(e)?this.steps_+=this.highlightConstants_.START_POINT:Xu.isLeftRoundedCorner(e)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):Xu.isPreviousConnection(e)?this.steps_+=this.notchPaths_.pathLeft:Xu.isHat(e)?this.steps_+=this.startPaths_.path(this.RTL_):Xu.isSpacer(e)&&0!==e.width&&(this.steps_+=ln("H",e.xPos+e.width-this.highlightOffset));this.steps_+=ln("H",t.xPos+t.width-this.highlightOffset)}drawJaggedEdge_(t){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+ln("v",t.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(t){const e=t.getLastInput();if(this.RTL_){const s=t.height-e.connectionHeight;this.steps_+=sn(e.xPos+e.width-this.highlightOffset,t.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+ln("v",s)}else this.steps_+=sn(e.xPos+e.width,t.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(t){const e=t.getLastInput();if(e)if(this.RTL_){const s=t.height-2*this.insideCornerPaths_.height;this.steps_+=sn(e.xPos,t.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+ln("v",s)+this.insideCornerPaths_.pathBottom(this.RTL_)+nn(t.width-e.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=sn(e.xPos,t.yPos+t.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+nn(t.width-e.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(t){const e=t.xPos+t.width-this.highlightOffset;t instanceof hd&&t.followsStatement&&(this.steps_+=ln("H",e)),this.RTL_&&(this.steps_+=ln("H",e),t.height>this.highlightOffset&&(this.steps_+=ln("V",t.yPos+t.height-this.highlightOffset)))}drawBottomRow(t){if(this.RTL_)this.steps_+=ln("V",t.baseline-this.highlightOffset);else{const e=this.info_.bottomRow.elements[0];Xu.isLeftSquareCorner(e)?this.steps_+=sn(t.xPos+this.highlightOffset,t.baseline-this.highlightOffset):Xu.isLeftRoundedCorner(e)&&(this.steps_+=sn(t.xPos,t.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var t=this.info_.outputConnection;t&&(t=t.connectionOffsetY+t.height,this.RTL_?this.steps_+=sn(this.info_.startX,t):(this.steps_+=sn(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=ln("V",t)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(t=this.info_.topRow,Xu.isLeftRoundedCorner(t.elements[0])?this.steps_+=ln("V",this.outsideCornerPaths_.height):this.steps_+=ln("V",t.capline+this.highlightOffset))}drawInlineInput(t){const e=this.highlightOffset,s=t.xPos+t.connectionWidth;var i=t.centerline-t.height/2;const o=t.width-t.connectionWidth,n=i+e;this.RTL_?(i=t.connectionOffsetY-e,t=t.height-(t.connectionOffsetY+t.connectionHeight)+e,this.inlineSteps_+=sn(s-e,n)+ln("v",i)+this.puzzleTabPaths_.pathDown(this.RTL_)+ln("v",t)+ln("h",o)):this.inlineSteps_+=sn(t.xPos+t.width+e,n)+ln("v",t.height)+ln("h",-o)+sn(s,i+t.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Lg=class extends _d{constructor(t,e){super(t,e),this.highlighter_=new vg(e)}draw(){this.drawOutline_(),this.drawInternals_();const t=this.block_.pathObject;t.setPath(this.outlinePath_+"\n"+this.inlinePath_),t.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&t.flipRTL(),this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow),this.highlighter_.drawRightSideRow(this.info_.topRow),super.drawTop_()}drawJaggedEdge_(t){this.highlighter_.drawJaggedEdge_(t),super.drawJaggedEdge_(t)}drawValueInput_(t){this.highlighter_.drawValueInput(t),super.drawValueInput_(t)}drawStatementInput_(t){this.highlighter_.drawStatementInput(t),super.drawStatementInput_(t)}drawRightSideRow_(t){this.highlighter_.drawRightSideRow(t),this.outlinePath_+=ln("H",t.xPos+t.width)+ln("V",t.yPos+t.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow),super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft(),super.drawLeft_()}drawInlineInput_(t){this.highlighter_.drawInlineInput(t),super.drawInlineInput_(t)}positionInlineInputConnection_(t){const e=t.centerline-t.height/2;if(t.connectionModel){let s=t.xPos+t.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(s*=-1),t.connectionModel.setOffsetInBlock(s,e+t.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(t){const e=t.getLastInput();if(null!=e&&e.connectionModel){let s=t.xPos+t.statementEdge+e.notchOffset;s=this.info_.RTL?-1*s:s+this.constants_.DARK_PATH_OFFSET,e.connectionModel.setOffsetInBlock(s,t.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(t){const e=t.getLastInput();if(e&&e.connectionModel){let s=t.xPos+t.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(s*=-1),e.connectionModel.setOffsetInBlock(s,t.yPos)}}positionNextConnection_(){const t=this.info_.bottomRow;if(t.connection){const e=t.connection,s=e.xPos;e.connectionModel.setOffsetInBlock((this.info_.RTL?-s:s)+this.constants_.DARK_PATH_OFFSET/2,t.baseline+this.constants_.DARK_PATH_OFFSET)}}},wg=class{constructor(t){this.OFFSET=.5,this.constantProvider=t,this.START_POINT=on(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(){const t=this.constantProvider.CORNER_RADIUS,e=this.OFFSET,s=(1-Math.SQRT1_2)*(t+e)-e,i=on(s,s)+an("a","0 0,0",t,tn(-s-e,t-s)),o=an("a","0 0,0",t+e,tn(t+e,t+e)),n=on(s,-s)+an("a","0 0,0",t+e,tn(t-s,s+e));return{width:t+e,height:t,pathTop:t=>t?i:"",pathBottom:t=>t?o:n}}makeOutsideCorner(){const t=this.constantProvider.CORNER_RADIUS,e=this.OFFSET,s=(1-Math.SQRT1_2)*(t-e)+e,i=on(s,s)+an("a","0 0,1",t-e,tn(t-s,-s+e)),o=on(e,t)+an("a","0 0,1",t-e,tn(t,-t+e)),n=-s,r=on(s,n)+an("a","0 0,1",t-e,tn(-s+e,-n-t));return{height:t,topLeft:t=>t?i:o,bottomLeft:()=>r}}makePuzzleTab(){const t=this.constantProvider.TAB_WIDTH,e=this.constantProvider.TAB_HEIGHT,s=on(-2,3.4-e)+nn(-.45*t,-2.1),i=ln("v",2.5)+on(.97*-t,2.5)+en("q",[tn(.05*-t,10),tn(.3*t,9.5)])+on(.67*t,-1.9)+ln("v",2.5),o=ln("v",-1.5)+on(-.92*t,-.5)+en("q",[tn(-.19*t,-5.5),tn(0,-11)])+on(.92*t,1),n=on(-5,e-.7)+nn(.46*t,-2.1);return{width:t,height:e,pathUp:t=>t?s:o,pathDown:t=>t?i:n}}makeNotch(){return{pathLeft:ln("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:nn(5.1,2.6)+on(-10.2,6.8)+nn(5.1,2.6),height:12,width:10.2}}makeStartHat(){const t=this.constantProvider.START_HAT.height,e=on(25,-8.7)+en("c",[tn(29.7,-6.2),tn(57.2,-.5),tn(75,8.7)]),s=en("c",[tn(17.8,-9.2),tn(45.3,-14.9),tn(75,-8.7)])+sn(100.5,t+.5);return{path:t=>t?e:s}}},Ng=class extends sd{constructor(t,e){super(t,e),this.constants_=t,this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},Mg=class extends id{constructor(t,e){super(t,e),this.constants_=t,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Dg=class extends $d{constructor(t,e){super(t,e),this.renderer_=t}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_(),this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof fd||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(t,e){this.isInline&&t instanceof Nr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new Ng(this.constants_,t)),e.hasInlineInput=!0):t instanceof fd?(e.elements.push(new Mg(this.constants_,t)),e.hasStatement=!0):t instanceof Nr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new qu(this.constants_,t)),e.hasExternalInput=!0):(t instanceof Ed||t instanceof bd)&&(e.minHeight=Math.max(e.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),e.hasDummyInput=!0),this.isInline||null!==e.align||(e.align=t.align)}addElemSpacing_(){let t=!1;for(let e,s=0;e=this.rows[s];s++)e.hasExternalInput&&(t=!0);for(let s,i=0;s=this.rows[i];i++){var e=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new ed(this.constants_,this.getInRowSpacing_(null,e[0]))),e.length){for(let t=0;t>>/sprites.png);\n height: 16px;\n vertical-align: middle;\n visibility: hidden;\n width: 16px;\n}\n\n.blocklyTreeIconClosed {\n background-position: -32px -1px;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeIconClosed {\n background-position: 0 -1px;\n}\n\n.blocklyTreeSelected>.blocklyTreeIconClosed {\n background-position: -32px -17px;\n}\n\n.blocklyToolboxDiv[dir="RTL"] .blocklyTreeSelected>.blocklyTreeIconClosed {\n background-position: 0 -17px;\n}\n\n.blocklyTreeIconOpen {\n background-position: -16px -1px;\n}\n\n.blocklyTreeSelected>.blocklyTreeIconOpen {\n background-position: -16px -17px;\n}\n\n.blocklyTreeLabel {\n cursor: default;\n font: 16px sans-serif;\n padding: 0 3px;\n vertical-align: middle;\n}\n\n.blocklyToolboxDelete .blocklyTreeLabel {\n cursor: url("<<>>/handdelete.cur"), auto;\n}\n\n.blocklyTreeSelected .blocklyTreeLabel {\n color: #fff;\n}\n'),t(Pr.TOOLBOX_ITEM,Jg.registrationName,Jg);var qg=class extends jg{constructor(t,e){super(t,e),this.cssConfig_={container:"blocklyTreeSeparator"},this.htmlDiv_=null,Object.assign(this.cssConfig_,t.cssconfig||t.cssConfig)}init(){this.createDom_()}createDom_(){const t=document.createElement("div"),e=this.cssConfig_.container;return e&&ot(t,e),this.htmlDiv_=t}getDiv(){return this.htmlDiv_}dispose(){at(this.htmlDiv_)}};qg.registrationName="sep",tt('\n.blocklyTreeSeparator {\n border-bottom: solid #e5e5e5 1px;\n height: 0;\n margin: 5px 0;\n}\n\n.blocklyToolboxDiv[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'),t(Pr.TOOLBOX_ITEM,qg.registrationName,qg);var Zg=class extends Jg{constructor(t,e,s){super(t,e,s),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){const t=super.makeDefaultCssConfig_();return t.contents="blocklyToolboxContents",t}parseContents_(t){if("custom"in t)this.flyoutItems_=t.custom;else{const e=t.contents;if(e){this.flyoutItems_=[],t=!0;for(let s=0;s>>/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.blocklyToolboxDiv {\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.blocklyToolboxContents {\n display: flex;\n flex-wrap: wrap;\n flex-direction: column;\n}\n\n.blocklyToolboxContents:focus {\n outline: none;\n}\n'),t(Pr.TOOLBOX,Br,Qg);var t_=Nr.Align$$module$build$src$core$inputs$align.LEFT,e_=Nr.Align$$module$build$src$core$inputs$align.CENTRE,s_=Nr.Align$$module$build$src$core$inputs$align.RIGHT,i_=Pc.INPUT_VALUE,o_=Pc.OUTPUT_VALUE,n_=Pc.NEXT_STATEMENT,r_=Pc.PREVIOUS_STATEMENT,l_=Nr.inputTypes$$module$build$src$core$inputs$input_types.DUMMY,a_=xa.TOP,c_=xa.BOTTOM,h_=xa.LEFT,u_=xa.RIGHT;Vd.prototype.newBlock=function(t,e){return new Jd(this,t,e)},Yd.prototype.newBlock=function(t,e){return new op(this,t,e)},Yd.newTrashcan=function(t){return new ap(t)},_c.prototype.showContextMenu=function(t){if(!this.workspace.options.readOnly){var e=[];this.isDeletable()&&this.isMovable()&&(e.push(li(this)),e.push(ri(this))),Qs(t,e,this.RTL)}},yu.prototype.newWorkspaceSvg=function(t){return new Yd(t)},Nr.Names$$module$build$src$core$names.prototype.populateProcedures=function(t){t=(t=un(t))[0].concat(t[1]);for(let e=0;e{this.updateType_(t)})),this.appendValueInput("TEXT").appendField(t,"TYPE"),this.setOutput(!0,"String"),this.setTooltip((()=>"TEXT"===this.getFieldValue("TYPE")?e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER))}});var _=Object.assign({},g,{init:function(){this.mixin(T);var t=[[e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(e.Msg$$module$build$src$core$msg.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),(t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:t})).setValidator((t=>{this.updateType_(t)})),this.appendDummyInput().appendField(t,"TYPE").appendField(this.newQuote_(!0)).appendField(e.fromJson$$module$build$src$core$field_registry({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),this.setTooltip((()=>"TEXT"===this.getFieldValue("TYPE")?e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_TEXT:e.Msg$$module$build$src$core$msg.TEXT_PROMPT_TOOLTIP_NUMBER))}});d.text_prompt=_,d.text_count={init:function(){this.jsonInit({message0:e.Msg$$module$build$src$core$msg.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:e.Msg$$module$build$src$core$msg.TEXT_COUNT_TOOLTIP,helpUrl:e.Msg$$module$build$src$core$msg.TEXT_COUNT_HELPURL})}},d.text_replace={init:function(){this.jsonInit({message0:e.Msg$$module$build$src$core$msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:e.Msg$$module$build$src$core$msg.TEXT_REPLACE_TOOLTIP,helpUrl:e.Msg$$module$build$src$core$msg.TEXT_REPLACE_HELPURL})}},d.text_reverse={init:function(){this.jsonInit({message0:e.Msg$$module$build$src$core$msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:e.Msg$$module$build$src$core$msg.TEXT_REVERSE_TOOLTIP,helpUrl:e.Msg$$module$build$src$core$msg.TEXT_REVERSE_HELPURL})}};var T={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(t){for(let e,s=0;e=this.inputList[s];s++)for(let s,i=0;s=e.fieldRow[i];i++)if(t===s.name)return e.insertFieldAt(i,this.newQuote_(!0)),void e.insertFieldAt(i+2,this.newQuote_(!1));console.warn('field named "'+t+'" not found in '+this.toDevString())},newQuote_:function(t){return t=this.RTL?!t:t,e.fromJson$$module$build$src$core$field_registry({type:"field_image",src:t?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,width:this.QUOTE_IMAGE_WIDTH,height:this.QUOTE_IMAGE_HEIGHT,alt:t?"“":"”"})}},m={itemCount_:0,mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");return t.setAttribute("items",`${this.itemCount_}`),t},domToMutation:function(t){this.itemCount_=parseInt(t.getAttribute("items"),10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(t){this.itemCount_=t.itemCount,this.updateShape_()},decompose:function(t){const e=t.newBlock("text_create_join_container");e.initSvg();let s=e.getInput("STACK").connection;for(let e=0;ee.Msg$$module$build$src$core$msg.TEXT_INDEXOF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1")))})),e.register$$module$build$src$core$extensions("text_quotes",(function(){this.mixin(T),this.quoteField_("TEXT")})),e.registerMixin$$module$build$src$core$extensions("quote_image_mixin",T),e.registerMutator$$module$build$src$core$extensions("text_join_mutator",m,(function(){this.mixin(T),this.itemCount_=2,this.updateShape_(),this.setMutator(new e.MutatorIcon$$module$build$src$core$icons$mutator_icon(["text_create_join_item"],this))})),e.registerMutator$$module$build$src$core$extensions("text_charAt_mutator",E,(function(){this.getField("WHERE").setValidator((function(t){t="FROM_START"===t||"FROM_END"===t;const e=this.getSourceBlock();t!==e.isAt_&&e.updateAt_(t)})),this.updateAt_(!0),this.setTooltip((()=>{var t=this.getFieldValue("WHERE");let s=e.Msg$$module$build$src$core$msg.TEXT_CHARAT_TOOLTIP;return("FROM_START"===t||"FROM_END"===t)&&(t="FROM_START"===t?e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP)&&(s+=" "+t.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),s}))})),e.defineBlocks$$module$build$src$core$common(d);var b={blocks:d},f={},$={setStatements_:function(t){this.hasStatements_!==t&&(t?(this.appendStatementInput("STACK").appendField(e.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=t)},updateParams_:function(){let t="";this.arguments_.length&&(t=e.Msg$$module$build$src$core$msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),e.disable$$module$build$src$core$events$utils();try{this.setFieldValue(t,"PARAMS")}finally{e.enable$$module$build$src$core$events$utils()}},mutationToDom:function(t){const s=e.createElement$$module$build$src$core$utils$xml("mutation");t&&s.setAttribute("name",this.getFieldValue("NAME"));for(let i=0;i","GT"],["‏≥","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);e.register$$module$build$src$core$extensions("logic_op_tooltip",e.buildTooltipForDropdown$$module$build$src$core$extensions("OP",{EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"}));var B={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const t=e.createElement$$module$build$src$core$utils$xml("mutation");return this.elseifCount_&&t.setAttribute("elseif",String(this.elseifCount_)),this.elseCount_&&t.setAttribute("else","1"),t},domToMutation:function(t){this.elseifCount_=parseInt(t.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(t.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const t=Object.create(null);return this.elseifCount_&&(t.elseIfCount=this.elseifCount_),this.elseCount_&&(t.hasElse=!0),t},loadExtraState:function(t){this.elseifCount_=t.elseIfCount||0,this.elseCount_=t.hasElse?1:0,this.updateShape_()},decompose:function(t){const e=t.newBlock("controls_if_if");e.initSvg();let s=e.nextConnection;for(let e=1;e<=this.elseifCount_;e++){const e=t.newBlock("controls_if_elseif");e.initSvg(),s.connect(e.previousConnection),s=e.nextConnection}return this.elseCount_&&((t=t.newBlock("controls_if_else")).initSvg(),s.connect(t.previousConnection)),e},compose:function(t){t=t.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const e=[null],s=[null];let i=null;for(;t;){if(!t.isInsertionMarker())switch(t.type){case"controls_if_elseif":this.elseifCount_++,e.push(t.valueConnection_),s.push(t.statementConnection_);break;case"controls_if_else":this.elseCount_++,i=t.statementConnection_;break;default:throw TypeError("Unknown block type: "+t.type)}t=t.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(e,s,i)},saveConnections:function(t){t=t.nextConnection.targetBlock();let e=1;for(;t;){if(!t.isInsertionMarker())switch(t.type){case"controls_if_elseif":var s=this.getInput("IF"+e);const i=this.getInput("DO"+e);t.valueConnection_=s&&s.connection.targetConnection,t.statementConnection_=i&&i.connection.targetConnection,e++;break;case"controls_if_else":s=this.getInput("ELSE"),t.statementConnection_=s&&s.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+t.type)}t=t.getNextBlock()}},rebuildShape_:function(){const t=[null],e=[null];let s=null;this.getInput("ELSE")&&(s=this.getInput("ELSE").connection.targetConnection);for(let s=1;this.getInput("IF"+s);s++){const i=this.getInput("IF"+s),o=this.getInput("DO"+s);t.push(i.connection.targetConnection),e.push(o.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(t,e,s)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var t=1;this.getInput("IF"+t);t++)this.removeInput("IF"+t),this.removeInput("DO"+t);for(t=1;t<=this.elseifCount_;t++)this.appendValueInput("IF"+t).setCheck("Boolean").appendField(e.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+t).appendField(e.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(e.Msg$$module$build$src$core$msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(t,e,s){for(let s=1;s<=this.elseifCount_;s++){let i,o;null==(i=t[s])||i.reconnect(this,"IF"+s),null==(o=e[s])||o.reconnect(this,"DO"+s)}null==s||s.reconnect(this,"ELSE")}};e.registerMutator$$module$build$src$core$extensions("controls_if_mutator",B,null,["controls_if_elseif","controls_if_else"]);e.register$$module$build$src$core$extensions("controls_if_tooltip",(function(){this.setTooltip(function(){return this.elseifCount_||this.elseCount_?!this.elseifCount_&&this.elseCount_?e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_2:this.elseifCount_&&!this.elseCount_?e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_3:this.elseifCount_&&this.elseCount_?e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_4:"":e.Msg$$module$build$src$core$msg.CONTROLS_IF_TOOLTIP_1}.bind(this))}));var P={onchange:function(t){this.prevBlocks_||(this.prevBlocks_=[null,null]);var s=this.getInputTargetBlock("A");const i=this.getInputTargetBlock("B");s&&i&&!this.workspace.connectionChecker.doTypeChecks(s.outputConnection,i.outputConnection)&&(e.setGroup$$module$build$src$core$events$utils(t.group),(t=this.prevBlocks_[0])!==s&&(s.unplug(),!t||t.isDisposed()||t.isShadow()||this.getInput("A").connection.connect(t.outputConnection)),(s=this.prevBlocks_[1])!==i&&(i.unplug(),!s||s.isDisposed()||s.isShadow()||this.getInput("B").connection.connect(s.outputConnection)),this.bumpNeighbours(),e.setGroup$$module$build$src$core$events$utils(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}};e.register$$module$build$src$core$extensions("logic_compare",(function(){this.mixin(P)}));var F={prevParentConnection_:null,onchange:function(t){const s=this.getInputTargetBlock("THEN"),i=this.getInputTargetBlock("ELSE"),o=this.outputConnection.targetConnection;if((s||i)&&o)for(let n=0;2>n;n++){const r=1===n?s:i;r&&!r.workspace.connectionChecker.doTypeChecks(r.outputConnection,o)&&(e.setGroup$$module$build$src$core$events$utils(t.group),o===this.prevParentConnection_?(this.unplug(),o.getSourceBlock().bumpNeighbours()):(r.unplug(),r.bumpNeighbours()),e.setGroup$$module$build$src$core$events$utils(!1))}this.prevParentConnection_=o}};e.registerMixin$$module$build$src$core$extensions("logic_ternary",F),e.defineBlocks$$module$build$src$core$common(x);var U=e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]),H={init:function(){this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_HELPURL),this.setStyle("list_blocks"),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new e.MutatorIcon$$module$build$src$core$icons$mutator_icon(["lists_create_with_item"],this)),this.setTooltip(e.Msg$$module$build$src$core$msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");return t.setAttribute("items",String(this.itemCount_)),t},domToMutation:function(t){if(!(t=t.getAttribute("items")))throw new TypeError("element did not have items");this.itemCount_=parseInt(t,10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(t){this.itemCount_=t.itemCount,this.updateShape_()},decompose:function(t){const e=t.newBlock("lists_create_with_container");e.initSvg();let s=e.getInput("STACK").connection;for(let e=0;ee.Msg$$module$build$src$core$msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"0":"-1")))}};U.lists_indexOf=W;var X={init:function(){var t=[[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET,"GET"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_HELPURL),this.setStyle("list_blocks"),(t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:t})).setValidator((function(t){t="REMOVE"===t,this.getSourceBlock().updateStatement_(t)})),this.appendValueInput("VALUE").setCheck("Array").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(t,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0),this.setTooltip((()=>{const t=this.getFieldValue("MODE"),s=this.getFieldValue("WHERE");let i="";switch(t+" "+s){case"GET FROM_START":case"GET FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case"GET LAST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case"GET RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case"GET_REMOVE LAST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case"GET_REMOVE RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case"REMOVE FROM_START":case"REMOVE FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case"REMOVE FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case"REMOVE LAST":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case"REMOVE RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}return"FROM_START"!==s&&"FROM_END"!==s||(i+=" "+("FROM_START"===s?e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP:e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),i}))},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");t.setAttribute("statement",String(!this.outputConnection));const s=this.getInput("AT")instanceof e.ValueInput$$module$build$src$core$inputs$value_input;return t.setAttribute("at",String(s)),t},domToMutation:function(t){const e="true"===t.getAttribute("statement");this.updateStatement_(e),t="false"!==t.getAttribute("at"),this.updateAt_(t)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(t){t.isStatement?this.updateStatement_(!0):"string"==typeof t&&this.domToMutation(e.textToDom$$module$build$src$core$utils$xml(t))},updateStatement_:function(t){t!==!this.outputConnection&&(this.unplug(!0,!0),t?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(t){this.removeInput("AT"),this.removeInput("ORDINAL",!0),t?(this.appendValueInput("AT").setCheck("Number"),e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const s=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS});s.setValidator((function(e){const s="FROM_START"===e||"FROM_END"===e;if(s!==t){const t=this.getSourceBlock();return t.updateAt_(s),t.setFieldValue(e,"WHERE"),null}})),this.getInput("AT").appendField(s,"WHERE"),e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};U.lists_getIndex=X;var Y={init:function(){var t=[[e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_SET,"SET"],[e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_FIRST,"FIRST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_LAST,"LAST"],[e.Msg$$module$build$src$core$msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_IN_LIST),t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:t}),this.appendDummyInput().appendField(t,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0),this.setTooltip((()=>{const t=this.getFieldValue("MODE"),s=this.getFieldValue("WHERE");let i="";switch(t+" "+s){case"SET FROM_START":case"SET FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case"SET FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case"SET LAST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case"SET RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case"INSERT FROM_START":case"INSERT FROM_END":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case"INSERT FIRST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case"INSERT LAST":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case"INSERT RANDOM":i=e.Msg$$module$build$src$core$msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}return"FROM_START"!==s&&"FROM_END"!==s||(i+=" "+e.Msg$$module$build$src$core$msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",this.workspace.options.oneBasedIndex?"#1":"#0")),i}))},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation"),s=this.getInput("AT")instanceof e.ValueInput$$module$build$src$core$inputs$value_input;return t.setAttribute("at",String(s)),t},domToMutation:function(t){t="false"!==t.getAttribute("at"),this.updateAt_(t)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(t){this.removeInput("AT"),this.removeInput("ORDINAL",!0),t?(this.appendValueInput("AT").setCheck("Number"),e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const s=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this.WHERE_OPTIONS});s.setValidator((function(e){const s="FROM_START"===e||"FROM_END"===e;if(s!==t){const t=this.getSourceBlock();return t.updateAt_(s),t.setFieldValue(e,"WHERE"),null}})),this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO"),this.getInput("AT").appendField(s,"WHERE")}};U.lists_setIndex=Y;var K={init:function(){this.WHERE_OPTIONS_1=[[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_INPUT_IN_LIST),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");var s=this.getInput("AT1")instanceof e.ValueInput$$module$build$src$core$inputs$value_input;return t.setAttribute("at1",String(s)),s=this.getInput("AT2")instanceof e.ValueInput$$module$build$src$core$inputs$value_input,t.setAttribute("at2",String(s)),t},domToMutation:function(t){const e="true"===t.getAttribute("at1");t="true"===t.getAttribute("at2"),this.updateAt_(1,e),this.updateAt_(2,t)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(t,s){this.removeInput("AT"+t),this.removeInput("ORDINAL"+t,!0),s?(this.appendValueInput("AT"+t).setCheck("Number"),e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+t).appendField(e.Msg$$module$build$src$core$msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+t);const i=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:this["WHERE_OPTIONS_"+t]});i.setValidator((function(e){const i="FROM_START"===e||"FROM_END"===e;if(i!==s){const s=this.getSourceBlock();return s.updateAt_(t,i),s.setFieldValue(e,"WHERE"+t),null}})),this.getInput("AT"+t).appendField(i,"WHERE"+t),1===t&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2")),e.Msg$$module$build$src$core$msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};U.lists_getSublist=K,U.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}},U.lists_split={init:function(){const t=e.fromJson$$module$build$src$core$field_registry({type:"field_dropdown",options:[[e.Msg$$module$build$src$core$msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[e.Msg$$module$build$src$core$msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});if(!t)throw Error("field_dropdown not found");t.setValidator((t=>{this.updateType_(t)})),this.setHelpUrl(e.Msg$$module$build$src$core$msg.LISTS_SPLIT_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("INPUT").setCheck("String").appendField(t,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(e.Msg$$module$build$src$core$msg.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip((()=>{const t=this.getFieldValue("MODE");if("SPLIT"===t)return e.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"===t)return e.Msg$$module$build$src$core$msg.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+t)}))},updateType_:function(t){if(this.getFieldValue("MODE")!==t){const t=this.getInput("INPUT").connection;t.setShadowDom(null);const e=t.targetBlock();e&&(t.disconnect(),e.isShadow()?e.dispose(!1):this.bumpNeighbours())}"SPLIT"===t?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){const t=e.createElement$$module$build$src$core$utils$xml("mutation");return t.setAttribute("mode",this.getFieldValue("MODE")),t},domToMutation:function(t){this.updateType_(t.getAttribute("mode"))},saveExtraState:function(){return null},loadExtraState:function(){}},e.defineBlocks$$module$build$src$core$common(U);var z={blocks:U},j=e.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"colour_picker",message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",helpUrl:"%{BKY_COLOUR_PICKER_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_PICKER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"colour_random",message0:"%{BKY_COLOUR_RANDOM_TITLE}",output:"Colour",helpUrl:"%{BKY_COLOUR_RANDOM_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RANDOM_TOOLTIP}"},{type:"colour_rgb",message0:"%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",args0:[{type:"input_value",name:"RED",check:"Number",align:"RIGHT"},{type:"input_value",name:"GREEN",check:"Number",align:"RIGHT"},{type:"input_value",name:"BLUE",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_RGB_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RGB_TOOLTIP}"},{type:"colour_blend",message0:"%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",args0:[{type:"input_value",name:"COLOUR1",check:"Colour",align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"},{type:"input_value",name:"RATIO",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_BLEND_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_BLEND_TOOLTIP}"}]);e.defineBlocks$$module$build$src$core$common(j);var J={blocks:j},q={blocks:Object.assign({},j,U,x,L,O,f,l,s),colour:J,lists:z,loops:D,math:v,procedures:k,texts:b,variables:u,variablesDynamic:r};return q.__namespace__=e,q})?i.apply(e,o):i)||(t.exports=n)},225:function(t,e,s){var i,o,n;o=[s(983),s(808),s(499),s(986)],void 0===(n="function"==typeof(i=function(t,e,s,i){"use strict";return t.setLocale(e),t})?i.apply(e,o):i)||(t.exports=n)},983:function(t,e,s){var i,o,n;o=[s(239)],void 0===(n="function"==typeof(i=function(t){"use strict";return t})?i.apply(e,o):i)||(t.exports=n)},369:function(t,e,s){var i,o,n;o=[s(225)],void 0===(n="function"==typeof(i=function(t){return t})?i.apply(e,o):i)||(t.exports=n)},986:function(t,e,s){var i,o,n;o=[s(983),s(824)],void 0===(n="function"==typeof(i=function(t,e){return e})?i.apply(e,o):i)||(t.exports=n)},824:function(t,e,s){var i,o,n;o=[s(731)],void 0===(n="function"==typeof(i=function(t){var e,s,i=t.__namespace__,o=function(t,s){var i=0;let o="";s.STATEMENT_PREFIX&&(o+=s.injectId(s.STATEMENT_PREFIX,t));do{const n=s.valueToCode(t,"IF"+i,e.NONE)||"false";let r=s.statementToCode(t,"DO"+i);s.STATEMENT_SUFFIX&&(r=s.prefixLines(s.injectId(s.STATEMENT_SUFFIX,t),s.INDENT)+r),o+=(0o?a=e.SUBTRACTION:n&&(a=e.UNARY_NEGATION),t=this.valueToCode(t,s,a)||l,0!==o||n?i.isNumber$$module$build$src$core$utils$string(t)?(t=String(Number(t)+o),n&&(t=String(-Number(t))),t):(0o&&(t=`${t} - ${-o}`),n&&(t=o?`-(${t})`:`-${t}`),Math.floor(r)>=Math.floor(a)&&(t=`(${t})`),t):t}},d={};d.JavascriptGenerator=u,d.Order=e;var p={colour_blend:function(t,s){const i=s.valueToCode(t,"COLOUR1",e.NONE)||"'#000000'",o=s.valueToCode(t,"COLOUR2",e.NONE)||"'#000000'";return t=s.valueToCode(t,"RATIO",e.NONE)||.5,[s.provideFunction_("colourBlend",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {\n ratio = Math.max(Math.min(Number(ratio), 1), 0);\n var r1 = parseInt(c1.substring(1, 3), 16);\n var g1 = parseInt(c1.substring(3, 5), 16);\n var b1 = parseInt(c1.substring(5, 7), 16);\n var r2 = parseInt(c2.substring(1, 3), 16);\n var g2 = parseInt(c2.substring(3, 5), 16);\n var b2 = parseInt(c2.substring(5, 7), 16);\n var r = Math.round(r1 * (1 - ratio) + r2 * ratio);\n var g = Math.round(g1 * (1 - ratio) + g2 * ratio);\n var b = Math.round(b1 * (1 - ratio) + b2 * ratio);\n r = ('0' + (r || 0).toString(16)).slice(-2);\n g = ('0' + (g || 0).toString(16)).slice(-2);\n b = ('0' + (b || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n`)+"("+i+", "+o+", "+t+")",e.FUNCTION_CALL]},colour_picker:function(t,s){return[s.quote_(t.getFieldValue("COLOUR")),e.ATOMIC]},colour_random:function(t,s){return[s.provideFunction_("colourRandom",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}() {\n var num = Math.floor(Math.random() * Math.pow(2, 24));\n return '#' + ('00000' + num.toString(16)).substr(-6);\n}\n`)+"()",e.FUNCTION_CALL]},colour_rgb:function(t,s){const i=s.valueToCode(t,"RED",e.NONE)||0,o=s.valueToCode(t,"GREEN",e.NONE)||0;return t=s.valueToCode(t,"BLUE",e.NONE)||0,[s.provideFunction_("colourRgb",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {\n r = Math.max(Math.min(Number(r), 100), 0) * 2.55;\n g = Math.max(Math.min(Number(g), 100), 0) * 2.55;\n b = Math.max(Math.min(Number(b), 100), 0) * 2.55;\n r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);\n g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);\n b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);\n return '#' + r + g + b;\n}\n`)+"("+i+", "+o+", "+t+")",e.FUNCTION_CALL]}},g=function(t,e,s){return"FIRST"===e?"0":"FROM_END"===e?t+".length - 1 - "+s:"LAST"===e?t+".length - 1":s},_={lists_create_empty:function(t,s){return["[]",e.ATOMIC]},lists_create_with:function(t,s){const i=Array(t.itemCount_);for(let o=0;o String(b) ? 1 : -1; },\n 'IGNORE_CASE': function(a, b) {\n return String(a).toLowerCase() > String(b).toLowerCase() ? 1 : -1; },\n };\n var compare = compareFuncs[type];\n return function(a, b) { return compare(a, b) * direction; };\n}\n `))+'("'+t+'", '+o+"))",e.FUNCTION_CALL]},lists_split:function(t,s){let i=s.valueToCode(t,"INPUT",e.MEMBER);if(s=s.valueToCode(t,"DELIM",e.NONE)||"''","SPLIT"===(t=t.getFieldValue("MODE")))i||(i="''"),t="split";else{if("JOIN"!==t)throw Error("Unknown mode: "+t);i||(i="[]"),t="join"}return[i+"."+t+"("+s+")",e.FUNCTION_CALL]}},T={};T.controls_if=o,T.controls_ifelse=o,T.logic_boolean=function(t,s){return["TRUE"===t.getFieldValue("BOOL")?"true":"false",e.ATOMIC]},T.logic_compare=function(t,s){const i={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[t.getFieldValue("OP")],o="=="===i||"!="===i?e.EQUALITY:e.RELATIONAL;return[(s.valueToCode(t,"A",o)||"0")+" "+i+" "+(t=s.valueToCode(t,"B",o)||"0"),o]},T.logic_negate=function(t,s){const i=e.LOGICAL_NOT;return["!"+(s.valueToCode(t,"BOOL",i)||"true"),i]},T.logic_null=function(t,s){return["null",e.ATOMIC]},T.logic_operation=function(t,s){const i="AND"===t.getFieldValue("OP")?"&&":"||",o="&&"===i?e.LOGICAL_AND:e.LOGICAL_OR;let n=s.valueToCode(t,"A",o);return t=s.valueToCode(t,"B",o),n||t?(s="&&"===i?"true":"false",n||(n=s),t||(t=s)):t=n="false",[n+" "+i+" "+t,o]},T.logic_ternary=function(t,s){return[(s.valueToCode(t,"IF",e.CONDITIONAL)||"false")+" ? "+(s.valueToCode(t,"THEN",e.CONDITIONAL)||"null")+" : "+(t=s.valueToCode(t,"ELSE",e.CONDITIONAL)||"null"),e.CONDITIONAL]};var m={controls_flow_statements:function(t,e){let s="";if(e.STATEMENT_PREFIX&&(s+=e.injectId(e.STATEMENT_PREFIX,t)),e.STATEMENT_SUFFIX&&(s+=e.injectId(e.STATEMENT_SUFFIX,t)),e.STATEMENT_PREFIX){const i=t.getSurroundLoop();i&&!i.suppressPrefixSuffix&&(s+=e.injectId(e.STATEMENT_PREFIX,i))}switch(t.getFieldValue("FLOW")){case"BREAK":return s+"break;\n";case"CONTINUE":return s+"continue;\n"}throw Error("Unknown flow statement.")},controls_for:function(t,s){var o=s.getVariableName(t.getFieldValue("VAR")),n=s.valueToCode(t,"FROM",e.ASSIGNMENT)||"0",r=s.valueToCode(t,"TO",e.ASSIGNMENT)||"0";const l=s.valueToCode(t,"BY",e.ASSIGNMENT)||"1";let a=s.statementToCode(t,"DO");if(a=s.addLoopTrap(a,t),i.isNumber$$module$build$src$core$utils$string(n)&&i.isNumber$$module$build$src$core$utils$string(r)&&i.isNumber$$module$build$src$core$utils$string(l))t="for ("+o+" = "+n+"; "+o+((s=Number(n)<=Number(r))?" <= ":" >= ")+r+"; "+o,t=1===(o=Math.abs(Number(l)))?t+(s?"++":"--"):t+(s?" += ":" -= ")+o,t+=") {\n"+a+"}\n";else{t="";let e=n;n.match(/^\w+$/)||i.isNumber$$module$build$src$core$utils$string(n)||(e=s.nameDB_.getDistinctName(o+"_start",i.NameType$$module$build$src$core$names.VARIABLE),t+="var "+e+" = "+n+";\n"),n=r,r.match(/^\w+$/)||i.isNumber$$module$build$src$core$utils$string(r)||(t+="var "+(n=s.nameDB_.getDistinctName(o+"_end",i.NameType$$module$build$src$core$names.VARIABLE))+" = "+r+";\n"),t+="var "+(r=s.nameDB_.getDistinctName(o+"_inc",i.NameType$$module$build$src$core$names.VARIABLE))+" = ",t=i.isNumber$$module$build$src$core$utils$string(l)?t+(Math.abs(Number(l))+";\n"):t+"Math.abs("+l+");\n",t+="if ("+e+" > "+n+") {\n",t=(t+=s.INDENT+r+" = -"+r+";\n")+"}\nfor ("+o+" = "+e+"; "+r+" >= 0 ? "+o+" <= "+n+" : "+o+" >= "+n+"; "+o+" += "+r+") {\n"+a+"}\n"}return t},controls_forEach:function(t,s){const o=s.getVariableName(t.getFieldValue("VAR"));var n=s.valueToCode(t,"LIST",e.ASSIGNMENT)||"[]";let r=s.statementToCode(t,"DO");r=s.addLoopTrap(r,t),t="";let l=n;return n.match(/^\w+$/)||(l=s.nameDB_.getDistinctName(o+"_list",i.NameType$$module$build$src$core$names.VARIABLE),t+="var "+l+" = "+n+";\n"),n=s.nameDB_.getDistinctName(o+"_index",i.NameType$$module$build$src$core$names.VARIABLE),r=s.INDENT+o+" = "+l+"["+n+"];\n"+r,t+"for (var "+n+" in "+l+") {\n"+r+"}\n"}};m.controls_repeat=n,m.controls_repeat_ext=n,m.controls_whileUntil=function(t,s){const i="UNTIL"===t.getFieldValue("MODE");let o=s.valueToCode(t,"BOOL",i?e.LOGICAL_NOT:e.NONE)||"false",n=s.statementToCode(t,"DO");return n=s.addLoopTrap(n,t),i&&(o="!"+o),"while ("+o+") {\n"+n+"}\n"};var E={math_arithmetic:function(t,s){var i={ADD:[" + ",e.ADDITION],MINUS:[" - ",e.SUBTRACTION],MULTIPLY:[" * ",e.MULTIPLICATION],DIVIDE:[" / ",e.DIVISION],POWER:[null,e.NONE]}[t.getFieldValue("OP")];const o=i[0];i=i[1];const n=s.valueToCode(t,"A",i)||"0";return t=s.valueToCode(t,"B",i)||"0",o?[n+o+t,i]:["Math.pow("+n+", "+t+")",e.FUNCTION_CALL]},math_atan2:function(t,s){const i=s.valueToCode(t,"X",e.NONE)||"0";return["Math.atan2("+(s.valueToCode(t,"Y",e.NONE)||"0")+", "+i+") / Math.PI * 180",e.DIVISION]},math_change:function(t,s){const i=s.valueToCode(t,"DELTA",e.ADDITION)||"0";return(t=s.getVariableName(t.getFieldValue("VAR")))+" = (typeof "+t+" === 'number' ? "+t+" : 0) + "+i+";\n"},math_constant:function(t,s){return{PI:["Math.PI",e.MEMBER],E:["Math.E",e.MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",e.DIVISION],SQRT2:["Math.SQRT2",e.MEMBER],SQRT1_2:["Math.SQRT1_2",e.MEMBER],INFINITY:["Infinity",e.ATOMIC]}[t.getFieldValue("CONSTANT")]},math_constrain:function(t,s){return["Math.min(Math.max("+(s.valueToCode(t,"VALUE",e.NONE)||"0")+", "+(s.valueToCode(t,"LOW",e.NONE)||"0")+"), "+(t=s.valueToCode(t,"HIGH",e.NONE)||"Infinity")+")",e.FUNCTION_CALL]},math_modulo:function(t,s){return[(s.valueToCode(t,"DIVIDEND",e.MODULUS)||"0")+" % "+(t=s.valueToCode(t,"DIVISOR",e.MODULUS)||"0"),e.MODULUS]},math_number:function(t,s){return t=Number(t.getFieldValue("NUM")),[String(t),0<=t?e.ATOMIC:e.UNARY_NEGATION]},math_number_property:function(t,s){var i={EVEN:[" % 2 === 0",e.MODULUS,e.EQUALITY],ODD:[" % 2 === 1",e.MODULUS,e.EQUALITY],WHOLE:[" % 1 === 0",e.MODULUS,e.EQUALITY],POSITIVE:[" > 0",e.RELATIONAL,e.RELATIONAL],NEGATIVE:[" < 0",e.RELATIONAL,e.RELATIONAL],DIVISIBLE_BY:[null,e.MODULUS,e.EQUALITY],PRIME:[null,e.NONE,e.FUNCTION_CALL]};const o=t.getFieldValue("PROPERTY"),[n,r,l]=i[o];return i=s.valueToCode(t,"NUMBER_TO_CHECK",r)||"0",[t="PRIME"===o?s.provideFunction_("mathIsPrime",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(n) {\n // https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if (n == 2 || n == 3) {\n return true;\n }\n // False if n is NaN, negative, is 1, or not whole.\n // And false if n is divisible by 2 or 3.\n if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {\n return false;\n }\n // Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {\n if (n % (x - 1) === 0 || n % (x + 1) === 0) {\n return false;\n }\n }\n return true;\n}\n`)+"("+i+")":"DIVISIBLE_BY"===o?i+" % "+(t=s.valueToCode(t,"DIVISOR",e.MODULUS)||"0")+" === 0":i+n,l]},math_on_list:function(t,s){var i=t.getFieldValue("OP");switch(i){case"SUM":t=s.valueToCode(t,"LIST",e.MEMBER)||"[]",t+=".reduce(function(x, y) {return x + y;}, 0)";break;case"MIN":t="Math.min.apply(null, "+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"MAX":t="Math.max.apply(null, "+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"AVERAGE":t=(i=s.provideFunction_("mathMean",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(myList) {\n return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"MEDIAN":t=(i=s.provideFunction_("mathMedian",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(myList) {\n var localList = myList.filter(function (x) {return typeof x === 'number';});\n if (!localList.length) return null;\n localList.sort(function(a, b) {return b - a;});\n if (localList.length % 2 === 0) {\n return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;\n } else {\n return localList[(localList.length - 1) / 2];\n }\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"MODE":t=(i=s.provideFunction_("mathModes",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(values) {\n var modes = [];\n var counts = [];\n var maxCount = 0;\n for (var i = 0; i < values.length; i++) {\n var value = values[i];\n var found = false;\n var thisCount;\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][0] === value) {\n thisCount = ++counts[j][1];\n found = true;\n break;\n }\n }\n if (!found) {\n counts.push([value, 1]);\n thisCount = 1;\n }\n maxCount = Math.max(thisCount, maxCount);\n }\n for (var j = 0; j < counts.length; j++) {\n if (counts[j][1] === maxCount) {\n modes.push(counts[j][0]);\n }\n }\n return modes;\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"STD_DEV":t=(i=s.provideFunction_("mathStandardDeviation",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(numbers) {\n var n = numbers.length;\n if (!n) return null;\n var mean = numbers.reduce(function(x, y) {return x + y;}) / n;\n var variance = 0;\n for (var j = 0; j < n; j++) {\n variance += Math.pow(numbers[j] - mean, 2);\n }\n variance = variance / n;\n return Math.sqrt(variance);\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;case"RANDOM":t=(i=s.provideFunction_("mathRandomList",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(list) {\n var x = Math.floor(Math.random() * list.length);\n return list[x];\n}\n`))+"("+(t=s.valueToCode(t,"LIST",e.NONE)||"[]")+")";break;default:throw Error("Unknown operator: "+i)}return[t,e.FUNCTION_CALL]},math_random_float:function(t,s){return["Math.random()",e.FUNCTION_CALL]},math_random_int:function(t,s){const i=s.valueToCode(t,"FROM",e.NONE)||"0";return t=s.valueToCode(t,"TO",e.NONE)||"0",[s.provideFunction_("mathRandomInt",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(a, b) {\n if (a > b) {\n // Swap a and b to ensure a is smaller.\n var c = a;\n a = b;\n b = c;\n }\n return Math.floor(Math.random() * (b - a + 1) + a);\n}\n`)+"("+i+", "+t+")",e.FUNCTION_CALL]}};E.math_round=r,E.math_single=r,E.math_trig=r;var b={procedures_callnoreturn:function(t,e){return e.forBlock.procedures_callreturn(t,e)[0]+";\n"},procedures_callreturn:function(t,s){const i=s.getProcedureName(t.getFieldValue("NAME")),o=[],n=t.getVars();for(let i=0;i{"use strict";s.d(e,{A:()=>l});var i=s(601),o=s.n(i),n=s(314),r=s.n(n)()(o());r.push([t.id,"body {\n margin: 0;\n max-width: 100vw;\n}\n\npre, code {\n overflow: auto;\n}\n\n#pageContainer {\n display: flex;\n width: 100%;\n max-width: 100vw;\n height: 100vh;\n}\n\n.hidden {\n display: none;\n opacity: 0;\n}\n\n#blocklyDiv {\n flex-basis: 100%;\n height: 100%;\n min-width: 600px;\n}\n\n#outputPane {\n display: flex;\n flex-direction: column;\n width: 400px;\n flex: 0 0 400px;\n overflow: auto;\n margin: 1rem;\n}\n\n#generatedCode {\n height: 50%;\n background-color: rgb(247, 240, 228);\n}\n\n#output {\n height: 50%;\n}",""]);const l=r},314:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s="",i=void 0!==e[5];return e[4]&&(s+="@supports (".concat(e[4],") {")),e[2]&&(s+="@media ".concat(e[2]," {")),i&&(s+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),s+=t(e),i&&(s+="}"),e[2]&&(s+="}"),e[4]&&(s+="}"),s})).join("")},e.i=function(t,s,i,o,n){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var l=0;l0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=n),s&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=s):h[2]=s),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),e.push(h))}},e}},601:t=>{"use strict";t.exports=function(t){return t[1]}},72:t=>{"use strict";var e=[];function s(t){for(var s=-1,i=0;i{"use strict";var e={};t.exports=function(t,s){var i=function(t){if(void 0===e[t]){var s=document.querySelector(t);if(window.HTMLIFrameElement&&s instanceof window.HTMLIFrameElement)try{s=s.contentDocument.head}catch(t){s=null}e[t]=s}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(s)}},540:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},56:(t,e,s)=>{"use strict";t.exports=function(t){var e=s.nc;e&&t.setAttribute("nonce",e)}},825:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(s){!function(t,e,s){var i="";s.supports&&(i+="@supports (".concat(s.supports,") {")),s.media&&(i+="@media ".concat(s.media," {"));var o=void 0!==s.layer;o&&(i+="@layer".concat(s.layer.length>0?" ".concat(s.layer):""," {")),i+=s.css,o&&(i+="}"),s.media&&(i+="}"),s.supports&&(i+="}");var n=s.sourceMap;n&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(n))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,s)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},113:t=>{"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function s(i){var o=e[i];if(void 0!==o)return o.exports;var n=e[i]={id:i,exports:{}};return t[i].call(n.exports,n,n.exports,s),n.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.nc=void 0,(()=>{"use strict";var t=s(369);const e=JSON.parse('{"B":[{"type":"small_bitmap","message0":"Small Bitmap %1 %2","output":null,"args0":[{"type":"input_dummy"},{"type":"field_bitmap","name":"field","align":"CENTRE","width":8,"height":8}]},{"type":"large_bitmap","message0":"Large Bitmap %1 %2","output":null,"args0":[{"type":"input_dummy"},{"type":"field_bitmap","name":"field","align":"CENTRE","width":16,"height":16}]},{"type":"metadata","message0":"Project Metadata %1 Game Name %2 Author %3 Description %4","args0":[{"type":"input_dummy"},{"type":"input_value","name":"game name","check":"String"},{"type":"input_value","name":"author name","check":"String"},{"type":"input_value","name":"description","check":"String"}],"colour":230,"tooltip":"Project Metadata","helpUrl":""},{"type":"game_loop","message0":"Game Loop","message1":"DO %1 End of Game","args0":[],"args1":[{"type":"input_statement","name":"DO"}],"previousStatement":null,"nextStatement":null,"tooltip":"Your Game Loop!","helpUrl":"","style":"loop_blocks"}]}');var i=s(983),o=s.n(i);const n=15,r="#363d80",l="#fff",a={0:"#fff",1:"#363d80",2:"#0da73f"};class c extends o().Field{constructor(t=void 0,e=void 0,s=void 0){super(t,e,s),this.SERIALIZABLE=!0,this.CURSOR="default",this.initialValue_=null,null!==this.getValue()?(this.imgHeight_=this.getValue().length,this.imgWidth_=this.getValue()[0].length||0):(this.imgHeight_=s&&s.height||5,this.imgWidth_=s&&s.width||5),null===this.getValue()&&this.setValue(this.getEmptyArray_()),this.boundEvents_=[],this.editorPixels_=null,this.fieldGroup_=null,this.blockDisplayPixels_=null,this.mouseIsDown_=!1,this.valToPaintWith_=void 0}static fromJson(t){return new this(t&&t.value,void 0,t)}getImageWidth(){return this.imgWidth_}getImageHeight(){return this.imgHeight_}doClassValidation_(t=void 0){if(!t)return null;if(!Array.isArray(t))return null;if(0==t.length)return null;const e=t[0].length;for(const s of t){if(!Array.isArray(s))return null;if(s.length!==e)return null}for(const e of t)for(const t of e)if(0!==t&&1!==t&&2!==t)return null;return t}doValueUpdate_(t){if(super.doValueUpdate_(t),t){const e=t.length,s=t[0]?t[0].length:0;this.imgHeight_===e&&this.imgWidth_===s||(this.imgHeight_=e,this.imgWidth_=s),this.imgHeight_=t.length,this.imgWidth_=t[0]?t[0].length:0}}showEditor_(t=void 0,e=void 0){const s=this.dropdownCreate_();o().DropDownDiv.getContentDiv().appendChild(s),o().DropDownDiv.showPositionedByField(this,this.dropdownDispose_.bind(this))}render_(){super.render_(),this.getValue()&&this.blockDisplayPixels_&&this.forAllCells_(((t,e)=>{const s=this.getValue()[t][e],i=a[s];this.blockDisplayPixels_&&(this.blockDisplayPixels_[t][e].style.fill=i),this.editorPixels_&&(this.editorPixels_[t][e].style.background=i)}))}updateEditable(){const t=super.updateEditable();return o().utils.dom.removeClass(this.fieldGroup_,"blocklyNonEditableText"),o().utils.dom.removeClass(this.fieldGroup_,"blocklyEditableText"),t}getScaledBBox(){const t=this.fieldGroup_.getBoundingClientRect();return new(o().utils.Rect)(t.top,t.bottom,t.left,t.right)}dropdownCreate_(){const t=this.createElementWithClassname_("div","dropdownEditor"),e=this.createElementWithClassname_("div","pixelContainer");t.appendChild(e),this.bindEvent_(t,"mouseup",this.onMouseUp_),this.bindEvent_(t,"mouseleave",this.onMouseUp_),this.bindEvent_(t,"dragstart",(t=>{t.preventDefault()})),this.editorPixels_=[];for(let t=0;t(this.onMouseDownInPixel_(t,e),!0))),this.bindEvent_(i,"mouseenter",(()=>{this.onMouseEnterPixel_(t,e)}))}e.appendChild(s)}return this.addControlButton_(t,"Randomize",this.randomizePixels_),this.addControlButton_(t,"Clear",this.clearPixels_),this.blockDisplayPixels_&&this.forAllCells_(((t,e)=>{const s=this.getValue()[t][e];this.editorPixels_&&(this.editorPixels_[t][e].style.background=s?r:l)})),this.initialValue_=this.getValue(),t}initView(){this.blockDisplayPixels_=[];for(let t=0;t{t[e][s]=Math.floor(2*Math.random())})),this.getSourceBlock()&&o().Events.fire(new(o().Events.get(o().Events.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,this.getValue(),t)),this.setValue(t,!1)}clearPixels_(){const t=this.getEmptyArray_();this.forAllCells_(((e,s)=>{t[e][s]=0})),this.getSourceBlock()&&o().Events.fire(new(o().Events.get(o().Events.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,this.getValue(),t)),this.setValue(t,!1)}setPixel_(t,e,s){const i=JSON.parse(JSON.stringify(this.getValue()));i[t][e]=s,this.getSourceBlock()&&o().Events.fire(new(o().Events.get(o().Events.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,this.getValue(),i)),this.setValue(i,!1)}forAllCells_(t){for(let e=0;e{const s=t.serialization.workspaces.save(v);var i=await fetch("http://localhost:5000/save/game",{method:"POST",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});console.log(i)})),v.addChangeListener((t=>{t.isUiEvent||function(t){const e=i.serialization.workspaces.save(t);window.localStorage?.setItem("mainWorkspace",JSON.stringify(e))}(v)})),v.addChangeListener((e=>{!e.isUiEvent&&e.type!=t.Events.FINISHED_LOADING&&v.isDragging()}));const L=e=>{fetch(`http://localhost:5000/games/${e}`).then((function(t){return t.json()})).then((e=>{t.Events.disable(),t.serialization.workspaces.load(e,v,!1),t.Events.enable(),O.classList.add("hidden"),A.classList.remove("hidden")})).catch((e=>{console.log("No games found, loading empty workspace."),t.serialization.workspaces.load({},v,!1),O.classList.add("hidden"),A.classList.remove("hidden")}))};var w=new URLSearchParams(document.location.search).get("load");w&&L(w),O.classList.remove("hidden"),A.classList.add("hidden"),fetch("http://localhost:5000/games").then((function(t){return t.json()})).then((t=>{for(var e of(console.log(t),t.games)){var s=document.createElement("h2");s.innerHTML=e,s.setAttribute("gameName",e),s.addEventListener("click",(t=>{var e=t.target.getAttribute("gameName");L(e)})),y.appendChild(s)}})).catch((e=>{console.log(e),console.log("No games found, loading empty workspace."),t.serialization.workspaces.load({},v,!1),O.classList.add("hidden"),A.classList.remove("hidden")}))})()})(); \ No newline at end of file diff --git a/blockly/dist/bundle.js.LICENSE.txt b/blockly/dist/bundle.js.LICENSE.txt index e5e00bd5..6d9d39f6 100644 --- a/blockly/dist/bundle.js.LICENSE.txt +++ b/blockly/dist/bundle.js.LICENSE.txt @@ -9,3 +9,9 @@ * Copyright 2020 Google LLC * SPDX-License-Identifier: Apache-2.0 */ + +/** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ diff --git a/blockly/package-lock.json b/blockly/package-lock.json index 44968239..f867b2ac 100644 --- a/blockly/package-lock.json +++ b/blockly/package-lock.json @@ -10,7 +10,10 @@ "license": "Apache-2.0", "dependencies": { "blockly": "^10.0.0", - "jsonfile": "^6.1.0" + "jsonfile": "^6.1.0", + "ndarray": "^1.0.19", + "save-pixels": "^2.3.6", + "zeros": "^1.0.0" }, "devDependencies": { "css-loader": "^6.7.1", @@ -1065,6 +1068,38 @@ "node": ">= 0.6" } }, + "node_modules/contentstream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/contentstream/-/contentstream-1.0.0.tgz", + "integrity": "sha512-jqWbfFZFG9tZbdej7+TzXI4kanABh3BLtTWY6NxqTK5zo6iTIeo5aq4iRVfYsLQ0y8ccQqmJR/J4NeMmEdnR2w==", + "dependencies": { + "readable-stream": "~1.0.33-1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/contentstream/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" + }, + "node_modules/contentstream/node_modules/readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/contentstream/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" + }, "node_modules/cookie": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", @@ -1083,8 +1118,7 @@ "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "dev": true + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" }, "node_modules/cross-spawn": { "version": "7.0.3", @@ -1177,6 +1211,14 @@ "node": ">=14" } }, + "node_modules/cwise-compiler": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/cwise-compiler/-/cwise-compiler-1.1.3.tgz", + "integrity": "sha512-WXlK/m+Di8DMMcCjcWr4i+XzcQra9eCdXIJrgh4TUgh0pIS/yJduLxS9JgefsHJ/YVLdgPtXm9r62W92MvanEQ==", + "dependencies": { + "uniq": "^1.0.0" + } + }, "node_modules/data-urls": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-4.0.0.tgz", @@ -1833,6 +1875,38 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/gif-encoder": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/gif-encoder/-/gif-encoder-0.4.3.tgz", + "integrity": "sha512-HMfSa+EIng62NbDhM63QGYoc49/m8DcZ9hhBtw+CXX9mKboSpeFVxjZ2WEWaMFZ14MUjfACK7jsrxrJffIVrCg==", + "dependencies": { + "readable-stream": "~1.1.9" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/gif-encoder/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==" + }, + "node_modules/gif-encoder/node_modules/readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/gif-encoder/node_modules/string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==" + }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -2266,8 +2340,7 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/interpret": { "version": "2.2.0", @@ -2278,6 +2351,11 @@ "node": ">= 0.10" } }, + "node_modules/iota-array": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/iota-array/-/iota-array-1.0.0.tgz", + "integrity": "sha512-pZ2xT+LOHckCatGQ3DcG/a+QuEqvoxqkiL7tvE8nn3uuu+f6i1TtpB5/FtWFbxUuVr5PZCx8KskuGatbJDXOWA==" + }, "node_modules/ipaddr.js": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.1.0.tgz", @@ -2299,6 +2377,11 @@ "node": ">=8" } }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, "node_modules/is-core-module": { "version": "2.13.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", @@ -2444,6 +2527,11 @@ "node": ">= 10.13.0" } }, + "node_modules/jpeg-js": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.4.tgz", + "integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==" + }, "node_modules/jsdom": { "version": "22.1.0", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-22.1.0.tgz", @@ -2758,6 +2846,23 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/ndarray": { + "version": "1.0.19", + "resolved": "https://registry.npmjs.org/ndarray/-/ndarray-1.0.19.tgz", + "integrity": "sha512-B4JHA4vdyZU30ELBw3g7/p9bZupyew5a7tX1Y/gGeF2hafrPaQZhgrGQfsvgfYbgdFZjYwuEcnaobeM/WMW+HQ==", + "dependencies": { + "iota-array": "^1.0.0", + "is-buffer": "^1.0.2" + } + }, + "node_modules/ndarray-ops": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/ndarray-ops/-/ndarray-ops-1.2.2.tgz", + "integrity": "sha512-BppWAFRjMYF7N/r6Ie51q6D4fs0iiGmeXIACKY66fLpnwIui3Wc3CXiD/30mgLbDjPpSLrsqcp3Z62+IcHZsDw==", + "dependencies": { + "cwise-compiler": "^1.0.0" + } + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -3071,6 +3176,15 @@ "node": ">=8" } }, + "node_modules/pngjs-nozlib": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pngjs-nozlib/-/pngjs-nozlib-1.0.0.tgz", + "integrity": "sha512-N1PggqLp9xDqwAoKvGohmZ3m4/N9xpY0nDZivFqQLcpLHmliHnCp9BuNCsOeqHWMuEEgFjpEaq9dZq6RZyy0fA==", + "engines": { + "iojs": ">= 1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/postcss": { "version": "8.4.33", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", @@ -3468,6 +3582,20 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/save-pixels": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/save-pixels/-/save-pixels-2.3.6.tgz", + "integrity": "sha512-/ayfEWBxt0tFpf5lxSU1S0+/TBn7EiaTZD+6GL+mwizHm3BKCBysnzT6Js7BusDUVcNVLkeJJKLZcBgdpM2leQ==", + "dependencies": { + "contentstream": "^1.0.0", + "gif-encoder": "~0.4.1", + "jpeg-js": "^0.4.3", + "ndarray": "^1.0.18", + "ndarray-ops": "^1.2.2", + "pngjs-nozlib": "^1.0.0", + "through": "^2.3.4" + } + }, "node_modules/saxes": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", @@ -4005,6 +4133,11 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, "node_modules/thunky": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz", @@ -4082,6 +4215,11 @@ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, + "node_modules/uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha512-Gw+zz50YNKPDKXs+9d+aKAjVwpjNwqzvNpLigIruT4HA9lMZNdMqs9x07kKHB/L9WRzqp4+DlTU5s4wG2esdoA==" + }, "node_modules/universalify": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", @@ -4687,6 +4825,14 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true + }, + "node_modules/zeros": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/zeros/-/zeros-1.0.0.tgz", + "integrity": "sha512-lZ+3mqJ62wAi1NVoGB9f9iF6TvfI23YlnAwj4yUnzY8VhOrazhPKCMNrlwVf57Qz0kW9ybuXUVjYmyFrgk+r8g==", + "dependencies": { + "ndarray": "^1.0.16" + } } } } diff --git a/blockly/package.json b/blockly/package.json index 0ab24dbd..6caf2ae1 100644 --- a/blockly/package.json +++ b/blockly/package.json @@ -26,6 +26,9 @@ }, "dependencies": { "blockly": "^10.0.0", - "jsonfile": "^6.1.0" + "jsonfile": "^6.1.0", + "ndarray": "^1.0.19", + "save-pixels": "^2.3.6", + "zeros": "^1.0.0" } } diff --git a/blockly/src/blocks/game.json b/blockly/src/blocks/game.json index 581b2741..62e5eda8 100644 --- a/blockly/src/blocks/game.json +++ b/blockly/src/blocks/game.json @@ -1,5 +1,39 @@ { "blocks": [ +{ + "type": "small_bitmap", + "message0": "Small Bitmap %1 %2", + "output": null, + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_bitmap", + "name": "field", + "align": "CENTRE", + "width": 8, + "height": 8 + } + ] +}, +{ + "type": "large_bitmap", + "message0": "Large Bitmap %1 %2", + "output": null, + "args0": [ + { + "type": "input_dummy" + }, + { + "type": "field_bitmap", + "name": "field", + "align": "CENTRE", + "width": 16, + "height": 16 + } + ] +}, { "type": "metadata", "message0": "Project Metadata %1 Game Name %2 Author %3 Description %4", diff --git a/blockly/src/field-bitmap.js b/blockly/src/field-bitmap.js new file mode 100644 index 00000000..4f65c64b --- /dev/null +++ b/blockly/src/field-bitmap.js @@ -0,0 +1,608 @@ +/** + * @license + * Copyright 2021 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @fileoverview Bitmap input field. + * @author gregoryc@outlook.com (Greg Cannon) + */ + +import Blockly from 'blockly/core'; + +export const DEFAULT_HEIGHT = 5; +export const DEFAULT_WIDTH = 5; +const PIXEL_SIZE = 15; +const FILLED_PIXEL_COLOR = '#363d80'; +const EMPTY_PIXEL_COLOR = '#fff'; + +const PIXEL_COLORS = { + 0: "#fff", + 1: "#363d80", + 2: "#0da73f" +} + +/** + * Field for inputting a small bitmap image. + * Includes a grid of clickable pixels that's exported as a bitmap. + */ +export class FieldBitmap extends Blockly.Field { + /** + * Constructor for the bitmap field. + * @param {!Array>=} value 2D rectangular array of 1s and 0s. + * @param {Function=} validator A function that is called to validate. + * @param {!Object=} config Config A map of options used to + * configure the field. + */ + constructor(value = undefined, validator = undefined, config = undefined) { + super(value, validator, config); + + this.SERIALIZABLE = true; + this.CURSOR = 'default'; + this.initialValue_ = null; + + // Configure value, height, and width + if (this.getValue() !== null) { + this.imgHeight_ = this.getValue().length; + this.imgWidth_ = this.getValue()[0].length || 0; + } else { + this.imgHeight_ = (config && config['height']) || DEFAULT_HEIGHT; + this.imgWidth_ = (config && config['width']) || DEFAULT_WIDTH; + } + + // Set a default empty value + if (this.getValue() === null) { + this.setValue(this.getEmptyArray_()); + } + + /** + * Array holding info needed to unbind events. + * Used for disposing. + * @type {!Array} + * @private + */ + this.boundEvents_ = []; + + /** References to UI elements */ + this.editorPixels_ = null; + this.fieldGroup_ = null; + this.blockDisplayPixels_ = null; + + /** Stateful variables */ + this.mouseIsDown_ = false; + this.valToPaintWith_ = undefined; + } + + /** + * Constructs a FieldBitmap from a JSON arg object. + * @param {!Object} options A JSON object with options. + * @returns {!FieldBitmap} The new field instance. + * @package + * @nocollapse + */ + static fromJson(options) { + // `this` might be a subclass of FieldBitmap if that class doesn't override + // the static fromJson method. + return new this(options && options['value'], undefined, options); + } + + /** + * Returns the width of the image in pixels. + * @returns {number} The width in pixels. + */ + getImageWidth() { + return this.imgWidth_; + } + + /** + * Returns the height of the image in pixels. + * @returns {number} The height in pixels. + */ + getImageHeight() { + return this.imgHeight_; + } + + /** + * Validates that a new value meets the requirements for a valid bitmap array. + * @param {*} newValue The new value to be tested. + * @returns {Object} The new value if it's valid, or null. + */ + doClassValidation_(newValue = undefined) { + if (!newValue) { + return null; + } + // Check if the new value is an array + if (!Array.isArray(newValue)) { + return null; + } + const newHeight = newValue.length; + // The empty list is not an acceptable bitmap + if (newHeight == 0) { + return null; + } + + // Check that the width matches the existing width of the image if it + // already has a value + const newWidth = newValue[0].length; + for (const row of newValue) { + if (!Array.isArray(row)) { + return null; + } + if (row.length !== newWidth) { + return null; + } + } + + // Check if all contents of the arrays are either 0 or 1 + for (const row of newValue) { + for (const cell of row) { + if (cell !== 0 && cell !== 1 && cell !== 2) { + return null; + } + } + } + return newValue; + } + + /** + * Called when a new value has been validated and is about to be set. + * @param {*} newValue The value that's about to be set. + */ + doValueUpdate_(newValue) { + super.doValueUpdate_(newValue); + if (newValue) { + const newHeight = newValue.length; + const newWidth = newValue[0] ? newValue[0].length : 0; + if (this.imgHeight_ !== newHeight || this.imgWidth_ !== newWidth) { + this.imgHeight_ = newHeight; + this.imgWidth_ = newWidth; + } + + this.imgHeight_ = newValue.length; + this.imgWidth_ = newValue[0] ? newValue[0].length : 0; + } + } + + /** + * Show the bitmap editor dialog. + * @param {!Event=} e Optional mouse event that triggered the field to + * open, or undefined if triggered programmatically. + * @param {boolean=} _quietInput Quiet input. + * @protected + */ + showEditor_(e = undefined, _quietInput = undefined) { + const editor = this.dropdownCreate_(); + Blockly.DropDownDiv.getContentDiv().appendChild(editor); + Blockly.DropDownDiv.showPositionedByField( + this, + this.dropdownDispose_.bind(this), + ); + } + + /** + * Updates the block display and editor dropdown when the field re-renders. + * @protected + * @override + */ + render_() { + super.render_(); + + if (!this.getValue()) { + return; + } + + if (this.blockDisplayPixels_) { + this.forAllCells_((r, c) => { + const pixel = this.getValue()[r][c]; + const color = PIXEL_COLORS[pixel]; + + if (this.blockDisplayPixels_) { + this.blockDisplayPixels_[r][c].style.fill = color + } + if (this.editorPixels_) { + this.editorPixels_[r][c].style.background = color + } + }); + } + } + + /** + * Determines whether the field is editable. + * @returns {boolean} True since it is always editable. + */ + updateEditable() { + const editable = super.updateEditable(); + // Blockly.Field's implementation sets these classes as appropriate, but + // since this field has no text they just mess up the rendering of the + // grid lines. + Blockly.utils.dom.removeClass(this.fieldGroup_, 'blocklyNonEditableText'); + Blockly.utils.dom.removeClass(this.fieldGroup_, 'blocklyEditableText'); + return editable; + } + + /** + * Gets the rectangle built out of dimentions matching SVG's element. + * @returns {Blockly.utils.Rect} The newly created rectangle of same size + * as the SVG element. + */ + getScaledBBox() { + const boundingBox = this.fieldGroup_.getBoundingClientRect(); + return new Blockly.utils.Rect( + boundingBox.top, + boundingBox.bottom, + boundingBox.left, + boundingBox.right, + ); + } + + /** + * Creates the bitmap editor and add event listeners. + * @returns {!Element} The newly created dropdown menu. + * @private + */ + dropdownCreate_() { + const dropdownEditor = this.createElementWithClassname_( + 'div', + 'dropdownEditor', + ); + const pixelContainer = this.createElementWithClassname_( + 'div', + 'pixelContainer', + ); + dropdownEditor.appendChild(pixelContainer); + + this.bindEvent_(dropdownEditor, 'mouseup', this.onMouseUp_); + this.bindEvent_(dropdownEditor, 'mouseleave', this.onMouseUp_); + this.bindEvent_(dropdownEditor, 'dragstart', (e) => { + e.preventDefault(); + }); + + this.editorPixels_ = []; + for (let r = 0; r < this.imgHeight_; r++) { + this.editorPixels_.push([]); + const rowDiv = this.createElementWithClassname_('div', 'pixelRow'); + for (let c = 0; c < this.imgWidth_; c++) { + // Add the button to the UI and save a reference to it + const button = this.createElementWithClassname_('div', 'pixelButton'); + this.editorPixels_[r].push(button); + rowDiv.appendChild(button); + + // Load the current pixel color + const isOn = this.getValue()[r][c]; + console.log(isOn); + button.style.background = PIXEL_COLORS[isOn] + + // Handle clicking a pixel + this.bindEvent_(button, 'mousedown', () => { + this.onMouseDownInPixel_(r, c); + return true; + }); + + // Handle dragging into a pixel when mouse is down + this.bindEvent_(button, 'mouseenter', () => { + this.onMouseEnterPixel_(r, c); + }); + } + pixelContainer.appendChild(rowDiv); + } + + // Add control buttons below the pixel grid + this.addControlButton_(dropdownEditor, 'Randomize', this.randomizePixels_); + this.addControlButton_(dropdownEditor, 'Clear', this.clearPixels_); + + if (this.blockDisplayPixels_) { + this.forAllCells_((r, c) => { + const pixel = this.getValue()[r][c]; + + // if (this.blockDisplayPixels_) { + // this.blockDisplayPixels_[r][c].style.fill = + // pixel ? FILLED_PIXEL_COLOR : EMPTY_PIXEL_COLOR; + // } + + if (this.editorPixels_) { + this.editorPixels_[r][c].style.background = PIXEL_COLORS[pixel] + } + }); + } + + // Store the initial value at the start of the edit. + this.initialValue_ = this.getValue(); + + return dropdownEditor; + } + + /** + * Initializes the on-block display. + * @override + */ + initView() { + this.blockDisplayPixels_ = []; + for (let r = 0; r < this.imgHeight_; r++) { + const row = []; + for (let c = 0; c < this.imgWidth_; c++) { + const square = Blockly.utils.dom.createSvgElement( + 'rect', + { + x: c * PIXEL_SIZE, + y: r * PIXEL_SIZE, + width: PIXEL_SIZE, + height: PIXEL_SIZE, + fill: EMPTY_PIXEL_COLOR, + fill_opacity: 1, + }, + this.fieldGroup_, + ); + row.push(square); + } + this.blockDisplayPixels_.push(row); + } + } + + /** + * Updates the size of the block based on the size of the underlying image. + * @override + * @protected + */ + updateSize_() { + { + const newWidth = PIXEL_SIZE * this.imgWidth_; + const newHeight = PIXEL_SIZE * this.imgHeight_; + if (this.borderRect_) { + this.borderRect_.setAttribute('width', String(newWidth)); + this.borderRect_.setAttribute('height', String(newHeight)); + } + + this.size_.width = newWidth; + this.size_.height = newHeight; + } + } + + /** + *Create control button. + * @param {!HTMLElement} parent Parent HTML element to which + * control button will be added. + * @param {string} buttonText Text of the control button. + * @param {Function} onClick Callback that will be + * attached to the control button. + */ + addControlButton_(parent, buttonText, onClick) { + const button = this.createElementWithClassname_('button', 'controlButton'); + button.innerHTML = buttonText; + parent.appendChild(button); + this.bindEvent_(button, 'click', onClick); + } + + /** + * Disposes of events belonging to the bitmap editor. + * @private + */ + dropdownDispose_() { + if ( + this.getSourceBlock() && + this.initialValue_ !== null && + this.initialValue_ !== this.getValue() + ) { + Blockly.Events.fire( + new (Blockly.Events.get(Blockly.Events.BLOCK_CHANGE))( + this.sourceBlock_, + 'field', + this.name || null, + this.initialValue_, + this.getValue(), + ), + ); + } + + for (const event of this.boundEvents_) { + Blockly.browserEvents.unbind(event); + } + this.boundEvents_.length = 0; + this.editorPixels_ = null; + // Set this.initialValue_ back to null. + this.initialValue_ = null; + } + + /** + * Constructs an array of zeros with the specified width and height. + * @returns {!Array>}The new value. + */ + getEmptyArray_() { + const newVal = []; + for (let r = 0; r < this.imgHeight_; r++) { + newVal.push([]); + for (let c = 0; c < this.imgWidth_; c++) { + newVal[r].push(0); + } + } + return newVal; + } + + /** + * Called when a mousedown event occurs within the bounds of a pixel. + * @private + * @param {number} r Row number of grid. + * @param {number} c Column number of grid. + */ + onMouseDownInPixel_(r, c) { + // Toggle that pixel to the opposite of its value + + var value = this.getValue()[r][c]; + var newValue = 0; + + if(value == 0) { + newValue = 1; + } else if(value == 1) { + newValue = 2 + } + + const newPixelValue = 1 - this.getValue()[r][c]; + + this.setPixel_(r, c, newValue); + this.mouseIsDown_ = true; + this.valToPaintWith_ = newValue; + } + + /** + * Called when the mouse drags over a pixel in the editor. + * @private + * @param {number} r Row number of grid. + * @param {number} c Column number of grid. + */ + onMouseEnterPixel_(r, c) { + if (!this.mouseIsDown_) { + return; + } + if (this.getValue()[r][c] !== this.valToPaintWith_) { + this.setPixel_(r, c, this.valToPaintWith_); + } + } + + /** + * Resets mouse state (e.g. After either a mouseup event or if the mouse + * leaves the editor area). + * @private + */ + onMouseUp_() { + this.mouseIsDown_ = false; + this.valToPaintWith_ = undefined; + } + + /** + * Sets all the pixels in the image to a random value. + * @private + */ + randomizePixels_() { + const getRandBinary = () => Math.floor(Math.random() * 2); + const newVal = this.getEmptyArray_(); + this.forAllCells_((r, c) => { + newVal[r][c] = getRandBinary(); + }); + + if (this.getSourceBlock()) { + Blockly.Events.fire( + new (Blockly.Events.get( + Blockly.Events.BLOCK_FIELD_INTERMEDIATE_CHANGE, + ))(this.sourceBlock_, this.name || null, this.getValue(), newVal), + ); + } + + this.setValue(newVal, false); + } + + /** + * Sets all the pixels to 0. + * @private + */ + clearPixels_() { + const newVal = this.getEmptyArray_(); + this.forAllCells_((r, c) => { + newVal[r][c] = 0; + }); + + if (this.getSourceBlock()) { + Blockly.Events.fire( + new (Blockly.Events.get( + Blockly.Events.BLOCK_FIELD_INTERMEDIATE_CHANGE, + ))(this.sourceBlock_, this.name || null, this.getValue(), newVal), + ); + } + + this.setValue(newVal, false); + } + + /** + * Sets the value of a particular pixel. + * @param {number} r Row number of grid. + * @param {number} c Column number of grid. + * @param {number} newValue Value of the pixel. + * @private + */ + setPixel_(r, c, newValue) { + const newGrid = JSON.parse(JSON.stringify(this.getValue())); + newGrid[r][c] = newValue; + + if (this.getSourceBlock()) { + Blockly.Events.fire( + new (Blockly.Events.get( + Blockly.Events.BLOCK_FIELD_INTERMEDIATE_CHANGE, + ))(this.sourceBlock_, this.name || null, this.getValue(), newGrid), + ); + } + + this.setValue(newGrid, false); + } + + /** + * Calls a given function for all cells in the image, with the cell + * coordinates as the arguments. + * @param {*} func A function to be applied. + */ + forAllCells_(func) { + for (let r = 0; r < this.imgHeight_; r++) { + for (let c = 0; c < this.imgWidth_; c++) { + func(r, c); + } + } + } + + /** + * Creates a new element with the specified type and class. + * @param {string} elementType Type of html element. + * @param {string} className ClassName of html element. + * @returns {!HTMLElement} The created element. + */ + createElementWithClassname_(elementType, className) { + const newElt = document.createElement(elementType); + newElt.className = className; + return newElt; + } + + /** + * Binds an event listener to the specified element. + * @param {!HTMLElement} element Specified element. + * @param {string} eventName Name of the event to bind. + * @param {Function} callback Function to be called on specified event. + */ + bindEvent_(element, eventName, callback) { + this.boundEvents_.push( + Blockly.browserEvents.conditionalBind(element, eventName, this, callback), + ); + } +} + +Blockly.fieldRegistry.register('field_bitmap', FieldBitmap); + +/** + * CSS for bitmap field. + */ +Blockly.Css.register(` +.dropdownEditor { + align-items: center; + flex-direction: column; + display: flex; + justify-content: center; + margin-bottom: 20px; +} +.pixelContainer { + margin: 20px; +} +.pixelRow { + display: flex; + flex-direction: row; + padding: 0; + margin: 0; + height: ${PIXEL_SIZE} +} +.pixelButton { + width: ${PIXEL_SIZE}px; + height: ${PIXEL_SIZE}px; + border: 1px solid #000; +} +.pixelDisplay { + white-space:pre-wrap; +} +.controlButton { + margin: 5px 0; +} +`); diff --git a/blockly/src/index.js b/blockly/src/index.js index 9b57e461..ba17b9ef 100644 --- a/blockly/src/index.js +++ b/blockly/src/index.js @@ -11,15 +11,19 @@ import * as Blockly from 'blockly'; import data from './blocks/game.json'; const blocks = Blockly.common.createBlockDefinitionsFromJsonArray(data.blocks); - // import {forBlock} from './generators/python'; // import {pythonGenerator} from 'blockly/python'; +// import {FieldBitmap} from '@blockly/blockly-field-bitmap'; +// import '@blockly/field-bitmap'; + +import './field-bitmap.js' import {save, load} from './serialization'; import {toolbox} from './toolbox'; import './index.css'; // Register the blocks and generator with Blockly Blockly.common.defineBlocks(blocks); + // Object.assign(pythonGenerator.forBlock, forBlock); // Set up UI elements and inject Blockly diff --git a/blockly/src/toolbox.js b/blockly/src/toolbox.js index 0dc5aa05..160ad1ee 100644 --- a/blockly/src/toolbox.js +++ b/blockly/src/toolbox.js @@ -34,6 +34,21 @@ listed here. export const toolbox = { 'kind': 'categoryToolbox', 'contents': [ + { + 'kind': 'category', + 'name': 'Custom', + 'categorystyle': 'logic_category', + 'contents': [ + { + 'kind': 'block', + 'type': 'small_bitmap', + }, + { + 'kind': 'block', + 'type': 'large_bitmap', + } + ], + }, { 'kind': 'category', 'name': 'Logic', diff --git a/blockly/umbrella.png b/blockly/umbrella.png new file mode 100644 index 00000000..9f3c6334 Binary files /dev/null and b/blockly/umbrella.png differ diff --git a/flask/saved/Multiplayer Tetris.json b/flask/saved/Multiplayer Tetris.json index 1fb99dc8..92f8a316 100644 --- a/flask/saved/Multiplayer Tetris.json +++ b/flask/saved/Multiplayer Tetris.json @@ -36,7 +36,628 @@ } } } + }, + { + "type": "large_bitmap", + "id": "W|cCx6fW@.X6f#H;m4@j", + "x": 449, + "y": 621, + "fields": { + "field": [ + [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 1, + 1, + 0 + ], + [ + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 0 + ], + [ + 1, + 1, + 0, + 1, + 1, + 0, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 0, + 0 + ], + [ + 1, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1 + ], + [ + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 0 + ], + [ + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 0 + ], + [ + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0 + ], + [ + 0, + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 1 + ], + [ + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1 + ], + [ + 0, + 1, + 1, + 1, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 1, + 0 + ], + [ + 1, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 0, + 1 + ], + [ + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 0, + 0 + ], + [ + 1, + 0, + 1, + 1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0 + ], + [ + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 0, + 0, + 0, + 1, + 1, + 0 + ], + [ + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1 + ], + [ + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1 + ] + ] + } + }, + { + "type": "variables_set", + "id": "X*-Uhp5fbTS4%;s?s/Vz", + "x": 121, + "y": 257, + "fields": { + "VAR": { + "id": "Ox7`zD)!i*0*b.gG3cCO" + } + }, + "inputs": { + "VALUE": { + "block": { + "type": "small_bitmap", + "id": "ju_2i#34!MueMq}0Y@zv", + "fields": { + "field": [ + [ + 0, + 0, + 1, + 2, + 1, + 1, + 0, + 0 + ], + [ + 0, + 1, + 2, + 2, + 2, + 1, + 1, + 0 + ], + [ + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1 + ], + [ + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1 + ], + [ + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0 + ], + [ + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0 + ], + [ + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0 + ] + ] + } + } + } + }, + "next": { + "block": { + "type": "variables_set", + "id": "pWd*f(GXN}Pv:(KPN=3r", + "fields": { + "VAR": { + "id": "a6oZI3!6oEDPG^~u`I3D" + } + }, + "inputs": { + "VALUE": { + "block": { + "type": "small_bitmap", + "id": "b8lFpJ=!X$WwbxrIaFPB", + "fields": { + "field": [ + [ + 0, + 2, + 0, + 0, + 0, + 0, + 2, + 0 + ], + [ + 0, + 0, + 2, + 0, + 0, + 2, + 0, + 0 + ], + [ + 1, + 0, + 0, + 1, + 1, + 0, + 0, + 1 + ], + [ + 1, + 0, + 1, + 1, + 1, + 1, + 0, + 1 + ], + [ + 1, + 1, + 2, + 1, + 1, + 2, + 1, + 1 + ], + [ + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 0 + ], + [ + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0 + ], + [ + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 1 + ] + ] + } + } + } + }, + "next": { + "block": { + "type": "variables_set", + "id": "@FA`^R:a80Rjx3oT^y*s", + "fields": { + "VAR": { + "id": "?dpW0=QcyAQ#88z+kf*A" + } + }, + "inputs": { + "VALUE": { + "block": { + "type": "small_bitmap", + "id": "^H;TPh3T2?3L7Zm~(6i.", + "fields": { + "field": [ + [ + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0 + ], + [ + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0 + ], + [ + 1, + 0, + 2, + 2, + 0, + 0, + 0, + 1 + ], + [ + 1, + 0, + 2, + 0, + 0, + 0, + 0, + 1 + ], + [ + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 1 + ], + [ + 1, + 0, + 0, + 0, + 0, + 2, + 0, + 1 + ], + [ + 0, + 1, + 0, + 0, + 0, + 0, + 1, + 0 + ], + [ + 0, + 0, + 1, + 1, + 1, + 1, + 0, + 0 + ] + ] + } + } + } + } + } + } + } + } } ] - } + }, + "variables": [ + { + "name": "bubble", + "id": "?dpW0=QcyAQ#88z+kf*A" + }, + { + "name": "alien", + "id": "a6oZI3!6oEDPG^~u`I3D" + }, + { + "name": "umbrella", + "id": "Ox7`zD)!i*0*b.gG3cCO" + } + ] } \ No newline at end of file