From 04db714c0dd6f3c23b986f4350f24690de264900 Mon Sep 17 00:00:00 2001 From: Sarxzer Date: Wed, 13 Mar 2024 18:44:19 +0100 Subject: [PATCH] v1.1.0 --- bundle.js | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundle.js b/bundle.js index 7c726aa..8c08ede 100644 --- a/bundle.js +++ b/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,f,b,$,I,O,S,C,R,k,y,N,v,A,L,w,M,D,x,P,B,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,ft,bt,$t,It,Ot,St,Ct,Rt,kt,yt,Nt,vt,At,Lt,wt,Mt,Dt,xt,Pt,Bt,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,fe,be,$e,Ie,Oe,Se,Ce,Re,ke,ye,Ne,ve,Ae,Le,we,Me,De,xe,Pe,Be,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,fs,bs,$s,Is,Os,Ss,Cs,Rs,ks,ys,Ns,vs,As,Ls,ws,Ms,Ds,xs,Ps,Bs,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,fi,bi,$i,Ii,Oi,Si,Ci,Ri,ki,yi,Ni,vi,Ai,Li,wi,Mi,Di,xi,Pi,Bi,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,fo,bo,$o,Io,Oo,So,Co,Ro,ko,yo,No,vo,Ao,Lo,wo,Mo,Do,xo,Po,Bo,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,fn,bn,$n,In,On,Sn,Cn,Rn,kn,yn,Nn,vn,An,Ln,wn,Mn,Dn,xn,Pn,Bn,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,fr,br,$r,Ir,Or,Sr,Cr,Rr,kr,yr,Nr,vr,Ar,Lr,wr,Mr,Dr={};t=function(t,s,i,o){if(!(t instanceof Ur)&&"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=xr[t],l=Br[t];if(r||(r=xr[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(Ur.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=xr[t];s&&s[e]?(delete xr[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=xr[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=xr[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=xr[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)]||Fr)?e:r(t,e,s)},h=function(t){return Xr[t]||null},u=function(){const t=[];for(const e in Xr)t.push(Xr[e]);return t},d=function(t){Xr[t.id]=t},p=function(t){delete Xr[t.id]},g=function(){return Gr},_=function(t){Gr=t},T=function(){return Yr},m=function(t){Yr=t},E=function(){return Vr},f=function(t){Vr=t},b=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)}},O=function(t){zr.defineBlocksWithJsonArrayInternal(t)},S=function(t){Dr.defineBlocks$$module$build$src$core$common(Dr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(t))},Dr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(t){const e={};for(let s=0;s{setTimeout(A,0)}))}catch(t){setTimeout(A,0)}fl.push(t)}},A=function(){var t=L(fl,!0);fl.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),ca="",(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."),da.has(t)||(da.add(t),console.warn(t))},it=function(t,e,s){t=document.createElementNS(_a,`${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(){fa++,Ea||(Ea=Object.create(null))},pt=function(){--fa||(Ea=null)},gt=function(t){const e=t.textContent+"\n"+t.className.baseVal;let s;if(Ea&&(s=Ea[e]))return s;try{s=t.getComputedTextLength()}catch(e){return 8*t.textContent.length}return Ea&&(Ea[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,Ea&&(n=Ea[t])||(ba||((n=document.createElement("canvas")).className="blocklyComputeCanvas",document.body.appendChild(n),ba=n.getContext("2d")),ba.font=s+" "+e+" "+i,n=o?ba.measureText(o).width:0,Ea&&(Ea[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 Ca.getSizeInternal(t)},ft=function(t){if("none"!==$t(t,"display"))return bt(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 Sa(n,t)},bt=function(t){return new Sa(t.offsetWidth,t.offsetHeight)},$t=function(t,e){return(t=window.getComputedStyle(t))[e]||t.getPropertyValue(e)},It=function(t){const e=new ua(0,0);t=t.getBoundingClientRect();var s=document.documentElement;return s=new ua(window.pageXOffset||s.scrollLeft,window.pageYOffset||s.scrollTop),e.x=t.left+s.x,e.y=t.top+s.y,e},Ot=function(){const t=document.body,e=document.documentElement;return new ua(t.scrollLeft||e.scrollLeft,t.scrollTop||e.scrollTop)},St=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 Oa(i,t,e,s)},Ct=function(t,e,s){t=Rt(t,e,s),e.scrollLeft=t.x,e.scrollTop=t.y},Rt=function(t,e,s){var i=It(t),o=It(e),n=St(e);const r=i.x-o.x-n.left;return i=i.y-o.y-n.top,o=bt(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 ua(n,e)},kt=function(t){const e=new ua(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(ka))&&(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)),Pt(t),t):null},Pt=function(t){const e=t.kind;if(t=t.contents,e&&e!==Ha&&e!==Ua)throw Error("Invalid toolbox kind "+e+". Please supply either "+Ha+" or "+Ua);if(!t)throw Error("Toolbox must have a contents attribute.")},Bt=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===Va.LEFT?(s=o.absoluteMetrics.left+s,r&&n.RTL&&(s+=va.scrollbarThickness)):(s=o.absoluteMetrics.left+o.viewMetrics.width-e.width-s,r&&!n.RTL&&(s-=va.scrollbarThickness)),t.vertical===Ga.TOP?t=o.absoluteMetrics.top+i:(t=o.absoluteMetrics.top+o.viewMetrics.height-e.height-i,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(t-=va.scrollbarThickness)),new Oa(t,t+e.height,s,s+e.width)},Kt=function(t,e){return{horizontal:e.toolboxMetrics.position===Fa.LEFT||t.horizontalLayout&&!t.RTL?Va.RIGHT:Va.LEFT,vertical:e.toolboxMetrics.position===Fa.BOTTOM?Ga.TOP:Ga.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)),Wr.variables_get){t.sort(cc.compareByName);for(let i,o=0;i=t[o];o++)(s=Dr.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 dc.generateUniqueNameInternal(t)},ae=function(t){return ce(uc.charAt(0),t.getAllVariableNames())},ce=function(t,e){if(!e.length)return t;const s=uc;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=Dr.createElement$$module$build$src$core$utils$xml("field");return e.setAttribute("name","VAR"),e.setAttribute("id",t.getId()),e.setAttribute("variabletype",t.type),t=Dr.createTextNode$$module$build$src$core$utils$xml(t.name),e.appendChild(t),e},Dr.getOrCreateVariablePackage$$module$build$src$core$variables=function(t,e,s,i){let o=Dr.getVariable$$module$build$src$core$variables(t,e,s,i);return o||(o=Ee(t,e,s,i)),o},Dr.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)},fe=function(t,e){t=t.getAllVariables();const s=[];if(e.length!==t.length)for(let i=0;i{Ic=t,Oc=window.requestAnimationFrame((()=>{ke(),t()}))}))),$c)},Oe=function(){return $c||Promise.resolve()},Se=function(t){t||window.cancelAnimationFrame(Oc),ke(t),!t&&Ic&&Ic()},Ce=function(){return zl},Re=function(t){bc.add(t);const e=t.getParent();e?Re(e):fc.add(t)},ke=function(t){const e=t?new Set([t]):new Set([...fc].map((t=>t.workspace))),s=[...fc].filter(Ne).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||($c=null)},ye=function(t){fc.delete(t),bc.delete(t);for(const e of t.getChildren(!1))ye(e)},Ne=function(t){return!t.isDisposed()&&!t.getParent()},ve=function(t){if(bc.has(t)){for(const e of t.getChildren(!1))ve(e);t.renderEfficiently()}},Ae=function(t,e){const s=Dr.createElement$$module$build$src$core$utils$xml("xml");var i=Le(Dr.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=Be(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=Dr.domToWorkspace$$module$build$src$core$xml(t,e),e.setResizesEnabled(!0),t},Dr.domToWorkspace$$module$build$src$core$xml=function(t,e){let s=0;e.RTL&&(s=e.getWidth());const i=[];dt();const o=Dr.getGroup$$module$build$src$core$events$utils();o||Dr.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?Ec.fromXmlRendered(r,e,s):gc.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{Dr.setGroup$$module$build$src$core$events$utils(o),e.setResizesEnabled&&e.setResizesEnabled(!0),e.rendered&&Se(),pt()}return N(new(B(ml))(e)),i},He=function(t,e){if(!e.getBlocksBoundingBox)return Dr.domToWorkspace$$module$build$src$core$xml(t,e);var s=e.getBlocksBoundingBox();if(t=Dr.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 kc(t);const o=e.newBlock(t.type,t.id);return o.setShadow(i),ms(o,t),Es(o,t),fs(o,t),bs(s,o,t),$s(o,t),Is(o,t),Os(o,t),Ss(o,t),Rs(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)},fs=function(t,e){e.extraState&&(t.loadExtraState?t.loadExtraState(e.extraState):t.domToMutation&&t.domToMutation(Dr.textToDom$$module$build$src$core$utils$xml(e.extraState)))},bs=function(t,e,s){if(t){if(t.getSourceBlock().isShadow()&&!e.isShadow())throw new vc(s);if(t.type===Dr.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var i=e.outputConnection;if(!i)throw new yc("output",e,s)}else if(!(i=e.previousConnection))throw new yc("previous",e,s);if(!t.connect(i)){const o=e.workspace.connectionChecker;throw new Nc(o.getErrorMessage(o.canConnectWithReason(i,t,!1),i,t),t.type===Dr.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(Ur.ICON,o,!1)))throw new Ac(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(ua.sum(i,o),n)||Ns(t,o,s);)e.RTL?o.translate(-s,2*s):o.translate(s,2*s);t.moveTo(ua.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)))},Ns=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()"),zc.copyInternal(t)},As=function(t){const e=t.toCopyData();let s;return Yc=e,Kc=null!=(s=t.workspace)?s:null,e},Ls=function(t,e,s){return t&&e?ws(t,e,s):Yc&&Kc?ws(Yc,Kc):null},ws=function(t,e,s){let i,o,n;return e=null!=(i=e.getRootWorkspace())?i:e,null!=(n=null==(o=l(Ur.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)"),zc.duplicateInternal(t)},Ds=function(t){const e=t.toCopyData();return e?Ls(e,t.workspace):null},xs=function(t,e){t.setAttribute(Qc,e)},Ps=function(t,e,s){Array.isArray(s)&&(s=s.join(" ")),t.setAttribute(Zc+e,`${s}`)},Bs=function(){return eh},Fs=function(t){if(eh=t,null===t){let t;null==(t=document.querySelector("."+rh))||t.remove()}},Us=function(){document.querySelector("."+rh)||((eh=document.createElement("div")).className=rh,(E()||document.body).appendChild(eh))},Hs=function(t,e,s){Gs(),oh=t,nh=s,(t=eh)&&(t.style.direction=e?"rtl":"ltr",t.style.display="block",e=g(),lh=e.getRenderer().getClassName(),ah=e.getTheme().getClassName(),lh&&ot(t,lh),ah&&ot(t,ah))},Gs=function(){if(Vs()){oh=null;var t=eh;t&&(t.style.display="none",t.style.left="",t.style.top="",nh&&nh(),nh=null,t.textContent="",lh&&(rt(t,lh),lh=""),ah&&(rt(t,ah),ah=""),g().markFocused())}},Vs=function(){return!!oh},Ws=function(t){oh===t&&Gs()},Xs=function(t,e,s){eh.style.left=t+"px",eh.style.top=e+"px",eh.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(oh)&&oh.repositionForWindowResize()||Gs()},qs=function(){return hh},Zs=function(t){hh=t},Qs=function(t,e,s){if(Hs(uh,s,ni),e.length){var i=ti(e,s);dh=i,ei(i,t,s),setTimeout((function(){i.focus()}),1),hh=null}else oi()},ti=function(t,e){const s=new sh;s.setRole(Jc.MENU);for(let i=0;i{setTimeout((()=>{o.callback(o.scope)}),0)}))}),{})}return s},ei=function(t,e,s){const i=Nt();e=new Oa(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=Bs();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(uh),hh=null},ni=function(){dh&&(dh.dispose(),dh=null)},Dr.callbackFactory$$module$build$src$core$contextmenu=function(t,e){return()=>{let s;Dr.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-Dr.config$$module$build$src$core$config.snapRadius:i.x+Dr.config$$module$build$src$core$config.snapRadius,i.y+=2*Dr.config$$module$build$src$core$config.snapRadius,s.moveBy(i.x,i.y)}finally{Dr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&N(new(B(Dr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}},ri=function(t){return{text:Dr.Msg$$module$build$src$core$msg.REMOVE_COMMENT,enabled:!0,callback:function(){Dr.setGroup$$module$build$src$core$events$utils(!0),t.dispose(),Dr.setGroup$$module$build$src$core$events$utils(!1)}}},li=function(t){return{text:Dr.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,enabled:!0,callback:function(){const e=t.toCopyData();e&&Ls(e,t.workspace)}}},ai=function(t,e){const s={enabled:!0};return s.text=Dr.Msg$$module$build$src$core$msg.ADD_COMMENT,s.callback=function(){const s=new Ec(t,Dr.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT,Ec.DEFAULT_SIZE,Ec.DEFAULT_SIZE);var i=t.getInjectionDiv().getBoundingClientRect();i=new ua(e.clientX-i.left,e.clientY-i.top);const o=t.getOriginOffsetInPixels();(i=ua.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(Ia.CIRCLE,{cx:i.x,cy:i.y,r:0,fill:"none",stroke:"#888","stroke-width":10},e.getParentSvg());t=it(Ia.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*s},o),e=it(Ia.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},o),t.beginElement(),e.beginElement(),setTimeout((()=>{at(o)}),150)}},Pi=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),xh=t,Bi(t,e,new Date)}},Bi=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)})`,Dh=setTimeout(Bi,10,t,e,s)),t.getSvgRoot().setAttribute("transform",`${t.getTranslation()} ${o}`)},Fi=function(){xh&&(Dh&&(clearTimeout(Dh),Dh=null),xh.getSvgRoot().setAttribute("transform",xh.getTranslation()),xh=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;ieu&&lo()}else Zh!==qh&&(clearTimeout(zh),jh=t.pageX,Jh=t.pageY,zh=setTimeout(go,su))},ro=function(){Zh=qh=null,lo()},lo=function(){Wh&&(Wh=!1,ou&&(ou.style.display="none")),zh&&(clearTimeout(zh),zh=0)},ao=function(){lo(),Xh=!0},co=function(){Xh=!1},ho=function(){ou&&qh&&("function"==typeof Vh?Vh(ou,qh):uo())},uo=function(){var t=Zi(qh);t=(t=Dr.wrap$$module$build$src$core$utils$string(t,Yh)).split("\n");for(let e=0;es+window.scrollY&&(o-=ou.offsetHeight+2*tu),t?i=Math.max(iu-window.scrollX,i):i+ou.offsetWidth>e+window.scrollX-2*iu&&(i=e-ou.offsetWidth-2*iu),{x:i,y:o}},go=function(){if(!Xh&&(Zh=qh,ou)){ou.textContent="",ho();var t=qh.RTL;ou.style.direction=t?"rtl":"ltr",ou.style.display="block",Wh=!0;var{x:e,y:s}=po(t);ou.style.left=e+"px",ou.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 _u},Eo=function(t){_u=t},fo=function(){return Tu},bo=function(t){Tu=t},$o=function(t){t=`${t}`.toLowerCase().trim();var e=mu[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)},Oo=function(t){return(t=$o(t))?[(t=parseInt(t.substr(1),16))>>16,t>>8&255,255&t]:[0,0,0]},So=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=Oo(t),e=Oo(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},Ro=function(t){return So(t,_u,255*Tu)},ko=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 Dr.Msg$$module$build$src$core$msg?"string"==typeof(n=Dr.Msg$$module$build$src$core$msg[l])?Array.prototype.push.apply(i,ko(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:So(s,mo(),255*fo())};if(s=$o(e))return{hue:null,hex:s};throw s='Invalid colour: "'+e+'"',t!==e&&(s+=' (from "'+t+'")'),Error(s)},Lo=function(t){return void 0!==t.getProcedureModel&&void 0!==t.doProcedureUpdate&&void 0!==t.isProcedureDef},wo=function(t){return void 0!==t.startPublishing&&void 0!==t.stopPublishing},Mo=function(e,s){t(Ur.FIELD,e,s)},Do=function(t){i(Ur.FIELD,t)},Dr.fromJson$$module$build$src$core$field_registry=function(t){return Cu.fromJsonInternal(t)},xo=function(t){const e=l(Ur.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},Po=function(t){let e=!1;const s=t.map((([t,s])=>"string"==typeof t?[No(t),s]:(e=!0,[null!==t.alt?Object.assign({},t,{alt:No(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:Bo(s,t,n),prefix:o,suffix:i})},Bo=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=>{!Lo(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=>{!Lo(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"})},Dr.findLegalName$$module$build$src$core$procedures=function(t,e){if(e.isInFlyout)return t;for(t=t||Dr.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)&&Dr.Names$$module$build$src$core$names.equals(i.getProcedureDef()[0],t))return!0;s=s&&Lo(s)?null==s?void 0:s.getProcedureModel():void 0;for(const i of e.getProcedureMap().getProcedures())if(i!==s&&Dr.Names$$module$build$src$core$names.equals(i.getName(),t))return!0;return!1},Dr.rename$$module$build$src$core$procedures=function(t){var e=this.getSourceBlock();if(!e)throw new $u;t=t.trim();const s=Dr.findLegalName$$module$build$src$core$procedures(t,e);Lo(e)&&!e.isInsertionMarker()&&e.getProcedureModel().setName(s);const i=this.getValue();if(i!==t&&i!==s)for(t=e.workspace.getAllBlocks(!1),e=0;ebn(e,t)||oe(e)&&Dr.Names$$module$build$src$core$names.equals(e.getProcedureCall(),t)))},bn=function(t,e){return Lo(t)&&!t.isProcedureDef()&&t.getProcedureModel()&&Dr.Names$$module$build$src$core$names.equals(t.getProcedureModel().getName(),e)},Dr.mutateCallers$$module$build$src$core$procedures=function(t){const e=y();var s=t.getProcedureDef()[0];const i=t.mutationToDom(!0);t=fn(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))&&(k(!1),N(new(B(Dr.CHANGE$$module$build$src$core$events$utils))(n,"mutation",null,s,o)),k(e))}},Dr.getDefinition$$module$build$src$core$procedures=function(t,e){for(const s of e.getAllBlocks(!1))if(Lo(s)&&s.isProcedureDef()&&Dr.Names$$module$build$src$core$names.equals(s.getProcedureModel().getName(),t)||ie(s)&&Dr.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],t))return s;return null},$n=function(t){return t.isDynamic},In=function(t){return void 0!==t.pathDown&&void 0!==t.pathUp},On=function(t){return void 0!==t.pathLeft&&void 0!==t.pathRight},Sn=function(t){let e=t.outputConnection;return(!e||t.previousConnection&&t.previousConnection.isConnected())&&(e=t.previousConnection),e},Cn=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},kn=function(t,e){let s;for(;s=Rn(t,e);)if(!(t=s.targetBlock())||t.isShadow())return s;return null},yn=function(e,s){t(Ur.RENDERER,e,s)},Nn=function(t){i(Ur.RENDERER,t)},vn=function(t,e,s){return(t=new(r(Ur.RENDERER,t))(t)).init(e,s),t},An=function(t){he(t.getTargetWorkspace(),void 0,"String")},Ln=function(t){he(t.getTargetWorkspace(),void 0,"Number")},wn=function(t){he(t.getTargetWorkspace(),void 0,"Colour")},Mn=function(t){let e=[],s=document.createElement("button");return s.setAttribute("text",Dr.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",Dr.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",Dr.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",Ln),t.registerButtonCallback("CREATE_VARIABLE_COLOUR",wn),t=Dn(t),e.concat(t)},Dn=function(t){const e=[];if(0<(t=t.getAllVariables()).length){if(Wr.variables_set_dynamic){var s=t[t.length-1];const i=Dr.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(Wr.variables_get_dynamic){t.sort(cc.compareByName);for(let i,o=0;i=t[o];o++)(s=Dr.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},xn=function(t){t.resizeContents()},Pn=function(t){return void 0!==t.toCopyData},Bn=function(){Rp.registry.register({name:ap.ESCAPE,preconditionFn:t=>!t.options.readOnly,callback:t=>(t.hideChaff(),!0),keyCodes:[Mu.ESC]})},Fn=function(){Rp.registry.register({name:ap.DELETE,preconditionFn(t){const e=T();return!t.options.readOnly&&null!=e&&e.isDeletable()},callback:(t,e)=>(e.preventDefault(),!lu.inProgress()&&(T().checkAndDelete(),!0)),keyCodes:[Mu.DELETE,Mu.BACKSPACE]})},Un=function(){const t=Rp.registry.createSerializedKey(Mu.C,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.C,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.C,[Mu.META]);Rp.registry.register({name:ap.COPY,preconditionFn(t){const e=T();return!t.options.readOnly&&!lu.inProgress()&&null!=e&&e.isDeletable()&&e.isMovable()&&Pn(e)},callback:(t,e)=>(e.preventDefault(),t.hideChaff(),!(!(e=T())||!Pn(e)||(kp=e.toCopyData(),yp=t,!kp))),keyCodes:[t,e,s]})},Hn=function(){const t=Rp.registry.createSerializedKey(Mu.X,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.X,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.X,[Mu.META]);Rp.registry.register({name:ap.CUT,preconditionFn(t){const e=T();return!t.options.readOnly&&!lu.inProgress()&&null!=e&&e instanceof lp&&e.isDeletable()&&e.isMovable()&&!e.workspace.isFlyout},callback(t){const e=T();return!(!e||!Pn(e)||(kp=e.toCopyData(),yp=t,e.checkAndDelete(),0))},keyCodes:[t,e,s]})},Gn=function(){const t=Rp.registry.createSerializedKey(Mu.V,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.V,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.V,[Mu.META]);Rp.registry.register({name:ap.PASTE,preconditionFn:t=>!t.options.readOnly&&!lu.inProgress(),callback:()=>!(!kp||!yp||!Ls(kp,yp)),keyCodes:[t,e,s]})},Vn=function(){const t=Rp.registry.createSerializedKey(Mu.Z,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.Z,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.Z,[Mu.META]);Rp.registry.register({name:ap.UNDO,preconditionFn:t=>!t.options.readOnly&&!lu.inProgress(),callback:t=>(t.hideChaff(),t.undo(!1),!0),keyCodes:[t,e,s]})},Wn=function(){const t=Rp.registry.createSerializedKey(Mu.Z,[Mu.SHIFT,Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.Z,[Mu.SHIFT,Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.Z,[Mu.SHIFT,Mu.META]),i=Rp.registry.createSerializedKey(Mu.Y,[Mu.CTRL]);Rp.registry.register({name:ap.REDO,preconditionFn:t=>!lu.inProgress()&&!t.options.readOnly,callback:t=>(t.hideChaff(),t.undo(!0),!0),keyCodes:[t,e,s,i]})},Xn=function(){Bn(),Fn(),Un(),Hn(),Gn(),Vn(),Wn()},Yn=function(t){const e={id:t.getId(),name:t.getName(),returnTypes:t.getReturnTypes()};return t.getParameters().length?(e.parameters=t.getParameters().map((t=>Kn(t))),e):e},Kn=function(t){const e={id:t.getId(),name:t.getName()};return t.getTypes().length?(e.types=t.getTypes(),e):e},zn=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(jn(e,n,i),o);return t},jn=function(t,e,s){return t=new t(s,e.name,e.id),e.types&&t.setTypes(e.types),t},Jn=function(t){const e=Object.create(null),s=a(Ur.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},qn=function(t,e,{recordUndo:s=!1}={}){var i=a(Ur.SERIALIZER,!0);if(i){i=Object.entries(i).sort(((t,e)=>e[1].priority-t[1].priority));var o=y();k(s),(s=Dr.getGroup$$module$build$src$core$events$utils())||Dr.setGroup$$module$build$src$core$events$utils(!0),dt(),e instanceof jd&&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 jd&&e.setResizesEnabled(!0),pt(),N(new(B(ml))(e)),Dr.setGroup$$module$build$src$core$events$utils(s),k(o)}},Zn=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!==El.indexOf(null!=(s=e.type)?s:"")){s=i.getScrollMetrics(!0);const o=tr(t,e);o&&(i=Dr.getGroup$$module$build$src$core$events$utils()||!1,Dr.setGroup$$module$build$src$core$events$utils(e.group),Zn(t,s,o)&&!e.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),Dr.setGroup$$module$build$src$core$events$utils(i))}else e.type===dl&&e.scale&&e.oldScale&&e.scale>e.oldScale&&er(t)}},tr=function(t,e){let s=null;switch(e.type){case Dr.CREATE$$module$build$src$core$events$utils:case Dr.MOVE$$module$build$src$core$events$utils:(s=t.getBlockById(e.blockId))&&(s=s.getRootBlock());break;case pl:case Tl:s=t.getCommentById(e.commentId)}return s},er=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++)Zn(t,e,i)}},sr=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(...sr(i,ua.sum(e,i.relativeCoords)));return s},ir=function(){gh.registry.register({displayText:()=>Dr.Msg$$module$build$src$core$msg.UNDO,preconditionFn:t=>0Dr.Msg$$module$build$src$core$msg.REDO,preconditionFn:t=>0Dr.Msg$$module$build$src$core$msg.CLEAN_UP,preconditionFn:t=>t.workspace.isMovable()?1Dr.Msg$$module$build$src$core$msg.COLLAPSE_ALL,preconditionFn(t){if(t.workspace.options.collapse){t=t.workspace.getTopBlocks(!1);for(let e=0;eDr.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=hr(t.workspace).length)?Dr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Dr.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${t}`):"",preconditionFn:t=>t.workspace&&0e.length?ur(e):qt(Dr.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(e.length)),(function(t){t&&ur(e)}))}},scopeType:gh.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},pr=function(){ir(),or(),nr(),lr(),ar(),dr()},gr=function(){gh.registry.register({displayText:()=>Dr.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&&Ls(e,t.block.workspace)}},scopeType:gh.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},_r=function(){gh.registry.register({displayText:t=>t.block.hasIcon(Hu.TYPE)?Dr.Msg$$module$build$src$core$msg.REMOVE_COMMENT:Dr.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(Hu.TYPE)?t.setCommentText(null):t.setCommentText("")},scopeType:gh.ScopeType.BLOCK,id:"blockComment",weight:2})},Tr=function(){gh.registry.register({displayText:t=>t.block.getInputsInline()?Dr.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:Dr.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()?Dr.Msg$$module$build$src$core$msg.EXPAND_BLOCK:Dr.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:gh.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Er=function(){gh.registry.register({displayText:t=>t.block.isEnabled()?Dr.Msg$$module$build$src$core$msg.DISABLE_BLOCK:Dr.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=Dr.getGroup$$module$build$src$core$events$utils();e||Dr.setGroup$$module$build$src$core$events$utils(!0),t.setEnabled(!t.isEnabled()),Dr.setGroup$$module$build$src$core$events$utils(e)},scopeType:gh.ScopeType.BLOCK,id:"blockDisable",weight:5})},fr=function(){gh.registry.register({displayText(t){var e=t.block;return t=e.getDescendants(!1).length,(e=e.getNextBlock())&&(t-=e.getDescendants(!1).length),1===t?Dr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Dr.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:gh.ScopeType.BLOCK,id:"blockDelete",weight:6})},br=function(){gh.registry.register({displayText:()=>Dr.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:gh.ScopeType.BLOCK,id:"blockHelp",weight:7})},$r=function(){gr(),_r(),Tr(),mr(),Er(),fr(),br()},Ir=function(){pr(),$r()},Or=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 pu(e||{}),(e=document.createElement("div")).className="injectionDiv",e.tabIndex=0,Ps(e,qc.LABEL,Dr.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),s.appendChild(e),s=Sr(e,t);const o=Cr(e,s,t);return Rr(o),_(o),b(o),e.addEventListener("focusin",(function(){_(o)})),o},Sr=function(t,e){t.setAttribute("dir","LTR"),et(e.hasCss,e.pathToMedia),t=it(Ia.SVG,{xmlns:_a,"xmlns:html":Ta,"xmlns:xlink":ma,version:"1.1",class:"blocklySvg",tabindex:"0"},t);const s=it(Ia.DEFS,{},t),i=String(Math.random()).substring(2);return e.gridPattern=au.createDom(i,e.gridOptions,s),t},Cr=function(t,e,s){s.parentWorkspace=null;const i=(s=new jd(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(Ia.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)),b(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),wi(),Js(),b(t),er(t)})),t.setResizeHandlerWrapper(s),yr(),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 Dp(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&&Nr(e.pathToMedia,t)},kr=function(t){const e=g();e&&!(j(t)||e.rendered&&!e.isVisible())&&Rp.registry.onKeyDown(e,t)},yr=function(){vg||(Y(document,"scroll",null,(function(){const t=u();for(let e,s=0;e=t[s];s++)e instanceof jd&&e.updateInverseScreenCTM()})),Y(document,"keydown",null,kr),K(document,"touchend",null,H),K(document,"touchcancel",null,H),ql&&Y(window,"orientationchange",document,(function(){b(g())}))),vg=!0},Nr=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))},vr=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},Lr=function(t){return t.isSelectable()},wr=function(t){g().hideChaff(t)},(Mr=Mr||{}).scope={},Mr.ASSUME_ES5=!1,Mr.ASSUME_NO_NATIVE_MAP=!1,Mr.ASSUME_NO_NATIVE_SET=!1,Mr.SIMPLE_FROUND_POLYFILL=!1,Mr.ISOLATE_POLYFILLS=!1,Mr.FORCE_POLYFILL_PROMISE=!1,Mr.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,Mr.defineProperty=Mr.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,s){return t==Array.prototype||t==Object.prototype||(t[e]=s.value),t},Mr.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,Mr.propertyToPolyfillSymbol[o]=Mr.IS_SYMBOL_NATIVE?Mr.global.Symbol(o):Mr.POLYFILL_PREFIX+s+"$"+o),Mr.defineProperty(i,Mr.propertyToPolyfillSymbol[o],{configurable:!0,writable:!0,value:e})))},Mr.polyfill("globalThis",(function(t){return t||Mr.global}),"es_2020","es3"),Mr.arrayIteratorImpl=function(t){var e=0;return function(){return e{const t=[];for(let e=0;20>e;e++)t[e]=Il.charAt(88*Math.random());return t.join("")}},Sl=0,Cl={TEST_ONLY:Ol};Cl.genUid=R,Cl.getNextUniqueId=C,Jr="",qr=!0,Zr=0,Dr.CREATE$$module$build$src$core$events$utils="create",Dr.CREATE$$module$build$src$core$events$utils,Dr.DELETE$$module$build$src$core$events$utils="delete",Dr.DELETE$$module$build$src$core$events$utils,Dr.CHANGE$$module$build$src$core$events$utils="change",Dr.CHANGE$$module$build$src$core$events$utils,Qr="block_field_intermediate_change",Dr.MOVE$$module$build$src$core$events$utils="move",Dr.MOVE$$module$build$src$core$events$utils,tl="var_create",el="var_delete",sl="var_rename",il="ui",ol="drag",nl="selected",rl="click",ll="marker_move",al="bubble_open",cl="trashcan_open",hl="toolbox_item_select",ul="theme_change",dl="viewport_change",pl="comment_create",gl="comment_delete",_l="comment_change",Tl="comment_move",ml="finished_loading",El=[Dr.CREATE$$module$build$src$core$events$utils,Dr.MOVE$$module$build$src$core$events$utils,pl,Tl],bl={FIRE_QUEUE:fl=[],fireNow:A,fireInternal:v,setGroupInternal:D},($l={BLOCK_CHANGE:Dr.CHANGE$$module$build$src$core$events$utils,BLOCK_CREATE:Dr.CREATE$$module$build$src$core$events$utils,BLOCK_DELETE:Dr.DELETE$$module$build$src$core$events$utils,BLOCK_DRAG:ol,BLOCK_FIELD_INTERMEDIATE_CHANGE:Qr,BLOCK_MOVE:Dr.MOVE$$module$build$src$core$events$utils,BUBBLE_OPEN:al,BUMP_EVENTS:El,CHANGE:Dr.CHANGE$$module$build$src$core$events$utils,CLICK:rl,COMMENT_CHANGE:_l,COMMENT_CREATE:pl,COMMENT_DELETE:gl,COMMENT_MOVE:Tl,CREATE:Dr.CREATE$$module$build$src$core$events$utils,DELETE:Dr.DELETE$$module$build$src$core$events$utils,FINISHED_LOADING:ml,MARKER_MOVE:ll,MOVE:Dr.MOVE$$module$build$src$core$events$utils,SELECTED:nl,TEST_ONLY:bl,THEME_CHANGE:ul,TOOLBOX_ITEM_SELECT:hl,TRASHCAN_OPEN:cl,UI:il,VAR_CREATE:tl,VAR_DELETE:el,VAR_RENAME:sl,VIEWPORT_CHANGE:dl}).clearPendingUndo=w,$l.disable=Dr.disable$$module$build$src$core$events$utils,$l.disableOrphans=F,$l.enable=Dr.enable$$module$build$src$core$events$utils,$l.filter=L,$l.fire=N,$l.fromJson=P,$l.get=B,$l.getDescendantIds=x,$l.getGroup=Dr.getGroup$$module$build$src$core$events$utils,$l.getRecordUndo=y,$l.isEnabled=M,$l.setGroup=Dr.setGroup$$module$build$src$core$events$utils,$l.setRecordUndo=k;var Rl,kl,yl=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Dr.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}},Nl=class extends yl{constructor(t){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=void 0===t,this.workspaceId=t||""}},vl=class extends Nl{constructor(t,e,s){null===(e=t?t.workspace.id:e)&&(e=void 0),super(e),this.type=rl,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 vl)).targetType=t.targetType,e.blockId=t.blockId,e}};(kl=Rl||(Rl={})).BLOCK="block",kl.WORKSPACE="workspace",kl.ZOOM_CONTROLS="zoom_controls",t(Ur.EVENT,rl,vl);var Al={};Al.Click=vl,Al.ClickTarget=Rl;var Ll,wl,Ml,Dl,xl,Pl,Bl,Fl,Ul,Hl,Gl=750,Vl="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Wl=null,Xl={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Yl=0,Kl={TOUCH_ENABLED:Vl,TOUCH_MAP:Xl};Kl.checkTouchIdentifier=X,Kl.clearTouchIdentifier=G,Kl.getTouchIdentifierFromEvent=W,Kl.longStart=U,Kl.longStop=H,Kl.shouldHandleEvent=V,function(t){function e(t){return-1!==s.indexOf(t.toUpperCase())}const s=(Ll=t).toUpperCase();wl=e("JavaFX"),Ml=e("WebKit"),Dl=e("Gecko")&&!Ml,xl=e("Android"),t=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Pl=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}};la.Capability=ra;var aa=!1,ca='\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',ha={};ha.inject=et,ha.register=tt;var ua=class{constructor(t,e){this.x=t,this.y=e}clone(){return new ua(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 ua(t.x-e.x,t.y-e.y)}static sum(t,e){return new ua(t.x+e.x,t.y+e.y)}},da=new Set,pa={};pa.warn=st;var ga,_a="http://www.w3.org/2000/svg",Ta="http://www.w3.org/1999/xhtml",ma="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"}(ga||(ga={}));var Ea=null,fa=0,ba=null,$a={HTML_NS:Ta};$a.NodeType=ga,$a.SVG_NS=_a,$a.XLINK_NS=ma,$a.addClass=ot,$a.containsNode=ht,$a.createSvgElement=it,$a.getFastTextWidth=_t,$a.getFastTextWidthWithSizeString=Tt,$a.getTextWidth=gt,$a.hasClass=lt,$a.insertAfter=ct,$a.measureFontMetrics=mt,$a.removeClass=rt,$a.removeClasses=nt,$a.removeNode=at,$a.setCssTransform=ut,$a.startTextWidthCache=dt,$a.stopTextWidthCache=pt;var Ia=class{constructor(t){this.tagName=t}toString(){return this.tagName}};Ia.ANIMATE=new Ia("animate"),Ia.CIRCLE=new Ia("circle"),Ia.CLIPPATH=new Ia("clipPath"),Ia.DEFS=new Ia("defs"),Ia.FECOMPOSITE=new Ia("feComposite"),Ia.FECOMPONENTTRANSFER=new Ia("feComponentTransfer"),Ia.FEFLOOD=new Ia("feFlood"),Ia.FEFUNCA=new Ia("feFuncA"),Ia.FEGAUSSIANBLUR=new Ia("feGaussianBlur"),Ia.FEPOINTLIGHT=new Ia("fePointLight"),Ia.FESPECULARLIGHTING=new Ia("feSpecularLighting"),Ia.FILTER=new Ia("filter"),Ia.FOREIGNOBJECT=new Ia("foreignObject"),Ia.G=new Ia("g"),Ia.IMAGE=new Ia("image"),Ia.LINE=new Ia("line"),Ia.PATH=new Ia("path"),Ia.PATTERN=new Ia("pattern"),Ia.POLYGON=new Ia("polygon"),Ia.RECT=new Ia("rect"),Ia.SVG=new Ia("svg"),Ia.TEXT=new Ia("text"),Ia.TSPAN=new Ia("tspan");var Oa=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&&va.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-=va.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),e=t.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(e+=va.scrollbarThickness),this.setPosition(e,t.absoluteTop+t.viewHeight-va.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-=va.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),this.setPosition(this.workspace.RTL?t.absoluteLeft+this.margin:t.absoluteLeft+t.viewWidth-va.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 ua(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}};va.scrollbarThickness=Vl?25:15,va.DEFAULT_SCROLLBAR_MARGIN=.5;var Aa={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},La={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:wa,DOMParser:Ma,XMLSerializer:Da}=globalThis;Ma&&(Aa=new Ma),Da&&(La=new Da);var xa="https://developers.google.com/blockly/xml",Pa=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,Ba={NAME_SPACE:xa};Ba.createElement=Dr.createElement$$module$build$src$core$utils$xml,Ba.createTextNode=Dr.createTextNode$$module$build$src$core$utils$xml,Ba.domToText=Mt,Ba.injectDependencies=wt,Ba.textToDom=Dr.textToDom$$module$build$src$core$utils$xml;var Fa,Ua="categoryToolbox",Ha="flyoutToolbox";!function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM",t[t.LEFT=2]="LEFT",t[t.RIGHT=3]="RIGHT"}(Fa||(Fa={}));var Ga,Va,Wa,Xa={hasCategoriesInternal:Ut},Ya={};Ya.Position=Fa,Ya.TEST_ONLY=Xa,Ya.convertFlyoutDefToJsonArray=Bt,Ya.convertToolboxDefToJson=xt,Ya.hasCategories=Ft,Ya.isCategoryCollapsible=Ht,Ya.parseToolboxTree=Xt,function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM"}(Ga||(Ga={})),function(t){t[t.LEFT=0]="LEFT",t[t.RIGHT=1]="RIGHT"}(Va||(Va={})),function(t){t[t.UP=0]="UP",t[t.DOWN=1]="DOWN"}(Wa||(Wa={}));var Ka={};Ka.bumpDirection=Wa,Ka.bumpPositionRect=zt,Ka.getCornerOppositeToolbox=Kt,Ka.getStartPositionRect=Yt,Ka.horizontalPosition=Va,Ka.verticalPosition=Ga;var za=96,ja=124,Ja="sprites.png",qa=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(Ia.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:[la.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 Oa(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 Sa(this.WIDTH,o),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,t,this.workspace),i=i.vertical,e=zt(t,this.MARGIN_VERTICAL,i===Ga.TOP?Wa.DOWN:Wa.UP,e),i===Ga.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(Ia.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const e=it(Ia.CLIPPATH,{id:"blocklyZoomoutClipPath"+t},this.zoomOutGroup);it(Ia.RECT,{width:32,height:32},e),it(Ia.IMAGE,{width:za,height:ja,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+t+")"},this.zoomOutGroup).setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),this.boundEvents.push(Y(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(t){this.zoomInGroup=it(Ia.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const e=it(Ia.CLIPPATH,{id:"blocklyZoominClipPath"+t},this.zoomInGroup);it(Ia.RECT,{width:32,height:32},e),it(Ia.IMAGE,{width:za,height:ja,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+t+")"},this.zoomInGroup).setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),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(Ia.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const e=it(Ia.CLIPPATH,{id:"blocklyZoomresetClipPath"+t},this.zoomResetGroup);it(Ia.RECT,{width:32,height:32},e),it(Ia.IMAGE,{width:za,height:ja,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+t+")"},this.zoomResetGroup).setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),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(B(rl))(null,this.workspace.id,"zoom_controls");N(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 Za=class{constructor(t){this.name=t}toString(){return this.name}equals(t){return this.name===t.toString()}};Za.MUTATOR=new Za("mutator"),Za.WARNING=new Za("warning"),Za.COMMENT=new Za("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"}(Dr.inputTypes$$module$build$src$core$inputs$input_types||(Dr.inputTypes$$module$build$src$core$inputs$input_types={})),Dr.inputTypes$$module$build$src$core$inputs$input_types;var Qa,tc,ec=function(t,e){window.alert(t),e&&e()},sc=function(t,e){e(window.confirm(t))},ic=function(t,e,s){s(window.prompt(t,e))},oc={confirmInternal:Zt},nc={TEST_ONLY:oc};nc.alert=jt,nc.confirm=qt,nc.prompt=te,nc.setAlert=Jt,nc.setConfirm=Qt,nc.setPrompt=ee,Dr.Msg$$module$build$src$core$msg=Object.create(null),Qa=function(t){Object.keys(t).forEach((function(e){Dr.Msg$$module$build$src$core$msg[e]=t[e]}))},tc={Msg:Dr.Msg$$module$build$src$core$msg,setLocale:Qa};var rc={};rc.isLegacyProcedureCallBlock=oe,rc.isLegacyProcedureDefBlock=ie;var lc=class extends yl{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 lc)).varId=t.varId,e}},ac=class extends lc{constructor(t){super(t),this.type=tl,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 ac)).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(Ur.EVENT,tl,ac);var cc=class{constructor(t,e,s,i){this.workspace=t,this.name=e,this.type=s||"",this.id_=i||R()}getId(){return this.id_}static compareByName(t,e){return t.name.localeCompare(e.name,void 0,{sensitivity:"base"})}},hc="VARIABLE",uc="ijkmnopqrstuvwxyzabcdefgh",dc={generateUniqueNameInternal:ae},pc={CATEGORY_NAME:hc,TEST_ONLY:dc,VAR_LETTER_OPTIONS:uc};pc.allDeveloperVariables=Dr.allDeveloperVariables$$module$build$src$core$variables,pc.allUsedVarModels=Dr.allUsedVarModels$$module$build$src$core$variables,pc.createVariableButtonHandler=he,pc.flyoutCategory=ne,pc.flyoutCategoryBlocks=re,pc.generateUniqueName=le,pc.generateUniqueNameFromOptions=ce,pc.generateVariableFieldDom=me,pc.getAddedVariables=fe,pc.getOrCreateVariablePackage=Dr.getOrCreateVariablePackage$$module$build$src$core$variables,pc.getVariable=Dr.getVariable$$module$build$src$core$variables,pc.nameUsedWithAnyType=pe,pc.nameUsedWithConflictingParam=ge,pc.promptName=ue,pc.renameVariable=Dr.renameVariable$$module$build$src$core$variables;var gc=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:R(),t.addTopComment(this),this.xy_=new ua(0,0),this.height_=s,this.width_=i,this.RTL=t.RTL,this.content_=e,gc.fireCreateEvent(this)}dispose(){this.disposed_||(M()&&N(new(B(gl))(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 ua(this.xy_.x,this.xy_.y)}moveBy(t,e){const s=new(B(Tl))(this);this.xy_.translate(t,e),s.recordNew(),N(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&&(N(new(B(_l))(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=Dr.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=Dr.getGroup$$module$build$src$core$events$utils();e||Dr.setGroup$$module$build$src$core$events$utils(!0);try{N(new(B(pl))(t))}finally{Dr.setGroup$$module$build$src$core$events$utils(e)}}}static fromXml(t,e){var s=gc.parseAttributes(t);return e=new gc(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),gc.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:""}}},_c=class extends Nl{constructor(t,e,s){super(s),this.type=nl,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 _c)).oldElementId=t.oldElementId,e.newElementId=t.newElementId,e}};t(Ur.EVENT,nl,_c);var Tc={};Tc.register=be,Tc.unregister=$e;var mc=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 Ec.fromXmlRendered(t.commentState,e)}};mc.TYPE="workspace-comment",be(mc.TYPE,new mc);var Ec=class extends gc{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(Ia.G,{class:"blocklyComment"}),this.workspace=t,this.svgRect_=it(Ia.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()&&N(new(B(gl))(this)),at(this.svgGroup),Dr.disable$$module$build$src$core$events$utils(),super.dispose(),Dr.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,Dr.disable$$module$build$src$core$events$utils();try{T().unselect()}finally{Dr.enable$$module$build$src$core$events$utils()}}t=new(B(nl))(t,this.id,this.workspace.id),N(t),m(this),this.addSelect()}}unselect(){if(T()===this){var t=new(B(nl))(this.id,null,this.workspace.id);N(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=kt(i);e+=t.x,s+=t.y,i=i.parentNode}while(i&&!t.hasLayer(i)&&null!==i);return this.xy_=new ua(e,s)}moveBy(t,e){const s=new(B(Tl))(this),i=this.getRelativeToSurfaceXY();this.translate(i.x+t,i.y+e),this.xy_=new ua(i.x+t,i.y+e),s.recordNew(),N(s),this.workspace.resizeContents()}translate(t,e){this.xy_=new ua(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 Oa(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:mc.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(Ia.RECT,{class:"blocklyCommentHandleTarget",x:0,y:0}),this.svgGroup.appendChild(this.svgHandleTarget),this.svgRectTarget=it(Ia.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(Ia.FOREIGNOBJECT,{x:0,y:Ec.TOP_OFFSET,class:"blocklyCommentForeignObject"});const t=document.createElementNS(Ta,"body");t.setAttribute("xmlns",Ta),t.className="blocklyMinimalBody";const e=document.createElementNS(Ta,"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(Ia.G,{class:this.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.svgGroup),it(Ia.POLYGON,{points:"0,8 8,8 8,0"},this.resizeGroup),it(Ia.LINE,{class:"blocklyResizeLine",x1:8/3,y1:7,x2:7,y2:8/3},this.resizeGroup),it(Ia.LINE,{class:"blocklyResizeLine",x1:16/3,y1:7,x2:7,y2:16/3},this.resizeGroup)}addDeleteDom(){this.deleteGroup=it(Ia.G,{class:"blocklyCommentDeleteIcon"},this.svgGroup),this.deleteIconBorder=it(Ia.CIRCLE,{class:"blocklyDeleteIconShape",r:"7",cx:"7.5",cy:"7.5"},this.deleteGroup),it(Ia.LINE,{x1:"5",y1:"10",x2:"10",y2:"5",stroke:"#fff","stroke-width":"2"},this.deleteGroup),it(Ia.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 ua(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=Ec.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+Ec.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(Ec.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;Dr.disable$$module$build$src$core$events$utils();try{const o=gc.parseAttributes(t);if(i=new Ec(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{Dr.enable$$module$build$src$core$events$utils()}return gc.fireCreateEvent(i),i}};Ec.DEFAULT_SIZE=100,Ec.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 fc=new Set,bc=new WeakSet,$c=null,Ic=null,Oc=0,Sc={};Sc.finishQueuedRenders=Oe,Sc.queueRender=Ie,Sc.triggerQueuedRenders=Se;var Cc={};Cc.appendDomToWorkspace=He,Cc.blockToDom=xe,Cc.blockToDomWithXY=we,Cc.clearWorkspaceAndLoadFromXml=Ue,Cc.deleteNext=ts,Cc.domToBlock=Dr.domToBlock$$module$build$src$core$xml,Cc.domToBlockInternal=Ge,Cc.domToPrettyText=Fe,Cc.domToText=Be,Cc.domToVariables=Ve,Cc.domToWorkspace=Dr.domToWorkspace$$module$build$src$core$xml,Cc.variablesToDom=Le,Cc.workspaceToDom=Ae;var Rc=class extends Error{},kc=class extends Rc{constructor(t){super("Expected to find a 'type' property, defining the block type"),this.state=t}},yc=class extends Rc{constructor(t,e,s){super(`The block ${e.toDevString()} is missing a(n) ${t}\nconnection`),this.block=e,this.state=s}},Nc=class extends Rc{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}},vc=class extends Rc{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}},Ac=class extends Rc{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}},Lc={};Lc.BadConnectionCheck=Nc,Lc.DeserializationError=Rc,Lc.MissingBlockType=kc,Lc.MissingConnection=yc,Lc.RealChildOfShadow=vc,Lc.UnregisteredIcon=Ac;var wc={BLOCKS:50,PROCEDURES:75,VARIABLES:100},Mc={};Mc.register=is,Mc.unregister=os;var Dc=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 Dc);var xc={};xc.BlockSerializer=Dc,xc.append=gs,xc.appendInternal=_s,xc.save=ns;var Pc=class extends yl{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 Pc)).blockId=t.blockId,e}},Bc=class extends Pc{constructor(t){super(t),this.type=Dr.CREATE$$module$build$src$core$events$utils,t&&(t.isShadow()&&(this.recordUndo=!1),this.xml=we(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=Be(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 Bc)).xml=Dr.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(!Fc(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(Ur.EVENT,Dr.CREATE$$module$build$src$core$events$utils,Bc);var Uc=class extends Nl{constructor(t,e){super(e),this.type=ul,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 Uc)).themeName=t.themeName,e}};t(Ur.EVENT,ul,Uc);var Hc,Gc=class extends Nl{constructor(t,e,s,i,o){super(i),this.type=dl,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 Gc)).viewTop=t.viewTop,e.viewLeft=t.viewLeft,e.scale=t.scale,e.oldScale=t.oldScale,e}};t(Ur.EVENT,dl,Gc),Dr.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250},Dr.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"}(Hc||(Hc={}));var Vc=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 ua(t.clientX,t.clientY);if(1>ua.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}},ih=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),Ps(t,qc.SELECTED,this.checkable&&this.checked||!1),Ps(t,qc.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)}},oh=null,nh=null,rh="blocklyWidgetDiv",lh="",ah="",ch={};ch.createDom=Us,ch.getDiv=Bs,ch.hide=Gs,ch.hideIfOwner=Ws,ch.isVisible=Vs,ch.positionWithAnchor=Ys,ch.repositionForWindowResize=Js,ch.show=Hs,ch.testOnly_setDiv=Fs;var hh=null,uh={},dh=null,ph={};ph.callbackFactory=Dr.callbackFactory$$module$build$src$core$contextmenu,ph.commentDeleteOption=ri,ph.commentDuplicateOption=li,ph.dispose=ni,ph.getCurrentBlock=qs,ph.hide=oi,ph.setCurrentBlock=Zs,ph.show=Qs,ph.workspaceCommentOption=ai;var gh=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}(gh||(gh={}));var _h=gh.ScopeType,Th={};Th.ContextMenuRegistry=gh,Th.ScopeType=_h;var mh={};mh.clamp=ui,mh.toDegrees=hi,mh.toRadians=ci;var Eh,fh,bh,$h=16,Ih=1,Oh=12,Sh=16,Ch=.25,Rh=null,kh=null,yh="",Nh="",vh=null,Ah=null,Lh=null,wh={getBoundsInfo:function(){const t=It(vh),e=Et(vh);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=wh.getBoundsInfo(),n=Et(Eh);return e+n.heighto.top?Ci(s,i,o,n):e+n.heightdocument.documentElement.clientTop?Ci(s,i,o,n):Ri(t,o,n)}},Mh={ANIMATION_TIME:Ch,ARROW_HORIZONTAL_PADDING:Oh,ARROW_SIZE:$h,BORDER_SIZE:Ih,PADDING_Y:Sh,TEST_ONLY:wh};Mh.clearContent=Ti,Mh.createDom=di,Mh.getContentDiv=_i,Mh.getOwner=gi,Mh.getPositionX=ki,Mh.hide=vi,Mh.hideIfOwner=Ni,Mh.hideWithoutAnimation=Ai,Mh.isVisible=yi,Mh.repositionForWindowResize=wi,Mh.setBoundsElement=pi,Mh.setColour=mi,Mh.show=Oi,Mh.showPositionedByBlock=Ei,Mh.showPositionedByField=fi;var Dh=null,xh=null,Ph={};Ph.connectionUiEffect=xi,Ph.disconnectUiEffect=Pi,Ph.disconnectUiStop=Fi,Ph.disposeUiEffect=Mi;var Bh=class{constructor(t,e){this.bubble=t,this.workspace=e,this.dragTarget_=null,this.wouldDeleteBubble_=!1,this.startXY_=this.bubble.getRelativeToSurfaceXY()}startBubbleDrag(){let t;Dr.getGroup$$module$build$src$core$events$utils()||Dr.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=ua.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,la.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=ua.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),Dr.setGroup$$module$build$src$core$events$utils(!1)}fireMoveEvent_(){if(this.bubble instanceof Ec){const t=new(B(Tl))(this.bubble);t.setOldCoordinate(this.startXY_),t.recordNew(),N(t)}}pixelsToWorkspaceUnits_(t){return t=new ua(t.x/this.workspace.scale,t.y/this.workspace.scale),this.workspace.isMutator&&t.scale(1/this.workspace.options.parentWorkspace.scale),t}},Fh=[];Fh[Hc.INPUT_VALUE]=Hc.OUTPUT_VALUE,Fh[Hc.OUTPUT_VALUE]=Hc.INPUT_VALUE,Fh[Hc.NEXT_STATEMENT]=Hc.PREVIOUS_STATEMENT,Fh[Hc.PREVIOUS_STATEMENT]=Hc.NEXT_STATEMENT;var Uh="RENAME_VARIABLE_ID",Hh="DELETE_VARIABLE_ID",Gh={};Gh.commonWordPrefix=Gi,Gh.commonWordSuffix=Vi,Gh.isNumber=Dr.isNumber$$module$build$src$core$utils$string,Gh.shortestStringLength=Hi,Gh.startsWith=Ui,Gh.wrap=Dr.wrap$$module$build$src$core$utils$string;var Vh=void 0,Wh=!1,Xh=!1,Yh=50,Kh=0,zh=0,jh=0,Jh=0,qh=null,Zh=null,Qh=0,tu=10,eu=10,su=750,iu=5,ou=null,nu={HOVER_MS:su,LIMIT:Yh,MARGINS:iu,OFFSET_X:Qh,OFFSET_Y:tu,RADIUS_OK:eu};nu.bindMouseEvents=eo,nu.block=ao,nu.createDom=to,nu.dispose=ro,nu.getCustomTooltip=ji,nu.getDiv=qi,nu.getTooltipOfObject=Zi,nu.hide=lo,nu.isVisible=Ji,nu.setCustomTooltip=zi,nu.unbindMouseEvents=so,nu.unblock=co;var ru=class{constructor(t){this.workspace=t,this.horizontalScrollEnabled_=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled_=this.workspace.isMovableVertically(),this.startScrollXY_=new ua(t.scrollX,t.scrollY)}dispose(){this.workspace=null}startDrag(){T()&&T().unselect()}endDrag(t){this.drag(t)}drag(t){if(t=ua.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)}}},lu=class{constructor(t,e){this.creatorWorkspace=e,this.mouseDownXY=new ua(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 ua(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 ua(t.clientX,t.clientY);this.updateDragDelta(e)&&(this.updateIsDragging(),H()),this.mostRecentEvent=t}updateDragDelta(t){return this.currentDragDeltaXY=ua.difference(t,this.mouseDownXY),!this.hasExceededDragRadius&&(this.hasExceededDragRadius=ua.magnitude(this.currentDragDeltaXY)>(this.flyout?Dr.config$$module$build$src$core$config.flyoutDragRadius:Dr.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(),Dr.getGroup$$module$build$src$core$events$utils()||Dr.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 ru(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(Ur.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 Bh(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 ua(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=ua.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=ua.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 ua(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){N(new(B(rl))(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 Ec&&(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()&&(Dr.getGroup$$module$build$src$core$events$utils()||Dr.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(B(rl))(this.startBlock,this.startWorkspace_.id,"block");N(t)}this.bringBlockToFront(),Dr.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}},au=class{constructor(t,e){let s,i,o;this.pattern=t,this.scale=1,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}setSpacing(t){this.spacing=t,this.update(this.scale)}setLength(t){this.length=t,this.update(this.scale)}setSnapToGrid(t){this.snapToGrid=t}shouldSnap(){return this.snapToGrid}getSpacing(){return this.spacing}getPatternId(){return this.pattern.id}update(t){this.scale=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(Ia.PATTERN,{id:"blocklyGridPattern"+t,patternUnits:"userSpaceOnUse"},s),0<(null!=(i=e.length)?i:1)&&0<(null!=(o=e.spacing)?o:0)){let s;it(Ia.LINE,{stroke:e.colour},t),null!=(s=e.length)&&s&&it(Ia.LINE,{stroke:e.colour},t)}else it(Ia.LINE,{},t);return t}},cu=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)}};cu.LOCAL_MARKER="local_marker_1";var hu={};hu.deepMerge=_o;var uu=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(Ur.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 uu(t);let i=e.base;if(i){if("string"==typeof i){let t;i=null!=(t=l(Ur.THEME,i))?t:void 0}i instanceof uu&&(_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}},du=new uu("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"}}),pu=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?Fa.TOP:Fa.BOTTOM:d===h?Fa.RIGHT:Fa.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,f,b,$=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=pu.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=pu.parseGridOptions_(t),this.zoomOptions=pu.parseZoomOptions_(t),this.toolboxPosition=d,this.theme=pu.parseThemeOptions_(t),this.renderer=T,this.rendererOverrides=null!=(f=t.rendererOverrides)?f:null,this.parentWorkspace=null!=(b=t.parentWorkspace)?b: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")),N(new gu(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())?Be(t):""}};t(Ur.EVENT,Dr.CHANGE$$module$build$src$core$events$utils,gu);var _u=.45,Tu=.65,mu={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"},Eu={};Eu.blend=Co,Eu.getHsvSaturation=mo,Eu.getHsvValue=fo,Eu.hexToRgb=Oo,Eu.hsvToHex=So,Eu.hueToHex=Ro,Eu.names=mu,Eu.parse=$o,Eu.rgbToHex=Io,Eu.setHsvSaturation=Eo,Eu.setHsvValue=bo;var fu={};fu.checkMessageReferences=vo,fu.parseBlockColour=Ao,fu.replaceMessageReferences=No,fu.tokenizeInterpolation=yo;var bu=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 Sa(0,0),t!==bu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){t.tooltip&&this.setTooltip(No(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(Ia.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(Ia.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(Ia.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(bu))?t:this.getValue()}loadState(t){this.loadLegacyState(bu,t)||this.setValue(t)}saveLegacyState(t){return t.prototype.saveState===this.saveState&&t.prototype.toXml!==this.toXml?((t=Dr.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(Dr.textToDom$$module$build$src$core$utils$xml(e)),!0)}dispose(){let t;Ni(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_!==bu.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 Sa(0,0)}getScaledBBox(){let t;var e=this.getSourceBlock();if(!e)throw new $u;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,jl?(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 Oa(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,bu.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(t+="‏"),t):bu.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()&&N(new(B(Dr.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 $u;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 $u;this.imageElement.style.display="",this.imageElement.setAttributeNS(ma,"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+yu);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 $u;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)}};ku.CHECKMARK_OVERHANG=25,ku.MAX_MENU_HEIGHT_VH=.45,ku.ARROW_CHAR="▾";var yu=10;Mo("field_dropdown",ku);var Nu,vu=class{constructor(t,e,s){this.workspace=t,this.anchor=e,this.ownerRect=s,this.size=new Sa(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.svgRoot=it(Ia.G,{},t.getBubbleCanvas()),t=it(Ia.G,{filter:`url(#${this.workspace.getRenderer().getConstants().embossFilterId})`},this.svgRoot),this.tail=it(Ia.PATH,{},t),this.background=it(Ia.RECT,{class:"blocklyDraggable",x:0,y:0,rx:Nu.BORDER_WIDTH,ry:Nu.BORDER_WIDTH},t),this.contentContainer=it(Ia.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,Nu.MIN_SIZE),t.height=Math.max(t.height,Nu.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 Oa(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 Oa(e,s,i,t)}getScrollbarThickness(){return va.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)/Nu.TAIL_THICKNESS;h=Math.min(h,this.size.width,this.size.height)/4,i=e+(l=1-Nu.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?-Nu.TAIL_ANGLE:Nu.TAIL_ANGLE)))>2*Math.PI&&(a-=2*Math.PI),r=Math.sin(a)*n/Nu.TAIL_BEND,n=Math.cos(a)*n/Nu.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 ua(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){}};Nu=vu,vu.BORDER_WIDTH=6,vu.DOUBLE_BORDER=2*Nu.BORDER_WIDTH,vu.MIN_SIZE=Nu.DOUBLE_BORDER,vu.TAIL_THICKNESS=1,vu.TAIL_ANGLE=20,vu.TAIL_BEND=4,vu.ANCHOR_RADIUS=8;var Au=class extends vu{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 pu(t),this.validateWorkspaceOptions(e),this.svgDialog=it(Ia.SVG,{x:vu.BORDER_WIDTH,y:vu.BORDER_WIDTH},this.contentContainer),t.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new pu(t)),this.miniWorkspace.internalIsMutator=!0,t=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(t),e.languageTree&&(t.insertBefore(this.miniWorkspace.addFlyout(Ia.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 ua.sum(this.workspaceLocation,new ua(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new Oa(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=>{Dr.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===Dr.CREATE$$module$build$src$core$events$utils||t.type===Dr.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=Dr.getGroup$$module$build$src$core$events$utils();t||Dr.setGroup$$module$build$src$core$events$utils(!0);var e=gu.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var s=gu.getExtraBlockState_(this.sourceBlock);e!==s&&N(new(B(Dr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"mutation",null,e,s)),Dr.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()}},Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=Za.MUTATOR,Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon;var Lu=Object.create(null),wu={allExtensions:Lu};Dr.register$$module$build$src$core$extensions("parent_tooltip_when_inline",Qo);var Mu,Du={TEST_ONLY:wu};Du.apply=Go,Du.buildTooltipForDropdown=Dr.buildTooltipForDropdown$$module$build$src$core$extensions,Du.buildTooltipWithFieldText=Dr.buildTooltipWithFieldText$$module$build$src$core$extensions,Du.isRegistered=Ho,Du.register=Dr.register$$module$build$src$core$extensions,Du.registerMixin=Dr.registerMixin$$module$build$src$core$extensions,Du.registerMutator=Dr.registerMutator$$module$build$src$core$extensions,Du.runAfterPageLoad=qo,Du.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"}(Mu||(Mu={}));var xu={};xu.arc=an,xu.curve=en,xu.line=rn,xu.lineOnAxis=ln,xu.lineTo=nn,xu.moveBy=on,xu.moveTo=sn,xu.point=tn;var Pu={};Pu.Coordinate=ua,Pu.KeyCodes=Mu,Pu.Rect=Oa,Pu.Size=Sa,Pu.Svg=Ia,Pu.aria=th,Pu.array=na,Pu.browserEvents=oa,Pu.colour=Eu,Pu.deprecation=pa,Pu.dom=$a,Pu.extensions=Du,Pu.idGenerator=Cl,Pu.math=mh,Pu.object=hu,Pu.parsing=fu,Pu.string=Gh,Pu.style=Ra,Pu.svgMath=Na,Pu.svgPaths=xu,Pu.toolbox=Ya,Pu.userAgent=ea,Pu.xml=Ba;var Bu={};Bu.register=cn,Bu.unregister=hn;var Fu=class extends vu{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(Ia.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:vu.BORDER_WIDTH},t)}createSpans(t,e){return e.split("\n").map((e=>{const s=it(Ia.TSPAN,{dy:"1em",x:vu.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+vu.BORDER_WIDTH}`)}updateBubbleSize(){const t=this.paragraph.getBBox();this.setSize(new Sa(t.width+2*vu.BORDER_WIDTH,t.height+2*vu.BORDER_WIDTH),!0)}},Uu=class extends vu{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 Sa(160+vu.DOUBLE_BORDER,80+vu.DOUBLE_BORDER),this.MIN_SIZE=new Sa(45+vu.DOUBLE_BORDER,20+vu.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(Ia.FOREIGNOBJECT,{x:vu.BORDER_WIDTH,y:vu.BORDER_WIDTH},t);const e=document.createElementNS(Ta,"body");e.setAttribute("xmlns",Ta),e.className="blocklyMinimalBody";const s=document.createElementNS(Ta,"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(Ia.G,{class:this.workspace.RTL?"blocklyResizeSW":"blocklyResizeSE"},t);const e=2*vu.BORDER_WIDTH;return it(Ia.POLYGON,{points:`0,${e} ${e},${e} ${e},0`},t),it(Ia.LINE,{class:"blocklyResizeLine",x1:e/3,y1:e-1,x2:e-1,y2:e/3},t),it(Ia.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-vu.DOUBLE_BORDER,i=t.height-vu.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(${vu.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 ua(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 Sa(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 Hu=class extends Su{constructor(t){super(t),this.sourceBlock=t,this.textBubble=this.textInputBubble=null,this.text="",this.bubbleSize=new Sa(160,80),this.bubbleVisiblity=!1}getType(){return Hu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(Ia.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),it(Ia.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(Ia.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 Hu.WEIGHT}getSize(){return new Sa(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;N(new(B(Dr.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 Sa(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&&(N(new(B(Dr.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(),N(new(B(al))(this.sourceBlock,t,"comment"))))}showEditableBubble(){this.textInputBubble=new Uu(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 Fu(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 ua.sum(this.workspaceLocation,new ua(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new Oa(t.y,t.y+t.height,t.x,t.x+t.width)}};Hu.TYPE=Za.COMMENT,Hu.WEIGHT=3,cn(Hu.TYPE,Hu);var Gu=class extends Su{constructor(t){super(t),this.sourceBlock=t,this.textMap=new Map,this.textBubble=null}getType(){return Gu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(Ia.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(Ia.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),it(Ia.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 Gu.WEIGHT}getSize(){return new Sa(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 Fu(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.applyColour();else{let t;null==(t=this.textBubble)||t.dispose(),this.textBubble=null}N(new(B(al))(this.sourceBlock,t,"warning"))}}getAnchorLocation(){return ua.sum(this.workspaceLocation,new ua(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new Oa(t.y,t.y+t.height,t.x,t.x+t.width)}};Gu.TYPE=Za.WARNING,Gu.WEIGHT=2;var Vu=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}},Wu={};Wu.DuplicateIconType=Vu;var Xu,Yu,Ku={};Ku.CommentIcon=Hu,Ku.Icon=Su,Ku.IconType=Za,Ku.MutatorIcon=Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon,Ku.WarningIcon=Gu,Ku.exceptions=Wu,Ku.registry=Bu,Xu="PROCEDURE",Dr.DEFAULT_ARG$$module$build$src$core$procedures="x",(Yu={CATEGORY_NAME:Xu,DEFAULT_ARG:Dr.DEFAULT_ARG$$module$build$src$core$procedures}).ObservableProcedureMap=Ou,Yu.allProcedures=un,Yu.findLegalName=Dr.findLegalName$$module$build$src$core$procedures,Yu.flyoutCategory=_n,Yu.getCallers=fn,Yu.getDefinition=Dr.getDefinition$$module$build$src$core$procedures,Yu.isNameUsed=gn,Yu.isProcedureBlock=Lo,Yu.mutateCallers=Dr.mutateCallers$$module$build$src$core$procedures,Yu.mutatorOpenListener=mn,Yu.rename=Dr.rename$$module$build$src$core$procedures;var zu=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}},ju=class{constructor(t){this.centerline=this.xPos=this.height=this.width=0,this.constants_=t,this.type=zu.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},Ju=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=zu.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(zu.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;","}"]}},md={};md.ConstantProvider=Td,md.isDynamicShape=$n,md.isNotch=On,md.isPuzzleTab=In;var Ed=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.updateConnectionHighlights(),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=Dr.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))&&(Dr.disable$$module$build$src$core$events$utils(),this.maybeHidePreview(s),this.maybeShowPreview(s),Dr.enable$$module$build$src$core$events$utils())}createMarkerBlock(t){var e=t.type;let s;Dr.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){Dr.disable$$module$build$src$core$events$utils();try{t.dispose()}finally{Dr.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"}(Md||(Md={}));var Dd=Md.PREVIEW_TYPE,xd={};xd.InsertionMarkerManager=Md,xd.PreviewType=Dd;var Pd=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 Td}makeRenderInfo_(t){return new Sd(this,t)}makeDrawer_(t,e){return new Ed(t,e)}makeMarkerDrawer(t,e){return new kd(t,this.getConstants(),e)}makePathObject(t,e){return new yd(t,e,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(t){return!0}orphanCanConnectAtEnd(t,e,s){return!!Nd.getConnectionForOrphanedConnection(t,s===Hc.OUTPUT_VALUE?e.outputConnection:e.previousConnection)}getConnectionPreviewMethod(t,e,s){return st("getConnectionPreviewMethod","v10","v12","an IConnectionPreviewer, if it fulfills your use case."),e.type===Hc.OUTPUT_VALUE||e.type===Hc.PREVIOUS_STATEMENT?!t.isConnected()||this.orphanCanConnectAtEnd(s,t.targetBlock(),e.type)?Md.PREVIEW_TYPE.INSERTION_MARKER:Md.PREVIEW_TYPE.REPLACEMENT_FADE:Md.PREVIEW_TYPE.INSERTION_MARKER}render(t){const e=this.makeRenderInfo_(t);e.measure(),this.makeDrawer_(t,e).draw()}},Bd={};Bd.BottomRow=qu,Bd.Connection=Zu,Bd.ConstantProvider=Td,Bd.Drawer=Ed,Bd.ExternalValueInput=td,Bd.Field=ed,Bd.Hat=sd,Bd.Icon=id,Bd.InRowSpacer=od,Bd.InlineInput=nd,Bd.InputConnection=Qu,Bd.InputRow=ld,Bd.JaggedEdge=ad,Bd.MarkerSvg=kd,Bd.Measurable=ju,Bd.NextConnection=cd,Bd.OutputConnection=hd,Bd.PathObject=yd,Bd.PreviousConnection=ud,Bd.RenderInfo=Sd,Bd.Renderer=Pd,Bd.RoundCorner=dd,Bd.Row=Ju,Bd.SpacerRow=pd,Bd.SquareCorner=gd,Bd.StatementInput=rd,Bd.TopRow=_d,Bd.Types=zu,Bd.init=vn,Bd.register=yn,Bd.unregister=Nn;var Fd=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()}},Ud="VARIABLE_DYNAMIC",Hd={CATEGORY_NAME:Ud};Hd.flyoutCategory=Mn,Hd.flyoutCategoryBlocks=Dn,Hd.onCreateVariableButtonClick_Colour=wn,Hd.onCreateVariableButtonClick_Number=Ln,Hd.onCreateVariableButtonClick_String=An;var Gd=class{canConnect(t,e,s,i){return this.canConnectWithReason(t,e,s,i)===Nd.CAN_CONNECT}canConnectWithReason(t,e,s,i){const o=this.doSafetyChecks(t,e);return o!==Nd.CAN_CONNECT?o:this.doTypeChecks(t,e)?s&&!this.doDragChecks(t,e,i||0)?Nd.REASON_DRAG_CHECKS_FAILED:Nd.CAN_CONNECT:Nd.REASON_CHECKS_FAILED}getErrorMessage(t,e,s){switch(t){case Nd.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Nd.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Nd.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case Nd.REASON_TARGET_NULL:return"Target connection is null.";case Nd.REASON_CHECKS_FAILED:return"Connection checks failed. "+e+" expected "+e.getCheck()+", found "+s.getCheck();case Nd.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Nd.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Nd.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 Nd.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?Nd.REASON_SELF_CONNECTION:o.type!==Fh[t.type]?Nd.REASON_WRONG_TYPE:s.workspace!==i.workspace?Nd.REASON_DIFFERENT_WORKSPACES:s.isShadow()&&!i.isShadow()?Nd.REASON_SHADOW_PARENT:o.type===Hc.OUTPUT_VALUE&&i.previousConnection&&i.previousConnection.isConnected()||o.type===Hc.PREVIOUS_STATEMENT&&i.outputConnection&&i.outputConnection.isConnected()?Nd.REASON_PREVIOUS_AND_OUTPUT:Nd.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 Hc.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(t,e);case Hc.OUTPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isInsertionMarker()||t.isConnected())return!1;break;case Hc.INPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isMovable()&&!e.targetBlock().isShadow())return!1;break;case Hc.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===Kr.indexOf(e)}canConnectToPrevious_(t,e){return!(t.targetConnection||-1!==Kr.indexOf(e)||e.targetConnection&&(!(t=e.targetBlock()).isInsertionMarker()||t.getPreviousBlock()))}};t(Ur.CONNECTION_CHECKER,Fr,Gd);var Vd=class extends lc{constructor(t){super(t),this.type=el,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 Vd)).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(Ur.EVENT,el,Vd);var Wd=class extends lc{constructor(t,e){super(t),this.type=sl,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 Wd)).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(Ur.EVENT,sl,Wd);var Xd=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=Dr.getGroup$$module$build$src$core$events$utils();s||Dr.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(Ur.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(t=c(Ur.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=jd.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 qa(this);const t=this.zoomControls_.createDom();this.svgGroup_.appendChild(t)}addFlyout(t){const e=new pu({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(Ur.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(e):new(c(Ur.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(la.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();ua.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(B(dl))(e,s,t,this.id,this.oldScale);this.oldScale=t,this.oldTop=e,this.oldLeft=s,N(i)}}}translate(t,e){let s,i;null==(s=this.layerManager)||s.translateLayers(new ua(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=Dr.getGroup$$module$build$src$core$events$utils();let s;e||Dr.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{Dr.setGroup$$module$build$src$core$events$utils(e)}return s}pasteBlock_(t,e){let s;Dr.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(Dr.config$$module$build$src$core$config.snapRadius,new ua(i,o)).connection){t=!0;break}}t&&(i=this.RTL?i-Dr.config$$module$build$src$core$config.snapRadius:i+Dr.config$$module$build$src$core$config.snapRadius,o+=2*Dr.config$$module$build$src$core$config.snapRadius)}while(t);s.moveTo(new ua(i,o))}}finally{Dr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&N(new(B(Dr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}pasteWorkspaceComment_(t){let e;Dr.disable$$module$build$src$core$events$utils();try{e=Ec.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{Dr.enable$$module$build$src$core$events$utils()}return M()&&gc.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(la.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=ua.difference(e,t)}moveDrag(t){return(t=q(t,this.getParentSvg(),this.getInverseScreenCTM())).x/=this.scale,t.y/=this.scale,ua.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(lu.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 Oa(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),Dr.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}Dr.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(t){if(!this.options.readOnly&&!this.isFlyout){var e=gh.registry.getContextMenuOptions(gh.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)}},Jd={};Jd.WorkspaceSvg=jd,Jd.resizeSvgContents=xn;var qd=class extends Nl{constructor(t,e){super(e),this.type=cl,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 qd)).isOpen=t.isOpen,e}};t(Ur.EVENT,cl,qd);var Zd=class extends Pc{constructor(t){if(super(t),this.type=Dr.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=we(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=Be(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 Zd)).oldXml=Dr.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!=vd){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 Dr.ValueInput$$module$build$src$core$inputs$value_input(t,this))}appendStatementInput(t){return this.statementInputCount++,this.appendInput(new Od(t,this))}appendDummyInput(t=""){return this.appendInput(new $d(t,this))}appendEndRowInput(t=""){return this.appendInput(new Id(t,this))}appendInput(t){return this.inputList.push(t),t}appendInputFromRegistry(t,e){return(t=r(Ur.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&&(Dr.disable$$module$build$src$core$events$utils(),this.setInputsInline(t.inputsInline),Dr.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=No(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=No(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 Za?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(B(Dr.MOVE$$module$build$src$core$events$utils))(this);s&&i.setReason(s),this.xy_.translate(t,e),i.recordNew(),N(i)}makeConnection_(t){return new Nd(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}};Qd.COLLAPSED_INPUT_NAME=vd,Qd.COLLAPSED_FIELD_NAME=Ad;var tp=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()}},ep=class extends tp{constructor(){super(),this.type="cursor"}next(){var t=this.getCurNode();if(!t)return null;for(t=t.next();t&&t.next()&&(t.getType()===Cd.types.NEXT||t.getType()===Cd.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()!==Cd.types.PREVIOUS&&t.getType()!==Cd.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()===Cd.types.NEXT||t.getType()===Cd.types.BLOCK);)t=t.prev();return t&&this.setCurNode(t),t}out(){var t=this.getCurNode();return t?((t=t.out())&&t.getType()===Cd.types.BLOCK&&(t=t.prev()||t),t&&this.setCurNode(t),t):null}};t(Ur.CURSOR,Fr,ep);var sp=class extends ep{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())!==Cd.types.OUTPUT&&t!==Cd.types.INPUT&&t!==Cd.types.FIELD&&t!==Cd.types.NEXT&&t!==Cd.types.PREVIOUS&&t!==Cd.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)}};sp.registrationName="basicCursor",t(Ur.CURSOR,sp.registrationName,sp);var ip=class extends sp{validNode_(t){let e=!1;const s=t&&t.getType();return t&&(t=t.getLocation(),s===Cd.types.FIELD&&t&&t.isTabNavigable()&&t.isClickable()&&(e=!0)),e}},op=class extends Nd{constructor(t,e){super(t,e),this.highlighted=!1,this.targetConnection=null,this.db=t.workspace.connectionDBList[e],this.dbOpposite=t.workspace.connectionDBList[Fh[e]],this.offsetInBlock=new ua(0,0),this.trackedState=op.TrackedState.WILL_TRACK}dispose(){let t,e;super.dispose(),this.trackedState===op.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),null==(e=(t=this.sourceBlock_.pathObject).removeConnectionHighlight)||e.call(t,this)}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+Dr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.x,n=t.y+Dr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.y;s&&(n=-n),e.RTL&&(o=t.x-Dr.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===op.TrackedState.WILL_TRACK?(this.db.addConnection(this,e),this.trackedState=op.TrackedState.TRACKED,s=!0):this.trackedState===op.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=ua.difference(this.offsetInBlock,t.offsetInBlock),e.translate(t.x,t.y))}closest(t,e){return this.dbOpposite.searchForClosest(this,t,e)}highlight(){this.highlighted=!0,this.getSourceBlock().queueRender()}unhighlight(){this.highlighted=!1,this.getSourceBlock().queueRender()}isHighlighted(){return this.highlighted}setTracking(t){t&&this.trackedState===op.TrackedState.TRACKED||!t&&this.trackedState===op.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(t?(this.db.addConnection(this,this.y),this.trackedState=op.TrackedState.TRACKED):(this.trackedState===op.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=op.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||(Dr.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),Dr.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:Wc.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(Gu.TYPE),t){let i=this.getSurroundParent(),o=null;for(;i;)i.isCollapsed()&&(o=i),i=i.getSurroundParent();o&&o.setWarningText(Dr.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,lp.COLLAPSED_WARNING_ID),s?s.addMessage(t,e):this.addIcon(new Gu(this).addMessage(t,e))}else s&&(e?(s.addMessage("",e),s.getText()||this.removeIcon(Gu.TYPE)):this.removeIcon(Gu.TYPE))}setMutator(t){this.removeIcon(Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),t&&this.addIcon(t)}addIcon(t){return super.addIcon(t),t instanceof Gu&&(this.warning=t),t instanceof Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=t),this.rendered&&(t.initView(this.createIconPointerDownListener(t)),t.applyColour(),t.updateEditable(),this.queueRender(),Se(),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(Gu.TYPE)&&(this.warning=null),t.equals(Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.rendered&&(this.queueRender(),Se(),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=Dr.getGroup$$module$build$src$core$events$utils();Dr.setGroup$$module$build$src$core$events$utils(t),this.getRootBlock().bumpNeighboursInternal(),Dr.setGroup$$module$build$src$core$events$utils(e),this.bumpNeighboursPid=0}),Dr.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(Dr.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=Dr.getGroup$$module$build$src$core$events$utils();setTimeout((()=>{Dr.setGroup$$module$build$src$core$events$utils(t),this.snapToGrid(),Dr.setGroup$$module$build$src$core$events$utils(!1)}),Dr.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(t,e,s){if(t.type===Hc.NEXT_STATEMENT||t.type===Hc.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(),Se()}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(cu.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)}};lp.INLINE=-1,lp.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var ap,cp=class{constructor(){}onDragEnter(t){}onDragOver(t){}onDragExit(t){}onDrop(t){}getClientRect(){return null}shouldPreventMove(t){return!1}},hp=class extends cp{constructor(){super(),this.wouldDelete_=!1}wouldDelete(t,e){return t instanceof lp?(t=!t.getParent()&&t.isDeletable(),this.updateWouldDelete_(t&&!e)):this.updateWouldDelete_(t.isDeletable()),this.wouldDelete_}updateWouldDelete_(t){this.wouldDelete_=t}},up=class extends hp{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 pu({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===Fa.TOP?Fa.BOTTOM:Fa.TOP,this.flyout=new(c(Ur.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(t)):(t.toolboxPosition=this.workspace.toolboxPosition===Fa.RIGHT?Fa.LEFT:Fa.RIGHT,this.flyout=new(c(Ur.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(t)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){let t;this.svgGroup=it(Ia.G,{class:"blocklyTrash"});const e=String(Math.random()).substring(2);t=it(Ia.CLIPPATH,{id:"blocklyTrashBodyClipPath"+e},this.svgGroup),it(Ia.RECT,{width:dp,height:pp,y:gp},t);const s=it(Ia.IMAGE,{width:za,x:-Ep,height:ja,y:-fp,"clip-path":"url(#blocklyTrashBodyClipPath"+e+")"},this.svgGroup);return s.setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),t=it(Ia.CLIPPATH,{id:"blocklyTrashLidClipPath"+e},this.svgGroup),it(Ia.RECT,{width:dp,height:gp},t),this.svgLid=it(Ia.IMAGE,{width:za,x:-Ep,height:ja,y:-fp,"clip-path":"url(#blocklyTrashLidClipPath"+e+")"},this.svgGroup),this.svgLid.setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),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 Sa(dp,pp+gp),Tp,_p,t,this.workspace),e=zt(t,_p,i.vertical===Ga.TOP?Wa.DOWN:Wa.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 Oa(this.top,this.top+pp+gp,this.left,this.left+dp)}getClientRect(){if(!this.svgGroup)return null;var t=this.svgGroup.getBoundingClientRect();const e=t.top+fp-mp;return t=t.left+Ep-mp,new Oa(e,e+gp+pp+2*mp,t,t+dp+2*mp)}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=Ip;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*Cp),e=Op+this.lidOpen*(Sp-Op),this.svgGroup&&(this.svgGroup.style.opacity=`${e}`),this.lidOpen>this.minOpenness&&1>this.lidOpen&&(this.lidTask=setTimeout(this.animateLid.bind(this),$p/t))}setLidAngle(t){const e=this.workspace.toolboxPosition===Fa.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let s;null==(s=this.svgLid)||s.setAttribute("transform","rotate("+(e?-t:t)+","+(e?4:dp-4)+","+(gp-2)+")")}setMinOpenness(t){this.minOpenness=t,this.isLidOpen||this.setLidAngle(t*Cp)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(t){t=new(B(cl))(t,this.workspace.id),N(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!==Dr.DELETE$$module$build$src$core$events$utils||t.type!==Dr.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(bp)}}}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)}},dp=47,pp=44,gp=16,_p=20,Tp=20,mp=10,Ep=0,fp=32,bp=.1,$p=80,Ip=4,Op=.4,Sp=.8,Cp=45,Rp=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)&&0Yn(t)))).length?t:null}load(t,e){const s=e.getProcedureMap();for(const i of t)s.add(zn(this.procedureModelClass,this.parameterModelClass,i,e))}clear(t){t.getProcedureMap().clear()}}};vp.loadParameter=jn,vp.loadProcedure=zn,vp.saveParameter=Kn,vp.saveProcedure=Yn;var Ap=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 Ap);var Lp={};Lp.VariableSerializer=Ap;var wp={};wp.load=qn,wp.save=Jn;var Mp={blocks:xc,exceptions:Lc,priorities:wc,procedures:vp,registry:Mc,variables:Lp,workspaces:wp},Dp=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 va(t,!0,n,i,o)),s&&(this.vScroll=new va(t,!1,n,i,o)),n&&(this.corner_=it(Ia.RECT,{height:va.scrollbarThickness,width:va.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{Dr.disable$$module$build$src$core$events$utils(),this.hScroll&&e&&this.hScroll.resize(t),this.vScroll&&s&&this.vScroll.resize(t)}finally{Dr.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)}},xp=class{constructor(t){this.workspace_=t}getDimensionsPx_(t){let e=0,s=0;return t&&(e=t.getWidth(),s=t.getHeight()),new Sa(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)===Fa.TOP;return n===Fa.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)===Fa.LEFT||n===Fa.RIGHT;return n!==Fa.TOP&&n!==Fa.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(Ur.METRICS_MANAGER,Fr,xp);var Pp=class extends yl{constructor(t){super(),this.isBlank=!0,this.recordUndo=!1,this.type=ml,this.isBlank=!!t,t&&(this.workspaceId=t.id)}};t(Ur.EVENT,ml,Pp);var Bp=class extends Nl{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=ol,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 Bp)).isStart=t.isStart,e.blockId=t.blockId,e.blocks=t.blocks,e}};t(Ur.EVENT,ol,Bp);var Fp={};Fp.bumpIntoBounds=Zn,Fp.bumpIntoBoundsHandler=Qn,Fp.bumpTopObjectsIntoBounds=er;var Up=class{constructor(t,e){this.connectionCandidate=this.dragTarget_=null,this.wouldDeleteBlock_=!1,this.dragIconData_=[],this.draggingBlock_=t,this.workspace_=e,this.connectionPreviewer=new(c(Ur.CONNECTION_PREVIEWER,this.workspace_.options))(t),this.startXY_=this.draggingBlock_.getRelativeToSurfaceXY(),this.dragIconData_=sr(t,this.startXY_)}dispose(){this.dragIconData_.length=0,this.connectionPreviewer.dispose()}startDrag(t,e){let s;Dr.getGroup$$module$build$src$core$events$utils()||Dr.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=ua.sum(this.startXY_,t),this.draggingBlock_.translate(t.x,t.y),Pi(this.draggingBlock_)}fireDragStartEvent_(){const t=new(B(ol))(this.draggingBlock_,!0,this.draggingBlock_.getDescendants(!1));N(t)}drag(t,e){const s=this.draggingBlock_;this.moveBlock(s,e),this.updateDragTargets(t,s),this.wouldDeleteBlock_=this.wouldDeleteBlock(t,s,e),this.updateCursorDuringBlockDrag_(),this.updateConnectionPreview(s,e)}moveBlock(t,e){e=this.pixelsToWorkspaceUnits_(e),e=ua.sum(this.startXY_,e),t.moveDuringDrag(e)}updateDragTargets(t,e){if(t=this.workspace_.getDragTarget(t),this.dragTarget_!==t){let s;null==(s=this.dragTarget_)||s.onDragExit(e),null==t||t.onDragEnter(e)}null==t||t.onDragOver(e),this.dragTarget_=t}wouldDeleteBlock(t,e,s){return!(!(t=this.workspace_.getDragTarget(t))||!this.workspace_.getComponentManager().hasCapability(t.id,la.Capability.DELETE_AREA))&&t.wouldDelete(e,!!this.getConnectionCandidate(e,s))}updateConnectionPreview(t,e){e=this.pixelsToWorkspaceUnits_(e);const s=this.connectionCandidate,i=this.getConnectionCandidate(t,e);if(i){this.connectionCandidate=e=s&&this.currCandidateIsBetter(s,e,i)?s:i;var{local:o,neighbour:n}=e;o.type!==Hc.OUTPUT_VALUE&&o.type!==Hc.PREVIOUS_STATEMENT||!n.isConnected()||n.targetBlock().isInsertionMarker()||this.orphanCanConnectAtEnd(t,n.targetBlock(),o.type)?this.connectionPreviewer.previewConnection(o,n):this.connectionPreviewer.previewReplacement(o,n,n.targetBlock())}else this.connectionPreviewer.hidePreview(),this.connectionCandidate=null}orphanCanConnectAtEnd(t,e,s){return!!Nd.getConnectionForOrphanedConnection(t,s===Hc.OUTPUT_VALUE?e.outputConnection:e.previousConnection)}currCandidateIsBetter(t,e,s){const{local:i,neighbour:o}=t;t=new ua(i.x,i.y);const n=new ua(o.x,o.y);return e=ua.distance(ua.sum(t,e),n),s.distance>e-Dr.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(t,e){t=this.getLocalConnections(t);let s=this.connectionCandidate?Dr.config$$module$build$src$core$config.connectingSnapRadius:Dr.config$$module$build$src$core$config.snapRadius,i=null;for(const o of t){const{connection:t,radius:n}=o.closest(s,e);t&&(i={local:o,neighbour:t,distance:n},s=n)}return i}getLocalConnections(t){const e=t.getConnections_(!1),s=t.lastConnectionInStack(!0);return s&&s!==t.nextConnection&&e.push(s),e}endDrag(t,e){if(this.drag(t,e),this.fireDragEndEvent_(),pt(),Fi(),this.connectionPreviewer.hidePreview(),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_():Zn(this.draggingBlock_.workspace,this.workspace_.getMetricsManager().getScrollMetrics(!0),this.draggingBlock_)}this.connectionPreviewer.dispose(),this.workspace_.setResizesEnabled(!0),Dr.setGroup$$module$build$src$core$events$utils(!1)}getNewLocationAfterDrag_(t){return{delta:t=this.pixelsToWorkspaceUnits_(t),newLocation:ua.sum(this.startXY_,t)}}maybeDeleteBlock_(){return!!this.wouldDeleteBlock_&&(this.fireMoveEvent_(),this.draggingBlock_.dispose(!1,!0),Kr.length=0,!0)}updateBlockAfterMove_(){this.fireMoveEvent_(),this.connectionCandidate?this.applyConnections(this.connectionCandidate):this.draggingBlock_.queueRender(),this.draggingBlock_.scheduleSnapAndBump()}applyConnections(t){const{local:e,neighbour:s}=t;if(e.connect(s),this.draggingBlock_.rendered){const t=e.isSuperior()?s:e,i=this.draggingBlock_.getRootBlock();Oe().then((()=>{xi(t.getSourceBlock()),setTimeout((()=>{i.bringToFront()}),0)}))}}fireDragEndEvent_(){const t=new(B(ol))(this.draggingBlock_,!1,this.draggingBlock_.getDescendants(!1));N(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(B(Dr.MOVE$$module$build$src$core$events$utils))(this.draggingBlock_);t.setReason(["drag"]),t.oldCoordinate=this.startXY_,t.recordNew(),N(t)}}updateCursorDuringBlockDrag_(){this.draggingBlock_.setDeleteStyle(this.wouldDeleteBlock_)}pixelsToWorkspaceUnits_(t){return t=new ua(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.workspace_.getAllBlocks().filter((t=>t.isInsertionMarker()))}};t(Ur.BLOCK_DRAGGER,Fr,Up);var Hp={};Hp.Bubble=vu,Hp.MiniWorkspaceBubble=Au,Hp.TextBubble=Fu,Hp.TextInputBubble=Uu;var Gp=class extends Pc{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 Gp)).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(Ur.EVENT,Qr,Gp);var Vp=class extends Pc{constructor(t){super(t),this.type=Dr.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 Vp)).oldParentId=t.oldParentId,e.oldInputName=t.oldInputName,t.oldCoordinate&&(s=t.oldCoordinate.split(","),e.oldCoordinate=new ua(Number(s[0]),Number(s[1]))),e.newParentId=t.newParentId,e.newInputName=t.newInputName,t.newCoordinate&&(s=t.newCoordinate.split(","),e.newCoordinate=new ua(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&&ua.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===Hc.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(Ur.EVENT,Dr.MOVE$$module$build$src$core$events$utils,Vp);var Wp,Xp=class extends Nl{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=al,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 Xp)).isOpen=t.isOpen,e.bubbleType=t.bubbleType,e.blockId=t.blockId,e}};(function(t){t.MUTATOR="mutator",t.COMMENT="comment",t.WARNING="warning"})(Wp||(Wp={})),t(Ur.EVENT,al,Xp);var Yp={};Yp.BubbleOpen=Xp,Yp.BubbleType=Wp;var Kp=class extends yl{constructor(t){super(),this.isBlank=!t,t&&(this.commentId=t.id,this.workspaceId=t.workspace.id,this.group=Dr.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 Kp)).commentId=t.commentId,e}static CommentCreateDeleteHelper(t,e){var s=t.getEventWorkspace_();if(e){if(e=Dr.createElement$$module$build$src$core$utils$xml("xml"),!t.xml)throw Error("Ecountered a comment event without proper xml");e.appendChild(t.xml),Dr.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)}}},zp=class extends Kp{constructor(t,e,s){super(t),this.type=_l,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 zp)).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(Ur.EVENT,_l,zp);var jp=class extends Kp{constructor(t){super(t),this.type=pl,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=Be(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new jp)).xml=Dr.textToDom$$module$build$src$core$utils$xml(t.xml),e}run(t){Kp.CommentCreateDeleteHelper(this,t)}};t(Ur.EVENT,pl,jp);var Jp=class extends Kp{constructor(t){super(t),this.type=gl,t&&(this.xml=t.toXmlWithXY())}run(t){Kp.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=Be(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Jp)).xml=Dr.textToDom$$module$build$src$core$utils$xml(t.xml),e}};t(Ur.EVENT,gl,Jp);var qp=class extends Kp{constructor(t){super(t),this.type=Tl,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 qp),s=t.oldCoordinate.split(","),e.oldCoordinate_=new ua(Number(s[0]),Number(s[1])),s=t.newCoordinate.split(","),e.newCoordinate_=new ua(Number(s[0]),Number(s[1])),e}isNull(){return ua.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(Ur.EVENT,Tl,qp);var Zp=class extends Nl{constructor(t,e,s){super(s),this.type=hl,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 Zp)).oldItem=t.oldItem,e.newItem=t.newItem,e}};t(Ur.EVENT,hl,Zp),Dr.CHANGE$$module$build$src$core$events$utils,Dr.CREATE$$module$build$src$core$events$utils,Dr.DELETE$$module$build$src$core$events$utils,Dr.MOVE$$module$build$src$core$events$utils,Dr.CHANGE$$module$build$src$core$events$utils,Dr.CREATE$$module$build$src$core$events$utils,Dr.DELETE$$module$build$src$core$events$utils,Dr.MOVE$$module$build$src$core$events$utils,Dr.disable$$module$build$src$core$events$utils,Dr.enable$$module$build$src$core$events$utils,Dr.getGroup$$module$build$src$core$events$utils,Dr.setGroup$$module$build$src$core$events$utils;var Qp={};Qp.Abstract=yl,Qp.BLOCK_CHANGE=Dr.CHANGE$$module$build$src$core$events$utils,Qp.BLOCK_CREATE=Dr.CREATE$$module$build$src$core$events$utils,Qp.BLOCK_DELETE=Dr.DELETE$$module$build$src$core$events$utils,Qp.BLOCK_DRAG=ol,Qp.BLOCK_FIELD_INTERMEDIATE_CHANGE=Qr,Qp.BLOCK_MOVE=Dr.MOVE$$module$build$src$core$events$utils,Qp.BUBBLE_OPEN=al,Qp.BUMP_EVENTS=El,Qp.BlockBase=Pc,Qp.BlockChange=gu,Qp.BlockCreate=Bc,Qp.BlockDelete=Zd,Qp.BlockDrag=Bp,Qp.BlockFieldIntermediateChange=Gp,Qp.BlockMove=Vp,Qp.BubbleOpen=Xp,Qp.BubbleType=Wp,Qp.CHANGE=Dr.CHANGE$$module$build$src$core$events$utils,Qp.CLICK=rl,Qp.COMMENT_CHANGE=_l,Qp.COMMENT_CREATE=pl,Qp.COMMENT_DELETE=gl,Qp.COMMENT_MOVE=Tl,Qp.CREATE=Dr.CREATE$$module$build$src$core$events$utils,Qp.Click=vl,Qp.ClickTarget=Rl,Qp.CommentBase=Kp,Qp.CommentChange=zp,Qp.CommentCreate=jp,Qp.CommentDelete=Jp,Qp.CommentMove=qp,Qp.DELETE=Dr.DELETE$$module$build$src$core$events$utils,Qp.FINISHED_LOADING=ml,Qp.FinishedLoading=Pp,Qp.MARKER_MOVE=ll,Qp.MOVE=Dr.MOVE$$module$build$src$core$events$utils,Qp.MarkerMove=Rd,Qp.SELECTED=nl,Qp.Selected=_c,Qp.THEME_CHANGE=ul,Qp.TOOLBOX_ITEM_SELECT=hl,Qp.TRASHCAN_OPEN=cl,Qp.ThemeChange=Uc,Qp.ToolboxItemSelect=Zp,Qp.TrashcanOpen=qd,Qp.UI=il,Qp.UiBase=Nl,Qp.VAR_CREATE=tl,Qp.VAR_DELETE=el,Qp.VAR_RENAME=sl,Qp.VIEWPORT_CHANGE=dl,Qp.VarBase=lc,Qp.VarCreate=ac,Qp.VarDelete=Vd,Qp.VarRename=Wd,Qp.ViewportChange=Gc,Qp.clearPendingUndo=w,Qp.disable=Dr.disable$$module$build$src$core$events$utils,Qp.disableOrphans=F,Qp.enable=Dr.enable$$module$build$src$core$events$utils,Qp.filter=L,Qp.fire=N,Qp.fromJson=P,Qp.get=B,Qp.getDescendantIds=x,Qp.getGroup=Dr.getGroup$$module$build$src$core$events$utils,Qp.getRecordUndo=y,Qp.isEnabled=M,Qp.setGroup=Dr.setGroup$$module$build$src$core$events$utils,Qp.setRecordUndo=k;var tg=class extends Td{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,n=i===e?"0":"1";return an("a","0 0,"+n,t=(t>s?s:t)/2,tn((i?1:-1)*t,(e?-1:1)*t))+ln("v",(e?-1:1)*o)+an("a","0 0,"+n,t,tn((i?-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){t-=2*e;const o=i===s?"0":"1";return an("a","0 0,"+o,e,tn((i?1:-1)*e,(s?-1:1)*e))+ln("v",(s?-1:1)*t)+an("a","0 0,"+o,e,tn((i?-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 Hc.INPUT_VALUE:case Hc.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 Hc.PREVIOUS_STATEMENT:case Hc.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(Ia.DEFS,{},t),e=it(Ia.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(Ia.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},e),s=it(Ia.FECOMPONENTTRANSFER,{result:"outBlur"},e),it(Ia.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},s),it(Ia.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),it(Ia.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.selectedGlowFilterId=e.id,this.selectedGlowFilter=e,t=it(Ia.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(Ia.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},t),e=it(Ia.FECOMPONENTTRANSFER,{result:"outBlur"},t),it(Ia.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},e),it(Ia.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),it(Ia.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),it(Ia.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;","}"]}},eg=class extends Ed{constructor(t,e){super(t,e)}draw(){const t=this.block_.pathObject;t.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),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(zu.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 Sa(e,s+sg.Y_PADDING),this.imageHeight=s,"function"==typeof o&&(this.clickHandler=o),t!==bu.SKIP_SETUP&&(r?this.configure_(r):(this.flipRtl=!!n,this.altText=No(i)||""),this.setValue(No(t)))}configure_(t){super.configure_(t),t.flipRtl&&(this.flipRtl=t.flipRtl),t.alt&&(this.altText=No(t.alt))}initView(){this.imageElement=it(Ia.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(ma,"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(ma,"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)}};sg.Y_PADDING=1,Mo("field_image",sg),sg.prototype.DEFAULT_VALUE="";var ig=class extends bu{constructor(t,e,s){super(bu.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!==bu.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 $u;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const t=this.getSourceBlock();if(!t)throw new $u;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()&&N(new(B(Dr.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 $u;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"),Ps(t,qc.INVALID,!1)):(ot(t,"blocklyInvalidInput"),Ps(t,qc.INVALID,!0))}if(!(t=this.getSourceBlock()))throw new $u;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&&(ta||Jl||ql)?this.showPromptEditor_():this.showInlineEditor_(e)}showPromptEditor_(){te(Dr.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 $u;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 $u;Dr.setGroup$$module$build$src$core$events$utils(!0);const e=Bs();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=ig.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_&&(N(new(B(Dr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),Dr.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var t=Bs().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(),Ai()):"Escape"===t.key?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),Gs(),Ai()):"Tab"===t.key&&(Gs(),Ai(),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&&N(new(B(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 $u;const e=Bs(),s=this.getScaledBBox();e.style.width=s.right-s.left+"px",e.style.height=s.bottom-s.top+"px",t=new ua(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 lp&&(Zn(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}};ig.BORDERRADIUS=4;var og=class extends ig{constructor(t,e,s){super(t,e,s)}doClassValidation_(t){return void 0===t?null:`${t}`}static fromJson(t){return new this(No(t.text),void 0,t)}};Mo("field_input",og),og.prototype.DEFAULT_VALUE="";var ng=class extends qu{constructor(t){super(t)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(t){return!!t.outputConnection}hasRightSquareCorner(t){return!!t.outputConnection&&!t.statementInputCount&&!t.nextConnection}},rg=class extends rd{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)}}},lg=class extends ju{constructor(t){super(t),this.width=this.height=0,this.type|=zu.getType("RIGHT_CONNECTION")}},ag=class extends _d{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}},cg=class extends Sd{constructor(t,e){super(t,e),this.isInline=!0,this.renderer_=t,this.constants_=this.renderer_.getConstants(),this.topRow=new ag(this.constants_),this.bottomRow=new ng(this.constants_),this.isMultiRow=!e.getInputsInline()||e.isCollapsed(),this.hasStatementInput=0=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!i.precedesStatement,zu.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)&&zu.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(zu.isInlineInput(t)&&t instanceof Qu){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 zu.isField(t)&&t instanceof ed?s===i.SHAPES.ROUND&&t.field instanceof og?e-2.75*i.GRID_UNIT:e-this.constants_.SHAPE_IN_SHAPE_PADDING[s][0]:zu.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 ed&&(s.field instanceof fd||s.field instanceof sg),!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(Ia.LINE,{x1:Tg.HALF+Tg.RADIUS,y1:Tg.HALF,x2:Tg.HALF+Tg.RADIUS-(0==e%45?10:5),y2:Tg.HALF,class:"blocklyAngleMarks",transform:"rotate("+e+","+Tg.HALF+","+Tg.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(){Ni(this),Gs()}onMouseMove_(t){var e=this.gauge.ownerSVGElement.getBoundingClientRect();const s=t.clientX-e.left-Tg.HALF;t=t.clientY-e.top-Tg.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)}};Tg.HALF=50,Tg.RADIUS=Tg.HALF-1,Tg.CLOCKWISE=!1,Tg.OFFSET=0,Tg.WRAP=360,Tg.ROUND=15,Mo("field_angle",Tg),Tg.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"}(_g||(_g={}));var mg={};mg.FieldAngle=Tg,mg.Mode=_g;var Eg=class extends bu{constructor(t,e,s){super(bu.SKIP_SETUP),this.SERIALIZABLE=!0,this.CURSOR="default",this.value_=this.value_,this.checkChar=Eg.CHECK_CHAR,t!==bu.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(Eg);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||Eg.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)}};Eg.CHECK_CHAR="✓",Mo("field_checkbox",Eg),Eg.prototype.DEFAULT_VALUE=!1;var fg=class extends bu{constructor(t,e,s){super(bu.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!==bu.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 Sa(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 $u;const e=this.getConstants();return t.isSimpleReporter()&&!(null==e||!e.FIELD_COLOUR_FULL_BLOCK)}applyColour(){const t=this.getSourceBlock();if(!t)throw new $u;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 $u;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),fi(this,this.dropdownDispose.bind(this)),this.picker.focus({preventScroll:!0})}onClick(t){null!==(t=(t=t.target)&&t.getAttribute("data-colour"))&&(this.setValue(t),Ni(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),Ai();break;default:e=!1}e&&t.stopPropagation()}moveHighlightBy(t,e){if(this.highlightedIndex){var s=this.colours||fg.COLOURS,i=this.columns||fg.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||fg.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&&Ps(this.picker,qc.ACTIVEDESCENDANT,t)}dropdownCreate(){const t=this.columns||fg.COLUMNS,e=this.colours||fg.COLOURS,s=this.titles||fg.TITLES,i=this.getValue(),o=document.createElement("table");let n;o.className="blocklyColourTable",o.tabIndex=0,o.dir="ltr",xs(o,Jc.GRID),Ps(o,qc.EXPANDED,!0),Ps(o,qc.ROWCOUNT,Math.floor(e.length/t)),Ps(o,qc.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 bg=class extends fd{constructor(t,e,s){super(String(null!=t?t:""),e,s),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(t){return new this(No(t.text),void 0,t)}};Mo("field_label_serializable",bg);var $g=class extends og{constructor(t,e,s){super(bu.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,t!==bu.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($g);return null!==t?t:this.getValue()}loadState(t){this.loadLegacyState(bu,t)||this.setValue(t)}initView(){this.createBorderRect_(),this.textGroup=it(Ia.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const t=this.getSourceBlock();if(!t)throw new $u;let e=this.getText();if(!e)return bu.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,bu.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 $u;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=Bs(),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=og.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",""),jl?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(s),s}setMaxLines(t){"number"==typeof t&&0this.max_&&(t.max=`${this.max_}`,Ps(t,qc.VALUEMAX,this.max_)),t}static fromJson(t){return new this(t.value,void 0,void 0,void 0,void 0,t)}};Mo("field_number",Ig),Ig.prototype.DEFAULT_VALUE=0;var Og=class extends ku{constructor(t,e,s,i,o){super(bu.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=Og.dropdownCreate,this.defaultVariableName="string"==typeof t?t:"",this.size_=new Sa(0,0),t!==bu.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 $u;this.variable||(t=Dr.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 $u;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 $u;const s=t.getAttribute("id"),i=t.textContent,o=t.getAttribute("variabletype")||t.getAttribute("variableType")||"";if(e=Dr.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: "+Be(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(Og);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 $u;this.loadLegacyState(Og,t)||(t=Dr.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 $u;return(e=Dr.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 $u;this.variable=Dr.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{this.targetWorkspace.isDragging()||e.addSelect()}))),this.listeners.push(K(t,"pointerleave",e,(()=>{this.targetWorkspace.isDragging()||e.removeSelect()}))),this.listeners.push(K(s,"pointerenter",e,(()=>{this.targetWorkspace.isDragging()||e.addSelect()}))),this.listeners.push(K(s,"pointerleave",e,(()=>{this.targetWorkspace.isDragging()||e.removeSelect()})))}blockMouseDown(t){return e=>{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;Dr.disable$$module$build$src$core$events$utils();var s=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{e=this.placeNewBlock(t)}finally{Dr.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),t=fe(this.targetWorkspace,s),M()){for(Dr.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_===Fa.TOP?new Oa(-1e9,e+t.height,-1e9,1e9):new Oa(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+=va.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_!==Fa.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+t),this.height_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};t(Ur.FLYOUTS_HORIZONTAL_TOOLBOX,Fr,yg);var Ng=class extends kg{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_===Fa.LEFT?t.width:s.width-this.width_:this.toolboxPosition_===Fa.LEFT?0:s.width:this.toolboxPosition_===Fa.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_===Fa.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(),Ai()}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_===Fa.LEFT?new Oa(-1e9,1e9,-1e9,e+t.width):new Oa(-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+=va.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_!==Fa.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+t,this.targetWorkspace.scrollY),this.width_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};Ng.registryName="verticalFlyout",t(Ur.FLYOUTS_VERTICAL_TOOLBOX,Fr,Ng),Dr.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{null==i||i.positionNearConnection(o,n,r),null==i||i.getSvgRoot().setAttribute("visibility","visible")})),this.workspace.getRenderer().shouldHighlightConnection(e)&&e.highlight(),this.markerConn=o,this.draggedConn=t,this.staticConn=e}finally{Dr.enable$$module$build$src$core$events$utils()}}}createInsertionMarker(t){const e=this.workspace.newBlock(t.type);if(e.setInsertionMarker(!0),t.saveExtraState){var s=t.saveExtraState(!0);s&&e.loadExtraState&&e.loadExtraState(s)}else t.mutationToDom&&(s=t.mutationToDom())&&e.domToMutation&&e.domToMutation(s);for(s=0;s.blocklyPathLight,`,`${t} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},Dg=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++)zu.isLeftSquareCorner(e)?this.steps_+=this.highlightConstants_.START_POINT:zu.isLeftRoundedCorner(e)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):zu.isPreviousConnection(e)?this.steps_+=this.notchPaths_.pathLeft:zu.isHat(e)?this.steps_+=this.startPaths_.path(this.RTL_):zu.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 pd&&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];zu.isLeftSquareCorner(e)?this.steps_+=sn(t.xPos+this.highlightOffset,t.baseline-this.highlightOffset):zu.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,zu.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_)}},xg=class extends Ed{constructor(t,e){super(t,e),this.highlighter_=new Dg(e)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();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)}}},Pg=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}}},Bg=class extends nd{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)}},Fg=class extends rd{constructor(t,e){super(t,e),this.constants_=t,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Ug=class extends Sd{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 Od||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(t,e){this.isInline&&t instanceof Dr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new Bg(this.constants_,t)),e.hasInlineInput=!0):t instanceof Od?(e.elements.push(new Fg(this.constants_,t)),e.hasStatement=!0):t instanceof Dr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new td(this.constants_,t)),e.hasExternalInput=!0):(t instanceof $d||t instanceof Id)&&(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 od(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(Ur.TOOLBOX_ITEM,e_.registrationName,e_);var s_=class extends t_{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_)}};s_.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(Ur.TOOLBOX_ITEM,s_.registrationName,s_);var i_=class extends e_{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(Ur.TOOLBOX,Fr,o_);var n_=Dr.Align$$module$build$src$core$inputs$align.LEFT,r_=Dr.Align$$module$build$src$core$inputs$align.CENTRE,l_=Dr.Align$$module$build$src$core$inputs$align.RIGHT,a_=Hc.INPUT_VALUE,c_=Hc.OUTPUT_VALUE,h_=Hc.NEXT_STATEMENT,u_=Hc.PREVIOUS_STATEMENT,d_=Dr.inputTypes$$module$build$src$core$inputs$input_types.DUMMY,p_=Fa.TOP,g_=Fa.BOTTOM,__=Fa.LEFT,T_=Fa.RIGHT;Yd.prototype.newBlock=function(t,e){return new Qd(this,t,e)},jd.prototype.newBlock=function(t,e){return new lp(this,t,e)},jd.newTrashcan=function(t){return new up(t)},Ec.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)}},Au.prototype.newWorkspaceSvg=function(t){return new jd(t)},Dr.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 f={blocks:d},b={},$={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 P={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",P,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 B={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(B)}));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,A,k,b,l,s),colour:J,lists:z,loops:D,math:v,procedures:R,texts:f,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 f={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",GTE:">="}[t.getFieldValue("OP")];return[(s.valueToCode(t,"A",e.RELATIONAL)||"0")+" "+i+" "+(t=s.valueToCode(t,"B",e.RELATIONAL)||"0"),e.RELATIONAL]},m.logic_negate=function(t,s){return["not "+(s.valueToCode(t,"BOOL",e.UNARY)||"true"),e.UNARY]},m.logic_null=function(t,s){return["nil",e.ATOMIC]},m.logic_operation=function(t,s){const i="AND"===t.getFieldValue("OP")?"and":"or",o="and"===i?e.AND:e.OR;let n=s.valueToCode(t,"A",o);return t=s.valueToCode(t,"B",o),n||t?(s="and"===i?"true":"false",n||(n=s),t||(t=s)):t=n="false",[n+" "+i+" "+t,o]},m.logic_ternary=function(t,s){return[(s.valueToCode(t,"IF",e.AND)||"false")+" and "+(s.valueToCode(t,"THEN",e.AND)||"nil")+" or "+(t=s.valueToCode(t,"ELSE",e.OR)||"nil"),e.OR]};var E="goto continue\n",f={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+E}throw Error("Unknown flow statement.")},controls_for:function(t,s){const o=s.getVariableName(t.getFieldValue("VAR")),r=s.valueToCode(t,"FROM",e.NONE)||"0",l=s.valueToCode(t,"TO",e.NONE)||"0",a=s.valueToCode(t,"BY",e.NONE)||"1";let c,h=s.statementToCode(t,"DO");return h=s.addLoopTrap(h,t),h=n(h,s.INDENT),t="",i.isNumber$$module$build$src$core$utils$string(r)&&i.isNumber$$module$build$src$core$utils$string(l)&&i.isNumber$$module$build$src$core$utils$string(a)?c=(Number(r)<=Number(l)?"":"-")+Math.abs(Number(a)):(t="",c=s.nameDB_.getDistinctName(o+"_inc",i.NameType$$module$build$src$core$names.VARIABLE),t+=c+" = ",t=(t=i.isNumber$$module$build$src$core$utils$string(a)?t+(Math.abs(a)+"\n"):t+"math.abs("+a+")\n")+"if ("+r+") > ("+l+") then\n"+(s.INDENT+c)+" = -"+c+"\n",t+="end\n"),t+"for "+o+" = "+r+", "+l+", "+c+" do\n"+h+"end\n"},controls_forEach:function(t,s){const i=s.getVariableName(t.getFieldValue("VAR")),o=s.valueToCode(t,"LIST",e.NONE)||"{}";let r=s.statementToCode(t,"DO");return r=s.addLoopTrap(r,t),r=n(r,s.INDENT),"for _, "+i+" in ipairs("+o+") do \n"+r+"end\n"}};f.controls_repeat=r,f.controls_repeat_ext=r,f.controls_whileUntil=function(t,s){const i="UNTIL"===t.getFieldValue("MODE");let o=s.valueToCode(t,"BOOL",i?e.UNARY:e.NONE)||"false",r=s.statementToCode(t,"DO");return r=s.addLoopTrap(r,t),r=n(r,s.INDENT),i&&(o="not "+o),"while "+o+" do\n"+r+"end\n"};var b={math_arithmetic:function(t,s){var i={ADD:[" + ",e.ADDITIVE],MINUS:[" - ",e.ADDITIVE],MULTIPLY:[" * ",e.MULTIPLICATIVE],DIVIDE:[" / ",e.MULTIPLICATIVE],POWER:[" ^ ",e.EXPONENTIATION]}[t.getFieldValue("OP")];const o=i[0];return i=i[1],[(s.valueToCode(t,"A",i)||"0")+o+(t=s.valueToCode(t,"B",i)||"0"),i]},math_atan2:function(t,s){const i=s.valueToCode(t,"X",e.NONE)||"0";return["math.deg(math.atan2("+(s.valueToCode(t,"Y",e.NONE)||"0")+", "+i+"))",e.HIGH]},math_change:function(t,s){const i=s.valueToCode(t,"DELTA",e.ADDITIVE)||"0";return(t=s.getVariableName(t.getFieldValue("VAR")))+" = "+t+" + "+i+"\n"},math_constant:function(t,s){return{PI:["math.pi",e.HIGH],E:["math.exp(1)",e.HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",e.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",e.HIGH],SQRT1_2:["math.sqrt(1 / 2)",e.HIGH],INFINITY:["math.huge",e.HIGH]}[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)||"-math.huge")+"), "+(t=s.valueToCode(t,"HIGH",e.NONE)||"math.huge")+")",e.HIGH]},math_modulo:function(t,s){return[(s.valueToCode(t,"DIVIDEND",e.MULTIPLICATIVE)||"0")+" % "+(t=s.valueToCode(t,"DIVISOR",e.MULTIPLICATIVE)||"0"),e.MULTIPLICATIVE]},math_number:function(t,s){return t=Number(t.getFieldValue("NUM")),[String(t),0>t?e.UNARY:e.ATOMIC]},math_number_property:function(t,s){var i={EVEN:[" % 2 == 0",e.MULTIPLICATIVE,e.RELATIONAL],ODD:[" % 2 == 1",e.MULTIPLICATIVE,e.RELATIONAL],WHOLE:[" % 1 == 0",e.MULTIPLICATIVE,e.RELATIONAL],POSITIVE:[" > 0",e.RELATIONAL,e.RELATIONAL],NEGATIVE:[" < 0",e.RELATIONAL,e.RELATIONAL],DIVISIBLE_BY:[null,e.MULTIPLICATIVE,e.RELATIONAL],PRIME:[null,e.NONE,e.HIGH]};const o=t.getFieldValue("PROPERTY"),[n,r,l]=i[o];if(i=s.valueToCode(t,"NUMBER_TO_CHECK",r)||"0","PRIME"===o)t=s.provideFunction_("math_isPrime",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(n)\n -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if n == 2 or n == 3 then\n return true\n end\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 not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then\n return false\n end\n -- Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for x = 6, math.sqrt(n) + 1.5, 6 do\n if n % (x - 1) == 0 or n % (x + 1) == 0 then\n return false\n end\n end\n return true\nend\n`)+"("+i+")";else if("DIVISIBLE_BY"===o){if("0"===(t=s.valueToCode(t,"DIVISOR",e.MULTIPLICATIVE)||"0"))return["nil",e.ATOMIC];t=i+" % "+t+" == 0"}else t=i+n;return[t,l]},math_on_list:function(t,s){function i(){return s.provideFunction_("math_sum",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n local result = 0\n for _, v in ipairs(t) do\n result = result + v\n end\n return result\nend\n`)}var o=t.getFieldValue("OP");switch(t=s.valueToCode(t,"LIST",e.NONE)||"{}",o){case"SUM":o=i();break;case"MIN":o=s.provideFunction_("math_min",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n local result = math.huge\n for _, v in ipairs(t) do\n if v < result then\n result = v\n end\n end\n return result\nend\n`);break;case"AVERAGE":o=s.provideFunction_("math_average",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n return ${i()}(t) / #t\nend\n`);break;case"MAX":o=s.provideFunction_("math_max",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n local result = -math.huge\n for _, v in ipairs(t) do\n if v > result then\n result = v\n end\n end\n return result\nend\n`);break;case"MEDIAN":o=s.provideFunction_("math_median",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n if #t == 0 then\n return 0\n end\n local temp = {}\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n table.insert(temp, v)\n end\n end\n table.sort(temp)\n if #temp % 2 == 0 then\n return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2\n else\n return temp[math.ceil(#temp / 2)]\n end\nend\n`);break;case"MODE":o=s.provideFunction_("math_modes",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n local counts = {}\n for _, v in ipairs(t) do\n if counts[v] == nil then\n counts[v] = 1\n else\n counts[v] = counts[v] + 1\n end\n end\n local biggestCount = 0\n for _, v in pairs(counts) do\n if v > biggestCount then\n biggestCount = v\n end\n end\n local temp = {}\n for k, v in pairs(counts) do\n if v == biggestCount then\n table.insert(temp, k)\n end\n end\n return temp\nend\n`);break;case"STD_DEV":o=s.provideFunction_("math_standard_deviation",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n local m\n local vm\n local total = 0\n local count = 0\n local result\n m = #t == 0 and 0 or ${i()}(t) / #t\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n vm = v - m\n total = total + (vm * vm)\n count = count + 1\n end\n end\n result = math.sqrt(total / (count-1))\n return result\nend\n`);break;case"RANDOM":o=s.provideFunction_("math_random_list",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return nil\n end\n return t[math.random(#t)]\nend\n`);break;default:throw Error("Unknown operator: "+o)}return[o+"("+t+")",e.HIGH]},math_random_float:function(t,s){return["math.random()",e.HIGH]},math_random_int:function(t,s){return["math.random("+(s.valueToCode(t,"FROM",e.NONE)||"0")+", "+(t=s.valueToCode(t,"TO",e.NONE)||"0")+")",e.HIGH]}};b.math_round=l,b.math_single=l,b.math_trig=l;var $={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#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),e=s(983);const i=e.common.createBlockDefinitionsFromJsonArray([{type:"sleep",message0:"Wait %1 seconds",args0:[{type:"input_value",name:"SEC",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Wait for some time",helpUrl:""},{type:"print",message0:"Print %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Write text with newline",helpUrl:""},{type:"printerror",message0:"Log error: %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:0,tooltip:"Log an error",helpUrl:""},{type:"write",message0:"Write %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Write text without newline",helpUrl:""},{type:"read",message0:"Read",colour:100,tooltip:"Read from console",helpUrl:"",output:"String"},{type:"read_completion",message0:"Read with autocomplete %1",args0:[{type:"input_value",check:"Array"}],colour:100,tooltip:"Read from console",helpUrl:"",output:"String"},{type:"read_replace",message0:"Read and replace with %1",args0:[{type:"input_value",name:"CHAR",check:"String"}],colour:100,tooltip:"Read from console and replace input with a character",helpUrl:"",output:"String"},{type:"tonumber",message0:"To number: %1",args0:[{type:"input_value",name:"OBJ"}],colour:100,tooltip:"Convert any object to a number",helpUrl:"",output:"Number"},{type:"tostring",message0:"To string: %1",args0:[{type:"input_value",name:"OBJ"}],colour:100,tooltip:"Convert any object to string",helpUrl:"",output:"String"},{type:"fs_open",message0:"Open for %1 byte mode %2 file: %3",args0:[{type:"field_dropdown",name:"MODE",options:[["read","r"],["write (overwrite)","w"],["write (keep)","a"],["update (keep)","r+"],["update (overwrite)","w+"]]},{type:"field_checkbox",name:"ISBYTE",checked:!1},{type:"input_value",check:"String",name:"NAME"}],colour:50,tooltip:"Open a file",helpUrl:"",output:"FileHandle"},{type:"fs_close",message0:"Close file %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],previousStatement:null,nextStatement:null,colour:50,tooltip:"Close a file",helpUrl:""},{type:"fs_read",message0:"Read %1 bytes from file %2",args0:[{type:"input_value",name:"BYTE",check:"Number"},{type:"input_value",name:"FILE",check:"FileHandle"}],inputsInline:!0,colour:50,tooltip:"Read bytes from file",helpUrl:"",output:"String"},{type:"fs_readall",message0:"Read everything from %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],colour:50,tooltip:"Read all remaining contents from file",helpUrl:"",output:"String"},{type:"fs_readline",message0:"Read a line from %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],colour:50,tooltip:"Read a line from file",helpUrl:"",output:"String"},{colour:50,type:"fs_seek",message0:"Offset pointer in file %1 by %2, relative to the %3",args0:[{type:"input_value",name:"FILE",check:"FileHandle"},{type:"input_value",name:"OFFSET",check:"Number"},{type:"field_dropdown",name:"MODE",options:[["current position","cur"],["beginning of the file","set"],["end of the file","end"]]}]},{colour:50,type:"fs_seek_pos",message0:"Pointer position in file %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],output:"Number"},{type:"list_getkey",message0:"Get key %2 of table %1",args0:[{type:"input_value",name:"TABLE",check:"Array"},{type:"input_value",name:"KEY",check:null}],colour:100,tooltip:"Get element by key",helpUrl:"",output:null},{type:"fs_copy",message0:"Copy %1 as %2",args0:[{type:"input_value",name:"FILE",check:"String"},{type:"input_value",name:"DEST",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Copy file to another file",helpUrl:""},{type:"fs_delete",message0:"Delete %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Delete a file or directory",helpUrl:""},{type:"fs_exists",message0:"%1 exists?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the file exists",helpUrl:"",output:"Boolean"},{type:"fs_getdrive",message0:"Drive of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks which drive is file located on",helpUrl:"",output:"String"},{type:"fs_getfreespace",message0:"Free space of drive of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Returns free space on the drive this file is located on",helpUrl:"",output:"Number"},{type:"fs_getcapacity",message0:"Capacity of drive of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Returns capacity of the drive this file is located on",helpUrl:"",output:"Number"},{type:"fs_isdir",message0:"Is %1 a directory?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the path is a directory",helpUrl:"",output:"Boolean"},{type:"fs_makedir",message0:"Create directory %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Create a directory",helpUrl:""},{type:"fs_isreadonly",message0:"Is %1 read-only?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the file can only be read",helpUrl:"",output:"Boolean"},{type:"fs_getsize",message0:"Get size of file %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Get the size of a file",helpUrl:"",output:"Number"},{type:"fs_move",message0:"Move file %1 to %2",args0:[{type:"input_value",name:"FILE",check:"String"},{type:"input_value",name:"DEST",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Move file to a directory",helpUrl:""},{type:"fs_complete",message0:"Completions of name %1 from directory %2",args0:[{type:"input_value",name:"FILE",check:"String"},{type:"input_value",name:"DEST",check:"String"}],colour:100,tooltip:"Returns list of filenames that can complete input",helpUrl:"",output:"Array"},{type:"fs_attributes",message0:"Attributes of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Return all attributes of a file",helpUrl:"",output:"Array"},{type:"fs_list",message0:"List dir %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Return all filepaths in a directory",helpUrl:"",output:"Array"},{type:"fs_find",message0:"Find files which match pattern %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Find all files which can fit in the search string",helpUrl:"",output:"Array"},{type:"fs_isdriveroot",message0:"Is drive of %1 root?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the drive is file located on is root",helpUrl:"",output:"Boolean"},{type:"shell_resolve",message0:"Resolve relative path %1",args0:[{type:"input_value",name:"PATH",check:"String"}],colour:0,tooltip:"Convert a relative path to an absolute one",helpUrl:"",output:"String"},{type:"fs_combine",message0:"Combine paths in table %1",args0:[{type:"input_value",name:"PATHS",check:"Array"}],colour:100,tooltip:"Combine paths",helpUrl:"",output:null},{type:"turtle_attack",message0:"Attack %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Attack!!!!",helpUrl:""},{type:"turtle_build",message0:"Build %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Place the selected block",helpUrl:""},{type:"turtle_compare",message0:"Compare %1 to inventory",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],colour:230,tooltip:"Is the block the same as selected?",helpUrl:"",output:"Boolean"},{type:"turtle_compareto",message0:"Compare to item in slot %1",args0:[{type:"input_value",name:"SLOT",check:"Number"}],colour:100,tooltip:"Compares selected item to another one",helpUrl:"",output:"Boolean"},{type:"turtle_craft",message0:"Attempt to craft %1 items",args0:[{type:"input_value",name:"NUM",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Anybody actually uses crafting turtles?",helpUrl:""},{type:"turtle_detect",message0:"Is there a block %1?",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],colour:230,tooltip:"Check for a block in given direction",helpUrl:"",output:"Boolean"},{type:"turtle_dig",message0:"Dig %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Dig. Rock and stone!",helpUrl:""},{type:"turtle_drop",message0:"Drop %1 %2 items",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]},{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Drop the selected item",helpUrl:""},{type:"turtle_equip",message0:"Equip to the %1",args0:[{type:"field_dropdown",name:"DIR",options:[["left","Left"],["right","Right"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Equips selected item. If slot is empty, unequip the side.",helpUrl:""},{type:"turtle_getfuellevel",message0:"Get fuel level",colour:100,tooltip:"Turtle not moving? Check the fuel!",helpUrl:"",output:"Number"},{type:"turtle_getfuellimit",message0:"Get fuel limit",colour:100,tooltip:"By default, 20000 for regular turtles and 100000 for advanced ones.",helpUrl:"",output:"Number"},{type:"turtle_getitemdetail",message0:"Item detail in slot %1",args0:[{type:"input_value",name:"SLOT",check:"Number"}],colour:230,tooltip:"Returns a table with some data about item. If 0, defaults to current slot.",helpUrl:"",output:"Array"},{type:"turtle_getitemdetail_detailed",message0:"Item detail in slot %1 (with more details)",args0:[{type:"input_value",name:"SLOT",check:"Number"}],colour:230,tooltip:"Gives more data at the cost of run time. If slot is 0, defaults to current slot.",helpUrl:"",output:"Array"},{type:"turtle_getselectedslot",message0:"Selected slot",colour:230,tooltip:"Get selected slot number",helpUrl:"",output:"Number"},{type:"turtle_inspect",message0:"Inspect the block %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","up"],["down","down"]]}],colour:230,tooltip:"I'm watching...",helpUrl:"",output:"Array"},{type:"turtle_move",message0:"Move %1 %2 times",args0:[{type:"field_dropdown",name:"DIR",options:[["forward","forward"],["up","up"],["down","down"],["back","back"],["left","turnLeft"],["right","turnRight"]]},{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:230,tooltip:"I like to move it move it",helpUrl:""},{type:"turtle_refuel",message0:"Refuel, consume at most %1 items",args0:[{type:"input_value",name:"NUM",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Refuel the turtle",helpUrl:""},{type:"turtle_refuel_isfuel",message0:"Is selected item combustable?",colour:100,tooltip:"Sticks are true, bucket of axolotl is false.",helpUrl:"",output:"Boolean"},{type:"turtle_select",message0:"Select slot %1",args0:[{type:"input_value",name:"NUM",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Select slot from 1 to 16",helpUrl:""},{type:"turtle_suck",message0:"Suck item from %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","up"],["down","down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Hmmm...",helpUrl:""},{type:"turtle_transferto",message0:"Transfer item to slot %1",args0:[{type:"input_value",name:"SLOT",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Moves the item in inventory",helpUrl:""},{type:"get_arg",message0:"Get arg # %1",args0:[{type:"input_value",check:"Number",name:"NUM"}],colour:100,tooltip:"Get command line argument",helpUrl:"",output:null},{type:"get_arg_amount",message0:"Amount of arguments",colour:100,tooltip:"Amount of command line arguments",helpUrl:"",output:"Number"},{type:"args",message0:"args",colour:100,tooltip:"Argument table",helpUrl:"",output:"Array"},{type:"shallow_copy",message0:"Shallow copy of table %1",args0:[{type:"input_value",check:"Array",name:"TABLE"}],colour:100,tooltip:"Get a copy of a table",helpUrl:"",output:"Array"},{type:"os_pullevent",message0:"Pull event with filter: %1 raw? %2",args0:[{type:"input_value",check:"String",name:"FILTER"},{type:"field_checkbox",name:"RAW",checked:!1}],colour:0,tooltip:"Pull an event and return all data as a table. If raw, will also pull terminate event.",helpUrl:"",output:"Array"},{type:"disk_ispresent",message0:"Is disk %1 present?",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Checks whether any item at all is in the disk drive",helpUrl:"",output:"Boolean"},{type:"disk_getlabel",message0:"Get label of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Get the label of the floppy disk, record, or other media within the given disk drive",helpUrl:"",output:"String"},{type:"disk_setlabel",message0:"Set label of disk %1 to %2",args0:[{type:"input_value",name:"DRIVE",check:"String"},{type:"input_value",name:"LABEL",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Set the label of the floppy disk or other media",helpUrl:""},{type:"disk_hasdata",message0:"Has disk %1 data?",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Check whether the current disk provides a mount",helpUrl:"",output:"Boolean"},{type:"disk_getmountpath",message0:"Get mount path of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Find the directory name on the local computer where the contents of the current floppy disk (or other mount) can be found",helpUrl:"",output:"String"},{type:"disk_hasaudio",message0:"Has disk %1 audio?",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Whether the current disk is a music disk as opposed to a floppy disk or other item",helpUrl:"",output:"Boolean"},{type:"disk_getaudiotitle",message0:"Get audio title of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Get the title of the audio track from the music record in the drive",helpUrl:"",output:"String"},{type:"disk_playaudio",message0:"Play audio of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Starts playing the music record in the drive",helpUrl:""},{type:"disk_stopaudio",message0:"Stop audio of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Stops the music record in the drive from playing",helpUrl:""},{type:"disk_eject",message0:"Eject disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Ejects any item currently in the drive, spilling it into the world as a loose item",helpUrl:""},{type:"disk_getid",message0:"Get ID of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Returns a number which uniquely identifies the disk in the drive",helpUrl:"",output:"String"},{type:"side",message0:"Side %1",args0:[{type:"field_dropdown",name:"SIDE",options:[["bottom","bottom"],["top","top"],["front","front"],["back","back"],["left","left"],["right","right"]]}],colour:100,tooltip:"Side of the computer",helpUrl:"",output:"String"},{type:"http_get",message0:"GET %1 with header (optional) %2",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"}],inputsInline:!0,colour:100,tooltip:"Make a HTTP GET request to the given url",helpUrl:"",output:"String"},{type:"http_post",message0:"POST %1 with data %2 and headers (optional) %3",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"DATA",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"}],inputsInline:!0,colour:100,tooltip:"Make a HTTP POST request to the given url",helpUrl:"",output:"String"},{type:"http_request",message0:"Request %1 with data %2 and header (optional) %3",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"DATA",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"}],colour:100,tooltip:"Asynchronously make a HTTP request to the given url",helpUrl:"",output:"String"},{type:"http_checkurl",message0:"Check URL %1 Async? %2",args0:[{type:"input_value",name:"URL",check:"String"},{type:"field_checkbox",name:"ASYNC",checked:!1}],colour:100,tooltip:"Determine whether a URL can be requested",helpUrl:"",output:"Boolean"},{type:"http_websocket",message0:"(Not working)Open websocket %1 with headers (optional) %2 Async? %3",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"},{type:"field_checkbox",name:"ASYNC",checked:!1}],inputsInline:!0,colour:100,tooltip:"Open a websocket to the given url (not working)",helpUrl:"",output:"String"},{type:"per_getnames",message0:"Get names of all peripherals",colour:100,tooltip:"Get names of all peripherals",helpUrl:"",output:"Array"},{type:"per_ispresent",message0:"Is peripheral %1 present?",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Check whether a peripheral is present",helpUrl:"",output:"Boolean"},{type:"per_gettypes",message0:"Get type of peripheral %1",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Get the type of a peripheral",helpUrl:"",output:"String"},{type:"per_hastype",message0:"Has peripheral %1 type %2?",args0:[{type:"input_value",name:"NAME",check:"String"},{type:"input_value",name:"TYPE",check:"String"}],colour:100,tooltip:"Check whether a peripheral has a specific type",helpUrl:"",output:"Boolean"},{type:"per_getmethods",message0:"Get methods of peripheral %1",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Get the methods of a peripheral",helpUrl:"",output:"Array"},{type:"per_call",message0:"Call method %1 of peripheral %2 with arguments %3",args0:[{type:"input_value",name:"METHOD",check:"String"},{type:"input_value",name:"NAME",check:"String"},{type:"input_value",name:"ARGS",check:"Array"}],colour:100,tooltip:"Call a method of a peripheral",helpUrl:"",output:null},{type:"per_wrap",message0:"Wrap peripheral %1",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Wrap a peripheral",helpUrl:"",output:"Table"},{type:"per_find",message0:"Find peripheral with type %1",args0:[{type:"input_value",name:"TYPE",check:"String"}],colour:100,tooltip:"Find a peripheral with a specific type",helpUrl:"",output:"String"}]);var o=s(619);const n=Object.create(null);n.sleep=function(t,e){return`sleep(${e.valueToCode(t,"SEC",o.Order.NONE)||"''"})\n`},n.print=function(t,e){return`print(${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})\n`},n.printerror=function(t,e){return`printError(${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})\n`},n.write=function(t,e){return`write(${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})\n`},n.read=function(t,e){return"read()"},n.read_completion=function(t,e){return`read(nil, nil, ${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})`},n.read_replace=function(t,e){return`read(${e.valueToCode(t,"CHAR",o.Order.NONE)||"''"})`},n.fs_open=function(t,e){const s=e.valueToCode(t,"NAME",o.Order.NONE)||"''",i="TRUE"===t.getFieldValue("ISBYTE");let n=t.getFieldValue("MODE");return i&&(n=n.slice(0,1)+"b"+n.slice(1)),[`fs.open(${s},${n})`,o.Order.NONE]},n.fs_close=function(t,e){return`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.close()\n`},n.fs_read=function(t,e){const s=e.valueToCode(t,"BYTE",o.Order.NONE)||"1";return[`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.read(${1==s?"":s})`,o.Order.NONE]},n.fs_readall=function(t,e){return[`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.readAll()`,o.Order.NONE]},n.fs_readline=function(t,e){return[`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.readLine()`,o.Order.NONE]},n.shell_resolve=function(t,e){return[`shell.resolve(${e.valueToCode(t,"PATH",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_seek=function(t,e){const s=e.valueToCode(t,"FILE",o.Order.NONE),i=e.valueToCode(t,"OFFSET",o.Order.NONE);return`${s}.seek("${t.getFieldValue("MODE")}",${i})\n`},n.fs_seek_pos=function(t,e){return[`${e.valueToCode(t,"FILE",o.Order.NONE)}.seek("cur")`,o.Order.NONE]},n.tostring=function(t,e){return[`tostring(${e.valueToCode(t,"OBJ",o.Order.NONE)})`,o.Order.NONE]},n.tonumber=function(t,e){return[`tonumber(${e.valueToCode(t,"OBJ",o.Order.NONE)})`,o.Order.NONE]},n.fs_copy=function(t,e){return`fs.copy("${e.valueToCode(t,"FILE",o.Order.NONE)}",${e.valueToCode(t,"DEST",o.Order.NONE)})\n`},n.fs_move=function(t,e){return`fs.copy("${e.valueToCode(t,"FILE",o.Order.NONE)}",${e.valueToCode(t,"DEST",o.Order.NONE)})\n`},n.fs_list=function(t,e){return[`fs.list(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_delete=function(t,e){return`fs.delete("${e.valueToCode(t,"FILE",o.Order.NONE)}")\n`},n.fs_makedir=function(t,e){return`fs.makedir("${e.valueToCode(t,"TEXT",o.Order.NONE)}")\n`},n.fs_isdir=function(t,e){return[`fs.isDir(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_isreadonly=function(t,e){return[`fs.isReadOnly(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getsize=function(t,e){return[`fs.getSize(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getcapacity=function(t,e){return[`fs.getCapacity(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getfreespace=function(t,e){return[`fs.getFreeSpace(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_attributes=function(t,e){return[`fs.attributes(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_exists=function(t,e){return[`fs.exists(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_complete=function(t,e){return[`fs.complete(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"},${e.valueToCode(t,"DEST",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_find=function(t,e){return[`fs.find(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getdrive=function(t,e){return[`fs.getDrive(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_isdriveroot=function(t,e){return[`fs.isDriveRoot(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_combine=function(t,e){return[`fs.combine(unpack(${e.valueToCode(t,"PATHS",o.Order.NONE)||"''"}))`,o.Order.NONE]},n.list_getkey=function(t,e){return[`${e.valueToCode(t,"TABLE",o.Order.NONE)||"{}"}[${e.valueToCode(t,"KEY",o.Order.NONE)||"''"}]`,o.Order.NONE]},n.turtle_move=function(t,e){const s=t.getFieldValue("DIR"),i=e.valueToCode(t,"TIMES",o.Order.NONE)||"";return`${i>1?`for i=1,${i} do `:""}turtle.${s}()${i>1?" end":""}\n`},n.turtle_attack=function(t,e){return`turtle.attack${t.getFieldValue("DIR")}()\n`},n.turtle_dig=function(t,e){return`turtle.dig${t.getFieldValue("DIR")}()\n`},n.turtle_build=function(t,e){return`turtle.build${t.getFieldValue("DIR")}()\n`},n.turtle_compare=function(t,e){return[`turtle.compare${t.getFieldValue("DIR")}()`,o.Order.NONE]},n.turtle_drop=function(t,e){return`turtle.drop${t.getFieldValue("DIR")}(${e.valueToCode(t,"TIMES",o.Order.NONE)||""})\n`},n.turtle_equip=function(t,e){return`turtle.equip${t.getFieldValue("DIR")}()\n`},n.turtle_detect=function(t,e){return[`turtle.detect${t.getFieldValue("DIR")}()`,o.Order.NONE]},n.turtle_suck=function(t,e){return`turtle.suck${t.getFieldValue("DIR")}()\n`},n.turtle_inspect=function(t,e){return[`{turtle.inspect${t.getFieldValue("DIR")}()}`,o.Order.NONE]},n.turtle_craft=function(t,e){return`turtle.craft(${e.valueToCode(t,"NUM",o.Order.NONE)||"64"})\n`},n.turtle_compareto=function(t,e){return[`turtle.compareTo(${e.valueToCode(t,"SLOT",o.Order.NONE)||""})`,o.Order.NONE]},n.turtle_transferto=function(t,e){return`turtle.transferTo(${e.valueToCode(t,"SLOT",o.Order.NONE)||""})\n`},n.turtle_getfuellevel=function(t,e){return["turtle.getFuelLevel()",o.Order.NONE]},n.turtle_getfuellimit=function(t,e){return["turtle.getFuelLimit()",o.Order.NONE]},n.turtle_getitemdetail=function(t,e){const s=e.valueToCode(t,"SLOT",o.Order.NONE)||"";return[`turtle.getItemDetail(${s>0?s:""})`,o.Order.NONE]},n.turtle_getitemdetail_detailed=function(t,e){const s=e.valueToCode(t,"SLOT",o.Order.NONE)||"";return[`turtle.getItemDetail(${s>0?s+",":""},true)`,o.Order.NONE]},n.turtle_getselectedslot=function(t,e){return["turtle.getSelectedSlot()",o.Order.NONE]},n.turtle_refuel_isfuel=function(t,e){return["turtle.refuel(0)",o.Order.NONE]},n.turtle_refuel=function(t,e){return`turtle.refuel(${e.valueToCode(t,"NUM",o.Order.NONE)||"64"})\n`},n.turtle_select=function(t,e){return`turtle.select(${e.valueToCode(t,"NUM",o.Order.NONE)||"1"})\n`},n.shallow_copy=function(t,e){const s=e.provideFunction_("shallow_copy",`function ${e.FUNCTION_NAME_PLACEHOLDER_}\n local t2 = {}\n for k,v in pairs(t) do\n t2[k] = v\n end\n return t2\nend\n`);return e.provideFunction_("getArgs","local args = {...}\n"),[`${s}(${e.valueToCode(t,"TABLE",o.Order.NONE)||"1"})`,o.Order.NONE]},n.get_arg=function(t,e){return e.provideFunction_("getArgs","local args = {...}\n"),[`args[${e.valueToCode(t,"NUM",o.Order.NONE)||"1"}]`,o.Order.NONE]},n.args=function(t,e){return e.provideFunction_("getArgs","local args = {...}\n"),["args",o.Order.NONE]},n.get_arg_amount=function(t,e){return e.provideFunction_("getArgs","local args = {...}\n"),["#args",o.Order.NONE]},n.disk_ispresent=function(t,e){return[`disk.isPresent("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_getlabel=function(t,e){return[`disk.getLabel("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_setlabel=function(t,e){return`disk.setLabel("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}",${e.valueToCode(t,"LABEL",o.Order.NONE)||"''"})\n`},n.disk_hasdata=function(t,e){return[`disk.hasData("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_getmountpath=function(t,e){return[`disk.getMountPath("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_hasaudio=function(t,e){return[`disk.hasAudio("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_getaudiotitle=function(t,e){return[`disk.getAudioTitle("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_playaudio=function(t,e){return`disk.playAudio("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")\n`},n.disk_stopaudio=function(t,e){return`disk.stopAudio("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")\n`},n.disk_eject=function(t,e){return`disk.eject("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")\n`},n.disk_getid=function(t,e){return[`disk.getID("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.side=function(t,e){return[`${t.getFieldValue("SIDE")}`,o.Order.NONE]},n.http_get=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''";return"''"!=i?[`http.get(${s},${i})`,o.Order.NONE]:[`http.get(${s})`,o.Order.NONE]},n.http_post=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"DATA",o.Order.NONE)||"''",n=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''";return"''"!=n?[`http.post(${s},${i},${n})`,o.Order.NONE]:[`http.post(${s},${i})`,o.Order.NONE]},n.http_request=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"DATA",o.Order.NONE)||"''",n=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''";return"''"!=n?[`http.request(${s},${i},${n})`,o.Order.NONE]:[`http.request(${s},${i})`,o.Order.NONE]},n.http_checkurl=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"ASYNC",o.Order.NONE)||"''";return"''"!=i?[`http.checkURL(${s},${i})`,o.Order.NONE]:[`http.checkURL(${s})`,o.Order.NONE]},n.http_websocket=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''",n=t.getFieldValue("ASYNC");return"''"!=i&&"TRUE"==n?[`http.websocketAsync(${s},${i})`,o.Order.NONE]:"''"!=i?[`http.websocket(${s},${i})`,o.Order.NONE]:"TRUE"==n?[`http.websocketAsync(${s})`,o.Order.NONE]:[`http.websocket(${s})`,o.Order.NONE]},n.per_getnames=function(t,e){return["peripheral.getNames()",o.Order.NONE]},n.per_ispresent=function(t,e){return[`peripheral.isPresent(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_gettypes=function(t,e){return[`peripheral.getType(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_hastype=function(t,e){return[`peripheral.hasType(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"},${e.valueToCode(t,"TYPE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_getmethods=function(t,e){return[`peripheral.getMethods(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_call=function(t,e){return[`peripheral.call(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"},${e.valueToCode(t,"METHOD",o.Order.NONE)||"''"},${e.valueToCode(t,"ARGS",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_wrap=function(t,e){return[`peripheral.wrap(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_find=function(t,e){return[`peripheral.find(${e.valueToCode(t,"TYPE",o.Order.NONE)||"''"})`,o.Order.NONE]};var r=s(72),l=s.n(r),a=s(825),c=s.n(a),h=s(659),u=s.n(h),d=s(56),p=s.n(d),g=s(540),_=s.n(g),T=s(113),m=s.n(T),E=s(523),f={};f.styleTagTransform=m(),f.setAttributes=p(),f.insert=u().bind(null,"head"),f.domAPI=c(),f.insertStyleElement=_(),l()(E.A,f),E.A&&E.A.locals&&E.A.locals,t.common.defineBlocks(i),Object.assign(o.luaGenerator.forBlock,n);const b=document.getElementById("generatedCode").firstChild,$=(document.getElementById("output"),document.getElementById("blocklyDiv")),I=t.inject($,{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:"category",name:"Lists",categorystyle:"list_category",contents:[{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:"block",type:"list_getkey"},{kind:"block",type:"shallow_copy"}]},{kind:"sep"},{kind:"category",name:"CC: Base",categorystyle:"text_category",contents:[{kind:"block",type:"sleep",inputs:{SEC:{shadow:{type:"math_number",fields:{NUM:5}}}}},{kind:"block",type:"args"},{kind:"block",type:"get_arg"},{kind:"block",type:"get_arg_amount"},{kind:"block",type:"print",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"write",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"read"},{kind:"block",type:"read_replace",inputs:{CHAR:{shadow:{type:"text",fields:{TEXT:"*"}}}}},{kind:"block",type:"tostring"},{kind:"block",type:"tonumber"},{kind:"block",type:"side"}]},{kind:"category",name:"CC: Shell + OS",categorystyle:"text_category",contents:[{kind:"block",type:"shell_resolve"}]},{kind:"category",name:"CC: Turtle",categorystyle:"text_category",contents:[{kind:"block",type:"turtle_move",inputs:{TIMES:{shadow:{type:"math_number",fields:{NUM:1}}}}},{kind:"block",type:"turtle_select"},{kind:"block",type:"turtle_attack"},{kind:"block",type:"turtle_build"},{kind:"block",type:"turtle_dig"},{kind:"block",type:"turtle_detect"},{kind:"block",type:"turtle_compare"},{kind:"block",type:"turtle_drop"},{kind:"block",type:"turtle_compareto"},{kind:"block",type:"turtle_craft"},{kind:"block",type:"turtle_equip"},{kind:"block",type:"turtle_getfuellevel"},{kind:"block",type:"turtle_getfuellimit"},{kind:"block",type:"turtle_getitemdetail"},{kind:"block",type:"turtle_getitemdetail_detailed"},{kind:"block",type:"turtle_getselectedslot"},{kind:"block",type:"turtle_inspect"},{kind:"block",type:"turtle_refuel"},{kind:"block",type:"turtle_refuel_isfuel"},{kind:"block",type:"turtle_suck"},{kind:"block",type:"turtle_transferto"}]},{kind:"category",name:"CC: fs",categorystyle:"text_category",contents:[{kind:"block",type:"fs_open"},{kind:"block",type:"fs_close"},{kind:"block",type:"fs_seek",inputs:{OFFSET:{shadow:{type:"math_number",fields:{NUM:1}}}}},{kind:"block",type:"fs_seek_pos"},{kind:"block",type:"fs_readall"},{kind:"block",type:"fs_readline"},{kind:"block",type:"fs_attributes"},{kind:"block",type:"fs_copy"},{kind:"block",type:"fs_delete"},{kind:"block",type:"fs_exists"},{kind:"block",type:"fs_getdrive"},{kind:"block",type:"fs_getfreespace"},{kind:"block",type:"fs_getcapacity"},{kind:"block",type:"fs_isdir"},{kind:"block",type:"fs_makedir"},{kind:"block",type:"fs_isreadonly"},{kind:"block",type:"fs_getsize"},{kind:"block",type:"fs_move"},{kind:"block",type:"fs_complete"},{kind:"block",type:"fs_combine"},{kind:"block",type:"fs_list"},{kind:"block",type:"fs_find"},{kind:"block",type:"fs_isdriveroot"}]},{kind:"category",name:"CC: Disk",categorystyle:"text_category",contents:[{kind:"block",type:"disk_ispresent"},{kind:"block",type:"disk_getlabel"},{kind:"block",type:"disk_setlabel",inputs:{LABEL:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"disk_hasdata"},{kind:"block",type:"disk_getmountpath"},{kind:"block",type:"disk_hasaudio"},{kind:"block",type:"disk_getaudiotitle"},{kind:"block",type:"disk_playaudio"},{kind:"block",type:"disk_stopaudio"},{kind:"block",type:"disk_eject"},{kind:"block",type:"disk_getid"}]},{kind:"category",name:"CC: HTTP",categorystyle:"text_category",contents:[{kind:"block",type:"http_checkurl"},{kind:"block",type:"http_get"},{kind:"block",type:"http_post"},{kind:"block",type:"http_request"},{kind:"block",type:"http_websocket"}]},{kind:"category",name:"CC: Peripherals",categorystyle:"text_category",contents:[{kind:"block",type:"per_getnames"},{kind:"block",type:"per_gettypes",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}},{kind:"block",type:"per_ispresent",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}},{kind:"block",type:"per_getmethods",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}},{kind:"block",type:"per_call",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}},METHOD:{shadow:{type:"text",fields:{TEXT:"open"}}}}},{kind:"block",type:"per_gettypes",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}}]},{kind:"sep"},{kind:"category",name:"Variables",categorystyle:"variable_category",custom:"VARIABLE"},{kind:"category",name:"Functions",categorystyle:"procedure_category",custom:"PROCEDURE"}]}}),O=()=>{const t=o.luaGenerator.workspaceToCode(I);b.innerText=t};O(),I.addChangeListener((t=>{t.isUiEvent||function(t){const s=e.serialization.workspaces.save(t);window.localStorage?.setItem("mainWorkspace",JSON.stringify(s))}(I)})),I.addChangeListener((e=>{e.isUiEvent||e.type==t.Events.FINISHED_LOADING||I.isDragging()||O()}))})()})(); \ 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,f,b,$,I,O,S,C,R,k,y,N,v,A,L,w,M,D,x,P,B,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,ft,bt,$t,It,Ot,St,Ct,Rt,kt,yt,Nt,vt,At,Lt,wt,Mt,Dt,xt,Pt,Bt,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,fe,be,$e,Ie,Oe,Se,Ce,Re,ke,ye,Ne,ve,Ae,Le,we,Me,De,xe,Pe,Be,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,fs,bs,$s,Is,Os,Ss,Cs,Rs,ks,ys,Ns,vs,As,Ls,ws,Ms,Ds,xs,Ps,Bs,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,fi,bi,$i,Ii,Oi,Si,Ci,Ri,ki,yi,Ni,vi,Ai,Li,wi,Mi,Di,xi,Pi,Bi,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,fo,bo,$o,Io,Oo,So,Co,Ro,ko,yo,No,vo,Ao,Lo,wo,Mo,Do,xo,Po,Bo,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,fn,bn,$n,In,On,Sn,Cn,Rn,kn,yn,Nn,vn,An,Ln,wn,Mn,Dn,xn,Pn,Bn,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,fr,br,$r,Ir,Or,Sr,Cr,Rr,kr,yr,Nr,vr,Ar,Lr,wr,Mr,Dr={};t=function(t,s,i,o){if(!(t instanceof Ur)&&"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=xr[t],l=Br[t];if(r||(r=xr[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(Ur.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=xr[t];s&&s[e]?(delete xr[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=xr[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=xr[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=xr[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)]||Fr)?e:r(t,e,s)},h=function(t){return Xr[t]||null},u=function(){const t=[];for(const e in Xr)t.push(Xr[e]);return t},d=function(t){Xr[t.id]=t},p=function(t){delete Xr[t.id]},g=function(){return Gr},_=function(t){Gr=t},T=function(){return Yr},m=function(t){Yr=t},E=function(){return Vr},f=function(t){Vr=t},b=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)}},O=function(t){zr.defineBlocksWithJsonArrayInternal(t)},S=function(t){Dr.defineBlocks$$module$build$src$core$common(Dr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(t))},Dr.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(t){const e={};for(let s=0;s{setTimeout(A,0)}))}catch(t){setTimeout(A,0)}fl.push(t)}},A=function(){var t=L(fl,!0);fl.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),ca="",(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."),da.has(t)||(da.add(t),console.warn(t))},it=function(t,e,s){t=document.createElementNS(_a,`${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(){fa++,Ea||(Ea=Object.create(null))},pt=function(){--fa||(Ea=null)},gt=function(t){const e=t.textContent+"\n"+t.className.baseVal;let s;if(Ea&&(s=Ea[e]))return s;try{s=t.getComputedTextLength()}catch(e){return 8*t.textContent.length}return Ea&&(Ea[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,Ea&&(n=Ea[t])||(ba||((n=document.createElement("canvas")).className="blocklyComputeCanvas",document.body.appendChild(n),ba=n.getContext("2d")),ba.font=s+" "+e+" "+i,n=o?ba.measureText(o).width:0,Ea&&(Ea[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 Ca.getSizeInternal(t)},ft=function(t){if("none"!==$t(t,"display"))return bt(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 Sa(n,t)},bt=function(t){return new Sa(t.offsetWidth,t.offsetHeight)},$t=function(t,e){return(t=window.getComputedStyle(t))[e]||t.getPropertyValue(e)},It=function(t){const e=new ua(0,0);t=t.getBoundingClientRect();var s=document.documentElement;return s=new ua(window.pageXOffset||s.scrollLeft,window.pageYOffset||s.scrollTop),e.x=t.left+s.x,e.y=t.top+s.y,e},Ot=function(){const t=document.body,e=document.documentElement;return new ua(t.scrollLeft||e.scrollLeft,t.scrollTop||e.scrollTop)},St=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 Oa(i,t,e,s)},Ct=function(t,e,s){t=Rt(t,e,s),e.scrollLeft=t.x,e.scrollTop=t.y},Rt=function(t,e,s){var i=It(t),o=It(e),n=St(e);const r=i.x-o.x-n.left;return i=i.y-o.y-n.top,o=bt(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 ua(n,e)},kt=function(t){const e=new ua(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(ka))&&(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)),Pt(t),t):null},Pt=function(t){const e=t.kind;if(t=t.contents,e&&e!==Ha&&e!==Ua)throw Error("Invalid toolbox kind "+e+". Please supply either "+Ha+" or "+Ua);if(!t)throw Error("Toolbox must have a contents attribute.")},Bt=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===Va.LEFT?(s=o.absoluteMetrics.left+s,r&&n.RTL&&(s+=va.scrollbarThickness)):(s=o.absoluteMetrics.left+o.viewMetrics.width-e.width-s,r&&!n.RTL&&(s-=va.scrollbarThickness)),t.vertical===Ga.TOP?t=o.absoluteMetrics.top+i:(t=o.absoluteMetrics.top+o.viewMetrics.height-e.height-i,n.scrollbar&&n.scrollbar.canScrollHorizontally()&&(t-=va.scrollbarThickness)),new Oa(t,t+e.height,s,s+e.width)},Kt=function(t,e){return{horizontal:e.toolboxMetrics.position===Fa.LEFT||t.horizontalLayout&&!t.RTL?Va.RIGHT:Va.LEFT,vertical:e.toolboxMetrics.position===Fa.BOTTOM?Ga.TOP:Ga.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)),Wr.variables_get){t.sort(cc.compareByName);for(let i,o=0;i=t[o];o++)(s=Dr.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 dc.generateUniqueNameInternal(t)},ae=function(t){return ce(uc.charAt(0),t.getAllVariableNames())},ce=function(t,e){if(!e.length)return t;const s=uc;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=Dr.createElement$$module$build$src$core$utils$xml("field");return e.setAttribute("name","VAR"),e.setAttribute("id",t.getId()),e.setAttribute("variabletype",t.type),t=Dr.createTextNode$$module$build$src$core$utils$xml(t.name),e.appendChild(t),e},Dr.getOrCreateVariablePackage$$module$build$src$core$variables=function(t,e,s,i){let o=Dr.getVariable$$module$build$src$core$variables(t,e,s,i);return o||(o=Ee(t,e,s,i)),o},Dr.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)},fe=function(t,e){t=t.getAllVariables();const s=[];if(e.length!==t.length)for(let i=0;i{Ic=t,Oc=window.requestAnimationFrame((()=>{ke(),t()}))}))),$c)},Oe=function(){return $c||Promise.resolve()},Se=function(t){t||window.cancelAnimationFrame(Oc),ke(t),!t&&Ic&&Ic()},Ce=function(){return zl},Re=function(t){bc.add(t);const e=t.getParent();e?Re(e):fc.add(t)},ke=function(t){const e=t?new Set([t]):new Set([...fc].map((t=>t.workspace))),s=[...fc].filter(Ne).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||($c=null)},ye=function(t){fc.delete(t),bc.delete(t);for(const e of t.getChildren(!1))ye(e)},Ne=function(t){return!t.isDisposed()&&!t.getParent()},ve=function(t){if(bc.has(t)){for(const e of t.getChildren(!1))ve(e);t.renderEfficiently()}},Ae=function(t,e){const s=Dr.createElement$$module$build$src$core$utils$xml("xml");var i=Le(Dr.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=Be(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=Dr.domToWorkspace$$module$build$src$core$xml(t,e),e.setResizesEnabled(!0),t},Dr.domToWorkspace$$module$build$src$core$xml=function(t,e){let s=0;e.RTL&&(s=e.getWidth());const i=[];dt();const o=Dr.getGroup$$module$build$src$core$events$utils();o||Dr.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?Ec.fromXmlRendered(r,e,s):gc.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{Dr.setGroup$$module$build$src$core$events$utils(o),e.setResizesEnabled&&e.setResizesEnabled(!0),e.rendered&&Se(),pt()}return N(new(B(ml))(e)),i},He=function(t,e){if(!e.getBlocksBoundingBox)return Dr.domToWorkspace$$module$build$src$core$xml(t,e);var s=e.getBlocksBoundingBox();if(t=Dr.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 kc(t);const o=e.newBlock(t.type,t.id);return o.setShadow(i),ms(o,t),Es(o,t),fs(o,t),bs(s,o,t),$s(o,t),Is(o,t),Os(o,t),Ss(o,t),Rs(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)},fs=function(t,e){e.extraState&&(t.loadExtraState?t.loadExtraState(e.extraState):t.domToMutation&&t.domToMutation(Dr.textToDom$$module$build$src$core$utils$xml(e.extraState)))},bs=function(t,e,s){if(t){if(t.getSourceBlock().isShadow()&&!e.isShadow())throw new vc(s);if(t.type===Dr.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var i=e.outputConnection;if(!i)throw new yc("output",e,s)}else if(!(i=e.previousConnection))throw new yc("previous",e,s);if(!t.connect(i)){const o=e.workspace.connectionChecker;throw new Nc(o.getErrorMessage(o.canConnectWithReason(i,t,!1),i,t),t.type===Dr.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(Ur.ICON,o,!1)))throw new Ac(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(ua.sum(i,o),n)||Ns(t,o,s);)e.RTL?o.translate(-s,2*s):o.translate(s,2*s);t.moveTo(ua.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)))},Ns=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()"),zc.copyInternal(t)},As=function(t){const e=t.toCopyData();let s;return Yc=e,Kc=null!=(s=t.workspace)?s:null,e},Ls=function(t,e,s){return t&&e?ws(t,e,s):Yc&&Kc?ws(Yc,Kc):null},ws=function(t,e,s){let i,o,n;return e=null!=(i=e.getRootWorkspace())?i:e,null!=(n=null==(o=l(Ur.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)"),zc.duplicateInternal(t)},Ds=function(t){const e=t.toCopyData();return e?Ls(e,t.workspace):null},xs=function(t,e){t.setAttribute(Qc,e)},Ps=function(t,e,s){Array.isArray(s)&&(s=s.join(" ")),t.setAttribute(Zc+e,`${s}`)},Bs=function(){return eh},Fs=function(t){if(eh=t,null===t){let t;null==(t=document.querySelector("."+rh))||t.remove()}},Us=function(){document.querySelector("."+rh)||((eh=document.createElement("div")).className=rh,(E()||document.body).appendChild(eh))},Hs=function(t,e,s){Gs(),oh=t,nh=s,(t=eh)&&(t.style.direction=e?"rtl":"ltr",t.style.display="block",e=g(),lh=e.getRenderer().getClassName(),ah=e.getTheme().getClassName(),lh&&ot(t,lh),ah&&ot(t,ah))},Gs=function(){if(Vs()){oh=null;var t=eh;t&&(t.style.display="none",t.style.left="",t.style.top="",nh&&nh(),nh=null,t.textContent="",lh&&(rt(t,lh),lh=""),ah&&(rt(t,ah),ah=""),g().markFocused())}},Vs=function(){return!!oh},Ws=function(t){oh===t&&Gs()},Xs=function(t,e,s){eh.style.left=t+"px",eh.style.top=e+"px",eh.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(oh)&&oh.repositionForWindowResize()||Gs()},qs=function(){return hh},Zs=function(t){hh=t},Qs=function(t,e,s){if(Hs(uh,s,ni),e.length){var i=ti(e,s);dh=i,ei(i,t,s),setTimeout((function(){i.focus()}),1),hh=null}else oi()},ti=function(t,e){const s=new sh;s.setRole(Jc.MENU);for(let i=0;i{setTimeout((()=>{o.callback(o.scope)}),0)}))}),{})}return s},ei=function(t,e,s){const i=Nt();e=new Oa(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=Bs();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(uh),hh=null},ni=function(){dh&&(dh.dispose(),dh=null)},Dr.callbackFactory$$module$build$src$core$contextmenu=function(t,e){return()=>{let s;Dr.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-Dr.config$$module$build$src$core$config.snapRadius:i.x+Dr.config$$module$build$src$core$config.snapRadius,i.y+=2*Dr.config$$module$build$src$core$config.snapRadius,s.moveBy(i.x,i.y)}finally{Dr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&N(new(B(Dr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}},ri=function(t){return{text:Dr.Msg$$module$build$src$core$msg.REMOVE_COMMENT,enabled:!0,callback:function(){Dr.setGroup$$module$build$src$core$events$utils(!0),t.dispose(),Dr.setGroup$$module$build$src$core$events$utils(!1)}}},li=function(t){return{text:Dr.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,enabled:!0,callback:function(){const e=t.toCopyData();e&&Ls(e,t.workspace)}}},ai=function(t,e){const s={enabled:!0};return s.text=Dr.Msg$$module$build$src$core$msg.ADD_COMMENT,s.callback=function(){const s=new Ec(t,Dr.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT,Ec.DEFAULT_SIZE,Ec.DEFAULT_SIZE);var i=t.getInjectionDiv().getBoundingClientRect();i=new ua(e.clientX-i.left,e.clientY-i.top);const o=t.getOriginOffsetInPixels();(i=ua.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(Ia.CIRCLE,{cx:i.x,cy:i.y,r:0,fill:"none",stroke:"#888","stroke-width":10},e.getParentSvg());t=it(Ia.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*s},o),e=it(Ia.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},o),t.beginElement(),e.beginElement(),setTimeout((()=>{at(o)}),150)}},Pi=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),xh=t,Bi(t,e,new Date)}},Bi=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)})`,Dh=setTimeout(Bi,10,t,e,s)),t.getSvgRoot().setAttribute("transform",`${t.getTranslation()} ${o}`)},Fi=function(){xh&&(Dh&&(clearTimeout(Dh),Dh=null),xh.getSvgRoot().setAttribute("transform",xh.getTranslation()),xh=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;ieu&&lo()}else Zh!==qh&&(clearTimeout(zh),jh=t.pageX,Jh=t.pageY,zh=setTimeout(go,su))},ro=function(){Zh=qh=null,lo()},lo=function(){Wh&&(Wh=!1,ou&&(ou.style.display="none")),zh&&(clearTimeout(zh),zh=0)},ao=function(){lo(),Xh=!0},co=function(){Xh=!1},ho=function(){ou&&qh&&("function"==typeof Vh?Vh(ou,qh):uo())},uo=function(){var t=Zi(qh);t=(t=Dr.wrap$$module$build$src$core$utils$string(t,Yh)).split("\n");for(let e=0;es+window.scrollY&&(o-=ou.offsetHeight+2*tu),t?i=Math.max(iu-window.scrollX,i):i+ou.offsetWidth>e+window.scrollX-2*iu&&(i=e-ou.offsetWidth-2*iu),{x:i,y:o}},go=function(){if(!Xh&&(Zh=qh,ou)){ou.textContent="",ho();var t=qh.RTL;ou.style.direction=t?"rtl":"ltr",ou.style.display="block",Wh=!0;var{x:e,y:s}=po(t);ou.style.left=e+"px",ou.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 _u},Eo=function(t){_u=t},fo=function(){return Tu},bo=function(t){Tu=t},$o=function(t){t=`${t}`.toLowerCase().trim();var e=mu[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)},Oo=function(t){return(t=$o(t))?[(t=parseInt(t.substr(1),16))>>16,t>>8&255,255&t]:[0,0,0]},So=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=Oo(t),e=Oo(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},Ro=function(t){return So(t,_u,255*Tu)},ko=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 Dr.Msg$$module$build$src$core$msg?"string"==typeof(n=Dr.Msg$$module$build$src$core$msg[l])?Array.prototype.push.apply(i,ko(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:So(s,mo(),255*fo())};if(s=$o(e))return{hue:null,hex:s};throw s='Invalid colour: "'+e+'"',t!==e&&(s+=' (from "'+t+'")'),Error(s)},Lo=function(t){return void 0!==t.getProcedureModel&&void 0!==t.doProcedureUpdate&&void 0!==t.isProcedureDef},wo=function(t){return void 0!==t.startPublishing&&void 0!==t.stopPublishing},Mo=function(e,s){t(Ur.FIELD,e,s)},Do=function(t){i(Ur.FIELD,t)},Dr.fromJson$$module$build$src$core$field_registry=function(t){return Cu.fromJsonInternal(t)},xo=function(t){const e=l(Ur.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},Po=function(t){let e=!1;const s=t.map((([t,s])=>"string"==typeof t?[No(t),s]:(e=!0,[null!==t.alt?Object.assign({},t,{alt:No(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:Bo(s,t,n),prefix:o,suffix:i})},Bo=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=>{!Lo(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=>{!Lo(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"})},Dr.findLegalName$$module$build$src$core$procedures=function(t,e){if(e.isInFlyout)return t;for(t=t||Dr.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)&&Dr.Names$$module$build$src$core$names.equals(i.getProcedureDef()[0],t))return!0;s=s&&Lo(s)?null==s?void 0:s.getProcedureModel():void 0;for(const i of e.getProcedureMap().getProcedures())if(i!==s&&Dr.Names$$module$build$src$core$names.equals(i.getName(),t))return!0;return!1},Dr.rename$$module$build$src$core$procedures=function(t){var e=this.getSourceBlock();if(!e)throw new $u;t=t.trim();const s=Dr.findLegalName$$module$build$src$core$procedures(t,e);Lo(e)&&!e.isInsertionMarker()&&e.getProcedureModel().setName(s);const i=this.getValue();if(i!==t&&i!==s)for(t=e.workspace.getAllBlocks(!1),e=0;ebn(e,t)||oe(e)&&Dr.Names$$module$build$src$core$names.equals(e.getProcedureCall(),t)))},bn=function(t,e){return Lo(t)&&!t.isProcedureDef()&&t.getProcedureModel()&&Dr.Names$$module$build$src$core$names.equals(t.getProcedureModel().getName(),e)},Dr.mutateCallers$$module$build$src$core$procedures=function(t){const e=y();var s=t.getProcedureDef()[0];const i=t.mutationToDom(!0);t=fn(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))&&(k(!1),N(new(B(Dr.CHANGE$$module$build$src$core$events$utils))(n,"mutation",null,s,o)),k(e))}},Dr.getDefinition$$module$build$src$core$procedures=function(t,e){for(const s of e.getAllBlocks(!1))if(Lo(s)&&s.isProcedureDef()&&Dr.Names$$module$build$src$core$names.equals(s.getProcedureModel().getName(),t)||ie(s)&&Dr.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],t))return s;return null},$n=function(t){return t.isDynamic},In=function(t){return void 0!==t.pathDown&&void 0!==t.pathUp},On=function(t){return void 0!==t.pathLeft&&void 0!==t.pathRight},Sn=function(t){let e=t.outputConnection;return(!e||t.previousConnection&&t.previousConnection.isConnected())&&(e=t.previousConnection),e},Cn=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},kn=function(t,e){let s;for(;s=Rn(t,e);)if(!(t=s.targetBlock())||t.isShadow())return s;return null},yn=function(e,s){t(Ur.RENDERER,e,s)},Nn=function(t){i(Ur.RENDERER,t)},vn=function(t,e,s){return(t=new(r(Ur.RENDERER,t))(t)).init(e,s),t},An=function(t){he(t.getTargetWorkspace(),void 0,"String")},Ln=function(t){he(t.getTargetWorkspace(),void 0,"Number")},wn=function(t){he(t.getTargetWorkspace(),void 0,"Colour")},Mn=function(t){let e=[],s=document.createElement("button");return s.setAttribute("text",Dr.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",Dr.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",Dr.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",Ln),t.registerButtonCallback("CREATE_VARIABLE_COLOUR",wn),t=Dn(t),e.concat(t)},Dn=function(t){const e=[];if(0<(t=t.getAllVariables()).length){if(Wr.variables_set_dynamic){var s=t[t.length-1];const i=Dr.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(Wr.variables_get_dynamic){t.sort(cc.compareByName);for(let i,o=0;i=t[o];o++)(s=Dr.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},xn=function(t){t.resizeContents()},Pn=function(t){return void 0!==t.toCopyData},Bn=function(){Rp.registry.register({name:ap.ESCAPE,preconditionFn:t=>!t.options.readOnly,callback:t=>(t.hideChaff(),!0),keyCodes:[Mu.ESC]})},Fn=function(){Rp.registry.register({name:ap.DELETE,preconditionFn(t){const e=T();return!t.options.readOnly&&null!=e&&e.isDeletable()},callback:(t,e)=>(e.preventDefault(),!lu.inProgress()&&(T().checkAndDelete(),!0)),keyCodes:[Mu.DELETE,Mu.BACKSPACE]})},Un=function(){const t=Rp.registry.createSerializedKey(Mu.C,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.C,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.C,[Mu.META]);Rp.registry.register({name:ap.COPY,preconditionFn(t){const e=T();return!t.options.readOnly&&!lu.inProgress()&&null!=e&&e.isDeletable()&&e.isMovable()&&Pn(e)},callback:(t,e)=>(e.preventDefault(),t.hideChaff(),!(!(e=T())||!Pn(e)||(kp=e.toCopyData(),yp=t,!kp))),keyCodes:[t,e,s]})},Hn=function(){const t=Rp.registry.createSerializedKey(Mu.X,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.X,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.X,[Mu.META]);Rp.registry.register({name:ap.CUT,preconditionFn(t){const e=T();return!t.options.readOnly&&!lu.inProgress()&&null!=e&&e instanceof lp&&e.isDeletable()&&e.isMovable()&&!e.workspace.isFlyout},callback(t){const e=T();return!(!e||!Pn(e)||(kp=e.toCopyData(),yp=t,e.checkAndDelete(),0))},keyCodes:[t,e,s]})},Gn=function(){const t=Rp.registry.createSerializedKey(Mu.V,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.V,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.V,[Mu.META]);Rp.registry.register({name:ap.PASTE,preconditionFn:t=>!t.options.readOnly&&!lu.inProgress(),callback:()=>!(!kp||!yp||!Ls(kp,yp)),keyCodes:[t,e,s]})},Vn=function(){const t=Rp.registry.createSerializedKey(Mu.Z,[Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.Z,[Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.Z,[Mu.META]);Rp.registry.register({name:ap.UNDO,preconditionFn:t=>!t.options.readOnly&&!lu.inProgress(),callback:t=>(t.hideChaff(),t.undo(!1),!0),keyCodes:[t,e,s]})},Wn=function(){const t=Rp.registry.createSerializedKey(Mu.Z,[Mu.SHIFT,Mu.CTRL]),e=Rp.registry.createSerializedKey(Mu.Z,[Mu.SHIFT,Mu.ALT]),s=Rp.registry.createSerializedKey(Mu.Z,[Mu.SHIFT,Mu.META]),i=Rp.registry.createSerializedKey(Mu.Y,[Mu.CTRL]);Rp.registry.register({name:ap.REDO,preconditionFn:t=>!lu.inProgress()&&!t.options.readOnly,callback:t=>(t.hideChaff(),t.undo(!0),!0),keyCodes:[t,e,s,i]})},Xn=function(){Bn(),Fn(),Un(),Hn(),Gn(),Vn(),Wn()},Yn=function(t){const e={id:t.getId(),name:t.getName(),returnTypes:t.getReturnTypes()};return t.getParameters().length?(e.parameters=t.getParameters().map((t=>Kn(t))),e):e},Kn=function(t){const e={id:t.getId(),name:t.getName()};return t.getTypes().length?(e.types=t.getTypes(),e):e},zn=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(jn(e,n,i),o);return t},jn=function(t,e,s){return t=new t(s,e.name,e.id),e.types&&t.setTypes(e.types),t},Jn=function(t){const e=Object.create(null),s=a(Ur.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},qn=function(t,e,{recordUndo:s=!1}={}){var i=a(Ur.SERIALIZER,!0);if(i){i=Object.entries(i).sort(((t,e)=>e[1].priority-t[1].priority));var o=y();k(s),(s=Dr.getGroup$$module$build$src$core$events$utils())||Dr.setGroup$$module$build$src$core$events$utils(!0),dt(),e instanceof jd&&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 jd&&e.setResizesEnabled(!0),pt(),N(new(B(ml))(e)),Dr.setGroup$$module$build$src$core$events$utils(s),k(o)}},Zn=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!==El.indexOf(null!=(s=e.type)?s:"")){s=i.getScrollMetrics(!0);const o=tr(t,e);o&&(i=Dr.getGroup$$module$build$src$core$events$utils()||!1,Dr.setGroup$$module$build$src$core$events$utils(e.group),Zn(t,s,o)&&!e.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),Dr.setGroup$$module$build$src$core$events$utils(i))}else e.type===dl&&e.scale&&e.oldScale&&e.scale>e.oldScale&&er(t)}},tr=function(t,e){let s=null;switch(e.type){case Dr.CREATE$$module$build$src$core$events$utils:case Dr.MOVE$$module$build$src$core$events$utils:(s=t.getBlockById(e.blockId))&&(s=s.getRootBlock());break;case pl:case Tl:s=t.getCommentById(e.commentId)}return s},er=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++)Zn(t,e,i)}},sr=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(...sr(i,ua.sum(e,i.relativeCoords)));return s},ir=function(){gh.registry.register({displayText:()=>Dr.Msg$$module$build$src$core$msg.UNDO,preconditionFn:t=>0Dr.Msg$$module$build$src$core$msg.REDO,preconditionFn:t=>0Dr.Msg$$module$build$src$core$msg.CLEAN_UP,preconditionFn:t=>t.workspace.isMovable()?1Dr.Msg$$module$build$src$core$msg.COLLAPSE_ALL,preconditionFn(t){if(t.workspace.options.collapse){t=t.workspace.getTopBlocks(!1);for(let e=0;eDr.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=hr(t.workspace).length)?Dr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Dr.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${t}`):"",preconditionFn:t=>t.workspace&&0e.length?ur(e):qt(Dr.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(e.length)),(function(t){t&&ur(e)}))}},scopeType:gh.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},pr=function(){ir(),or(),nr(),lr(),ar(),dr()},gr=function(){gh.registry.register({displayText:()=>Dr.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&&Ls(e,t.block.workspace)}},scopeType:gh.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},_r=function(){gh.registry.register({displayText:t=>t.block.hasIcon(Hu.TYPE)?Dr.Msg$$module$build$src$core$msg.REMOVE_COMMENT:Dr.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(Hu.TYPE)?t.setCommentText(null):t.setCommentText("")},scopeType:gh.ScopeType.BLOCK,id:"blockComment",weight:2})},Tr=function(){gh.registry.register({displayText:t=>t.block.getInputsInline()?Dr.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:Dr.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()?Dr.Msg$$module$build$src$core$msg.EXPAND_BLOCK:Dr.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:gh.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Er=function(){gh.registry.register({displayText:t=>t.block.isEnabled()?Dr.Msg$$module$build$src$core$msg.DISABLE_BLOCK:Dr.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=Dr.getGroup$$module$build$src$core$events$utils();e||Dr.setGroup$$module$build$src$core$events$utils(!0),t.setEnabled(!t.isEnabled()),Dr.setGroup$$module$build$src$core$events$utils(e)},scopeType:gh.ScopeType.BLOCK,id:"blockDisable",weight:5})},fr=function(){gh.registry.register({displayText(t){var e=t.block;return t=e.getDescendants(!1).length,(e=e.getNextBlock())&&(t-=e.getDescendants(!1).length),1===t?Dr.Msg$$module$build$src$core$msg.DELETE_BLOCK:Dr.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:gh.ScopeType.BLOCK,id:"blockDelete",weight:6})},br=function(){gh.registry.register({displayText:()=>Dr.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:gh.ScopeType.BLOCK,id:"blockHelp",weight:7})},$r=function(){gr(),_r(),Tr(),mr(),Er(),fr(),br()},Ir=function(){pr(),$r()},Or=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 pu(e||{}),(e=document.createElement("div")).className="injectionDiv",e.tabIndex=0,Ps(e,qc.LABEL,Dr.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),s.appendChild(e),s=Sr(e,t);const o=Cr(e,s,t);return Rr(o),_(o),b(o),e.addEventListener("focusin",(function(){_(o)})),o},Sr=function(t,e){t.setAttribute("dir","LTR"),et(e.hasCss,e.pathToMedia),t=it(Ia.SVG,{xmlns:_a,"xmlns:html":Ta,"xmlns:xlink":ma,version:"1.1",class:"blocklySvg",tabindex:"0"},t);const s=it(Ia.DEFS,{},t),i=String(Math.random()).substring(2);return e.gridPattern=au.createDom(i,e.gridOptions,s),t},Cr=function(t,e,s){s.parentWorkspace=null;const i=(s=new jd(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(Ia.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)),b(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),wi(),Js(),b(t),er(t)})),t.setResizeHandlerWrapper(s),yr(),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 Dp(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&&Nr(e.pathToMedia,t)},kr=function(t){const e=g();e&&!(j(t)||e.rendered&&!e.isVisible())&&Rp.registry.onKeyDown(e,t)},yr=function(){vg||(Y(document,"scroll",null,(function(){const t=u();for(let e,s=0;e=t[s];s++)e instanceof jd&&e.updateInverseScreenCTM()})),Y(document,"keydown",null,kr),K(document,"touchend",null,H),K(document,"touchcancel",null,H),ql&&Y(window,"orientationchange",document,(function(){b(g())}))),vg=!0},Nr=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))},vr=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},Lr=function(t){return t.isSelectable()},wr=function(t){g().hideChaff(t)},(Mr=Mr||{}).scope={},Mr.ASSUME_ES5=!1,Mr.ASSUME_NO_NATIVE_MAP=!1,Mr.ASSUME_NO_NATIVE_SET=!1,Mr.SIMPLE_FROUND_POLYFILL=!1,Mr.ISOLATE_POLYFILLS=!1,Mr.FORCE_POLYFILL_PROMISE=!1,Mr.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,Mr.defineProperty=Mr.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,s){return t==Array.prototype||t==Object.prototype||(t[e]=s.value),t},Mr.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,Mr.propertyToPolyfillSymbol[o]=Mr.IS_SYMBOL_NATIVE?Mr.global.Symbol(o):Mr.POLYFILL_PREFIX+s+"$"+o),Mr.defineProperty(i,Mr.propertyToPolyfillSymbol[o],{configurable:!0,writable:!0,value:e})))},Mr.polyfill("globalThis",(function(t){return t||Mr.global}),"es_2020","es3"),Mr.arrayIteratorImpl=function(t){var e=0;return function(){return e{const t=[];for(let e=0;20>e;e++)t[e]=Il.charAt(88*Math.random());return t.join("")}},Sl=0,Cl={TEST_ONLY:Ol};Cl.genUid=R,Cl.getNextUniqueId=C,Jr="",qr=!0,Zr=0,Dr.CREATE$$module$build$src$core$events$utils="create",Dr.CREATE$$module$build$src$core$events$utils,Dr.DELETE$$module$build$src$core$events$utils="delete",Dr.DELETE$$module$build$src$core$events$utils,Dr.CHANGE$$module$build$src$core$events$utils="change",Dr.CHANGE$$module$build$src$core$events$utils,Qr="block_field_intermediate_change",Dr.MOVE$$module$build$src$core$events$utils="move",Dr.MOVE$$module$build$src$core$events$utils,tl="var_create",el="var_delete",sl="var_rename",il="ui",ol="drag",nl="selected",rl="click",ll="marker_move",al="bubble_open",cl="trashcan_open",hl="toolbox_item_select",ul="theme_change",dl="viewport_change",pl="comment_create",gl="comment_delete",_l="comment_change",Tl="comment_move",ml="finished_loading",El=[Dr.CREATE$$module$build$src$core$events$utils,Dr.MOVE$$module$build$src$core$events$utils,pl,Tl],bl={FIRE_QUEUE:fl=[],fireNow:A,fireInternal:v,setGroupInternal:D},($l={BLOCK_CHANGE:Dr.CHANGE$$module$build$src$core$events$utils,BLOCK_CREATE:Dr.CREATE$$module$build$src$core$events$utils,BLOCK_DELETE:Dr.DELETE$$module$build$src$core$events$utils,BLOCK_DRAG:ol,BLOCK_FIELD_INTERMEDIATE_CHANGE:Qr,BLOCK_MOVE:Dr.MOVE$$module$build$src$core$events$utils,BUBBLE_OPEN:al,BUMP_EVENTS:El,CHANGE:Dr.CHANGE$$module$build$src$core$events$utils,CLICK:rl,COMMENT_CHANGE:_l,COMMENT_CREATE:pl,COMMENT_DELETE:gl,COMMENT_MOVE:Tl,CREATE:Dr.CREATE$$module$build$src$core$events$utils,DELETE:Dr.DELETE$$module$build$src$core$events$utils,FINISHED_LOADING:ml,MARKER_MOVE:ll,MOVE:Dr.MOVE$$module$build$src$core$events$utils,SELECTED:nl,TEST_ONLY:bl,THEME_CHANGE:ul,TOOLBOX_ITEM_SELECT:hl,TRASHCAN_OPEN:cl,UI:il,VAR_CREATE:tl,VAR_DELETE:el,VAR_RENAME:sl,VIEWPORT_CHANGE:dl}).clearPendingUndo=w,$l.disable=Dr.disable$$module$build$src$core$events$utils,$l.disableOrphans=F,$l.enable=Dr.enable$$module$build$src$core$events$utils,$l.filter=L,$l.fire=N,$l.fromJson=P,$l.get=B,$l.getDescendantIds=x,$l.getGroup=Dr.getGroup$$module$build$src$core$events$utils,$l.getRecordUndo=y,$l.isEnabled=M,$l.setGroup=Dr.setGroup$$module$build$src$core$events$utils,$l.setRecordUndo=k;var Rl,kl,yl=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Dr.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}},Nl=class extends yl{constructor(t){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=void 0===t,this.workspaceId=t||""}},vl=class extends Nl{constructor(t,e,s){null===(e=t?t.workspace.id:e)&&(e=void 0),super(e),this.type=rl,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 vl)).targetType=t.targetType,e.blockId=t.blockId,e}};(kl=Rl||(Rl={})).BLOCK="block",kl.WORKSPACE="workspace",kl.ZOOM_CONTROLS="zoom_controls",t(Ur.EVENT,rl,vl);var Al={};Al.Click=vl,Al.ClickTarget=Rl;var Ll,wl,Ml,Dl,xl,Pl,Bl,Fl,Ul,Hl,Gl=750,Vl="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Wl=null,Xl={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Yl=0,Kl={TOUCH_ENABLED:Vl,TOUCH_MAP:Xl};Kl.checkTouchIdentifier=X,Kl.clearTouchIdentifier=G,Kl.getTouchIdentifierFromEvent=W,Kl.longStart=U,Kl.longStop=H,Kl.shouldHandleEvent=V,function(t){function e(t){return-1!==s.indexOf(t.toUpperCase())}const s=(Ll=t).toUpperCase();wl=e("JavaFX"),Ml=e("WebKit"),Dl=e("Gecko")&&!Ml,xl=e("Android"),t=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Pl=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}};la.Capability=ra;var aa=!1,ca='\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',ha={};ha.inject=et,ha.register=tt;var ua=class{constructor(t,e){this.x=t,this.y=e}clone(){return new ua(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 ua(t.x-e.x,t.y-e.y)}static sum(t,e){return new ua(t.x+e.x,t.y+e.y)}},da=new Set,pa={};pa.warn=st;var ga,_a="http://www.w3.org/2000/svg",Ta="http://www.w3.org/1999/xhtml",ma="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"}(ga||(ga={}));var Ea=null,fa=0,ba=null,$a={HTML_NS:Ta};$a.NodeType=ga,$a.SVG_NS=_a,$a.XLINK_NS=ma,$a.addClass=ot,$a.containsNode=ht,$a.createSvgElement=it,$a.getFastTextWidth=_t,$a.getFastTextWidthWithSizeString=Tt,$a.getTextWidth=gt,$a.hasClass=lt,$a.insertAfter=ct,$a.measureFontMetrics=mt,$a.removeClass=rt,$a.removeClasses=nt,$a.removeNode=at,$a.setCssTransform=ut,$a.startTextWidthCache=dt,$a.stopTextWidthCache=pt;var Ia=class{constructor(t){this.tagName=t}toString(){return this.tagName}};Ia.ANIMATE=new Ia("animate"),Ia.CIRCLE=new Ia("circle"),Ia.CLIPPATH=new Ia("clipPath"),Ia.DEFS=new Ia("defs"),Ia.FECOMPOSITE=new Ia("feComposite"),Ia.FECOMPONENTTRANSFER=new Ia("feComponentTransfer"),Ia.FEFLOOD=new Ia("feFlood"),Ia.FEFUNCA=new Ia("feFuncA"),Ia.FEGAUSSIANBLUR=new Ia("feGaussianBlur"),Ia.FEPOINTLIGHT=new Ia("fePointLight"),Ia.FESPECULARLIGHTING=new Ia("feSpecularLighting"),Ia.FILTER=new Ia("filter"),Ia.FOREIGNOBJECT=new Ia("foreignObject"),Ia.G=new Ia("g"),Ia.IMAGE=new Ia("image"),Ia.LINE=new Ia("line"),Ia.PATH=new Ia("path"),Ia.PATTERN=new Ia("pattern"),Ia.POLYGON=new Ia("polygon"),Ia.RECT=new Ia("rect"),Ia.SVG=new Ia("svg"),Ia.TEXT=new Ia("text"),Ia.TSPAN=new Ia("tspan");var Oa=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&&va.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-=va.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),e=t.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(e+=va.scrollbarThickness),this.setPosition(e,t.absoluteTop+t.viewHeight-va.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-=va.scrollbarThickness),this.setScrollbarLength(Math.max(0,e)),this.setPosition(this.workspace.RTL?t.absoluteLeft+this.margin:t.absoluteLeft+t.viewWidth-va.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 ua(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}};va.scrollbarThickness=Vl?25:15,va.DEFAULT_SCROLLBAR_MARGIN=.5;var Aa={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},La={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:wa,DOMParser:Ma,XMLSerializer:Da}=globalThis;Ma&&(Aa=new Ma),Da&&(La=new Da);var xa="https://developers.google.com/blockly/xml",Pa=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,Ba={NAME_SPACE:xa};Ba.createElement=Dr.createElement$$module$build$src$core$utils$xml,Ba.createTextNode=Dr.createTextNode$$module$build$src$core$utils$xml,Ba.domToText=Mt,Ba.injectDependencies=wt,Ba.textToDom=Dr.textToDom$$module$build$src$core$utils$xml;var Fa,Ua="categoryToolbox",Ha="flyoutToolbox";!function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM",t[t.LEFT=2]="LEFT",t[t.RIGHT=3]="RIGHT"}(Fa||(Fa={}));var Ga,Va,Wa,Xa={hasCategoriesInternal:Ut},Ya={};Ya.Position=Fa,Ya.TEST_ONLY=Xa,Ya.convertFlyoutDefToJsonArray=Bt,Ya.convertToolboxDefToJson=xt,Ya.hasCategories=Ft,Ya.isCategoryCollapsible=Ht,Ya.parseToolboxTree=Xt,function(t){t[t.TOP=0]="TOP",t[t.BOTTOM=1]="BOTTOM"}(Ga||(Ga={})),function(t){t[t.LEFT=0]="LEFT",t[t.RIGHT=1]="RIGHT"}(Va||(Va={})),function(t){t[t.UP=0]="UP",t[t.DOWN=1]="DOWN"}(Wa||(Wa={}));var Ka={};Ka.bumpDirection=Wa,Ka.bumpPositionRect=zt,Ka.getCornerOppositeToolbox=Kt,Ka.getStartPositionRect=Yt,Ka.horizontalPosition=Va,Ka.verticalPosition=Ga;var za=96,ja=124,Ja="sprites.png",qa=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(Ia.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:[la.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 Oa(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 Sa(this.WIDTH,o),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,t,this.workspace),i=i.vertical,e=zt(t,this.MARGIN_VERTICAL,i===Ga.TOP?Wa.DOWN:Wa.UP,e),i===Ga.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(Ia.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const e=it(Ia.CLIPPATH,{id:"blocklyZoomoutClipPath"+t},this.zoomOutGroup);it(Ia.RECT,{width:32,height:32},e),it(Ia.IMAGE,{width:za,height:ja,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+t+")"},this.zoomOutGroup).setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),this.boundEvents.push(Y(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(t){this.zoomInGroup=it(Ia.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const e=it(Ia.CLIPPATH,{id:"blocklyZoominClipPath"+t},this.zoomInGroup);it(Ia.RECT,{width:32,height:32},e),it(Ia.IMAGE,{width:za,height:ja,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+t+")"},this.zoomInGroup).setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),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(Ia.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const e=it(Ia.CLIPPATH,{id:"blocklyZoomresetClipPath"+t},this.zoomResetGroup);it(Ia.RECT,{width:32,height:32},e),it(Ia.IMAGE,{width:za,height:ja,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+t+")"},this.zoomResetGroup).setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),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(B(rl))(null,this.workspace.id,"zoom_controls");N(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 Za=class{constructor(t){this.name=t}toString(){return this.name}equals(t){return this.name===t.toString()}};Za.MUTATOR=new Za("mutator"),Za.WARNING=new Za("warning"),Za.COMMENT=new Za("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"}(Dr.inputTypes$$module$build$src$core$inputs$input_types||(Dr.inputTypes$$module$build$src$core$inputs$input_types={})),Dr.inputTypes$$module$build$src$core$inputs$input_types;var Qa,tc,ec=function(t,e){window.alert(t),e&&e()},sc=function(t,e){e(window.confirm(t))},ic=function(t,e,s){s(window.prompt(t,e))},oc={confirmInternal:Zt},nc={TEST_ONLY:oc};nc.alert=jt,nc.confirm=qt,nc.prompt=te,nc.setAlert=Jt,nc.setConfirm=Qt,nc.setPrompt=ee,Dr.Msg$$module$build$src$core$msg=Object.create(null),Qa=function(t){Object.keys(t).forEach((function(e){Dr.Msg$$module$build$src$core$msg[e]=t[e]}))},tc={Msg:Dr.Msg$$module$build$src$core$msg,setLocale:Qa};var rc={};rc.isLegacyProcedureCallBlock=oe,rc.isLegacyProcedureDefBlock=ie;var lc=class extends yl{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 lc)).varId=t.varId,e}},ac=class extends lc{constructor(t){super(t),this.type=tl,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 ac)).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(Ur.EVENT,tl,ac);var cc=class{constructor(t,e,s,i){this.workspace=t,this.name=e,this.type=s||"",this.id_=i||R()}getId(){return this.id_}static compareByName(t,e){return t.name.localeCompare(e.name,void 0,{sensitivity:"base"})}},hc="VARIABLE",uc="ijkmnopqrstuvwxyzabcdefgh",dc={generateUniqueNameInternal:ae},pc={CATEGORY_NAME:hc,TEST_ONLY:dc,VAR_LETTER_OPTIONS:uc};pc.allDeveloperVariables=Dr.allDeveloperVariables$$module$build$src$core$variables,pc.allUsedVarModels=Dr.allUsedVarModels$$module$build$src$core$variables,pc.createVariableButtonHandler=he,pc.flyoutCategory=ne,pc.flyoutCategoryBlocks=re,pc.generateUniqueName=le,pc.generateUniqueNameFromOptions=ce,pc.generateVariableFieldDom=me,pc.getAddedVariables=fe,pc.getOrCreateVariablePackage=Dr.getOrCreateVariablePackage$$module$build$src$core$variables,pc.getVariable=Dr.getVariable$$module$build$src$core$variables,pc.nameUsedWithAnyType=pe,pc.nameUsedWithConflictingParam=ge,pc.promptName=ue,pc.renameVariable=Dr.renameVariable$$module$build$src$core$variables;var gc=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:R(),t.addTopComment(this),this.xy_=new ua(0,0),this.height_=s,this.width_=i,this.RTL=t.RTL,this.content_=e,gc.fireCreateEvent(this)}dispose(){this.disposed_||(M()&&N(new(B(gl))(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 ua(this.xy_.x,this.xy_.y)}moveBy(t,e){const s=new(B(Tl))(this);this.xy_.translate(t,e),s.recordNew(),N(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&&(N(new(B(_l))(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=Dr.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=Dr.getGroup$$module$build$src$core$events$utils();e||Dr.setGroup$$module$build$src$core$events$utils(!0);try{N(new(B(pl))(t))}finally{Dr.setGroup$$module$build$src$core$events$utils(e)}}}static fromXml(t,e){var s=gc.parseAttributes(t);return e=new gc(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),gc.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:""}}},_c=class extends Nl{constructor(t,e,s){super(s),this.type=nl,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 _c)).oldElementId=t.oldElementId,e.newElementId=t.newElementId,e}};t(Ur.EVENT,nl,_c);var Tc={};Tc.register=be,Tc.unregister=$e;var mc=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 Ec.fromXmlRendered(t.commentState,e)}};mc.TYPE="workspace-comment",be(mc.TYPE,new mc);var Ec=class extends gc{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(Ia.G,{class:"blocklyComment"}),this.workspace=t,this.svgRect_=it(Ia.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()&&N(new(B(gl))(this)),at(this.svgGroup),Dr.disable$$module$build$src$core$events$utils(),super.dispose(),Dr.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,Dr.disable$$module$build$src$core$events$utils();try{T().unselect()}finally{Dr.enable$$module$build$src$core$events$utils()}}t=new(B(nl))(t,this.id,this.workspace.id),N(t),m(this),this.addSelect()}}unselect(){if(T()===this){var t=new(B(nl))(this.id,null,this.workspace.id);N(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=kt(i);e+=t.x,s+=t.y,i=i.parentNode}while(i&&!t.hasLayer(i)&&null!==i);return this.xy_=new ua(e,s)}moveBy(t,e){const s=new(B(Tl))(this),i=this.getRelativeToSurfaceXY();this.translate(i.x+t,i.y+e),this.xy_=new ua(i.x+t,i.y+e),s.recordNew(),N(s),this.workspace.resizeContents()}translate(t,e){this.xy_=new ua(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 Oa(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:mc.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(Ia.RECT,{class:"blocklyCommentHandleTarget",x:0,y:0}),this.svgGroup.appendChild(this.svgHandleTarget),this.svgRectTarget=it(Ia.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(Ia.FOREIGNOBJECT,{x:0,y:Ec.TOP_OFFSET,class:"blocklyCommentForeignObject"});const t=document.createElementNS(Ta,"body");t.setAttribute("xmlns",Ta),t.className="blocklyMinimalBody";const e=document.createElementNS(Ta,"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(Ia.G,{class:this.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.svgGroup),it(Ia.POLYGON,{points:"0,8 8,8 8,0"},this.resizeGroup),it(Ia.LINE,{class:"blocklyResizeLine",x1:8/3,y1:7,x2:7,y2:8/3},this.resizeGroup),it(Ia.LINE,{class:"blocklyResizeLine",x1:16/3,y1:7,x2:7,y2:16/3},this.resizeGroup)}addDeleteDom(){this.deleteGroup=it(Ia.G,{class:"blocklyCommentDeleteIcon"},this.svgGroup),this.deleteIconBorder=it(Ia.CIRCLE,{class:"blocklyDeleteIconShape",r:"7",cx:"7.5",cy:"7.5"},this.deleteGroup),it(Ia.LINE,{x1:"5",y1:"10",x2:"10",y2:"5",stroke:"#fff","stroke-width":"2"},this.deleteGroup),it(Ia.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 ua(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=Ec.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+Ec.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(Ec.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;Dr.disable$$module$build$src$core$events$utils();try{const o=gc.parseAttributes(t);if(i=new Ec(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{Dr.enable$$module$build$src$core$events$utils()}return gc.fireCreateEvent(i),i}};Ec.DEFAULT_SIZE=100,Ec.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 fc=new Set,bc=new WeakSet,$c=null,Ic=null,Oc=0,Sc={};Sc.finishQueuedRenders=Oe,Sc.queueRender=Ie,Sc.triggerQueuedRenders=Se;var Cc={};Cc.appendDomToWorkspace=He,Cc.blockToDom=xe,Cc.blockToDomWithXY=we,Cc.clearWorkspaceAndLoadFromXml=Ue,Cc.deleteNext=ts,Cc.domToBlock=Dr.domToBlock$$module$build$src$core$xml,Cc.domToBlockInternal=Ge,Cc.domToPrettyText=Fe,Cc.domToText=Be,Cc.domToVariables=Ve,Cc.domToWorkspace=Dr.domToWorkspace$$module$build$src$core$xml,Cc.variablesToDom=Le,Cc.workspaceToDom=Ae;var Rc=class extends Error{},kc=class extends Rc{constructor(t){super("Expected to find a 'type' property, defining the block type"),this.state=t}},yc=class extends Rc{constructor(t,e,s){super(`The block ${e.toDevString()} is missing a(n) ${t}\nconnection`),this.block=e,this.state=s}},Nc=class extends Rc{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}},vc=class extends Rc{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}},Ac=class extends Rc{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}},Lc={};Lc.BadConnectionCheck=Nc,Lc.DeserializationError=Rc,Lc.MissingBlockType=kc,Lc.MissingConnection=yc,Lc.RealChildOfShadow=vc,Lc.UnregisteredIcon=Ac;var wc={BLOCKS:50,PROCEDURES:75,VARIABLES:100},Mc={};Mc.register=is,Mc.unregister=os;var Dc=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 Dc);var xc={};xc.BlockSerializer=Dc,xc.append=gs,xc.appendInternal=_s,xc.save=ns;var Pc=class extends yl{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 Pc)).blockId=t.blockId,e}},Bc=class extends Pc{constructor(t){super(t),this.type=Dr.CREATE$$module$build$src$core$events$utils,t&&(t.isShadow()&&(this.recordUndo=!1),this.xml=we(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=Be(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 Bc)).xml=Dr.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(!Fc(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(Ur.EVENT,Dr.CREATE$$module$build$src$core$events$utils,Bc);var Uc=class extends Nl{constructor(t,e){super(e),this.type=ul,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 Uc)).themeName=t.themeName,e}};t(Ur.EVENT,ul,Uc);var Hc,Gc=class extends Nl{constructor(t,e,s,i,o){super(i),this.type=dl,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 Gc)).viewTop=t.viewTop,e.viewLeft=t.viewLeft,e.scale=t.scale,e.oldScale=t.oldScale,e}};t(Ur.EVENT,dl,Gc),Dr.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:28,connectingSnapRadius:28,currentConnectionPreference:8,bumpDelay:250},Dr.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"}(Hc||(Hc={}));var Vc=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 ua(t.clientX,t.clientY);if(1>ua.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}},ih=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),Ps(t,qc.SELECTED,this.checkable&&this.checked||!1),Ps(t,qc.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)}},oh=null,nh=null,rh="blocklyWidgetDiv",lh="",ah="",ch={};ch.createDom=Us,ch.getDiv=Bs,ch.hide=Gs,ch.hideIfOwner=Ws,ch.isVisible=Vs,ch.positionWithAnchor=Ys,ch.repositionForWindowResize=Js,ch.show=Hs,ch.testOnly_setDiv=Fs;var hh=null,uh={},dh=null,ph={};ph.callbackFactory=Dr.callbackFactory$$module$build$src$core$contextmenu,ph.commentDeleteOption=ri,ph.commentDuplicateOption=li,ph.dispose=ni,ph.getCurrentBlock=qs,ph.hide=oi,ph.setCurrentBlock=Zs,ph.show=Qs,ph.workspaceCommentOption=ai;var gh=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}(gh||(gh={}));var _h=gh.ScopeType,Th={};Th.ContextMenuRegistry=gh,Th.ScopeType=_h;var mh={};mh.clamp=ui,mh.toDegrees=hi,mh.toRadians=ci;var Eh,fh,bh,$h=16,Ih=1,Oh=12,Sh=16,Ch=.25,Rh=null,kh=null,yh="",Nh="",vh=null,Ah=null,Lh=null,wh={getBoundsInfo:function(){const t=It(vh),e=Et(vh);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=wh.getBoundsInfo(),n=Et(Eh);return e+n.heighto.top?Ci(s,i,o,n):e+n.heightdocument.documentElement.clientTop?Ci(s,i,o,n):Ri(t,o,n)}},Mh={ANIMATION_TIME:Ch,ARROW_HORIZONTAL_PADDING:Oh,ARROW_SIZE:$h,BORDER_SIZE:Ih,PADDING_Y:Sh,TEST_ONLY:wh};Mh.clearContent=Ti,Mh.createDom=di,Mh.getContentDiv=_i,Mh.getOwner=gi,Mh.getPositionX=ki,Mh.hide=vi,Mh.hideIfOwner=Ni,Mh.hideWithoutAnimation=Ai,Mh.isVisible=yi,Mh.repositionForWindowResize=wi,Mh.setBoundsElement=pi,Mh.setColour=mi,Mh.show=Oi,Mh.showPositionedByBlock=Ei,Mh.showPositionedByField=fi;var Dh=null,xh=null,Ph={};Ph.connectionUiEffect=xi,Ph.disconnectUiEffect=Pi,Ph.disconnectUiStop=Fi,Ph.disposeUiEffect=Mi;var Bh=class{constructor(t,e){this.bubble=t,this.workspace=e,this.dragTarget_=null,this.wouldDeleteBubble_=!1,this.startXY_=this.bubble.getRelativeToSurfaceXY()}startBubbleDrag(){let t;Dr.getGroup$$module$build$src$core$events$utils()||Dr.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=ua.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,la.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=ua.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),Dr.setGroup$$module$build$src$core$events$utils(!1)}fireMoveEvent_(){if(this.bubble instanceof Ec){const t=new(B(Tl))(this.bubble);t.setOldCoordinate(this.startXY_),t.recordNew(),N(t)}}pixelsToWorkspaceUnits_(t){return t=new ua(t.x/this.workspace.scale,t.y/this.workspace.scale),this.workspace.isMutator&&t.scale(1/this.workspace.options.parentWorkspace.scale),t}},Fh=[];Fh[Hc.INPUT_VALUE]=Hc.OUTPUT_VALUE,Fh[Hc.OUTPUT_VALUE]=Hc.INPUT_VALUE,Fh[Hc.NEXT_STATEMENT]=Hc.PREVIOUS_STATEMENT,Fh[Hc.PREVIOUS_STATEMENT]=Hc.NEXT_STATEMENT;var Uh="RENAME_VARIABLE_ID",Hh="DELETE_VARIABLE_ID",Gh={};Gh.commonWordPrefix=Gi,Gh.commonWordSuffix=Vi,Gh.isNumber=Dr.isNumber$$module$build$src$core$utils$string,Gh.shortestStringLength=Hi,Gh.startsWith=Ui,Gh.wrap=Dr.wrap$$module$build$src$core$utils$string;var Vh=void 0,Wh=!1,Xh=!1,Yh=50,Kh=0,zh=0,jh=0,Jh=0,qh=null,Zh=null,Qh=0,tu=10,eu=10,su=750,iu=5,ou=null,nu={HOVER_MS:su,LIMIT:Yh,MARGINS:iu,OFFSET_X:Qh,OFFSET_Y:tu,RADIUS_OK:eu};nu.bindMouseEvents=eo,nu.block=ao,nu.createDom=to,nu.dispose=ro,nu.getCustomTooltip=ji,nu.getDiv=qi,nu.getTooltipOfObject=Zi,nu.hide=lo,nu.isVisible=Ji,nu.setCustomTooltip=zi,nu.unbindMouseEvents=so,nu.unblock=co;var ru=class{constructor(t){this.workspace=t,this.horizontalScrollEnabled_=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled_=this.workspace.isMovableVertically(),this.startScrollXY_=new ua(t.scrollX,t.scrollY)}dispose(){this.workspace=null}startDrag(){T()&&T().unselect()}endDrag(t){this.drag(t)}drag(t){if(t=ua.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)}}},lu=class{constructor(t,e){this.creatorWorkspace=e,this.mouseDownXY=new ua(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 ua(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 ua(t.clientX,t.clientY);this.updateDragDelta(e)&&(this.updateIsDragging(),H()),this.mostRecentEvent=t}updateDragDelta(t){return this.currentDragDeltaXY=ua.difference(t,this.mouseDownXY),!this.hasExceededDragRadius&&(this.hasExceededDragRadius=ua.magnitude(this.currentDragDeltaXY)>(this.flyout?Dr.config$$module$build$src$core$config.flyoutDragRadius:Dr.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(),Dr.getGroup$$module$build$src$core$events$utils()||Dr.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 ru(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(Ur.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 Bh(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 ua(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=ua.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=ua.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 ua(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){N(new(B(rl))(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 Ec&&(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()&&(Dr.getGroup$$module$build$src$core$events$utils()||Dr.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(B(rl))(this.startBlock,this.startWorkspace_.id,"block");N(t)}this.bringBlockToFront(),Dr.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}},au=class{constructor(t,e){let s,i,o;this.pattern=t,this.scale=1,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}setSpacing(t){this.spacing=t,this.update(this.scale)}setLength(t){this.length=t,this.update(this.scale)}setSnapToGrid(t){this.snapToGrid=t}shouldSnap(){return this.snapToGrid}getSpacing(){return this.spacing}getPatternId(){return this.pattern.id}update(t){this.scale=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(Ia.PATTERN,{id:"blocklyGridPattern"+t,patternUnits:"userSpaceOnUse"},s),0<(null!=(i=e.length)?i:1)&&0<(null!=(o=e.spacing)?o:0)){let s;it(Ia.LINE,{stroke:e.colour},t),null!=(s=e.length)&&s&&it(Ia.LINE,{stroke:e.colour},t)}else it(Ia.LINE,{},t);return t}},cu=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)}};cu.LOCAL_MARKER="local_marker_1";var hu={};hu.deepMerge=_o;var uu=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(Ur.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 uu(t);let i=e.base;if(i){if("string"==typeof i){let t;i=null!=(t=l(Ur.THEME,i))?t:void 0}i instanceof uu&&(_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}},du=new uu("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"}}),pu=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?Fa.TOP:Fa.BOTTOM:d===h?Fa.RIGHT:Fa.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,f,b,$=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=pu.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=pu.parseGridOptions_(t),this.zoomOptions=pu.parseZoomOptions_(t),this.toolboxPosition=d,this.theme=pu.parseThemeOptions_(t),this.renderer=T,this.rendererOverrides=null!=(f=t.rendererOverrides)?f:null,this.parentWorkspace=null!=(b=t.parentWorkspace)?b: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")),N(new gu(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())?Be(t):""}};t(Ur.EVENT,Dr.CHANGE$$module$build$src$core$events$utils,gu);var _u=.45,Tu=.65,mu={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"},Eu={};Eu.blend=Co,Eu.getHsvSaturation=mo,Eu.getHsvValue=fo,Eu.hexToRgb=Oo,Eu.hsvToHex=So,Eu.hueToHex=Ro,Eu.names=mu,Eu.parse=$o,Eu.rgbToHex=Io,Eu.setHsvSaturation=Eo,Eu.setHsvValue=bo;var fu={};fu.checkMessageReferences=vo,fu.parseBlockColour=Ao,fu.replaceMessageReferences=No,fu.tokenizeInterpolation=yo;var bu=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 Sa(0,0),t!==bu.SKIP_SETUP&&(s&&this.configure_(s),this.setValue(t),e&&this.setValidator(e))}configure_(t){t.tooltip&&this.setTooltip(No(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(Ia.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(Ia.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(Ia.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(bu))?t:this.getValue()}loadState(t){this.loadLegacyState(bu,t)||this.setValue(t)}saveLegacyState(t){return t.prototype.saveState===this.saveState&&t.prototype.toXml!==this.toXml?((t=Dr.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(Dr.textToDom$$module$build$src$core$utils$xml(e)),!0)}dispose(){let t;Ni(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_!==bu.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 Sa(0,0)}getScaledBBox(){let t;var e=this.getSourceBlock();if(!e)throw new $u;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,jl?(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 Oa(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,bu.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(t+="‏"),t):bu.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()&&N(new(B(Dr.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 $u;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 $u;this.imageElement.style.display="",this.imageElement.setAttributeNS(ma,"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+yu);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 $u;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)}};ku.CHECKMARK_OVERHANG=25,ku.MAX_MENU_HEIGHT_VH=.45,ku.ARROW_CHAR="▾";var yu=10;Mo("field_dropdown",ku);var Nu,vu=class{constructor(t,e,s){this.workspace=t,this.anchor=e,this.ownerRect=s,this.size=new Sa(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.svgRoot=it(Ia.G,{},t.getBubbleCanvas()),t=it(Ia.G,{filter:`url(#${this.workspace.getRenderer().getConstants().embossFilterId})`},this.svgRoot),this.tail=it(Ia.PATH,{},t),this.background=it(Ia.RECT,{class:"blocklyDraggable",x:0,y:0,rx:Nu.BORDER_WIDTH,ry:Nu.BORDER_WIDTH},t),this.contentContainer=it(Ia.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,Nu.MIN_SIZE),t.height=Math.max(t.height,Nu.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 Oa(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 Oa(e,s,i,t)}getScrollbarThickness(){return va.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)/Nu.TAIL_THICKNESS;h=Math.min(h,this.size.width,this.size.height)/4,i=e+(l=1-Nu.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?-Nu.TAIL_ANGLE:Nu.TAIL_ANGLE)))>2*Math.PI&&(a-=2*Math.PI),r=Math.sin(a)*n/Nu.TAIL_BEND,n=Math.cos(a)*n/Nu.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 ua(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){}};Nu=vu,vu.BORDER_WIDTH=6,vu.DOUBLE_BORDER=2*Nu.BORDER_WIDTH,vu.MIN_SIZE=Nu.DOUBLE_BORDER,vu.TAIL_THICKNESS=1,vu.TAIL_ANGLE=20,vu.TAIL_BEND=4,vu.ANCHOR_RADIUS=8;var Au=class extends vu{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 pu(t),this.validateWorkspaceOptions(e),this.svgDialog=it(Ia.SVG,{x:vu.BORDER_WIDTH,y:vu.BORDER_WIDTH},this.contentContainer),t.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new pu(t)),this.miniWorkspace.internalIsMutator=!0,t=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(t),e.languageTree&&(t.insertBefore(this.miniWorkspace.addFlyout(Ia.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 ua.sum(this.workspaceLocation,new ua(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new Oa(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=>{Dr.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===Dr.CREATE$$module$build$src$core$events$utils||t.type===Dr.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=Dr.getGroup$$module$build$src$core$events$utils();t||Dr.setGroup$$module$build$src$core$events$utils(!0);var e=gu.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var s=gu.getExtraBlockState_(this.sourceBlock);e!==s&&N(new(B(Dr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock,"mutation",null,e,s)),Dr.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()}},Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=Za.MUTATOR,Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon;var Lu=Object.create(null),wu={allExtensions:Lu};Dr.register$$module$build$src$core$extensions("parent_tooltip_when_inline",Qo);var Mu,Du={TEST_ONLY:wu};Du.apply=Go,Du.buildTooltipForDropdown=Dr.buildTooltipForDropdown$$module$build$src$core$extensions,Du.buildTooltipWithFieldText=Dr.buildTooltipWithFieldText$$module$build$src$core$extensions,Du.isRegistered=Ho,Du.register=Dr.register$$module$build$src$core$extensions,Du.registerMixin=Dr.registerMixin$$module$build$src$core$extensions,Du.registerMutator=Dr.registerMutator$$module$build$src$core$extensions,Du.runAfterPageLoad=qo,Du.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"}(Mu||(Mu={}));var xu={};xu.arc=an,xu.curve=en,xu.line=rn,xu.lineOnAxis=ln,xu.lineTo=nn,xu.moveBy=on,xu.moveTo=sn,xu.point=tn;var Pu={};Pu.Coordinate=ua,Pu.KeyCodes=Mu,Pu.Rect=Oa,Pu.Size=Sa,Pu.Svg=Ia,Pu.aria=th,Pu.array=na,Pu.browserEvents=oa,Pu.colour=Eu,Pu.deprecation=pa,Pu.dom=$a,Pu.extensions=Du,Pu.idGenerator=Cl,Pu.math=mh,Pu.object=hu,Pu.parsing=fu,Pu.string=Gh,Pu.style=Ra,Pu.svgMath=Na,Pu.svgPaths=xu,Pu.toolbox=Ya,Pu.userAgent=ea,Pu.xml=Ba;var Bu={};Bu.register=cn,Bu.unregister=hn;var Fu=class extends vu{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(Ia.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:vu.BORDER_WIDTH},t)}createSpans(t,e){return e.split("\n").map((e=>{const s=it(Ia.TSPAN,{dy:"1em",x:vu.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+vu.BORDER_WIDTH}`)}updateBubbleSize(){const t=this.paragraph.getBBox();this.setSize(new Sa(t.width+2*vu.BORDER_WIDTH,t.height+2*vu.BORDER_WIDTH),!0)}},Uu=class extends vu{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 Sa(160+vu.DOUBLE_BORDER,80+vu.DOUBLE_BORDER),this.MIN_SIZE=new Sa(45+vu.DOUBLE_BORDER,20+vu.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(Ia.FOREIGNOBJECT,{x:vu.BORDER_WIDTH,y:vu.BORDER_WIDTH},t);const e=document.createElementNS(Ta,"body");e.setAttribute("xmlns",Ta),e.className="blocklyMinimalBody";const s=document.createElementNS(Ta,"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(Ia.G,{class:this.workspace.RTL?"blocklyResizeSW":"blocklyResizeSE"},t);const e=2*vu.BORDER_WIDTH;return it(Ia.POLYGON,{points:`0,${e} ${e},${e} ${e},0`},t),it(Ia.LINE,{class:"blocklyResizeLine",x1:e/3,y1:e-1,x2:e-1,y2:e/3},t),it(Ia.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-vu.DOUBLE_BORDER,i=t.height-vu.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(${vu.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 ua(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 Sa(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 Hu=class extends Su{constructor(t){super(t),this.sourceBlock=t,this.textBubble=this.textInputBubble=null,this.text="",this.bubbleSize=new Sa(160,80),this.bubbleVisiblity=!1}getType(){return Hu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(Ia.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),it(Ia.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(Ia.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 Hu.WEIGHT}getSize(){return new Sa(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;N(new(B(Dr.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 Sa(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&&(N(new(B(Dr.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(),N(new(B(al))(this.sourceBlock,t,"comment"))))}showEditableBubble(){this.textInputBubble=new Uu(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 Fu(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 ua.sum(this.workspaceLocation,new ua(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new Oa(t.y,t.y+t.height,t.x,t.x+t.width)}};Hu.TYPE=Za.COMMENT,Hu.WEIGHT=3,cn(Hu.TYPE,Hu);var Gu=class extends Su{constructor(t){super(t),this.sourceBlock=t,this.textMap=new Map,this.textBubble=null}getType(){return Gu.TYPE}initView(t){this.svgRoot||(super.initView(t),it(Ia.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(Ia.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),it(Ia.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 Gu.WEIGHT}getSize(){return new Sa(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 Fu(this.getText(),this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.applyColour();else{let t;null==(t=this.textBubble)||t.dispose(),this.textBubble=null}N(new(B(al))(this.sourceBlock,t,"warning"))}}getAnchorLocation(){return ua.sum(this.workspaceLocation,new ua(8.5,8.5))}getBubbleOwnerRect(){const t=this.sourceBlock.getSvgRoot().getBBox();return new Oa(t.y,t.y+t.height,t.x,t.x+t.width)}};Gu.TYPE=Za.WARNING,Gu.WEIGHT=2;var Vu=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}},Wu={};Wu.DuplicateIconType=Vu;var Xu,Yu,Ku={};Ku.CommentIcon=Hu,Ku.Icon=Su,Ku.IconType=Za,Ku.MutatorIcon=Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon,Ku.WarningIcon=Gu,Ku.exceptions=Wu,Ku.registry=Bu,Xu="PROCEDURE",Dr.DEFAULT_ARG$$module$build$src$core$procedures="x",(Yu={CATEGORY_NAME:Xu,DEFAULT_ARG:Dr.DEFAULT_ARG$$module$build$src$core$procedures}).ObservableProcedureMap=Ou,Yu.allProcedures=un,Yu.findLegalName=Dr.findLegalName$$module$build$src$core$procedures,Yu.flyoutCategory=_n,Yu.getCallers=fn,Yu.getDefinition=Dr.getDefinition$$module$build$src$core$procedures,Yu.isNameUsed=gn,Yu.isProcedureBlock=Lo,Yu.mutateCallers=Dr.mutateCallers$$module$build$src$core$procedures,Yu.mutatorOpenListener=mn,Yu.rename=Dr.rename$$module$build$src$core$procedures;var zu=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}},ju=class{constructor(t){this.centerline=this.xPos=this.height=this.width=0,this.constants_=t,this.type=zu.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},Ju=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=zu.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(zu.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;","}"]}},md={};md.ConstantProvider=Td,md.isDynamicShape=$n,md.isNotch=On,md.isPuzzleTab=In;var Ed=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.updateConnectionHighlights(),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=Dr.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))&&(Dr.disable$$module$build$src$core$events$utils(),this.maybeHidePreview(s),this.maybeShowPreview(s),Dr.enable$$module$build$src$core$events$utils())}createMarkerBlock(t){var e=t.type;let s;Dr.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){Dr.disable$$module$build$src$core$events$utils();try{t.dispose()}finally{Dr.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"}(Md||(Md={}));var Dd=Md.PREVIEW_TYPE,xd={};xd.InsertionMarkerManager=Md,xd.PreviewType=Dd;var Pd=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 Td}makeRenderInfo_(t){return new Sd(this,t)}makeDrawer_(t,e){return new Ed(t,e)}makeMarkerDrawer(t,e){return new kd(t,this.getConstants(),e)}makePathObject(t,e){return new yd(t,e,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(t){return!0}orphanCanConnectAtEnd(t,e,s){return!!Nd.getConnectionForOrphanedConnection(t,s===Hc.OUTPUT_VALUE?e.outputConnection:e.previousConnection)}getConnectionPreviewMethod(t,e,s){return st("getConnectionPreviewMethod","v10","v12","an IConnectionPreviewer, if it fulfills your use case."),e.type===Hc.OUTPUT_VALUE||e.type===Hc.PREVIOUS_STATEMENT?!t.isConnected()||this.orphanCanConnectAtEnd(s,t.targetBlock(),e.type)?Md.PREVIEW_TYPE.INSERTION_MARKER:Md.PREVIEW_TYPE.REPLACEMENT_FADE:Md.PREVIEW_TYPE.INSERTION_MARKER}render(t){const e=this.makeRenderInfo_(t);e.measure(),this.makeDrawer_(t,e).draw()}},Bd={};Bd.BottomRow=qu,Bd.Connection=Zu,Bd.ConstantProvider=Td,Bd.Drawer=Ed,Bd.ExternalValueInput=td,Bd.Field=ed,Bd.Hat=sd,Bd.Icon=id,Bd.InRowSpacer=od,Bd.InlineInput=nd,Bd.InputConnection=Qu,Bd.InputRow=ld,Bd.JaggedEdge=ad,Bd.MarkerSvg=kd,Bd.Measurable=ju,Bd.NextConnection=cd,Bd.OutputConnection=hd,Bd.PathObject=yd,Bd.PreviousConnection=ud,Bd.RenderInfo=Sd,Bd.Renderer=Pd,Bd.RoundCorner=dd,Bd.Row=Ju,Bd.SpacerRow=pd,Bd.SquareCorner=gd,Bd.StatementInput=rd,Bd.TopRow=_d,Bd.Types=zu,Bd.init=vn,Bd.register=yn,Bd.unregister=Nn;var Fd=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()}},Ud="VARIABLE_DYNAMIC",Hd={CATEGORY_NAME:Ud};Hd.flyoutCategory=Mn,Hd.flyoutCategoryBlocks=Dn,Hd.onCreateVariableButtonClick_Colour=wn,Hd.onCreateVariableButtonClick_Number=Ln,Hd.onCreateVariableButtonClick_String=An;var Gd=class{canConnect(t,e,s,i){return this.canConnectWithReason(t,e,s,i)===Nd.CAN_CONNECT}canConnectWithReason(t,e,s,i){const o=this.doSafetyChecks(t,e);return o!==Nd.CAN_CONNECT?o:this.doTypeChecks(t,e)?s&&!this.doDragChecks(t,e,i||0)?Nd.REASON_DRAG_CHECKS_FAILED:Nd.CAN_CONNECT:Nd.REASON_CHECKS_FAILED}getErrorMessage(t,e,s){switch(t){case Nd.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case Nd.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case Nd.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case Nd.REASON_TARGET_NULL:return"Target connection is null.";case Nd.REASON_CHECKS_FAILED:return"Connection checks failed. "+e+" expected "+e.getCheck()+", found "+s.getCheck();case Nd.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case Nd.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case Nd.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 Nd.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?Nd.REASON_SELF_CONNECTION:o.type!==Fh[t.type]?Nd.REASON_WRONG_TYPE:s.workspace!==i.workspace?Nd.REASON_DIFFERENT_WORKSPACES:s.isShadow()&&!i.isShadow()?Nd.REASON_SHADOW_PARENT:o.type===Hc.OUTPUT_VALUE&&i.previousConnection&&i.previousConnection.isConnected()||o.type===Hc.PREVIOUS_STATEMENT&&i.outputConnection&&i.outputConnection.isConnected()?Nd.REASON_PREVIOUS_AND_OUTPUT:Nd.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 Hc.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(t,e);case Hc.OUTPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isInsertionMarker()||t.isConnected())return!1;break;case Hc.INPUT_VALUE:if(e.isConnected()&&!e.targetBlock().isMovable()&&!e.targetBlock().isShadow())return!1;break;case Hc.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===Kr.indexOf(e)}canConnectToPrevious_(t,e){return!(t.targetConnection||-1!==Kr.indexOf(e)||e.targetConnection&&(!(t=e.targetBlock()).isInsertionMarker()||t.getPreviousBlock()))}};t(Ur.CONNECTION_CHECKER,Fr,Gd);var Vd=class extends lc{constructor(t){super(t),this.type=el,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 Vd)).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(Ur.EVENT,el,Vd);var Wd=class extends lc{constructor(t,e){super(t),this.type=sl,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 Wd)).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(Ur.EVENT,sl,Wd);var Xd=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=Dr.getGroup$$module$build$src$core$events$utils();s||Dr.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(Ur.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(t=c(Ur.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=jd.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 qa(this);const t=this.zoomControls_.createDom();this.svgGroup_.appendChild(t)}addFlyout(t){const e=new pu({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(Ur.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(e):new(c(Ur.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(la.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();ua.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(B(dl))(e,s,t,this.id,this.oldScale);this.oldScale=t,this.oldTop=e,this.oldLeft=s,N(i)}}}translate(t,e){let s,i;null==(s=this.layerManager)||s.translateLayers(new ua(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=Dr.getGroup$$module$build$src$core$events$utils();let s;e||Dr.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{Dr.setGroup$$module$build$src$core$events$utils(e)}return s}pasteBlock_(t,e){let s;Dr.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(Dr.config$$module$build$src$core$config.snapRadius,new ua(i,o)).connection){t=!0;break}}t&&(i=this.RTL?i-Dr.config$$module$build$src$core$config.snapRadius:i+Dr.config$$module$build$src$core$config.snapRadius,o+=2*Dr.config$$module$build$src$core$config.snapRadius)}while(t);s.moveTo(new ua(i,o))}}finally{Dr.enable$$module$build$src$core$events$utils()}return M()&&!s.isShadow()&&N(new(B(Dr.CREATE$$module$build$src$core$events$utils))(s)),s.select(),s}pasteWorkspaceComment_(t){let e;Dr.disable$$module$build$src$core$events$utils();try{e=Ec.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{Dr.enable$$module$build$src$core$events$utils()}return M()&&gc.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(la.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=ua.difference(e,t)}moveDrag(t){return(t=q(t,this.getParentSvg(),this.getInverseScreenCTM())).x/=this.scale,t.y/=this.scale,ua.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(lu.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 Oa(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),Dr.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}Dr.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(t){if(!this.options.readOnly&&!this.isFlyout){var e=gh.registry.getContextMenuOptions(gh.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)}},Jd={};Jd.WorkspaceSvg=jd,Jd.resizeSvgContents=xn;var qd=class extends Nl{constructor(t,e){super(e),this.type=cl,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 qd)).isOpen=t.isOpen,e}};t(Ur.EVENT,cl,qd);var Zd=class extends Pc{constructor(t){if(super(t),this.type=Dr.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=we(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=Be(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 Zd)).oldXml=Dr.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!=vd){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 Dr.ValueInput$$module$build$src$core$inputs$value_input(t,this))}appendStatementInput(t){return this.statementInputCount++,this.appendInput(new Od(t,this))}appendDummyInput(t=""){return this.appendInput(new $d(t,this))}appendEndRowInput(t=""){return this.appendInput(new Id(t,this))}appendInput(t){return this.inputList.push(t),t}appendInputFromRegistry(t,e){return(t=r(Ur.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&&(Dr.disable$$module$build$src$core$events$utils(),this.setInputsInline(t.inputsInline),Dr.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=No(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=No(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 Za?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(B(Dr.MOVE$$module$build$src$core$events$utils))(this);s&&i.setReason(s),this.xy_.translate(t,e),i.recordNew(),N(i)}makeConnection_(t){return new Nd(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}};Qd.COLLAPSED_INPUT_NAME=vd,Qd.COLLAPSED_FIELD_NAME=Ad;var tp=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()}},ep=class extends tp{constructor(){super(),this.type="cursor"}next(){var t=this.getCurNode();if(!t)return null;for(t=t.next();t&&t.next()&&(t.getType()===Cd.types.NEXT||t.getType()===Cd.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()!==Cd.types.PREVIOUS&&t.getType()!==Cd.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()===Cd.types.NEXT||t.getType()===Cd.types.BLOCK);)t=t.prev();return t&&this.setCurNode(t),t}out(){var t=this.getCurNode();return t?((t=t.out())&&t.getType()===Cd.types.BLOCK&&(t=t.prev()||t),t&&this.setCurNode(t),t):null}};t(Ur.CURSOR,Fr,ep);var sp=class extends ep{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())!==Cd.types.OUTPUT&&t!==Cd.types.INPUT&&t!==Cd.types.FIELD&&t!==Cd.types.NEXT&&t!==Cd.types.PREVIOUS&&t!==Cd.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)}};sp.registrationName="basicCursor",t(Ur.CURSOR,sp.registrationName,sp);var ip=class extends sp{validNode_(t){let e=!1;const s=t&&t.getType();return t&&(t=t.getLocation(),s===Cd.types.FIELD&&t&&t.isTabNavigable()&&t.isClickable()&&(e=!0)),e}},op=class extends Nd{constructor(t,e){super(t,e),this.highlighted=!1,this.targetConnection=null,this.db=t.workspace.connectionDBList[e],this.dbOpposite=t.workspace.connectionDBList[Fh[e]],this.offsetInBlock=new ua(0,0),this.trackedState=op.TrackedState.WILL_TRACK}dispose(){let t,e;super.dispose(),this.trackedState===op.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),null==(e=(t=this.sourceBlock_.pathObject).removeConnectionHighlight)||e.call(t,this)}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+Dr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.x,n=t.y+Dr.config$$module$build$src$core$config.snapRadius+Math.floor(10*Math.random())-this.y;s&&(n=-n),e.RTL&&(o=t.x-Dr.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===op.TrackedState.WILL_TRACK?(this.db.addConnection(this,e),this.trackedState=op.TrackedState.TRACKED,s=!0):this.trackedState===op.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=ua.difference(this.offsetInBlock,t.offsetInBlock),e.translate(t.x,t.y))}closest(t,e){return this.dbOpposite.searchForClosest(this,t,e)}highlight(){this.highlighted=!0,this.getSourceBlock().queueRender()}unhighlight(){this.highlighted=!1,this.getSourceBlock().queueRender()}isHighlighted(){return this.highlighted}setTracking(t){t&&this.trackedState===op.TrackedState.TRACKED||!t&&this.trackedState===op.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(t?(this.db.addConnection(this,this.y),this.trackedState=op.TrackedState.TRACKED):(this.trackedState===op.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=op.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||(Dr.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),Dr.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:Wc.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(Gu.TYPE),t){let i=this.getSurroundParent(),o=null;for(;i;)i.isCollapsed()&&(o=i),i=i.getSurroundParent();o&&o.setWarningText(Dr.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,lp.COLLAPSED_WARNING_ID),s?s.addMessage(t,e):this.addIcon(new Gu(this).addMessage(t,e))}else s&&(e?(s.addMessage("",e),s.getText()||this.removeIcon(Gu.TYPE)):this.removeIcon(Gu.TYPE))}setMutator(t){this.removeIcon(Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),t&&this.addIcon(t)}addIcon(t){return super.addIcon(t),t instanceof Gu&&(this.warning=t),t instanceof Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=t),this.rendered&&(t.initView(this.createIconPointerDownListener(t)),t.applyColour(),t.updateEditable(),this.queueRender(),Se(),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(Gu.TYPE)&&(this.warning=null),t.equals(Dr.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.rendered&&(this.queueRender(),Se(),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=Dr.getGroup$$module$build$src$core$events$utils();Dr.setGroup$$module$build$src$core$events$utils(t),this.getRootBlock().bumpNeighboursInternal(),Dr.setGroup$$module$build$src$core$events$utils(e),this.bumpNeighboursPid=0}),Dr.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(Dr.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=Dr.getGroup$$module$build$src$core$events$utils();setTimeout((()=>{Dr.setGroup$$module$build$src$core$events$utils(t),this.snapToGrid(),Dr.setGroup$$module$build$src$core$events$utils(!1)}),Dr.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(t,e,s){if(t.type===Hc.NEXT_STATEMENT||t.type===Hc.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(),Se()}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(cu.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)}};lp.INLINE=-1,lp.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var ap,cp=class{constructor(){}onDragEnter(t){}onDragOver(t){}onDragExit(t){}onDrop(t){}getClientRect(){return null}shouldPreventMove(t){return!1}},hp=class extends cp{constructor(){super(),this.wouldDelete_=!1}wouldDelete(t,e){return t instanceof lp?(t=!t.getParent()&&t.isDeletable(),this.updateWouldDelete_(t&&!e)):this.updateWouldDelete_(t.isDeletable()),this.wouldDelete_}updateWouldDelete_(t){this.wouldDelete_=t}},up=class extends hp{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 pu({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===Fa.TOP?Fa.BOTTOM:Fa.TOP,this.flyout=new(c(Ur.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(t)):(t.toolboxPosition=this.workspace.toolboxPosition===Fa.RIGHT?Fa.LEFT:Fa.RIGHT,this.flyout=new(c(Ur.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(t)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){let t;this.svgGroup=it(Ia.G,{class:"blocklyTrash"});const e=String(Math.random()).substring(2);t=it(Ia.CLIPPATH,{id:"blocklyTrashBodyClipPath"+e},this.svgGroup),it(Ia.RECT,{width:dp,height:pp,y:gp},t);const s=it(Ia.IMAGE,{width:za,x:-Ep,height:ja,y:-fp,"clip-path":"url(#blocklyTrashBodyClipPath"+e+")"},this.svgGroup);return s.setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),t=it(Ia.CLIPPATH,{id:"blocklyTrashLidClipPath"+e},this.svgGroup),it(Ia.RECT,{width:dp,height:gp},t),this.svgLid=it(Ia.IMAGE,{width:za,x:-Ep,height:ja,y:-fp,"clip-path":"url(#blocklyTrashLidClipPath"+e+")"},this.svgGroup),this.svgLid.setAttributeNS(ma,"xlink:href",this.workspace.options.pathToMedia+Ja),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 Sa(dp,pp+gp),Tp,_p,t,this.workspace),e=zt(t,_p,i.vertical===Ga.TOP?Wa.DOWN:Wa.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 Oa(this.top,this.top+pp+gp,this.left,this.left+dp)}getClientRect(){if(!this.svgGroup)return null;var t=this.svgGroup.getBoundingClientRect();const e=t.top+fp-mp;return t=t.left+Ep-mp,new Oa(e,e+gp+pp+2*mp,t,t+dp+2*mp)}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=Ip;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*Cp),e=Op+this.lidOpen*(Sp-Op),this.svgGroup&&(this.svgGroup.style.opacity=`${e}`),this.lidOpen>this.minOpenness&&1>this.lidOpen&&(this.lidTask=setTimeout(this.animateLid.bind(this),$p/t))}setLidAngle(t){const e=this.workspace.toolboxPosition===Fa.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let s;null==(s=this.svgLid)||s.setAttribute("transform","rotate("+(e?-t:t)+","+(e?4:dp-4)+","+(gp-2)+")")}setMinOpenness(t){this.minOpenness=t,this.isLidOpen||this.setLidAngle(t*Cp)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(t){t=new(B(cl))(t,this.workspace.id),N(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!==Dr.DELETE$$module$build$src$core$events$utils||t.type!==Dr.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(bp)}}}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)}},dp=47,pp=44,gp=16,_p=20,Tp=20,mp=10,Ep=0,fp=32,bp=.1,$p=80,Ip=4,Op=.4,Sp=.8,Cp=45,Rp=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)&&0Yn(t)))).length?t:null}load(t,e){const s=e.getProcedureMap();for(const i of t)s.add(zn(this.procedureModelClass,this.parameterModelClass,i,e))}clear(t){t.getProcedureMap().clear()}}};vp.loadParameter=jn,vp.loadProcedure=zn,vp.saveParameter=Kn,vp.saveProcedure=Yn;var Ap=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 Ap);var Lp={};Lp.VariableSerializer=Ap;var wp={};wp.load=qn,wp.save=Jn;var Mp={blocks:xc,exceptions:Lc,priorities:wc,procedures:vp,registry:Mc,variables:Lp,workspaces:wp},Dp=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 va(t,!0,n,i,o)),s&&(this.vScroll=new va(t,!1,n,i,o)),n&&(this.corner_=it(Ia.RECT,{height:va.scrollbarThickness,width:va.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{Dr.disable$$module$build$src$core$events$utils(),this.hScroll&&e&&this.hScroll.resize(t),this.vScroll&&s&&this.vScroll.resize(t)}finally{Dr.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)}},xp=class{constructor(t){this.workspace_=t}getDimensionsPx_(t){let e=0,s=0;return t&&(e=t.getWidth(),s=t.getHeight()),new Sa(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)===Fa.TOP;return n===Fa.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)===Fa.LEFT||n===Fa.RIGHT;return n!==Fa.TOP&&n!==Fa.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(Ur.METRICS_MANAGER,Fr,xp);var Pp=class extends yl{constructor(t){super(),this.isBlank=!0,this.recordUndo=!1,this.type=ml,this.isBlank=!!t,t&&(this.workspaceId=t.id)}};t(Ur.EVENT,ml,Pp);var Bp=class extends Nl{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=ol,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 Bp)).isStart=t.isStart,e.blockId=t.blockId,e.blocks=t.blocks,e}};t(Ur.EVENT,ol,Bp);var Fp={};Fp.bumpIntoBounds=Zn,Fp.bumpIntoBoundsHandler=Qn,Fp.bumpTopObjectsIntoBounds=er;var Up=class{constructor(t,e){this.connectionCandidate=this.dragTarget_=null,this.wouldDeleteBlock_=!1,this.dragIconData_=[],this.draggingBlock_=t,this.workspace_=e,this.connectionPreviewer=new(c(Ur.CONNECTION_PREVIEWER,this.workspace_.options))(t),this.startXY_=this.draggingBlock_.getRelativeToSurfaceXY(),this.dragIconData_=sr(t,this.startXY_)}dispose(){this.dragIconData_.length=0,this.connectionPreviewer.dispose()}startDrag(t,e){let s;Dr.getGroup$$module$build$src$core$events$utils()||Dr.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=ua.sum(this.startXY_,t),this.draggingBlock_.translate(t.x,t.y),Pi(this.draggingBlock_)}fireDragStartEvent_(){const t=new(B(ol))(this.draggingBlock_,!0,this.draggingBlock_.getDescendants(!1));N(t)}drag(t,e){const s=this.draggingBlock_;this.moveBlock(s,e),this.updateDragTargets(t,s),this.wouldDeleteBlock_=this.wouldDeleteBlock(t,s,e),this.updateCursorDuringBlockDrag_(),this.updateConnectionPreview(s,e)}moveBlock(t,e){e=this.pixelsToWorkspaceUnits_(e),e=ua.sum(this.startXY_,e),t.moveDuringDrag(e)}updateDragTargets(t,e){if(t=this.workspace_.getDragTarget(t),this.dragTarget_!==t){let s;null==(s=this.dragTarget_)||s.onDragExit(e),null==t||t.onDragEnter(e)}null==t||t.onDragOver(e),this.dragTarget_=t}wouldDeleteBlock(t,e,s){return!(!(t=this.workspace_.getDragTarget(t))||!this.workspace_.getComponentManager().hasCapability(t.id,la.Capability.DELETE_AREA))&&t.wouldDelete(e,!!this.getConnectionCandidate(e,s))}updateConnectionPreview(t,e){e=this.pixelsToWorkspaceUnits_(e);const s=this.connectionCandidate,i=this.getConnectionCandidate(t,e);if(i){this.connectionCandidate=e=s&&this.currCandidateIsBetter(s,e,i)?s:i;var{local:o,neighbour:n}=e;o.type!==Hc.OUTPUT_VALUE&&o.type!==Hc.PREVIOUS_STATEMENT||!n.isConnected()||n.targetBlock().isInsertionMarker()||this.orphanCanConnectAtEnd(t,n.targetBlock(),o.type)?this.connectionPreviewer.previewConnection(o,n):this.connectionPreviewer.previewReplacement(o,n,n.targetBlock())}else this.connectionPreviewer.hidePreview(),this.connectionCandidate=null}orphanCanConnectAtEnd(t,e,s){return!!Nd.getConnectionForOrphanedConnection(t,s===Hc.OUTPUT_VALUE?e.outputConnection:e.previousConnection)}currCandidateIsBetter(t,e,s){const{local:i,neighbour:o}=t;t=new ua(i.x,i.y);const n=new ua(o.x,o.y);return e=ua.distance(ua.sum(t,e),n),s.distance>e-Dr.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(t,e){t=this.getLocalConnections(t);let s=this.connectionCandidate?Dr.config$$module$build$src$core$config.connectingSnapRadius:Dr.config$$module$build$src$core$config.snapRadius,i=null;for(const o of t){const{connection:t,radius:n}=o.closest(s,e);t&&(i={local:o,neighbour:t,distance:n},s=n)}return i}getLocalConnections(t){const e=t.getConnections_(!1),s=t.lastConnectionInStack(!0);return s&&s!==t.nextConnection&&e.push(s),e}endDrag(t,e){if(this.drag(t,e),this.fireDragEndEvent_(),pt(),Fi(),this.connectionPreviewer.hidePreview(),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_():Zn(this.draggingBlock_.workspace,this.workspace_.getMetricsManager().getScrollMetrics(!0),this.draggingBlock_)}this.connectionPreviewer.dispose(),this.workspace_.setResizesEnabled(!0),Dr.setGroup$$module$build$src$core$events$utils(!1)}getNewLocationAfterDrag_(t){return{delta:t=this.pixelsToWorkspaceUnits_(t),newLocation:ua.sum(this.startXY_,t)}}maybeDeleteBlock_(){return!!this.wouldDeleteBlock_&&(this.fireMoveEvent_(),this.draggingBlock_.dispose(!1,!0),Kr.length=0,!0)}updateBlockAfterMove_(){this.fireMoveEvent_(),this.connectionCandidate?this.applyConnections(this.connectionCandidate):this.draggingBlock_.queueRender(),this.draggingBlock_.scheduleSnapAndBump()}applyConnections(t){const{local:e,neighbour:s}=t;if(e.connect(s),this.draggingBlock_.rendered){const t=e.isSuperior()?s:e,i=this.draggingBlock_.getRootBlock();Oe().then((()=>{xi(t.getSourceBlock()),setTimeout((()=>{i.bringToFront()}),0)}))}}fireDragEndEvent_(){const t=new(B(ol))(this.draggingBlock_,!1,this.draggingBlock_.getDescendants(!1));N(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(B(Dr.MOVE$$module$build$src$core$events$utils))(this.draggingBlock_);t.setReason(["drag"]),t.oldCoordinate=this.startXY_,t.recordNew(),N(t)}}updateCursorDuringBlockDrag_(){this.draggingBlock_.setDeleteStyle(this.wouldDeleteBlock_)}pixelsToWorkspaceUnits_(t){return t=new ua(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.workspace_.getAllBlocks().filter((t=>t.isInsertionMarker()))}};t(Ur.BLOCK_DRAGGER,Fr,Up);var Hp={};Hp.Bubble=vu,Hp.MiniWorkspaceBubble=Au,Hp.TextBubble=Fu,Hp.TextInputBubble=Uu;var Gp=class extends Pc{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 Gp)).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(Ur.EVENT,Qr,Gp);var Vp=class extends Pc{constructor(t){super(t),this.type=Dr.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 Vp)).oldParentId=t.oldParentId,e.oldInputName=t.oldInputName,t.oldCoordinate&&(s=t.oldCoordinate.split(","),e.oldCoordinate=new ua(Number(s[0]),Number(s[1]))),e.newParentId=t.newParentId,e.newInputName=t.newInputName,t.newCoordinate&&(s=t.newCoordinate.split(","),e.newCoordinate=new ua(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&&ua.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===Hc.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(Ur.EVENT,Dr.MOVE$$module$build$src$core$events$utils,Vp);var Wp,Xp=class extends Nl{constructor(t,e,s){super(t?t.workspace.id:void 0),this.type=al,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 Xp)).isOpen=t.isOpen,e.bubbleType=t.bubbleType,e.blockId=t.blockId,e}};(function(t){t.MUTATOR="mutator",t.COMMENT="comment",t.WARNING="warning"})(Wp||(Wp={})),t(Ur.EVENT,al,Xp);var Yp={};Yp.BubbleOpen=Xp,Yp.BubbleType=Wp;var Kp=class extends yl{constructor(t){super(),this.isBlank=!t,t&&(this.commentId=t.id,this.workspaceId=t.workspace.id,this.group=Dr.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 Kp)).commentId=t.commentId,e}static CommentCreateDeleteHelper(t,e){var s=t.getEventWorkspace_();if(e){if(e=Dr.createElement$$module$build$src$core$utils$xml("xml"),!t.xml)throw Error("Ecountered a comment event without proper xml");e.appendChild(t.xml),Dr.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)}}},zp=class extends Kp{constructor(t,e,s){super(t),this.type=_l,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 zp)).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(Ur.EVENT,_l,zp);var jp=class extends Kp{constructor(t){super(t),this.type=pl,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=Be(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new jp)).xml=Dr.textToDom$$module$build$src$core$utils$xml(t.xml),e}run(t){Kp.CommentCreateDeleteHelper(this,t)}};t(Ur.EVENT,pl,jp);var Jp=class extends Kp{constructor(t){super(t),this.type=gl,t&&(this.xml=t.toXmlWithXY())}run(t){Kp.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=Be(this.xml),t}static fromJson(t,e,s){return(e=super.fromJson(t,e,null!=s?s:new Jp)).xml=Dr.textToDom$$module$build$src$core$utils$xml(t.xml),e}};t(Ur.EVENT,gl,Jp);var qp=class extends Kp{constructor(t){super(t),this.type=Tl,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 qp),s=t.oldCoordinate.split(","),e.oldCoordinate_=new ua(Number(s[0]),Number(s[1])),s=t.newCoordinate.split(","),e.newCoordinate_=new ua(Number(s[0]),Number(s[1])),e}isNull(){return ua.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(Ur.EVENT,Tl,qp);var Zp=class extends Nl{constructor(t,e,s){super(s),this.type=hl,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 Zp)).oldItem=t.oldItem,e.newItem=t.newItem,e}};t(Ur.EVENT,hl,Zp),Dr.CHANGE$$module$build$src$core$events$utils,Dr.CREATE$$module$build$src$core$events$utils,Dr.DELETE$$module$build$src$core$events$utils,Dr.MOVE$$module$build$src$core$events$utils,Dr.CHANGE$$module$build$src$core$events$utils,Dr.CREATE$$module$build$src$core$events$utils,Dr.DELETE$$module$build$src$core$events$utils,Dr.MOVE$$module$build$src$core$events$utils,Dr.disable$$module$build$src$core$events$utils,Dr.enable$$module$build$src$core$events$utils,Dr.getGroup$$module$build$src$core$events$utils,Dr.setGroup$$module$build$src$core$events$utils;var Qp={};Qp.Abstract=yl,Qp.BLOCK_CHANGE=Dr.CHANGE$$module$build$src$core$events$utils,Qp.BLOCK_CREATE=Dr.CREATE$$module$build$src$core$events$utils,Qp.BLOCK_DELETE=Dr.DELETE$$module$build$src$core$events$utils,Qp.BLOCK_DRAG=ol,Qp.BLOCK_FIELD_INTERMEDIATE_CHANGE=Qr,Qp.BLOCK_MOVE=Dr.MOVE$$module$build$src$core$events$utils,Qp.BUBBLE_OPEN=al,Qp.BUMP_EVENTS=El,Qp.BlockBase=Pc,Qp.BlockChange=gu,Qp.BlockCreate=Bc,Qp.BlockDelete=Zd,Qp.BlockDrag=Bp,Qp.BlockFieldIntermediateChange=Gp,Qp.BlockMove=Vp,Qp.BubbleOpen=Xp,Qp.BubbleType=Wp,Qp.CHANGE=Dr.CHANGE$$module$build$src$core$events$utils,Qp.CLICK=rl,Qp.COMMENT_CHANGE=_l,Qp.COMMENT_CREATE=pl,Qp.COMMENT_DELETE=gl,Qp.COMMENT_MOVE=Tl,Qp.CREATE=Dr.CREATE$$module$build$src$core$events$utils,Qp.Click=vl,Qp.ClickTarget=Rl,Qp.CommentBase=Kp,Qp.CommentChange=zp,Qp.CommentCreate=jp,Qp.CommentDelete=Jp,Qp.CommentMove=qp,Qp.DELETE=Dr.DELETE$$module$build$src$core$events$utils,Qp.FINISHED_LOADING=ml,Qp.FinishedLoading=Pp,Qp.MARKER_MOVE=ll,Qp.MOVE=Dr.MOVE$$module$build$src$core$events$utils,Qp.MarkerMove=Rd,Qp.SELECTED=nl,Qp.Selected=_c,Qp.THEME_CHANGE=ul,Qp.TOOLBOX_ITEM_SELECT=hl,Qp.TRASHCAN_OPEN=cl,Qp.ThemeChange=Uc,Qp.ToolboxItemSelect=Zp,Qp.TrashcanOpen=qd,Qp.UI=il,Qp.UiBase=Nl,Qp.VAR_CREATE=tl,Qp.VAR_DELETE=el,Qp.VAR_RENAME=sl,Qp.VIEWPORT_CHANGE=dl,Qp.VarBase=lc,Qp.VarCreate=ac,Qp.VarDelete=Vd,Qp.VarRename=Wd,Qp.ViewportChange=Gc,Qp.clearPendingUndo=w,Qp.disable=Dr.disable$$module$build$src$core$events$utils,Qp.disableOrphans=F,Qp.enable=Dr.enable$$module$build$src$core$events$utils,Qp.filter=L,Qp.fire=N,Qp.fromJson=P,Qp.get=B,Qp.getDescendantIds=x,Qp.getGroup=Dr.getGroup$$module$build$src$core$events$utils,Qp.getRecordUndo=y,Qp.isEnabled=M,Qp.setGroup=Dr.setGroup$$module$build$src$core$events$utils,Qp.setRecordUndo=k;var tg=class extends Td{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,n=i===e?"0":"1";return an("a","0 0,"+n,t=(t>s?s:t)/2,tn((i?1:-1)*t,(e?-1:1)*t))+ln("v",(e?-1:1)*o)+an("a","0 0,"+n,t,tn((i?-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){t-=2*e;const o=i===s?"0":"1";return an("a","0 0,"+o,e,tn((i?1:-1)*e,(s?-1:1)*e))+ln("v",(s?-1:1)*t)+an("a","0 0,"+o,e,tn((i?-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 Hc.INPUT_VALUE:case Hc.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 Hc.PREVIOUS_STATEMENT:case Hc.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(Ia.DEFS,{},t),e=it(Ia.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(Ia.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},e),s=it(Ia.FECOMPONENTTRANSFER,{result:"outBlur"},e),it(Ia.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},s),it(Ia.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),it(Ia.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.selectedGlowFilterId=e.id,this.selectedGlowFilter=e,t=it(Ia.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},t),it(Ia.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},t),e=it(Ia.FECOMPONENTTRANSFER,{result:"outBlur"},t),it(Ia.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},e),it(Ia.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),it(Ia.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),it(Ia.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;","}"]}},eg=class extends Ed{constructor(t,e){super(t,e)}draw(){const t=this.block_.pathObject;t.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),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(zu.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 Sa(e,s+sg.Y_PADDING),this.imageHeight=s,"function"==typeof o&&(this.clickHandler=o),t!==bu.SKIP_SETUP&&(r?this.configure_(r):(this.flipRtl=!!n,this.altText=No(i)||""),this.setValue(No(t)))}configure_(t){super.configure_(t),t.flipRtl&&(this.flipRtl=t.flipRtl),t.alt&&(this.altText=No(t.alt))}initView(){this.imageElement=it(Ia.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(ma,"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(ma,"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)}};sg.Y_PADDING=1,Mo("field_image",sg),sg.prototype.DEFAULT_VALUE="";var ig=class extends bu{constructor(t,e,s){super(bu.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!==bu.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 $u;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot())}isFullBlockField(){const t=this.getSourceBlock();if(!t)throw new $u;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()&&N(new(B(Dr.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 $u;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"),Ps(t,qc.INVALID,!1)):(ot(t,"blocklyInvalidInput"),Ps(t,qc.INVALID,!0))}if(!(t=this.getSourceBlock()))throw new $u;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&&(ta||Jl||ql)?this.showPromptEditor_():this.showInlineEditor_(e)}showPromptEditor_(){te(Dr.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 $u;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 $u;Dr.setGroup$$module$build$src$core$events$utils(!0);const e=Bs();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=ig.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_&&(N(new(B(Dr.CHANGE$$module$build$src$core$events$utils))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),Dr.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var t=Bs().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(),Ai()):"Escape"===t.key?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),Gs(),Ai()):"Tab"===t.key&&(Gs(),Ai(),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&&N(new(B(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 $u;const e=Bs(),s=this.getScaledBBox();e.style.width=s.right-s.left+"px",e.style.height=s.bottom-s.top+"px",t=new ua(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 lp&&(Zn(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}};ig.BORDERRADIUS=4;var og=class extends ig{constructor(t,e,s){super(t,e,s)}doClassValidation_(t){return void 0===t?null:`${t}`}static fromJson(t){return new this(No(t.text),void 0,t)}};Mo("field_input",og),og.prototype.DEFAULT_VALUE="";var ng=class extends qu{constructor(t){super(t)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(t){return!!t.outputConnection}hasRightSquareCorner(t){return!!t.outputConnection&&!t.statementInputCount&&!t.nextConnection}},rg=class extends rd{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)}}},lg=class extends ju{constructor(t){super(t),this.width=this.height=0,this.type|=zu.getType("RIGHT_CONNECTION")}},ag=class extends _d{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}},cg=class extends Sd{constructor(t,e){super(t,e),this.isInline=!0,this.renderer_=t,this.constants_=this.renderer_.getConstants(),this.topRow=new ag(this.constants_),this.bottomRow=new ng(this.constants_),this.isMultiRow=!e.getInputsInline()||e.isCollapsed(),this.hasStatementInput=0=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!i.precedesStatement,zu.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)&&zu.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(zu.isInlineInput(t)&&t instanceof Qu){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 zu.isField(t)&&t instanceof ed?s===i.SHAPES.ROUND&&t.field instanceof og?e-2.75*i.GRID_UNIT:e-this.constants_.SHAPE_IN_SHAPE_PADDING[s][0]:zu.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 ed&&(s.field instanceof fd||s.field instanceof sg),!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(Ia.LINE,{x1:Tg.HALF+Tg.RADIUS,y1:Tg.HALF,x2:Tg.HALF+Tg.RADIUS-(0==e%45?10:5),y2:Tg.HALF,class:"blocklyAngleMarks",transform:"rotate("+e+","+Tg.HALF+","+Tg.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(){Ni(this),Gs()}onMouseMove_(t){var e=this.gauge.ownerSVGElement.getBoundingClientRect();const s=t.clientX-e.left-Tg.HALF;t=t.clientY-e.top-Tg.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)}};Tg.HALF=50,Tg.RADIUS=Tg.HALF-1,Tg.CLOCKWISE=!1,Tg.OFFSET=0,Tg.WRAP=360,Tg.ROUND=15,Mo("field_angle",Tg),Tg.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"}(_g||(_g={}));var mg={};mg.FieldAngle=Tg,mg.Mode=_g;var Eg=class extends bu{constructor(t,e,s){super(bu.SKIP_SETUP),this.SERIALIZABLE=!0,this.CURSOR="default",this.value_=this.value_,this.checkChar=Eg.CHECK_CHAR,t!==bu.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(Eg);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||Eg.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)}};Eg.CHECK_CHAR="✓",Mo("field_checkbox",Eg),Eg.prototype.DEFAULT_VALUE=!1;var fg=class extends bu{constructor(t,e,s){super(bu.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!==bu.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 Sa(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 $u;const e=this.getConstants();return t.isSimpleReporter()&&!(null==e||!e.FIELD_COLOUR_FULL_BLOCK)}applyColour(){const t=this.getSourceBlock();if(!t)throw new $u;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 $u;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),fi(this,this.dropdownDispose.bind(this)),this.picker.focus({preventScroll:!0})}onClick(t){null!==(t=(t=t.target)&&t.getAttribute("data-colour"))&&(this.setValue(t),Ni(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),Ai();break;default:e=!1}e&&t.stopPropagation()}moveHighlightBy(t,e){if(this.highlightedIndex){var s=this.colours||fg.COLOURS,i=this.columns||fg.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||fg.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&&Ps(this.picker,qc.ACTIVEDESCENDANT,t)}dropdownCreate(){const t=this.columns||fg.COLUMNS,e=this.colours||fg.COLOURS,s=this.titles||fg.TITLES,i=this.getValue(),o=document.createElement("table");let n;o.className="blocklyColourTable",o.tabIndex=0,o.dir="ltr",xs(o,Jc.GRID),Ps(o,qc.EXPANDED,!0),Ps(o,qc.ROWCOUNT,Math.floor(e.length/t)),Ps(o,qc.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 bg=class extends fd{constructor(t,e,s){super(String(null!=t?t:""),e,s),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(t){return new this(No(t.text),void 0,t)}};Mo("field_label_serializable",bg);var $g=class extends og{constructor(t,e,s){super(bu.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,t!==bu.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($g);return null!==t?t:this.getValue()}loadState(t){this.loadLegacyState(bu,t)||this.setValue(t)}initView(){this.createBorderRect_(),this.textGroup=it(Ia.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const t=this.getSourceBlock();if(!t)throw new $u;let e=this.getText();if(!e)return bu.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,bu.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 $u;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=Bs(),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=og.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",""),jl?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(s),s}setMaxLines(t){"number"==typeof t&&0this.max_&&(t.max=`${this.max_}`,Ps(t,qc.VALUEMAX,this.max_)),t}static fromJson(t){return new this(t.value,void 0,void 0,void 0,void 0,t)}};Mo("field_number",Ig),Ig.prototype.DEFAULT_VALUE=0;var Og=class extends ku{constructor(t,e,s,i,o){super(bu.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=Og.dropdownCreate,this.defaultVariableName="string"==typeof t?t:"",this.size_=new Sa(0,0),t!==bu.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 $u;this.variable||(t=Dr.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 $u;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 $u;const s=t.getAttribute("id"),i=t.textContent,o=t.getAttribute("variabletype")||t.getAttribute("variableType")||"";if(e=Dr.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: "+Be(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(Og);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 $u;this.loadLegacyState(Og,t)||(t=Dr.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 $u;return(e=Dr.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 $u;this.variable=Dr.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{this.targetWorkspace.isDragging()||e.addSelect()}))),this.listeners.push(K(t,"pointerleave",e,(()=>{this.targetWorkspace.isDragging()||e.removeSelect()}))),this.listeners.push(K(s,"pointerenter",e,(()=>{this.targetWorkspace.isDragging()||e.addSelect()}))),this.listeners.push(K(s,"pointerleave",e,(()=>{this.targetWorkspace.isDragging()||e.removeSelect()})))}blockMouseDown(t){return e=>{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;Dr.disable$$module$build$src$core$events$utils();var s=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{e=this.placeNewBlock(t)}finally{Dr.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),t=fe(this.targetWorkspace,s),M()){for(Dr.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_===Fa.TOP?new Oa(-1e9,e+t.height,-1e9,1e9):new Oa(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+=va.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_!==Fa.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+t),this.height_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};t(Ur.FLYOUTS_HORIZONTAL_TOOLBOX,Fr,yg);var Ng=class extends kg{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_===Fa.LEFT?t.width:s.width-this.width_:this.toolboxPosition_===Fa.LEFT?0:s.width:this.toolboxPosition_===Fa.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_===Fa.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(),Ai()}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_===Fa.LEFT?new Oa(-1e9,1e9,-1e9,e+t.width):new Oa(-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+=va.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_!==Fa.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+t,this.targetWorkspace.scrollY),this.width_=t,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};Ng.registryName="verticalFlyout",t(Ur.FLYOUTS_VERTICAL_TOOLBOX,Fr,Ng),Dr.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{null==i||i.positionNearConnection(o,n,r),null==i||i.getSvgRoot().setAttribute("visibility","visible")})),this.workspace.getRenderer().shouldHighlightConnection(e)&&e.highlight(),this.markerConn=o,this.draggedConn=t,this.staticConn=e}finally{Dr.enable$$module$build$src$core$events$utils()}}}createInsertionMarker(t){const e=this.workspace.newBlock(t.type);if(e.setInsertionMarker(!0),t.saveExtraState){var s=t.saveExtraState(!0);s&&e.loadExtraState&&e.loadExtraState(s)}else t.mutationToDom&&(s=t.mutationToDom())&&e.domToMutation&&e.domToMutation(s);for(s=0;s.blocklyPathLight,`,`${t} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},Dg=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++)zu.isLeftSquareCorner(e)?this.steps_+=this.highlightConstants_.START_POINT:zu.isLeftRoundedCorner(e)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):zu.isPreviousConnection(e)?this.steps_+=this.notchPaths_.pathLeft:zu.isHat(e)?this.steps_+=this.startPaths_.path(this.RTL_):zu.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 pd&&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];zu.isLeftSquareCorner(e)?this.steps_+=sn(t.xPos+this.highlightOffset,t.baseline-this.highlightOffset):zu.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,zu.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_)}},xg=class extends Ed{constructor(t,e){super(t,e),this.highlighter_=new Dg(e)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();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)}}},Pg=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}}},Bg=class extends nd{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)}},Fg=class extends rd{constructor(t,e){super(t,e),this.constants_=t,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Ug=class extends Sd{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 Od||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(t,e){this.isInline&&t instanceof Dr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new Bg(this.constants_,t)),e.hasInlineInput=!0):t instanceof Od?(e.elements.push(new Fg(this.constants_,t)),e.hasStatement=!0):t instanceof Dr.ValueInput$$module$build$src$core$inputs$value_input?(e.elements.push(new td(this.constants_,t)),e.hasExternalInput=!0):(t instanceof $d||t instanceof Id)&&(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 od(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(Ur.TOOLBOX_ITEM,e_.registrationName,e_);var s_=class extends t_{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_)}};s_.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(Ur.TOOLBOX_ITEM,s_.registrationName,s_);var i_=class extends e_{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(Ur.TOOLBOX,Fr,o_);var n_=Dr.Align$$module$build$src$core$inputs$align.LEFT,r_=Dr.Align$$module$build$src$core$inputs$align.CENTRE,l_=Dr.Align$$module$build$src$core$inputs$align.RIGHT,a_=Hc.INPUT_VALUE,c_=Hc.OUTPUT_VALUE,h_=Hc.NEXT_STATEMENT,u_=Hc.PREVIOUS_STATEMENT,d_=Dr.inputTypes$$module$build$src$core$inputs$input_types.DUMMY,p_=Fa.TOP,g_=Fa.BOTTOM,__=Fa.LEFT,T_=Fa.RIGHT;Yd.prototype.newBlock=function(t,e){return new Qd(this,t,e)},jd.prototype.newBlock=function(t,e){return new lp(this,t,e)},jd.newTrashcan=function(t){return new up(t)},Ec.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)}},Au.prototype.newWorkspaceSvg=function(t){return new jd(t)},Dr.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 f={blocks:d},b={},$={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 P={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",P,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 B={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(B)}));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,A,k,b,l,s),colour:J,lists:z,loops:D,math:v,procedures:R,texts:f,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 f={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",GTE:">="}[t.getFieldValue("OP")];return[(s.valueToCode(t,"A",e.RELATIONAL)||"0")+" "+i+" "+(t=s.valueToCode(t,"B",e.RELATIONAL)||"0"),e.RELATIONAL]},m.logic_negate=function(t,s){return["not "+(s.valueToCode(t,"BOOL",e.UNARY)||"true"),e.UNARY]},m.logic_null=function(t,s){return["nil",e.ATOMIC]},m.logic_operation=function(t,s){const i="AND"===t.getFieldValue("OP")?"and":"or",o="and"===i?e.AND:e.OR;let n=s.valueToCode(t,"A",o);return t=s.valueToCode(t,"B",o),n||t?(s="and"===i?"true":"false",n||(n=s),t||(t=s)):t=n="false",[n+" "+i+" "+t,o]},m.logic_ternary=function(t,s){return[(s.valueToCode(t,"IF",e.AND)||"false")+" and "+(s.valueToCode(t,"THEN",e.AND)||"nil")+" or "+(t=s.valueToCode(t,"ELSE",e.OR)||"nil"),e.OR]};var E="goto continue\n",f={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+E}throw Error("Unknown flow statement.")},controls_for:function(t,s){const o=s.getVariableName(t.getFieldValue("VAR")),r=s.valueToCode(t,"FROM",e.NONE)||"0",l=s.valueToCode(t,"TO",e.NONE)||"0",a=s.valueToCode(t,"BY",e.NONE)||"1";let c,h=s.statementToCode(t,"DO");return h=s.addLoopTrap(h,t),h=n(h,s.INDENT),t="",i.isNumber$$module$build$src$core$utils$string(r)&&i.isNumber$$module$build$src$core$utils$string(l)&&i.isNumber$$module$build$src$core$utils$string(a)?c=(Number(r)<=Number(l)?"":"-")+Math.abs(Number(a)):(t="",c=s.nameDB_.getDistinctName(o+"_inc",i.NameType$$module$build$src$core$names.VARIABLE),t+=c+" = ",t=(t=i.isNumber$$module$build$src$core$utils$string(a)?t+(Math.abs(a)+"\n"):t+"math.abs("+a+")\n")+"if ("+r+") > ("+l+") then\n"+(s.INDENT+c)+" = -"+c+"\n",t+="end\n"),t+"for "+o+" = "+r+", "+l+", "+c+" do\n"+h+"end\n"},controls_forEach:function(t,s){const i=s.getVariableName(t.getFieldValue("VAR")),o=s.valueToCode(t,"LIST",e.NONE)||"{}";let r=s.statementToCode(t,"DO");return r=s.addLoopTrap(r,t),r=n(r,s.INDENT),"for _, "+i+" in ipairs("+o+") do \n"+r+"end\n"}};f.controls_repeat=r,f.controls_repeat_ext=r,f.controls_whileUntil=function(t,s){const i="UNTIL"===t.getFieldValue("MODE");let o=s.valueToCode(t,"BOOL",i?e.UNARY:e.NONE)||"false",r=s.statementToCode(t,"DO");return r=s.addLoopTrap(r,t),r=n(r,s.INDENT),i&&(o="not "+o),"while "+o+" do\n"+r+"end\n"};var b={math_arithmetic:function(t,s){var i={ADD:[" + ",e.ADDITIVE],MINUS:[" - ",e.ADDITIVE],MULTIPLY:[" * ",e.MULTIPLICATIVE],DIVIDE:[" / ",e.MULTIPLICATIVE],POWER:[" ^ ",e.EXPONENTIATION]}[t.getFieldValue("OP")];const o=i[0];return i=i[1],[(s.valueToCode(t,"A",i)||"0")+o+(t=s.valueToCode(t,"B",i)||"0"),i]},math_atan2:function(t,s){const i=s.valueToCode(t,"X",e.NONE)||"0";return["math.deg(math.atan2("+(s.valueToCode(t,"Y",e.NONE)||"0")+", "+i+"))",e.HIGH]},math_change:function(t,s){const i=s.valueToCode(t,"DELTA",e.ADDITIVE)||"0";return(t=s.getVariableName(t.getFieldValue("VAR")))+" = "+t+" + "+i+"\n"},math_constant:function(t,s){return{PI:["math.pi",e.HIGH],E:["math.exp(1)",e.HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",e.MULTIPLICATIVE],SQRT2:["math.sqrt(2)",e.HIGH],SQRT1_2:["math.sqrt(1 / 2)",e.HIGH],INFINITY:["math.huge",e.HIGH]}[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)||"-math.huge")+"), "+(t=s.valueToCode(t,"HIGH",e.NONE)||"math.huge")+")",e.HIGH]},math_modulo:function(t,s){return[(s.valueToCode(t,"DIVIDEND",e.MULTIPLICATIVE)||"0")+" % "+(t=s.valueToCode(t,"DIVISOR",e.MULTIPLICATIVE)||"0"),e.MULTIPLICATIVE]},math_number:function(t,s){return t=Number(t.getFieldValue("NUM")),[String(t),0>t?e.UNARY:e.ATOMIC]},math_number_property:function(t,s){var i={EVEN:[" % 2 == 0",e.MULTIPLICATIVE,e.RELATIONAL],ODD:[" % 2 == 1",e.MULTIPLICATIVE,e.RELATIONAL],WHOLE:[" % 1 == 0",e.MULTIPLICATIVE,e.RELATIONAL],POSITIVE:[" > 0",e.RELATIONAL,e.RELATIONAL],NEGATIVE:[" < 0",e.RELATIONAL,e.RELATIONAL],DIVISIBLE_BY:[null,e.MULTIPLICATIVE,e.RELATIONAL],PRIME:[null,e.NONE,e.HIGH]};const o=t.getFieldValue("PROPERTY"),[n,r,l]=i[o];if(i=s.valueToCode(t,"NUMBER_TO_CHECK",r)||"0","PRIME"===o)t=s.provideFunction_("math_isPrime",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(n)\n -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods\n if n == 2 or n == 3 then\n return true\n end\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 not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then\n return false\n end\n -- Check all the numbers of form 6k +/- 1, up to sqrt(n).\n for x = 6, math.sqrt(n) + 1.5, 6 do\n if n % (x - 1) == 0 or n % (x + 1) == 0 then\n return false\n end\n end\n return true\nend\n`)+"("+i+")";else if("DIVISIBLE_BY"===o){if("0"===(t=s.valueToCode(t,"DIVISOR",e.MULTIPLICATIVE)||"0"))return["nil",e.ATOMIC];t=i+" % "+t+" == 0"}else t=i+n;return[t,l]},math_on_list:function(t,s){function i(){return s.provideFunction_("math_sum",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n local result = 0\n for _, v in ipairs(t) do\n result = result + v\n end\n return result\nend\n`)}var o=t.getFieldValue("OP");switch(t=s.valueToCode(t,"LIST",e.NONE)||"{}",o){case"SUM":o=i();break;case"MIN":o=s.provideFunction_("math_min",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n local result = math.huge\n for _, v in ipairs(t) do\n if v < result then\n result = v\n end\n end\n return result\nend\n`);break;case"AVERAGE":o=s.provideFunction_("math_average",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n return ${i()}(t) / #t\nend\n`);break;case"MAX":o=s.provideFunction_("math_max",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return 0\n end\n local result = -math.huge\n for _, v in ipairs(t) do\n if v > result then\n result = v\n end\n end\n return result\nend\n`);break;case"MEDIAN":o=s.provideFunction_("math_median",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n if #t == 0 then\n return 0\n end\n local temp = {}\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n table.insert(temp, v)\n end\n end\n table.sort(temp)\n if #temp % 2 == 0 then\n return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2\n else\n return temp[math.ceil(#temp / 2)]\n end\nend\n`);break;case"MODE":o=s.provideFunction_("math_modes",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n -- Source: http://lua-users.org/wiki/SimpleStats\n local counts = {}\n for _, v in ipairs(t) do\n if counts[v] == nil then\n counts[v] = 1\n else\n counts[v] = counts[v] + 1\n end\n end\n local biggestCount = 0\n for _, v in pairs(counts) do\n if v > biggestCount then\n biggestCount = v\n end\n end\n local temp = {}\n for k, v in pairs(counts) do\n if v == biggestCount then\n table.insert(temp, k)\n end\n end\n return temp\nend\n`);break;case"STD_DEV":o=s.provideFunction_("math_standard_deviation",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n local m\n local vm\n local total = 0\n local count = 0\n local result\n m = #t == 0 and 0 or ${i()}(t) / #t\n for _, v in ipairs(t) do\n if type(v) == 'number' then\n vm = v - m\n total = total + (vm * vm)\n count = count + 1\n end\n end\n result = math.sqrt(total / (count-1))\n return result\nend\n`);break;case"RANDOM":o=s.provideFunction_("math_random_list",`\nfunction ${s.FUNCTION_NAME_PLACEHOLDER_}(t)\n if #t == 0 then\n return nil\n end\n return t[math.random(#t)]\nend\n`);break;default:throw Error("Unknown operator: "+o)}return[o+"("+t+")",e.HIGH]},math_random_float:function(t,s){return["math.random()",e.HIGH]},math_random_int:function(t,s){return["math.random("+(s.valueToCode(t,"FROM",e.NONE)||"0")+", "+(t=s.valueToCode(t,"TO",e.NONE)||"0")+")",e.HIGH]}};b.math_round=l,b.math_single=l,b.math_trig=l;var $={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#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),e=s(983);const i=e.common.createBlockDefinitionsFromJsonArray([{type:"sleep",message0:"Wait %1 seconds",args0:[{type:"input_value",name:"SEC",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Wait for some time",helpUrl:""},{type:"print",message0:"Print %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Write text with newline",helpUrl:""},{type:"printerror",message0:"Log error: %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:0,tooltip:"Log an error",helpUrl:""},{type:"write",message0:"Write %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Write text without newline",helpUrl:""},{type:"read",message0:"Read",colour:100,tooltip:"Read from console",helpUrl:"",output:"String"},{type:"read_completion",message0:"Read with autocomplete %1",args0:[{type:"input_value",check:"Array"}],colour:100,tooltip:"Read from console",helpUrl:"",output:"String"},{type:"read_replace",message0:"Read and replace with %1",args0:[{type:"input_value",name:"CHAR",check:"String"}],colour:100,tooltip:"Read from console and replace input with a character",helpUrl:"",output:"String"},{type:"tonumber",message0:"To number: %1",args0:[{type:"input_value",name:"OBJ"}],colour:100,tooltip:"Convert any object to a number",helpUrl:"",output:"Number"},{type:"tostring",message0:"To string: %1",args0:[{type:"input_value",name:"OBJ"}],colour:100,tooltip:"Convert any object to string",helpUrl:"",output:"String"},{type:"fs_open",message0:"Open for %1 byte mode %2 file: %3",args0:[{type:"field_dropdown",name:"MODE",options:[["read","r"],["write (overwrite)","w"],["write (keep)","a"],["update (keep)","r+"],["update (overwrite)","w+"]]},{type:"field_checkbox",name:"ISBYTE",checked:!1},{type:"input_value",check:"String",name:"NAME"}],colour:50,tooltip:"Open a file",helpUrl:"",output:"FileHandle"},{type:"fs_close",message0:"Close file %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],previousStatement:null,nextStatement:null,colour:50,tooltip:"Close a file",helpUrl:""},{type:"fs_read",message0:"Read %1 bytes from file %2",args0:[{type:"input_value",name:"BYTE",check:"Number"},{type:"input_value",name:"FILE",check:"FileHandle"}],inputsInline:!0,colour:50,tooltip:"Read bytes from file",helpUrl:"",output:"String"},{type:"fs_readall",message0:"Read everything from %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],colour:50,tooltip:"Read all remaining contents from file",helpUrl:"",output:"String"},{type:"fs_readline",message0:"Read a line from %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],colour:50,tooltip:"Read a line from file",helpUrl:"",output:"String"},{colour:50,type:"fs_seek",message0:"Offset pointer in file %1 by %2, relative to the %3",args0:[{type:"input_value",name:"FILE",check:"FileHandle"},{type:"input_value",name:"OFFSET",check:"Number"},{type:"field_dropdown",name:"MODE",options:[["current position","cur"],["beginning of the file","set"],["end of the file","end"]]}]},{colour:50,type:"fs_seek_pos",message0:"Pointer position in file %1",args0:[{type:"input_value",name:"FILE",check:"FileHandle"}],output:"Number"},{type:"list_getkey",message0:"Get key %2 of table %1",args0:[{type:"input_value",name:"TABLE",check:"Array"},{type:"input_value",name:"KEY",check:null}],colour:100,tooltip:"Get element by key",helpUrl:"",output:null},{type:"fs_copy",message0:"Copy %1 as %2",args0:[{type:"input_value",name:"FILE",check:"String"},{type:"input_value",name:"DEST",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Copy file to another file",helpUrl:""},{type:"fs_delete",message0:"Delete %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Delete a file or directory",helpUrl:""},{type:"fs_exists",message0:"%1 exists?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the file exists",helpUrl:"",output:"Boolean"},{type:"fs_getdrive",message0:"Drive of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks which drive is file located on",helpUrl:"",output:"String"},{type:"fs_getfreespace",message0:"Free space of drive of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Returns free space on the drive this file is located on",helpUrl:"",output:"Number"},{type:"fs_getcapacity",message0:"Capacity of drive of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Returns capacity of the drive this file is located on",helpUrl:"",output:"Number"},{type:"fs_isdir",message0:"Is %1 a directory?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the path is a directory",helpUrl:"",output:"Boolean"},{type:"fs_makedir",message0:"Create directory %1",args0:[{type:"input_value",name:"TEXT",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Create a directory",helpUrl:""},{type:"fs_isreadonly",message0:"Is %1 read-only?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the file can only be read",helpUrl:"",output:"Boolean"},{type:"fs_getsize",message0:"Get size of file %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Get the size of a file",helpUrl:"",output:"Number"},{type:"fs_move",message0:"Move file %1 to %2",args0:[{type:"input_value",name:"FILE",check:"String"},{type:"input_value",name:"DEST",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Move file to a directory",helpUrl:""},{type:"fs_complete",message0:"Completions of name %1 from directory %2",args0:[{type:"input_value",name:"FILE",check:"String"},{type:"input_value",name:"DEST",check:"String"}],colour:100,tooltip:"Returns list of filenames that can complete input",helpUrl:"",output:"Array"},{type:"fs_attributes",message0:"Attributes of %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Return all attributes of a file",helpUrl:"",output:"Array"},{type:"fs_list",message0:"List dir %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Return all filepaths in a directory",helpUrl:"",output:"Array"},{type:"fs_find",message0:"Find files which match pattern %1",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Find all files which can fit in the search string",helpUrl:"",output:"Array"},{type:"fs_isdriveroot",message0:"Is drive of %1 root?",args0:[{type:"input_value",name:"FILE",check:"String"}],colour:100,tooltip:"Checks whether the drive is file located on is root",helpUrl:"",output:"Boolean"},{type:"shell_resolve",message0:"Resolve relative path %1",args0:[{type:"input_value",name:"PATH",check:"String"}],colour:0,tooltip:"Convert a relative path to an absolute one",helpUrl:"",output:"String"},{type:"fs_combine",message0:"Combine paths in table %1",args0:[{type:"input_value",name:"PATHS",check:"Array"}],colour:100,tooltip:"Combine paths",helpUrl:"",output:null},{type:"turtle_attack",message0:"Attack %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Attack!!!!",helpUrl:""},{type:"turtle_build",message0:"Build %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Place the selected block",helpUrl:""},{type:"turtle_compare",message0:"Compare %1 to inventory",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],colour:230,tooltip:"Is the block the same as selected?",helpUrl:"",output:"Boolean"},{type:"turtle_compareto",message0:"Compare to item in slot %1",args0:[{type:"input_value",name:"SLOT",check:"Number"}],colour:100,tooltip:"Compares selected item to another one",helpUrl:"",output:"Boolean"},{type:"turtle_craft",message0:"Attempt to craft %1 items",args0:[{type:"input_value",name:"NUM",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Anybody actually uses crafting turtles?",helpUrl:""},{type:"turtle_detect",message0:"Is there a block %1?",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],colour:230,tooltip:"Check for a block in given direction",helpUrl:"",output:"Boolean"},{type:"turtle_dig",message0:"Dig %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Dig. Rock and stone!",helpUrl:""},{type:"turtle_drop",message0:"Drop %1 %2 items",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","Up"],["down","Down"]]},{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Drop the selected item",helpUrl:""},{type:"turtle_equip",message0:"Equip to the %1",args0:[{type:"field_dropdown",name:"DIR",options:[["left","Left"],["right","Right"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Equips selected item. If slot is empty, unequip the side.",helpUrl:""},{type:"turtle_getfuellevel",message0:"Get fuel level",colour:100,tooltip:"Turtle not moving? Check the fuel!",helpUrl:"",output:"Number"},{type:"turtle_getfuellimit",message0:"Get fuel limit",colour:100,tooltip:"By default, 20000 for regular turtles and 100000 for advanced ones.",helpUrl:"",output:"Number"},{type:"turtle_getitemdetail",message0:"Item detail in slot %1",args0:[{type:"input_value",name:"SLOT",check:"Number"}],colour:230,tooltip:"Returns a table with some data about item. If 0, defaults to current slot.",helpUrl:"",output:"Array"},{type:"turtle_getitemdetail_detailed",message0:"Item detail in slot %1 (with more details)",args0:[{type:"input_value",name:"SLOT",check:"Number"}],colour:230,tooltip:"Gives more data at the cost of run time. If slot is 0, defaults to current slot.",helpUrl:"",output:"Array"},{type:"turtle_getselectedslot",message0:"Selected slot",colour:230,tooltip:"Get selected slot number",helpUrl:"",output:"Number"},{type:"turtle_inspect",message0:"Inspect the block %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","up"],["down","down"]]}],colour:230,tooltip:"I'm watching...",helpUrl:"",output:"Array"},{type:"turtle_move",message0:"Move %1 %2 times",args0:[{type:"field_dropdown",name:"DIR",options:[["forward","forward"],["up","up"],["down","down"],["back","back"],["left","turnLeft"],["right","turnRight"]]},{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:230,tooltip:"I like to move it move it",helpUrl:""},{type:"turtle_refuel",message0:"Refuel, consume at most %1 items",args0:[{type:"input_value",name:"NUM",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Refuel the turtle",helpUrl:""},{type:"turtle_refuel_isfuel",message0:"Is selected item combustable?",colour:100,tooltip:"Sticks are true, bucket of axolotl is false.",helpUrl:"",output:"Boolean"},{type:"turtle_select",message0:"Select slot %1",args0:[{type:"input_value",name:"NUM",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Select slot from 1 to 16",helpUrl:""},{type:"turtle_suck",message0:"Suck item from %1",args0:[{type:"field_dropdown",name:"DIR",options:[["forward",""],["up","up"],["down","down"]]}],previousStatement:null,nextStatement:null,colour:230,tooltip:"Hmmm...",helpUrl:""},{type:"turtle_transferto",message0:"Transfer item to slot %1",args0:[{type:"input_value",name:"SLOT",check:"Number"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Moves the item in inventory",helpUrl:""},{type:"get_arg",message0:"Get arg # %1",args0:[{type:"input_value",check:"Number",name:"NUM"}],colour:100,tooltip:"Get command line argument",helpUrl:"",output:null},{type:"get_arg_amount",message0:"Amount of arguments",colour:100,tooltip:"Amount of command line arguments",helpUrl:"",output:"Number"},{type:"args",message0:"args",colour:100,tooltip:"Argument table",helpUrl:"",output:"Array"},{type:"shallow_copy",message0:"Shallow copy of table %1",args0:[{type:"input_value",check:"Array",name:"TABLE"}],colour:100,tooltip:"Get a copy of a table",helpUrl:"",output:"Array"},{type:"os_pullevent",message0:"Pull event with filter: %1 raw? %2",args0:[{type:"input_value",check:"String",name:"FILTER"},{type:"field_checkbox",name:"RAW",checked:!1}],colour:0,tooltip:"Pull an event and return all data as a table. If raw, will also pull terminate event.",helpUrl:"",output:"Array"},{type:"disk_ispresent",message0:"Is disk %1 present?",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Checks whether any item at all is in the disk drive",helpUrl:"",output:"Boolean"},{type:"disk_getlabel",message0:"Get label of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Get the label of the floppy disk, record, or other media within the given disk drive",helpUrl:"",output:"String"},{type:"disk_setlabel",message0:"Set label of disk %1 to %2",args0:[{type:"input_value",name:"DRIVE",check:"String"},{type:"input_value",name:"LABEL",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Set the label of the floppy disk or other media",helpUrl:""},{type:"disk_hasdata",message0:"Has disk %1 data?",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Check whether the current disk provides a mount",helpUrl:"",output:"Boolean"},{type:"disk_getmountpath",message0:"Get mount path of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Find the directory name on the local computer where the contents of the current floppy disk (or other mount) can be found",helpUrl:"",output:"String"},{type:"disk_hasaudio",message0:"Has disk %1 audio?",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Whether the current disk is a music disk as opposed to a floppy disk or other item",helpUrl:"",output:"Boolean"},{type:"disk_getaudiotitle",message0:"Get audio title of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Get the title of the audio track from the music record in the drive",helpUrl:"",output:"String"},{type:"disk_playaudio",message0:"Play audio of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Starts playing the music record in the drive",helpUrl:""},{type:"disk_stopaudio",message0:"Stop audio of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Stops the music record in the drive from playing",helpUrl:""},{type:"disk_eject",message0:"Eject disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],previousStatement:null,nextStatement:null,colour:100,tooltip:"Ejects any item currently in the drive, spilling it into the world as a loose item",helpUrl:""},{type:"disk_getid",message0:"Get ID of disk %1",args0:[{type:"input_value",name:"DRIVE",check:"String"}],colour:100,tooltip:"Returns a number which uniquely identifies the disk in the drive",helpUrl:"",output:"String"},{type:"side",message0:"Side %1",args0:[{type:"field_dropdown",name:"SIDE",options:[["bottom","bottom"],["top","top"],["front","front"],["back","back"],["left","left"],["right","right"]]}],colour:100,tooltip:"Side of the computer",helpUrl:"",output:"String"},{type:"http_get",message0:"GET %1 with header (optional) %2",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"}],inputsInline:!0,colour:100,tooltip:"Make a HTTP GET request to the given url",helpUrl:"",output:"String"},{type:"http_post",message0:"POST %1 with data %2 and headers (optional) %3",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"DATA",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"}],inputsInline:!0,colour:100,tooltip:"Make a HTTP POST request to the given url",helpUrl:"",output:"String"},{type:"http_request",message0:"Request %1 with data %2 and header (optional) %3",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"DATA",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"}],colour:100,tooltip:"Asynchronously make a HTTP request to the given url",helpUrl:"",output:"String"},{type:"http_checkurl",message0:"Check URL %1 Async? %2",args0:[{type:"input_value",name:"URL",check:"String"},{type:"field_checkbox",name:"ASYNC",checked:!1}],colour:100,tooltip:"Determine whether a URL can be requested",helpUrl:"",output:"Boolean"},{type:"http_websocket",message0:"(Not working)Open websocket %1 with headers (optional) %2 Async? %3",args0:[{type:"input_value",name:"URL",check:"String"},{type:"input_value",name:"HEADERS",check:"Array"},{type:"field_checkbox",name:"ASYNC",checked:!1}],inputsInline:!0,colour:100,tooltip:"Open a websocket to the given url (not working)",helpUrl:"",output:"String"},{type:"per_getnames",message0:"Get names of all peripherals",colour:100,tooltip:"Get names of all peripherals",helpUrl:"",output:"Array"},{type:"per_ispresent",message0:"Is peripheral %1 present?",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Check whether a peripheral is present",helpUrl:"",output:"Boolean"},{type:"per_gettypes",message0:"Get type of peripheral %1",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Get the type of a peripheral",helpUrl:"",output:"String"},{type:"per_hastype",message0:"Has peripheral %1 type %2?",args0:[{type:"input_value",name:"NAME",check:"String"},{type:"input_value",name:"TYPE",check:"String"}],colour:100,tooltip:"Check whether a peripheral has a specific type",helpUrl:"",output:"Boolean"},{type:"per_getmethods",message0:"Get methods of peripheral %1",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Get the methods of a peripheral",helpUrl:"",output:"Array"},{type:"per_call",message0:"Call method %1 of peripheral %2 with arguments %3",args0:[{type:"input_value",name:"METHOD",check:"String"},{type:"input_value",name:"NAME",check:"String"},{type:"input_value",name:"ARGS",check:"Array"}],colour:100,tooltip:"Call a method of a peripheral",helpUrl:"",output:null},{type:"per_wrap",message0:"Wrap peripheral %1",args0:[{type:"input_value",name:"NAME",check:"String"}],colour:100,tooltip:"Wrap a peripheral",helpUrl:"",output:"Table"},{type:"per_find",message0:"Find peripheral with type %1",args0:[{type:"input_value",name:"TYPE",check:"String"}],colour:100,tooltip:"Find a peripheral with a specific type",helpUrl:"",output:"String"}]);var o=s(619);const n=Object.create(null);n.sleep=function(t,e){return`sleep(${e.valueToCode(t,"SEC",o.Order.NONE)||"''"})\n`},n.print=function(t,e){return`print(${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})\n`},n.printerror=function(t,e){return`printError(${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})\n`},n.write=function(t,e){return`write(${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})\n`},n.read=function(t,e){return"read()"},n.read_completion=function(t,e){return`read(nil, nil, ${e.valueToCode(t,"TEXT",o.Order.NONE)||"''"})`},n.read_replace=function(t,e){return`read(${e.valueToCode(t,"CHAR",o.Order.NONE)||"''"})`},n.fs_open=function(t,e){const s=e.valueToCode(t,"NAME",o.Order.NONE)||"''",i="TRUE"===t.getFieldValue("ISBYTE");let n=t.getFieldValue("MODE");return i&&(n=n.slice(0,1)+"b"+n.slice(1)),[`fs.open(${s},${n})`,o.Order.NONE]},n.fs_close=function(t,e){return`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.close()\n`},n.fs_read=function(t,e){const s=e.valueToCode(t,"BYTE",o.Order.NONE)||"1";return[`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.read(${1==s?"":s})`,o.Order.NONE]},n.fs_readall=function(t,e){return[`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.readAll()`,o.Order.NONE]},n.fs_readline=function(t,e){return[`${e.valueToCode(t,"FILE",o.Order.NONE)||"''"}.readLine()`,o.Order.NONE]},n.shell_resolve=function(t,e){return[`shell.resolve(${e.valueToCode(t,"PATH",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_seek=function(t,e){const s=e.valueToCode(t,"FILE",o.Order.NONE),i=e.valueToCode(t,"OFFSET",o.Order.NONE);return`${s}.seek("${t.getFieldValue("MODE")}",${i})\n`},n.fs_seek_pos=function(t,e){return[`${e.valueToCode(t,"FILE",o.Order.NONE)}.seek("cur")`,o.Order.NONE]},n.tostring=function(t,e){return[`tostring(${e.valueToCode(t,"OBJ",o.Order.NONE)})`,o.Order.NONE]},n.tonumber=function(t,e){return[`tonumber(${e.valueToCode(t,"OBJ",o.Order.NONE)})`,o.Order.NONE]},n.fs_copy=function(t,e){return`fs.copy("${e.valueToCode(t,"FILE",o.Order.NONE)}",${e.valueToCode(t,"DEST",o.Order.NONE)})\n`},n.fs_move=function(t,e){return`fs.copy("${e.valueToCode(t,"FILE",o.Order.NONE)}",${e.valueToCode(t,"DEST",o.Order.NONE)})\n`},n.fs_list=function(t,e){return[`fs.list(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_delete=function(t,e){return`fs.delete("${e.valueToCode(t,"FILE",o.Order.NONE)}")\n`},n.fs_makedir=function(t,e){return`fs.makedir("${e.valueToCode(t,"TEXT",o.Order.NONE)}")\n`},n.fs_isdir=function(t,e){return[`fs.isDir(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_isreadonly=function(t,e){return[`fs.isReadOnly(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getsize=function(t,e){return[`fs.getSize(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getcapacity=function(t,e){return[`fs.getCapacity(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getfreespace=function(t,e){return[`fs.getFreeSpace(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_attributes=function(t,e){return[`fs.attributes(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_exists=function(t,e){return[`fs.exists(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_complete=function(t,e){return[`fs.complete(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"},${e.valueToCode(t,"DEST",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_find=function(t,e){return[`fs.find(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_getdrive=function(t,e){return[`fs.getDrive(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_isdriveroot=function(t,e){return[`fs.isDriveRoot(${e.valueToCode(t,"FILE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.fs_combine=function(t,e){return[`fs.combine(unpack(${e.valueToCode(t,"PATHS",o.Order.NONE)||"''"}))`,o.Order.NONE]},n.list_getkey=function(t,e){return[`${e.valueToCode(t,"TABLE",o.Order.NONE)||"{}"}[${e.valueToCode(t,"KEY",o.Order.NONE)||"''"}]`,o.Order.NONE]},n.turtle_move=function(t,e){const s=t.getFieldValue("DIR"),i=e.valueToCode(t,"TIMES",o.Order.NONE)||"";return`${i>1?`for i=1,${i} do `:""}turtle.${s}()${i>1?" end":""}\n`},n.turtle_attack=function(t,e){return`turtle.attack${t.getFieldValue("DIR")}()\n`},n.turtle_dig=function(t,e){return`turtle.dig${t.getFieldValue("DIR")}()\n`},n.turtle_build=function(t,e){return`turtle.build${t.getFieldValue("DIR")}()\n`},n.turtle_compare=function(t,e){return[`turtle.compare${t.getFieldValue("DIR")}()`,o.Order.NONE]},n.turtle_drop=function(t,e){return`turtle.drop${t.getFieldValue("DIR")}(${e.valueToCode(t,"TIMES",o.Order.NONE)||""})\n`},n.turtle_equip=function(t,e){return`turtle.equip${t.getFieldValue("DIR")}()\n`},n.turtle_detect=function(t,e){return[`turtle.detect${t.getFieldValue("DIR")}()`,o.Order.NONE]},n.turtle_suck=function(t,e){return`turtle.suck${t.getFieldValue("DIR")}()\n`},n.turtle_inspect=function(t,e){return[`{turtle.inspect${t.getFieldValue("DIR")}()}`,o.Order.NONE]},n.turtle_craft=function(t,e){return`turtle.craft(${e.valueToCode(t,"NUM",o.Order.NONE)||"64"})\n`},n.turtle_compareto=function(t,e){return[`turtle.compareTo(${e.valueToCode(t,"SLOT",o.Order.NONE)||""})`,o.Order.NONE]},n.turtle_transferto=function(t,e){return`turtle.transferTo(${e.valueToCode(t,"SLOT",o.Order.NONE)||""})\n`},n.turtle_getfuellevel=function(t,e){return["turtle.getFuelLevel()",o.Order.NONE]},n.turtle_getfuellimit=function(t,e){return["turtle.getFuelLimit()",o.Order.NONE]},n.turtle_getitemdetail=function(t,e){const s=e.valueToCode(t,"SLOT",o.Order.NONE)||"";return[`turtle.getItemDetail(${s>0?s:""})`,o.Order.NONE]},n.turtle_getitemdetail_detailed=function(t,e){const s=e.valueToCode(t,"SLOT",o.Order.NONE)||"";return[`turtle.getItemDetail(${s>0?s+",":""},true)`,o.Order.NONE]},n.turtle_getselectedslot=function(t,e){return["turtle.getSelectedSlot()",o.Order.NONE]},n.turtle_refuel_isfuel=function(t,e){return["turtle.refuel(0)",o.Order.NONE]},n.turtle_refuel=function(t,e){return`turtle.refuel(${e.valueToCode(t,"NUM",o.Order.NONE)||"64"})\n`},n.turtle_select=function(t,e){return`turtle.select(${e.valueToCode(t,"NUM",o.Order.NONE)||"1"})\n`},n.shallow_copy=function(t,e){const s=e.provideFunction_("shallow_copy",`function ${e.FUNCTION_NAME_PLACEHOLDER_}\n local t2 = {}\n for k,v in pairs(t) do\n t2[k] = v\n end\n return t2\nend\n`);return e.provideFunction_("getArgs","local args = {...}\n"),[`${s}(${e.valueToCode(t,"TABLE",o.Order.NONE)||"1"})`,o.Order.NONE]},n.get_arg=function(t,e){return e.provideFunction_("getArgs","local args = {...}\n"),[`args[${e.valueToCode(t,"NUM",o.Order.NONE)||"1"}]`,o.Order.NONE]},n.args=function(t,e){return e.provideFunction_("getArgs","local args = {...}\n"),["args",o.Order.NONE]},n.get_arg_amount=function(t,e){return e.provideFunction_("getArgs","local args = {...}\n"),["#args",o.Order.NONE]},n.disk_ispresent=function(t,e){return[`disk.isPresent("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_getlabel=function(t,e){return[`disk.getLabel("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_setlabel=function(t,e){return`disk.setLabel("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}",${e.valueToCode(t,"LABEL",o.Order.NONE)||"''"})\n`},n.disk_hasdata=function(t,e){return[`disk.hasData("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_getmountpath=function(t,e){return[`disk.getMountPath("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_hasaudio=function(t,e){return[`disk.hasAudio("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_getaudiotitle=function(t,e){return[`disk.getAudioTitle("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.disk_playaudio=function(t,e){return`disk.playAudio("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")\n`},n.disk_stopaudio=function(t,e){return`disk.stopAudio("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")\n`},n.disk_eject=function(t,e){return`disk.eject("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")\n`},n.disk_getid=function(t,e){return[`disk.getID("${e.valueToCode(t,"DRIVE",o.Order.NONE)||"''"}")`,o.Order.NONE]},n.side=function(t,e){return[`${t.getFieldValue("SIDE")}`,o.Order.NONE]},n.http_get=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''";return"''"!=i?[`http.get(${s},${i})`,o.Order.NONE]:[`http.get(${s})`,o.Order.NONE]},n.http_post=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"DATA",o.Order.NONE)||"''",n=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''";return"''"!=n?[`http.post(${s},${i},${n})`,o.Order.NONE]:[`http.post(${s},${i})`,o.Order.NONE]},n.http_request=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"DATA",o.Order.NONE)||"''",n=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''";return"''"!=n?[`http.request(${s},${i},${n})`,o.Order.NONE]:[`http.request(${s},${i})`,o.Order.NONE]},n.http_checkurl=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"ASYNC",o.Order.NONE)||"''";return"''"!=i?[`http.checkURL(${s},${i})`,o.Order.NONE]:[`http.checkURL(${s})`,o.Order.NONE]},n.http_websocket=function(t,e){const s=e.valueToCode(t,"URL",o.Order.NONE)||"''",i=e.valueToCode(t,"HEADERS",o.Order.NONE)||"''",n=t.getFieldValue("ASYNC");return"''"!=i&&"TRUE"==n?[`http.websocketAsync(${s},${i})`,o.Order.NONE]:"''"!=i?[`http.websocket(${s},${i})`,o.Order.NONE]:"TRUE"==n?[`http.websocketAsync(${s})`,o.Order.NONE]:[`http.websocket(${s})`,o.Order.NONE]},n.per_getnames=function(t,e){return["peripheral.getNames()",o.Order.NONE]},n.per_ispresent=function(t,e){return[`peripheral.isPresent(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_gettypes=function(t,e){return[`peripheral.getType(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_hastype=function(t,e){return[`peripheral.hasType(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"},${e.valueToCode(t,"TYPE",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_getmethods=function(t,e){return[`peripheral.getMethods(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_call=function(t,e){return[`peripheral.call(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"},${e.valueToCode(t,"METHOD",o.Order.NONE)||"''"},${e.valueToCode(t,"ARGS",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_wrap=function(t,e){return[`peripheral.wrap(${e.valueToCode(t,"NAME",o.Order.NONE)||"''"})`,o.Order.NONE]},n.per_find=function(t,e){return[`peripheral.find(${e.valueToCode(t,"TYPE",o.Order.NONE)||"''"})`,o.Order.NONE]};const r=function(t){const s=e.serialization.workspaces.save(t);return JSON.stringify(s)};var l=s(72),a=s.n(l),c=s(825),h=s.n(c),u=s(659),d=s.n(u),p=s(56),g=s.n(p),_=s(540),T=s.n(_),m=s(113),E=s.n(m),f=s(523),b={};b.styleTagTransform=E(),b.setAttributes=g(),b.insert=d().bind(null,"head"),b.domAPI=h(),b.insertStyleElement=T(),a()(f.A,b),f.A&&f.A.locals&&f.A.locals,t.common.defineBlocks(i),Object.assign(o.luaGenerator.forBlock,n);const $=document.getElementById("generatedCode").firstChild,I=(document.getElementById("output"),document.getElementById("blocklyDiv")),O=t.inject(I,{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:"category",name:"Lists",categorystyle:"list_category",contents:[{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:"block",type:"list_getkey"},{kind:"block",type:"shallow_copy"}]},{kind:"sep"},{kind:"category",name:"CC: Base",categorystyle:"text_category",contents:[{kind:"block",type:"sleep",inputs:{SEC:{shadow:{type:"math_number",fields:{NUM:5}}}}},{kind:"block",type:"args"},{kind:"block",type:"get_arg"},{kind:"block",type:"get_arg_amount"},{kind:"block",type:"print",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"write",inputs:{TEXT:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"read"},{kind:"block",type:"read_replace",inputs:{CHAR:{shadow:{type:"text",fields:{TEXT:"*"}}}}},{kind:"block",type:"tostring"},{kind:"block",type:"tonumber"},{kind:"block",type:"side"}]},{kind:"category",name:"CC: Shell + OS",categorystyle:"text_category",contents:[{kind:"block",type:"shell_resolve"}]},{kind:"category",name:"CC: Turtle",categorystyle:"text_category",contents:[{kind:"block",type:"turtle_move",inputs:{TIMES:{shadow:{type:"math_number",fields:{NUM:1}}}}},{kind:"block",type:"turtle_select"},{kind:"block",type:"turtle_attack"},{kind:"block",type:"turtle_build"},{kind:"block",type:"turtle_dig"},{kind:"block",type:"turtle_detect"},{kind:"block",type:"turtle_compare"},{kind:"block",type:"turtle_drop"},{kind:"block",type:"turtle_compareto"},{kind:"block",type:"turtle_craft"},{kind:"block",type:"turtle_equip"},{kind:"block",type:"turtle_getfuellevel"},{kind:"block",type:"turtle_getfuellimit"},{kind:"block",type:"turtle_getitemdetail"},{kind:"block",type:"turtle_getitemdetail_detailed"},{kind:"block",type:"turtle_getselectedslot"},{kind:"block",type:"turtle_inspect"},{kind:"block",type:"turtle_refuel"},{kind:"block",type:"turtle_refuel_isfuel"},{kind:"block",type:"turtle_suck"},{kind:"block",type:"turtle_transferto"}]},{kind:"category",name:"CC: fs",categorystyle:"text_category",contents:[{kind:"block",type:"fs_open"},{kind:"block",type:"fs_close"},{kind:"block",type:"fs_seek",inputs:{OFFSET:{shadow:{type:"math_number",fields:{NUM:1}}}}},{kind:"block",type:"fs_seek_pos"},{kind:"block",type:"fs_readall"},{kind:"block",type:"fs_readline"},{kind:"block",type:"fs_attributes"},{kind:"block",type:"fs_copy"},{kind:"block",type:"fs_delete"},{kind:"block",type:"fs_exists"},{kind:"block",type:"fs_getdrive"},{kind:"block",type:"fs_getfreespace"},{kind:"block",type:"fs_getcapacity"},{kind:"block",type:"fs_isdir"},{kind:"block",type:"fs_makedir"},{kind:"block",type:"fs_isreadonly"},{kind:"block",type:"fs_getsize"},{kind:"block",type:"fs_move"},{kind:"block",type:"fs_complete"},{kind:"block",type:"fs_combine"},{kind:"block",type:"fs_list"},{kind:"block",type:"fs_find"},{kind:"block",type:"fs_isdriveroot"}]},{kind:"category",name:"CC: Disk",categorystyle:"text_category",contents:[{kind:"block",type:"disk_ispresent"},{kind:"block",type:"disk_getlabel"},{kind:"block",type:"disk_setlabel",inputs:{LABEL:{shadow:{type:"text",fields:{TEXT:"abc"}}}}},{kind:"block",type:"disk_hasdata"},{kind:"block",type:"disk_getmountpath"},{kind:"block",type:"disk_hasaudio"},{kind:"block",type:"disk_getaudiotitle"},{kind:"block",type:"disk_playaudio"},{kind:"block",type:"disk_stopaudio"},{kind:"block",type:"disk_eject"},{kind:"block",type:"disk_getid"}]},{kind:"category",name:"CC: HTTP",categorystyle:"text_category",contents:[{kind:"block",type:"http_checkurl"},{kind:"block",type:"http_get"},{kind:"block",type:"http_post"},{kind:"block",type:"http_request"},{kind:"block",type:"http_websocket"}]},{kind:"category",name:"CC: Peripherals",categorystyle:"text_category",contents:[{kind:"block",type:"per_getnames"},{kind:"block",type:"per_gettypes",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}},{kind:"block",type:"per_ispresent",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}},{kind:"block",type:"per_getmethods",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}},{kind:"block",type:"per_call",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}},METHOD:{shadow:{type:"text",fields:{TEXT:"open"}}}}},{kind:"block",type:"per_gettypes",inputs:{NAME:{shadow:{type:"text",fields:{TEXT:"modem"}}}}}]},{kind:"sep"},{kind:"category",name:"Variables",categorystyle:"variable_category",custom:"VARIABLE"},{kind:"category",name:"Functions",categorystyle:"procedure_category",custom:"PROCEDURE"}]}}),S=()=>{const t=o.luaGenerator.workspaceToCode(O);$.innerText=t};S(),O.addChangeListener((t=>{t.isUiEvent||r(O)})),O.addChangeListener((e=>{e.isUiEvent||e.type==t.Events.FINISHED_LOADING||O.isDragging()||S()}));const C=document.getElementById("fileName"),R=document.getElementById("downloadButton"),k=document.getElementById("loadButton");R.onclick=()=>{const t=r(O),e=new Blob([t],{type:"application/json"}),s=URL.createObjectURL(e),i=document.createElement("a");i.href=s,i.download=C.value||"workspace.json",i.click()},k.onclick=()=>{const t=document.createElement("input");t.type="file",t.accept=".json",t.click(),t.onchange=()=>{const s=t.files[0],i=new FileReader;i.onload=()=>{var t,s;t=O,s=i.result,e.Events.disable(),e.serialization.workspaces.load(JSON.parse(s),t,!1),e.Events.enable()},i.readAsText(s)}}})()})(); \ No newline at end of file diff --git a/index.html b/index.html index 2d1289d..6e4820f 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -CC Lua Code Generator
\ No newline at end of file +CC Lua Code Generator
\ No newline at end of file