maze-blockly-wrapper 0.2.2 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockly-B8_W0qMx.js +328 -0
- package/dist/blockly-B8_W0qMx.js.map +1 -0
- package/dist/blockly-D-XLGkbZ.cjs +2 -0
- package/dist/blockly-D-XLGkbZ.cjs.map +1 -0
- package/dist/blockly_compressed-BMyLVN-Q.js +15717 -0
- package/dist/blockly_compressed-BMyLVN-Q.js.map +1 -0
- package/dist/blockly_compressed-BSXJbxOI.cjs +792 -0
- package/dist/blockly_compressed-BSXJbxOI.cjs.map +1 -0
- package/dist/blocks-B72zId9w.js +1316 -0
- package/dist/blocks-B72zId9w.js.map +1 -0
- package/dist/blocks-GkRPBplU.cjs +4 -0
- package/dist/blocks-GkRPBplU.cjs.map +1 -0
- package/dist/components/ExternalImportTest.d.ts +16 -0
- package/dist/components/maze/MazeBlocklyContainer.d.ts +0 -1
- package/dist/components/maze/blocks.d.ts +5 -1
- package/dist/index-D10FGDwl.js +3666 -0
- package/dist/index-D10FGDwl.js.map +1 -0
- package/dist/index-I2TnBYCs.cjs +74 -0
- package/dist/index-I2TnBYCs.cjs.map +1 -0
- package/dist/index.cjs.js +1 -1082
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +31 -21796
- package/dist/index.esm.js.map +1 -1
- package/dist/javascript-CBgY3c4m.js +819 -0
- package/dist/javascript-CBgY3c4m.js.map +1 -0
- package/dist/javascript-DCJc0bzp.cjs +219 -0
- package/dist/javascript-DCJc0bzp.cjs.map +1 -0
- package/dist/utils/blocklySetup.d.ts +2 -5
- package/package.json +1 -1
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
"use strict";const Nm=require("./index-I2TnBYCs.cjs");var An={exports:{}},Df=An.exports,Am;function Nf(){return Am||(Am=1,(function(Om,Af){(function(n,I){Om.exports=I()})(Df,function(){var n={},I,Hh,qt,On,Ri,Ve,Ot,Di,_e,xn,Je,Ee,ys,Ro,Ln,k,xe,x,vs,We,Do,Cs,Le,_t,Ni,Mn,No,Gh,ws,Vh,Bn,Ai,we,C,Wh,Oi,Pn,Fn,Hn,z,Uh,xi,zh,w,Xh,m,b,Li,O,Mi,F,Qt,Bi,eo,to,Ao,Yh,ks,Pi,Oo,Fi,Ze,xt,xo,Gn,Vn,Me,Is,Ss,Kh,Lt,Rs,Wn,oo,Ds,jh,Un,Jh,Ns,ke,qe,zn,As,Zh,Xn,Qe,Mt,Yn,Kn,jn,Jn,Os,Hi,Zn,qn,Qn,Lo,qh,Mo,Qh,Gi,ea,xs,Vi,ta,Wi,oa,Ui,el,tl,zi,Xi,Yi,Ls,sa,Bo,Ms,Ki,ia,ra,na,et,oe,Bs,ol,tt,Bt,la,sl,ji,il,ca,rl,Ps,ua,Ji,ha,Zi,aa,da,$a,Po,pa,nl,le,qi,ll,Qi,er,ga,cl,ul,ma,tr,so,or,fa,hl,al,ba,_a,io,Ea,Fs,Fo,Ho,Be,Ta,ya,va,Ca,wa,ka,Ia,dl,Pt,Go,$l,Sa,Ra,Da,Na,Aa,Oa,xa,La,Ma,pl,Ba,ro,sr,Pa,Vo,ir,gl,ml,rr,nr,fl,Fa,bl,_l,El,Tl,yl,vl,Cl,Ha,Hs,wl,lr,cr,ot,kl,Il,Gs,Sl,Rl,Ga,ur,Dl,Va,Wa,Ua,za,Xa,Wo,Nl,Al,Vs,Ol,Ya,Ka,xl,Ll,Et,Ml,Bl,ja,Ja,Za,qa,Pl,Qa,Fl,ed,no,Ws,hr,ar,lo,Hl,dr,Gl,J,td,Uo,zo,od,Vl,$r,Xo,Wl,co,Us,Ul,zl,sd,id,rd,Xl,nd,Yl,Yo,ld,cd,ud,hd,zs,Kl,jl,pr,gr,ad,Xs,Jl,Ys,dd,$d,Ft,Zl,st,pd,gd,ql,md,uo,Ql,fd,bd,_d,Ed,Td,ec,yd,vd,mr,Cd,wd,tc,it,kd,Id,Ko,Sd,oc,fr,Rd,Dd,Nd,sc,br,ic,_r,Ad,Od,xd,Ld,y,ve,ce,K,rt,jo,v,Z,Md,Bd,Pd,rc,Fd,Er,nc,lc,cc,uc,Jo,Hd,Gd,Vd,Zo,hc,Wd,Tr,Pe,ac,qo,Ue,Qo,dc,$c,Ud,Ht,yr,Ks,pc,zd,gc,Xd,vr,mc,fc,bc,Yd,_c,Kd,Cr,jd,Jd,js,Zd,Ec,wr,kr,Ir,Sr,Tc,qd,yc,Rr,Dr,Qd,Nr,e$,vc,t$,Gt,Cc,Js,wc,kc,Ar,Ic,Sc,Rc,Dc,Nc,Ac,Oc,xc,Lc,o$,s$,i$,r$,n$,l$,c$,u$,Mc,Bc,Pc,Fc,Hc,Gc,Vc,Or,Zs,Wc,h$,Uc,zc,Xc,Yc,Kc,jc,Jc,Zc,qc,Qc,a$,d$,$$,eu,p$,g$,m$,f$,$;I=function(e,t,o,s){if(!(e instanceof g)&&typeof e!="string"||`${e}`.trim()==="")throw Error('Invalid type "'+e+'". The type must be a non-empty string or a Blockly.registry.Type.');if(e=`${e}`.toLowerCase(),typeof t!="string"||t.trim()==="")throw Error('Invalid name "'+t+'". The name must be a non-empty string.');const i=t.toLowerCase();if(!o)throw Error("Can not register a null value");let r=Vt[e],l=xr[e];if(r||(r=Vt[e]=Object.create(null),l=xr[e]=Object.create(null)),Hh(e,o),!s&&r[i]&&r[i]!==o)throw Error('Name "'+i+'" with type "'+e+'" already registered.');r[i]=o,l[i]=t},Hh=function(e,t){switch(e){case String(g.FIELD):if(typeof t.fromJson!="function")throw Error('Type "'+e+'" must have a fromJson function')}},qt=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();const o=Vt[e];o&&o[t]?(delete Vt[e][t],delete xr[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},On=function(e,t,o){e=`${e}`.toLowerCase(),t=t.toLowerCase();const s=Vt[e];if(!s||!s[t]){if(t="Unable to find ["+t+"]["+e+"] in the registry.",o)throw Error(t+" You must require or register a "+e+" plugin.");return console.warn(t),null}return s[t]},Ri=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=Vt[e])?!!e[t]:!1},Ve=function(e,t,o){return On(e,t,o)},Ot=function(e,t,o){return On(e,t,o)},Di=function(e,t,o){e=`${e}`.toLowerCase();var s=Vt[e];if(!s){if(s=`Unable to find [${e}] in the registry.`,o)throw Error(`${s} You must require or register a ${e} plugin.`);return console.warn(s),null}if(!t)return s;e=xr[e],o=Object.create(null);for(const i of Object.keys(s))o[e[i]]=s[i];return o},_e=function(e,t,o){return t=t.plugins[String(e)]||Ce,typeof t=="function"?t:Ve(e,t,o)},xn=function(e,t){Je(),Mr=setTimeout(function(){t&&t.handleRightClick(e)},Lm)},Je=function(){Mr&&(clearTimeout(Mr),Mr=0)},Ee=function(){Lr=null},ys=function(e){return!e.type.startsWith("pointer")||e instanceof PointerEvent&&Ln(e)},Ro=function(e){return`${e.pointerId}`},Ln=function(e){const t=Ro(e);return Lr?Lr===t:e.type==="pointerdown"?(Lr=t,!0):!1},k=function(e,t,o,s,i){function r(c){(i||ys(c))&&(o?s.call(o,c):s(c))}const l=[];if(t in ho)for(let c=0;c<ho[t].length;c++){const p=ho[t][c];e.addEventListener(p,r,!1),l.push([e,p,r])}else e.addEventListener(t,r,!1),l.push([e,t,r]);return l},xe=function(e,t,o,s){function i(l){o?s.call(o,l):s(l)}const r=[];if(t in ho)for(let l=0;l<ho[t].length;l++){const c=ho[t][l];e.addEventListener(c,i,!1),r.push([e,c,i])}else e.addEventListener(t,i,!1),r.push([e,t,i]);return r},x=function(e){const t=e[e.length-1][2];for(;e.length;){const[o,s,i]=e.pop();o.removeEventListener(s,i,!1)}return t},vs=function(e){if(e.target instanceof HTMLElement){if(e.target.isContentEditable||e.target.getAttribute("data-is-text-input")==="true")return!0;if(e.target instanceof HTMLInputElement)return e=e.target,e.type==="text"||e.type==="number"||e.type==="email"||e.type==="password"||e.type==="search"||e.type==="tel"||e.type==="url";if(e.target instanceof HTMLTextAreaElement)return!0}return!1},We=function(e){return e.ctrlKey&&iu?!0:e.button===2},Do=function(e,t,o){const s=t.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,o||(o=t.getScreenCTM().inverse()),s.matrixTransform(o)},Cs=function(e){switch(e.deltaMode){default:return{x:e.deltaX,y:e.deltaY};case 1:return{x:e.deltaX*R$,y:e.deltaY*R$};case 2:return{x:e.deltaX*D$,y:e.deltaY*D$}}},Le=function(){return"blockly-"+(Pm++).toString(36)},_t=function(){return O$.genUid()},Ni=function(e){return e.type===a.BLOCK_CREATE},Mn=function(e){return e.type===a.BLOCK_DELETE},No=function(e){return e.type===a.BLOCK_CHANGE},Gh=function(e){return e.type===a.BLOCK_FIELD_INTERMEDIATE_CHANGE},ws=function(e){return e.type===a.BLOCK_MOVE},Vh=function(e){return e.type===a.CLICK},Bn=function(e){return e.type===a.BUBBLE_OPEN},Ai=function(e){return e.type===a.VIEWPORT_CHANGE},n.setRecordUndo$$module$build$src$core$events$utils=function(e){qs=e},we=function(){return qs},C=function(e){L$.fireInternal(e)},Wh=function(e){if(z()){if(!vt.length)try{requestAnimationFrame(()=>{setTimeout(Oi,0)})}catch{setTimeout(Oi,0)}Pn(e)}},Oi=function(){const e=Fn(vt);vt.length=0;for(const t of e){if(!t.workspaceId)continue;let o;(o=xt(t.workspaceId))==null||o.fireChangeListener(t)}},Pn=function(e){if(No(e)&&e.element==="mutation"){let t;for(t=vt.length;t>0;t--){const o=vt[t-1];if(o.group!==e.group||o.workspaceId!==e.workspaceId||!ws(o)||o.newParentId!==e.blockId)break}vt.splice(t,0,e)}else vt.push(e)},Fn=function(e){const t=[];for(const o of e)if(e=t[t.length-1],!o.isNull())if(e&&e.workspaceId===o.workspaceId&&e.group===o.group)if(ws(o)&&ws(e)&&o.blockId===e.blockId){if(e.newParentId=o.newParentId,e.newInputName=o.newInputName,e.newCoordinate=o.newCoordinate,e.reason||o.reason){let s,i;e.reason=Array.from(new Set(((s=e.reason)!=null?s:[]).concat((i=o.reason)!=null?i:[])))}}else No(o)&&No(e)&&o.blockId===e.blockId&&o.element===e.element&&o.name===e.name?e.newValue=o.newValue:Ai(o)&&Ai(e)?(e.viewTop=o.viewTop,e.viewLeft=o.viewLeft,e.scale=o.scale,e.oldScale=o.oldScale):Vh(o)&&Bn(e)||t.push(o);else t.push(o);return e=t.filter(o=>!o.isNull())},Hn=function(){for(let e=0,t;t=vt[e];e++)t.recordUndo=!1},n.disable$$module$build$src$core$events$utils=function(){nu++},n.enable$$module$build$src$core$events$utils=function(){nu--},z=function(){return nu===0},n.getGroup$$module$build$src$core$events$utils=function(){return x$},n.setGroup$$module$build$src$core$events$utils=function(e){L$.setGroupInternal(e)},Uh=function(e){x$=typeof e=="boolean"?e?_t():"":e},xi=function(e){const t=[];e=e.getDescendants(!1);for(let o=0,s;s=e[o];o++)t[o]=s.id;return t},zh=function(e,t){const o=w(e.type);if(!o)throw Error("Unknown event type.");return o.fromJson(e,t)},w=function(e){const t=Ve(g.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Xh=function(e){if((ws(e)||Ni(e))&&e.workspaceId){var t=xt(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){const o=qs;try{qs=!1;const s=e.getParent();if(s&&!s.hasDisabledReason(lu)){const i=e.getDescendants(!1);for(let r=0,l;l=i[r];r++)l.setDisabledReason(!1,lu)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setDisabledReason(!0,lu),e=e.getNextBlock();while(e)}finally{qs=o}}}},m=function(e,t,o){e=document.createElementNS(Qs,`${e}`);for(const s in t)e.setAttribute(s,`${t[s]}`);return o&&o.appendChild(e),e},b=function(e,t){return t=t.split(" "),t.every(o=>e.classList.contains(o))?!1:(e.classList.add(...t),!0)},Li=function(e,t){e.classList.remove(...t.split(" "))},O=function(e,t){return t=t.split(" "),t.every(o=>!e.classList.contains(o))?!1:(e.classList.remove(...t),!0)},Mi=function(e,t){return e.classList.contains(t)},F=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},Qt=function(e,t){const o=t.nextSibling;if(t=t.parentNode,!t)throw Error("Reference node has no parent.");o?t.insertBefore(e,o):t.appendChild(e)},Bi=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},eo=function(){cu++,ze||(ze=Object.create(null))},to=function(){cu--,cu||(ze=null)},Ao=function(e){const t=e.textContent+`
|
|
2
|
+
`+e.className.baseVal;var o;return ze&&(o=ze[t])||(o=window.getComputedStyle(e),o=ks(e,o.fontSize,o.fontWeight,o.fontFamily),ze&&(ze[t]=o)),o},Yh=function(e,t,o,s){return ks(e,t+"pt",o,s)},ks=function(e,t,o,s){const i=e.textContent;e=i+`
|
|
3
|
+
`+e.className.baseVal;var r;return ze&&(r=ze[e])||(ei||(r=document.createElement("canvas"),r.className="blocklyComputeCanvas",document.body.appendChild(r),ei=r.getContext("2d")),i&&ei?(ei.font=o+" "+t+" "+s,r=ei.measureText(i).width):r=0,ze&&(ze[e]=r)),r},Pi=function(e,t,o,s){const i=document.createElement("span");i.style.font=o+" "+t+" "+s,i.textContent=e,e=document.createElement("div"),e.style.width="1px",e.style.height="0",t=document.createElement("div"),t.style.display="flex",t.style.position="fixed",t.style.top="0",t.style.left="0",t.appendChild(i),t.appendChild(e),document.body.appendChild(t),o={height:0,baseline:0};try{t.style.alignItems="baseline",o.baseline=e.offsetTop-i.offsetTop,t.style.alignItems="flex-end",o.height=e.offsetTop-i.offsetTop}finally{document.body.removeChild(t)}return o},n.getFocusManager$$module$build$src$core$focus_manager=function(){return de.getFocusManager()},Oo=function(e){return e&&typeof e.getFocusableElement=="function"&&typeof e.getFocusableTree=="function"&&typeof e.onNodeFocus=="function"&&typeof e.onNodeBlur=="function"&&typeof e.canBeFocused=="function"},Fi=function(e){return Oo(e)&&typeof e.id=="string"&&typeof e.workspace=="object"&&typeof e.select=="function"&&typeof e.unselect=="function"},Ze=function(e,t){for(const o in t)t[o]!==null&&Array.isArray(t[o])?e[o]=Ze(e[o]||[],t[o]):e[o]=t[o]!==null&&typeof t[o]=="object"?Ze(e[o]||Object.create(null),t[o]):t[o];return e},xt=function(e){return ti[e]||null},xo=function(){const e=[];for(const t in ti)e.push(ti[t]);return e},Gn=function(e){ti[e.id]=e},Vn=function(e){delete ti[e.id]},Me=function(){return B$},Is=function(e){B$=e},Ss=function(){const e=n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();return e&&Fi(e)?e:null},Kh=function(e){n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)},Lt=function(e){const t=Ss();let o,s,i,r;const l=new(w(a.SELECTED))((o=t?.id)!=null?o:null,(s=e?.id)!=null?s:null,(r=(i=e?.workspace.id)!=null?i:t?.workspace.id)!=null?r:"");C(l)},Rs=function(){return P$},Wn=function(e){P$=e},oo=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;const t=e.getParentSvg(),o=e.getCachedParentSvgSize();var s=t.parentElement;if(s instanceof HTMLElement){var i=s.offsetWidth;s=s.offsetHeight,o.width!==i&&(t.setAttribute("width",i+"px"),e.setCachedParentSvgSize(i,null)),o.height!==s&&(t.setAttribute("height",s+"px"),e.setCachedParentSvgSize(null,s)),e.resize()}},Ds=function(e,t){const o=Object.create(null),s=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=s.indexOf(e),s.splice(e,s.length-e));for(let i=0,r;r=s[i];i++)o[r.type]?o[r.type]++:o[r.type]=1;return o},jh=function(e){return function(){this.jsonInit(e)}},Un=function(e){F$.defineBlocksWithJsonArrayInternal(e)},Jh=function(e){n.defineBlocks$$module$build$src$core$common(n.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(e))},n.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(e){const t={};for(let o=0;o<e.length;o++){const s=e[o];if(!s){console.warn(`Block definition #${o} in JSON array is ${s}. Skipping`);continue}const i=s.type;i?t[i]={init:jh(s)}:console.warn(`Block definition #${o} in JSON array is missing a type attribute. Skipping.`)}return t},n.defineBlocks$$module$build$src$core$common=function(e){for(const t of Object.keys(e)){const o=e[t];t in W&&console.warn(`Block definition "${t}" overwrites previous definition.`),W[t]=o}},Ns=function(e){let t=Me();const o=n.getFocusManager$$module$build$src$core$focus_manager().getFocusedTree();for(const s of xo())if(o===s){t=s;break}!vs(e)&&t&&(!t.rendered||t.isFlyout||t.isVisible())&&G.registry.onKeyDown(t,e)},ke=function(e,t){return t=e.indexOf(t),t===-1?!1:(e.splice(t,1),!0)},qe=function(e){if(au)throw Error("CSS already injected");du+=`
|
|
4
|
+
`+e},zn=function(e,t){au||(au=!0,e&&(e=t.replace(/[\\/]$/,""),t=du.replace(/<<<PATH>>>/g,e),du="",e=document.createElement("style"),e.id="blockly-common-style",t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},As=function(e){return G$.getSizeInternal(e)},Zh=function(e){if(Qe(e,"display")!=="none")return Xn(e);const t=e.style,o=t.display,s=t.visibility,i=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";const r=e.offsetWidth;return e=e.offsetHeight,t.display=o,t.position=i,t.visibility=s,new N(r,e)},Xn=function(e){return new N(e.offsetWidth,e.offsetHeight)},Qe=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},Mt=function(e){const t=new f(0,0);e=e.getBoundingClientRect();var o=document.documentElement;return o=new f(window.pageXOffset||o.scrollLeft,window.pageYOffset||o.scrollTop),t.x=e.left+o.x,t.y=e.top+o.y,t},Yn=function(){const e=document.body,t=document.documentElement;return new f(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},Kn=function(e){const t=parseFloat(Qe(e,"borderLeftWidth")),o=parseFloat(Qe(e,"borderRightWidth")),s=parseFloat(Qe(e,"borderTopWidth"));return e=parseFloat(Qe(e,"borderBottomWidth")),new D(s,e,t,o)},jn=function(e,t,o){e=Jn(e,t,o),t.scrollLeft=e.x,t.scrollTop=e.y},Jn=function(e,t,o){var s=Mt(e),i=Mt(t),r=Kn(t);const l=s.x-i.x-r.left;return s=s.y-i.y-r.top,i=Xn(e),e=t.clientWidth-i.width,i=t.clientHeight-i.height,r=t.scrollLeft,t=t.scrollTop,o?(r+=l-e/2,t+=s-i/2):(r+=Math.min(l,Math.max(l-e,0)),t+=Math.min(s,Math.max(s-i,0))),new f(r,t)},Os=function(e){const t=new f(0,0);var o=e.x&&e.getAttribute("x");const s=e.y&&e.getAttribute("y");return o&&(t.x=parseInt(o)),s&&(t.y=parseInt(s)),(o=(o=e.getAttribute("transform"))&&o.match(V$))&&(t.x+=Number(o[1]),o[3]&&(t.y+=Number(o[3]))),(e=e.getAttribute("style"))&&e.includes("translate")&&(e=e.match(W$))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},Hi=function(e){let t=0,o=0;for(;e;){const s=Os(e);if(t+=s.x,o+=s.y,(" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv "))break;e=e.parentNode}return new f(t,o)},Zn=function(){const e=Yn();return new D(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},qn=function(){const e=document.documentElement,t=window;return new f(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},Qn=function(e,t){var o=t.x;t=t.y;const s=e.getInjectionDiv().getBoundingClientRect();return o=new f(o-s.left,t-s.top),t=e.getOriginOffsetInPixels(),f.difference(o,t).scale(1/e.scale)},Lo=function(e,t){var o=t.scale(e.scale);t=o.x,o=o.y;const s=e.getInjectionDiv().getBoundingClientRect();return e=e.getOriginOffsetInPixels(),new f(t+s.left+e.x,o+s.top+e.y)},qh=function(e){({document:Gr=Gr,DOMParser:si=si,XMLSerializer:ii=ii}=e),Hr=new si,pu=new ii},n.createElement$$module$build$src$core$utils$xml=function(e){return Gr.createElementNS(U$,e)},n.createTextNode$$module$build$src$core$utils$xml=function(e){return Gr.createTextNode(e)},n.textToDom$$module$build$src$core$utils$xml=function(e){let t=Hr.parseFromString(e,"text/xml");if(t&&t.documentElement&&!t.getElementsByTagName("parsererror").length)return t.documentElement;if((t=Hr.parseFromString(e,"text/html"))&&t.body.firstChild&&t.body.firstChild.nodeName.toLowerCase()==="xml")return t.body.firstChild;throw Error(`DOMParser was unable to parse: ${e}`)},Mo=function(e){return Qh(pu.serializeToString(e))},Qh=function(e){return e.replace(Gm,t=>`&#${t.charCodeAt(0)};`)},Gi=function(e){return e?((e instanceof Element||typeof e=="string")&&(e=tl(e),e=oa(e)),ea(e),e):null},ea=function(e){const t=e.kind;if(e=e.contents,t&&t!==z$&&t!==gu)throw Error("Invalid toolbox kind "+t+". Please supply either "+z$+" or "+gu);if(!e)throw Error("Toolbox must have a contents attribute.")},xs=function(e){return e?e.contents?e.contents:Array.isArray(e)&&e.length>0&&!e[0].nodeType?e:Ui(e):[]},Vi=function(e){return X$.hasCategoriesInternal(e)},ta=function(e){if(!e)return!1;const t=e.kind;return t?t===gu:!!e.contents.filter(o=>o.kind.toUpperCase()==="CATEGORY").length},Wi=function(e){return e&&e.contents?!!e.contents.filter(function(t){return t.kind.toUpperCase()==="CATEGORY"}).length:!1},oa=function(e){const t={contents:Ui(e)};return e instanceof Node&&el(e,t),t},Ui=function(e){const t=[];let o=e.childNodes;o||(o=e);for(let s=0,i;i=o[s];s++){if(!i.tagName)continue;e={};const r=i.tagName.toUpperCase();e.kind=r,r==="BLOCK"?e.blockxml=i:i.childNodes&&i.childNodes.length>0&&(e.contents=Ui(i)),el(i,e),t.push(e)}return t},el=function(e,t){for(let o=0;o<e.attributes.length;o++){const s=e.attributes[o];s.nodeName.includes("css-")?(t.cssconfig=t.cssconfig||{},t.cssconfig[s.nodeName.replace("css-","")]=s.value):t[s.nodeName]=s.value}},tl=function(e){let t=null;if(e)if(typeof e=="string"){if(t=n.textToDom$$module$build$src$core$utils$xml(e),t.nodeName.toLowerCase()!=="xml")throw TypeError("Toolbox should be an <xml> document.")}else e instanceof Element&&(t=e);return t},zi=function(e,t,o,s,i,r){const l=r.scrollbar&&r.scrollbar.canScrollVertically();return e.horizontal===os.LEFT?(o=i.absoluteMetrics.left+o,l&&r.RTL&&(o+=q.scrollbarThickness)):(o=i.absoluteMetrics.left+i.viewMetrics.width-t.width-o,l&&!r.RTL&&(o-=q.scrollbarThickness)),e.vertical===kt.TOP?e=i.absoluteMetrics.top+s:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-s,r.scrollbar&&r.scrollbar.canScrollHorizontally()&&(e-=q.scrollbarThickness)),new D(e,e+t.height,o,o+t.width)},Xi=function(e,t){return{horizontal:t.toolboxMetrics.position===S.LEFT||e.horizontalLayout&&!e.RTL?os.RIGHT:os.LEFT,vertical:t.toolboxMetrics.position===S.BOTTOM?kt.TOP:kt.BOTTOM}},Yi=function(e,t,o,s){const i=e.left,r=e.right-e.left,l=e.bottom-e.top;for(let c=0;c<s.length;c++){const p=s[c];e.intersects(p)&&(e=o===zt.UP?p.top-l-t:p.bottom+t,e=new D(e,e+l,i,i+r),c=-1)}return e},Ls=function(e,t){I(g.SERIALIZER,e,t)},sa=function(e){qt(g.SERIALIZER,e)},Bo=function(e,{addCoordinates:t=!1,saveIds:o=!0}={}){const s=e.workspace,i=Object.create(null);return i.height=e.getSize().height,i.width=e.getSize().width,o&&(i.id=e.id),t&&(t=e.getRelativeToSurfaceXY(),i.x=s.RTL?s.getWidth()-t.x:t.x,i.y=t.y),e.getText()&&(i.text=e.getText()),e.isCollapsed()&&(i.collapsed=!0),e.isOwnEditable()||(i.editable=!1),e.isOwnMovable()||(i.movable=!1),e.isOwnDeletable()||(i.deletable=!1),i},Ms=function(e,t,{recordUndo:o=!1}={}){const s=we();if(n.setRecordUndo$$module$build$src$core$events$utils(o),o=t.newComment(e.id),e.text!==void 0&&o.setText(e.text),e.x!==void 0||e.y!==void 0){const r=o.getRelativeToSurfaceXY();let l,c=(l=e.x)!=null?l:r.x;c=t.RTL?t.getWidth()-c:c;var i;t=(i=e.y)!=null?i:r.y,o.moveTo(new f(c,t))}if(e.width!==void 0||e.height){i=o.getSize();let r,l;o.setSize(new N((r=e.width)!=null?r:i.width,(l=e.height)!=null?l:i.height))}return e.collapsed!==void 0&&o.setCollapsed(e.collapsed),e.editable!==void 0&&o.setEditable(e.editable),e.movable!==void 0&&o.setMovable(e.movable),e.deletable!==void 0&&o.setDeletable(e.deletable),n.setRecordUndo$$module$build$src$core$events$utils(s),o},Ki=function(e,t){I(g.PASTER,e,t)},ia=function(e){qt(g.PASTER,e)},ra=function(e){const t=e.workspace,o=e.getRelativeToSurfaceXY(),s=new f(0,0),i=t.getTopComments(!1).filter(r=>r.id!==e.id).map(r=>r.getRelativeToSurfaceXY());for(;na(f.sum(o,s),i);)s.translate(t.RTL?-30:30,30);e.moveTo(f.sum(o,s))},na=function(e,t){return t.some(o=>Math.abs(o.x-e.x)<=1&&Math.abs(o.y-e.y)<=1)},et=function(e,t){e.setAttribute(Um,t)},oe=function(e,t,o){Array.isArray(o)&&(o=o.join(" ")),e.setAttribute(Wm+t,`${o}`)},Bs=function(e){return e&&typeof e.saveState=="function"&&typeof e.loadState=="function"},ol=function(e){return sl(e),la()?(ji(),Promise.resolve()):(ss||(ss=new Promise(t=>{yu=t,ep=window.requestAnimationFrame(()=>{ji(),t()})})),ss)},tt=function(){return ss||Promise.resolve()},Bt=function(e){e||window.cancelAnimationFrame(ep),ji(e),!e&&yu&&yu()},la=function(){return w$},sl=function(e){Eu.add(e),Tu.set(e,n.getGroup$$module$build$src$core$events$utils());const t=e.getParent();t?sl(t):Xr.add(e)},ji=function(e){const t=e?new Set([e]):new Set([...Xr].map(r=>r.workspace)),o=[...Xr].filter(ca).filter(r=>t.has(r.workspace));for(var s of o)rl(s);for(const r of t)r.resizeContents();for(var i of o)s=i.getRelativeToSurfaceXY(),i.updateComponentLocations(s);for(const r of o)i=n.getGroup$$module$build$src$core$events$utils(),(s=Tu.get(r))&&n.setGroup$$module$build$src$core$events$utils(s),r.bumpNeighbours(),n.setGroup$$module$build$src$core$events$utils(i);for(const r of o)il(r);e||(ss=null)},il=function(e){Xr.delete(e),Eu.delete(e),Tu.delete(e);for(const t of e.getChildren(!1))il(t)},ca=function(e){return!e.isDisposed()&&!e.getParent()},rl=function(e){if(Eu.has(e)&&e.initialized){for(const t of e.getChildren(!1))rl(t);e.renderEfficiently()}},Ps=function(e,t){rp(e,t)},ua=function(e=ip){rp=e},Ji=function(e,t){lp(e,t)},ha=function(e=np){lp=e},Zi=function(e,t,o){up(e,t,o)},aa=function(e=cp){up=e},da=function(e,t){ap(e,t)},$a=function(e=hp){ap=e},Po=function(e){return e&&typeof e.getProcedureDef=="function"},pa=function(e){return e&&typeof e.getProcedureCall=="function"&&typeof e.renameProcedure=="function"},nl=function(e){return e.getVariableModel!==void 0},le=function(e,t,o,s){e=e+" was deprecated in "+t+" and will be deleted in "+o+".",s&&(e+=`
|
|
5
|
+
Use `+s+" instead."),dp.has(e)||(dp.add(e),console.warn(e))},n.allUsedVarModels$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let o=0;o<e.length;o++){const s=e[o].getVarModels();if(s)for(let i=0;i<s.length;i++){const r=s[i];r.getId()&&t.add(r)}}return Array.from(t.values())},n.allDeveloperVariables$$module$build$src$core$variables=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let s=0,i;i=e[s];s++){var o=i.getDeveloperVariables;if(o){o=o();for(let r=0;r<o.length;r++)t.add(o[r])}}return Array.from(t.values())},qi=function(e){return ll(e,!1)},ll=function(e,t=!0){return W.variables_set||W.variables_get||console.warn("There are no variable blocks, but there is a variable category."),t?(le("The XML return value of Blockly.Variables.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),ga(e)):(e.registerButtonCallback("CREATE_VARIABLE",function(o){so(o.getTargetWorkspace())}),[{kind:"button",text:"%{BKY_NEW_VARIABLE}",callbackkey:"CREATE_VARIABLE"},...er(e,e.getVariableMap().getVariablesOfType(""),!0)])},Qi=function(e){return{VAR:{name:e.getName(),type:e.getType()}}},er=function(e,t,o,s="variables_get",i="variables_set"){o&&(o=W.math_change),e=[];const r=t.slice(-1)[0];return r&&(W[i]&&e.push({kind:"block",type:i,gap:o?8:24,fields:Qi(r)}),o&&e.push({kind:"block",type:"math_change",gap:W[s]?20:8,fields:Qi(r),inputs:{DELTA:{shadow:{type:"math_number",fields:{NUM:1}}}}})),W[s]&&e.push(...t.sort(Fo).map(l=>({kind:"block",type:s,gap:8,fields:Qi(l)}))),e},ga=function(e){let t=[];const o=document.createElement("button");return o.setAttribute("text","%{BKY_NEW_VARIABLE}"),o.setAttribute("callbackKey","CREATE_VARIABLE"),e.registerButtonCallback("CREATE_VARIABLE",function(s){so(s.getTargetWorkspace())}),t.push(o),e=cl(e),t=t.concat(e)},cl=function(e){e=e.getVariableMap().getVariablesOfType("");const t=[];if(e.length>0){var o=e[e.length-1];if(W.variables_set){var s=n.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set"),s.setAttribute("gap",W.math_change?"8":"24"),s.appendChild(io(o)),t.push(s)}if(W.math_change&&(s=n.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","math_change"),s.setAttribute("gap",W.variables_get?"20":"8"),s.appendChild(io(o)),o=n.textToDom$$module$build$src$core$utils$xml('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),s.appendChild(o),t.push(s)),W.variables_get){e.sort(Fo);for(let i=0,r;r=e[i];i++)o=n.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get"),o.setAttribute("gap","8"),o.appendChild(io(r)),t.push(o)}}return t},ul=function(e){return pp.generateUniqueNameInternal(e)},ma=function(e){return tr(wu.charAt(0),e.getVariableMap().getAllVariables().map(t=>t.getName()))},tr=function(e,t){if(!t.length)return e;const o=wu;let s="",i=o.indexOf(e);for(;;){let r=!1;for(let l=0;l<t.length;l++)if(t[l].toLowerCase()===e){r=!0;break}if(!r)break;i++,i===o.length&&(i=0,s=`${Number(s)+1}`),e=o.charAt(i)+s}return e},so=function(e,t,o){function s(r){or(n.Msg$$module$build$src$core$msg.NEW_VARIABLE_TITLE,r,function(l){if(l){var c=hl(l,e);if(c){if(c.getType()===i)var p=n.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS.replace("%1",c.getName());else p=n.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,p=p.replace("%1",c.getName()).replace("%2",c.getType());Ps(p,function(){s(l)})}else e.getVariableMap().createVariable(l,i),t&&t(l)}else t&&t(null)})}const i=o||"";s("")},n.renameVariable$$module$build$src$core$variables=function(e,t,o){function s(i){const r=n.Msg$$module$build$src$core$msg.RENAME_VARIABLE_TITLE.replace("%1",t.getName());or(r,i,function(l){if(l){var c=fa(l,t.getType(),e),p=al(t.getName(),l,e);if(c||p){var T="";c?T=n.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",c.getName()).replace("%2",c.getType()):p&&(T=n.Msg$$module$build$src$core$msg.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",l).replace("%2",p)),Ps(T,function(){s(l)})}else e.getVariableMap().renameVariable(t,l),o&&o(l)}else o&&o(null)})}s("")},or=function(e,t,o){Zi(e,t,function(s){s&&(s=s.replace(/[\s\xa0]+/g," ").trim(),s===n.Msg$$module$build$src$core$msg.RENAME_VARIABLE||s===n.Msg$$module$build$src$core$msg.NEW_VARIABLE)&&(s=null),o(s)})},fa=function(e,t,o){o=o.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let s=0,i;i=o[s];s++)if(i.getName().toLowerCase()===e&&i.getType()!==t)return i;return null},hl=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let o=0,s;s=t[o];o++)if(s.getName().toLowerCase()===e)return s;return null},al=function(e,t,o){return o.getProcedureMap().getProcedures().length?ba(e,t,o):_a(e,t,o)},ba=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getProcedureMap().getProcedures();for(const i of o){var s=i.getParameters().filter(nl).map(r=>r.getVariableModel().getName());if(s&&(o=s.some(r=>r.toLowerCase()===e),s=s.some(r=>r.toLowerCase()===t),o&&s))return i.getName()}return null},_a=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getAllBlocks(!1);for(const i of o){if(!Po(i))continue;o=i.getProcedureDef();var s=o[1];const r=s.some(l=>l.toLowerCase()===e);if(s=s.some(l=>l.toLowerCase()===t),r&&s)return o[0]}return null},io=function(e){const t=n.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name","VAR"),t.setAttribute("id",e.getId()),t.setAttribute("variabletype",e.getType()),e=n.createTextNode$$module$build$src$core$utils$xml(e.getName()),t.appendChild(e),t},n.getOrCreateVariablePackage$$module$build$src$core$variables=function(e,t,o,s){let i=n.getVariable$$module$build$src$core$variables(e,t,o,s);return i||(i=Ea(e,t,o,s)),i},n.getVariable$$module$build$src$core$variables=function(e,t,o,s){const i=e.getPotentialVariableMap();let r=null;if(t&&(r=e.getVariableById(t),!r&&i&&(r=i.getVariableById(t)),r))return r;if(o){if(s===void 0)throw Error("Tried to look up a variable by name without a type");r=e.getVariable(o,s),!r&&i&&(r=i.getVariable(o,s))}return r},Ea=function(e,t,o,s){const i=e.getVariableMap(),r=e.getPotentialVariableMap();return o||(o=ul(e.isFlyout?e.targetWorkspace:e)),r?r.createVariable(o,s,t??void 0):i.createVariable(o,s,t)},Fs=function(e,t){e=e.getAllVariables();const o=[];if(t.length!==e.length)for(let s=0;s<e.length;s++){const i=e[s];t.includes(i)||o.push(i)}return o},Fo=function(e,t){return e.getName().localeCompare(t.getName(),void 0,{sensitivity:"base"})},Ho=function(e,t){const o=[];e=e.getAllBlocks(!1);for(let s=0;s<e.length;s++){const i=e[s].getVarModels();if(i)for(let r=0;r<i.length;r++)i[r].getId()===t&&o.push(e[s])}return o},n.deleteVariable$$module$build$src$core$variables=function(e,t,o){var s=t.getName();const i=Ho(e,t.getId());for(let r=i.length-1;r>=0;r--){const l=i[r];if(l.type==="procedures_defnoreturn"||l.type==="procedures_defreturn"){o=String(l.getFieldValue("NAME")),s=n.Msg$$module$build$src$core$msg.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",s).replace("%2",o),Ps(s);return}l===o&&i.splice(r,1)}o&&i.length||i.length>1?(s=n.Msg$$module$build$src$core$msg.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(i.length+(o&&!o.workspace.isFlyout?1:0))).replace("%2",s),Ji(s,r=>{r&&t&&e.getVariableMap().deleteVariable(t)})):e.getVariableMap().deleteVariable(t)},Be=function(e,{addCoordinates:t=!1,addInputBlocks:o=!0,addNextBlocks:s=!0,doFullSerialization:i=!0,saveIds:r=!0}={}){if(e.isInsertionMarker())return null;const l={type:e.type,id:r?e.id:void 0};return t&&ya(e,l),Ta(e,l),va(e,l,i),Ca(e,l,i),wa(e,l,i),o&&ka(e,l,i,r),s&&Ia(e,l,i,r),l},Ta=function(e,t){e.isCollapsed()&&(t.collapsed=!0),e.isEnabled()||(t.disabledReasons=Array.from(e.getDisabledReasons())),e.isOwnDeletable()||(t.deletable=!1),e.isOwnMovable()||(t.movable=!1),e.isOwnEditable()||(t.editable=!1),e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&(t.inline=e.inputsInline),e.data&&(t.data=e.data)},ya=function(e,t){const o=e.workspace;e=e.getRelativeToSurfaceXY(),t.x=Math.round(o.RTL?o.getWidth()-e.x:e.x),t.y=Math.round(e.y)},va=function(e,t,o){e.saveExtraState?(e=e.saveExtraState(o),e!==null&&(t.extraState=e)):e.mutationToDom&&(e=e.mutationToDom(),e!==null&&(t.extraState=st(e).replace(' xmlns="https://developers.google.com/blockly/xml"',"")))},Ca=function(e,t,o){const s=Object.create(null);for(const i of e.getIcons())Bs(i)&&(e=i.saveState(o))&&(s[i.getType().toString()]=e);Object.keys(s).length&&(t.icons=s)},wa=function(e,t,o){const s=Object.create(null);for(const i of e.getFields())i.isSerializable()&&(s[i.name]=i.saveState(o));Object.keys(s).length&&(t.fields=s)},ka=function(e,t,o,s){const i=Object.create(null);for(let r=0;r<e.inputList.length;r++){const l=e.inputList[r];if(!l.connection)continue;const c=dl(l.connection,o,s);c&&(i[l.name]=c)}Object.keys(i).length&&(t.inputs=i)},Ia=function(e,t,o,s){e.nextConnection&&(e=dl(e.nextConnection,o,s))&&(t.next=e)},dl=function(e,t,o){const s=e.getShadowState(!0);if(e=e.targetBlock(),!s&&!e)return null;const i=Object.create(null);return s&&(i.shadow=s),e&&!e.isShadow()&&(i.block=Be(e,{doFullSerialization:t,saveIds:o})),i},Pt=function(e,t,{recordUndo:o=!1}={}){return e=Go(e,t,{recordUndo:o}),t.rendered&&Bt(),e},Go=function(e,t,{parentConnection:o,isShadow:s=!1,recordUndo:i=!1}={}){const r=we();n.setRecordUndo$$module$build$src$core$events$utils(i),(i=n.getGroup$$module$build$src$core$events$utils())||n.setGroup$$module$build$src$core$events$utils(!0),n.disable$$module$build$src$core$events$utils();const l=t.getAllVariables();let c;try{c=$l(e,t,{parentConnection:o,isShadow:s})}finally{n.enable$$module$build$src$core$events$utils()}if(Sa(t,l),z()&&C(new(w(a.BLOCK_CREATE))(c)),n.setGroup$$module$build$src$core$events$utils(i),n.setRecordUndo$$module$build$src$core$events$utils(r),t.rendered){const p=c;setTimeout(()=>{p.disposed||p.setConnectionTracking(!0)},1)}return c},$l=function(e,t,{parentConnection:o,isShadow:s=!1}={}){if(!e.type)throw new gp(e);const i=t.newBlock(e.type,e.id);return i.setShadow(s),Ra(i,e),Da(i,e),Na(i,e),Aa(o,i,e),Oa(i,e),xa(i,e),La(i,e),Ma(i,e),Ba(i,t.rendered),i},Sa=function(e,t){if(z())for(e=Fs(e,t),t=0;t<e.length;t++){const o=e[t];C(new(w(a.VAR_CREATE))(o))}},Ra=function(e,t){let o=t.x===void 0?0:t.x;t=t.y===void 0?0:t.y;const s=e.workspace;o=s.RTL?s.getWidth()-o:o,e.moveBy(o,t)},Da=function(e,t){if(t.collapsed&&e.setCollapsed(!0),t.deletable===!1&&e.setDeletable(!1),t.movable===!1&&e.setMovable(!1),t.editable===!1&&e.setEditable(!1),t.enabled===!1&&e.setDisabledReason(!0,Fe),Array.isArray(t.disabledReasons))for(const o of t.disabledReasons)e.setDisabledReason(!0,o);t.inline!==void 0&&e.setInputsInline(t.inline),t.data!==void 0&&(e.data=t.data)},Na=function(e,t){t.extraState&&(e.loadExtraState?e.loadExtraState(t.extraState):e.domToMutation&&e.domToMutation(n.textToDom$$module$build$src$core$utils$xml(t.extraState)))},Aa=function(e,t,o){if(e){if(e.getSourceBlock().isShadow()&&!t.isShadow())throw new fp(o);if(e.type===n.inputTypes$$module$build$src$core$inputs$input_types.VALUE){var s=t.outputConnection;if(!s)throw new ci("output",t,o)}else if(s=t.previousConnection,!s)throw new ci("previous",t,o);if(!e.connect(s)){const i=t.workspace.connectionChecker;throw new mp(i.getErrorMessage(i.canConnectWithReason(s,e,!1),s,e),e.type===n.inputTypes$$module$build$src$core$inputs$input_types.VALUE?"output connection":"previous connection",t,o)}}},Oa=function(e,t){if(t.icons){var o=Object.keys(t.icons);for(const i of o){o=t.icons[i];var s=e.getIcon(i);if(!s){if(s=Ve(g.ICON,i,!1),!s)throw new bp(i,e,t);s=new s(e),e.addIcon(s)}Bs(s)&&s.loadState(o)}}},xa=function(e,t){if(t.fields){var o=Object.keys(t.fields);for(let s=0;s<o.length;s++){const i=o[s],r=t.fields[i],l=e.getField(i);l?l.loadState(r):console.warn(`Ignoring non-existant field ${i} in block ${e.type}`)}}},La=function(e,t){if(t.inputs){var o=Object.keys(t.inputs);for(let s=0;s<o.length;s++){const i=o[s],r=e.getInput(i);if(!r||!r.connection)throw new ci(i,e,t);pl(r.connection,t.inputs[i])}}},Ma=function(e,t){if(t.next){if(!e.nextConnection)throw new ci("next",e,t);pl(e.nextConnection,t.next)}},pl=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&$l(t.block,e.getSourceBlock().workspace,{parentConnection:e})},Ba=function(e,t){if(t){e.setConnectionTracking(!1),e.initSvg(),e.queueRender();for(const o of e.getIcons())o.onLocationChange(e.getRelativeToSurfaceXY())}else e.initModel()},ro=function(e){return typeof e.bubbleIsVisible=="function"&&typeof e.setBubbleVisible=="function"&&typeof e.getBubble=="function"},sr=function(e){return e*Math.PI/180},Pa=function(e){return e*180/Math.PI},Vo=function(e,t,o){if(o<e){const s=o;o=e,e=s}return Math.max(e,Math.min(t,o))},ir=function(){document.querySelector(".blocklyDropDownDiv")||(j=document.createElement("div"),j.className="blocklyDropDownDiv",j.tabIndex=-1,(Rs()||document.body).appendChild(j),hi=document.createElement("div"),hi.className="blocklyDropDownContent",j.appendChild(hi),qr=k(hi,"keydown",null,Ns),Eo=document.createElement("div"),Eo.className="blocklyDropDownArrow",j.appendChild(Eo),j.style.opacity="0",j.style.transition="transform "+Jr+"s, opacity "+Jr+"s")},gl=function(e){Su=e},ml=function(){return Xt},rr=function(){return hi},nr=function(){qr&&(x(qr),qr=null),j.remove(),ir()},fl=function(e,t){j.style.backgroundColor=e,j.style.borderColor=t},Fa=function(e,t,o,s,i=!0){return Tl(_l(t),e,i,o,s)},bl=function(e,t,o,s=!0){return Cp=!0,Tl(El(e),e,s,t,o)},_l=function(e){var t=e.getSvgRoot();const o=e.workspace.scale,s=e.height*o;return e=e.width*o,t=Mt(t),new D(t.y,t.y+s,t.x,t.x+e)},El=function(e){return e=e.getScaledBBox(),new D(e.top,e.bottom,e.left,e.right)},Tl=function(e,t,o,s,i){const r=e.left+(e.right-e.left)/2,l=e.bottom;e=e.top,i&&(e+=i),i=t.getSourceBlock();let c=i.workspace;for(;c.options.parentWorkspace;)c=c.options.parentWorkspace;return gl(c.getParentSvg().parentNode),yl(t,i.RTL,r,l,r,e,o,s)},yl=function(e,t,o,s,i,r,l,c){return Xt=e,_o=c||null,j.style.direction=t?"rtl":"ltr",e=Me(),yp=e.getRenderer().getClassName(),vp=e.getTheme().getClassName(),b(j,yp),b(j,vp),o=kl(o,s,i,r),l&&(Zr=n.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(j)),o},vl=function(e,t,o,s){return e=Hs(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+ku,arrowX:e.arrowX,arrowY:-9,arrowAtTop:!0,arrowVisible:!0}},Cl=function(e,t,o,s){return e=Hs(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t-s.height,finalX:e.divX,finalY:t-s.height-ku,arrowX:e.arrowX,arrowY:s.height-Ep*2-jr/2,arrowAtTop:!1,arrowVisible:!0}},Ha=function(e,t,o){return e=Hs(e,t.left,t.right,o.width),{initialX:e.divX,initialY:0,finalX:e.divX,finalY:0,arrowAtTop:null,arrowX:null,arrowY:null,arrowVisible:!1}},Hs=function(e,t,o,s){return t=Vo(t,e-s/2,o-s),e=e-jr/2-t,o=Tp,e=Vo(o,e,s-o-jr),{arrowX:e,divX:t}},wl=function(){return!!Xt},lr=function(e,t){return Xt===e?(t?ot():cr(),!0):!1},cr=function(){j.style.transform="translate(0, 0)",j.style.opacity="0",Iu=setTimeout(function(){ot()},Jr*1e3),_o&&(_o(),_o=null)},ot=function(){wl()&&(Iu&&clearTimeout(Iu),_o&&(_o(),_o=null),nr(),Xt=null,Me().markFocused(),Zr&&(Zr(),Zr=null))},kl=function(e,t,o,s){e=Ru.getPositionMetrics(e,t,o,s),e.arrowVisible?(t=e.arrowX,o=e.arrowY,s=e.arrowAtTop?45:225,Eo.style.display="",Eo.style.transform=`translate(${t}px, ${o}px) rotate(${s}deg)`,Eo.setAttribute("class","blocklyDropDownArrow")):Eo.style.display="none",t=Math.floor(e.initialX),o=Math.floor(e.initialY),s=Math.floor(e.finalX);const i=Math.floor(e.finalY);return j.style.left=t+"px",j.style.top=o+"px",j.style.display="block",j.style.opacity="1",j.style.transform="translate("+(s-t)+"px,"+(i-o)+"px)",!!e.arrowAtTop},Il=function(){if(Xt){var e=Xt.getSourceBlock();e=Cp?El(Xt):_l(e);const t=e.left+(e.right-e.left)/2;kl(t,e.bottom,t,e.top)}else cr()},Gs=function(e){return e.length?e.reduce(function(t,o){return t.length<o.length?t:o}).length:0},Sl=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||Gs(e);let s;for(s=0;s<t;s++){for(var i=e[0][s],r=1;r<e.length;r++)if(i!==e[r][s])return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((r=e[i][s])&&r!==" ")return o;return t},Rl=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||Gs(e);let s;for(s=0;s<t;s++){for(var i=e[0].substr(-s-1,1),r=1;r<e.length;r++)if(i!==e[r].substr(-s-1,1))return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((r=e[i].charAt(e[i].length-s-1))&&r!==" ")return o;return t},n.wrap$$module$build$src$core$utils$string=function(e,t){e=e.split(`
|
|
6
|
+
`);for(let o=0;o<e.length;o++)e[o]=Ga(e[o],t);return e.join(`
|
|
7
|
+
`)},Ga=function(e,t){if(e.length<=t)return e;const o=e.trim().split(/\s+/);for(var s=0;s<o.length;s++)o[s].length>t&&(t=o[s].length);var i=-1/0;let r,l=1;do{s=i,r=e,e=[],i=o.length/l;let c=1;for(let p=0;p<o.length-1;p++)c<(p+1.5)/i?(c++,e[p]=!0):e[p]=!1;e=Dl(o,e,t),i=ur(o,e,t),e=Va(o,e),l++}while(i>s);return r},ur=function(e,t,o){const s=[0],i=[];for(var r=0;r<e.length;r++)s[s.length-1]+=e[r].length,t[r]===!0?(s.push(0),i.push(e[r].charAt(e[r].length-1))):t[r]===!1&&s[s.length-1]++;for(e=Math.max(...s),t=0,r=0;r<s.length;r++)t-=Math.pow(Math.abs(o-s[r]),1.5)*2,t-=Math.pow(e-s[r],1.5),".?!".includes(i[r])?t+=o/3:",;)]}".includes(i[r])&&(t+=o/4);return s.length>1&&s[s.length-1]<=s[s.length-2]&&(t+=.5),t},Dl=function(e,t,o){let s=ur(e,t,o),i;for(let r=0;r<t.length-1;r++){if(t[r]===t[r+1])continue;const l=[].concat(t);l[r]=!l[r],l[r+1]=!l[r+1];const c=ur(e,l,o);c>s&&(s=c,i=l)}return i?Dl(e,i,o):t},Va=function(e,t){const o=[];for(let s=0;s<e.length;s++)o.push(e[s]),t[s]!==void 0&&o.push(t[s]?`
|
|
8
|
+
`:" ");return o.join("")},n.isNumber$$module$build$src$core$utils$string=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},Wa=function(e){Qr=e},Ua=function(){return Qr},za=function(){return ai},Xa=function(){return ie},Wo=function(e){if(e=Nl(e)){for(e=e.tooltip;typeof e=="function";)e=e();if(typeof e!="string")throw Error("Tooltip function must return a string.");return e}return""},Nl=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip=="string"||typeof e.tooltip=="function")return e;e=e.tooltip}return null},Al=function(){document.querySelector(".blocklyTooltipDiv")||(ie=document.createElement("div"),ie.className="blocklyTooltipDiv",(Rs()||document.body).appendChild(ie))},Vs=function(e){e.mouseOverWrapper_=xe(e,"pointerover",null,Ya),e.mouseOutWrapper_=xe(e,"pointerout",null,Ka),e.addEventListener("pointermove",xl,!1)},Ol=function(e){e&&(x(e.mouseOverWrapper_),x(e.mouseOutWrapper_),e.removeEventListener("pointermove",xl))},Ya=function(e){ns||(e=Nl(e.currentTarget),He!==e&&(Et(),di=null,He=e),clearTimeout(kp))},Ka=function(e){ns||(kp=setTimeout(function(){di=He=null,Et()},1),clearTimeout(To),To=0)},xl=function(e){if(He&&He.tooltip&&!ns)if(ai){const t=Du-e.pageX;e=Nu-e.pageY,Math.sqrt(t*t+e*e)>Ip&&Et()}else di!==He&&(clearTimeout(To),Du=e.pageX,Nu=e.pageY,To=setTimeout(qa,Sp))},Ll=function(){di=He=null,Et()},Et=function(){ai&&(ai=!1,ie&&(ie.style.display="none")),To&&(clearTimeout(To),To=0)},Ml=function(){Et(),ns=!0},Bl=function(){ns=!1},ja=function(){ie&&He&&(typeof Qr=="function"?Qr(ie,He):Ja())},Ja=function(){var e=Wo(He);e=n.wrap$$module$build$src$core$utils$string(e,wp),e=e.split(`
|
|
9
|
+
`);for(let t=0;t<e.length;t++){const o=document.createElement("div");o.appendChild(document.createTextNode(e[t])),ie.appendChild(o)}},Za=function(e){const t=document.documentElement.clientWidth,o=document.documentElement.clientHeight;let s=Du;s=e?s-(Au+ie.offsetWidth):s+Au;let i=Nu+Ou;return i+ie.offsetHeight>o+window.scrollY&&(i-=ie.offsetHeight+2*Ou),e?s=Math.max(en-window.scrollX,s):s+ie.offsetWidth>t+window.scrollX-2*en&&(s=t-ie.offsetWidth-2*en),{x:s,y:i}},qa=function(){if(!ns&&(di=He,ie)){ie.textContent="",ja();var e=He.RTL;ie.style.direction=e?"rtl":"ltr",ie.style.display="block",ai=!0;var{x:t,y:o}=Za(e);ie.style.left=t+"px",ie.style.top=o+"px"}},Pl=function(){return xu},Qa=function(e){xu=e},Fl=function(){return Lu},ed=function(e){Lu=e},no=function(e){e=`${e}`.toLowerCase().trim();var t=Rp[e];if(t||(t=e.substring(0,2)==="0x"?"#"+e.substring(2):e,t=t[0]==="#"?t:"#"+t,/^#[0-9a-f]{6}$/.test(t)))return t;if(/^#[0-9a-f]{3}$/.test(t))return["#",t[1],t[1],t[2],t[2],t[3],t[3]].join("");var o=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return o&&(e=Number(o[1]),t=Number(o[2]),o=Number(o[3]),e>=0&&e<256&&t>=0&&t<256&&o>=0&&o<256)?Ws(e,t,o):null},Ws=function(e,t,o){return t=e<<16|t<<8|o,e<16?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},hr=function(e){return e=no(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},ar=function(e,t,o){let s=0,i=0,r=0;if(t===0)r=i=s=o;else{const l=Math.floor(e/60),c=e/60-l;e=o*(1-t);const p=o*(1-t*c);switch(t=o*(1-t*(1-c)),l){case 1:s=p,i=o,r=e;break;case 2:s=e,i=o,r=t;break;case 3:s=e,i=p,r=o;break;case 4:s=t,i=e,r=o;break;case 5:s=o,i=e,r=p;break;case 6:case 0:s=o,i=t,r=e}}return Ws(Math.floor(s),Math.floor(i),Math.floor(r))},lo=function(e,t,o){return e=no(e),!e||(t=no(t),!t)?null:(e=hr(e),t=hr(t),Ws(Math.round(t[0]+o*(e[0]-t[0])),Math.round(t[1]+o*(e[1]-t[1])),Math.round(t[2]+o*(e[2]-t[2]))))},Hl=function(e){return ar(e,xu,Lu*255)},dr=function(e,t,o){const s=[];var i=e.split("");i.push("");var r=0;e=[];let l=null;for(let T=0;T<i.length;T++){var c=i[T];if(r===0)if(c==="%")(r=e.join(""))&&s.push(r),e.length=0,r=1;else if(o&&c===`
|
|
10
|
+
`){const Y=e.join("");Y&&s.push(Y),e.length=0,s.push(c)}else e.push(c);else if(r===1)c==="%"?(e.push(c),r=0):t&&"0"<=c&&c<="9"?(r=2,l=c,(c=e.join(""))&&s.push(c),e.length=0):c==="{"?r=3:(e.push("%",c),r=0);else if(r===2)if("0"<=c&&c<="9")l+=c;else{var p=void 0;s.push(parseInt((p=l)!=null?p:"",10)),T--,r=0}else r===3&&(c===""?(e.splice(0,0,"%{"),T--,r=0):c!=="}"?e.push(c):(r=e.join(""),/[A-Z]\w*/i.test(r)?(c=r.toUpperCase(),(c=c.startsWith("BKY_")?c.substring(4):null)&&c in n.Msg$$module$build$src$core$msg?(r=n.Msg$$module$build$src$core$msg[c],typeof r=="string"?Array.prototype.push.apply(s,dr(r,t,o)):t?s.push(`${r}`):s.push(r)):s.push("%{"+r+"}")):s.push("%{"+r+"}"),r=e.length=0))}for((t=e.join(""))&&s.push(t),p=[],e.length=0,i=0;i<s.length;i++)typeof s[i]!="string"||o&&s[i]===`
|
|
11
|
+
`?((t=e.join(""))&&p.push(t),e.length=0,p.push(s[i])):e.push(s[i]);return(t=e.join(""))&&p.push(t),e.length=0,p},Gl=function(e){return dr(e,!0,!0)},J=function(e){return typeof e!="string"?e:(e=dr(e,!1,!1),e.length?String(e[0]):"")},td=function(e){let t=!0;const o=n.Msg$$module$build$src$core$msg,s=e.match(/%{BKY_[A-Z]\w*}/gi);if(s)for(let i=0;i<s.length;i++){const r=s[i].toUpperCase();o[r.slice(6,-1)]===void 0&&(console.warn("No message string for "+s[i]+" in "+e),t=!1)}return t},Uo=function(e){const t=typeof e=="string"?J(e):e;var o=Number(t);if(!isNaN(o)&&0<=o&&o<=360)return{hue:o,hex:ar(o,Pl(),Fl()*255)};if(o=no(t))return{hue:null,hex:o};throw o='Invalid colour: "'+t+'"',e!==t&&(o+=' (from "'+e+'")'),Error(o)},zo=function(){return De},od=function(e){if(De=e,e===null){let t;(t=document.querySelector("."+Mu))==null||t.remove()}},Vl=function(){const e=Rs()||document.body,t=document.querySelector("div."+Mu);t?De=t:(De=document.createElement("div"),De.className=Mu,De.tabIndex=-1),k(De,"keydown",null,Ns),e.appendChild(De)},$r=function(e,t,o,s,i=!0){if(Xo(),ls=e,tn=o,o=De){if(o.style.direction=t?"rtl":"ltr",o.style.display="block",!s&&e instanceof L){let c;s=(c=e.getSourceBlock())==null?void 0:c.workspace}var r;Dp=(r=s)!=null?r:null;var l;e=(l=s)!=null?l:Me(),cs=e.getRenderer().getClassName(),us=e.getTheme().getClassName(),cs&&b(o,cs),us&&b(o,us),i&&(on=n.getFocusManager$$module$build$src$core$focus_manager().takeEphemeralFocus(o))}},Xo=function(){if(Wl()){ls=null;var e=De;e&&(e.style.display="none",e.style.left="",e.style.top="",tn&&(tn(),tn=null),e.textContent="",cs&&(O(e,cs),cs=""),us&&(O(e,us),us=""),Me().markFocused(),on&&(on(),on=null))}},Wl=function(){return!!ls},co=function(e){ls===e&&Xo()},Us=function(e){let t=Dp===null,o=e;for(;!t&&o;){if(o===e){t=!0;break}o=e.options.parentWorkspace}t&&Xo()},Ul=function(e,t,o){De.style.left=e+"px",De.style.top=t+"px",De.style.height=o+"px"},zl=function(e,t,o,s){const i=id(e,t,o);e=sd(e,t,o,s),i<0?Ul(e,0,o.height+i):Ul(e,i,o.height)},sd=function(e,t,o,s){return s?Math.min(Math.max(t.right-o.width,e.left),e.right-o.width):Math.max(Math.min(t.left,e.right-o.width),e.left)},id=function(e,t,o){return t.bottom+o.height>=e.bottom?t.top-o.height:t.bottom},rd=function(e){return!(e==null||!e.repositionForWindowResize)},Xl=function(){rd(ls)&&ls.repositionForWindowResize()||Xo()},nd=function(){return sn},Yl=function(e){sn=e},Yo=function(e,t,o,s,i){if($r(Np,o,Kl,s),t.length){i||(e instanceof PointerEvent?i=new f(e.clientX,e.clientY):(console.warn("Context menu opened with keyboard but no location given"),i=new f(0,0)));var r=ld(t,o,e,i);rn=r,cd(r,o,i),setTimeout(function(){r.focus()},1),sn=null}else zs()},ld=function(e,t,o,s){const i=new _u;i.setRole(Se.MENU);for(let r=0;r<e.length;r++){const l=e[r];if(l.separator){i.addChild(new Q$);continue}const c=new Ur(l.text);c.setRightToLeft(t),c.setRole(Se.MENUITEM),i.addChild(c),c.setEnabled(l.enabled),l.enabled&&c.onAction(function(p,T){zs(),requestAnimationFrame(()=>{setTimeout(()=>{l.callback(l.scope,o,T,s)},0)})},{})}return i},cd=function(e,t,o){const s=Zn();o=new D(o.y+s.top,o.y+s.top,o.x+s.left,o.x+s.left),ud(e);const i=e.getSize();t&&(o.left+=i.width,o.right+=i.width,s.left+=i.width,s.right+=i.width),zl(s,o,i,t),e.focus()},ud=function(e){var t=zo();if(!t)throw Error("Attempting to create a context menu when widget div is null");t=e.render(t),b(t,"blocklyContextMenu"),k(t,"contextmenu",null,hd),e.focus()},hd=function(e){e.preventDefault(),e.stopPropagation()},zs=function(){co(Np),sn=null},Kl=function(){rn&&(rn.dispose(),rn=null)},n.callbackFactory$$module$build$src$core$contextmenu=function(e,t){return()=>{n.disable$$module$build$src$core$events$utils();let o;try{o=t instanceof Element?uo(t,e.workspace):Go(t,e.workspace);const s=e.getRelativeToSurfaceXY();s.x=e.RTL?s.x-n.config$$module$build$src$core$config.snapRadius:s.x+n.config$$module$build$src$core$config.snapRadius,s.y+=n.config$$module$build$src$core$config.snapRadius*2,o.moveBy(s.x,s.y)}finally{n.enable$$module$build$src$core$events$utils()}return z()&&!o.isShadow()&&C(new(w(a.BLOCK_CREATE))(o)),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(o),o}},jl=function(e,t){return t=Do(t,e.getParentSvg(),e.getInverseScreenCTM()),t.x/=e.scale,t.y/=e.scale,t},pr=function(e,t,o){t=jl(e,t),Op.set(e,f.difference(o,t))},gr=function(e,t){if(t=jl(e,t),e=Op.get(e),!e)throw Error("Drag not initialized");return f.sum(e,t)},ad=function(e,t=!1){const o=n.createElement$$module$build$src$core$utils$xml("xml");var s=Jl(n.allUsedVarModels$$module$build$src$core$variables(e));s.hasChildNodes()&&o.appendChild(s);for(const i of e.getTopComments())o.appendChild(Xs(i,t));for(e=e.getTopBlocks(!0),s=0;s<e.length;s++)o.appendChild(Ys(e[s],t));return o},Xs=function(e,t=!1){const o=n.createElement$$module$build$src$core$utils$xml("comment");t||o.setAttribute("id",e.id),t=e.workspace;const s=e.getRelativeToSurfaceXY();return s.x=t.RTL?t.getWidth()-s.x:s.x,o.setAttribute("x",`${s.x}`),o.setAttribute("y",`${s.y}`),o.setAttribute("w",`${e.getSize().width}`),o.setAttribute("h",`${e.getSize().height}`),e.getText()&&(o.textContent=e.getText()),e.isCollapsed()&&o.setAttribute("collapsed","true"),e.isOwnEditable()||o.setAttribute("editable","false"),e.isOwnMovable()||o.setAttribute("movable","false"),e.isOwnDeletable()||o.setAttribute("deletable","false"),o},Jl=function(e){const t=n.createElement$$module$build$src$core$utils$xml("variables");for(let o=0;o<e.length;o++){const s=e[o],i=n.createElement$$module$build$src$core$utils$xml("variable");i.appendChild(n.createTextNode$$module$build$src$core$utils$xml(s.getName())),s.getType()&&i.setAttribute("type",s.getType()),i.id=s.getId(),t.appendChild(i)}return t},Ys=function(e,t){if(e.isInsertionMarker()&&(e=e.getChildren(!1)[0],!e))return new DocumentFragment;let o=0;if(e.workspace.RTL&&(o=e.workspace.getWidth()),t=Ft(e,t),tc(t)){const s=e.getRelativeToSurfaceXY();t.setAttribute("x",String(Math.round(e.workspace.RTL?o-s.x:s.x))),t.setAttribute("y",String(Math.round(s.y)))}return t},dd=function(e){if(e.isSerializable()){const t=n.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name",e.name||""),e.toXml(t)}return null},$d=function(e,t){for(const o of e.getFields())(e=dd(o))&&t.appendChild(e)},Ft=function(e,t){if(e.isInsertionMarker())return(t=e.getChildren(!1)[0])?Ft(t):new DocumentFragment;const o=n.createElement$$module$build$src$core$utils$xml(e.isShadow()?"shadow":"block");if(o.setAttribute("type",e.type),t||(o.id=e.id),e.mutationToDom){var s=e.mutationToDom();s&&(s.hasChildNodes()||s.hasAttributes())&&o.appendChild(s)}if($d(e,o),s=e.getCommentText()){var i=e.getIcon(se.COMMENT),r=i.getBubbleSize(),l=i.bubbleIsVisible();i=i.getBubbleLocation();var c=n.createElement$$module$build$src$core$utils$xml("comment");c.appendChild(n.createTextNode$$module$build$src$core$utils$xml(s)),c.setAttribute("pinned",`${l}`),c.setAttribute("h",`${r.height}`),c.setAttribute("w",`${r.width}`),i&&(c.setAttribute("x",`${e.workspace.RTL?e.workspace.getWidth()-(i.x+r.width):i.x}`),c.setAttribute("y",`${i.y}`)),o.appendChild(c)}for(e.data&&(s=n.createElement$$module$build$src$core$utils$xml("data"),s.appendChild(n.createTextNode$$module$build$src$core$utils$xml(e.data)),o.appendChild(s)),s=0;s<e.inputList.length;s++){r=e.inputList[s];var p=void 0;l=!0,r.type!==n.inputTypes$$module$build$src$core$inputs$input_types.DUMMY&&r.type!==n.inputTypes$$module$build$src$core$inputs$input_types.END_ROW&&(i=r.connection.targetBlock(),r.type===n.inputTypes$$module$build$src$core$inputs$input_types.VALUE?p=n.createElement$$module$build$src$core$utils$xml("value"):r.type===n.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT&&(p=n.createElement$$module$build$src$core$utils$xml("statement")),c=r.connection.getShadowDom(),!c||i&&i.isShadow()||p.appendChild(Zl(c,t)),i&&(i=Ft(i,t),i.nodeType===Ct.ELEMENT_NODE&&(p.appendChild(i),l=!1)),p.setAttribute("name",r.name),l||o.appendChild(p))}e.inputsInline!==void 0&&e.inputsInline!==e.inputsInlineDefault&&o.setAttribute("inline",String(e.inputsInline)),e.isCollapsed()&&o.setAttribute("collapsed","true"),e.isEnabled()||o.setAttribute("disabled-reasons",Array.from(e.getDisabledReasons()).map(encodeURIComponent).join(",")),e.isOwnDeletable()||o.setAttribute("deletable","false"),e.isOwnMovable()||o.setAttribute("movable","false"),e.isOwnEditable()||o.setAttribute("editable","false"),p=e.getNextBlock();let T;return p&&(s=Ft(p,t),s.nodeType===Ct.ELEMENT_NODE&&(T=n.createElement$$module$build$src$core$utils$xml("next"),T.appendChild(s),o.appendChild(T))),e=e.nextConnection&&e.nextConnection.getShadowDom(),!e||p&&p.isShadow()||T.appendChild(Zl(e,t)),o},Zl=function(e,t){let o=e=e.cloneNode(!0),s;for(;o;)if(t&&o.nodeName==="shadow"&&o.removeAttribute("id"),o.firstChild)o=o.firstChild;else{for(;o&&!o.nextSibling;){s=o,o=o.parentNode;let i;s.nodeType===Ct.TEXT_NODE&&s.data.trim()===""&&((i=o)==null?void 0:i.firstChild)!==s&&F(s)}o&&(s=o,o=o.nextSibling,s.nodeType===Ct.TEXT_NODE&&s.data.trim()===""&&F(s))}return e},st=function(e){return Mo(e).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")},pd=function(e){e=st(e).split("<");let t="";for(let o=1;o<e.length;o++){const s=e[o];s[0]==="/"&&(t=t.substring(2)),e[o]=t+"<"+s,s[0]!=="/"&&s.slice(-2)!=="/>"&&(t+=" ")}return e=e.join(`
|
|
12
|
+
`),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>"),e.replace(/^\n/,"")},gd=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=n.domToWorkspace$$module$build$src$core$xml(e,t),t.setResizesEnabled(!0),e},n.domToWorkspace$$module$build$src$core$xml=function(e,t){let o=0;t.RTL&&(o=t.getWidth());const s=[];eo();const i=n.getGroup$$module$build$src$core$events$utils();i||n.setGroup$$module$build$src$core$events$utils(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);let r=!0;try{for(let l=0,c;c=e.childNodes[l];l++){const p=c.nodeName.toLowerCase(),T=c;if(p==="block"||p==="shadow"&&!we()){const Y=uo(T,t);s.push(Y.id);let V;const pe=parseInt((V=T.getAttribute("x"))!=null?V:"10",10);let At;const bt=parseInt((At=T.getAttribute("y"))!=null?At:"10",10);isNaN(pe)||isNaN(bt)||Y.moveBy(t.RTL?o-pe:pe,bt,["create"]),r=!1}else{if(p==="shadow")throw TypeError("Shadow block cannot be a top-level block.");if(p==="comment")ql(T,t);else if(p==="variables"){if(r)Ql(T,t);else throw Error("'variables' tag must exist once before block and shadow tag elements in the workspace XML, but it was found in another location.");r=!1}}}}finally{n.setGroup$$module$build$src$core$events$utils(i),t.setResizesEnabled&&t.setResizesEnabled(!0),t.rendered&&Bt(),to()}return C(new(w(a.FINISHED_LOADING))(t)),s},ql=function(e,t){var o;const s=(o=e.getAttribute("id"))!=null?o:void 0;o=t.rendered?new ct(t,s):new cn(t,s);var i;o.setText((i=e.textContent)!=null?i:"");var r;i=parseInt((r=e.getAttribute("x"))!=null?r:"",10);let l;r=parseInt((l=e.getAttribute("y"))!=null?l:"",10),isNaN(i)||isNaN(r)||(i=t.RTL?t.getWidth()-i:i,o.moveTo(new f(i,r)));var c;t=parseInt((c=e.getAttribute("w"))!=null?c:"",10);let p;return c=parseInt((p=e.getAttribute("h"))!=null?p:"",10),isNaN(t)||isNaN(c)||o.setSize(new N(t,c)),e.getAttribute("collapsed")==="true"&&o.setCollapsed(!0),e.getAttribute("editable")==="false"&&o.setEditable(!1),e.getAttribute("movable")==="false"&&o.setMovable(!1),e.getAttribute("deletable")==="false"&&o.setDeletable(!1),o},md=function(e,t){if(!t.getBlocksBoundingBox)return n.domToWorkspace$$module$build$src$core$xml(e,t);var o=t.getBlocksBoundingBox();if(e=n.domToWorkspace$$module$build$src$core$xml(e,t),o&&o.top!==o.bottom){var s=o.bottom;o=t.RTL?o.right:o.left;var i=1/0;let r=-1/0,l=1/0;for(let c=0;c<e.length;c++){const p=t.getBlockById(e[c]).getRelativeToSurfaceXY();p.y<l&&(l=p.y),p.x<i&&(i=p.x),p.x>r&&(r=p.x)}for(s=s-l+10,o=t.RTL?o-r:o-i,i=0;i<e.length;i++)t.getBlockById(e[i]).moveBy(o,s,["create"])}return e},n.domToBlock$$module$build$src$core$xml=function(e,t){return e=uo(e,t),t.rendered&&Bt(),e},uo=function(e,t){n.disable$$module$build$src$core$events$utils();var o=t.getAllVariables();let s;try{if(s=mr(e,t),t.rendered){const i=s,r=s.getDescendants(!1);i.setConnectionTracking(!1);for(let l=r.length-1;l>=0;l--)r[l].initSvg();for(let l=r.length-1;l>=0;l--)r[l].queueRender();setTimeout(function(){i.disposed||i.setConnectionTracking(!0)},1),t.resizeContents()}else{const i=s.getDescendants(!1);for(let r=i.length-1;r>=0;r--)i[r].initModel()}}finally{n.enable$$module$build$src$core$events$utils()}if(z()){for(e=Fs(t,o),t=0;t<e.length;t++)o=e[t],C(new(w(a.VAR_CREATE))(o));C(new(w(a.BLOCK_CREATE))(s))}return s},Ql=function(e,t){for(let s=0;s<e.children.length;s++){var o=e.children[s];const i=o.getAttribute("type"),r=o.getAttribute("id");if(o=o.textContent,!o)break;let l;t.getVariableMap().createVariable(o,(l=i)!=null?l:void 0,r)}},fd=function(e){const t={mutation:[],comment:[],data:[],field:[],input:[],next:[]};for(let o=0;o<e.children.length;o++){const s=e.children[o];if(s.nodeType!==Ct.TEXT_NODE)switch(s.nodeName.toLowerCase()){case"mutation":t.mutation.push(s);break;case"comment":t.comment.push(s);break;case"data":t.data.push(s);break;case"title":case"field":t.field.push(s);break;case"value":case"statement":t.input.push(s);break;case"next":t.next.push(s);break;default:console.warn("Ignoring unknown tag: "+s.nodeName)}}return t},bd=function(e,t){let o=!1;for(let s=0;s<e.length;s++){const i=e[s];t.domToMutation&&(t.domToMutation(i),t.initSvg&&(o=!0))}return o},_d=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.textContent,r=s.getAttribute("pinned")==="true";let l;const c=parseInt((l=s.getAttribute("w"))!=null?l:"50",10);let p;const T=parseInt((p=s.getAttribute("h"))!=null?p:"50",10);let Y,V=parseInt((Y=s.getAttribute("x"))!=null?Y:"",10),pe;const At=parseInt((pe=s.getAttribute("y"))!=null?pe:"",10);t.setCommentText(i);const bt=t.getIcon(se.COMMENT);isNaN(c)||isNaN(T)||bt.setBubbleSize(new N(c,T)),bt.setBubbleVisible(r),setTimeout(()=>{isNaN(V)||isNaN(At)||(V=t.workspace.RTL?t.workspace.getWidth()-(V+c):V,bt.setBubbleLocation(new f(V,At))),bt.setBubbleVisible(r)},1)}},Ed=function(e,t){for(let o=0;o<e.length;o++)t.data=e[o].textContent},Td=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.getAttribute("name");i?Cd(t,i,s):console.warn(`Ignoring unnamed field in block ${t.type}`)}},ec=function(e){let t=null,o=null;for(let s=0;s<e.childNodes.length;s++){const i=e.childNodes[s];tc(i)&&(i.nodeName.toLowerCase()==="block"?t=i:i.nodeName.toLowerCase()==="shadow"&&(o=i))}return{childBlockElement:t,childShadowElement:o}},yd=function(e,t,o,s){for(let r=0;r<e.length;r++){var i=e[r];const l=i.getAttribute("name"),c=l?o.getInput(l):null;if(!c){console.warn("Ignoring non-existent input "+l+" in block "+s);break}if(i=ec(i),i.childBlockElement){if(!c.connection)throw TypeError("Input connection does not exist.");mr(i.childBlockElement,t,c.connection,!1)}if(i.childShadowElement){let p;(p=c.connection)==null||p.setShadowDom(i.childShadowElement)}}},vd=function(e,t,o){for(let s=0;s<e.length;s++){const i=ec(e[s]);if(i.childBlockElement){if(!o.nextConnection)throw TypeError("Next statement does not exist.");if(o.nextConnection.isConnected())throw TypeError("Next statement is already connected.");mr(i.childBlockElement,t,o.nextConnection,!0)}i.childShadowElement&&o.nextConnection&&o.nextConnection.setShadowDom(i.childShadowElement)}},mr=function(e,t,o,s){var i;const r=e.getAttribute("type");if(!r)throw TypeError("Block type unspecified: "+e.outerHTML);var l=(i=e.getAttribute("id"))!=null?i:void 0;i=t.newBlock(r,l),l=fd(e);const c=bd(l.mutation,i);if(_d(l.comment,i),Ed(l.data,i),o)if(s)if(i.previousConnection)o.connect(i.previousConnection);else throw TypeError("Next block does not have previous statement.");else if(i.outputConnection)o.connect(i.outputConnection);else if(i.previousConnection)o.connect(i.previousConnection);else throw TypeError("Child block does not have output or previous statement.");if(Td(l.field,i),yd(l.input,t,i,r),vd(l.next,t,i),c&&i.initSvg(),(t=e.getAttribute("inline"))&&i.setInputsInline(t==="true"),(t=e.getAttribute("disabled"))&&i.setDisabledReason(t==="true"||t==="disabled",Fe),t=e.getAttribute("disabled-reasons"),t!==null)for(var p of t.split(","))i.setDisabledReason(!0,decodeURIComponent(p));if((p=e.getAttribute("deletable"))&&i.setDeletable(p==="true"),(p=e.getAttribute("movable"))&&i.setMovable(p==="true"),(p=e.getAttribute("editable"))&&i.setEditable(p==="true"),(p=e.getAttribute("collapsed"))&&i.setCollapsed(p==="true"),e.nodeName.toLowerCase()==="shadow"){for(e=i.getChildren(!1),p=0;p<e.length;p++)if(!e[p].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");i.setShadow(!0)}return i},Cd=function(e,t,o){const s=e.getField(t);s?s.fromXml(o):console.warn("Ignoring non-existent field "+t+" in block "+e.type)},wd=function(e){for(let t=0;t<e.childNodes.length;t++){const o=e.childNodes[t];if(o.nodeName.toLowerCase()==="next"){e.removeChild(o);break}}},tc=function(e){return e.nodeType===Ct.ELEMENT_NODE},it=function(e,t){I(g.FIELD,e,t)},kd=function(e){qt(g.FIELD,e)},n.fromJson$$module$build$src$core$field_registry=function(e){return Fp.fromJsonInternal(e)},Id=function(e){const t=Ot(g.FIELD,e.type);return t?t.fromJson(e):(console.warn("Blockly could not create a field of type "+e.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)},Ko=function(e){return e&&typeof e=="object"&&"src"in e&&typeof e.src=="string"&&"alt"in e&&typeof e.alt=="string"&&"width"in e&&typeof e.width=="number"&&"height"in e&&typeof e.height=="number"},n.register$$module$build$src$core$extensions=function(e,t){if(typeof e!="string"||e.trim()==="")throw Error('Error: Invalid extension name "'+e+'"');if(as[e])throw Error('Error: Extension "'+e+'" is already registered.');if(typeof t!="function")throw Error('Error: Extension "'+e+'" must be a function');as[e]=t},n.registerMixin$$module$build$src$core$extensions=function(e,t){if(!t||typeof t!="object")throw Error('Error: Mixin "'+e+'" must be a object');n.register$$module$build$src$core$extensions(e,function(){this.mixin(t)})},n.registerMutator$$module$build$src$core$extensions=function(e,t,o,s){const i='Error when registering mutator "'+e+'": ';ic(i,t);const r=sc(t,i);if(o&&typeof o!="function")throw Error(i+'Extension "'+e+'" is not a function');n.register$$module$build$src$core$extensions(e,function(){r&&this.setMutator(new n.MutatorIcon$$module$build$src$core$icons$mutator_icon(s||[],this)),this.mixin(t),o&&o.apply(this)})},Sd=function(e){oc(e)?delete as[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')},oc=function(e){return!!as[e]},fr=function(e,t,o){const s=as[e];if(typeof s!="function")throw Error('Error: Extension "'+e+'" not found.');let i;if(o?Rd(e,t):i=_r(t),s.apply(t),o)ic('Error after applying mutator "'+e+'": ',t);else if(!Ad(i,t))throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')},Rd=function(e,t){if(_r(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)},Dd=function(e,t){return br(e.mutationToDom,e.domToMutation,t+" mutationToDom/domToMutation")},Nd=function(e,t){return br(e.saveExtraState,e.loadExtraState,t+" saveExtraState/loadExtraState")},sc=function(e,t){return br(e.compose,e.decompose,t+" compose/decompose")},br=function(e,t,o){if(e&&t){if(typeof e!="function"||typeof t!="function")throw Error(o+" must be a function");return!0}if(!e&&!t)return!1;throw Error(o+"Must have both or neither functions")},ic=function(e,t){const o=Dd(t,e),s=Nd(t,e);if(!o&&!s)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");sc(t,e)},_r=function(e){const t=[];return e.domToMutation!==void 0&&t.push(e.domToMutation),e.mutationToDom!==void 0&&t.push(e.mutationToDom),e.saveExtraState!==void 0&&t.push(e.saveExtraState),e.loadExtraState!==void 0&&t.push(e.loadExtraState),e.compose!==void 0&&t.push(e.compose),e.decompose!==void 0&&t.push(e.decompose),t},Ad=function(e,t){if(t=_r(t),t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(e[o]!==t[o])return!1;return!0},Od=function(e){if(typeof document!="object")throw Error("runAfterPageLoad() requires browser document.");if(document.readyState==="complete")e();else{const t=setInterval(function(){document.readyState==="complete"&&(clearInterval(t),e())},10)}},n.buildTooltipForDropdown$$module$build$src$core$extensions=function(e,t){const o=[];return function(){o.includes(this.type)||(xd(this,e,t),o.push(this.type)),this.setTooltip((function(){const s=String(this.getFieldValue(e));return J(t[s])}).bind(this))}},xd=function(e,t,o){var s=e.getField(t);if(s instanceof $e&&!s.isOptionListDynamic()){s=s.getOptions();for(const i of s)i!==$e.SEPARATOR&&([,s]=i,o[s]===void 0&&console.warn(`No tooltip mapping for value ${s} of field ${t} of block type ${e.type}.`))}},n.buildTooltipWithFieldText$$module$build$src$core$extensions=function(e,t){return function(){this.setTooltip((function(){const o=this.getField(t);return J(e).replace("%1",o?o.getText():"")}).bind(this))}},Ld=function(){const e=this.tooltip;this.setTooltip((function(){const t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}).bind(this))},y=function(e,t){return" "+e+","+t+" "},ve=function(e,t){return" "+e+t.join("")},ce=function(e,t){return" M "+e+","+t+" "},K=function(e,t){return" m "+e+","+t+" "},rt=function(e,t){return" l "+e+","+t+" "},jo=function(e){return" l"+e.join("")},v=function(e,t){return" "+e+" "+t+" "},Z=function(e,t,o,s){return e+" "+o+" "+o+" "+t+s},Md=function(e,t){if(!e||!t)throw Error("Cannot connect null connections.");e.targetConnection=t,t.targetConnection=e},Bd=function(e,t){let o=null;t=t.outputConnection;const s=t?.getConnectionChecker();for(let i=0,r;r=e.inputList[i];i++){const l=r.connection;let c;if(l&&((c=s)!=null&&c.canConnect(t,l,!1))){if(o)return null;o=l}}return o},Pd=function(e,t){let o;for(;o=Bd(e,t);)if(e=o.targetBlock(),!e||e.isShadow())return o;return null},rc=function(e){return Oo(e)&&typeof e.getType=="function"&&typeof e.initView=="function"&&typeof e.dispose=="function"&&typeof e.getWeight=="function"&&typeof e.getSize=="function"&&typeof e.applyColour=="function"&&typeof e.hideForInsertionMarker=="function"&&typeof e.updateEditable=="function"&&typeof e.updateCollapsed=="function"&&typeof e.isShownWhenCollapsed=="function"&&typeof e.setOffsetInBlock=="function"&&typeof e.onLocationChange=="function"&&typeof e.onClick=="function"},Fd=function(e){return rc(e)&&ro(e)&&Bs(e)&&typeof e.setText=="function"&&typeof e.getText=="function"&&typeof e.setBubbleSize=="function"&&typeof e.getBubbleSize=="function"&&typeof e.setBubbleLocation=="function"&&typeof e.getBubbleLocation=="function"&&e.getType()===se.COMMENT},Er=function(e){if(!(e.getDescendants(!1).length>100)){var t=e.workspace,o=e.getSvgRoot();t.getAudioManager().play("delete");var s=e.getRelativeToSurfaceXY(),i=o.cloneNode(!0);i.setAttribute("transform","translate("+s.x+","+s.y+")");var r;(r=t.getLayerManager())==null||r.appendToAnimationLayer({getSvgRoot:()=>i}),nc(i,{x:s.x,y:s.y,width:e.width,height:e.height},t.RTL,new Date)}},nc=function(e,t,o,s){const i=(new Date().getTime()-s.getTime())/150;i>1?F(e):(e.setAttribute("transform","translate("+(t.x+(o?-1:1)*t.width/2*i)+","+(t.y+t.height/2*i)+") scale("+(1-i)+")"),setTimeout(nc,10,e,t,o,s))},lc=function(e){var t=e.workspace;const o=t.scale;if(t.getAudioManager().play("click"),!(o<1)){var s=t.getSvgXY(e.getSvgRoot());e.outputConnection?(s.x+=(e.RTL?3:-3)*o,s.y+=13*o):e.previousConnection&&(s.x+=(e.RTL?-23:23)*o,s.y+=3*o);var i=m(h.CIRCLE,{cx:s.x,cy:s.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg());e=m(h.ANIMATE,{id:"animationCircle",begin:"indefinite",attributeName:"r",dur:"150ms",from:0,to:25*o},i),t=m(h.ANIMATE,{id:"animationOpacity",begin:"indefinite",attributeName:"opacity",dur:"150ms",from:1,to:0},i),e.beginElement(),t.beginElement(),setTimeout(()=>void F(i),150)}},cc=function(e){if(Jo(),e.workspace.getAudioManager().play("disconnect"),!(e.workspace.scale<1)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),mi=e,uc(e,t,new Date,0)}},uc=function(e,t,o,s){const i=[.66,1,.66,0,-.66,-1,-.66,0];let r="";o.getTime()+200>new Date().getTime()&&(r=`skewX(${Math.round(i[s%i.length]*t)})`,$n=setTimeout(uc,15,e,t,o,s+1)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${r}`)},Jo=function(){mi&&($n&&(clearTimeout($n),$n=null),mi.getSvgRoot().setAttribute("transform",mi.getTranslation()),mi=null)},Hd=function(e,t){const o=e.workspace,s=n.config$$module$build$src$core$config.snapRadius,i=f.difference(t,e.getRelativeToSurfaceXY()),r=new f(0,0),l=o.getAllBlocks(!1).filter(c=>c.id!=e.id).map(c=>c.getRelativeToSurfaceXY());for(;Gd(f.sum(t,r),l)||Vd(e,f.sum(i,r),s);)o.RTL?r.translate(-s,s*2):r.translate(s,s*2);e.moveTo(f.sum(t,r))},Gd=function(e,t){return t.some(o=>Math.abs(o.x-e.x)<=1&&Math.abs(o.y-e.y)<=1)},Vd=function(e,t,o){return e.getConnections_(!1).some(s=>!!s.closest(o,t).connection)},Zo=function(e,t,o){const s=o.getBoundingRectangle(),i=s.right-s.left,r=Vo(t.top,s.top,t.top+t.height-(s.bottom-s.top))-s.top;let l=t.left;return t=t.left+t.width-i,e.RTL?l=Math.min(t,l):t=Math.max(l,t),(e=Vo(l,s.left,t)-s.left)||r?(o.moveBy(e,r,["inbounds"]),!0):!1},hc=function(e){return t=>{var o=e.getMetricsManager();if(o.hasFixedEdges()&&!e.isDragging()){var s;if(N$.includes((s=t.type)!=null?s:"")){s=o.getScrollMetrics(!0);const i=Wd(e,t);i&&(o=n.getGroup$$module$build$src$core$events$utils()||!1,n.setGroup$$module$build$src$core$events$utils(t.group),Zo(e,s,i)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),n.setGroup$$module$build$src$core$events$utils(o))}else Ai(t)&&t.scale&&t.oldScale&&t.scale>t.oldScale&&Tr(e)}}},Wd=function(e,t){let o=null;switch(t.type){case a.BLOCK_CREATE:case a.BLOCK_MOVE:(o=e.getBlockById(t.blockId))&&(o=o.getRootBlock());break;case a.COMMENT_CREATE:case a.COMMENT_MOVE:case a.COMMENT_RESIZE:o=e.getCommentById(t.commentId)}return o},Tr=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var o=e.getTopBoundedElements();for(let s=0,i;i=o[s];s++)Zo(e,t,i)}},Pe=function(e){return e&&typeof e.isDeletable=="function"&&typeof e.dispose=="function"&&typeof e.setDeleteStyle=="function"},ac=function(e,t){const o=e.getIcons();for(const s of e.inputList){if(!s.isVisible())continue;o.push(...s.fieldRow);let i;if((i=s.connection)!=null&&i.targetBlock())if(e=s.connection.targetBlock(),s.connection.type!==E.NEXT_STATEMENT||t)o.push(e);else{let r;(e=(r=e.lastConnectionInStack(!1))==null?void 0:r.getSourceBlock())&&o.push(e)}else{let r;((r=s.connection)==null?void 0:r.type)===E.INPUT_VALUE&&o.push(s.connection)}}return o},qo=function(e,t){const o=e.workspace.getTopBoundedElements(!0).filter(i=>Oo(i));e=o.indexOf(e instanceof H?e.getRootBlock():e)+t;let s=null;if(e>=0&&e<o.length?s=o[e]:e<0?s=o[o.length-1]:e>=o.length&&(s=o[0]),t<0&&s instanceof H){let i,r;return(r=(i=s.lastConnectionInStack(!1))==null?void 0:i.getSourceBlock())!=null?r:s}return s},Ue=function(e,t){var o;let s;const i=e instanceof H?(s=(o=e.outputConnection)==null?void 0:o.targetBlock())!=null?s:e.getSurroundParent():e.getSourceBlock();return!(i instanceof H)||(o=ac(i,t>0),e=o.indexOf(e),e===-1)?null:(t=e+t,t>=0&&t<o.length?o[t]:null)},Qo=function(e){return e&&typeof e.getRelativeToSurfaceXY=="function"&&typeof e.isMovable=="function"&&typeof e.startDrag=="function"&&typeof e.drag=="function"&&typeof e.endDrag=="function"&&typeof e.revertDrag=="function"},dc=function(e){return e&&typeof e.autoHide=="function"},$c=function(e,t){I(g.ICON,e.toString(),t)},Ud=function(e){qt(g.ICON,e)},Ht=function(e){return typeof e.getProcedureModel=="function"&&typeof e.doProcedureUpdate=="function"&&typeof e.isProcedureDef=="function"},yr=function(e){return e&&typeof e.startPublishing=="function"&&typeof e.stopPublishing=="function"},Ks=function(e){const t=e.getProcedureMap().getProcedures().filter(s=>!s.getReturnTypes()).map(s=>[s.getName(),s.getParameters().map(i=>i.getName()),!1]);e.getBlocksByType("procedures_defnoreturn",!1).forEach(s=>{!Ht(s)&&Po(s)&&t.push(s.getProcedureDef())});const o=e.getProcedureMap().getProcedures().filter(s=>!!s.getReturnTypes()).map(s=>[s.getName(),s.getParameters().map(i=>i.getName()),!0]);return e.getBlocksByType("procedures_defreturn",!1).forEach(s=>{!Ht(s)&&Po(s)&&o.push(s.getProcedureDef())}),t.sort(pc),o.sort(pc),[t,o]},pc=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},n.findLegalName$$module$build$src$core$procedures=function(e,t){if(t.isInFlyout)return e;for(e=e||n.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed";!zd(e,t.workspace,t);){const o=e.match(/^(.*?)(\d+)$/);e=o?o[1]+(parseInt(o[2])+1):e+"2"}return e},zd=function(e,t,o){return!gc(e,t,o)},gc=function(e,t,o){for(const s of t.getAllBlocks(!1))if(s!==o&&Po(s)&&n.Names$$module$build$src$core$names.equals(s.getProcedureDef()[0],e))return!0;o=o&&Ht(o)?o?.getProcedureModel():void 0;for(const s of t.getProcedureMap().getProcedures())if(s!==o&&n.Names$$module$build$src$core$names.equals(s.getName(),e))return!0;return!1},n.rename$$module$build$src$core$procedures=function(e){var t=this.getSourceBlock();if(!t)throw new te;e=e.trim();const o=n.findLegalName$$module$build$src$core$procedures(e,t);Ht(t)&&!t.isInsertionMarker()&&t.getProcedureModel().setName(o);const s=this.getValue();if(s!==e&&s!==o)for(e=t.workspace.getAllBlocks(!1),t=0;t<e.length;t++){const i=e[t];i.renameProcedure&&i.renameProcedure(s,o)}return o},Xd=function(e){function t(r,l){for(let p=0;p<r.length;p++){var c=r[p][0];const T=r[p][1],Y=n.createElement$$module$build$src$core$utils$xml("block");Y.setAttribute("type",l),Y.setAttribute("gap","16");const V=n.createElement$$module$build$src$core$utils$xml("mutation");for(V.setAttribute("name",c),Y.appendChild(V),c=0;c<T.length;c++){const pe=n.createElement$$module$build$src$core$utils$xml("arg");pe.setAttribute("name",T[c]),V.appendChild(pe)}o.push(Y)}}const o=[];if(W.procedures_defnoreturn){var s=n.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","procedures_defnoreturn"),s.setAttribute("gap","16");var i=n.createElement$$module$build$src$core$utils$xml("field");i.setAttribute("name","NAME"),i.appendChild(n.createTextNode$$module$build$src$core$utils$xml(n.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE)),s.appendChild(i),o.push(s)}return W.procedures_defreturn&&(s=n.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","procedures_defreturn"),s.setAttribute("gap","16"),i=n.createElement$$module$build$src$core$utils$xml("field"),i.setAttribute("name","NAME"),i.appendChild(n.createTextNode$$module$build$src$core$utils$xml(n.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE)),s.appendChild(i),o.push(s)),W.procedures_ifreturn&&(s=n.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","procedures_ifreturn"),s.setAttribute("gap","16"),o.push(s)),o.length&&o[o.length-1].setAttribute("gap","24"),e=Ks(e),t(e[0],"procedures_callnoreturn"),t(e[1],"procedures_callreturn"),o},vr=function(e){return mc(e,!1)},mc=function(e,t=!0){function o(i,r){for(const[l,c]of i)s.push({kind:"block",type:r,gap:16,extraState:{name:l,params:c}})}if(t)return le("The XML return value of Blockly.Procedures.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),Xd(e);const s=[];return W.procedures_defnoreturn&&s.push({kind:"block",type:"procedures_defnoreturn",gap:16,fields:{NAME:n.Msg$$module$build$src$core$msg.PROCEDURES_DEFNORETURN_PROCEDURE}}),W.procedures_defreturn&&s.push({kind:"block",type:"procedures_defreturn",gap:16,fields:{NAME:n.Msg$$module$build$src$core$msg.PROCEDURES_DEFRETURN_PROCEDURE}}),W.procedures_ifreturn&&s.push({kind:"block",type:"procedures_ifreturn",gap:16}),s.length&&(s[s.length-1].gap=24),e=Ks(e),o(e[0],"procedures_callnoreturn"),o(e[1],"procedures_callreturn"),s},fc=function(e){var t=[],o=e.getBlocksByType("procedures_mutatorarg",!1);for(let r=0,l;l=o[r];r++)t.push(l.getFieldValue("NAME"));o=n.createElement$$module$build$src$core$utils$xml("xml");const s=n.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","procedures_mutatorarg");const i=n.createElement$$module$build$src$core$utils$xml("field");i.setAttribute("name","NAME"),t=tr(n.DEFAULT_ARG$$module$build$src$core$procedures,t),t=n.createTextNode$$module$build$src$core$utils$xml(t),i.appendChild(t),s.appendChild(i),o.appendChild(s),e.updateToolbox(o)},bc=function(e){if(Bn(e)&&e.bubbleType==="mutator"&&e.isOpen&&e.blockId){e=xt(e.workspaceId).getBlockById(e.blockId);var t=e.type;(t==="procedures_defnoreturn"||t==="procedures_defreturn")&&(e=e.getIcon(n.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE).getWorkspace(),fc(e),e.addChangeListener(Yd))}},Yd=function(e){(Ni(e)||Mn(e)||No(e)||Gh(e))&&(e=xt(e.workspaceId),fc(e))},_c=function(e,t){return t.getAllBlocks(!1).filter(o=>Kd(o,e)||pa(o)&&n.Names$$module$build$src$core$names.equals(o.getProcedureCall(),e))},Kd=function(e,t){return Ht(e)&&!e.isProcedureDef()&&e.getProcedureModel()&&n.Names$$module$build$src$core$names.equals(e.getProcedureModel().getName(),t)},n.mutateCallers$$module$build$src$core$procedures=function(e){const t=we();var o=e.getProcedureDef()[0];const s=e.mutationToDom(!0);e=_c(o,e.workspace);for(let r=0,l;l=e[r];r++){o=(o=l.mutationToDom())&&Mo(o),l.domToMutation&&l.domToMutation(s);var i=l.mutationToDom();i=i&&Mo(i),o!==i&&(n.setRecordUndo$$module$build$src$core$events$utils(!1),C(new(w(a.BLOCK_CHANGE))(l,"mutation",null,o,i)),n.setRecordUndo$$module$build$src$core$events$utils(t))}},n.getDefinition$$module$build$src$core$procedures=function(e,t){for(const o of t.getAllBlocks(!1))if(Ht(o)&&o.isProcedureDef()&&n.Names$$module$build$src$core$names.equals(o.getProcedureModel().getName(),e)||Po(o)&&n.Names$$module$build$src$core$names.equals(o.getProcedureDef()[0],e))return o;return null},Cr=function(e){return e.isDynamic},jd=function(e){return e.pathDown!==void 0&&e.pathUp!==void 0},Jd=function(e){return e.pathLeft!==void 0&&e.pathRight!==void 0},js=function(e,t){I(g.RENDERER,e,t)},Zd=function(e){qt(g.RENDERER,e)},Ec=function(e,t,o){return e=new(Ve(g.RENDERER,e))(e),e.init(t,o),e},wr=function(e){so(e.getTargetWorkspace(),void 0,"String")},kr=function(e){so(e.getTargetWorkspace(),void 0,"Number")},Ir=function(e){so(e.getTargetWorkspace(),void 0,"Colour")},Sr=function(e){return Tc(e,!1)},Tc=function(e,t=!0){return W.variables_set_dynamic||W.variables_get_dynamic||console.warn("There are no dynamic variable blocks, but there is a dynamic variable category."),t?(le("The XML return value of Blockly.VariablesDynamic.flyoutCategory()","v12","v13","the same method, but handle a return type of FlyoutItemInfo[] (JSON) instead."),qd(e)):(e.registerButtonCallback("CREATE_VARIABLE_STRING",wr),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",kr),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Ir),[{kind:"button",text:n.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE,callbackkey:"CREATE_VARIABLE_STRING"},{kind:"button",text:n.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE,callbackkey:"CREATE_VARIABLE_NUMBER"},{kind:"button",text:n.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE,callbackkey:"CREATE_VARIABLE_COLOUR"},...er(e,e.getVariableMap().getAllVariables(),!1,"variables_get_dynamic","variables_set_dynamic")])},qd=function(e){let t=[],o=document.createElement("button");return o.setAttribute("text",n.Msg$$module$build$src$core$msg.NEW_STRING_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),t.push(o),o=document.createElement("button"),o.setAttribute("text",n.Msg$$module$build$src$core$msg.NEW_NUMBER_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),t.push(o),o=document.createElement("button"),o.setAttribute("text",n.Msg$$module$build$src$core$msg.NEW_COLOUR_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),t.push(o),e.registerButtonCallback("CREATE_VARIABLE_STRING",wr),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",kr),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Ir),e=yc(e),t=t.concat(e)},yc=function(e){e=e.getVariableMap().getAllVariables();const t=[];if(e.length>0){if(W.variables_set_dynamic){var o=e[e.length-1];const s=n.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set_dynamic"),s.setAttribute("gap","24"),s.appendChild(io(o)),t.push(s)}if(W.variables_get_dynamic){e.sort(Fo);for(let s=0,i;i=e[s];s++)o=n.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get_dynamic"),o.setAttribute("gap","8"),o.appendChild(io(i)),t.push(o)}}return t},Rr=function(e,t){const o=e.toCopyData();return vi=o,Ci=Fi(e)&&e.workspace instanceof be?e.workspace:null,Rn=t,o},Dr=function(){return vi},Qd=function(e){vi=e},Nr=function(){return Ci},e$=function(e){Ci=e},vc=function(){return Rn},t$=function(e){Rn=e},Gt=function(e,t,o){return e&&t?Cc(e,t,o):vi&&Ci?Cc(vi,Ci,Rn):null},Cc=function(e,t,o){let s;t=t.isMutator?t:(s=t.options.parentWorkspace)!=null?s:t;let i,r;return(r=(i=Ot(g.PASTER,e.paster,!1))==null?void 0:i.paste(e,t,o))!=null?r:null},Js=function(e){return e&&typeof e.toCopyData=="function"},wc=function(){G.registry.register({name:$t.ESCAPE,preconditionFn(e){return!e.isReadOnly()},callback(e){return e.hideChaff(),!0},keyCodes:[P.ESC]})},kc=function(){G.registry.register({name:$t.DELETE,preconditionFn(e,t){return t=t.focusedNode,!e.isReadOnly()&&t!=null&&Pe(t)&&t.isDeletable()&&!e.isDragging()&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(e,t,o,s){return t.preventDefault(),e=s.focusedNode,e instanceof H?e.checkAndDelete():Pe(e)&&e.isDeletable()&&(n.setGroup$$module$build$src$core$events$utils(!0),e.dispose(),n.setGroup$$module$build$src$core$events$utils(!1)),!0},keyCodes:[P.DELETE,P.BACKSPACE]})},Ar=function(e){return Js(e)&&Pe(e)&&Qo(e)?e.isCopyable?e.isCopyable():e instanceof H||e instanceof ct?e.isOwnDeletable()&&e.isOwnMovable():e.isDeletable()&&e.isMovable():!1},Ic=function(e){return Ar(e)&&Pe(e)&&e.isDeletable()},Sc=function(){const e=G.registry.createSerializedKey(P.C,[P.CTRL]),t=G.registry.createSerializedKey(P.C,[P.META]);G.registry.register({name:$t.COPY,preconditionFn(o,s){return s=s.focusedNode,o=o.isFlyout?o.targetWorkspace:o,!!s&&!!o&&!o.isDragging()&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&Ar(s)},callback(o,s,i,r){return s.preventDefault(),s=r.focusedNode,!s||!Js(s)||!Ar(s)||(o=o.isFlyout?o.targetWorkspace:o,!o)?!1:(s.workspace.isFlyout||o.hideChaff(),o=Qo(s)&&s.workspace==o?s.getRelativeToSurfaceXY():void 0,!!Rr(s,o))},keyCodes:[e,t]})},Rc=function(){const e=G.registry.createSerializedKey(P.X,[P.CTRL]),t=G.registry.createSerializedKey(P.X,[P.META]);G.registry.register({name:$t.CUT,preconditionFn(o,s){return s=s.focusedNode,!!s&&!o.isReadOnly()&&!o.isDragging()&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()&&Ic(s)},callback(o,s,i,r){return o=r.focusedNode,!o||!Ic(o)||!Js(o)?!1:(s=Qo(o)?o.getRelativeToSurfaceXY():void 0,s=Rr(o,s),o instanceof H?o.checkAndDelete():Pe(o)&&o.dispose(),!!s)},keyCodes:[e,t]})},Dc=function(){const e=G.registry.createSerializedKey(P.V,[P.CTRL]),t=G.registry.createSerializedKey(P.V,[P.META]);G.registry.register({name:$t.PASTE,preconditionFn(){var o=Nr();return!o||!o.rendered?!1:(o=o.isFlyout?o.targetWorkspace:o,!!Dr()&&!!o&&!o.isReadOnly()&&!o.isDragging()&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken())},callback(o,s){if(o=Dr(),!o)return!1;var i=Nr();if(!i||(i=i.isFlyout?i.targetWorkspace:i,!i||i.isReadOnly()))return!1;if(s instanceof PointerEvent)return s=Qn(i,new f(s.clientX,s.clientY)),!!Gt(o,i,s);if(s=vc(),!s)return!!Gt(o,i);const{left:r,top:l,width:c,height:p}=i.getMetricsManager().getViewMetrics(!0);return new D(l,l+p,r,r+c).contains(s.x,s.y)?!!Gt(o,i):(s=new f(r+c/2,l+p/2),!!Gt(o,i,s))},keyCodes:[e,t]})},Nc=function(){const e=G.registry.createSerializedKey(P.Z,[P.CTRL]),t=G.registry.createSerializedKey(P.Z,[P.META]);G.registry.register({name:$t.UNDO,preconditionFn(o){return!o.isReadOnly()&&!o.isDragging()&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(o,s){return o.hideChaff(),o.undo(!1),s.preventDefault(),!0},keyCodes:[e,t]})},Ac=function(){const e=G.registry.createSerializedKey(P.Z,[P.CTRL,P.SHIFT]),t=G.registry.createSerializedKey(P.Z,[P.META,P.SHIFT]),o=G.registry.createSerializedKey(P.Y,[P.CTRL]);G.registry.register({name:$t.REDO,preconditionFn(s){return!s.isDragging()&&!s.isReadOnly()&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()},callback(s,i){return s.hideChaff(),s.undo(!0),i.preventDefault(),!0},keyCodes:[e,t,o]})},Oc=function(){wc(),kc(),Sc(),Rc(),Dc(),Nc(),Ac()},xc=function(e){const t=e.saveState();return e.getParameters().length&&(t.parameters=e.getParameters().map(o=>o.saveState())),t},Lc=function(e,t,o,s){if(e=e.loadState(o,s),!o.parameters)return e;for(const[i,r]of o.parameters.entries())e.insertParameter(t.loadState(r,s),i);return e},o$=function(e){const t=Object.create(null),o=Di(g.SERIALIZER,!0);for(const s in o){let i;const r=(i=o[s])==null?void 0:i.save(e);r&&(t[s]=r)}return t},s$=function(e,t,{recordUndo:o=!1}={}){var s=Di(g.SERIALIZER,!0);if(s){s=Object.entries(s).sort((r,l)=>l[1].priority-r[1].priority);var i=we();n.setRecordUndo$$module$build$src$core$events$utils(o),(o=n.getGroup$$module$build$src$core$events$utils())||n.setGroup$$module$build$src$core$events$utils(!0),eo(),t instanceof be&&t.setResizesEnabled(!1);for(const[,r]of s.reverse()){let l;(l=r)==null||l.clear(t)}for(const[r,l]of s.reverse())if(e[r]){let c;(c=l)==null||c.load(e[r],t)}t instanceof be&&t.setResizesEnabled(!0),to(),C(new(w(a.FINISHED_LOADING))(t)),n.setGroup$$module$build$src$core$events$utils(o),n.setRecordUndo$$module$build$src$core$events$utils(i)}},i$=function(e,t){let o=null;o=typeof e=="string"?document.getElementById(e)||document.querySelector(e):e;var s;if(!document.contains(o)&&document!==((s=o)==null?void 0:s.ownerDocument))throw Error("Error: container is not in current document");e=new ut(t||{}),s=document.createElement("div"),b(s,"injectionDiv"),t!=null&&t.rtl&&b(s,"blocklyRTL"),o.appendChild(s),t=r$(s,e);const i=n$(s,t,e);return l$(i),Is(i),oo(i),s.addEventListener("focusin",function(){Is(i)}),k(s,"keydown",null,Ns),i},r$=function(e,t){e.setAttribute("dir","LTR"),zn(t.hasCss,t.pathToMedia);const o=m(h.SVG,{xmlns:Qs,"xmlns:html":nt,"xmlns:xlink":Ie,version:"1.1",class:"blocklySvg"},e),s=m(h.DEFS,{},o),i=String(Math.random()).substring(2);return t.gridPattern=Ju.createDom(i,t.gridOptions,s,e),o},n$=function(e,t,o){o.parentWorkspace=null,o=new be(o);const s=o.options;o.scale=s.zoomOptions.startScale,t.appendChild(o.createDom("blocklyMainBackground",e));var i=o.getRenderer().getClassName();return i&&b(e,i),(i=o.getTheme().getClassName())&&b(e,i),!s.hasCategories&&s.languageTree&&(e=o.addFlyout(h.SVG),Qt(e,t)),s.hasTrashcan&&o.addTrashcan(),s.zoomOptions&&s.zoomOptions.controls&&o.addZoomControls(),o.getThemeManager().subscribe(t,"workspaceBackgroundColour","background-color"),o.translate(0,0),o.addChangeListener(hc(o)),oo(o),Vl(),ir(),Al(),o},l$=function(e){const t=e.options;var o=e.getParentSvg();if(k(o.parentNode,"contextmenu",null,function(s){vs(s)||s.preventDefault()}),o=k(window,"resize",null,function(){Et(),e.hideComponents(!0),Il(),Xl(),oo(e),Tr(e)}),e.setResizeHandlerWrapper(o),c$(),t.languageTree){o=e.getToolbox();const s=e.getFlyout(!0);o?o.init():s&&(s.init(e),s.show(t.languageTree),typeof s.scrollToStart=="function"&&s.scrollToStart())}t.hasTrashcan&&e.trashcan.init(),t.zoomOptions&&t.zoomOptions.controls&&e.zoomControls_.init(),t.moveOptions&&t.moveOptions.scrollbars?(e.scrollbar=new ju(e,t.moveOptions.scrollbars===!0||!!t.moveOptions.scrollbars.horizontal,t.moveOptions.scrollbars===!0||!!t.moveOptions.scrollbars.vertical,"blocklyMainWorkspaceScrollbar"),e.scrollbar.resize()):e.setMetrics({x:.5,y:.5}),t.hasSounds&&u$(t.pathToMedia,e)},c$=function(){Bg||(k(document,"scroll",null,function(){const e=xo();for(let t=0,o;o=e[t];t++)o instanceof be&&o.updateInverseScreenCTM()}),xe(document,"touchend",null,Je),xe(document,"touchcancel",null,Je)),Bg=!0},u$=function(e,t){function o(){for(;i.length;){const r=i.pop();r&&x(r)}s.preload()}const s=t.getAudioManager();s.load([e+"click.mp3",e+"click.wav",e+"click.ogg"],"click"),s.load([e+"disconnect.wav",e+"disconnect.mp3",e+"disconnect.ogg"],"disconnect"),s.load([e+"delete.mp3",e+"delete.ogg",e+"delete.wav"],"delete");const i=[];i.push(k(document,"pointermove",null,o,!0)),i.push(k(document,"touchstart",null,o,!0))},Mc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.UNDO},preconditionFn(e){return e.workspace.getUndoStack().length>0?"enabled":"disabled"},callback(e){e.workspace.undo(!1)},scopeType:R.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1})},Bc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.REDO},preconditionFn(e){return e.workspace.getRedoStack().length>0?"enabled":"disabled"},callback(e){e.workspace.undo(!0)},scopeType:R.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2})},Pc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.CLEAN_UP},preconditionFn(e){return e.workspace.isMovable()?e.workspace.getTopBlocks(!1).length>1?"enabled":"disabled":"hidden"},callback(e){e.workspace.cleanUp()},scopeType:R.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3})},Fc=function(e,t){function o(r){i--,r.setCollapsed(e),i===0&&n.setGroup$$module$build$src$core$events$utils(!1)}let s=0,i=0;n.setGroup$$module$build$src$core$events$utils(!0);for(let r=0;r<t.length;r++){let l=t[r];for(;l;)i++,setTimeout(o.bind(null,l),s),l=l.getNextBlock(),s+=10}},Hc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.COLLAPSE_ALL},preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let o=e[t];for(;o;){if(!o.isCollapsed())return"enabled";o=o.getNextBlock()}}return"disabled"}return"hidden"},callback(e){Fc(!0,e.workspace.getTopBlocks(!0))},scopeType:R.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})},Gc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.EXPAND_ALL},preconditionFn(e){if(e.workspace.options.collapse){e=e.workspace.getTopBlocks(!1);for(let t=0;t<e.length;t++){let o=e[t];for(;o;){if(o.isCollapsed())return"enabled";o=o.getNextBlock()}}return"disabled"}return"hidden"},callback(e){Fc(!1,e.workspace.getTopBlocks(!0))},scopeType:R.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})},Vc=function(e,t){if(e.isDeletable())Array.prototype.push.apply(t,e.getDescendants(!1));else{e=e.getChildren(!1);for(let o=0;o<e.length;o++)Vc(e[o],t)}},Or=function(e){const t=[];e=e.getTopBlocks(!0);for(let o=0;o<e.length;o++)Vc(e[o],t);return t},Zs=function(e,t){t?n.setGroup$$module$build$src$core$events$utils(t):(n.setGroup$$module$build$src$core$events$utils(!0),t=n.getGroup$$module$build$src$core$events$utils());const o=e.shift();o&&(o.isDeadOrDying()?Zs(e,t):(o.dispose(!1,!0),setTimeout(Zs,10,e,t))),n.setGroup$$module$build$src$core$events$utils(!1)},Wc=function(){R.registry.register({displayText(e){return e.workspace?(e=Or(e.workspace).length,e===1?n.Msg$$module$build$src$core$msg.DELETE_BLOCK:n.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${e}`)):""},preconditionFn(e){return e.workspace&&Or(e.workspace).length>0?"enabled":"disabled"},callback(e){if(e.workspace){e.workspace.cancelCurrentGesture();var t=Or(e.workspace);t.length<2?Zs(t):Ji(n.Msg$$module$build$src$core$msg.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),function(o){o&&Zs(t)})}},scopeType:R.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},h$=function(){Mc(),Bc(),Pc(),Hc(),Gc(),Wc()},Uc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.DUPLICATE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden"},callback(e){if(e.block){var t=e.block.toCopyData();t&&Gt(t,e.block.workspace)}},scopeType:R.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},zc=function(){R.registry.register({displayText(e){return e.block.hasIcon(Nt.TYPE)?n.Msg$$module$build$src$core$msg.REMOVE_COMMENT:n.Msg$$module$build$src$core$msg.ADD_COMMENT},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.workspace.options.comments&&!e.isCollapsed()&&e.isEditable()?"enabled":"hidden"},callback(e){e=e.block,e.hasIcon(Nt.TYPE)?e.setCommentText(null):e.setCommentText("")},scopeType:R.ScopeType.BLOCK,id:"blockComment",weight:2})},Xc=function(){R.registry.register({displayText(e){return e.block.getInputsInline()?n.Msg$$module$build$src$core$msg.EXTERNAL_INPUTS:n.Msg$$module$build$src$core$msg.INLINE_INPUTS},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.isMovable()&&!e.isCollapsed()){for(let t=1;t<e.inputList.length;t++)if(!(e.inputList[t-1]instanceof Nn||e.inputList[t]instanceof Nn))return"enabled"}return"hidden"},callback(e){e.block.setInputsInline(!e.block.getInputsInline())},scopeType:R.ScopeType.BLOCK,id:"blockInline",weight:3})},Yc=function(){R.registry.register({displayText(e){return e.block.isCollapsed()?n.Msg$$module$build$src$core$msg.EXPAND_BLOCK:n.Msg$$module$build$src$core$msg.COLLAPSE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isMovable()&&e.workspace.options.collapse?"enabled":"hidden"},callback(e){e.block.setCollapsed(!e.block.isCollapsed())},scopeType:R.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Kc=function(){R.registry.register({displayText(e){return e.block.hasDisabledReason(Fe)?n.Msg$$module$build$src$core$msg.ENABLE_BLOCK:n.Msg$$module$build$src$core$msg.DISABLE_BLOCK},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.workspace.options.disable&&e.isEditable()){var t=e.getDisabledReasons();return t=t.size>(t.has(Fe)?1:0),e.getInheritedDisabled()||t?"disabled":"enabled"}return"hidden"},callback(e){e=e.block;const t=n.getGroup$$module$build$src$core$events$utils();t||n.setGroup$$module$build$src$core$events$utils(!0),e.setDisabledReason(!e.hasDisabledReason(Fe),Fe),n.setGroup$$module$build$src$core$events$utils(t)},scopeType:R.ScopeType.BLOCK,id:"blockDisable",weight:5})},jc=function(){R.registry.register({displayText(e){var t=e.block;return e=t.getDescendants(!1).length,(t=t.getNextBlock())&&(e-=t.getDescendants(!1).length),e===1?n.Msg$$module$build$src$core$msg.DELETE_BLOCK:n.Msg$$module$build$src$core$msg.DELETE_X_BLOCKS.replace("%1",`${e}`)},preconditionFn(e){return!e.block.isInFlyout&&e.block.isDeletable()?"enabled":"hidden"},callback(e){e.block&&e.block.checkAndDelete()},scopeType:R.ScopeType.BLOCK,id:"blockDelete",weight:6})},Jc=function(){R.registry.register({displayText(){return n.Msg$$module$build$src$core$msg.HELP},preconditionFn(e){return e=e.block,(typeof e.helpUrl=="function"?e.helpUrl():e.helpUrl)?"enabled":"hidden"},callback(e){e.block.showHelp()},scopeType:R.ScopeType.BLOCK,id:"blockHelp",weight:7})},Zc=function(){R.registry.register({displayText:()=>n.Msg$$module$build$src$core$msg.REMOVE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isDeletable()?"enabled":"hidden"},callback(e){n.setGroup$$module$build$src$core$events$utils(!0);let t;(t=e.comment)==null||t.dispose(),n.setGroup$$module$build$src$core$events$utils(!1)},scopeType:R.ScopeType.COMMENT,id:"commentDelete",weight:6})},qc=function(){R.registry.register({displayText:()=>n.Msg$$module$build$src$core$msg.DUPLICATE_COMMENT,preconditionFn(e){let t;return(t=e.comment)!=null&&t.isMovable()?"enabled":"hidden"},callback(e){if(e.comment){var t=e.comment.toCopyData();t&&Gt(t,e.comment.workspace)}},scopeType:R.ScopeType.COMMENT,id:"commentDuplicate",weight:1})},Qc=function(){R.registry.register({displayText:()=>n.Msg$$module$build$src$core$msg.ADD_COMMENT,preconditionFn:e=>{let t;return(t=e.workspace)!=null&&t.isMutator?"hidden":"enabled"},callback:(e,t,o,s)=>{(e=e.workspace)&&(n.setGroup$$module$build$src$core$events$utils(!0),t=new ct(e),t.setPlaceholderText(n.Msg$$module$build$src$core$msg.WORKSPACE_COMMENT_DEFAULT_TEXT),t.moveTo(a$(new f(s.x,s.y),e)),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),n.setGroup$$module$build$src$core$events$utils(!1))},scopeType:R.ScopeType.WORKSPACE,id:"commentCreate",weight:8})},a$=function(e,t){var o=t.getInjectionDiv().getBoundingClientRect();return e=new f(e.x-o.left,e.y-o.top),o=t.getOriginOffsetInPixels(),e=f.difference(e,o),e.scale(1/t.scale),e},d$=function(){Uc(),zc(),Xc(),Yc(),Kc(),jc(),Jc()},$$=function(){qc(),Zc(),Qc()},eu=function(){h$(),d$()},p$=function(e){return e&&typeof e.paste=="function"},g$=function(e){return e&&typeof e.getSvgRoot=="function"},m$=function(e){return e.isSelectable()},f$=function(e){Me().hideChaff(e)},$=$||{},$.scope={},$.ASSUME_ES5=!1,$.ASSUME_ES6=!1,$.ASSUME_ES2020=!1,$.ASSUME_NO_NATIVE_MAP=!1,$.ASSUME_NO_NATIVE_SET=!1,$.ISOLATE_POLYFILLS=!1,$.FORCE_POLYFILL_PROMISE=!1,$.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,$.INSTRUMENT_ASYNC_CONTEXT=!0,$.objectCreate=$.ASSUME_ES5||typeof Object.create=="function"?Object.create:function(e){var t=function(){};return t.prototype=e,new t},$.defineProperty=$.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(e,t,o){return e==Array.prototype||e==Object.prototype||(e[t]=o.value),e},$.getGlobal=function(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof Nm.commonjsGlobal=="object"&&Nm.commonjsGlobal];for(var t=0;t<e.length;++t){var o=e[t];if(o&&o.Math==Math)return o}throw Error("Cannot find global object")},$.global=$.ASSUME_ES2020?globalThis:$.getGlobal(this),$.IS_SYMBOL_NATIVE=typeof Symbol=="function"&&typeof Symbol("x")=="symbol",$.TRUST_ES6_POLYFILLS=!$.ISOLATE_POLYFILLS||$.IS_SYMBOL_NATIVE,$.polyfills={},$.propertyToPolyfillSymbol={},$.POLYFILL_PREFIX="$jscp$",$.polyfill=function(e,t,o,s){t&&($.ISOLATE_POLYFILLS?$.polyfillIsolated(e,t,o,s):$.polyfillUnisolated(e,t,o,s))},$.polyfillUnisolated=function(e,t,o,s){for(o=$.global,e=e.split("."),s=0;s<e.length-1;s++){var i=e[s];if(!(i in o))return;o=o[i]}e=e[e.length-1],s=o[e],t=t(s),t!=s&&t!=null&&$.defineProperty(o,e,{configurable:!0,writable:!0,value:t})},$.polyfillIsolated=function(e,t,o,s){var i=e.split(".");e=i.length===1,s=i[0],s=!e&&s in $.polyfills?$.polyfills:$.global;for(var r=0;r<i.length-1;r++){var l=i[r];if(!(l in s))return;s=s[l]}i=i[i.length-1],o=$.IS_SYMBOL_NATIVE&&o==="es6"?s[i]:null,t=t(o),t!=null&&(e?$.defineProperty($.polyfills,i,{configurable:!0,writable:!0,value:t}):t!==o&&($.propertyToPolyfillSymbol[i]===void 0&&(o=Math.random()*1e9>>>0,$.propertyToPolyfillSymbol[i]=$.IS_SYMBOL_NATIVE?$.global.Symbol(i):$.POLYFILL_PREFIX+o+"$"+i),$.defineProperty(s,$.propertyToPolyfillSymbol[i],{configurable:!0,writable:!0,value:t})))},$.getConstructImplementation=function(){function e(){function o(){}return Reflect.construct(o,[],function(){}),new o instanceof o}if($.TRUST_ES6_POLYFILLS&&typeof Reflect<"u"&&Reflect.construct){if(e())return Reflect.construct;var t=Reflect.construct;return function(o,s,i){return o=t(o,s),i&&Reflect.setPrototypeOf(o,i.prototype),o}}return function(o,s,i){return i===void 0&&(i=o),i=$.objectCreate(i.prototype||Object.prototype),Function.prototype.apply.call(o,i,s)||i}},$.construct={valueOf:$.getConstructImplementation}.valueOf(),$.underscoreProtoCanBeSet=function(){var e={a:!0},t={};try{return t.__proto__=e,t.a}catch{}return!1},$.setPrototypeOf=$.ASSUME_ES6||$.TRUST_ES6_POLYFILLS&&typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf:$.underscoreProtoCanBeSet()?function(e,t){if(e.__proto__=t,e.__proto__!==t)throw new TypeError(e+" is not extensible");return e}:null,$.inherits=function(e,t){if(e.prototype=$.objectCreate(t.prototype),e.prototype.constructor=e,$.ASSUME_ES6||$.setPrototypeOf){var o=$.setPrototypeOf;o(e,t)}else for(o in t)if(o!="prototype")if(Object.defineProperties){var s=Object.getOwnPropertyDescriptor(t,o);s&&Object.defineProperty(e,o,s)}else e[o]=t[o];e.superClass_=t.prototype},$.arrayIteratorImpl=function(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}},$.arrayIterator=function(e){return{next:$.arrayIteratorImpl(e)}},$.makeIterator=function(e){var t=typeof Symbol<"u"&&Symbol.iterator&&e[Symbol.iterator];if(t)return t.call(e);if(typeof e.length=="number")return $.arrayIterator(e);throw Error(String(e)+" is not an iterable or ArrayLike")},$.arrayFromIterator=function(e){for(var t,o=[];!(t=e.next()).done;)o.push(t.value);return o},$.arrayFromIterable=function(e){return e instanceof Array?e:$.arrayFromIterator($.makeIterator(e))},$.generator={},$.generator.ensureIteratorResultIsObject_=function(e){if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object")},$.generator.Context=function(){this.isRunning_=!1,this.yieldAllIterator_=null,this.yieldResult=void 0,this.nextAddress=1,this.finallyAddress_=this.catchAddress_=0,this.finallyContexts_=this.abruptCompletion_=null},$.generator.Context.prototype.start_=function(){if(this.isRunning_)throw new TypeError("Generator is already running");this.isRunning_=!0},$.generator.Context.prototype.stop_=function(){this.isRunning_=!1},$.generator.Context.prototype.jumpToErrorHandler_=function(){this.nextAddress=this.catchAddress_||this.finallyAddress_},$.generator.Context.prototype.next_=function(e){this.yieldResult=e},$.generator.Context.prototype.throw_=function(e){this.abruptCompletion_={exception:e,isException:!0},this.jumpToErrorHandler_()},$.generator.Context.prototype.return=function(e){this.abruptCompletion_={return:e},this.nextAddress=this.finallyAddress_},$.generator.Context.prototype.jumpThroughFinallyBlocks=function(e){this.abruptCompletion_={jumpTo:e},this.nextAddress=this.finallyAddress_},$.generator.Context.prototype.yield=function(e,t){return this.nextAddress=t,{value:e}},$.generator.Context.prototype.yieldAll=function(e,t){e=$.makeIterator(e);var o=e.next();if($.generator.ensureIteratorResultIsObject_(o),o.done)this.yieldResult=o.value,this.nextAddress=t;else return this.yieldAllIterator_=e,this.yield(o.value,t)},$.generator.Context.prototype.jumpTo=function(e){this.nextAddress=e},$.generator.Context.prototype.jumpToEnd=function(){this.nextAddress=0},$.generator.Context.prototype.setCatchFinallyBlocks=function(e,t){this.catchAddress_=e,t!=null&&(this.finallyAddress_=t)},$.generator.Context.prototype.setFinallyBlock=function(e){this.catchAddress_=0,this.finallyAddress_=e||0},$.generator.Context.prototype.leaveTryBlock=function(e,t){this.nextAddress=e,this.catchAddress_=t||0},$.generator.Context.prototype.enterCatchBlock=function(e){return this.catchAddress_=e||0,e=this.abruptCompletion_.exception,this.abruptCompletion_=null,e},$.generator.Context.prototype.enterFinallyBlock=function(e,t,o){o?this.finallyContexts_[o]=this.abruptCompletion_:this.finallyContexts_=[this.abruptCompletion_],this.catchAddress_=e||0,this.finallyAddress_=t||0},$.generator.Context.prototype.leaveFinallyBlock=function(e,t){if(t=this.finallyContexts_.splice(t||0)[0],t=this.abruptCompletion_=this.abruptCompletion_||t){if(t.isException)return this.jumpToErrorHandler_();t.jumpTo!=null&&this.finallyAddress_<t.jumpTo?(this.nextAddress=t.jumpTo,this.abruptCompletion_=null):this.nextAddress=this.finallyAddress_}else this.nextAddress=e},$.generator.Context.prototype.forIn=function(e){return new $.generator.Context.PropertyIterator(e)},$.generator.Context.PropertyIterator=function(e){this.object_=e,this.properties_=[];for(var t in e)this.properties_.push(t);this.properties_.reverse()},$.generator.Context.PropertyIterator.prototype.getNext=function(){for(;this.properties_.length>0;){var e=this.properties_.pop();if(e in this.object_)return e}return null},$.generator.Engine_=function(e){this.context_=new $.generator.Context,this.program_=e},$.generator.Engine_.prototype.next_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.next,e,this.context_.next_):(this.context_.next_(e),this.nextStep_())},$.generator.Engine_.prototype.return_=function(e){this.context_.start_();var t=this.context_.yieldAllIterator_;return t?this.yieldAllStep_("return"in t?t.return:function(o){return{value:o,done:!0}},e,this.context_.return):(this.context_.return(e),this.nextStep_())},$.generator.Engine_.prototype.throw_=function(e){return this.context_.start_(),this.context_.yieldAllIterator_?this.yieldAllStep_(this.context_.yieldAllIterator_.throw,e,this.context_.next_):(this.context_.throw_(e),this.nextStep_())},$.generator.Engine_.prototype.yieldAllStep_=function(e,t,o){try{var s=e.call(this.context_.yieldAllIterator_,t);if($.generator.ensureIteratorResultIsObject_(s),!s.done)return this.context_.stop_(),s;var i=s.value}catch(r){return this.context_.yieldAllIterator_=null,this.context_.throw_(r),this.nextStep_()}return this.context_.yieldAllIterator_=null,o.call(this.context_,i),this.nextStep_()},$.generator.Engine_.prototype.nextStep_=function(){for(;this.context_.nextAddress;)try{var e=this.program_(this.context_);if(e)return this.context_.stop_(),{value:e.value,done:!1}}catch(t){this.context_.yieldResult=void 0,this.context_.throw_(t)}if(this.context_.stop_(),this.context_.abruptCompletion_){if(e=this.context_.abruptCompletion_,this.context_.abruptCompletion_=null,e.isException)throw e.exception;return{value:e.return,done:!0}}return{value:void 0,done:!0}},$.generator.Generator_=function(e){this.next=function(t){return e.next_(t)},this.throw=function(t){return e.throw_(t)},this.return=function(t){return e.return_(t)},this[Symbol.iterator]=function(){return this}},$.generator.createGenerator=function(e,t){return t=new $.generator.Generator_(new $.generator.Engine_(t)),$.setPrototypeOf&&e.prototype&&$.setPrototypeOf(t,e.prototype),t},$.asyncExecutePromiseGenerator=function(e){function t(s){return e.next(s)}function o(s){return e.throw(s)}return new Promise(function(s,i){function r(l){l.done?s(l.value):Promise.resolve(l.value).then(t,o).then(r,i)}r(e.next())})},$.asyncExecutePromiseGeneratorFunction=function(e){return $.asyncExecutePromiseGenerator(e())},$.asyncExecutePromiseGeneratorProgram=function(e){return $.asyncExecutePromiseGenerator(new $.generator.Generator_(new $.generator.Engine_(e)))},$.polyfill("globalThis",function(e){return e||$.global},"es_2020","es3"),$.polyfill("Array.prototype.includes",function(e){return e||function(t,o){var s=this;s instanceof String&&(s=String(s));var i=s.length;for(o=o||0,o<0&&(o=Math.max(o+i,0));o<i;o++){var r=s[o];if(r===t||Object.is(r,t))return!0}return!1}},"es7","es3"),$.checkEs6ConformanceViaProxy=function(){try{var e={},t=Object.create(new $.global.Proxy(e,{get:function(o,s,i){return o==e&&s=="q"&&i==t}}));return t.q===!0}catch{return!1}},$.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,$.ES6_CONFORMANCE=$.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$.checkEs6ConformanceViaProxy(),$.initSymbol=function(){},$.iteratorPrototype=function(e){return e={next:e},e[Symbol.iterator]=function(){return this},e},$.owns=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},$.MapEntry=function(){},$.polyfill("Set.prototype.difference",function(e){return e||function(t){$.checkIsSetInstance(this),$.checkIsSetLike(t);var o=$.getSmallerAndLargerSets(this,t);t=new Set(this);var s=o.smallerSetIterator;o=o.largerSet;for(var i=s.next();!i.done;)o.has(i.value)&&t.delete(i.value),i=s.next();return t}},"es_next","es6"),$.checkIsSetLike=function(e){if(typeof e!="object"||e===null||typeof e.size!="number"||e.size<0||typeof e.keys!="function"||typeof e.has!="function")throw new TypeError("Argument must be set-like")},$.checkIsValidIterator=function(e){if(typeof e!="object"||e===null||typeof e.next!="function")throw new TypeError("Invalid iterator.");return e},$.getSmallerAndLargerSets=function(e,t){return e.size<=t.size?{smallerSetIterator:e.keys(),largerSet:t}:{smallerSetIterator:$.checkIsValidIterator(t.keys()),largerSet:e}},$.checkIsSetInstance=function(e){if(!(e instanceof Set))throw new TypeError("Method must be called on an instance of Set.")},$.iteratorFromArray=function(e,t){if($.ASSUME_ES6)return e[Symbol.iterator]();e instanceof String&&(e+="");var o=0,s=!1,i={next:function(){if(!s&&o<e.length){var r=o++;return{value:t(r,e[r]),done:!1}}return s=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i},$.polyfill("Array.prototype.values",function(e){return e||function(){return $.iteratorFromArray(this,function(t,o){return o})}},"es8","es3"),$.polyfill("Array.prototype.flatMap",function(e){return e||function(t,o){var s=[];return Array.prototype.forEach.call(this,function(i,r){i=t.call(o,i,r,this),Array.isArray(i)?s.push.apply(s,i):s.push(i)}),s}},"es9","es5"),$.polyfill("Array.prototype.flat",function(e){return e||function(t){t=t===void 0?1:t;var o=[];return Array.prototype.forEach.call(this,function(s){Array.isArray(s)&&t>0?(s=Array.prototype.flat.call(s,t-1),o.push.apply(o,s)):o.push(s)}),o}},"es9","es5"),$.polyfill("Object.entries",function(e){return e||function(t){var o=[],s;for(s in t)$.owns(t,s)&&o.push([s,t[s]]);return o}},"es8","es3"),$.polyfill("Object.values",function(e){return e||function(t){var o=[],s;for(s in t)$.owns(t,s)&&o.push(t[s]);return o}},"es8","es3");var Vt=Object.create(null),xm={typeMap:Vt},xr=Object.create(null),Ce="default",g=class{constructor(e){this.name=e}toString(){return this.name}};g.CONNECTION_CHECKER=new g("connectionChecker"),g.CONNECTION_PREVIEWER=new g("connectionPreviewer"),g.CURSOR=new g("cursor"),g.EVENT=new g("event"),g.FIELD=new g("field"),g.INPUT=new g("input"),g.RENDERER=new g("renderer"),g.TOOLBOX=new g("toolbox"),g.THEME=new g("theme"),g.TOOLBOX_ITEM=new g("toolboxItem"),g.FLYOUTS_VERTICAL_TOOLBOX=new g("flyoutsVerticalToolbox"),g.FLYOUTS_HORIZONTAL_TOOLBOX=new g("flyoutsHorizontalToolbox"),g.FLYOUT_INFLATER=new g("flyoutInflater"),g.METRICS_MANAGER=new g("metricsManager"),g.BLOCK_DRAGGER=new g("blockDragger"),g.SERIALIZER=new g("serializer"),g.ICON=new g("icon"),g.PASTER=new g("paster"),g.VARIABLE_MODEL=new g("variableModel"),g.VARIABLE_MAP=new g("variableMap");var Tt={DEFAULT:Ce,TEST_ONLY:xm};Tt.Type=g,Tt.getAllItems=Di,Tt.getClass=Ve,Tt.getClassFromOptions=_e,Tt.getObject=Ot,Tt.hasItem=Ri,Tt.register=I,Tt.unregister=qt;var W=Object.create(null),Lm=750,b$="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Lr=null,ho={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Mr=0,ao={TOUCH_ENABLED:b$,TOUCH_MAP:ho};ao.checkTouchIdentifier=Ln,ao.clearTouchIdentifier=Ee,ao.getTouchIdentifierFromEvent=Ro,ao.longStart=xn,ao.longStop=Je,ao.shouldHandleEvent=ys;var tu,_$,E$,T$,Br,Pr,ou,y$,v$,C$;(function(e){function t(s){return o.includes(s.toUpperCase())}tu=e;const o=tu.toUpperCase();_$=t("JavaFX"),E$=t("WebKit"),T$=t("Gecko")&&!E$,Br=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Pr=t("iPad")||t("Macintosh")&&e>0,ou=t("iPhone")&&!Pr,y$=t("Macintosh"),v$=Pr||Br&&!t("Mobile")||t("Silk"),C$=!v$&&(ou||Br)})(globalThis.navigator&&globalThis.navigator.userAgent||"");var Mm=tu,w$=_$,k$=T$,su=Br,Fr=Pr,I$=ou,iu=y$,S$=C$,Bm={ANDROID:su,GECKO:k$,IPAD:Fr,IPHONE:I$,JavaFx:w$,MAC:iu,MOBILE:S$,raw:Mm},R$=40,D$=125,yt={};yt.bind=xe,yt.conditionalBind=k,yt.getScrollDeltaPixels=Cs,yt.isRightButton=We,yt.isTargetInput=vs,yt.mouseToSvg=Do,yt.unbind=x;var a;(function(e){e.BLOCK_CREATE="create",e.BLOCK_DELETE="delete",e.BLOCK_CHANGE="change",e.BLOCK_FIELD_INTERMEDIATE_CHANGE="block_field_intermediate_change",e.BLOCK_MOVE="move",e.VAR_CREATE="var_create",e.VAR_DELETE="var_delete",e.VAR_RENAME="var_rename",e.VAR_TYPE_CHANGE="var_type_change",e.UI="ui",e.BLOCK_DRAG="drag",e.SELECTED="selected",e.CLICK="click",e.MARKER_MOVE="marker_move",e.BUBBLE_OPEN="bubble_open",e.TRASHCAN_OPEN="trashcan_open",e.TOOLBOX_ITEM_SELECT="toolbox_item_select",e.THEME_CHANGE="theme_change",e.VIEWPORT_CHANGE="viewport_change",e.COMMENT_CREATE="comment_create",e.COMMENT_DELETE="comment_delete",e.COMMENT_CHANGE="comment_change",e.COMMENT_MOVE="comment_move",e.COMMENT_RESIZE="comment_resize",e.COMMENT_DRAG="comment_drag",e.COMMENT_COLLAPSE="comment_collapse",e.FINISHED_LOADING="finished_loading"})(a||(a={}));var N$=[a.BLOCK_CREATE,a.BLOCK_MOVE,a.COMMENT_CREATE,a.COMMENT_MOVE],A$="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",O$={genUid:()=>{const e=A$.length,t=[];for(let o=0;o<20;o++)t[o]=A$.charAt(Math.random()*e);return t.join("")}},Pm=0,ru={TEST_ONLY:O$};ru.genUid=_t,ru.getNextUniqueId=Le;var x$="",qs=!0,nu=0,lu="ORPHANED_BLOCK",vt=[],L$={FIRE_QUEUE:vt,enqueueEvent:Pn,fireNow:Oi,fireInternal:Wh,setGroupInternal:Uh};n.disable$$module$build$src$core$events$utils,n.enable$$module$build$src$core$events$utils,n.getGroup$$module$build$src$core$events$utils,n.setGroup$$module$build$src$core$events$utils,n.setRecordUndo$$module$build$src$core$events$utils;var Qs="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",Ie="http://www.w3.org/1999/xlink",Ct;(function(e){e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE"})(Ct||(Ct={}));var ze=null,cu=0,ei=null,ue={HTML_NS:nt};ue.NodeType=Ct,ue.SVG_NS=Qs,ue.XLINK_NS=Ie,ue.addClass=b,ue.createSvgElement=m,ue.getFastTextWidth=Yh,ue.getFastTextWidthWithSizeString=ks,ue.getTextWidth=Ao,ue.hasClass=Mi,ue.insertAfter=Qt,ue.measureFontMetrics=Pi,ue.removeClass=O,ue.removeClasses=Li,ue.removeNode=F,ue.setCssTransform=Bi,ue.startTextWidthCache=eo,ue.stopTextWidthCache=to;var he=class{static findFocusedNode(e){var t=e.getRootFocusableNode();if(!t.canBeFocused())return null;var o=t.getFocusableElement();return Mi(o,he.ACTIVE_CLASS_NAME)||Mi(o,he.PASSIVE_CSS_CLASS_NAME)||(t=o.querySelector(this.ACTIVE_FOCUS_NODE_CSS_SELECTOR),(t instanceof HTMLElement||t instanceof SVGElement)&&(t=he.findFocusableNodeFor(t,e)))?t:(o=o.querySelector(this.PASSIVE_FOCUS_NODE_CSS_SELECTOR),(o instanceof HTMLElement||o instanceof SVGElement)&&(e=he.findFocusableNodeFor(o,e))?e:null)}static findFocusableNodeFor(e,t){if(!e.id||e.id==="null"||t.getNestedTrees().map(i=>he.findFocusableNodeFor(e,i)).findIndex(i=>!!i)!==-1)return null;var o=t.getRootFocusableNode();if(o.canBeFocused()&&e===o.getFocusableElement())return o;var s;return(o=(s=t.lookUpFocusableNode(e.id))!=null?s:null)?o:(s=e.parentElement,!o&&s?he.findFocusableNodeFor(s,t):null)}};he.ACTIVE_CLASS_NAME="blocklyActiveFocus",he.PASSIVE_CSS_CLASS_NAME="blocklyPassiveFocus",he.ACTIVE_FOCUS_NODE_CSS_SELECTOR=`.${he.ACTIVE_CLASS_NAME}`,he.PASSIVE_FOCUS_NODE_CSS_SELECTOR=`.${he.PASSIVE_CSS_CLASS_NAME}`;var Fm=class{constructor(e,t){this.tree=e,this.rootShouldBeAutoTabbable=t}},de=class{constructor(e){this.previouslyFocusedNode=this.focusedNode=null,this.registeredTrees=[],this.isUpdatingFocusedNode=this.recentlyLostAllFocus=this.lockFocusStateChanges=this.currentlyHoldsEphemeralFocus=!1;const t=o=>{if(!this.isUpdatingFocusedNode){this.recentlyLostAllFocus=!o;var s=null;if(o instanceof HTMLElement||o instanceof SVGElement){for(var i of this.registeredTrees)if(s=he.findFocusableNodeFor(o,i.tree))break}if(s&&s.canBeFocused()){o=s.getFocusableTree();let r;i=(r=this.focusedNode)==null?void 0:r.getFocusableTree(),s===o.getRootFocusableNode()&&o!==i?this.focusTree(o):this.focusNode(s)}else this.defocusCurrentFocusedNode()}};e("focusin",o=>{o instanceof FocusEvent&&t(document.activeElement)}),e("focusout",o=>{o instanceof FocusEvent&&t(o.relatedTarget)})}registerTree(e,t=!1){if(this.ensureManagerIsUnlocked(),this.isRegistered(e))throw Error(`Attempted to re-register already registered tree: ${e}.`);this.registeredTrees.push(new Fm(e,t));const o=e.getRootFocusableNode().getFocusableElement();if(!o.id||o.id==="null")throw Error(`Attempting to register a tree with a root element that has an invalid ID: ${e}.`);t&&(o.tabIndex=0)}isRegistered(e){return!!this.lookUpRegistration(e)}lookUpRegistration(e){let t;return(t=this.registeredTrees.find(o=>o.tree===e))!=null?t:null}unregisterTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to unregister not registered tree: ${e}.`);var t=this.registeredTrees.findIndex(i=>i.tree===e);const o=this.registeredTrees[t];this.registeredTrees.splice(t,1),t=he.findFocusedNode(e);const s=e.getRootFocusableNode();t&&this.removeHighlight(t),this.focusedNode!==t&&this.focusedNode!==s||this.updateFocusedNode(null),this.removeHighlight(s),o.rootShouldBeAutoTabbable&&e.getRootFocusableNode().getFocusableElement().removeAttribute("tabindex")}getFocusedTree(){let e,t;return(t=(e=this.focusedNode)==null?void 0:e.getFocusableTree())!=null?t:null}getFocusedNode(){return this.focusedNode}focusTree(e){if(this.ensureManagerIsUnlocked(),!this.isRegistered(e))throw Error(`Attempted to focus unregistered tree: ${e}.`);const t=he.findFocusedNode(e),o=e.getRestoredFocusableNode(t);e=e.getRootFocusableNode();let s;this.focusNode((s=o??t)!=null?s:e)}focusNode(e){this.ensureManagerIsUnlocked();const t=!this.currentlyHoldsEphemeralFocus;t&&(this.isUpdatingFocusedNode=!0);var o,s=((o=this.focusedNode)==null?void 0:o.getFocusableElement())!==document.activeElement;if(this.focusedNode!==e||s)if(e.canBeFocused()){if(o=e.getFocusableTree(),!this.isRegistered(o))throw Error(`Attempted to focus unregistered node: ${e}.`);s=e.getFocusableElement(),s.id&&s.id!=="null"||console.warn("Trying to focus a node that has an invalid ID.");var i=he.findFocusableNodeFor(s,o);s=he.findFocusedNode(o);var r=e;if(i!==e){r=o.getRestoredFocusableNode(s),e=o.getRootFocusableNode();var l;r=(l=r??s)!=null?l:e}e=this.focusedNode,l=e?.getFocusableTree(),e&&this.passivelyFocusNode(e,o),o=o.getRootFocusableNode(),s&&this.removeHighlight(s),o!==r&&this.removeHighlight(o),this.currentlyHoldsEphemeralFocus||this.activelyFocusNode(r,l??null),this.updateFocusedNode(r)}else console.warn("Trying to focus a node that can't be focused.");t&&(this.isUpdatingFocusedNode=!1)}takeEphemeralFocus(e){if(this.ensureManagerIsUnlocked(),this.currentlyHoldsEphemeralFocus)throw Error(`Attempted to take ephemeral focus when it's already held, with new element: ${e}.`);this.currentlyHoldsEphemeralFocus=!0,this.focusedNode&&this.passivelyFocusNode(this.focusedNode,null),e.focus();let t=!1;return()=>{if(t)throw Error(`Attempted to finish ephemeral focus twice for element: ${e}.`);if(t=!0,this.currentlyHoldsEphemeralFocus=!1,this.focusedNode){this.activelyFocusNode(this.focusedNode,null);const o=this.focusedNode;setTimeout(()=>{!this.focusedNode&&this.previouslyFocusedNode===o&&this.recentlyLostAllFocus&&this.focusNode(o)},0)}}}ephemeralFocusTaken(){return this.currentlyHoldsEphemeralFocus}ensureManagerIsUnlocked(){if(this.lockFocusStateChanges)throw Error("FocusManager state changes cannot happen in a tree/node focus/blur callback.")}updateFocusedNode(e){this.previouslyFocusedNode=this.focusedNode,this.focusedNode=e}defocusCurrentFocusedNode(){this.focusedNode&&!this.currentlyHoldsEphemeralFocus&&(this.passivelyFocusNode(this.focusedNode,null),this.updateFocusedNode(null))}activelyFocusNode(e,t){this.lockFocusStateChanges=!0;const o=e.getFocusableTree(),s=e.getFocusableElement();let i;const r=(i=this.lookUpRegistration(o))==null?void 0:i.rootShouldBeAutoTabbable;o!==t&&(o.onTreeFocus(e,t),r&&(o.getRootFocusableNode().getFocusableElement().tabIndex=-1)),e.onNodeFocus(),this.lockFocusStateChanges=!1,r&&e===o.getRootFocusableNode()||s.hasAttribute("tabindex")||(s.tabIndex=-1),this.setNodeToVisualActiveFocus(e),s.focus()}passivelyFocusNode(e,t){this.lockFocusStateChanges=!0;const o=e.getFocusableTree();if(o!==t){o.onTreeBlur(t);let s;(s=this.lookUpRegistration(o))!=null&&s.rootShouldBeAutoTabbable&&(o.getRootFocusableNode().getFocusableElement().tabIndex=0)}e.onNodeBlur(),this.lockFocusStateChanges=!1,o!==t&&this.setNodeToVisualPassiveFocus(e)}setNodeToVisualActiveFocus(e){e=e.getFocusableElement(),b(e,de.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),O(e,de.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}setNodeToVisualPassiveFocus(e){e=e.getFocusableElement(),O(e,de.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),b(e,de.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}removeHighlight(e){e=e.getFocusableElement(),O(e,de.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),O(e,de.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME)}static getFocusManager(){return de.focusManager||(de.focusManager=new de(document.addEventListener)),de.focusManager}};de.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyActiveFocus",de.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME="blocklyPassiveFocus",de.focusManager=null,n.getFocusManager$$module$build$src$core$focus_manager;var M$={};M$.deepMerge=Ze;var G=class{constructor(){this.shortcuts=new Map,this.keyMap=new Map,this.reset()}reset(){this.shortcuts.clear(),this.keyMap.clear()}register(e,t){if(this.shortcuts.get(e.name)&&!t)throw Error(`Shortcut named "${e.name}" already exists.`);if(this.shortcuts.set(e.name,e),t=e.keyCodes,t!=null&&t.length)for(const o of t)this.addKeyMapping(o,e.name,!!e.allowCollision)}unregister(e){return this.shortcuts.get(e)?(this.removeAllKeyMappings(e),this.shortcuts.delete(e),!0):(console.warn(`Keyboard shortcut named "${e}" not found.`),!1)}addKeyMapping(e,t,o){e=`${e}`;const s=this.keyMap.get(e);if(s&&!o)throw Error(`Shortcut named "${t}" collides with shortcuts "${s}"`);s&&o?s.unshift(t):this.keyMap.set(e,[t])}removeKeyMapping(e,t,o){const s=this.keyMap.get(e);if(!s)return o||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1;const i=s.indexOf(t);return i>-1?(s.splice(i,1),s.length===0&&this.keyMap.delete(e),!0):(o||console.warn(`No keyboard shortcut named "${t}" registered with key code "${e}"`),!1)}removeAllKeyMappings(e){for(const t of this.keyMap.keys())this.removeKeyMapping(t,e,!0)}setKeyMap(e){this.keyMap.clear();for(const t in e)this.keyMap.set(t,e[t])}getKeyMap(){const e=Object.create(null);for(const[t,o]of this.keyMap)e[t]=o;return e}getRegistry(){const e=Object.create(null);for(const[t,o]of this.shortcuts)e[t]=o;return Ze(Object.create(null),e)}onKeyDown(e,t){var o=this.serializeKeyEvent(t);if(o=this.getShortcutNamesByKeyCode(o),!o)return!1;for(const s of o){o=this.shortcuts.get(s);let i;if(!o||o.preconditionFn&&!o.preconditionFn(e,{focusedNode:(i=n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode())!=null?i:void 0}))continue;let r,l,c;if((l=(r=o).callback)!=null&&l.call(r,e,t,o,{focusedNode:(c=n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode())!=null?c:void 0}))return!0}return!1}getShortcutNamesByKeyCode(e){let t;return((t=this.keyMap.get(e))==null?void 0:t.slice())||[]}getKeyCodesByShortcutName(e){const t=[];for(const[o,s]of this.keyMap)s.indexOf(e)>-1&&t.push(o);return t}serializeKeyEvent(e){let t="";for(const o in G.modifierKeys)e.getModifierState(o)&&(t!==""&&(t+="+"),t+=o);return t!==""&&e.keyCode?t+="+"+e.keyCode:e.keyCode&&(t=String(e.keyCode)),t}checkModifiers(e){for(const t of e)if(!(t in G.modifierKeys))throw Error(t+" is not a valid modifier key.")}createSerializedKey(e,t){let o="";if(t){this.checkModifiers(t);for(const s in G.modifierKeys)t.includes(G.modifierKeys[s])&&(o!==""&&(o+="+"),o+=s)}return o!==""&&e?o+="+"+e:e&&(o=`${e}`),o}};G.registry=new G,(function(e){e=e.modifierKeys||(e.modifierKeys={}),e[e.Shift=16]="Shift",e[e.Control=17]="Control",e[e.Alt=18]="Alt",e[e.Meta=91]="Meta"})(G||(G={}));var ti=Object.create(null),B$,P$,oi=[],F$={defineBlocksWithJsonArrayInternal:Jh},re={TEST_ONLY:F$};re.createBlockDefinitionsFromJsonArray=n.createBlockDefinitionsFromJsonArray$$module$build$src$core$common,re.defineBlocks=n.defineBlocks$$module$build$src$core$common,re.defineBlocksWithJsonArray=Un,re.draggingConnections=oi,re.fireSelectedEvent=Lt,re.getAllWorkspaces=xo,re.getBlockTypeCounts=Ds,re.getMainWorkspace=Me,re.getParentContainer=Rs,re.getSelected=Ss,re.getWorkspaceById=xt,re.globalShortcutHandler=Ns,re.registerWorkspace=Gn,re.setMainWorkspace=Is,re.setParentContainer=Wn,re.setSelected=Kh,re.svgResize=oo,re.unregisterWorkpace=Vn;var es=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=n.getGroup$$module$build$src$core$events$utils(),this.recordUndo=we()}toJson(){return{type:this.type,group:this.group}}static fromJson(e,t,o){return o.isBlank=!1,o.group=e.group||"",o.workspaceId=t.id,o}isNull(){return!1}run(e){}getEventWorkspace_(){let e;if(this.workspaceId&&(e=xt(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},lt=class extends es{constructor(e){super(),this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=typeof e>"u",this.workspaceId=e||""}},uu=class extends lt{constructor(e,t,o){t=e?e.workspace.id:t,t===null&&(t=void 0),super(t),this.type=a.CLICK,this.blockId=e?e.id:void 0,this.targetType=o}toJson(){const e=super.toJson();if(!this.targetType)throw Error("The click target type is undefined. Either pass a block to the constructor, or call fromJson");return e.targetType=this.targetType,e.blockId=this.blockId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new uu),t.targetType=e.targetType,t.blockId=e.blockId,t}},hu;(function(e){e.BLOCK="block",e.WORKSPACE="workspace",e.ZOOM_CONTROLS="zoom_controls"})(hu||(hu={})),I(g.EVENT,a.CLICK,uu);var H$={};H$.removeElem=ke;var wt=class{constructor(e){this.name=e}toString(){return this.name}};wt.POSITIONABLE=new wt("positionable"),wt.DRAG_TARGET=new wt("drag_target"),wt.DELETE_AREA=new wt("delete_area"),wt.AUTOHIDEABLE=new wt("autohideable");var U=class{constructor(){this.componentData=new Map,this.capabilityToComponentIds=new Map}addComponent(e,t){const o=e.component.id;if(!t&&this.componentData.has(o)){var s;throw Error('Plugin "'+o+'" with capabilities "'+((s=this.componentData.get(o))==null?void 0:s.capabilities)+'" already added.')}for(this.componentData.set(o,e),t=[],s=0;s<e.capabilities.length;s++){const i=String(e.capabilities[s]).toLowerCase();if(t.push(i),this.capabilityToComponentIds.has(i)){let r;(r=this.capabilityToComponentIds.get(i))==null||r.push(o)}else this.capabilityToComponentIds.set(i,[o])}this.componentData.get(o).capabilities=t}removeComponent(e){const t=this.componentData.get(e);if(t){for(let o=0;o<t.capabilities.length;o++){const s=String(t.capabilities[o]).toLowerCase();ke(this.capabilityToComponentIds.get(s),e)}this.componentData.delete(e)}}addCapability(e,t){if(!this.getComponent(e))throw Error('Cannot add capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');if(this.hasCapability(e,t))console.warn('Plugin "'+e+'already has capability "'+t+'"');else{t=`${t}`.toLowerCase();var o;(o=this.componentData.get(e))==null||o.capabilities.push(t);var s;(s=this.capabilityToComponentIds.get(t))==null||s.push(e)}}removeCapability(e,t){if(!this.getComponent(e))throw Error('Cannot remove capability, "'+t+'". Plugin "'+e+'" has not been added to the ComponentManager');this.hasCapability(e,t)?(t=`${t}`.toLowerCase(),ke(this.componentData.get(e).capabilities,t),ke(this.capabilityToComponentIds.get(t),e)):console.warn('Plugin "'+e+`doesn't have capability "`+t+'" to remove')}hasCapability(e,t){return t=`${t}`.toLowerCase(),this.componentData.has(e)&&this.componentData.get(e).capabilities.includes(t)}getComponent(e){let t;return(t=this.componentData.get(e))==null?void 0:t.component}getComponents(e,t){if(e=`${e}`.toLowerCase(),e=this.capabilityToComponentIds.get(e),!e)return[];const o=[];if(t){const s=[];e.forEach(i=>{s.push(this.componentData.get(i))}),s.sort(function(i,r){return i.weight-r.weight}),s.forEach(function(i){o.push(i.component)})}else e.forEach(s=>{o.push(this.componentData.get(s).component)});return o}};U.Capability=wt,(function(e){e=e.ComponentWeight||(e.ComponentWeight={}),e[e.TOOLBOX_WEIGHT=0]="TOOLBOX_WEIGHT",e[e.FLYOUT_WEIGHT=1]="FLYOUT_WEIGHT",e[e.TRASHCAN_WEIGHT=2]="TRASHCAN_WEIGHT",e[e.ZOOM_CONTROLS_WEIGHT=3]="ZOOM_CONTROLS_WEIGHT"})(U||(U={})),U.ComponentWeight;var au=!1,du=`
|
|
13
|
+
.blocklySvg {
|
|
14
|
+
background-color: #fff;
|
|
15
|
+
outline: none;
|
|
16
|
+
overflow: hidden; /* IE overflows by default. */
|
|
17
|
+
position: absolute;
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.blocklyWidgetDiv {
|
|
22
|
+
display: none;
|
|
23
|
+
position: absolute;
|
|
24
|
+
z-index: 99999; /* big value for bootstrap3 compatibility */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.injectionDiv {
|
|
28
|
+
height: 100%;
|
|
29
|
+
position: relative;
|
|
30
|
+
overflow: hidden; /* So blocks in drag surface disappear at edges */
|
|
31
|
+
touch-action: none;
|
|
32
|
+
user-select: none;
|
|
33
|
+
-webkit-user-select: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.blocklyBlockCanvas.blocklyCanvasTransitioning,
|
|
37
|
+
.blocklyBubbleCanvas.blocklyCanvasTransitioning {
|
|
38
|
+
transition: transform .5s;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.blocklyEmboss {
|
|
42
|
+
filter: var(--blocklyEmbossFilter);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.blocklyTooltipDiv {
|
|
46
|
+
background-color: #ffffc7;
|
|
47
|
+
border: 1px solid #ddc;
|
|
48
|
+
box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);
|
|
49
|
+
color: #000;
|
|
50
|
+
display: none;
|
|
51
|
+
font: 9pt sans-serif;
|
|
52
|
+
opacity: .9;
|
|
53
|
+
padding: 2px;
|
|
54
|
+
position: absolute;
|
|
55
|
+
z-index: 100000; /* big value for bootstrap3 compatibility */
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.blocklyDropDownDiv {
|
|
59
|
+
position: absolute;
|
|
60
|
+
left: 0;
|
|
61
|
+
top: 0;
|
|
62
|
+
z-index: 1000;
|
|
63
|
+
display: none;
|
|
64
|
+
border: 1px solid;
|
|
65
|
+
border-color: #dadce0;
|
|
66
|
+
background-color: #fff;
|
|
67
|
+
border-radius: 2px;
|
|
68
|
+
padding: 4px;
|
|
69
|
+
box-shadow: 0 0 3px 1px rgba(0,0,0,.3);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.blocklyDropDownDiv:focus {
|
|
73
|
+
box-shadow: 0 0 6px 1px rgba(0,0,0,.3);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.blocklyDropDownContent {
|
|
77
|
+
max-height: 300px; /* @todo: spec for maximum height. */
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.blocklyDropDownArrow {
|
|
81
|
+
position: absolute;
|
|
82
|
+
left: 0;
|
|
83
|
+
top: 0;
|
|
84
|
+
width: 16px;
|
|
85
|
+
height: 16px;
|
|
86
|
+
z-index: -1;
|
|
87
|
+
background-color: inherit;
|
|
88
|
+
border-color: inherit;
|
|
89
|
+
border-top: 1px solid;
|
|
90
|
+
border-left: 1px solid;
|
|
91
|
+
border-top-left-radius: 4px;
|
|
92
|
+
border-color: inherit;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.blocklyHighlighted>.blocklyPath {
|
|
96
|
+
filter: var(--blocklyEmbossFilter);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.blocklyHighlightedConnectionPath {
|
|
100
|
+
fill: none;
|
|
101
|
+
stroke: #fc3;
|
|
102
|
+
stroke-width: 4px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.blocklyPathLight {
|
|
106
|
+
fill: none;
|
|
107
|
+
stroke-linecap: round;
|
|
108
|
+
stroke-width: 1;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.blocklySelected>.blocklyPathLight {
|
|
112
|
+
display: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.blocklyDraggable {
|
|
116
|
+
cursor: grab;
|
|
117
|
+
cursor: -webkit-grab;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.blocklyDragging {
|
|
121
|
+
cursor: grabbing;
|
|
122
|
+
cursor: -webkit-grabbing;
|
|
123
|
+
/* Drag surface disables events to not block the toolbox, so we have to
|
|
124
|
+
* reenable them here for the cursor values to work. */
|
|
125
|
+
pointer-events: auto;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Changes cursor on mouse down. Not effective in Firefox because of
|
|
129
|
+
https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */
|
|
130
|
+
.blocklyDraggable:active {
|
|
131
|
+
cursor: grabbing;
|
|
132
|
+
cursor: -webkit-grabbing;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.blocklyDragging.blocklyDraggingDelete {
|
|
136
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.blocklyDragging>.blocklyPath,
|
|
140
|
+
.blocklyDragging>.blocklyPathLight {
|
|
141
|
+
fill-opacity: .8;
|
|
142
|
+
stroke-opacity: .8;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.blocklyDragging>.blocklyPathDark {
|
|
146
|
+
display: none;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.blocklyDisabledPattern>.blocklyPath {
|
|
150
|
+
fill: var(--blocklyDisabledPattern);
|
|
151
|
+
fill-opacity: .5;
|
|
152
|
+
stroke-opacity: .5;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.blocklyDisabled>.blocklyPathLight,
|
|
156
|
+
.blocklyDisabled>.blocklyPathDark {
|
|
157
|
+
display: none;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.blocklyInsertionMarker>.blocklyPath,
|
|
161
|
+
.blocklyInsertionMarker>.blocklyPathLight,
|
|
162
|
+
.blocklyInsertionMarker>.blocklyPathDark {
|
|
163
|
+
fill-opacity: .2;
|
|
164
|
+
stroke: none;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.blocklyNonEditableField>text {
|
|
168
|
+
pointer-events: none;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.blocklyFlyout {
|
|
172
|
+
position: absolute;
|
|
173
|
+
z-index: 20;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.blocklyText text {
|
|
177
|
+
cursor: default;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/*
|
|
181
|
+
Don't allow users to select text. It gets annoying when trying to
|
|
182
|
+
drag a block and selected text moves instead.
|
|
183
|
+
*/
|
|
184
|
+
.blocklySvg text {
|
|
185
|
+
user-select: none;
|
|
186
|
+
-ms-user-select: none;
|
|
187
|
+
-webkit-user-select: none;
|
|
188
|
+
cursor: inherit;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.blocklyIconGroup {
|
|
192
|
+
cursor: default;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.blocklyIconGroup:not(:hover),
|
|
196
|
+
.blocklyIconGroupReadonly {
|
|
197
|
+
opacity: .6;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.blocklyIconShape {
|
|
201
|
+
fill: #00f;
|
|
202
|
+
stroke: #fff;
|
|
203
|
+
stroke-width: 1px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.blocklyIconSymbol {
|
|
207
|
+
fill: #fff;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.blocklyMinimalBody {
|
|
211
|
+
margin: 0;
|
|
212
|
+
padding: 0;
|
|
213
|
+
height: 100%;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.blocklyHtmlInput {
|
|
217
|
+
border: none;
|
|
218
|
+
border-radius: 4px;
|
|
219
|
+
height: 100%;
|
|
220
|
+
margin: 0;
|
|
221
|
+
outline: none;
|
|
222
|
+
padding: 0;
|
|
223
|
+
width: 100%;
|
|
224
|
+
text-align: center;
|
|
225
|
+
display: block;
|
|
226
|
+
box-sizing: border-box;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* Remove the increase and decrease arrows on the field number editor */
|
|
230
|
+
input.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,
|
|
231
|
+
input.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {
|
|
232
|
+
-webkit-appearance: none;
|
|
233
|
+
margin: 0;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
input[type=number] {
|
|
237
|
+
-moz-appearance: textfield;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.blocklyMainBackground {
|
|
241
|
+
stroke-width: 1;
|
|
242
|
+
stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.blocklyMutatorBackground {
|
|
246
|
+
fill: #fff;
|
|
247
|
+
stroke: #ddd;
|
|
248
|
+
stroke-width: 1;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.blocklyFlyoutBackground {
|
|
252
|
+
fill: #ddd;
|
|
253
|
+
fill-opacity: .8;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.blocklyMainWorkspaceScrollbar {
|
|
257
|
+
z-index: 20;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.blocklyFlyoutScrollbar {
|
|
261
|
+
z-index: 30;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.blocklyScrollbarHorizontal,
|
|
265
|
+
.blocklyScrollbarVertical {
|
|
266
|
+
position: absolute;
|
|
267
|
+
outline: none;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.blocklyScrollbarBackground {
|
|
271
|
+
opacity: 0;
|
|
272
|
+
pointer-events: none;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.blocklyScrollbarHandle {
|
|
276
|
+
fill: #ccc;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,
|
|
280
|
+
.blocklyScrollbarHandle:hover {
|
|
281
|
+
fill: #bbb;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/* Darken flyout scrollbars due to being on a grey background. */
|
|
285
|
+
/* By contrast, workspace scrollbars are on a white background. */
|
|
286
|
+
.blocklyFlyout .blocklyScrollbarHandle {
|
|
287
|
+
fill: #bbb;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,
|
|
291
|
+
.blocklyFlyout .blocklyScrollbarHandle:hover {
|
|
292
|
+
fill: #aaa;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.blocklyInvalidInput {
|
|
296
|
+
background: #faa;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.blocklyVerticalMarker {
|
|
300
|
+
stroke-width: 3px;
|
|
301
|
+
fill: rgba(255,255,255,.5);
|
|
302
|
+
pointer-events: none;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.blocklyComputeCanvas {
|
|
306
|
+
position: absolute;
|
|
307
|
+
width: 0;
|
|
308
|
+
height: 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.blocklyNoPointerEvents {
|
|
312
|
+
pointer-events: none;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.blocklyContextMenu {
|
|
316
|
+
border-radius: 4px;
|
|
317
|
+
max-height: 100%;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.blocklyDropdownMenu {
|
|
321
|
+
border-radius: 2px;
|
|
322
|
+
padding: 0 !important;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.blocklyDropdownMenu .blocklyMenuItem {
|
|
326
|
+
/* 28px on the left for icon or checkbox. */
|
|
327
|
+
padding-left: 28px;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* BiDi override for the resting state. */
|
|
331
|
+
.blocklyDropdownMenu .blocklyMenuItemRtl {
|
|
332
|
+
/* Flip left/right padding for BiDi. */
|
|
333
|
+
padding-left: 5px;
|
|
334
|
+
padding-right: 28px;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.blocklyWidgetDiv .blocklyMenu {
|
|
338
|
+
user-select: none;
|
|
339
|
+
-ms-user-select: none;
|
|
340
|
+
-webkit-user-select: none;
|
|
341
|
+
background: #fff;
|
|
342
|
+
border: 1px solid transparent;
|
|
343
|
+
box-shadow: 0 0 3px 1px rgba(0,0,0,.3);
|
|
344
|
+
font: normal 13px Arial, sans-serif;
|
|
345
|
+
margin: 0;
|
|
346
|
+
outline: none;
|
|
347
|
+
padding: 4px 0;
|
|
348
|
+
position: absolute;
|
|
349
|
+
overflow-y: auto;
|
|
350
|
+
overflow-x: hidden;
|
|
351
|
+
max-height: 100%;
|
|
352
|
+
z-index: 20000; /* Arbitrary, but some apps depend on it... */
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.blocklyWidgetDiv .blocklyMenu:focus {
|
|
356
|
+
box-shadow: 0 0 6px 1px rgba(0,0,0,.3);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.blocklyDropDownDiv .blocklyMenu {
|
|
360
|
+
user-select: none;
|
|
361
|
+
-ms-user-select: none;
|
|
362
|
+
-webkit-user-select: none;
|
|
363
|
+
background: inherit; /* Compatibility with gapi, reset from goog-menu */
|
|
364
|
+
border: inherit; /* Compatibility with gapi, reset from goog-menu */
|
|
365
|
+
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
|
|
366
|
+
outline: none;
|
|
367
|
+
overflow-y: auto;
|
|
368
|
+
overflow-x: hidden;
|
|
369
|
+
max-height: 100%;
|
|
370
|
+
z-index: 20000; /* Arbitrary, but some apps depend on it... */
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/* State: resting. */
|
|
374
|
+
.blocklyMenuItem {
|
|
375
|
+
border: none;
|
|
376
|
+
color: #000;
|
|
377
|
+
cursor: pointer;
|
|
378
|
+
list-style: none;
|
|
379
|
+
margin: 0;
|
|
380
|
+
/* 7em on the right for shortcut. */
|
|
381
|
+
min-width: 7em;
|
|
382
|
+
padding: 6px 15px;
|
|
383
|
+
white-space: nowrap;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/* State: disabled. */
|
|
387
|
+
.blocklyMenuItemDisabled {
|
|
388
|
+
color: #ccc;
|
|
389
|
+
cursor: inherit;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/* State: hover. */
|
|
393
|
+
.blocklyMenuItemHighlight {
|
|
394
|
+
background-color: rgba(0,0,0,.1);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/* State: selected/checked. */
|
|
398
|
+
.blocklyMenuItemCheckbox {
|
|
399
|
+
height: 16px;
|
|
400
|
+
position: absolute;
|
|
401
|
+
width: 16px;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.blocklyMenuItemSelected .blocklyMenuItemCheckbox {
|
|
405
|
+
background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;
|
|
406
|
+
float: left;
|
|
407
|
+
margin-left: -24px;
|
|
408
|
+
position: static; /* Scroll with the menu. */
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.blocklyMenuItemRtl .blocklyMenuItemCheckbox {
|
|
412
|
+
float: right;
|
|
413
|
+
margin-right: -24px;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.blocklyMenuSeparator {
|
|
417
|
+
background-color: #ccc;
|
|
418
|
+
height: 1px;
|
|
419
|
+
border: 0;
|
|
420
|
+
margin-left: 4px;
|
|
421
|
+
margin-right: 4px;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.blocklyBlockDragSurface, .blocklyAnimationLayer {
|
|
425
|
+
position: absolute;
|
|
426
|
+
top: 0;
|
|
427
|
+
left: 0;
|
|
428
|
+
right: 0;
|
|
429
|
+
bottom: 0;
|
|
430
|
+
overflow: visible !important;
|
|
431
|
+
z-index: 80;
|
|
432
|
+
pointer-events: none;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.blocklyField {
|
|
436
|
+
cursor: default;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.blocklyInputField {
|
|
440
|
+
cursor: text;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.blocklyDragging .blocklyField,
|
|
444
|
+
.blocklyDragging .blocklyIconGroup {
|
|
445
|
+
cursor: grabbing;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.blocklyActiveFocus:is(
|
|
449
|
+
.blocklyFlyout,
|
|
450
|
+
.blocklyWorkspace,
|
|
451
|
+
.blocklyField,
|
|
452
|
+
.blocklyPath,
|
|
453
|
+
.blocklyHighlightedConnectionPath,
|
|
454
|
+
.blocklyComment,
|
|
455
|
+
.blocklyBubble,
|
|
456
|
+
.blocklyIconGroup,
|
|
457
|
+
.blocklyTextarea
|
|
458
|
+
) {
|
|
459
|
+
outline: none;
|
|
460
|
+
}
|
|
461
|
+
`,$u={};$u.inject=zn,$u.register=qe;var f=class{constructor(e,t){this.x=e,this.y=t}clone(){return new f(this.x,this.y)}scale(e){return this.x*=e,this.y*=e,this}translate(e,t){return this.x+=e,this.y+=t,this}static equals(e,t){return e===t?!0:e&&t?e.x===t.x&&e.y===t.y:!1}static distance(e,t){const o=e.x-t.x;return e=e.y-t.y,Math.sqrt(o*o+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new f(e.x-t.x,e.y-t.y)}static sum(e,t){return new f(e.x+t.x,e.y+t.y)}},h=class{constructor(e){this.tagName=e}toString(){return this.tagName}};h.ANIMATE=new h("animate"),h.CIRCLE=new h("circle"),h.CLIPPATH=new h("clipPath"),h.DEFS=new h("defs"),h.FECOMPOSITE=new h("feComposite"),h.FECOMPONENTTRANSFER=new h("feComponentTransfer"),h.FEFLOOD=new h("feFlood"),h.FEFUNCA=new h("feFuncA"),h.FEGAUSSIANBLUR=new h("feGaussianBlur"),h.FEPOINTLIGHT=new h("fePointLight"),h.FESPECULARLIGHTING=new h("feSpecularLighting"),h.FILTER=new h("filter"),h.FOREIGNOBJECT=new h("foreignObject"),h.G=new h("g"),h.IMAGE=new h("image"),h.LINE=new h("line"),h.PATH=new h("path"),h.PATTERN=new h("pattern"),h.POLYGON=new h("polygon"),h.RECT=new h("rect"),h.SVG=new h("svg"),h.TEXT=new h("text"),h.TSPAN=new h("tspan");var D=class{constructor(e,t,o,s){this.top=e,this.bottom=t,this.left=o,this.right=s}static from(e){return new D(e.y,e.y+e.height,e.x,e.x+e.width)}clone(){return new D(this.top,this.bottom,this.left,this.right)}getHeight(){return this.bottom-this.top}getWidth(){return this.right-this.left}getOrigin(){return new f(this.left,this.top)}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}intersects(e){return this.left<=e.right&&this.right>=e.left&&this.bottom>=e.top&&this.top<=e.bottom}static equals(e,t){return e===t?!0:e&&t?e.top===t.top&&e.bottom===t.bottom&&e.left===t.left&&e.right===t.right:!1}static createFromPoint(e,t,o){const s=e.x;return e=e.y,new D(e,e+o,s,s+t)}},N=class{constructor(e,t){this.width=e,this.height=t}static equals(e,t){return e===t?!0:e&&t?e.width===t.width&&e.height===t.height:!1}static max(e,t){return new N(Math.max(e.width,t.width),Math.max(e.height,t.height))}static min(e,t){return new N(Math.min(e.width,t.width),Math.min(e.height,t.height))}},G$={getSizeInternal:Zh},Wt={TEST_ONLY:G$};Wt.getBorderBox=Kn,Wt.getComputedStyle=Qe,Wt.getContainerOffsetToScrollInto=Jn,Wt.getPageOffset=Mt,Wt.getSize=As,Wt.getViewportPageOffset=Yn,Wt.scrollIntoContainerView=jn;var V$=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,W$=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Hm={XY_REGEX:V$,XY_STYLE_REGEX:W$},$o={TEST_ONLY:Hm};$o.getDocumentScroll=qn,$o.getInjectionDivXY=Hi,$o.getRelativeXY=Os,$o.getViewportBBox=Zn,$o.screenToWsCoordinates=Qn,$o.wsToScreenCoordinates=Lo;var q=class{constructor(e,t,o,s,i){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new f(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new f(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=o||!1,this.margin=i!==void 0?i:q.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),s&&(e+=" "+s),this.outerSvg=m(h.SVG,{class:e}),s=m(h.G,{},this.outerSvg),this.svgBackground=m(h.RECT,{class:"blocklyScrollbarBackground"},s),e=Math.floor((q.scrollbarThickness-5)/2),this.svgHandle=m(h.RECT,{class:"blocklyScrollbarHandle",rx:e,ry:e},s),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill"),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity"),Qt(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=k(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=k(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const e=q.scrollbarThickness;this.horizontal?(this.svgBackground.setAttribute("height",String(e)),this.outerSvg.setAttribute("height",String(e)),this.svgHandle.setAttribute("height",String(e-5)),this.svgHandle.setAttribute("y","2.5")):(this.svgBackground.setAttribute("width",String(e)),this.outerSvg.setAttribute("width",String(e)),this.svgHandle.setAttribute("width",String(e-5)),this.svgHandle.setAttribute("x","2.5"))}dispose(){this.cleanUp(),x(this.onMouseDownBarWrapper_),x(this.onMouseDownHandleWrapper_),F(this.outerSvg),this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(e){return e=e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength)}setHandleLength(e){this.handleLength=e,this.svgHandle.setAttribute(this.lengthAttribute_,String(this.handleLength))}constrainHandlePosition(e){return e=e<=0||isNaN(e)?0:Math.min(e,this.scrollbarLength-this.handleLength)}setHandlePosition(e){this.handlePosition=e,this.svgHandle.setAttribute(this.positionAttribute_,String(this.handlePosition))}setScrollbarLength(e){this.scrollbarLength=e,this.outerSvg.setAttribute(this.lengthAttribute_,String(this.scrollbarLength)),this.svgBackground.setAttribute(this.lengthAttribute_,String(this.scrollbarLength))}setPosition(e,t){this.position.x=e,this.position.y=t,Bi(this.outerSvg,"translate("+(this.position.x+this.origin.x)+"px,"+(this.position.y+this.origin.y)+"px)")}resize(e){!e&&(e=this.workspace.getMetrics(),!e)||this.oldHostMetrics&&q.metricsAreEquivalent(e,this.oldHostMetrics)||(this.horizontal?this.resizeHorizontal(e):this.resizeVertical(e),this.oldHostMetrics=e,this.updateMetrics())}requiresViewResize(e){return this.oldHostMetrics?this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft||this.oldHostMetrics.absoluteTop!==e.absoluteTop:!0}resizeHorizontal(e){this.requiresViewResize(e)?this.resizeViewHorizontal(e):this.resizeContentHorizontal(e)}resizeViewHorizontal(e){var t=e.viewWidth-this.margin*2;this.pair&&(t-=q.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=q.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-q.scrollbarThickness-this.margin),this.resizeContentHorizontal(e)}resizeContentHorizontal(e){if(e.viewWidth>=e.scrollWidth)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewWidth/e.scrollWidth;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollWidth-e.viewWidth;var o=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*o,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=o/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){let t=e.viewHeight-this.margin*2;this.pair&&(t-=q.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-q.scrollbarThickness-this.margin,e.absoluteTop+this.margin),this.resizeContentVertical(e)}resizeContentVertical(e){if(e.viewHeight>=e.scrollHeight)this.setHandleLength(this.scrollbarLength),this.setHandlePosition(0),this.pair||this.setVisible(!1);else{this.pair||this.setVisible(!0);var t=this.scrollbarLength*e.viewHeight/e.scrollHeight;t=this.constrainHandleLength(t),this.setHandleLength(t),t=e.scrollHeight-e.viewHeight;var o=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*o,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=o/t}}isVisible(){return this.isHandleVisible}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay_()}setVisible(e){if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");this.setVisibleInternal(e)}setVisibleInternal(e){const t=e!==this.isVisible();this.isHandleVisible=e,t&&this.updateDisplay_()}updateDisplay_(){this.containerVisible&&this.isVisible()?this.outerSvg.setAttribute("display","block"):this.outerSvg.setAttribute("display","none")}onMouseDownBar(e){if(this.workspace.markFocused(),Ee(),this.cleanUp(),We(e))e.stopPropagation();else{var t=Do(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var o=Hi(this.svgHandle);o=this.horizontal?o.x:o.y;var s=this.handlePosition,i=this.handleLength*.95;t<=o?s-=i:t>=o+this.handleLength&&(s+=i),this.setHandlePosition(this.constrainHandlePosition(s)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),We(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=k(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=k(document,"pointermove",this,this.onMouseMoveHandle),e.stopPropagation(),e.preventDefault())}onMouseMoveHandle(e){this.setHandlePosition(this.constrainHandlePosition(this.startDragHandle+((this.horizontal?e.clientX:e.clientY)-this.startDragMouse))),this.updateMetrics()}onMouseUpHandle(){Ee(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(x(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(x(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}getRatio_(){let e=this.handlePosition/(this.scrollbarLength-this.handleLength);return isNaN(e)&&(e=0),e}updateMetrics(){const e=this.getRatio_();this.horizontal?this.workspace.setMetrics({x:e}):this.workspace.setMetrics({y:e})}set(e,t){this.setHandlePosition(this.constrainHandlePosition(e*this.ratio)),(t||t===void 0)&&this.updateMetrics()}setOrigin(e,t){this.origin=new f(e,t)}static metricsAreEquivalent(e,t){return e.viewWidth===t.viewWidth&&e.viewHeight===t.viewHeight&&e.viewLeft===t.viewLeft&&e.viewTop===t.viewTop&&e.absoluteTop===t.absoluteTop&&e.absoluteLeft===t.absoluteLeft&&e.scrollWidth===t.scrollWidth&&e.scrollHeight===t.scrollHeight&&e.scrollLeft===t.scrollLeft&&e.scrollTop===t.scrollTop}};q.scrollbarThickness=b$?25:15,q.DEFAULT_SCROLLBAR_MARGIN=.5;var Hr={parseFromString:function(){throw Error("DOMParser was not found in the global scope and was not properly injected using injectDependencies")}},pu={serializeToString:function(){throw Error("XMLSerializer was not foundin the global scope and was not properly injected using injectDependencies")}},{document:Gr,DOMParser:si,XMLSerializer:ii}=globalThis;si&&(Hr=new si),ii&&(pu=new ii);var U$="https://developers.google.com/blockly/xml",Gm=/[\x00-\x09\x0B\x0C\x0E-\x1F]/g,ts={NAME_SPACE:U$};ts.createElement=n.createElement$$module$build$src$core$utils$xml,ts.createTextNode=n.createTextNode$$module$build$src$core$utils$xml,ts.domToText=Mo,ts.injectDependencies=qh,ts.textToDom=n.textToDom$$module$build$src$core$utils$xml;var gu="categoryToolbox",z$="flyoutToolbox",S;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"})(S||(S={}));var X$={hasCategoriesInternal:ta},Ut={};Ut.Position=S,Ut.TEST_ONLY=X$,Ut.convertFlyoutDefToJsonArray=xs,Ut.convertToolboxDefToJson=Gi,Ut.hasCategories=Vi,Ut.isCategoryCollapsible=Wi,Ut.parseToolboxTree=tl;var kt;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM"})(kt||(kt={}));var os;(function(e){e[e.LEFT=0]="LEFT",e[e.RIGHT=1]="RIGHT"})(os||(os={}));var zt;(function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN"})(zt||(zt={}));var po={};po.bumpDirection=zt,po.bumpPositionRect=Yi,po.getCornerOppositeToolbox=Xi,po.getStartPositionRect=zi,po.horizontalPosition=os,po.verticalPosition=kt;var Te={width:96,height:124,url:"sprites.png"},Y$=class{constructor(e){this.workspace=e,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=m(h.G,{});const e=String(Math.random()).substring(2);return this.createZoomOutSvg(e),this.createZoomInSvg(e),this.workspace.isMovable()&&this.createZoomResetSvg(e),this.svgGroup}init(){this.workspace.getComponentManager().addComponent({component:this,weight:U.ComponentWeight.ZOOM_CONTROLS_WEIGHT,capabilities:[U.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&F(this.svgGroup);for(const e of this.boundEvents)x(e);this.boundEvents.length=0}getBoundingRectangle(){let e=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(e+=this.LARGE_SPACING+this.HEIGHT),new D(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var o=Xi(this.workspace,e),s=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(s+=this.LARGE_SPACING+this.HEIGHT),e=zi(o,new N(this.WIDTH,s),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),o=o.vertical,t=Yi(e,this.MARGIN_VERTICAL,o===kt.TOP?zt.DOWN:zt.UP,t),o===kt.TOP){var i=this.SMALL_SPACING+this.HEIGHT,r;(r=this.zoomInGroup)==null||r.setAttribute("transform","translate(0, "+i+")"),this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(i+this.LARGE_SPACING+this.HEIGHT)+")")}else{r=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0;let c;(c=this.zoomInGroup)==null||c.setAttribute("transform","translate(0, "+r+")"),r=r+this.SMALL_SPACING+this.HEIGHT,(i=this.zoomOutGroup)==null||i.setAttribute("transform","translate(0, "+r+")")}this.top=t.top,this.left=t.left;var l;(l=this.svgGroup)==null||l.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(e){this.zoomOutGroup=m(h.G,{class:"blocklyZoom blocklyZoomOut"},this.svgGroup);const t=m(h.CLIPPATH,{id:"blocklyZoomoutClipPath"+e},this.zoomOutGroup);m(h.RECT,{width:32,height:32},t),m(h.IMAGE,{width:Te.width,height:Te.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+e+")"},this.zoomOutGroup).setAttributeNS(Ie,"xlink:href",this.workspace.options.pathToMedia+Te.url),this.boundEvents.push(k(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(e){this.zoomInGroup=m(h.G,{class:"blocklyZoom blocklyZoomIn"},this.svgGroup);const t=m(h.CLIPPATH,{id:"blocklyZoominClipPath"+e},this.zoomInGroup);m(h.RECT,{width:32,height:32},t),m(h.IMAGE,{width:Te.width,height:Te.height,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+e+")"},this.zoomInGroup).setAttributeNS(Ie,"xlink:href",this.workspace.options.pathToMedia+Te.url),this.boundEvents.push(k(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(e,t){this.workspace.markFocused(),this.workspace.zoomCenter(e),this.fireZoomEvent(),Ee(),t.stopPropagation(),t.preventDefault()}createZoomResetSvg(e){this.zoomResetGroup=m(h.G,{class:"blocklyZoom blocklyZoomReset"},this.svgGroup);const t=m(h.CLIPPATH,{id:"blocklyZoomresetClipPath"+e},this.zoomResetGroup);m(h.RECT,{width:32,height:32},t),m(h.IMAGE,{width:Te.width,height:Te.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+e+")"},this.zoomResetGroup).setAttributeNS(Ie,"xlink:href",this.workspace.options.pathToMedia+Te.url),this.boundEvents.push(k(this.zoomResetGroup,"pointerdown",null,this.resetZoom.bind(this)))}resetZoom(e){this.workspace.markFocused();const t=Math.log(this.workspace.options.zoomOptions.startScale/this.workspace.scale)/Math.log(this.workspace.options.zoomOptions.scaleSpeed);this.workspace.beginCanvasTransition(),this.workspace.zoomCenter(t),this.workspace.scrollCenter(),setTimeout(this.workspace.endCanvasTransition.bind(this.workspace),500),this.fireZoomEvent(),Ee(),e.stopPropagation(),e.preventDefault()}fireZoomEvent(){const e=new(w(a.CLICK))(null,this.workspace.id,"zoom_controls");C(e)}};qe(`
|
|
462
|
+
.blocklyZoom>image, .blocklyZoom>svg>image {
|
|
463
|
+
opacity: .4;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {
|
|
467
|
+
opacity: .6;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.blocklyZoom>image:active, .blocklyZoom>svg>image:active {
|
|
471
|
+
opacity: .8;
|
|
472
|
+
}
|
|
473
|
+
`);var K$=100,j$=75,J$=50,Z$=25,Vm={BLOCKS:J$,PROCEDURES:j$,VARIABLES:K$,WORKSPACE_COMMENTS:Z$},mu={};mu.register=Ls,mu.unregister=sa;var q$=class{constructor(){this.priority=Z$}save(e){const t=[];for(const o of e.getTopComments())(e=Bo(o,{addCoordinates:!0,saveIds:!0}))&&t.push(e);return t.length?t:null}load(e,t){for(const o of e)Ms(o,t,{recordUndo:we()})}clear(e){for(const t of e.getTopComments())t.dispose()}};Ls("workspaceComments",new q$);var Vr={};Vr.WorkspaceCommentSerializer=q$,Vr.append=Ms,Vr.save=Bo;var fu={};fu.register=Ki,fu.unregister=ia;var Wr=class{paste(e,t,o){e=e.commentState,o&&(e.x=o.x,e.y=o.y),n.disable$$module$build$src$core$events$utils();let s;try{s=Ms(e,t),ra(s)}finally{n.enable$$module$build$src$core$events$utils()}return s?(z()&&C(new(w(a.COMMENT_CREATE))(s)),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(s),s):null}};Wr.TYPE="workspace-comment",Ki(Wr.TYPE,new Wr);var bu;bu=28,n.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:bu,connectingSnapRadius:bu,currentConnectionPreference:8,bumpDelay:250},n.config$$module$build$src$core$config;var Wm="aria-",Um="role",Se;(function(e){e.GRID="grid",e.GRIDCELL="gridcell",e.GROUP="group",e.LISTBOX="listbox",e.MENU="menu",e.MENUITEM="menuitem",e.MENUITEMCHECKBOX="menuitemcheckbox",e.OPTION="option",e.PRESENTATION="presentation",e.ROW="row",e.TREE="tree",e.TREEITEM="treeitem",e.SEPARATOR="separator",e.STATUS="status"})(Se||(Se={}));var Q;(function(e){e.ACTIVEDESCENDANT="activedescendant",e.COLCOUNT="colcount",e.DISABLED="disabled",e.EXPANDED="expanded",e.INVALID="invalid",e.LABEL="label",e.LABELLEDBY="labelledby",e.LEVEL="level",e.ORIENTATION="orientation",e.POSINSET="posinset",e.ROWCOUNT="rowcount",e.SELECTED="selected",e.SETSIZE="setsize",e.VALUEMAX="valuemax",e.VALUEMIN="valuemin",e.LIVE="live",e.HIDDEN="hidden"})(Q||(Q={}));var ri={};ri.Role=Se,ri.State=Q,ri.setRole=et,ri.setState=oe;var Ur=class{constructor(e,t){this.content=e,this.opt_value=t,this.enabled=!0,this.element=null,this.rightToLeft=!1,this.roleName=null,this.highlight=this.checked=this.checkable=!1,this.actionHandler=null}createDom(){const e=document.createElement("div");e.id=Le(),this.element=e,e.className="blocklyMenuItem "+(this.enabled?"":"blocklyMenuItemDisabled ")+(this.checked?"blocklyMenuItemSelected ":"")+(this.highlight?"blocklyMenuItemHighlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl ":"");const t=document.createElement("div");if(t.className="blocklyMenuItemContent",this.checkable){var o=document.createElement("div");o.className="blocklyMenuItemCheckbox ",t.appendChild(o)}return o=this.content,typeof this.content=="string"&&(o=document.createTextNode(this.content)),t.appendChild(o),e.appendChild(t),this.roleName&&et(e,this.roleName),oe(e,Q.SELECTED,this.checkable&&this.checked||!1),oe(e,Q.DISABLED,!this.enabled),e}dispose(){this.element=null}getElement(){return this.element}getId(){return this.element.id}getValue(){let e;return(e=this.opt_value)!=null?e:null}setRightToLeft(e){this.rightToLeft=e}setRole(e){this.roleName=e}setCheckable(e){this.checkable=e}setChecked(e){this.checked=e}setHighlighted(e){this.highlight=e;const t=this.getElement();t&&this.isEnabled()&&(e?b(t,"blocklyMenuItemHighlight"):O(t,"blocklyMenuItemHighlight"))}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}performAction(e){this.isEnabled()&&this.actionHandler&&this.actionHandler(this,e)}onAction(e,t){this.actionHandler=e.bind(t)}},_u=class{constructor(){this.menuItems=[],this.roleName=this.element=this.onKeyDownHandler=this.pointerLeaveHandler=this.pointerEnterHandler=this.clickHandler=this.pointerMoveHandler=this.highlightedItem=this.openingCoords=null}addChild(e){this.menuItems.push(e)}render(e){const t=document.createElement("div");t.className="blocklyMenu",t.tabIndex=0,this.roleName&&et(t,this.roleName),this.element=t;for(let o=0,s;s=this.menuItems[o];o++)t.appendChild(s.createDom());return this.pointerMoveHandler=k(t,"pointermove",this,this.handlePointerMove,!0),this.clickHandler=k(t,"pointerup",this,this.handleClick,!0),this.pointerEnterHandler=k(t,"pointerenter",this,this.handlePointerEnter,!0),this.pointerLeaveHandler=k(t,"pointerleave",this,this.handlePointerLeave,!0),this.onKeyDownHandler=k(t,"keydown",this,this.handleKeyEvent),e.appendChild(t),t}getElement(){return this.element}focus(){const e=this.getElement();e&&e.focus({preventScroll:!0})}blur(){const e=this.getElement();e&&e.blur()}setRole(e){this.roleName=e}dispose(){this.pointerMoveHandler&&(x(this.pointerMoveHandler),this.pointerMoveHandler=null),this.clickHandler&&(x(this.clickHandler),this.clickHandler=null),this.pointerEnterHandler&&(x(this.pointerEnterHandler),this.pointerEnterHandler=null),this.pointerLeaveHandler&&(x(this.pointerLeaveHandler),this.pointerLeaveHandler=null),this.onKeyDownHandler&&(x(this.onKeyDownHandler),this.onKeyDownHandler=null);for(let e=0,t;t=this.menuItems[e];e++)t.dispose();this.element=null}getMenuItem(e){const t=this.getElement();for(;e&&e!==t;){if(e.classList.contains("blocklyMenuItem")){const o=this.getMenuItems();for(let s=0,i;i=o[s];s++)if(i.getElement()===e)return i}e=e.parentElement}return null}setHighlighted(e){var t=this.highlightedItem;if(t&&(t.setHighlighted(!1),this.highlightedItem=null),e){e.setHighlighted(!0),this.highlightedItem=e,t=this.getElement();const o=e.getElement();t&&o&&(jn(o,t),oe(t,Q.ACTIVEDESCENDANT,e.getId()))}}highlightNext(){const e=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(e,1)}highlightPrevious(){const e=this.highlightedItem?this.menuItems.indexOf(this.highlightedItem):-1;this.highlightHelper(e<0?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;let o;const s=this.getMenuItems();for(;o=s[e];){if(o.isEnabled()){this.setHighlighted(o);break}e+=t}}handlePointerMove(e){Math.max(Math.abs(e.movementX),Math.abs(e.movementY))!==0&&(e=this.getMenuItem(e.target))&&(e.isEnabled()?this.highlightedItem!==e&&this.setHighlighted(e):this.setHighlighted(null))}handleClick(e){var t=this.openingCoords;if(this.openingCoords=null,t&&typeof e.clientX=="number"){const o=new f(e.clientX,e.clientY);if(f.distance(t,o)<1)return}(t=this.getMenuItem(e.target))&&t.performAction(e)}handlePointerEnter(e){this.focus()}handlePointerLeave(e){this.getElement()&&this.setHighlighted(null)}handleKeyEvent(e){if(this.menuItems.length&&!(e.shiftKey||e.ctrlKey||e.metaKey||e.altKey)){var t=this.highlightedItem;switch(e.key){case"Enter":case" ":t&&t.performAction(e);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}e.preventDefault(),e.stopPropagation()}}getSize(){const e=this.getElement(),t=As(e);return t.height=e.scrollHeight,t}getMenuItems(){return this.menuItems.filter(e=>e instanceof Ur)}},Q$=class{constructor(){this.element=null}createDom(){return this.element=document.createElement("hr"),this.element.className="blocklyMenuSeparator",et(this.element,Se.SEPARATOR),this.element}dispose(){let e;(e=this.element)==null||e.remove(),this.element=null}},ni="_TEMP_COLLAPSED_INPUT",zr="_TEMP_COLLAPSED_FIELD",Fe="MANUALLY_DISABLED",zm={COLLAPSED_FIELD_NAME:zr,COLLAPSED_INPUT_NAME:ni,MANUALLY_DISABLED:Fe};(function(e){e[e.VALUE=1]="VALUE",e[e.STATEMENT=3]="STATEMENT",e[e.DUMMY=5]="DUMMY",e[e.CUSTOM=6]="CUSTOM",e[e.END_ROW=7]="END_ROW"})(n.inputTypes$$module$build$src$core$inputs$input_types||(n.inputTypes$$module$build$src$core$inputs$input_types={})),n.inputTypes$$module$build$src$core$inputs$input_types;var Xr=new Set,Eu=new WeakSet,Tu=new WeakMap,ss=null,yu=null,ep=0,Yr={};Yr.finishQueuedRenders=tt,Yr.queueRender=ol,Yr.triggerQueuedRenders=Bt;var vu,tp;n.Msg$$module$build$src$core$msg=Object.create(null),vu=function(e){Object.keys(e).forEach(function(t){n.Msg$$module$build$src$core$msg[t]=e[t]})},tp={Msg:n.Msg$$module$build$src$core$msg,setLocale:vu};var li="blocklyToast",op="blocklyToastMessage",sp="blocklyToastCloseButton",go=class{static show(e,t){if(t.oncePerSession&&t.id){if(this.shownIds.has(t.id))return;this.shownIds.add(t.id)}this.hide(e);const o=this.createDom(e,t);requestAnimationFrame(()=>{o.style.bottom="2rem"})}static createDom(e,t){const{message:o,duration:s=5,assertiveness:i=go.Assertiveness.POLITE}=t,r=document.createElement("div");e.getInjectionDiv().appendChild(r),r.dataset.toastId=t.id,r.className=li,et(r,Se.STATUS),oe(r,Q.LIVE,i),t=r.appendChild(document.createElement("div")),t.className=op,t.innerText=o,t=r.appendChild(document.createElement("button")),t.className=sp,oe(t,Q.LABEL,n.Msg$$module$build$src$core$msg.CLOSE);var l=m(h.SVG,{width:24,height:24,viewBox:"0 0 24 24",fill:"none"},t);oe(l,Q.HIDDEN,!0),m(h.RECT,{x:19.7782,y:2.80762,width:2,height:24,transform:"rotate(45, 19.7782, 2.80762)",fill:"black"},l),m(h.RECT,{x:2.80762,y:4.22183,width:2,height:24,transform:"rotate(-45, 2.80762, 4.22183)",fill:"black"},l),t.addEventListener("click",()=>{r.remove(),e.markFocused()});let c;return t=()=>{c=setTimeout(()=>r.remove(),s*1e3)},l=()=>clearTimeout(c),r.addEventListener("focusin",l),r.addEventListener("focusout",t),r.addEventListener("mouseenter",l),r.addEventListener("mousemove",l),r.addEventListener("mouseleave",t),t(),r}static hide(e,t){e=e.getInjectionDiv().querySelector(`.${li}`),e instanceof HTMLElement&&(!t||t===e.dataset.toastId)&&e.remove()}};go.shownIds=new Set,(function(e){e=e.Assertiveness||(e.Assertiveness={}),e.ASSERTIVE="assertive",e.POLITE="polite"})(go||(go={})),qe(`
|
|
474
|
+
.${li} {
|
|
475
|
+
font-size: 1.2rem;
|
|
476
|
+
position: absolute;
|
|
477
|
+
bottom: -10rem;
|
|
478
|
+
right: 2rem;
|
|
479
|
+
padding: 1rem;
|
|
480
|
+
color: black;
|
|
481
|
+
background-color: white;
|
|
482
|
+
border: 2px solid black;
|
|
483
|
+
border-radius: 0.4rem;
|
|
484
|
+
z-index: 999;
|
|
485
|
+
display: flex;
|
|
486
|
+
align-items: center;
|
|
487
|
+
gap: 0.8rem;
|
|
488
|
+
line-height: 1.5;
|
|
489
|
+
transition: bottom 0.3s ease-out;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.${li} .${op} {
|
|
493
|
+
maxWidth: 18rem;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
.${li} .${sp} {
|
|
497
|
+
margin: 0;
|
|
498
|
+
padding: 0.2rem;
|
|
499
|
+
background-color: transparent;
|
|
500
|
+
color: black;
|
|
501
|
+
border: none;
|
|
502
|
+
cursor: pointer;
|
|
503
|
+
}
|
|
504
|
+
`);var ip=function(e,t){window.alert(e),t&&t()},rp=ip,np=function(e,t){t(window.confirm(e))},lp=np,cp=function(e,t,o){o(window.prompt(e,t))},up=cp,hp=go.show.bind(go),ap=hp,It={};It.alert=Ps,It.confirm=Ji,It.prompt=Zi,It.setAlert=ua,It.setConfirm=ha,It.setPrompt=aa,It.setToast=$a,It.toast=da;var dp=new Set,$p={};$p.warn=le;var Cu="VARIABLE",wu="ijkmnopqrstuvwxyzabcdefgh",pp={generateUniqueNameInternal:ma},ee={CATEGORY_NAME:Cu,TEST_ONLY:pp,VAR_LETTER_OPTIONS:wu};ee.allDeveloperVariables=n.allDeveloperVariables$$module$build$src$core$variables,ee.allUsedVarModels=n.allUsedVarModels$$module$build$src$core$variables,ee.compareByName=Fo,ee.createVariableButtonHandler=so,ee.deleteVariable=n.deleteVariable$$module$build$src$core$variables,ee.flyoutCategory=ll,ee.flyoutCategoryBlocks=cl,ee.generateUniqueName=ul,ee.generateUniqueNameFromOptions=tr,ee.generateVariableFieldDom=io,ee.getAddedVariables=Fs,ee.getOrCreateVariablePackage=n.getOrCreateVariablePackage$$module$build$src$core$variables,ee.getVariable=n.getVariable$$module$build$src$core$variables,ee.getVariableUsesById=Ho,ee.internalFlyoutCategory=qi,ee.jsonFlyoutCategoryBlocks=er,ee.nameUsedWithAnyType=hl,ee.nameUsedWithConflictingParam=al,ee.promptName=or,ee.renameVariable=n.renameVariable$$module$build$src$core$variables;var is=class extends Error{},gp=class extends is{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},ci=class extends is{constructor(e,t,o){super(`The block ${t.toDevString()} is missing a(n) ${e}
|
|
505
|
+
connection`),this.block=t,this.state=o}},mp=class extends is{constructor(e,t,o,s){super(`The block ${o.toDevString()} could not connect its
|
|
506
|
+
${t} to its parent, because: ${e}`),this.childBlock=o,this.childState=s}},fp=class extends is{constructor(e){super(`Encountered a real block which is defined as a child of a shadow
|
|
507
|
+
block. It is an invariant of Blockly that shadow blocks only have shadow
|
|
508
|
+
children`),this.state=e}},bp=class extends is{constructor(e,t,o){super(`Cannot add an icon of type '${e}' to the block ${t.toDevString()}, because there is no icon registered with type '${e}'. Make sure that all of your icons have been registered.`),this.block=t,this.state=o}},mo={};mo.BadConnectionCheck=mp,mo.DeserializationError=is,mo.MissingBlockType=gp,mo.MissingConnection=ci,mo.RealChildOfShadow=fp,mo.UnregisteredIcon=bp;var _p=class{constructor(){this.priority=J$}save(e){const t=[];for(const o of e.getTopBlocks(!1))(e=Be(o,{addCoordinates:!0,doFullSerialization:!1}))&&t.push(e);return t.length?{languageVersion:0,blocks:t}:null}load(e,t){e=e.blocks;for(const o of e)Pt(o,t,{recordUndo:we()})}clear(e){for(const t of e.getTopBlocks(!1))t.dispose(!1)}};Ls("blocks",new _p);var ui={};ui.BlockSerializer=_p,ui.append=Pt,ui.appendInternal=Go,ui.save=Be;var se=class{constructor(e){this.name=e}toString(){return this.name}equals(e){return this.name===e.toString()}};se.MUTATOR=new se("mutator"),se.WARNING=new se("warning"),se.COMMENT=new se("comment");var fo=class extends es{constructor(e){super(),this.isBlank=!e,e&&(this.blockId=e.id,this.workspaceId=e.workspace.id)}toJson(){const e=super.toJson();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.blockId=this.blockId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new fo),t.blockId=e.blockId,t}},bo=class extends fo{constructor(e,t,o,s,i){super(e),this.type=a.BLOCK_CHANGE,e&&(this.element=t,this.name=o||void 0,this.oldValue=s,this.newValue=i)}toJson(){const e=super.toJson();if(!this.element)throw Error("The changed element is undefined. Either pass an element to the constructor, or call fromJson");return e.element=this.element,e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,this.disabledReason&&(e.disabledReason=this.disabledReason),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new bo),t.element=e.element,t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,e.disabledReason!==void 0&&(t.disabledReason=e.disabledReason),t}setDisabledReason(e){if(this.element!=="disabled")throw Error('Cannot set the disabled reason for a BlockChange event if the element is not "disabled".');this.disabledReason=e}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(t=t.getBlockById(this.blockId),!t)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");const o=t.getIcon(se.MUTATOR);switch(o&&ro(o)&&o.bubbleIsVisible()&&o.setBubbleVisible(!1),e=e?this.newValue:this.oldValue,this.element){case"field":(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name);break;case"comment":t.setCommentText(e||null);break;case"collapsed":t.setCollapsed(!!e);break;case"disabled":var s;t.setDisabledReason(!!e,(s=this.disabledReason)!=null?s:Fe);break;case"inline":t.setInputsInline(!!e);break;case"mutation":s=bo.getExtraBlockState_(t),t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(n.textToDom$$module$build$src$core$utils$xml(e||"<mutation/>")),C(new bo(t,"mutation",null,s,e));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(e){return e.saveExtraState?(e=e.saveExtraState(!0))?JSON.stringify(e):"":e.mutationToDom&&(e=e.mutationToDom())?st(e):""}};I(g.EVENT,a.BLOCK_CHANGE,bo);var Kr={};Kr.clamp=Vo,Kr.toDegrees=Pa,Kr.toRadians=sr;var jr=16,Ep=1,Tp=12,ku=16,Jr=.25,Iu=null,_o=null,yp="",vp="",j,hi,Eo,Su=null,Xt=null,Cp=null,Zr=null,qr=null,Ru={getBoundsInfo:function(){const e=Mt(Su),t=As(Su);return{left:e.x,right:e.x+t.width,top:e.y,bottom:e.y+t.height,width:t.width,height:t.height}},getPositionMetrics:function(e,t,o,s){const i=Ru.getBoundsInfo(),r=As(j);return t+r.height<i.bottom?vl(e,t,i,r):s-r.height>i.top?Cl(o,s,i,r):t+r.height<document.documentElement.clientHeight?vl(e,t,i,r):s-r.height>document.documentElement.clientTop?Cl(o,s,i,r):Ha(e,i,r)}},ge={ANIMATION_TIME:Jr,ARROW_HORIZONTAL_PADDING:Tp,ARROW_SIZE:jr,BORDER_SIZE:Ep,PADDING_Y:ku,TEST_ONLY:Ru};ge.clearContent=nr,ge.createDom=ir,ge.getContentDiv=rr,ge.getOwner=ml,ge.getPositionX=Hs,ge.hide=cr,ge.hideIfOwner=lr,ge.hideWithoutAnimation=ot,ge.isVisible=wl,ge.repositionForWindowResize=Il,ge.setBoundsElement=gl,ge.setColour=fl,ge.show=yl,ge.showPositionedByBlock=Fa,ge.showPositionedByField=bl;var rs={};rs.commonWordPrefix=Sl,rs.commonWordSuffix=Rl,rs.isNumber=n.isNumber$$module$build$src$core$utils$string,rs.shortestStringLength=Gs,rs.wrap=n.wrap$$module$build$src$core$utils$string;var Qr=void 0,ai=!1,ns=!1,wp=50,kp=0,To=0,Du=0,Nu=0,He=null,di=null,Au=0,Ou=10,Ip=10,Sp=750,en=5,ie=null,Re={HOVER_MS:Sp,LIMIT:wp,MARGINS:en,OFFSET_X:Au,OFFSET_Y:Ou,RADIUS_OK:Ip};Re.bindMouseEvents=Vs,Re.block=Ml,Re.createDom=Al,Re.dispose=Ll,Re.getCustomTooltip=Ua,Re.getDiv=Xa,Re.getTooltipOfObject=Wo,Re.hide=Et,Re.isVisible=za,Re.setCustomTooltip=Wa,Re.unbindMouseEvents=Ol,Re.unblock=Bl;var xu=.45,Lu=.65,Rp={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"},Ge={};Ge.blend=lo,Ge.getHsvSaturation=Pl,Ge.getHsvValue=Fl,Ge.hexToRgb=hr,Ge.hsvToHex=ar,Ge.hueToHex=Hl,Ge.names=Rp,Ge.parse=no,Ge.rgbToHex=Ws,Ge.setHsvSaturation=Qa,Ge.setHsvValue=ed;var $i={};$i.checkMessageReferences=td,$i.parseBlockColour=Uo,$i.replaceMessageReferences=J,$i.tokenizeInterpolation=Gl;var L=class{get size_(){return this.size}set size_(e){this.size=e}constructor(e,t,o){this.DEFAULT_VALUE=null,this.name=void 0,this.tooltip=this.validator_=null,this.size=new N(0,0),this.constants_=this.mouseDownWrapper=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.id_=null,this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new N(0,0),e!==L.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(J(e.tooltip))}setSourceBlock(e){if(this.sourceBlock_)throw Error("Field already bound to a block");if(this.sourceBlock_=e,e.id.includes("_field"))throw Error(`Field ID indicator is contained in block ID. This may cause problems with focus: ${e.id}.`);this.id_=`${e.id}_field_${Le()}`}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(){if(!this.fieldGroup_){var e=this.id_;if(!e)throw Error("Expected ID to be defined prior to init.");this.fieldGroup_=m(h.G,{id:e}),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(),this.applyColour()}}initView(){this.createBorderRect_(),this.createTextElement_(),this.fieldGroup_&&b(this.fieldGroup_,"blocklyField")}initModel(){}isFullBlockField(){return!this.borderRect_}createBorderRect_(){this.borderRect_=m(h.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_=m(h.TEXT,{class:"blocklyText blocklyFieldText"},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 e=this.getClickTarget_();if(!e)throw Error("A click target has not been set.");Vs(e),this.mouseDownWrapper=k(e,"pointerdown",this,this.onMouseDown_)}fromXml(e){this.setValue(e.textContent)}toXml(e){return e.textContent=this.getValue(),e}saveState(e){return e=this.saveLegacyState(L),e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(L,e)||this.setValue(e)}saveLegacyState(e){return e.prototype.saveState===this.saveState&&e.prototype.toXml!==this.toXml?(e=n.createElement$$module$build$src$core$utils$xml("field"),e.setAttribute("name",this.name||""),Mo(this.toXml(e)).replace(' xmlns="https://developers.google.com/blockly/xml"',"")):null}loadLegacyState(e,t){return e.prototype.loadState===this.loadState&&e.prototype.fromXml!==this.fromXml?(this.fromXml(n.textToDom$$module$build$src$core$utils$xml(t)),!0):!1}dispose(){lr(this),co(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||F(this.fieldGroup_),this.disposed=!0}updateEditable(){const e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(b(e,"blocklyEditableField"),O(e,"blocklyNonEditableField")):(b(e,"blocklyNonEditableField"),O(e,"blocklyEditableField")))}setEnabled(e){this.enabled_=e,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==L.prototype.showEditor_}isClickableInFlyout(e){return!e}isCurrentlyEditable(){return this.enabled_&&this.EDITABLE&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()}isSerializable(){let e=!1;return this.name&&(this.SERIALIZABLE?e=!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."),e=!0)),e}isVisible(){return this.visible_}setVisible(e){if(this.visible_!==e){this.visible_=e;var t=this.fieldGroup_;t&&(t.style.display=e?"block":"none")}}setValidator(e){this.validator_=e}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(e){this.isClickable()&&this.showEditor_(e)}showEditor_(e){}repositionForWindowResize(){return!1}updateSize_(e){const t=this.getConstants();e=e!==void 0?e:this.isFullBlockField()?0:this.getConstants().FIELD_BORDER_RECT_X_PADDING;let o=e*2,s=t.FIELD_TEXT_HEIGHT,i=0;this.textElement_&&(i=Ao(this.textElement_),o+=i),this.isFullBlockField()||(s=Math.max(s,t.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=s,this.size_.width=o,this.positionTextElement_(e,i),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var o=this.getConstants(),s=this.size_.height/2,i;this.textElement_.setAttribute("x",String((i=this.getSourceBlock())!=null&&i.RTL?this.size_.width-t-e:e)),this.textElement_.setAttribute("y",String(o.FIELD_TEXT_BASELINE_CENTER?s:s-o.FIELD_TEXT_HEIGHT/2+o.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.size_):new N(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new te;if(this.isFullBlockField()){var o=this.sourceBlock_.getHeightWidth();const s=t.workspace.scale;e=this.getAbsoluteXY_(),t=(o.width+1)*s,o=(o.height+1)*s,k$?(e.x+=1.5*s,e.y+=1.5*s):(e.x-=.5*s,e.y-=.5*s)}else o=this.borderRect_.getBoundingClientRect(),e=Mt(this.borderRect_),t=o.width,o=o.height;return new D(e.y,e.y+o,e.x,e.x+t)}onLocationChange(e){}getDisplayText_(){let e=this.getText();return e.length>this.maxDisplayLength&&(e=e.substring(0,this.maxDisplayLength-2)+"…"),e=e.replace(/\s/g,L.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+=""),e}getText(){const e=this.getText_();return String(e!==null?e:this.getValue())}getText_(){return null}markDirty(){this.isDirty_=!0,this.constants_=null}forceRerender(){this.isDirty_=!0,this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_.queueRender()}setValue(e,t=!0){if(e!==null){var o=n.getGroup$$module$build$src$core$events$utils();o||n.setGroup$$module$build$src$core$events$utils(!0);try{const p=this.doClassValidation_(e),T=this.processValidation(e,p,t);if(!(T instanceof Error)){var s,i=(s=this.getValidator())==null?void 0:s.call(this,T),r=this.processValidation(T,i,t);if(!(r instanceof Error)){var l=this.sourceBlock_;if(!l||!l.disposed){var c=this.getValue();c===r?this.doValueUpdate_(r):(this.doValueUpdate_(r),t&&l&&z()&&C(new(w(a.BLOCK_CHANGE))(l,"field",this.name||null,c,r)),this.isDirty_&&this.forceRerender())}}}}finally{n.setGroup$$module$build$src$core$events$utils(o)}}}processValidation(e,t,o){return t===null?(this.doValueInvalid_(e,o),this.isDirty_&&this.forceRerender(),Error()):t===void 0?e:t}getValue(){return this.value_}doClassValidation_(e){return e??null}doValueUpdate_(e){this.value_=e,this.isDirty_=!0}doValueInvalid_(e,t){}onMouseDown_(e){this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&(e=this.sourceBlock_.workspace.getGesture(e))&&e.setStartField(this)}setTooltip(e){e||e===""||(e=this.sourceBlock_);const t=this.getClickTarget_();t?t.tooltip=e:this.tooltip=e}getTooltip(){const e=this.getClickTarget_();return Wo(e||{tooltip:this.tooltip})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Mt(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null;const t=this.getSourceBlock();if(!t)throw new te;const o=t.inputList;for(let s=0;s<t.inputList.length;s++){const i=o[s],r=i.fieldRow;for(let l=0;l<r.length;l++)if(r[l]===this){e=i;break}}return e}getFlipRtl(){return!1}onShortcut(e){return!1}getFocusableElement(){if(!this.fieldGroup_)throw Error("This field currently has no representative DOM element.");return this.fieldGroup_}getFocusableTree(){const e=this.getSourceBlock();if(!e)throw new te;return e.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}static fromJson(e){throw Error("Attempted to instantiate a field from the registry that hasn't defined a 'fromJson' method.")}};L.NBSP=" ",L.SKIP_SETUP=Symbol("SKIP_SETUP");var te=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}},ls=null,Dp=null,tn=null,Mu="blocklyWidgetDiv",cs="",us="",De,on=null,Xe={};Xe.createDom=Vl,Xe.getDiv=zo,Xe.hide=Xo,Xe.hideIfOwner=co,Xe.hideIfOwnerIsInWorkspace=Us,Xe.isVisible=Wl,Xe.positionWithAnchor=zl,Xe.repositionForWindowResize=Xl,Xe.show=$r,Xe.testOnly_setDiv=od;var sn=null,Np={},rn=null,yo={};yo.callbackFactory=n.callbackFactory$$module$build$src$core$contextmenu,yo.dispose=Kl,yo.getCurrentBlock=nd,yo.hide=zs,yo.setCurrentBlock=Yl,yo.show=Yo;var R=class{constructor(){this.registeredItems=new Map,this.reset()}reset(){this.registeredItems.clear()}register(e){if(this.registeredItems.has(e.id))throw Error('Menu item with ID "'+e.id+'" is already registered.');this.registeredItems.set(e.id,e)}unregister(e){if(!this.registeredItems.has(e))throw Error('Menu item with ID "'+e+'" not found.');this.registeredItems.delete(e)}getItem(e){let t;return(t=this.registeredItems.get(e))!=null?t:null}getContextMenuOptions(e,t){const o=[];for(const s of this.registeredItems.values()){if(s.scopeType&&(s.scopeType===Bu.BLOCK&&!e.block||s.scopeType===Bu.COMMENT&&!e.comment||s.scopeType===Bu.WORKSPACE&&!e.workspace))continue;let i;if(i={scope:e,weight:s.weight},s.separator)i=Object.assign({},i,{separator:!0});else{const r=s.preconditionFn(e,t);if(r==="hidden")continue;const l=typeof s.displayText=="function"?s.displayText(e):s.displayText;i=Object.assign({},i,{text:l,callback:s.callback,enabled:r==="enabled"})}o.push(i)}return o.sort(function(s,i){return s.weight-i.weight}),o}};(function(e){var t=e.ScopeType||(e.ScopeType={});t.BLOCK="block",t.WORKSPACE="workspace",t.COMMENT="comment",e.registry=new e})(R||(R={}));var Bu=R.ScopeType,Yt=50,nn=100,Xm={BLOCK:Yt,BUBBLE:nn},Ap=class{constructor(e){this.comment=e,this.startLoc=null,this.workspace=e.workspace}isMovable(){return this.comment.isOwnMovable()&&!this.comment.isDeadOrDying()&&!this.workspace.isReadOnly()}startDrag(){this.fireDragStartEvent(),this.startLoc=this.comment.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1);let e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(this.comment),this.comment.setDragging(!0)}drag(e){this.comment.moveDuringDrag(e)}endDrag(){this.fireDragEndEvent(),this.fireMoveEvent();let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.comment,Yt),this.comment.setDragging(!1),this.comment.snapToGrid(),this.workspace.setResizesEnabled(!0)}fireDragStartEvent(){const e=new(w(a.COMMENT_DRAG))(this.comment,!0);C(e)}fireDragEndEvent(){const e=new(w(a.COMMENT_DRAG))(this.comment,!1);C(e)}fireMoveEvent(){if(!this.comment.isDeadOrDying()){var e=new(w(a.COMMENT_MOVE))(this.comment);e.setReason(["drag"]),e.oldCoordinate_=this.startLoc,e.recordNew(),C(e)}}revertDrag(){this.startLoc&&this.comment.moveDuringDrag(this.startLoc)}},Op=new WeakMap,ln=class{constructor(e,t,o){this.id=e,this.workspace=t,this.container=o}isVisible(){return this.icon.checkVisibility()}getParentComment(){const e=this.workspace.getCommentById(this.id);if(!e)throw Error(`Comment bar button ${this.id} has no corresponding comment`);return e}getSize(e=!1){var t=this.icon.getBBox();return t=D.from(t),e&&(e=this.getMargin(),t.left-=e,t.top-=e,t.bottom+=e,t.right+=e),t}getMargin(){return(this.container.getBBox().height-this.icon.getBBox().height)/2}getFocusableElement(){return this.icon}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return this.isVisible()}},xp="_collapse_bar_button",Lp=class extends ln{constructor(e,t,o){super(e,t,o),this.id=e,this.workspace=t,this.container=o,this.icon=m(h.IMAGE,{class:"blocklyFoldoutIcon",href:`${this.workspace.options.pathToMedia}foldout-icon.svg`,id:`${this.id}${xp}`},this.container),this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){x(this.bindId)}reposition(){const e=this.getMargin();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${e}`)}performAction(e){Ee();const t=this.getParentComment();t.view.bringToFront(),e&&e instanceof PointerEvent&&We(e)?e.stopPropagation():(t.setCollapsed(!t.isCollapsed()),this.workspace.hideChaff(),e?.stopPropagation())}},Pu="_comment_textarea_",Mp=class{constructor(e,t,o){this.workspace=e,this.onFinishEditing=o,this.textChangeListeners=[],this.text="",this.foreignObject=m(h.FOREIGNOBJECT,{class:"blocklyCommentForeignObject"}),e=document.createElementNS(nt,"body"),e.setAttribute("xmlns",nt),e.className="blocklyMinimalBody",this.textArea=document.createElementNS(nt,"textarea"),this.textArea.setAttribute("tabindex","-1"),b(this.textArea,"blocklyCommentText"),b(this.textArea,"blocklyTextarea"),b(this.textArea,"blocklyText"),e.appendChild(this.textArea),this.foreignObject.appendChild(e),t&&(this.id=t+Pu,this.textArea.setAttribute("id",this.id)),k(this.textArea,"change",this,this.onTextChange),k(this.textArea,"pointerdown",this,s=>{s.stopPropagation(),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this),Ee()}),k(this.textArea,"keydown",this,this.handleKeyDown)}getDom(){return this.foreignObject}getText(){return this.text}setText(e){this.textArea.value=e,this.onTextChange()}onTextChange(){const e=this.text;this.text=this.textArea.value;for(let t=this.textChangeListeners.length-1;t>=0;t--)this.textChangeListeners[t](e,this.text)}handleKeyDown(e){(e.key==="Escape"||e.key==="Enter"&&(e.ctrlKey||e.metaKey))&&(this.onFinishEditing&&this.onFinishEditing(),e.stopPropagation())}addTextChangeListener(e){this.textChangeListeners.push(e)}removeTextChangeListener(e){this.textChangeListeners.splice(this.textChangeListeners.indexOf(e),1)}setPlaceholderText(e){this.textArea.placeholder=e}setEditable(e){e?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","true")}updateSize(e,t){this.foreignObject.setAttribute("height",`${e.height-t.height}`),this.foreignObject.setAttribute("width",`${e.width}`),this.foreignObject.setAttribute("y",`${t.height}`),this.workspace.RTL&&this.foreignObject.setAttribute("x",`${-e.width}`)}getFocusableElement(){return this.textArea}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!!this.id}},Bp="_delete_bar_button",Pp=class extends ln{constructor(e,t,o){super(e,t,o),this.id=e,this.workspace=t,this.container=o,this.icon=m(h.IMAGE,{class:"blocklyDeleteIcon",href:`${this.workspace.options.pathToMedia}delete-icon.svg`,id:`${this.id}${Bp}`},o),this.bindId=k(this.icon,"pointerdown",this,this.performAction.bind(this))}dispose(){x(this.bindId)}reposition(){const e=this.getMargin();this.icon.setAttribute("x","0");const t=this.container.getBBox();this.icon.setAttribute("y",`${e}`),this.icon.setAttribute("x",`${t.width-this.getSize(!0).getWidth()}`)}performAction(e){Ee(),e&&e instanceof PointerEvent&&We(e)?e.stopPropagation():(this.getParentComment().dispose(),e?.stopPropagation(),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.workspace))}},pi=class{constructor(e,t){this.workspace=e,this.commentId=t,this.collapsed=!1,this.editable=!0,this.location=new f(0,0),this.sizeChangeListeners=[],this.disposeListeners=[],this.collapseChangeListeners=[],this.resizePointerMoveListener=this.resizePointerUpListener=null,this.disposed=this.disposing=!1,this.svgRoot=m(h.G,{class:"blocklyComment blocklyEditable blocklyDraggable"}),this.highlightRect=this.createHighlightRect(this.svgRoot),{topBarGroup:this.topBarGroup,topBarBackground:this.topBarBackground,deleteButton:this.deleteButton,foldoutButton:this.foldoutButton,textPreview:this.textPreview,textPreviewNode:this.textPreviewNode}=this.createTopBar(this.svgRoot),this.commentEditor=this.createTextArea(),this.resizeHandle=this.createResizeHandle(this.svgRoot,e);let o;(o=e.getLayerManager())==null||o.append(this,Yt),this.size=pi.defaultCommentSize,this.setSizeWithoutFiringEvents(this.size),this.moveTo(new f(0,0))}createHighlightRect(e){return m(h.RECT,{class:"blocklyCommentHighlight"},e)}createTopBar(e){e=m(h.G,{class:"blocklyCommentTopbar"},e);const t=m(h.RECT,{class:"blocklyCommentTopbarBackground"},e),o=new Pp(this.commentId,this.workspace,e),s=new Lp(this.commentId,this.workspace,e),i=m(h.TEXT,{class:"blocklyCommentPreview blocklyCommentText blocklyText"},e),r=document.createTextNode("");return i.appendChild(r),{topBarGroup:e,topBarBackground:t,deleteButton:o,foldoutButton:s,textPreview:i,textPreviewNode:r}}createTextArea(){const e=new Mp(this.workspace,this.commentId,()=>this.svgRoot.focus());return this.svgRoot.appendChild(e.getDom()),e.addTextChangeListener((t,o)=>{this.updateTextPreview(o),this.setSize(this.size)}),e}getEditorFocusableNode(){return this.commentEditor}createResizeHandle(e,t){return e=m(h.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),k(e,"pointerdown",this,this.onResizePointerDown),e}getSvgRoot(){return this.svgRoot}getSize(){return this.collapsed?this.topBarBackground.getBBox():this.size}setSizeWithoutFiringEvents(e){const t=this.topBarBackground.getBBox(),o=this.textPreview.getBBox(),s=this.resizeHandle.getBBox();this.size=e=N.max(e,this.calcMinSize(t)),this.svgRoot.setAttribute("height",`${e.height}`),this.svgRoot.setAttribute("width",`${e.width}`),this.updateHighlightRect(e),this.updateTopBarSize(e),this.commentEditor.updateSize(e,t),this.deleteButton.reposition(),this.foldoutButton.reposition(),this.updateTextPreviewSize(e,t,o),this.updateResizeHandlePosition(e,s)}setSize(e){const t=this.preResizeSize||this.size;this.setSizeWithoutFiringEvents(e),this.onSizeChange(t,this.size)}calcMinSize(e){var t;this.updateTextPreview((t=this.commentEditor.getText())!=null?t:"");let o=t=Ao(this.textPreview);return this.foldoutButton.isVisible()?o+=this.foldoutButton.getSize(!0).getWidth():t&&(o+=4),this.deleteButton.isVisible()?o+=this.deleteButton.getSize(!0).getWidth():t&&(o+=4),new N(o,e.height+20)}updateHighlightRect(e){this.highlightRect.setAttribute("height",`${e.height}`),this.highlightRect.setAttribute("width",`${e.width}`),this.workspace.RTL&&this.highlightRect.setAttribute("x",`${-e.width}`)}updateTopBarSize(e){this.topBarBackground.setAttribute("width",`${e.width}`)}updateTextPreviewSize(e,t,o){t=(t.height-o.height)/2;const s=this.foldoutButton.getSize(!0),i=this.deleteButton.getSize(!0);e=e.width-s.getWidth()-i.getWidth(),this.textPreview.setAttribute("x",`${s.getWidth()}`),this.textPreview.setAttribute("y",`${t+o.height/2}`),this.textPreview.setAttribute("width",`${e}`)}updateResizeHandlePosition(e,t){this.resizeHandle.setAttribute("y",`${e.height-t.height}`),this.resizeHandle.setAttribute("x",`${e.width-t.width}`)}onSizeChange(e,t){for(let o=this.sizeChangeListeners.length-1;o>=0;o--)this.sizeChangeListeners[o](e,t)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}removeSizeChangeListener(e){this.sizeChangeListeners.splice(this.sizeChangeListeners.indexOf(e),1)}onResizePointerDown(e){this.isEditable()&&(this.bringToFront(),We(e)||(this.preResizeSize=this.getSize(),pr(this.workspace,e,new f(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=k(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=k(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation())}onResizePointerUp(e){Ee(),this.resizePointerUpListener&&(x(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(x(this.resizePointerMoveListener),this.resizePointerMoveListener=null),this.setSize(this.size),this.preResizeSize=void 0}onResizePointerMove(e){e=gr(this.workspace,e),this.setSizeWithoutFiringEvents(new N(this.workspace.RTL?-e.x:e.x,e.y))}isCollapsed(){return this.collapsed}setCollapsed(e){(this.collapsed=e)?b(this.svgRoot,"blocklyCollapsed"):O(this.svgRoot,"blocklyCollapsed"),this.setSizeWithoutFiringEvents(this.size),this.onCollapse()}onCollapse(){for(let e=this.collapseChangeListeners.length-1;e>=0;e--)this.collapseChangeListeners[e](this.collapsed)}addOnCollapseListener(e){this.collapseChangeListeners.push(e)}removeOnCollapseListener(e){this.collapseChangeListeners.splice(this.collapseChangeListeners.indexOf(e),1)}isEditable(){return this.editable}setEditable(e){(this.editable=e)?(b(this.svgRoot,"blocklyEditable"),O(this.svgRoot,"blocklyReadonly")):(O(this.svgRoot,"blocklyEditable"),b(this.svgRoot,"blocklyReadonly")),this.commentEditor.setEditable(e)}getRelativeToSurfaceXY(){return this.location}moveTo(e){this.location=e,this.svgRoot.setAttribute("transform",`translate(${e.x}, ${e.y})`)}getText(){return this.commentEditor.getText()}setText(e){this.commentEditor.setText(e)}setPlaceholderText(e){this.commentEditor.setPlaceholderText(e)}addTextChangeListener(e){this.commentEditor.addTextChangeListener(e)}removeTextChangeListener(e){this.commentEditor.removeTextChangeListener(e)}updateTextPreview(e){this.textPreviewNode.textContent=this.truncateText(e)}truncateText(e){return e.length>=12?`${e.substring(0,9)}...`:e}bringToFront(){const e=this.svgRoot.parentNode,t=e.childNodes;t[t.length-1]!==this.svgRoot&&e.appendChild(this.svgRoot)}onDeleteDown(e){Ee(),We(e)||this.dispose(),e.stopPropagation()}dispose(){this.disposing=!0,this.foldoutButton.dispose(),this.deleteButton.dispose(),F(this.svgRoot);for(let e=this.disposeListeners.length-1;e>=0;e--)this.disposeListeners[e]();this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}addDisposeListener(e){this.disposeListeners.push(e)}removeDisposeListener(e){this.disposeListeners.splice(this.disposeListeners.indexOf(e),1)}getCommentBarButtons(){return[this.foldoutButton,this.deleteButton]}};pi.defaultCommentSize=new N(120,100),qe(`
|
|
509
|
+
.injectionDiv {
|
|
510
|
+
--commentFillColour: #FFFCC7;
|
|
511
|
+
--commentBorderColour: #F2E49B;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.blocklyComment .blocklyTextarea {
|
|
515
|
+
background-color: var(--commentFillColour);
|
|
516
|
+
border: 1px solid var(--commentBorderColour);
|
|
517
|
+
box-sizing: border-box;
|
|
518
|
+
display: block;
|
|
519
|
+
outline: 0;
|
|
520
|
+
padding: 5px;
|
|
521
|
+
resize: none;
|
|
522
|
+
width: 100%;
|
|
523
|
+
height: 100%;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.blocklyReadonly.blocklyComment .blocklyTextarea {
|
|
527
|
+
cursor: inherit;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.blocklyDeleteIcon {
|
|
531
|
+
width: 20px;
|
|
532
|
+
height: 20px;
|
|
533
|
+
display: none;
|
|
534
|
+
cursor: pointer;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.blocklyFoldoutIcon {
|
|
538
|
+
width: 20px;
|
|
539
|
+
height: 20px;
|
|
540
|
+
transform-origin: 12px 12px;
|
|
541
|
+
cursor: pointer;
|
|
542
|
+
}
|
|
543
|
+
.blocklyResizeHandle {
|
|
544
|
+
width: 12px;
|
|
545
|
+
height: 12px;
|
|
546
|
+
cursor: se-resize;
|
|
547
|
+
}
|
|
548
|
+
.blocklyReadonly.blocklyComment .blocklyResizeHandle {
|
|
549
|
+
cursor: inherit;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.blocklyCommentTopbarBackground {
|
|
553
|
+
fill: var(--commentBorderColour);
|
|
554
|
+
height: 24px;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.blocklyComment .blocklyCommentPreview.blocklyText {
|
|
558
|
+
fill: #000;
|
|
559
|
+
dominant-baseline: middle;
|
|
560
|
+
visibility: hidden;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.blocklyCollapsed.blocklyComment .blocklyCommentPreview {
|
|
564
|
+
visibility: visible;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.blocklyCollapsed.blocklyComment .blocklyCommentForeignObject,
|
|
568
|
+
.blocklyCollapsed.blocklyComment .blocklyResizeHandle {
|
|
569
|
+
display: none;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.blocklyCollapsed.blocklyComment .blocklyFoldoutIcon {
|
|
573
|
+
transform: rotate(-90deg);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.blocklyRTL .blocklyCommentTopbar {
|
|
577
|
+
transform: scale(-1, 1);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.blocklyRTL .blocklyCommentForeignObject {
|
|
581
|
+
direction: rtl;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.blocklyRTL .blocklyCommentPreview {
|
|
585
|
+
/* Revert the scale and control RTL using direction instead. */
|
|
586
|
+
transform: scale(-1, 1);
|
|
587
|
+
direction: rtl;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.blocklyRTL .blocklyResizeHandle {
|
|
591
|
+
transform: scale(-1, 1);
|
|
592
|
+
cursor: sw-resize;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
.blocklyCommentHighlight {
|
|
596
|
+
fill: none;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.blocklyCommentText.blocklyActiveFocus {
|
|
600
|
+
border-color: #fc3;
|
|
601
|
+
border-width: 2px;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
.blocklySelected .blocklyCommentHighlight {
|
|
605
|
+
stroke: #fc3;
|
|
606
|
+
stroke-width: 3px;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
.blocklyCollapsed.blocklySelected .blocklyCommentHighlight {
|
|
610
|
+
stroke: none;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.blocklyCollapsed.blocklySelected .blocklyCommentTopbarBackground {
|
|
614
|
+
stroke: #fc3;
|
|
615
|
+
stroke-width: 3px;
|
|
616
|
+
}
|
|
617
|
+
`);var cn=class{constructor(e,t){this.workspace=e,this.text="",this.collapsed=!1,this.deletable=this.movable=this.editable=!0,this.location=new f(0,0),this.disposing=this.disposed=!1,this.id=t&&!e.getCommentById(t)?t:_t(),this.size=pi.defaultCommentSize,e.addTopComment(this),this.fireCreateEvent()}fireCreateEvent(){z()&&C(new(w(a.COMMENT_CREATE))(this))}fireDeleteEvent(){z()&&C(new(w(a.COMMENT_DELETE))(this))}fireChangeEvent(e,t){z()&&C(new(w(a.COMMENT_CHANGE))(this,e,t))}fireCollapseEvent(e){z()&&C(new(w(a.COMMENT_COLLAPSE))(this,e))}setText(e){const t=this.text;this.text=e,this.fireChangeEvent(t,e)}getText(){return this.text}setSize(e){const t=new(w(a.COMMENT_RESIZE))(this);this.size=e,t.recordCurrentSizeAsNewSize(),C(t)}getSize(){return this.size}setCollapsed(e){this.collapsed=e,this.fireCollapseEvent(e)}isCollapsed(){return this.collapsed}setEditable(e){this.editable=e}isEditable(){return this.isOwnEditable()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setMovable(e){this.movable=e}isMovable(){return this.isOwnMovable()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnMovable(){return this.movable}setDeletable(e){this.deletable=e}isDeletable(){return this.isOwnDeletable()&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.workspace.isFlyout}isOwnDeletable(){return this.deletable}moveTo(e,t){const o=new(w(a.COMMENT_MOVE))(this);t&&o.setReason(t),this.location=e,o.recordNew(),C(o)}getRelativeToSurfaceXY(){return this.location}dispose(){this.disposing=!0,this.fireDeleteEvent(),this.workspace.removeTopComment(this),this.disposed=!0}isDisposed(){return this.disposed}isDeadOrDying(){return this.disposing||this.disposed}},ct=class extends cn{constructor(e,t){super(e,t),this.dragStrategy=new Ap(this),this.workspace=e,this.view=new pi(e,this.id),this.view.setSize(this.getSize()),this.view.setEditable(this.isEditable()),this.view.getSvgRoot().setAttribute("data-id",this.id),this.view.getSvgRoot().setAttribute("id",this.id),this.addModelUpdateBindings(),k(this.view.getSvgRoot(),"pointerdown",this,this.startGesture),k(this.view.getSvgRoot(),"wheel",this,o=>{o.stopPropagation()})}addModelUpdateBindings(){this.view.addTextChangeListener((e,t)=>void super.setText(t)),this.view.addSizeChangeListener((e,t)=>void super.setSize(t)),this.view.addOnCollapseListener(()=>void super.setCollapsed(this.view.isCollapsed())),this.view.addDisposeListener(()=>{this.isDeadOrDying()||this.dispose()})}setText(e){this.view.setText(e)}setPlaceholderText(e){this.view.setPlaceholderText(e)}setSize(e){this.view.setSize(e)}setCollapsed(e){this.view.setCollapsed(e)}setEditable(e){super.setEditable(e),this.view.setEditable(this.isEditable())}getSvgRoot(){return this.view.getSvgRoot()}getSize(){return super.getSize()}getBoundingRectangle(){const e=this.getRelativeToSurfaceXY();var t,o;const s=(o=(t=this.view)==null?void 0:t.getSize())!=null?o:this.getSize();return this.workspace.RTL?(t=e.x-s.width,o=e.x):(t=e.x,o=e.x+s.width),new D(e.y,e.y+s.height,t,o)}moveBy(e,t,o){const s=this.getRelativeToSurfaceXY();e=new f(s.x+e,s.y+t),this.moveTo(e,o)}moveTo(e,t){super.moveTo(e,t),this.view.moveTo(e)}moveDuringDrag(e){this.location=e,this.view.moveTo(e)}setDragging(e){e?b(this.getSvgRoot(),"blocklyDragging"):O(this.getSvgRoot(),"blocklyDragging")}dispose(){this.disposing=!0;const e=n.getFocusManager$$module$build$src$core$focus_manager();e.getFocusedNode()===this&&setTimeout(()=>e.focusTree(this.workspace),0),this.view.isDeadOrDying()||this.view.dispose(),super.dispose()}startGesture(e){const t=this.workspace.getGesture(e);t&&(t.handleCommentStart(e,this),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this))}setDeleteStyle(e){e?b(this.getSvgRoot(),"blocklyDraggingDelete"):O(this.getSvgRoot(),"blocklyDraggingDelete")}isCopyable(){return this.isOwnMovable()&&this.isOwnDeletable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(){this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){b(this.getSvgRoot(),"blocklySelected"),Lt(this)}unselect(){O(this.getSvgRoot(),"blocklySelected"),Lt(null)}toCopyData(){return{paster:Wr.TYPE,commentState:Bo(this,{addCoordinates:!0})}}showContextMenu(e){const t=R.registry.getContextMenuOptions({comment:this,focusedNode:this},e);let o;o=e instanceof PointerEvent?new f(e.clientX,e.clientY):Lo(this.workspace,this.getRelativeToSurfaceXY()).translate(10,10),Yo(e,t,this.workspace.RTL,this.workspace,o)}snapToGrid(){if(!this.isDeadOrDying()){var e=this.workspace.getGrid();if(e!=null&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();e=e.alignXY(t),e!==t&&this.moveTo(e,["snap"])}}}getEditorFocusableNode(){return this.view.getEditorFocusableNode()}getFocusableElement(){return this.getSvgRoot()}getFocusableTree(){return this.workspace}onNodeFocus(){this.select();let e;(e=this.workspace.getLayerManager())==null||e.append(this,Yt)}onNodeBlur(){this.unselect()}canBeFocused(){return!0}},me={};me.appendDomToWorkspace=md,me.blockToDom=Ft,me.blockToDomWithXY=Ys,me.clearWorkspaceAndLoadFromXml=gd,me.deleteNext=wd,me.domToBlock=n.domToBlock$$module$build$src$core$xml,me.domToBlockInternal=uo,me.domToPrettyText=pd,me.domToText=st,me.domToVariables=Ql,me.domToWorkspace=n.domToWorkspace$$module$build$src$core$xml,me.loadWorkspaceComment=ql,me.saveWorkspaceComment=Xs,me.variablesToDom=Jl,me.workspaceToDom=ad;var Fu=class extends fo{constructor(e){super(e),this.type=a.BLOCK_CREATE,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=Ys(e),this.ids=xi(e),this.json=Be(e,{addCoordinates:!0}))}toJson(){const e=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 e.xml=st(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Fu),t.xml=n.textToDom$$module$build$src$core$utils$xml(e.xml),t.ids=e.ids,t.json=e.json,e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}run(e){const t=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(!Ym(t,this.ids))if(e)Pt(this.json,t);else for(e=0;e<this.ids.length;e++){const o=this.ids[e],s=t.getBlockById(o);s?s.dispose(!1):o===this.blockId&&console.warn("Can't uncreate non-existent block: "+o)}}},Ym=function(e,t){return t.map(o=>e.getBlockById(o)).filter(o=>o&&o.isShadow()).length===t.length};I(g.EVENT,a.BLOCK_CREATE,Fu);var Hu=class extends lt{constructor(e,t){super(t),this.type=a.THEME_CHANGE,this.themeName=e}toJson(){const e=super.toJson();if(!this.themeName)throw Error("The theme name is undefined. Either pass a theme name to the constructor, or call fromJson");return e.themeName=this.themeName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Hu),t.themeName=e.themeName,t}};I(g.EVENT,a.THEME_CHANGE,Hu);var Gu=class extends lt{constructor(e,t,o,s,i){super(s),this.type=a.VIEWPORT_CHANGE,this.viewTop=e,this.viewLeft=t,this.scale=o,this.oldScale=i}toJson(){const e=super.toJson();if(this.viewTop===void 0)throw Error("The view top is undefined. Either pass a value to the constructor, or call fromJson");if(this.viewLeft===void 0)throw Error("The view left is undefined. Either pass a value to the constructor, or call fromJson");if(this.scale===void 0)throw Error("The scale is undefined. Either pass a value to the constructor, or call fromJson");if(this.oldScale===void 0)throw Error("The old scale is undefined. Either pass a value to the constructor, or call fromJson");return e.viewTop=this.viewTop,e.viewLeft=this.viewLeft,e.scale=this.scale,e.oldScale=this.oldScale,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Gu),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};I(g.EVENT,a.VIEWPORT_CHANGE,Gu);var E;(function(e){e[e.INPUT_VALUE=1]="INPUT_VALUE",e[e.OUTPUT_VALUE=2]="OUTPUT_VALUE",e[e.NEXT_STATEMENT=3]="NEXT_STATEMENT",e[e.PREVIOUS_STATEMENT=4]="PREVIOUS_STATEMENT"})(E||(E={}));var hs=class{constructor(e){this.connectionChecker=e,this.connections=[]}addConnection(e,t){t=this.calculateIndexForYPos(t),this.connections.splice(t,0,e)}findIndexOfConnection(e,t){if(!this.connections.length)return-1;const o=this.calculateIndexForYPos(t);if(o>=this.connections.length)return-1;t=e.y;let s=o;for(;s>=0&&this.connections[s].y===t;){if(this.connections[s]===e)return s;s--}for(s=o;s<this.connections.length&&this.connections[s].y===t;){if(this.connections[s]===e)return s;s++}return-1}calculateIndexForYPos(e){if(!this.connections.length)return 0;let t=0,o=this.connections.length;for(;t<o;){const s=Math.floor((t+o)/2);if(this.connections[s].y<e)t=s+1;else if(this.connections[s].y>e)o=s;else{t=s;break}}return t}removeConnection(e,t){if(e=this.findIndexOfConnection(e,t),e===-1)throw Error("Unable to find connection in connectionDB.");this.connections.splice(e,1)}getNeighbours(e,t){function o(T){const Y=i-s[T].x,V=r-s[T].y;return Math.sqrt(Y*Y+V*V)<=t&&p.push(s[T]),V<t}const s=this.connections,i=e.x,r=e.y;e=0;let l=s.length-2,c=l;for(;e<c;)s[c].y<r?e=c:l=c,c=Math.floor((e+l)/2);const p=[];if(l=e=c,s.length){for(;e>=0&&o(e);)e--;do l++;while(l<s.length&&o(l))}return p}isInYRange(e,t,o){return Math.abs(this.connections[e].y-t)<=o}searchForClosest(e,t,o){if(!this.connections.length)return{connection:null,radius:t};const s=e.y,i=e.x;e.x=i+o.x,e.y=s+o.y;var r=this.calculateIndexForYPos(e.y);o=null;let l=t,c,p=r-1;for(;p>=0&&this.isInYRange(p,e.y,t);)c=this.connections[p],this.connectionChecker.canConnect(e,c,!0,l)&&(o=c,l=c.distanceFrom(e)),p--;for(;r<this.connections.length&&this.isInYRange(r,e.y,t);)c=this.connections[r],this.connectionChecker.canConnect(e,c,!0,l)&&(o=c,l=c.distanceFrom(e)),r++;return e.x=i,e.y=s,{connection:o,radius:l}}static init(e){const t=[];return t[E.INPUT_VALUE]=new hs(e),t[E.OUTPUT_VALUE]=new hs(e),t[E.NEXT_STATEMENT]=new hs(e),t[E.PREVIOUS_STATEMENT]=new hs(e),t}},Vu=class extends lt{constructor(e,t,o){super(o),this.type=a.SELECTED,this.oldElementId=e??void 0,this.newElementId=t??void 0}toJson(){const e=super.toJson();return e.oldElementId=this.oldElementId,e.newElementId=this.newElementId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Vu),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};I(g.EVENT,a.SELECTED,Vu);var Wu=class extends fo{constructor(e){if(super(e),this.type=a.BLOCK_DELETE,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.oldXml=Ys(e),this.ids=xi(e),this.wasShadow=e.isShadow(),this.oldJson=Be(e,{addCoordinates:!0})}}toJson(){const e=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(this.wasShadow===void 0)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 e.oldXml=st(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Wu),t.oldXml=n.textToDom$$module$build$src$core$utils$xml(e.oldXml),t.ids=e.ids,t.wasShadow=e.wasShadow||t.oldXml.tagName.toLowerCase()==="shadow",t.oldJson=e.oldJson,e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}run(e){const t=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(e)for(e=0;e<this.ids.length;e++){const o=this.ids[e],s=t.getBlockById(o);s?s.dispose(!1):o===this.blockId&&console.warn("Can't delete non-existent block: "+o)}else Pt(this.oldJson,t)}};I(g.EVENT,a.BLOCK_DELETE,Wu);var Fp={fromJsonInternal:Id},un={TEST_ONLY:Fp};un.fromJson=n.fromJson$$module$build$src$core$field_registry,un.register=it,un.unregister=kd;var $e=class extends L{constructor(e,t,o){super(L.SKIP_SETUP),this.svgArrow=this.arrow=this.imageElement=this.menu_=this.selectedMenuItem=null,this.SERIALIZABLE=!0,this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions=null,e!==L.SKIP_SETUP&&(this.setOptions(e),o&&this.configure_(o),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState($e,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement=m(h.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&b(this.borderRect_,"blocklyDropdownRect"),this.fieldGroup_&&(b(this.fieldGroup_,"blocklyField"),b(this.fieldGroup_,"blocklyDropdownField"))}shouldAddBorderRect_(){let e;return!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW&&!((e=this.getSourceBlock())!=null&&e.isShadow())}createTextArrow_(){this.arrow=m(h.TSPAN,{},this.textElement_);let e;this.arrow.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?$e.ARROW_CHAR+" ":" "+$e.ARROW_CHAR)),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.arrow.setAttribute("dominant-baseline","central");let t;(t=this.getSourceBlock())!=null&&t.RTL?this.getTextElement().insertBefore(this.arrow,this.textContent_):this.getTextElement().appendChild(this.arrow)}createSVGArrow_(){this.svgArrow=m(h.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),this.svgArrow.setAttributeNS(Ie,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new te;this.dropdownCreate(),this.menu_&&(this.menu_.openingCoords=e&&typeof e.clientX=="number"?new f(e.clientX,e.clientY):null,nr(),e=this.menu_.render(rr()),b(e,"blocklyDropdownMenu"),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(t=t.getColour(),e=this.sourceBlock_.getColourTertiary(),fl(t,e)),bl(this,this.dropdownDispose_.bind(this)),rr().style.height=`${this.menu_.getSize().height}px`,this.menu_.focus(),this.selectedMenuItem&&this.menu_.setHighlighted(this.selectedMenuItem),this.applyColour())}dropdownCreate(){const e=this.getSourceBlock();if(!e)throw new te;const t=new _u;t.setRole(Se.LISTBOX),this.menu_=t;const o=this.getOptions(!1);this.selectedMenuItem=null;for(let i=0;i<o.length;i++){var s=o[i];if(s===$e.SEPARATOR){t.addChild(new Q$);continue}const[r,l]=s;Ko(r)?(s=new Image(r.width,r.height),s.src=r.src,s.alt=r.alt):s=r,s=new Ur(s,l),s.setRole(Se.OPTION),s.setRightToLeft(e.RTL),s.setCheckable(!0),t.addChild(s),s.setChecked(l===this.value_),l===this.value_&&(this.selectedMenuItem=s),s.onAction(this.handleMenuActionEvent,this)}}dropdownDispose_(){this.menu_&&this.menu_.dispose(),this.selectedMenuItem=this.menu_=null,this.applyColour()}handleMenuActionEvent(e){lr(this,!0),this.onItemSelected_(this.menu_,e)}onItemSelected_(e,t){this.setValue(t.getValue())}isOptionListDynamic(){return typeof this.menuGenerator_=="function"}getOptions(e){if(!this.menuGenerator_)throw TypeError("A menu generator was never defined.");return Array.isArray(this.menuGenerator_)?this.menuGenerator_:e&&this.generatedOptions?this.generatedOptions:(this.generatedOptions=this.menuGenerator_(),this.validateOptions(this.generatedOptions),this.generatedOptions)}setOptions(e){Array.isArray(e)?(this.validateOptions(e),e=this.trimOptions(e),this.menuGenerator_=e.options,this.prefixField=e.prefix||null,this.suffixField=e.suffix||null):this.menuGenerator_=e,this.selectedOption=this.getOptions(!1)[0],this.setValue(this.selectedOption[1])}doClassValidation_(e){return this.getOptions(!0).some(t=>t[1]===e)?e:(this.sourceBlock_&&console.warn("Cannot set the dropdown's value to an unavailable option. Block type: "+this.sourceBlock_.type+", Field name: "+this.name+", Value: "+e),null)}doValueUpdate_(e){super.doValueUpdate_(e),e=this.getOptions(!0);for(let t=0,o;o=e[t];t++)o[1]===this.value_&&(this.selectedOption=o)}applyColour(){const e=this.sourceBlock_;this.borderRect_&&(this.borderRect_.setAttribute("stroke",e.getColourTertiary()),this.menu_?this.borderRect_.setAttribute("fill",e.getColourTertiary()):this.borderRect_.setAttribute("fill","transparent")),e&&this.arrow&&(e.isShadow()?this.arrow.style.fill=e.getColourSecondary():this.arrow.style.fill=e.getColour())}render_(){this.getTextContent().nodeValue="",this.imageElement.style.display="none";const e=this.selectedOption&&this.selectedOption[0];Ko(e)?this.renderSelectedImage(e):this.renderSelectedText(),this.positionBorderRect_()}renderSelectedImage(e){const t=this.getSourceBlock();if(!t)throw new te;this.imageElement.style.display="",this.imageElement.setAttributeNS(Ie,"xlink:href",e.src),this.imageElement.setAttribute("height",String(e.height)),this.imageElement.setAttribute("width",String(e.width));const o=Number(e.height);e=Number(e.width);var s=!!this.borderRect_;const i=Math.max(s?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,o+$e.IMAGE_Y_PADDING);s=s?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let r;r=this.svgArrow?this.positionSVGArrow(e+s,i/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):Ao(this.arrow),this.size_.width=e+r+s*2,this.size_.height=i;let l=0;t.RTL?this.imageElement.setAttribute("x",`${s+r}`):(l=e+r,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement.setAttribute("x",`${s}`)),this.imageElement.setAttribute("y",String(i/2-o/2)),this.positionTextElement_(l+s,e+r)}renderSelectedText(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();b(e,"blocklyDropdownText"),e.setAttribute("text-anchor","start");var t=!!this.borderRect_;e=Math.max(t?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,this.getConstants().FIELD_TEXT_HEIGHT);const o=Ao(this.getTextElement());t=t?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let s=0;this.svgArrow&&(s=this.positionSVGArrow(o+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=o+s+t*2,this.size_.height=e,this.positionTextElement_(t,o)}positionSVGArrow(e,t){if(!this.svgArrow)return 0;const o=this.getSourceBlock();if(!o)throw new te;const s=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,i=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,r=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow.setAttribute("transform","translate("+(o.RTL?s:e+i)+","+t+")"),r+i}getText_(){if(!this.selectedOption)return null;const e=this.selectedOption[0];if(Ko(e))return e.alt;if(typeof HTMLElement<"u"&&e instanceof HTMLElement){let t,o;return(o=(t=e.title)!=null?t:e.ariaLabel)!=null?o:e.innerText}return typeof e=="string"?e:(console.warn("Can't get text for existing dropdown option. If you're using HTMLElement dropdown options in node, ensure you're using jsdom-global or similar."),null)}static fromJson(e){if(!e.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(e.options,void 0,e)}trimOptions(e){let t=!1;const o=e.map(l=>{if(l===$e.SEPARATOR)return l;const[c,p]=l;return typeof c=="string"?[J(c),p]:(t=!0,[Ko(c)?Object.assign({},c,{alt:J(c.alt)}):Object.assign({},c),p])});if(t||e.length<2)return{options:o};var s=o.map(([l])=>l),i=Gs(s);e=Sl(s,i);const r=Rl(s,i);return!e&&!r||i<=e+r?{options:o}:(i=e?s[0].substring(0,e-1):void 0,s=r?s[0].substr(1-r):void 0,{options:this.applyTrim(o,e,r),prefix:i,suffix:s})}applyTrim(e,t,o){return e.map(([s,i])=>[s.substring(t,s.length-o),i])}validateOptions(e){if(!Array.isArray(e))throw TypeError("FieldDropdown options must be an array.");if(!e.length)throw TypeError("FieldDropdown options must not be an empty array.");let t=!1;for(let o=0;o<e.length;o++){const s=e[o];Array.isArray(s)||s===$e.SEPARATOR?typeof s[1]!="string"?(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option id must be a string.
|
|
618
|
+
Found ${s[1]} in: ${s}`)):!s[0]||typeof s[0]=="string"||Ko(s[0])||typeof HTMLElement<"u"&&s[0]instanceof HTMLElement||(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option must have a string
|
|
619
|
+
label, image description, or HTML element. Found ${s[0]} in: ${s}`)):(t=!0,console.error(`Invalid option[${o}]: Each FieldDropdown option must be an array or
|
|
620
|
+
the string literal 'separator'. Found: ${s}`))}if(t)throw TypeError("Found invalid FieldDropdown options.")}};$e.SEPARATOR="separator",$e.ARROW_CHAR="▾",$e.IMAGE_Y_OFFSET=5,$e.IMAGE_Y_PADDING=$e.IMAGE_Y_OFFSET*2,it("field_dropdown",$e);var vo=class{constructor(e,t,o,s){this.name=e,this.startHats=!1,this.blockStyles=t||Object.create(null),this.categoryStyles=o||Object.create(null),this.componentStyles=s||Object.create(null),this.fontStyle=Object.create(null),I(g.THEME,e,this,!0)}getClassName(){return this.name+"-theme"}setBlockStyle(e,t){this.blockStyles[e]=t}setCategoryStyle(e,t){this.categoryStyles[e]=t}getComponentStyle(e){if(e=this.componentStyles[e],!e)return null;if(typeof e=="string"){const t=this.getComponentStyle(e);if(t)return t}return`${e}`}setComponentStyle(e,t){this.componentStyles[e]=t}setFontStyle(e){this.fontStyle=e}setStartHats(e){this.startHats=e}static defineTheme(e,t){e=e.toLowerCase();const o=new vo(e);let s=t.base;if(s){if(typeof s=="string"){let i;s=(i=Ot(g.THEME,s))!=null?i:void 0}s instanceof vo&&(Ze(o,s),o.name=e)}return Ze(o.blockStyles,t.blockStyles),Ze(o.categoryStyles,t.categoryStyles),Ze(o.componentStyles,t.componentStyles),Ze(o.fontStyle,t.fontStyle),t.startHats!==null&&(o.startHats=t.startHats),o}},Km={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"}},jm={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"}},hn=new vo("classic",Km,jm),ut=class{constructor(e){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let t=null,o=!1;var s=!1,i=!1,r=!1,l=!1,c=!1;const p=!!e.readOnly;if(!p){var T;t=Gi((T=e.toolbox)!=null?T:null),o=Vi(t),s=e.trashcan,s=s===void 0?o:s,i=e.collapse,i=i===void 0?o:i,r=e.comments,r=r===void 0?o:r,l=e.disable,l=l===void 0?o:l,c=e.sounds,c=c===void 0?!0:c}T=e.maxTrashcanContents,s?T===void 0&&(T=32):T=0;const Y=!!e.rtl;let V=e.horizontalLayout;V===void 0&&(V=!1);var pe=e.toolboxPosition!=="end";pe=V?pe?S.TOP:S.BOTTOM:pe===Y?S.RIGHT:S.LEFT;let At=e.css;At===void 0&&(At=!0);let bt="https://blockly-demo.appspot.com/static/media/";e.media&&(bt=e.media.endsWith("/")?e.media:e.media+"/");const Im=e.oneBasedIndex,Sf=e.renderer||"geras",Rf=e.plugins||{};let Fh=e.modalInputs;Fh===void 0&&(Fh=!0),this.RTL=Y,this.oneBasedIndex=Im===void 0?!0:Im,this.collapse=i,this.comments=r,this.disable=l,this.readOnly=p,this.maxBlocks=e.maxBlocks||1/0;let Sm;this.maxInstances=(Sm=e.maxInstances)!=null?Sm:null,this.modalInputs=Fh,this.pathToMedia=bt,this.hasCategories=o,this.moveOptions=ut.parseMoveOptions(e,o),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=s,this.maxTrashcanContents=T,this.hasSounds=c,this.hasCss=At,this.horizontalLayout=V,this.languageTree=t,this.gridOptions=ut.parseGridOptions(e),this.zoomOptions=ut.parseZoomOptions(e),this.toolboxPosition=pe,this.theme=ut.parseThemeOptions(e),this.renderer=Sf;let Rm;this.rendererOverrides=(Rm=e.rendererOverrides)!=null?Rm:null;let Dm;this.parentWorkspace=(Dm=e.parentWorkspace)!=null?Dm:null,this.plugins=Rf}static parseMoveOptions(e,t){const o=e.move||{},s={};return o.scrollbars===void 0&&e.scrollbars===void 0?s.scrollbars=t:typeof o.scrollbars=="object"?(s.scrollbars={horizontal:!!o.scrollbars.horizontal,vertical:!!o.scrollbars.vertical},s.scrollbars.horizontal&&s.scrollbars.vertical?s.scrollbars=!0:s.scrollbars.horizontal||s.scrollbars.vertical||(s.scrollbars=!1)):s.scrollbars=!!o.scrollbars||!!e.scrollbars,s.wheel=s.scrollbars&&o.wheel!==void 0?!!o.wheel:typeof s.scrollbars=="object",s.drag=s.scrollbars?o.drag===void 0?!0:!!o.drag:!1,s}static parseZoomOptions(e){e=e.zoom||{};const t={};return t.controls=e.controls===void 0?!1:!!e.controls,t.wheel=e.wheel===void 0?!1:!!e.wheel,t.startScale=e.startScale===void 0?1:Number(e.startScale),t.maxScale=e.maxScale===void 0?3:Number(e.maxScale),t.minScale=e.minScale===void 0?.3:Number(e.minScale),t.scaleSpeed=e.scaleSpeed===void 0?1.2:Number(e.scaleSpeed),t.pinch=e.pinch===void 0?t.wheel||t.controls:!!e.pinch,t}static parseGridOptions(e){e=e.grid||{};const t={};return t.spacing=Number(e.spacing)||0,t.colour=e.colour||"#888",t.length=e.length===void 0?1:Number(e.length),t.snap=t.spacing>0&&!!e.snap,t}static parseThemeOptions(e){return e=e.theme||hn,typeof e=="string"?Ot(g.THEME,e):e instanceof vo?e:vo.defineTheme(e.name||"builtin"+Le(),e)}},Hp=class{constructor(e,t){this.bubble=e,this.workspace=t,this.startLoc=null}isMovable(){return!0}startDrag(){this.startLoc=this.bubble.getRelativeToSurfaceXY(),this.workspace.setResizesEnabled(!1);let e;(e=this.workspace.getLayerManager())==null||e.moveToDragLayer(this.bubble),this.bubble.setDragging&&this.bubble.setDragging(!0)}drag(e){this.bubble.moveDuringDrag(e)}endDrag(){this.workspace.setResizesEnabled(!0);let e;(e=this.workspace.getLayerManager())==null||e.moveOffDragLayer(this.bubble,nn),this.bubble.setDragging(!1)}revertDrag(){this.startLoc&&this.bubble.moveDuringDrag(this.startLoc)}},Ne,M=class{constructor(e,t,o,s){this.workspace=e,this.anchor=t,this.ownerRect=o,this.size=new N(0,0),this.colour="#ffffff",this.disposed=!1,this.relativeLeft=this.relativeTop=0,this.dragStrategy=new Hp(this,this.workspace),this.id=Le(),this.svgRoot=m(h.G,{class:"blocklyBubble"},e.getBubbleCanvas()),e=m(h.G,{class:"blocklyEmboss"},this.svgRoot),this.tail=m(h.PATH,{class:"blocklyBubbleTail"},e),this.background=m(h.RECT,{class:"blocklyDraggable",x:0,y:0,rx:Ne.BORDER_WIDTH,ry:Ne.BORDER_WIDTH},e),this.contentContainer=m(h.G,{},this.svgRoot),this.focusableElement=s??this.svgRoot,this.focusableElement.setAttribute("id",this.id),k(this.background,"pointerdown",this,this.onMouseDown)}dispose(){F(this.svgRoot),this.disposed=!0}setAnchorLocation(e,t=!1){this.anchor=e,t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}setPositionRelativeToAnchor(e,t){this.relativeLeft=e,this.relativeTop=t,this.positionRelativeToAnchor(),this.renderTail()}getSize(){return this.size}setSize(e,t=!1){e.width=Math.max(e.width,Ne.MIN_SIZE),e.height=Math.max(e.height,Ne.MIN_SIZE),this.size=e,this.background.setAttribute("width",`${e.width}`),this.background.setAttribute("height",`${e.height}`),t?this.positionByRect(this.ownerRect):this.positionRelativeToAnchor(),this.renderTail()}getColour(){return this.colour}setColour(e){this.colour=e,this.tail.setAttribute("fill",e),this.background.setAttribute("fill",e)}onMouseDown(e){let t;(t=this.workspace.getGesture(e))==null||t.handleBubbleStart(e,this),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this)}positionRelativeToAnchor(){let e=this.anchor.x;e=this.workspace.RTL?e-(this.relativeLeft+this.size.width):e+this.relativeLeft,this.moveTo(e,this.relativeTop+this.anchor.y)}moveTo(e,t){this.svgRoot.setAttribute("transform",`translate(${e}, ${t})`)}positionByRect(e=new D(0,0,0,0)){var t=this.workspace.getMetricsManager().getViewMetrics(!0),o=this.getOptimalRelativeLeft(t),s=this.getOptimalRelativeTop(t);const i={x:o,y:-this.size.height-this.workspace.getRenderer().getConstants().MIN_BLOCK_HEIGHT},r={x:-this.size.width-30,y:s};s={x:e.getWidth(),y:s};var l={x:o,y:e.getHeight()};o=e.getWidth()<e.getHeight()?s:l,e=e.getWidth()<e.getHeight()?l:s,s=this.getOverlap(i,t),l=this.getOverlap(r,t);const c=this.getOverlap(o,t);t=this.getOverlap(e,t),t=Math.max(s,l,c,t),s===t?(this.relativeLeft=i.x,this.relativeTop=i.y):l===t?(this.relativeLeft=r.x,this.relativeTop=r.y):c===t?(this.relativeLeft=o.x,this.relativeTop=o.y):(this.relativeLeft=e.x,this.relativeTop=e.y),this.positionRelativeToAnchor()}getOverlap(e,t){var o=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x+this.anchor.x;return e=e.y+this.anchor.y,Math.max(0,Math.min(1,(Math.min(o+this.size.width,t.left+t.width)-Math.max(o,t.left))*(Math.min(e+this.size.height,t.top+t.height)-Math.max(e,t.top))/(this.size.width*this.size.height)))}getOptimalRelativeLeft(e){let t=-this.size.width/4;if(this.size.width>e.width)return t;if(e=this.getWorkspaceViewRect(e),this.workspace.RTL){var o=this.anchor.x-t;o-this.size.width<e.left?t=-(e.left-this.anchor.x+this.size.width):o>e.right&&(t=-(e.right-this.anchor.x))}else{o=t+this.anchor.x;const s=o+this.size.width;o<e.left?t=e.left-this.anchor.x:s>e.right&&(t=e.right-this.anchor.x-this.size.width)}return t}getOptimalRelativeTop(e){let t=-this.size.height/4;if(this.size.height>e.height)return t;const o=this.anchor.y+t,s=o+this.size.height;return e=this.getWorkspaceViewRect(e),o<e.top?t=e.top-this.anchor.y:s>e.bottom&&(t=e.bottom-this.anchor.y-this.size.height),t}getWorkspaceViewRect(e){const t=e.top;let o=e.top+e.height,s=e.left;return e=e.left+e.width,o-=this.getScrollbarThickness(),this.workspace.RTL?s-=this.getScrollbarThickness():e-=this.getScrollbarThickness(),new D(t,o,s,e)}getScrollbarThickness(){return q.scrollbarThickness/this.workspace.scale}renderTail(){const e=[];var t=this.size.width/2,o=this.size.height/2,s=-this.relativeLeft,i=-this.relativeTop;if(t===s&&o===i)e.push("M "+t+","+o);else{i-=o,s-=t,this.workspace.RTL&&(s*=-1);var r=Math.sqrt(i*i+s*s),l=Math.acos(s/r);i<0&&(l=2*Math.PI-l);var c=l+Math.PI/2;c>Math.PI*2&&(c-=Math.PI*2);var p=Math.sin(c);const Y=Math.cos(c);let V=(this.size.width+this.size.height)/Ne.TAIL_THICKNESS;V=Math.min(V,this.size.width,this.size.height)/4,c=1-Ne.ANCHOR_RADIUS/r,s=t+c*s,i=o+c*i,c=t+V*Y;const pe=o+V*p;t-=V*Y,o-=V*p,p=sr(this.workspace.RTL?-Ne.TAIL_ANGLE:Ne.TAIL_ANGLE),p=l+p,p>Math.PI*2&&(p-=Math.PI*2),l=Math.sin(p)*r/Ne.TAIL_BEND,r=Math.cos(p)*r/Ne.TAIL_BEND,e.push("M"+c+","+pe),e.push("C"+(c+r)+","+(pe+l)+" "+s+","+i+" "+s+","+i),e.push("C"+s+","+i+" "+(t+r)+","+(o+l)+" "+t+","+o)}e.push("z");let T;(T=this.tail)==null||T.setAttribute("d",e.join(" "))}bringToFront(){let e;const t=(e=this.svgRoot)==null?void 0:e.parentNode;return this.svgRoot&&t?.lastChild!==this.svgRoot?(t?.appendChild(this.svgRoot),!0):!1}getRelativeToSurfaceXY(){return new f(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(e){this.moveTo(e.x,e.y),this.relativeLeft=this.workspace.RTL?this.anchor.x-e.x-this.size.width:e.x-this.anchor.x,this.relativeTop=e.y-this.anchor.y,this.renderTail()}setDragging(e){}setDeleteStyle(e){}isDeletable(){return!1}showContextMenu(e){}isMovable(){return!0}startDrag(){this.dragStrategy.startDrag()}drag(e){this.dragStrategy.drag(e)}endDrag(){this.dragStrategy.endDrag()}revertDrag(){this.dragStrategy.revertDrag()}select(){Lt(this)}unselect(){Lt(null)}getFocusableElement(){return this.focusableElement}getFocusableTree(){return this.workspace}onNodeFocus(){this.select(),this.bringToFront()}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};Ne=M,M.BORDER_WIDTH=6,M.DOUBLE_BORDER=Ne.BORDER_WIDTH*2,M.MIN_SIZE=Ne.DOUBLE_BORDER,M.TAIL_THICKNESS=1,M.TAIL_ANGLE=20,M.TAIL_BEND=4,M.ANCHOR_RADIUS=8;var St=class extends M{constructor(e,t,o,s){super(t,o,s),this.workspace=t,this.anchor=o,this.ownerRect=s,this.autoLayout=!0,t=new ut(e),this.validateWorkspaceOptions(t),this.svgDialog=m(h.SVG,{x:M.BORDER_WIDTH,y:M.BORDER_WIDTH},this.contentContainer),e.parentWorkspace=this.workspace,this.miniWorkspace=this.newWorkspaceSvg(new ut(e)),this.miniWorkspace.internalIsMutator=!0,e=this.miniWorkspace.createDom("blocklyMutatorBackground"),this.svgDialog.appendChild(e),t.languageTree&&(e.insertBefore(this.miniWorkspace.addFlyout(h.G),this.miniWorkspace.getCanvas()),e=this.miniWorkspace.getFlyout(),e?.init(this.miniWorkspace),e?.show(t.languageTree)),b(this.svgRoot,"blocklyMiniWorkspaceBubble"),this.miniWorkspace.addChangeListener(this.onWorkspaceChange.bind(this));let i,r;(i=this.miniWorkspace.getFlyout())==null||(r=i.getWorkspace())==null||r.addChangeListener(this.onWorkspaceChange.bind(this)),this.updateBubbleSize()}dispose(){this.miniWorkspace.dispose(),super.dispose()}getWorkspace(){return this.miniWorkspace}addWorkspaceChangeListener(e){this.miniWorkspace.addChangeListener(e)}validateWorkspaceOptions(e){if(e.hasCategories)throw Error("The miniworkspace bubble does not support toolboxes with categories");if(e.hasTrashcan)throw Error("The miniworkspace bubble does not support trashcans");if(e.zoomOptions.controls||e.zoomOptions.wheel||e.zoomOptions.pinch)throw Error("The miniworkspace bubble does not support zooming");if(e.moveOptions.scrollbars||e.moveOptions.wheel||e.moveOptions.drag)throw Error("The miniworkspace bubble does not scrolling/moving the workspace");if(e.horizontalLayout)throw Error("The miniworkspace bubble does not support horizontal layouts")}onWorkspaceChange(){this.bumpBlocksIntoBounds(),this.updateBubbleSize()}bumpBlocksIntoBounds(){if(!this.miniWorkspace.isDragging()||this.miniWorkspace.keyboardMoveInProgress)for(const e of this.miniWorkspace.getTopBlocks(!1)){const t=e.getRelativeToSurfaceXY();if(t.y<20&&e.moveBy(0,20-t.y),e.RTL){let o=-20;const s=this.miniWorkspace.getFlyout();s&&(o-=s.getWidth()),t.x>o&&e.moveBy(o-t.x,0)}else t.x<20&&e.moveBy(20-t.x,0)}}updateBubbleSize(){if(!this.miniWorkspace.isDragging()||this.miniWorkspace.keyboardMoveInProgress){this.autoLayout&&(this.autoLayout=!this.miniWorkspace.keyboardMoveInProgress);var e=this.getSize(),t=this.calculateWorkspaceSize();Math.abs(e.width-t.width)<St.MINIMUM_VIEW_CHANGE&&Math.abs(e.height-t.height)<St.MINIMUM_VIEW_CHANGE||(this.svgDialog.setAttribute("width",`${t.width}px`),this.svgDialog.setAttribute("height",`${t.height}px`),this.miniWorkspace.setCachedParentSvgSize(t.width,t.height),this.miniWorkspace.RTL&&this.miniWorkspace.getCanvas().setAttribute("transform",`translate(${t.width}, 0)`),this.setSize(new N(t.width+M.DOUBLE_BORDER,t.height+M.DOUBLE_BORDER),this.autoLayout),this.miniWorkspace.resize(),this.miniWorkspace.recordDragTargets())}}calculateWorkspaceSize(){var e=this.miniWorkspace.getCanvas().getBBox();let t=e.width+St.MARGIN;e=e.height+St.MARGIN;const o=this.miniWorkspace.getFlyout();if(o){const s=o.getWorkspace().getMetricsManager().getScrollMetrics();e=Math.max(e,s.height+20),t+=o.getWidth()}return new N(t,e)}updateBlockStyles(){for(var e of this.miniWorkspace.getAllBlocks(!1))e.setStyle(e.getStyleName());let t;if(e=(t=this.miniWorkspace.getFlyout())==null?void 0:t.getWorkspace())for(const o of e.getAllBlocks(!1))o.setStyle(o.getStyleName())}moveDuringDrag(e){super.moveDuringDrag(e),this.autoLayout=!1}moveTo(e,t){super.moveTo(e,t),this.miniWorkspace.recordDragTargets()}newWorkspaceSvg(e){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts")}};St.MINIMUM_VIEW_CHANGE=10,St.MARGIN=M.DOUBLE_BORDER*3;var gi=class{constructor(e){this.sourceBlock=e,this.offsetInBlock=new f(0,0),this.workspaceLocation=new f(0,0),this.svgRoot=null,this.tooltip=e,this.id=Le()}getType(){throw Error("Icons must implement getType")}initView(e){if(!this.svgRoot){var t=this.sourceBlock;this.svgRoot=m(h.G,{class:"blocklyIconGroup",id:this.id}),t.getSvgRoot().appendChild(this.svgRoot),this.updateSvgRootOffset(),k(this.svgRoot,"pointerdown",this,e),this.svgRoot.tooltip=this,Vs(this.svgRoot)}}dispose(){Ol(this.svgRoot),F(this.svgRoot)}getWeight(){return-1}getSize(){return new N(0,0)}setTooltip(e){this.tooltip=e??this.sourceBlock}getTooltip(){return this.tooltip}applyColour(){}updateEditable(){}updateCollapsed(){this.svgRoot&&(this.sourceBlock.isCollapsed()?this.svgRoot.style.display="none":this.svgRoot.style.display="block",ro(this)&&this.setBubbleVisible(!1))}hideForInsertionMarker(){this.svgRoot&&(this.svgRoot.style.display="none")}isShownWhenCollapsed(){return!1}setOffsetInBlock(e){this.offsetInBlock=e,this.updateSvgRootOffset()}updateSvgRootOffset(){let e;(e=this.svgRoot)==null||e.setAttribute("transform",`translate(${this.offsetInBlock.x}, ${this.offsetInBlock.y})`)}onLocationChange(e){this.workspaceLocation=f.sum(e,this.offsetInBlock)}onClick(){}isClickableInFlyout(e){return!0}getFocusableElement(){const e=this.svgRoot;if(!e)throw Error("Attempting to focus uninitialized icon.");return e}getFocusableTree(){return this.sourceBlock.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getSourceBlock(){return this.sourceBlock}},an,dn;an=17,dn=16,n.MutatorIcon$$module$build$src$core$icons$mutator_icon=class extends gi{constructor(e,t){super(t),this.flyoutBlockTypes=e,this.sourceBlock=t,this.saveConnectionsListener=this.updateWorkspacePid=this.rootBlock=this.miniWorkspaceBubble=null}getType(){return n.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE}initView(e){this.svgRoot||(super.initView(e),m(h.RECT,{class:"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},this.svgRoot),m(h.PATH,{class:"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},this.svgRoot),m(h.CIRCLE,{class:"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},this.svgRoot),b(this.svgRoot,"blocklyMutatorIcon"))}dispose(){super.dispose();let e;(e=this.miniWorkspaceBubble)==null||e.dispose()}getWeight(){return n.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT}getSize(){return new N(an,an)}applyColour(){super.applyColour();let e;(e=this.miniWorkspaceBubble)==null||e.setColour(this.sourceBlock.getColour());let t;(t=this.miniWorkspaceBubble)==null||t.updateBlockStyles()}updateCollapsed(){super.updateCollapsed(),this.sourceBlock.isCollapsed()&&this.setBubbleVisible(!1)}onLocationChange(e){super.onLocationChange(e);let t;(t=this.miniWorkspaceBubble)==null||t.setAnchorLocation(this.getAnchorLocation())}onClick(){super.onClick(),this.sourceBlock.isEditable()&&this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.miniWorkspaceBubble}setBubbleVisible(e){const t=this;return(0,$.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield tt(),e){t.miniWorkspaceBubble=new St(t.getMiniWorkspaceConfig(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour(),t.createRootBlock(),t.addSaveConnectionsListener();let o;(o=t.miniWorkspaceBubble)==null||o.addWorkspaceChangeListener(t.createMiniWorkspaceChangeListener())}else{let o;(o=t.miniWorkspaceBubble)==null||o.dispose(),t.miniWorkspaceBubble=null,t.saveConnectionsListener&&t.sourceBlock.workspace.removeChangeListener(t.saveConnectionsListener),t.saveConnectionsListener=null}C(new(w(a.BUBBLE_OPEN))(t.sourceBlock,e,"mutator"))}})}getBubble(){return this.miniWorkspaceBubble}getMiniWorkspaceConfig(){let e;const t={disable:!1,media:this.sourceBlock.workspace.options.pathToMedia,rtl:this.sourceBlock.RTL,renderer:this.sourceBlock.workspace.options.renderer,rendererOverrides:(e=this.sourceBlock.workspace.options.rendererOverrides)!=null?e:void 0};return this.flyoutBlockTypes.length&&(t.toolbox={kind:"flyoutToolbox",contents:this.flyoutBlockTypes.map(o=>({kind:"block",type:o}))}),t}getAnchorLocation(){const e=an/2;return f.sum(this.workspaceLocation,new f(e,e))}getBubbleOwnerRect(){const e=this.sourceBlock.getSvgRoot().getBBox();return new D(e.y,e.y+e.height,e.x,e.x+e.width)}createRootBlock(){if(!this.sourceBlock.decompose)throw Error("Blocks with mutator icons must include a decompose method");this.rootBlock=this.sourceBlock.decompose(this.miniWorkspaceBubble.getWorkspace());for(var e of this.rootBlock.getDescendants(!1))e.queueRender();this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1);let t,o,s,i;e=(i=(t=this.miniWorkspaceBubble)==null||(o=t.getWorkspace())==null||(s=o.getFlyout())==null?void 0:s.getWidth())!=null?i:0,this.rootBlock.moveBy(this.rootBlock.RTL?-(e+dn):dn,dn)}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 e=>{n.MutatorIcon$$module$build$src$core$icons$mutator_icon.isIgnorableMutatorEvent(e)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null,this.recomposeSourceBlock()},0))}}static isIgnorableMutatorEvent(e){return e.isUiEvent||Ni(e)||No(e)&&e.element==="disabled"}recomposeSourceBlock(){if(this.rootBlock){if(!this.sourceBlock.compose)throw Error("Blocks with mutator icons must include a compose method");var e=n.getGroup$$module$build$src$core$events$utils();e||n.setGroup$$module$build$src$core$events$utils(!0);var t=bo.getExtraBlockState_(this.sourceBlock);this.sourceBlock.compose(this.rootBlock);var o=bo.getExtraBlockState_(this.sourceBlock);t!==o&&C(new(w(a.BLOCK_CHANGE))(this.sourceBlock,"mutation",null,t,o)),n.setGroup$$module$build$src$core$events$utils(e)}}getWorkspace(){let e;return(e=this.miniWorkspaceBubble)==null?void 0:e.getWorkspace()}},n.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE=se.MUTATOR,n.MutatorIcon$$module$build$src$core$icons$mutator_icon.WEIGHT=1,n.MutatorIcon$$module$build$src$core$icons$mutator_icon;var as=Object.create(null),Jm={allExtensions:as};n.register$$module$build$src$core$extensions("parent_tooltip_when_inline",Ld);var Ye={TEST_ONLY:Jm};Ye.apply=fr,Ye.buildTooltipForDropdown=n.buildTooltipForDropdown$$module$build$src$core$extensions,Ye.buildTooltipWithFieldText=n.buildTooltipWithFieldText$$module$build$src$core$extensions,Ye.isRegistered=oc,Ye.register=n.register$$module$build$src$core$extensions,Ye.registerMixin=n.registerMixin$$module$build$src$core$extensions,Ye.registerMutator=n.registerMutator$$module$build$src$core$extensions,Ye.runAfterPageLoad=Od,Ye.unregister=Sd;var P;(function(e){e[e.WIN_KEY_FF_LINUX=0]="WIN_KEY_FF_LINUX",e[e.MAC_ENTER=3]="MAC_ENTER",e[e.BACKSPACE=8]="BACKSPACE",e[e.TAB=9]="TAB",e[e.NUM_CENTER=12]="NUM_CENTER",e[e.ENTER=13]="ENTER",e[e.SHIFT=16]="SHIFT",e[e.CTRL=17]="CTRL",e[e.ALT=18]="ALT",e[e.PAUSE=19]="PAUSE",e[e.CAPS_LOCK=20]="CAPS_LOCK",e[e.ESC=27]="ESC",e[e.SPACE=32]="SPACE",e[e.PAGE_UP=33]="PAGE_UP",e[e.PAGE_DOWN=34]="PAGE_DOWN",e[e.END=35]="END",e[e.HOME=36]="HOME",e[e.LEFT=37]="LEFT",e[e.UP=38]="UP",e[e.RIGHT=39]="RIGHT",e[e.DOWN=40]="DOWN",e[e.PLUS_SIGN=43]="PLUS_SIGN",e[e.PRINT_SCREEN=44]="PRINT_SCREEN",e[e.INSERT=45]="INSERT",e[e.DELETE=46]="DELETE",e[e.ZERO=48]="ZERO",e[e.ONE=49]="ONE",e[e.TWO=50]="TWO",e[e.THREE=51]="THREE",e[e.FOUR=52]="FOUR",e[e.FIVE=53]="FIVE",e[e.SIX=54]="SIX",e[e.SEVEN=55]="SEVEN",e[e.EIGHT=56]="EIGHT",e[e.NINE=57]="NINE",e[e.FF_SEMICOLON=59]="FF_SEMICOLON",e[e.FF_EQUALS=61]="FF_EQUALS",e[e.FF_DASH=173]="FF_DASH",e[e.FF_HASH=163]="FF_HASH",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.AT_SIGN=64]="AT_SIGN",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.META=91]="META",e[e.WIN_KEY_RIGHT=92]="WIN_KEY_RIGHT",e[e.CONTEXT_MENU=93]="CONTEXT_MENU",e[e.NUM_ZERO=96]="NUM_ZERO",e[e.NUM_ONE=97]="NUM_ONE",e[e.NUM_TWO=98]="NUM_TWO",e[e.NUM_THREE=99]="NUM_THREE",e[e.NUM_FOUR=100]="NUM_FOUR",e[e.NUM_FIVE=101]="NUM_FIVE",e[e.NUM_SIX=102]="NUM_SIX",e[e.NUM_SEVEN=103]="NUM_SEVEN",e[e.NUM_EIGHT=104]="NUM_EIGHT",e[e.NUM_NINE=105]="NUM_NINE",e[e.NUM_MULTIPLY=106]="NUM_MULTIPLY",e[e.NUM_PLUS=107]="NUM_PLUS",e[e.NUM_MINUS=109]="NUM_MINUS",e[e.NUM_PERIOD=110]="NUM_PERIOD",e[e.NUM_DIVISION=111]="NUM_DIVISION",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NUMLOCK=144]="NUMLOCK",e[e.SCROLL_LOCK=145]="SCROLL_LOCK",e[e.FIRST_MEDIA_KEY=166]="FIRST_MEDIA_KEY",e[e.LAST_MEDIA_KEY=183]="LAST_MEDIA_KEY",e[e.SEMICOLON=186]="SEMICOLON",e[e.DASH=189]="DASH",e[e.EQUALS=187]="EQUALS",e[e.COMMA=188]="COMMA",e[e.PERIOD=190]="PERIOD",e[e.SLASH=191]="SLASH",e[e.APOSTROPHE=192]="APOSTROPHE",e[e.TILDE=192]="TILDE",e[e.SINGLE_QUOTE=222]="SINGLE_QUOTE",e[e.OPEN_SQUARE_BRACKET=219]="OPEN_SQUARE_BRACKET",e[e.BACKSLASH=220]="BACKSLASH",e[e.CLOSE_SQUARE_BRACKET=221]="CLOSE_SQUARE_BRACKET",e[e.WIN_KEY=224]="WIN_KEY",e[e.MAC_FF_META=224]="MAC_FF_META",e[e.MAC_WK_CMD_LEFT=91]="MAC_WK_CMD_LEFT",e[e.MAC_WK_CMD_RIGHT=93]="MAC_WK_CMD_RIGHT",e[e.WIN_IME=229]="WIN_IME",e[e.VK_NONAME=252]="VK_NONAME",e[e.PHANTOM=255]="PHANTOM"})(P||(P={}));var Rt={};Rt.arc=Z,Rt.curve=ve,Rt.line=jo,Rt.lineOnAxis=v,Rt.lineTo=rt,Rt.moveBy=K,Rt.moveTo=ce,Rt.point=y;var X={};X.Coordinate=f,X.KeyCodes=P,X.Rect=D,X.Size=N,X.Svg=h,X.aria=ri,X.array=H$,X.browserEvents=yt,X.colour=Ge,X.deprecation=$p,X.dom=ue,X.extensions=Ye,X.idGenerator=ru,X.math=Kr,X.object=M$,X.parsing=$i,X.string=rs,X.style=Wt,X.svgMath=$o,X.svgPaths=Rt,X.toolbox=Ut,X.userAgent=Bm,X.xml=ts;var A=class{constructor(e,t){if(this.type=t,this.targetConnection=null,this.disposed=!1,this.shadowDom=this.check=null,this.y=this.x=0,this.shadowState=null,this.sourceBlock_=e,e.id.includes("_connection"))throw Error(`Connection ID indicator is contained in block ID. This will cause problems with focus: ${e.id}.`);this.id=`${e.id}_connection_${Le()}`}connect_(e){const t=E.INPUT_VALUE,o=this.getSourceBlock();var s=e.getSourceBlock();e.isConnected()&&e.disconnectInternal(!1);let i;if(this.isConnected()){const l=this.stashShadowState(),c=this.targetBlock();c.isShadow()?c.dispose(!1):(this.disconnectInternal(),i=c),this.applyShadowState(l)}let r;z()&&(r=new(w(a.BLOCK_MOVE))(s),r.setReason(["connect"])),Md(this,e),s.setParent(o),r&&(r.recordNew(),C(r)),i&&(e=this.type===t?i.outputConnection:i.previousConnection)&&((s=A.getConnectionForOrphanedConnection(s,e))?e.connect(s):e.onFailedConnect(this))}dispose(){if(this.isConnected()){this.isSuperior()&&this.setShadowStateInternal();const e=this.targetBlock();e&&!e.isDeadOrDying()&&e.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===E.INPUT_VALUE||this.type===E.NEXT_STATEMENT}isConnected(){return!!this.targetConnection}getConnectionChecker(){return this.sourceBlock_.workspace.connectionChecker}onFailedConnect(e){}connect(e){if(this.targetConnection===e)return!0;if(this.getConnectionChecker().canConnect(this,e,!1)){const t=n.getGroup$$module$build$src$core$events$utils();t||n.setGroup$$module$build$src$core$events$utils(!0),this.isSuperior()?this.connect_(e):e.connect_(this),n.setGroup$$module$build$src$core$events$utils(t)}return this.isConnected()}disconnect(){this.disconnectInternal()}disconnectInternal(e=!0){const{parentConnection:t,childConnection:o}=this.getParentAndChildConnections();if(!t||!o)throw Error("Source connection not connected.");const s=n.getGroup$$module$build$src$core$events$utils();s||n.setGroup$$module$build$src$core$events$utils(!0);let i;z()&&(i=new(w(a.BLOCK_MOVE))(o.getSourceBlock()),i.setReason(["disconnect"]));const r=this.targetConnection;r&&(r.targetConnection=null),this.targetConnection=null,e&&o.getSourceBlock().setParent(null),i&&(i.recordNew(),C(i)),o.getSourceBlock().isShadow()||t.respawnShadow_(),n.setGroup$$module$build$src$core$events$utils(s)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock(!0)}reconnect(e,t){if(this.getSourceBlock().isDeadOrDying())return!1;var o;return t=(o=e.getInput(t))==null?void 0:o.connection,o=this.targetBlock(),o&&o!==e||!t||t.targetConnection===this?!1:(t.isConnected()&&t.disconnect(),t.connect(this),!0)}targetBlock(){if(this.isConnected()){let e,t;return(t=(e=this.targetConnection)==null?void 0:e.getSourceBlock())!=null?t:null}return null}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return e?(Array.isArray(e)||(e=[e]),this.check=e,this.onCheckChanged_()):this.check=null,this}getCheck(){return this.check}setShadowDom(e){this.setShadowStateInternal({shadowDom:e})}getShadowDom(e){return e&&this.targetBlock().isShadow()?Ft(this.targetBlock()):this.shadowDom}setShadowState(e){this.setShadowStateInternal({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?Be(this.targetBlock()):this.shadowState}neighbours(e){return[]}getParentInput(){let e=null;const t=this.sourceBlock_.inputList;for(let o=0;o<t.length;o++)if(t[o].connection===this){e=t[o];break}return e}toString(){const e=this.sourceBlock_;if(!e)return"Orphan Connection";if(e.outputConnection===this)var t="Output Connection of ";else if(e.previousConnection===this)t="Previous Connection of ";else if(e.nextConnection===this)t="Next Connection of ";else{t=null;for(let o=0,s;s=e.inputList[o];o++)if(s.connection===this){t=s;break}if(t)t='Input "'+t.name+'" connection on ';else return console.warn("Connection not actually connected to sourceBlock_"),"Orphan Connection"}return t+e.toDevString()}stashShadowState(){const e=this.getShadowDom(!0),t=this.getShadowState(!0);return this.shadowState=this.shadowDom=null,{shadowDom:e,shadowState:t}}applyShadowState({shadowDom:e,shadowState:t}){this.shadowDom=e,this.shadowState=t}setShadowStateInternal({shadowDom:e=null,shadowState:t=null}={}){this.shadowDom=e,this.shadowState=t,this.getSourceBlock().isDeadOrDying()||((e=this.targetBlock())?e.isShadow()?(e.dispose(!1),this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())):(e=this.createShadowBlock(!1),this.serializeShadow(e),e&&e.dispose(!1)):(this.respawnShadow_(),this.targetBlock()&&this.targetBlock().isShadow()&&this.serializeShadow(this.targetBlock())))}createShadowBlock(e){var t=this.getSourceBlock();const o=this.getShadowState(),s=this.getShadowDom();if(t.isDeadOrDying()||!o&&!s)return null;if(o)return t=Go(o,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(s){if(t=uo(s,t.workspace),e)if(this.type===E.INPUT_VALUE){if(!t.outputConnection)throw Error("Shadow block is missing an output connection");if(!this.connect(t.outputConnection))throw Error("Could not connect shadow block to connection")}else if(this.type===E.NEXT_STATEMENT){if(!t.previousConnection)throw Error("Shadow block is missing previous connection");if(!this.connect(t.previousConnection))throw Error("Could not connect shadow block to connection")}else throw Error("Cannot connect a shadow block to a previous/output connection");return t}return null}serializeShadow(e){e&&(this.shadowDom=Ft(e),this.shadowState=Be(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===E.OUTPUT_VALUE)return Pd(e,t.getSourceBlock());e=e.lastConnectionInStack(!0);const o=t.getConnectionChecker();return e&&o.canConnect(t,e,!1)?e:null}};A.CAN_CONNECT=0,A.REASON_SELF_CONNECTION=1,A.REASON_WRONG_TYPE=2,A.REASON_TARGET_NULL=3,A.REASON_CHECKS_FAILED=4,A.REASON_DIFFERENT_WORKSPACES=5,A.REASON_SHADOW_PARENT=6,A.REASON_DRAG_CHECKS_FAILED=7,A.REASON_PREVIOUS_AND_OUTPUT=8;var Gp=class extends Error{constructor(e){super(`Tried to append an icon of type ${e.getType()} when an icon of that type already exists on the block. Use getIcon to access the existing icon.`),this.icon=e}},Vp={};Vp.DuplicateIconType=Gp,(function(e){e[e.LEFT=-1]="LEFT",e[e.CENTRE=0]="CENTRE",e[e.RIGHT=1]="RIGHT"})(n.Align$$module$build$src$core$inputs$align||(n.Align$$module$build$src$core$inputs$align={})),n.Align$$module$build$src$core$inputs$align;var Co=class extends L{constructor(e,t,o){super(L.SKIP_SETUP),this.class=null,this.EDITABLE=!1,this.maxDisplayLength=1/0,e!==L.SKIP_SETUP&&(o?this.configure_(o):this.class=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class=e.class)}initView(){this.createTextElement_(),this.class&&b(this.getTextElement(),this.class),this.fieldGroup_&&b(this.fieldGroup_,"blocklyLabelField")}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class&&O(this.textElement_,this.class),e&&b(this.textElement_,e)),this.class=e}static fromJson(e){return new this(J(e.text),void 0,e)}};it("field_label",Co),Co.prototype.DEFAULT_VALUE="";var Wp=30,wo=[];wo[E.INPUT_VALUE]=E.OUTPUT_VALUE,wo[E.OUTPUT_VALUE]=E.INPUT_VALUE,wo[E.NEXT_STATEMENT]=E.PREVIOUS_STATEMENT,wo[E.PREVIOUS_STATEMENT]=E.NEXT_STATEMENT;var Uu="RENAME_VARIABLE_ID",zu="DELETE_VARIABLE_ID",Up=10,ae=class extends A{constructor(e,t){super(e,t),this.highlighted=!1,this.targetConnection=null,this.db=e.workspace.connectionDBList[t],this.dbOpposite=e.workspace.connectionDBList[wo[t]],this.offsetInBlock=new f(0,0),this.trackedState=ae.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState===ae.TrackedState.TRACKED&&this.db.removeConnection(this,this.y);let e,t;(t=(e=this.sourceBlock_.pathObject).removeConnectionHighlight)==null||t.call(e,this)}getSourceBlock(){return super.getSourceBlock()}targetBlock(){return super.targetBlock()}distanceFrom(e){const t=this.x-e.x;return e=this.y-e.y,Math.sqrt(t*t+e*e)}bumpAwayFrom(e,t=!1){if(!this.sourceBlock_.workspace.isDragging()){var o=n.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*Up),s=n.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*Up),i=e.sourceBlock_.getRootBlock(),r=this.sourceBlock_.getRootBlock();if(!i.isInFlyout&&!r.isInFlyout){var l=!0;if(r.isMovable())i.isMovable()&&t&&(s=-s);else if(i.isMovable())l=!1,o=-o,s=-s;else return;t=l?e:this,e=l?this:e,i=l?r:i,i.RTL&&(o=-o),i.moveBy(t.x+o-e.x,t.y+s-e.y,["bump"])}}}moveTo(e,t){let o=!1;return this.trackedState===ae.TrackedState.WILL_TRACK?(this.db.addConnection(this,t),this.trackedState=ae.TrackedState.TRACKED,o=!0):this.trackedState===ae.TrackedState.TRACKED&&(this.db.removeConnection(this,this.y),this.db.addConnection(this,t),o=!0),this.x=e,this.y=t,o}moveBy(e,t){return this.moveTo(this.x+e,this.y+t)}moveToOffset(e){return this.moveTo(e.x+this.offsetInBlock.x,e.y+this.offsetInBlock.y)}setOffsetInBlock(e,t){this.offsetInBlock.x=e,this.offsetInBlock.y=t}getOffsetInBlock(){return this.offsetInBlock}tightenEfficiently(){var e=this.targetConnection;const t=this.targetBlock();e&&t&&(e=f.difference(this.offsetInBlock,e.offsetInBlock),t.translate(e.x,e.y))}closest(e,t){return this.dbOpposite.searchForClosest(this,e,t)}highlight(){this.highlighted=!0;const e=this.findHighlightSvg();e&&(e.style.display="")}unhighlight(){this.highlighted=!1;const e=this.findHighlightSvg();e&&(e.style.display="none")}isHighlighted(){return this.highlighted}setTracking(e){e&&this.trackedState===ae.TrackedState.TRACKED||!e&&this.trackedState===ae.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(e?(this.db.addConnection(this,this.y),this.trackedState=ae.TrackedState.TRACKED):(this.trackedState===ae.TrackedState.TRACKED&&this.db.removeConnection(this,this.y),this.trackedState=ae.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){const e=this.targetBlock().getDescendants(!1);for(let t=0;t<e.length;t++){const o=e[t],s=o.getConnections_(!0);for(let i=0;i<s.length;i++)s[i].setTracking(!1);for(const i of o.getIcons())ro(i)&&i.setBubbleVisible(!1)}}}startTrackingAll(){this.setTracking(!0);let e=[];if(this.type!==E.INPUT_VALUE&&this.type!==E.NEXT_STATEMENT)return e;const t=this.targetBlock();if(t){let o;t.isCollapsed()?(o=[],t.outputConnection&&o.push(t.outputConnection),t.nextConnection&&o.push(t.nextConnection),t.previousConnection&&o.push(t.previousConnection)):o=t.getConnections_(!0);for(let s=0;s<o.length;s++)e.push(...o[s].startTrackingAll());e.length||(e=[t])}return e}onFailedConnect(e){const t=this.getSourceBlock();if(we()){const o=n.getGroup$$module$build$src$core$events$utils();setTimeout((function(){t.isDisposed()||t.getParent()||(n.setGroup$$module$build$src$core$events$utils(o),this.bumpAwayFrom(e),n.setGroup$$module$build$src$core$events$utils(!1))}).bind(this),n.config$$module$build$src$core$config.bumpDelay)}}disconnectInternal(e=!0){const{parentConnection:t,childConnection:o}=this.getParentAndChildConnections();if(t&&o){var s=n.getGroup$$module$build$src$core$events$utils();s||n.setGroup$$module$build$src$core$events$utils(!0);var i=t.getSourceBlock(),r=o.getSourceBlock();super.disconnectInternal(e),i.queueRender(),r.updateDisabled(),r.queueRender(),r.getSvgRoot().style.display="block",n.setGroup$$module$build$src$core$events$utils(s)}}respawnShadow_(){super.respawnShadow_();const e=this.targetBlock();e&&(e.initSvg(),e.queueRender())}neighbours(e){return this.dbOpposite.getNeighbours(this,e)}connect_(e){super.connect_(e);var t=this.getSourceBlock();e=e.getSourceBlock(),t.updateDisabled(),e.updateDisabled(),e.queueRender(),(t=t.getInputWithBlock(e))&&(t=t.isVisible(),e.getSvgRoot().style.display=t?"block":"none")}onCheckChanged_(){!this.isConnected()||this.targetConnection&&this.getConnectionChecker().canConnect(this,this.targetConnection,!1)||(this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug()}setCheck(e){return super.setCheck(e),this.sourceBlock_.queueRender(),this}showContextMenu(e){const t=R.registry.getContextMenuOptions({focusedNode:this},e);if(t.length){var o=this.getSourceBlock(),s=o.workspace;if(e instanceof PointerEvent)var i=new f(e.clientX,e.clientY);else i=new f(this.x,this.y),i=Lo(s,i).translate(o.RTL?-5:5,5);Yo(e,t,o.RTL,s,i)}}getFocusableElement(){const e=this.findHighlightSvg();if(e)return e;throw Error("No highlight SVG found corresponding to this connection.")}getFocusableTree(){return this.getSourceBlock().workspace}onNodeFocus(){this.highlight()}onNodeBlur(){this.unhighlight()}canBeFocused(){return!0}findHighlightSvg(){return document.getElementById(this.id)}};(function(e){e=e.TrackedState||(e.TrackedState={}),e[e.WILL_TRACK=-1]="WILL_TRACK",e[e.UNTRACKED=0]="UNTRACKED",e[e.TRACKED=1]="TRACKED"})(ae||(ae={})),ae.TrackedState;var ds=class{constructor(e,t){this.name=e,this.sourceBlock=t,this.fieldRow=[],this.align=n.Align$$module$build$src$core$inputs$align.LEFT,this.visible=!0,this.type=n.inputTypes$$module$build$src$core$inputs$input_types.CUSTOM,this.connection=null}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,o){if(e<0||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return(t||t===""&&o)&&(typeof t=="string"&&(t=n.fromJson$$module$build$src$core$field_registry({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.initialized&&this.initField(t),t.name=o,t.setVisible(this.isVisible()),t.prefixField&&(e=this.insertFieldAt(e,t.prefixField)),this.fieldRow.splice(e,0,t),e++,t.suffixField&&(e=this.insertFieldAt(e,t.suffixField)),this.sourceBlock.rendered&&this.sourceBlock.queueRender()),e}removeField(e,t){for(let o=0,s;s=this.fieldRow[o];o++)if(s.name===e)return s.dispose(),this.fieldRow.splice(o,1),this.sourceBlock.rendered&&this.sourceBlock.queueRender(),!0;if(t)return!1;throw Error('Field "'+e+'" not found.')}isVisible(){return this.visible}setVisible(e){let t=[];if(this.visible===e)return t;this.visible=e;for(let o=0,s;s=this.fieldRow[o];o++)s.setVisible(e);if(this.connection&&this.connection instanceof ae){e?t=this.connection.startTrackingAll():this.connection.stopTrackingAll();const o=this.connection.targetBlock();o&&(o.getSvgRoot().style.display=e?"block":"none")}return t}markDirty(){for(let e=0,t;t=this.fieldRow[e];e++)t.markDirty()}setCheck(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setCheck(e),this}setAlign(e){return this.align=e,this.sourceBlock.rendered&&this.sourceBlock.queueRender(),this}setShadowDom(e){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.setShadowDom(e),this}getShadowDom(){if(!this.connection)throw Error("This input does not have a connection.");return this.connection.getShadowDom()}init(){for(const e of this.fieldRow)e.init()}initModel(){for(const e of this.fieldRow)e.initModel()}initField(e){this.sourceBlock.rendered?e.init():e.initModel()}dispose(){for(let e=0,t;t=this.fieldRow[e];e++)t.dispose();this.connection&&this.connection.dispose()}makeConnection(e){return this.sourceBlock.makeConnection_(e)}},ht=class extends ds{constructor(e,t){super(e,t),this.name=e,this.type=n.inputTypes$$module$build$src$core$inputs$input_types.DUMMY}},Dt=class extends ds{constructor(e,t){super(e,t),this.name=e,this.type=n.inputTypes$$module$build$src$core$inputs$input_types.END_ROW}},Ae=class extends ds{constructor(e,t){if(!e)throw Error("Statement inputs must have a non-empty name");super(e,t),this.name=e,this.type=n.inputTypes$$module$build$src$core$inputs$input_types.STATEMENT,this.connection=this.makeConnection(E.NEXT_STATEMENT)}},zp;n.ValueInput$$module$build$src$core$inputs$value_input=class extends ds{constructor(e,t){if(!e)throw Error("Value inputs must have a non-empty name");super(e,t),this.name=e,this.type=n.inputTypes$$module$build$src$core$inputs$input_types.VALUE,this.connection=this.makeConnection(E.INPUT_VALUE)}},zp={},zp.ValueInput=n.ValueInput$$module$build$src$core$inputs$value_input;var $s=class{constructor(e,t,o){if(this.data=null,this.disposed=!1,this.hue=null,this.colour_="#000000",this.styleName_="",this.suppressPrefixSuffix=!1,this.previousConnection=this.nextConnection=this.outputConnection=null,this.inputList=[],this.icons=[],this.disabledReasons=new Set,this.tooltip="",this.contextMenu=!0,this.parentBlock_=null,this.childBlocks_=[],this.editable=this.movable=this.deletable=!0,this.collapsed_=this.shadow=!1,this.outputShape_=null,this.rendered=this.isInsertionMarker_=this.initialized=this.disposing=!1,this.onchangeWrapper=this.helpUrl=null,this.statementInputCount=0,this.workspace=e,this.id=o&&!e.getBlockById(o)?o:_t(),e.setBlockById(this.id,this),this.xy=new f(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,o=W[t],!o||typeof o!="object")throw TypeError("Invalid block definition for type: "+t);Object.assign(this,o)}e.addTopBlock(this),e.addTypedBlock(this),new.target===$s&&this.doInit_()}doInit_(){const e=n.getGroup$$module$build$src$core$events$utils();e||n.setGroup$$module$build$src$core$events$utils(!0);const t=we();try{typeof this.init=="function"&&(n.setRecordUndo$$module$build$src$core$events$utils(!1),this.init(),n.setRecordUndo$$module$build$src$core$events$utils(t)),z()&&C(new(w(a.BLOCK_CREATE))(this))}finally{n.setGroup$$module$build$src$core$events$utils(e),n.setRecordUndo$$module$build$src$core$events$utils(t)}this.inputsInlineDefault=this.inputsInline,typeof this.onchange=="function"&&this.setOnChange(this.onchange)}dispose(e=!1){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.unplug(e),z()&&C(new(w(a.BLOCK_DELETE))(this)),this.workspace.removeTopBlock(this),this.disposeInternal()}disposeInternal(){this.disposing=!0,this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.workspace.removeTypedBlock(this),this.workspace.removeBlockById(this.id),typeof this.destroy=="function"&&this.destroy(),this.childBlocks_.forEach(e=>e.disposeInternal()),this.inputList.forEach(e=>e.dispose()),this.inputList.length=0,this.getConnections_(!0).forEach(e=>e.dispose()),this.disposed=!0}isDeadOrDying(){return this.disposing||this.disposed}initModel(){if(!this.initialized){for(const e of this.inputList)e.initModel();this.initialized=!0}}unplug(e){this.outputConnection&&this.unplugFromRow(e),this.previousConnection&&this.unplugFromStack(e)}unplugFromRow(e){let t=null,o;(o=this.outputConnection)!=null&&o.isConnected()&&(t=this.outputConnection.targetConnection,this.outputConnection.disconnect()),t&&e&&(e=this.getOnlyValueConnection())&&e.isConnected()&&!e.targetBlock().isShadow()&&(e=e.targetConnection,e?.disconnect(),this.workspace.connectionChecker.canConnect(e,t,!1)?t.connect(e):e?.onFailedConnect(t))}getOnlyValueConnection(){let e=null;for(let t=0;t<this.inputList.length;t++){const o=this.inputList[t].connection;if(o&&o.type===E.INPUT_VALUE&&o.targetConnection){if(e)return null;e=o}}return e}unplugFromStack(e){let t=null;var o;if((o=this.previousConnection)!=null&&o.isConnected()&&(t=this.previousConnection.targetConnection,this.previousConnection.disconnect()),o=this.getNextBlock(),e&&o&&!o.isShadow()){let s,i;e=(i=(s=this.nextConnection)==null?void 0:s.targetConnection)!=null?i:null,e?.disconnect(),t&&this.workspace.connectionChecker.canConnect(t,e,!1)&&t.connect(e)}}getConnections_(e){e=[],this.outputConnection&&e.push(this.outputConnection),this.previousConnection&&e.push(this.previousConnection),this.nextConnection&&e.push(this.nextConnection);for(let t=0,o;o=this.inputList[t];t++)o.connection&&e.push(o.connection);return e}lastConnectionInStack(e){let t=this.nextConnection;for(;t;){const o=t.targetBlock();if(!o||e&&o.isShadow())return t;t=o.nextConnection}return null}bumpNeighbours(){}getParent(){return this.parentBlock_}getInputWithBlock(e){for(let t=0,o;o=this.inputList[t];t++)if(o.connection&&o.connection.targetBlock()===e)return o;return null}getSurroundParent(){let e=this,t;do if(t=e,e=e.getParent(),!e)return null;while(e.getNextBlock()===t);return e}getNextBlock(){return this.nextConnection&&this.nextConnection.targetBlock()}getPreviousBlock(){return this.previousConnection&&this.previousConnection.targetBlock()}getRootBlock(){let e,t=this;do e=t,t=e.parentBlock_;while(t);return e}getTopStackBlock(){let e=this,t;do t=e.getPreviousBlock();while(t&&t.getNextBlock()===e&&(e=t));return e}getChildren(e){if(!e)return this.childBlocks_;e=[];for(let o=0,s;s=this.inputList[o];o++)if(s.connection){var t=s.connection.targetBlock();t&&e.push(t)}return(t=this.getNextBlock())&&e.push(t),e}setParent(e){if(e!==this.parentBlock_){var t=this.previousConnection&&this.previousConnection.targetBlock()||this.outputConnection&&this.outputConnection.targetBlock(),o=!!t;if(o&&e&&t!==e)throw Error("Block connected to superior one that is not new parent.");if(!o&&e)throw Error("Block not connected to new parent.");if(o&&!e)throw Error("Cannot set parent to null while block is still connected to superior block.");this.parentBlock_?ke(this.parentBlock_.childBlocks_,this):this.workspace.removeTopBlock(this),(this.parentBlock_=e)?e.childBlocks_.push(this):this.workspace.addTopBlock(this)}}getDescendants(e){const t=[this],o=this.getChildren(e);for(let s,i=0;s=o[i];i++)t.push(...s.getDescendants(e));return t}isDeletable(){return this.deletable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnDeletable(){return this.deletable}setDeletable(e){this.deletable=e}isMovable(){return this.movable&&!this.isInFlyout&&!this.shadow&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnMovable(){return this.movable}setMovable(e){this.movable=e}isDuplicatable(){return this.workspace.hasBlockLimits()?this.workspace.isCapacityAvailable(Ds(this,!0)):!0}isShadow(){return this.shadow}setShadow(e){this.shadow=e}isInsertionMarker(){return this.isInsertionMarker_}setInsertionMarker(e){this.isInsertionMarker_=e}isEditable(){return this.editable&&!this.isDeadOrDying()&&!this.workspace.isReadOnly()}isOwnEditable(){return this.editable}setEditable(e){this.editable=e;for(const t of this.getFields())t.updateEditable()}isDisposed(){return this.disposed}isSimpleReporter(){if(!this.outputConnection)return!1;for(const e of this.inputList)if(e.connection||e.fieldRow.length>1)return!1;return!0}getMatchingConnection(e,t){const o=this.getConnections_(!0);if(e=e.getConnections_(!0),o.length!==e.length)throw Error("Connection lists did not match in length.");for(let s=0;s<e.length;s++)if(e[s]===t)return o[s];return null}setHelpUrl(e){this.helpUrl=e}setTooltip(e){this.tooltip=e}getTooltip(){return Wo(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue}setColour(e){e=Uo(e),this.hue=e.hue,this.colour_=e.hex}setStyle(e){this.styleName_=e}setOnChange(e){if(e&&typeof e!="function")throw Error("onchange must be a function.");this.onchangeWrapper&&this.workspace.removeChangeListener(this.onchangeWrapper),this.onchange=e,this.onchangeWrapper=e.bind(this),this.workspace.addChangeListener(this.onchangeWrapper)}getField(e){if(typeof e!="string")throw TypeError("Block.prototype.getField expects a string with the field name but received "+(e===void 0?"nothing":e+" of type "+typeof e)+" instead");for(const t of this.getFields())if(t.name===e)return t;return null}*getFields(){for(const e of this.inputList)for(const t of e.fieldRow)yield t}getVars(){const e=[];for(const t of this.getFields())t.referencesVariables()&&e.push(t.getValue());return e}getVarModels(){const e=[];for(const t of this.getFields())if(t.referencesVariables()){const o=this.workspace.getVariableById(t.getValue());o&&e.push(o)}return e}updateVarName(e){for(const t of this.getFields())t.referencesVariables()&&e.getId()===t.getValue()&&t.refreshVariableName()}renameVarById(e,t){for(const o of this.getFields())o.referencesVariables()&&e===o.getValue()&&o.setValue(t)}getFieldValue(e){return(e=this.getField(e))?e.getValue():null}setFieldValue(e,t){const o=this.getField(t);if(!o)throw Error('Field "'+t+'" not found.');o.setValue(e)}setPreviousStatement(e,t){if(e)t===void 0&&(t=null),this.previousConnection||(this.previousConnection=this.makeConnection_(E.PREVIOUS_STATEMENT)),this.previousConnection.setCheck(t);else if(this.previousConnection){if(this.previousConnection.isConnected())throw Error("Must disconnect previous statement before removing connection.");this.previousConnection.dispose(),this.previousConnection=null}}setNextStatement(e,t){if(e)t===void 0&&(t=null),this.nextConnection||(this.nextConnection=this.makeConnection_(E.NEXT_STATEMENT)),this.nextConnection.setCheck(t);else if(this.nextConnection){if(this.nextConnection.isConnected())throw Error("Must disconnect next statement before removing connection.");this.nextConnection.dispose(),this.nextConnection=null}}setOutput(e,t){if(e)t===void 0&&(t=null),this.outputConnection||(this.outputConnection=this.makeConnection_(E.OUTPUT_VALUE)),this.outputConnection.setCheck(t);else if(this.outputConnection){if(this.outputConnection.isConnected())throw Error("Must disconnect output value before removing connection.");this.outputConnection.dispose(),this.outputConnection=null}}setInputsInline(e){this.inputsInline!==e&&(C(new(w(a.BLOCK_CHANGE))(this,"inline",null,this.inputsInline,e)),this.inputsInline=e)}getInputsInline(){if(this.inputsInline!==void 0)return this.inputsInline;for(var e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof ht&&this.inputList[e]instanceof ht)return!1;for(e=1;e<this.inputList.length;e++)if(this.inputList[e-1]instanceof n.ValueInput$$module$build$src$core$inputs$value_input&&this.inputList[e]instanceof ht)return!0;for(e=0;e<this.inputList.length;e++)if(this.inputList[e]instanceof Dt)return!0;return!1}setOutputShape(e){this.outputShape_=e}getOutputShape(){return this.outputShape_}isEnabled(){return this.disabledReasons.size===0}setDisabledReason(e,t){e||this.workspace.options.disable||!this.hasDisabledReason(Fe)||t==Fe||this.setDisabledReason(!1,Fe),this.disabledReasons.has(t)!==e&&(e?this.disabledReasons.add(t):this.disabledReasons.delete(t),e=new(w(a.BLOCK_CHANGE))(this,"disabled",null,!e,e),e.setDisabledReason(t),C(e))}getInheritedDisabled(){let e=this.getSurroundParent();for(;e;){if(!e.isEnabled())return!0;e=e.getSurroundParent()}return!1}hasDisabledReason(e){return this.disabledReasons.has(e)}getDisabledReasons(){return this.disabledReasons}isCollapsed(){return this.collapsed_}setCollapsed(e){this.collapsed_!==e&&(C(new(w(a.BLOCK_CHANGE))(this,"collapsed",null,this.collapsed_,e)),this.collapsed_=e)}toString(e,t){t=this.toTokens(t);for(let s=2;s<t.length;s++)t[s-2]==="("&&t[s]===")"&&(t[s-2]=t[s-1],t.splice(s-1,2));let o="";return t=t.reduce((s,i)=>(s=s+(o==="("||i===")"?"":" ")+i,o=i[i.length-1],s),""),t=t.trim()||"???",e&&t.length>e&&(t=t.substring(0,e-3)+"..."),t}toTokens(e="?"){const t=[];for(const s of this.inputList)if(s.name!=ni){for(const i of s.fieldRow)t.push(i.getText());if(s.connection){const i=s.connection.targetBlock();if(i){var o=s.connection;let r=o.getCheck();!r&&o.targetConnection&&(r=o.targetConnection.getCheck()),(o=!!r&&(r.includes("Boolean")||r.includes("Number")))&&t.push("("),t.push(...i.toTokens(e)),o&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput(new n.ValueInput$$module$build$src$core$inputs$value_input(e,this))}appendStatementInput(e){return this.statementInputCount++,this.appendInput(new Ae(e,this))}appendDummyInput(e=""){return this.appendInput(new ht(e,this))}appendEndRowInput(e=""){return this.appendInput(new Dt(e,this))}appendInput(e){return this.inputList.push(e),e}appendInputFromRegistry(e,t){return(e=Ve(g.INPUT,e,!1))?this.appendInput(new e(t,this)):null}jsonInit(e){var t=e.type?'Block "'+e.type+'": ':"";if(e.output&&e.previousStatement)throw Error(t+"Must not have both an output and a previousStatement.");for(var o=0;e["args"+o];){if(e["message"+o]===void 0)throw Error(t+`args${o} must have a corresponding message (message${o}).`);o++}if(e.style&&e.style.hat&&(this.hat=e.style.hat,e.style=null),e.style&&e.colour)throw Error(t+"Must not have both a colour and a style.");for(e.style?this.jsonInitStyle(e,t):this.jsonInitColour(e,t),o=0;e["message"+o]!==void 0;)this.interpolate(e["message"+o],e["args"+o]||[],e["implicitAlign"+o]||e["lastDummyAlign"+o],t),o++;if(e.inputsInline!==void 0&&(n.disable$$module$build$src$core$events$utils(),this.setInputsInline(e.inputsInline),n.enable$$module$build$src$core$events$utils()),e.output!==void 0&&this.setOutput(!0,e.output),e.outputShape!==void 0&&this.setOutputShape(e.outputShape),e.previousStatement!==void 0&&this.setPreviousStatement(!0,e.previousStatement),e.nextStatement!==void 0&&this.setNextStatement(!0,e.nextStatement),e.tooltip!==void 0&&(o=J(e.tooltip),this.setTooltip(o)),e.enableContextMenu!==void 0&&(this.contextMenu=!!e.enableContextMenu),e.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!e.suppressPrefixSuffix),e.helpUrl!==void 0&&(o=J(e.helpUrl),this.setHelpUrl(o)),typeof e.extensions=="string"&&(console.warn(t+"JSON attribute 'extensions' should be an array of strings. Found raw string in JSON for '"+e.type+"' block."),e.extensions=[e.extensions]),e.mutator!==void 0&&fr(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;t<e.length;t++)fr(e[t],this,!1)}jsonInitColour(e,t){if("colour"in e)if(e.colour===void 0)console.warn(t+"Undefined colour value.");else{e=e.colour;try{this.setColour(e)}catch{console.warn(t+"Illegal colour value: ",e)}}}jsonInitStyle(e,t){e=e.style;try{this.setStyle(e)}catch{console.warn(t+"Style does not exist: ",e)}}mixin(e,t){if(t!==void 0&&typeof t!="boolean")throw Error("opt_disableCheck must be a boolean if provided");if(!t){t=[];for(const o in e)this[o]!==void 0&&t.push(o);if(t.length)throw Error("Mixin will overwrite block members: "+JSON.stringify(t))}Object.assign(this,e)}interpolate(e,t,o,s){e=Gl(e),this.validateTokens(e,t.length),t=this.interpolateArguments(e,t,o),o=[];for(let i=0,r;r=t[i];i++)if(this.isInputKeyword(r.type)){if(e=this.inputFromJson(r,s)){for(let l=0,c;c=o[l];l++)e.appendField(c[0],c[1]);o.length=0}}else(e=this.fieldFromJson(r))&&o.push([e,r.name])}validateTokens(e,t){const o=[];let s=0;for(let i=0;i<e.length;i++){const r=e[i];if(typeof r=="number"){if(r<1||r>t)throw Error('Block "'+this.type+'": Message index %'+r+" out of range.");if(o[r])throw Error('Block "'+this.type+'": Message index %'+r+" duplicated.");o[r]=!0,s++}}if(s!==t)throw Error('Block "'+this.type+'": Message does not reference all '+t+" arg(s).")}interpolateArguments(e,t,o){const s=[];for(let r=0;r<e.length;r++){var i=e[r];if(typeof i=="number"&&(i=t[i-1]),typeof i=="string"){if(i===`
|
|
621
|
+
`)i={type:"input_end_row"},o&&(i.align=o);else if(i=this.stringToFieldJson(i),!i)continue}s.push(i)}return(e=s.length)&&!this.isInputKeyword(s[e-1].type)&&(e={type:"input_dummy"},o&&(e.align=o),s.push(e)),s}fieldFromJson(e){const t=n.fromJson$$module$build$src$core$field_registry(e);return!t&&e.alt?typeof e.alt=="string"?(e=this.stringToFieldJson(e.alt))?this.fieldFromJson(e):null:this.fieldFromJson(e.alt):t}inputFromJson(e,t){var o={LEFT:n.Align$$module$build$src$core$inputs$align.LEFT,RIGHT:n.Align$$module$build$src$core$inputs$align.RIGHT,CENTRE:n.Align$$module$build$src$core$inputs$align.CENTRE,CENTER:n.Align$$module$build$src$core$inputs$align.CENTRE};let s;switch(e.type){case"input_value":s=this.appendValueInput(e.name);break;case"input_statement":s=this.appendStatementInput(e.name);break;case"input_dummy":s=this.appendDummyInput(e.name);break;case"input_end_row":s=this.appendEndRowInput(e.name);break;default:s=this.appendInputFromRegistry(e.type,e.name)}return s?(e.check&&s.setCheck(e.check),e.align&&(o=o[e.align.toUpperCase()],o===void 0?console.warn(t+"Illegal align value: ",e.align):s.setAlign(o)),s):null}isInputKeyword(e){return e==="input_value"||e==="input_statement"||e==="input_dummy"||e==="input_end_row"||Ri(g.INPUT,e)}stringToFieldJson(e){return(e=e.trim())?{type:"field_label",text:e}:null}moveInputBefore(e,t){if(e!==t){var o=-1,s=t?-1:this.inputList.length;for(let i=0,r;r=this.inputList[i];i++)if(r.name===e){if(o=i,s!==-1)break}else if(t&&r.name===t&&(s=i,o!==-1))break;if(o===-1)throw Error('Named input "'+e+'" not found.');if(s===-1)throw Error('Reference input "'+t+'" not found.');this.moveNumberedInputBefore(o,s)}}moveNumberedInputBefore(e,t){if(e===t)throw Error("Can't move input to itself.");if(e>=this.inputList.length)throw RangeError("Input index "+e+" out of bounds.");if(t>this.inputList.length)throw RangeError("Reference input "+t+" out of bounds.");const o=this.inputList[e];this.inputList.splice(e,1),e<t&&t--,this.inputList.splice(t,0,o)}removeInput(e,t){for(let o=0,s;s=this.inputList[o];o++)if(s.name===e)return s instanceof Ae&&this.statementInputCount--,s.dispose(),this.inputList.splice(o,1),!0;if(t)return!1;throw Error("Input not found: "+e)}getInput(e){for(let t=0,o;o=this.inputList[t];t++)if(o.name===e)return o;return null}getInputTargetBlock(e){return(e=this.getInput(e))&&e.connection&&e.connection.targetBlock()}getCommentText(){let e,t;return(t=(e=this.getIcon(se.COMMENT))==null?void 0:e.getText())!=null?t:null}setCommentText(e){var t;let o;const s=(o=(t=this.getIcon(se.COMMENT))==null?void 0:t.getText())!=null?o:null;if(s!==e){if(e!==null){if(t=this.getIcon(se.COMMENT),!t){if(t=Ve(g.ICON,se.COMMENT.toString(),!1),!t)throw Error("No comment icon class is registered, so a comment cannot be set");if(t=new t(this),!Fd(t))throw Error("The class registered as a comment icon does not conform to the ICommentIcon interface");t=this.addIcon(t)}n.disable$$module$build$src$core$events$utils(),t.setText(e),n.enable$$module$build$src$core$events$utils()}else this.removeIcon(se.COMMENT);C(new(w(a.BLOCK_CHANGE))(this,"comment",null,s,e))}}setWarningText(e,t){}setMutator(e){}addIcon(e){if(this.hasIcon(e.getType()))throw new Gp(e);return this.icons.push(e),this.icons.sort((t,o)=>t.getWeight()-o.getWeight()),e}removeIcon(e){if(!this.hasIcon(e))return!1;let t;return(t=this.getIcon(e))==null||t.dispose(),this.icons=this.icons.filter(o=>!o.getType().equals(e)),!0}hasIcon(e){return this.icons.some(t=>t.getType().equals(e))}getIcon(e){return e instanceof se?this.icons.find(t=>t.getType().equals(e)):this.icons.find(t=>t.getType().toString()===e)}getIcons(){return[...this.icons]}getRelativeToSurfaceXY(){return this.xy}moveBy(e,t,o){if(this.parentBlock_)throw Error("Block has parent");const s=new(w(a.BLOCK_MOVE))(this);o&&s.setReason(o),this.xy.translate(e,t),s.recordNew(),C(s)}makeConnection_(e){return new A(this,e)}allInputsFilled(e){if(e===void 0&&(e=!0),!e&&this.isShadow())return!1;for(let o=0,s;s=this.inputList[o];o++)if(s.connection){var t=s.connection.targetBlock();if(!t||!t.allInputsFilled(e))return!1}return(t=this.getNextBlock())?t.allInputsFilled(e):!0}toDevString(){let e=this.type?'"'+this.type+'" block':"Block";return this.id&&(e+=' (id="'+this.id+'")'),e}};$s.COLLAPSED_INPUT_NAME=ni,$s.COLLAPSED_FIELD_NAME=zr;var $n=null,mi=null,fi={};fi.connectionUiEffect=lc,fi.disconnectUiEffect=cc,fi.disconnectUiStop=Jo,fi.disposeUiEffect=Er;var bi=class{paste(e,t,o){if(!t.isCapacityAvailable(e.typeCounts))return null;o&&(e.blockState.x=o.x,e.blockState.y=o.y),o=o||new f(e.blockState.x||0,e.blockState.y||0),n.disable$$module$build$src$core$events$utils();let s;try{s=Pt(e.blockState,t),Hd(s,o)}finally{n.enable$$module$build$src$core$events$utils()}if(!s)return s;z()&&!s.isShadow()&&C(new(w(a.BLOCK_CREATE))(s));const i=s;return tt().then(()=>n.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)),s}};bi.TYPE="block",Ki(bi.TYPE,new bi);var pn={};pn.bumpIntoBounds=Zo,pn.bumpIntoBoundsHandler=hc,pn.bumpTopObjectsIntoBounds=Tr;var Xp=class{constructor(e){this.block=e,this.connectionPreviewer=this.connectionCandidate=this.startLoc=this.startChildConn=this.startParentConn=null,this.dragging=!1,this.dragOffset=new f(0,0),this.originalEventGroup="",this.workspace=e.workspace}isMovable(){if(this.block.isShadow()){let e,t;return(t=(e=this.block.getParent())==null?void 0:e.isMovable())!=null?t:!1}return this.block.isOwnMovable()&&!this.block.isDeadOrDying()&&!this.workspace.isReadOnly()&&!this.block.isInFlyout}startDrag(e){if(this.block.isShadow())this.startDraggingShadow(e);else{this.dragging=!0,this.fireDragStartEvent(),this.startLoc=this.block.getRelativeToSurfaceXY(),this.connectionCandidate=null,this.connectionPreviewer=new(_e(g.CONNECTION_PREVIEWER,this.workspace.options))(this.block),eo(),this.workspace.setResizesEnabled(!1),Jo(),e=this.shouldHealStack(e),this.shouldDisconnect(e)&&this.disconnectBlock(e),this.block.setDragging(!0);var t;(t=this.workspace.getLayerManager())==null||t.moveToDragLayer(this.block)}}shouldHealStack(e){return!!e&&(e.altKey||e.ctrlKey||e.metaKey)}startDraggingShadow(e){const t=this.block.getParent();if(!t)throw Error("Tried to drag a shadow block with no parent. Shadow blocks should always have parents.");this.dragOffset=f.difference(t.getRelativeToSurfaceXY(),this.block.getRelativeToSurfaceXY()),t.startDrag(e)}shouldDisconnect(e){return!!(this.block.getParent()||e&&this.block.nextConnection&&this.block.nextConnection.targetBlock())}disconnectBlock(e){let t,o,s;if(this.startParentConn=(s=(t=this.block.outputConnection)==null?void 0:t.targetConnection)!=null?s:(o=this.block.previousConnection)==null?void 0:o.targetConnection,e){let i;this.startChildConn=(i=this.block.nextConnection)==null?void 0:i.targetConnection}this.block.unplug(e),cc(this.block)}fireDragStartEvent(){const e=new(w(a.BLOCK_DRAG))(this.block,!0,this.block.getDescendants(!1));C(e)}fireDragEndEvent(){const e=new(w(a.BLOCK_DRAG))(this.block,!1,this.block.getDescendants(!1));C(e)}fireMoveEvent(){if(!this.block.isDeadOrDying()){var e=new(w(a.BLOCK_MOVE))(this.block);e.setReason(["drag"]),e.oldCoordinate=this.startLoc,e.recordNew(),C(e)}}drag(e){if(this.block.isShadow()){let t;(t=this.block.getParent())==null||t.drag(f.sum(e,this.dragOffset))}else this.block.moveDuringDrag(e),this.updateConnectionPreview(this.block,f.difference(e,this.startLoc))}updateConnectionPreview(e,t){var o=this.connectionCandidate;const s=this.getConnectionCandidate(e,t);if(s){this.connectionCandidate=t=o&&this.currCandidateIsBetter(o,t,s)?o:s;var{local:i,neighbour:r}=t;t=i.type===E.OUTPUT_VALUE||i.type===E.PREVIOUS_STATEMENT;var l;if(o=r.isConnected()&&!((l=r.targetBlock())!=null&&l.isInsertionMarker()),t&&o&&!this.orphanCanConnectAtEnd(e,r.targetBlock(),i.type)){let p;(p=this.connectionPreviewer)==null||p.previewReplacement(i,r,r.targetBlock())}else{var c;(c=this.connectionPreviewer)==null||c.previewConnection(i,r)}}else{let p;(p=this.connectionPreviewer)==null||p.hidePreview(),this.connectionCandidate=null}}orphanCanConnectAtEnd(e,t,o){return!!A.getConnectionForOrphanedConnection(e,o===E.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}currCandidateIsBetter(e,t,o){const{local:s,neighbour:i}=e;e=new f(s.x,s.y);const r=new f(i.x,i.y);return t=f.distance(f.sum(e,t),r),o.distance>t-n.config$$module$build$src$core$config.currentConnectionPreference}getConnectionCandidate(e,t){e=this.getLocalConnections(e);let o=this.getSearchRadius(),s=null;for(const i of e){const{connection:r,radius:l}=i.closest(o,t);r&&(s={local:i,neighbour:r,distance:l},o=l)}return s}getSearchRadius(){return this.connectionCandidate?n.config$$module$build$src$core$config.connectingSnapRadius:n.config$$module$build$src$core$config.snapRadius}getLocalConnections(e){const t=e.getConnections_(!1),o=e.lastConnectionInStack(!0);return o&&o!==e.nextConnection&&t.push(o),t}endDrag(e){if(this.block.isShadow()){let o;(o=this.block.getParent())==null||o.endDrag(e)}else{this.originalEventGroup=n.getGroup$$module$build$src$core$events$utils(),this.fireDragEndEvent(),this.fireMoveEvent(),to(),Jo();var t;if((t=this.connectionPreviewer)==null||t.hidePreview(),!this.block.isDeadOrDying()&&this.dragging){let o;(o=this.workspace.getLayerManager())==null||o.moveOffDragLayer(this.block,Yt),this.block.setDragging(!1)}this.connectionCandidate?(this.applyConnections(this.connectionCandidate),this.disposeStep()):this.block.queueRender().then(()=>this.disposeStep())}}disposeStep(){const e=n.getGroup$$module$build$src$core$events$utils();n.setGroup$$module$build$src$core$events$utils(this.originalEventGroup),this.block.snapToGrid();let t;(t=this.connectionPreviewer)==null||t.dispose(),this.workspace.setResizesEnabled(!0),n.setGroup$$module$build$src$core$events$utils(e)}applyConnections(e){const{local:t,neighbour:o}=e;t.connect(o);const s=t.isSuperior()?o:t,i=this.block.getRootBlock();tt().then(()=>{lc(s.getSourceBlock()),setTimeout(()=>{i.bringToFront()},0)})}revertDrag(){if(this.block.isShadow()){let o;(o=this.block.getParent())==null||o.revertDrag()}else{var e;(e=this.connectionPreviewer)==null||e.hidePreview(),this.connectionCandidate=null;var t;if((t=this.startChildConn)==null||t.connect(this.block.nextConnection),this.startParentConn)switch(this.startParentConn.type){case E.INPUT_VALUE:this.startParentConn.connect(this.block.outputConnection);break;case E.NEXT_STATEMENT:this.startParentConn.connect(this.block.previousConnection)}else{this.block.moveTo(this.startLoc,["drag"]);let o;(o=this.workspace.getLayerManager())==null||o.moveOffDragLayer(this.block,Yt),Zo(this.workspace,this.workspace.getMetricsManager().getScrollMetrics(!0),this.block)}this.startParentConn=this.startChildConn=null,this.block.setDragging(!1),this.dragging=!1}}},Yp=class extends M{constructor(e,t,o,s){super(t,o,s),this.text=e,this.workspace=t,this.anchor=o,this.ownerRect=s,this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize(),b(this.svgRoot,"blocklyTextBubble")}getText(){return this.text}setText(e){this.text=e,F(this.paragraph),this.paragraph=this.stringToSvg(e,this.contentContainer),this.updateBubbleSize()}stringToSvg(e,t){return t=this.createParagraph(t),e=this.createTextFragments(t,e),this.workspace.RTL&&this.rightAlignTextFragments(t.getBBox().width,e),t}createParagraph(e){return m(h.G,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",transform:`translate(0,${M.BORDER_WIDTH})`,style:`direction: ${this.workspace.RTL?"rtl":"ltr"}`},e)}createTextFragments(e,t){let o=1;return t.split(`
|
|
622
|
+
`).map(s=>{const i=m(h.TEXT,{y:`${o}em`,x:M.BORDER_WIDTH},e);return s=document.createTextNode(s),i.appendChild(s),o+=1,i})}rightAlignTextFragments(e,t){for(const o of t)o.setAttribute("text-anchor","start"),o.setAttribute("x",`${e+M.BORDER_WIDTH}`)}updateBubbleSize(){const e=this.paragraph.getBBox();this.setSize(new N(e.width+M.BORDER_WIDTH*2,e.height+M.BORDER_WIDTH*2),!0)}},Xu=17,at=class extends gi{constructor(e){super(e),this.sourceBlock=e,this.textMap=new Map,this.textBubble=null}getType(){return at.TYPE}initView(e){this.svgRoot||(super.initView(e),m(h.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),m(h.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},this.svgRoot),m(h.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},this.svgRoot),b(this.svgRoot,"blocklyWarningIcon"))}dispose(){super.dispose();let e;(e=this.textBubble)==null||e.dispose()}getWeight(){return at.WEIGHT}getSize(){return new N(Xu,Xu)}applyColour(){super.applyColour();let e;(e=this.textBubble)==null||e.setColour(this.sourceBlock.getColour())}updateCollapsed(){}isShownWhenCollapsed(){return!0}onLocationChange(e){super.onLocationChange(e);let t;(t=this.textBubble)==null||t.setAnchorLocation(this.getAnchorLocation())}addMessage(e,t){if(this.textMap.get(t)===e)return this;e?this.textMap.set(t,e):this.textMap.delete(t);let o;return(o=this.textBubble)==null||o.setText(this.getText()),this}getText(){return[...this.textMap.values()].join(`
|
|
623
|
+
`)}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}bubbleIsVisible(){return!!this.textBubble}setBubbleVisible(e){const t=this;return(0,$.asyncExecutePromiseGeneratorFunction)(function*(){if(t.bubbleIsVisible()!==e){if(yield tt(),e)t.textBubble=new Yp(t.getText(),t.sourceBlock.workspace,t.getAnchorLocation(),t.getBubbleOwnerRect()),t.applyColour();else{let o;(o=t.textBubble)==null||o.dispose(),t.textBubble=null}C(new(w(a.BUBBLE_OPEN))(t.sourceBlock,e,"warning"))}})}getBubble(){return this.textBubble}getAnchorLocation(){const e=Xu/2;return f.sum(this.workspaceLocation,new f(e,e))}getBubbleOwnerRect(){const e=this.sourceBlock.getSvgRoot().getBBox();return new D(e.y,e.y+e.height,e.x,e.x+e.width)}};at.TYPE=se.WARNING,at.WEIGHT=2;var H=class extends $s{constructor(e,t,o){if(super(e,t,o),this.childlessWidth=this.width=this.height=0,this.warningTextDb=new Map,this.mutator=null,this.rendered=!0,this.visuallyDisabled=!1,this.translation="",this.dragging=!1,this.relativeCoords=new f(0,0),this.dragStrategy=new Xp(this),!e.rendered)throw TypeError("Cannot create a rendered block in a headless workspace");this.workspace=e,this.svgGroup=m(h.G,{}),t&&b(this.svgGroup,t),this.style=e.getRenderer().getConstants().getBlockStyle(null),this.pathObject=e.getRenderer().makePathObject(this.svgGroup,this.style),e=this.pathObject.svgPath,e.tooltip=this,Vs(e),this.svgGroup.setAttribute("data-id",this.id),e.id=Le(),this.doInit_()}initSvg(){if(!this.initialized){for(var e of this.inputList)e.init();for(const t of this.getIcons())t.initView(this.createIconPointerDownListener(t)),t.updateEditable();this.applyColour(),this.pathObject.updateMovable(this.isMovable()||this.isInFlyout),(e=this.getSvgRoot())&&k(e,"pointerdown",this,this.onMouseDown),e.parentNode||this.workspace.getCanvas().appendChild(e),this.initialized=!0}}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){this.addSelect(),Lt(this)}unselect(){this.removeSelect(),Lt(null)}setParent(e){var t=this.parentBlock_;if(e!==t){eo(),super.setParent(e),to();var o=this.getSvgRoot();if(!this.workspace.isClearing&&o){var s=this.getRelativeToSurfaceXY(),i=n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode(),r,l=this.getSvgRoot().contains((r=i?.getFocusableElement())!=null?r:null);e?(e.getSvgRoot().appendChild(o),l&&i&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)):t&&(e=this.workspace.getCanvas().querySelector(".blocklyDragging"),t=e?.parentElement,r=this.workspace.getCanvas(),t===r?r.insertBefore(o,e):(r.appendChild(o),l&&i&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(i)),this.translate(s.x,s.y)),this.applyColour()}}}getRelativeToSurfaceXY(){const e=this.workspace.getLayerManager();if(!e)throw Error("Cannot calculate position because the workspace has not been appended");let t=0,o=0,s=this.getSvgRoot();if(s)do{const i=Os(s);t+=i.x,o+=i.y,s=s.parentNode}while(s&&!e.hasLayer(s));return new f(t,o)}moveBy(e,t,o){if(this.parentBlock_)throw Error("Block has parent");const s=z();let i=null;s&&(i=new(w(a.BLOCK_MOVE))(this),o&&i.setReason(o)),e=new f(e,t),t=this.getRelativeToSurfaceXY(),e=f.sum(t,e),this.translate(e.x,e.y),this.updateComponentLocations(e),s&&i&&(i.recordNew(),C(i)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new f(e,t),this.getSvgRoot().setAttribute("transform",this.getTranslation())}getTranslation(){return this.translation}moveTo(e,t){const o=this.getRelativeToSurfaceXY();this.moveBy(e.x-o.x,e.y-o.y,t)}moveDuringDrag(e){this.translate(e.x,e.y),this.getSvgRoot().setAttribute("transform",this.getTranslation()),this.updateComponentLocations(e)}snapToGrid(){if(!this.isDeadOrDying()&&!this.getParent()&&!this.isInFlyout){var e=this.workspace.getGrid();if(e!=null&&e.shouldSnap()){var t=this.getRelativeToSurfaceXY();e=e.alignXY(t),e!==t&&this.moveTo(e,["snap"])}}}getBoundingRectangle(){return this.getBoundingRectangleWithDimensions(this.getHeightWidth())}getBoundingRectangleWithoutChildren(){return this.getBoundingRectangleWithDimensions({height:this.height,width:this.childlessWidth})}getBoundingRectangleWithDimensions(e){const t=this.getRelativeToSurfaceXY();let o,s;return this.RTL?(o=t.x-e.width,s=t.x):(o=t.x,s=t.x+e.width),new D(t.y,t.y+e.height,o,s)}markDirty(){this.pathObject.constants=this.workspace.getRenderer().getConstants();for(let e=0,t;t=this.inputList[e];e++)t.markDirty()}setCollapsed(e){this.collapsed_!==e&&(super.setCollapsed(e),this.updateCollapsed())}childHasWarning(){const e=this.getChildren(!1);for(const t of e)if(t.getIcon(at.TYPE)||t.childHasWarning())return!0;return!1}updateCollapsed(){var e=this.isCollapsed();const t=ni,o=zr;for(let i=0,r;r=this.inputList[i];i++)r.name!==t&&r.setVisible(!e);for(var s of this.getIcons())s.updateCollapsed();e?(b(this.svgGroup,"blocklyCollapsed"),this.childHasWarning()&&this.setWarningText(n.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,H.COLLAPSED_WARNING_ID),e=this.toString(Wp),(s=this.getField(o))?s.setValue(e):(this.getInput(t)||this.appendDummyInput(t)).appendField(new Co(e),o)):(this.updateDisabled(),this.removeInput(t),O(this.svgGroup,"blocklyCollapsed"),this.setWarningText(null,H.COLLAPSED_WARNING_ID))}onMouseDown(e){if(!this.workspace.isReadOnly()){var t=this.workspace.getGesture(e);t&&t.handleBlockStart(e,this)}}showHelp(){const e=typeof this.helpUrl=="function"?this.helpUrl():this.helpUrl;e&&window.open(e)}generateContextMenu(e){return this.workspace.isReadOnly()||!this.contextMenu?null:(e=R.registry.getContextMenuOptions({block:this,focusedNode:this},e),this.customContextMenu&&this.customContextMenu(e),e)}calculateContextMenuLocation(e){if(e instanceof PointerEvent)return new f(e.clientX,e.clientY);e=Lo(this.workspace,this.getRelativeToSurfaceXY());let t,o;const s=(t=this.inputList.filter(i=>i.isVisible()).flatMap(i=>i.fieldRow).find(i=>i.isVisible()))==null||(o=t.getSvgRoot())==null?void 0:o.getBoundingClientRect();return new f(this.RTL?e.x-5:e.x+5,(s&&s.height?s.y+s.height:e.y+this.height)+5)}showContextMenu(e){const t=this.generateContextMenu(e),o=this.calculateContextMenuLocation(e);t&&t.length&&(Yo(e,t,this.RTL,this.workspace,o),Yl(this))}updateComponentLocations(e){this.dragging||this.updateConnectionLocations(e),this.updateIconLocations(e),this.updateFieldLocations(e);for(const t of this.getChildren(!1))t.updateComponentLocations(f.sum(e,t.relativeCoords))}updateConnectionLocations(e){for(const t of this.getConnections_(!1))t.moveToOffset(e)}updateIconLocations(e){for(const t of this.getIcons())t.onLocationChange(e)}updateFieldLocations(e){for(const t of this.inputList)for(const o of t.fieldRow)o.onLocationChange(e)}addClass(e){b(this.svgGroup,e)}removeClass(e){O(this.svgGroup,e)}setDragging(e){(this.dragging=e)?(this.translation="",oi.push(...this.getConnections_(!0)),this.addClass("blocklyDragging")):(oi.length=0,this.removeClass("blocklyDragging"));for(let t=0;t<this.childBlocks_.length;t++)this.childBlocks_[t].setDragging(e)}setMovable(e){super.setMovable(e),this.pathObject.updateMovable(e)}setEditable(e){super.setEditable(e),e?O(this.svgGroup,"blocklyNotEditable"):b(this.svgGroup,"blocklyNotEditable"),e=this.getIcons();for(let t=0;t<e.length;t++)e[t].updateEditable()}setShadow(e){super.setShadow(e),this.applyColour()}setInsertionMarker(e){this.isInsertionMarker_!==e&&(this.isInsertionMarker_=e)&&(this.setColour(this.workspace.getRenderer().getConstants().INSERTION_MARKER_COLOUR),this.pathObject.updateInsertionMarker(!0))}getSvgRoot(){return this.svgGroup}dispose(e,t){this.disposing=!0,Ll(),zs();const o=n.getFocusManager$$module$build$src$core$focus_manager();var s,i;if(this.getSvgRoot().contains((i=(s=o.getFocusedNode())==null?void 0:s.getFocusableElement())!=null?i:null)){if(s=this.getParent(),!s){let r;if(i=(r=this.outputConnection)!=null?r:this.previousConnection){let l;s=(l=i.closest(0,new f(0,0)).connection)==null?void 0:l.getSourceBlock()}}s?o.focusNode(s):setTimeout(()=>o.focusTree(this.workspace),0)}t&&(this.unplug(e),Er(this)),super.dispose(!!e),F(this.svgGroup)}disposeInternal(){this.disposing=!0,super.disposeInternal(),n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===this&&this.workspace.cancelCurrentGesture(),[...this.warningTextDb.values()].forEach(e=>clearTimeout(e)),this.warningTextDb.clear(),this.getIcons().forEach(e=>e.dispose())}checkAndDelete(){this.workspace.isFlyout||(n.setGroup$$module$build$src$core$events$utils(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),n.setGroup$$module$build$src$core$events$utils(!1))}toCopyData(){return this.isInsertionMarker_?null:{paster:bi.TYPE,blockState:Be(this,{addCoordinates:!0,addNextBlocks:!1}),typeCounts:Ds(this,!0)}}applyColour(){var e,t;for((t=(e=this.pathObject).applyColour)==null||t.call(e,this),e=this.getIcons(),t=0;t<e.length;t++)e[t].applyColour();for(const o of this.getFields())o.applyColour()}updateDisabled(){const e=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled===e){let t;(t=this.getNextBlock())==null||t.updateDisabled()}else{this.applyColour(),this.visuallyDisabled=e;for(const t of this.getChildren(!1))t.updateDisabled()}}setWarningText(e,t=""){if(t)this.warningTextDb.has(t)&&(clearTimeout(this.warningTextDb.get(t)),this.warningTextDb.delete(t));else{for(var o of this.warningTextDb.values())clearTimeout(o);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(t,setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(t),this.setWarningText(e,t))},100));else if(this.isInFlyout&&(e=null),o=this.getIcon(at.TYPE),e){let s=this.getSurroundParent(),i=null;for(;s;)s.isCollapsed()&&(i=s),s=s.getSurroundParent();i&&i.setWarningText(n.Msg$$module$build$src$core$msg.COLLAPSED_WARNINGS_WARNING,H.COLLAPSED_WARNING_ID),o?o.addMessage(e,t):this.addIcon(new at(this).addMessage(e,t))}else o&&(t?(o.addMessage("",t),o.getText()||this.removeIcon(at.TYPE)):this.removeIcon(at.TYPE))}setMutator(e){this.removeIcon(n.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE),e&&this.addIcon(e)}addIcon(e){return super.addIcon(e),e instanceof n.MutatorIcon$$module$build$src$core$icons$mutator_icon&&(this.mutator=e),e.initView(this.createIconPointerDownListener(e)),e.applyColour(),e.updateEditable(),this.queueRender(),e}createIconPointerDownListener(e){return t=>{this.isDeadOrDying()||(t=this.workspace.getGesture(t))&&t.setStartIcon(e)}}removeIcon(e){const t=super.removeIcon(e);return e.equals(n.MutatorIcon$$module$build$src$core$icons$mutator_icon.TYPE)&&(this.mutator=null),this.queueRender(),t}setDisabledReason(e,t){const o=this.isEnabled();super.setDisabledReason(e,t),this.isEnabled()===o||this.getInheritedDisabled()||this.updateDisabled()}setDeletable(e){super.setDeletable(e),e?O(this.svgGroup,"blocklyNotDeletable"):b(this.svgGroup,"blocklyNotDeletable")}setHighlighted(e){this.pathObject.updateHighlighted(e)}addSelect(){this.pathObject.updateSelected(!0)}removeSelect(){this.pathObject.updateSelected(!1)}setDeleteStyle(e){this.pathObject.updateDraggingDelete(e)}getColour(){return this.style.colourPrimary}setColour(e){super.setColour(e),e=this.workspace.getRenderer().getConstants().getBlockStyleForColour(this.colour_);let t,o;(o=(t=this.pathObject).setStyle)==null||o.call(t,e.style),this.style=e.style,this.styleName_=e.name,this.applyColour()}setStyle(e){const t=this.workspace.getRenderer().getConstants().getBlockStyle(e);if(this.styleName_&&O(this.svgGroup,this.styleName_),t){this.hat=t.hat;let o,s;(s=(o=this.pathObject).setStyle)==null||s.call(o,t),this.colour_=t.colourPrimary,this.style=t,this.applyColour(),b(this.svgGroup,e),this.styleName_=e}else throw Error("Invalid style name: "+e)}getStyle(){return this.style}bringToFront(e=!1){const t=n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode();let o=this;if(!o.isDeadOrDying()){do{const s=o.getSvgRoot(),i=s.parentNode,r=i.childNodes;if(r[r.length-1]!==s&&i.appendChild(s),e)break;o=o.getParent()}while(o);t&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(t)}}setPreviousStatement(e,t){super.setPreviousStatement(e,t),this.queueRender()}setNextStatement(e,t){super.setNextStatement(e,t),this.queueRender()}setOutput(e,t){super.setOutput(e,t),this.queueRender()}setInputsInline(e){super.setInputsInline(e),this.queueRender()}removeInput(e,t){return e=super.removeInput(e,t),this.queueRender(),e}moveNumberedInputBefore(e,t){super.moveNumberedInputBefore(e,t),this.queueRender()}appendInput(e){return super.appendInput(e),this.queueRender(),e}setConnectionTracking(e){if(this.previousConnection&&this.previousConnection.setTracking(e),this.outputConnection&&this.outputConnection.setTracking(e),this.nextConnection){this.nextConnection.setTracking(e);var t=this.nextConnection.targetBlock();t&&t.setConnectionTracking(e)}if(!this.collapsed_)for(t=0;t<this.inputList.length;t++){var o=this.inputList[t].connection;o&&(o.setTracking(e),(o=o.targetBlock())&&o.setConnectionTracking(e))}}getConnections_(e){const t=[];if(this.outputConnection&&t.push(this.outputConnection),this.previousConnection&&t.push(this.previousConnection),this.nextConnection&&t.push(this.nextConnection),e||!this.collapsed_)for(let o=0,s;s=this.inputList[o];o++)s.connection&&t.push(s.connection);return t}lastConnectionInStack(e){return super.lastConnectionInStack(e)}getMatchingConnection(e,t){return super.getMatchingConnection(e,t)}makeConnection_(e){return new ae(this,e)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){const e=this.getRootBlock();if(!(this.isDeadOrDying()||this.workspace.isDragging()||e.isInFlyout))for(const t of this.getConnections_(!1)){if(t.isSuperior()){let o;(o=t.targetBlock())==null||o.bumpNeighbours()}for(const o of t.neighbours(n.config$$module$build$src$core$config.snapRadius))o.getSourceBlock().getRootBlock()!==e&&(t.isConnected()&&o.isConnected()||(t.isSuperior()?o.bumpAwayFrom(t,!1):t.bumpAwayFrom(o,!0)))}}scheduleSnapAndBump(){this.snapToGrid(),this.bumpNeighbours()}positionNearConnection(e,t,o){if(e.type===E.NEXT_STATEMENT||e.type===E.INPUT_VALUE){let s=t.x;t=t.y,s+=o.x-e.getOffsetInBlock().x,t+=o.y-e.getOffsetInBlock().y,this.moveBy(s,t)}}getChildren(e){return super.getChildren(e)}queueRender(){return ol(this)}render(){this.queueRender(),Bt()}renderEfficiently(){eo(),this.isCollapsed()&&this.updateCollapsed(),this.isEnabled()||this.updateDisabled(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),to()}tightenChildrenEfficiently(){for(const e of this.inputList){const t=e.connection;t&&t.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}getHeightWidth(){let e=this.height,t=this.width;var o=this.getNextBlock();if(o){o=o.getHeightWidth();const s=this.workspace.getRenderer().getConstants().NOTCH_HEIGHT;e+=o.height-s,t=Math.max(t,o.width)}return{height:e,width:t}}fadeForReplacement(e){this.pathObject.updateReplacementFade(e)}highlightShapeForInput(e,t){this.pathObject.updateShapeForInputHighlight(e,t)}getDragStrategy(){return this.dragStrategy}setDragStrategy(e){this.dragStrategy=e}isCopyable(){return this.isOwnDeletable()&&this.isOwnMovable()}isMovable(){return this.dragStrategy.isMovable()}startDrag(e){this.dragStrategy.startDrag(e)}drag(e,t){this.dragStrategy.drag(e,t)}endDrag(e){this.dragStrategy.endDrag(e)}revertDrag(){this.dragStrategy.revertDrag()}toFlyoutInfo(){const e=Object.assign({},{kind:"BLOCK"},Be(this)),t=new Set(["id","height","width","pinned","enabled"]),o=function(s){for(const i in s)t.has(i)?delete s[i]:typeof s[i]=="object"&&o(s[i])};return o(e),[e]}jsonInit(e){super.jsonInit(e),e.classes&&this.addClass(Array.isArray(e.classes)?e.classes.join(" "):e.classes)}getFocusableElement(){return this.pathObject.svgPath}getFocusableTree(){return this.workspace}onNodeFocus(){this.select()}onNodeBlur(){this.unselect()}canBeFocused(){return!0}};H.INLINE=-1,H.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var Kp=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},gn=class extends Kp{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e){return e instanceof H?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e)):this.updateWouldDelete_(Pe(e)&&e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},ps=class{constructor(e,t){this.element=e,this.type=t}getElement(){return this.element}getType(){return this.type}},Yu=class{constructor(e){this.workspace_=e}getDimensionsPx_(e){let t=0,o=0;return e&&(t=e.getWidth(),o=e.getHeight()),new N(t,o)}getFlyoutMetrics(e){return e=this.getDimensionsPx_(this.workspace_.getFlyout(e)),{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getToolboxMetrics(){const e=this.getDimensionsPx_(this.workspace_.getToolbox());return{width:e.width,height:e.height,position:this.workspace_.toolboxPosition}}getSvgMetrics(){return this.workspace_.getCachedParentSvgSize()}getAbsoluteMetrics(){let e=0,t=0;const o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var r;const l=!((r=this.workspace_.getFlyout())!=null&&r.autoClose);r=i?o.position:s.position;const c=r===S.TOP;return r===S.LEFT&&(i&&(e+=o.width),l&&(e+=s.width)),c&&(i&&(t+=o.height),l&&(t+=s.height)),{top:t,left:e}}getViewMetrics(e){e=e?this.workspace_.scale:1;const t=this.getSvgMetrics(),o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(),i=!!this.workspace_.getToolbox();var r;const l=!((r=this.workspace_.getFlyout())!=null&&r.autoClose);r=i?o.position:s.position;const c=r===S.LEFT||r===S.RIGHT;return(r===S.TOP||r===S.BOTTOM)&&(i&&(t.height-=o.height),l&&(t.height-=s.height)),c&&(i&&(t.width-=o.width),l&&(t.width-=s.width)),{height:t.height/e,width:t.width/e,top:-this.workspace_.scrollY/e,left:-this.workspace_.scrollX/e}}getContentMetrics(e){e=e?1:this.workspace_.scale;const t=this.workspace_.getBlocksBoundingBox();return{height:(t.bottom-t.top)*e,width:(t.right-t.left)*e,top:t.top*e,left:t.left*e}}hasFixedEdges(){return!this.workspace_.isMovableHorizontally()||!this.workspace_.isMovableVertically()}getComputedFixedEdges_(e){if(!this.hasFixedEdges())return{};const t=this.workspace_.isMovableHorizontally(),o=this.workspace_.isMovableVertically();e=e||this.getViewMetrics(!1);const s={};return o||(s.top=e.top,s.bottom=e.top+e.height),t||(s.left=e.left,s.right=e.left+e.width),s}getPaddedContent_(e,t){const o=t.top+t.height,s=t.left+t.width,i=e.width;e=e.height;const r=i/2,l=e/2;return{top:Math.min(t.top-l,o-e),bottom:Math.max(o+l,t.top+e),left:Math.min(t.left-r,s-i),right:Math.max(s+r,t.left+i)}}getScrollMetrics(e,t,o){e=e?this.workspace_.scale:1,t=t||this.getViewMetrics(!1);var s=o||this.getContentMetrics();o=this.getComputedFixedEdges_(t),t=this.getPaddedContent_(t,s),s=o.top!==void 0?o.top:t.top;const i=o.left!==void 0?o.left:t.left;return{top:s/e,left:i/e,width:((o.right!==void 0?o.right:t.right)-i)/e,height:((o.bottom!==void 0?o.bottom:t.bottom)-s)/e}}getUiMetrics(){return{viewMetrics:this.getViewMetrics(),absoluteMetrics:this.getAbsoluteMetrics(),toolboxMetrics:this.getToolboxMetrics()}}getMetrics(){const e=this.getToolboxMetrics(),t=this.getFlyoutMetrics(!0),o=this.getSvgMetrics(),s=this.getAbsoluteMetrics(),i=this.getViewMetrics(),r=this.getContentMetrics(),l=this.getScrollMetrics(!1,i,r);return{contentHeight:r.height,contentWidth:r.width,contentTop:r.top,contentLeft:r.left,scrollHeight:l.height,scrollWidth:l.width,scrollTop:l.top,scrollLeft:l.left,viewHeight:i.height,viewWidth:i.width,viewTop:i.top,viewLeft:i.left,absoluteTop:s.top,absoluteLeft:s.left,svgHeight:o.height,svgWidth:o.width,toolboxWidth:e.width,toolboxHeight:e.height,toolboxPosition:e.position,flyoutWidth:t.width,flyoutHeight:t.height}}};I(g.METRICS_MANAGER,Ce,Yu);var jp=class extends Yu{constructor(e,t){super(e),this.flyout_=t}getBoundingBox(){let e;try{e=this.workspace_.getCanvas().getBBox()}catch{e={height:0,y:0,width:0,x:0}}return e}getContentMetrics(e){const t=this.getBoundingBox();return e=e?1:this.workspace_.scale,{height:t.height*e,width:t.width*e,top:t.y*e,left:t.x*e}}getScrollMetrics(e,t,o){return t=o||this.getContentMetrics(),o=this.flyout_.MARGIN*this.workspace_.scale,e=e?this.workspace_.scale:1,{height:(t.height+2*o)/e,width:(t.width+t.left+o)/e,top:0,left:0}}},ye=class{constructor(e,t,o,s){this.workspace=e,this.targetWorkspace=t,this.isFlyoutLabel=s,this.height=this.width=0,this.cursorSvg=this.svgText=null,this.text=o.text,this.position=new f(0,0),this.callbackKey=o.callbackKey||o.callbackkey,this.cssClass=o["web-class"]||null,this.info=o,e=this.isFlyoutLabel?"blocklyFlyoutLabel":"blocklyFlyoutButton",this.cssClass&&(e+=" "+this.cssClass),this.id=Le(),this.svgGroup=m(h.G,{id:this.id,class:e},this.workspace.getCanvas());let i;this.isFlyoutLabel||(i=m(h.RECT,{class:"blocklyFlyoutButtonShadow",rx:ye.BORDER_RADIUS,ry:ye.BORDER_RADIUS,x:1,y:1},this.svgGroup)),e=m(h.RECT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:ye.BORDER_RADIUS,ry:ye.BORDER_RADIUS},this.svgGroup),t=m(h.TEXT,{class:this.isFlyoutLabel?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup),o=J(this.text),this.workspace.RTL&&(o+=""),t.textContent=o,this.isFlyoutLabel&&(this.svgText=t,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill")),s=Qe(t,"fontSize");const r=Qe(t,"fontWeight"),l=Qe(t,"fontFamily");if(this.width=ks(t,s,r,l),o=Pi(o,s,r,l),this.height=this.height||o.height,!this.isFlyoutLabel){this.width+=2*ye.TEXT_MARGIN_X,this.height+=2*ye.TEXT_MARGIN_Y;let c;(c=i)==null||c.setAttribute("width",String(this.width));let p;(p=i)==null||p.setAttribute("height",String(this.height))}e.setAttribute("width",String(this.width)),e.setAttribute("height",String(this.height)),t.setAttribute("x",String(this.width/2)),t.setAttribute("y",String(this.height/2-o.height/2+o.baseline)),this.updateTransform(),this.onMouseDownWrapper=k(this.svgGroup,"pointerdown",this,this.onMouseDown),this.onMouseUpWrapper=k(this.svgGroup,"pointerup",this,this.onMouseUp)}createDom(){return this.svgGroup}show(){this.updateTransform(),this.svgGroup.setAttribute("display","block")}updateTransform(){this.svgGroup.setAttribute("transform","translate("+this.position.x+","+this.position.y+")")}moveTo(e,t){this.position.x=e,this.position.y=t,this.updateTransform()}moveBy(e,t,o){this.moveTo(this.position.x+e,this.position.y+t)}isLabel(){return this.isFlyoutLabel}getPosition(){return this.position}getBoundingRectangle(){return new D(this.position.y,this.position.y+this.height,this.position.x,this.position.x+this.width)}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}getWorkspace(){return this.workspace}dispose(){x(this.onMouseDownWrapper),x(this.onMouseUpWrapper),this.svgGroup&&F(this.svgGroup),this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}setCursorSvg(e){e?this.svgGroup&&(this.svgGroup.appendChild(e),this.cursorSvg=e):this.cursorSvg=null}onMouseUp(e){(e=this.targetWorkspace.getGesture(e))&&e.cancel(),this.isFlyoutLabel&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isFlyoutLabel||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?this.isFlyoutLabel||(e=this.targetWorkspace.getButtonCallback(this.callbackKey))&&e(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}onMouseDown(e){const t=this.targetWorkspace.getGesture(e),o=this.targetWorkspace.getFlyout();t&&o&&t.handleFlyoutStart(e,o)}getSvgRoot(){return this.svgGroup}getFocusableElement(){return this.svgGroup}getFocusableTree(){return this.workspace}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}};ye.TEXT_MARGIN_X=5,ye.TEXT_MARGIN_Y=2,ye.BORDER_RADIUS=4,qe(`
|
|
624
|
+
.blocklyFlyoutButton {
|
|
625
|
+
fill: #888;
|
|
626
|
+
cursor: default;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
.blocklyFlyoutButtonShadow {
|
|
630
|
+
fill: #666;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.blocklyFlyoutButton:hover {
|
|
634
|
+
fill: #aaa;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.blocklyFlyoutLabel {
|
|
638
|
+
cursor: default;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.blocklyFlyoutLabelBackground {
|
|
642
|
+
opacity: 0;
|
|
643
|
+
}
|
|
644
|
+
`);var Jp=class{getFirstChild(e){return null}getParent(e){return e.getWorkspace()}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof ye}},Zp=class{constructor(e,t){this.policy=e,this.flyout=t}getFirstChild(e){return null}getParent(e){return this.policy.getParent(e)}getNextSibling(e){const t=this.flyout.getContents();if(!t)return null;let o=t.findIndex(s=>s.getElement()===e);return o===-1?null:(o++,o>=t.length&&(o=0),t[o].getElement())}getPreviousSibling(e){const t=this.flyout.getContents();if(!t)return null;let o=t.findIndex(s=>s.getElement()===e);return o===-1?null:(o--,o<0&&(o=t.length-1),t[o].getElement())}isNavigable(e){return this.policy.isNavigable(e)}isApplicable(e){return this.policy.isApplicable(e)}},mn=class{constructor(e,t){this.gap=e,this.axis=t,this.y=this.x=0}getBoundingRectangle(){switch(this.axis){case"x":return new D(this.y,this.y,this.x,this.x+this.gap);case"y":return new D(this.y,this.y+this.gap,this.x,this.x)}}moveBy(e,t,o){this.x+=e,this.y+=t}isNavigable(){return!1}getFocusableElement(){throw Error("Cannot be focused")}getFocusableTree(){throw Error("Cannot be focused")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}},qp=class{getFirstChild(e){return null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return!1}isApplicable(e){return e instanceof mn}},Qp=class{getFirstChild(e){return ac(e,!0)[0]}getParent(e){var t;if((t=e.previousConnection)!=null&&t.targetBlock()){if(t=e.getSurroundParent())return t}else{let o;if((o=e.outputConnection)!=null&&o.targetBlock())return e.outputConnection.targetBlock()}return e.workspace}getNextSibling(e){let t;if((t=e.nextConnection)!=null&&t.targetBlock()){let s;return(s=e.nextConnection)==null?void 0:s.targetBlock()}let o;return(o=e.outputConnection)!=null&&o.targetBlock()?Ue(e,1):e.getSurroundParent()?Ue(e.getTopStackBlock(),1):this.getParent(e)instanceof be?qo(e,1):null}getPreviousSibling(e){let t;if((t=e.previousConnection)!=null&&t.targetBlock()){let s;return(s=e.previousConnection)==null?void 0:s.targetBlock()}let o;return(o=e.outputConnection)!=null&&o.targetBlock()?Ue(e,-1):this.getParent(e)instanceof be?qo(e,-1):null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof H}},Zm=class{getFirstChild(e){return null}getParent(e){return e.getParentComment()}getNextSibling(e){const t=e.getParentComment().view.getCommentBarButtons();return e=t.indexOf(e),e>=0&&e+1<t.length?t[e+1]:null}getPreviousSibling(e){const t=e.getParentComment().view.getCommentBarButtons();return e=t.indexOf(e),e>0?t[e-1]:null}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof ln}},eg=class{getFirstChild(e){return e.getParentInput()?e.targetConnection:null}getParent(e){return e.getSourceBlock()}getNextSibling(e){if(e.getParentInput())return Ue(e,1);if(e.type===E.NEXT_STATEMENT){const o=e.targetConnection;var t=e.getSourceBlock();if(!o&&t.getRootBlock().lastConnectionInStack(!1)===e){e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())+1,t>=e.length&&(t=0),t=e[t];let s;return(s=this.getParentConnection(t))!=null?s:t}return o}return e.getSourceBlock()}getPreviousSibling(e){if(e.getParentInput())return Ue(e,-1);if(e.type===E.PREVIOUS_STATEMENT||e.type===E.OUTPUT_VALUE){const o=e.targetConnection&&!e.targetConnection.getParentInput()?e.targetConnection:null;var t=e.getSourceBlock();if(!o&&this.getParentConnection(t.getRootBlock())===e){e=t.workspace.getTopBlocks(!0),t=e.indexOf(t.getRootBlock())-1,t<0&&(t=e.length-1),t=e[t];let s;return(s=t.lastConnectionInStack(!1))!=null?s:t}return o}return e.type===E.NEXT_STATEMENT?e.getSourceBlock():null}getParentConnection(e){let t;return!e.outputConnection||(t=e.previousConnection)!=null&&t.isConnected()?e.previousConnection:e.outputConnection}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof ae}},tg=class{getFirstChild(e){return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return Ue(e,1)}getPreviousSibling(e){return Ue(e,-1)}isNavigable(e){let t;return e.canBeFocused()&&e.isVisible()&&(e.isClickable()||e.isCurrentlyEditable())&&!((t=e.getSourceBlock())!=null&&t.isSimpleReporter()&&e.isFullBlockField())&&e.getParentInput().isVisible()}isApplicable(e){return e instanceof L}},qm=class{getFirstChild(e){if(e instanceof n.MutatorIcon$$module$build$src$core$icons$mutator_icon&&e.bubbleIsVisible()&&n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()===e){let t,o;return(o=(t=e.getBubble())==null?void 0:t.getWorkspace())!=null?o:null}return null}getParent(e){return e.getSourceBlock()}getNextSibling(e){return Ue(e,1)}getPreviousSibling(e){return Ue(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof gi}},Qm=class{getFirstChild(e){return e.view.getCommentBarButtons()[0]}getParent(e){return e.workspace}getNextSibling(e){return qo(e,1)}getPreviousSibling(e){return qo(e,-1)}isNavigable(e){return e.canBeFocused()}isApplicable(e){return e instanceof ct}},og=class{getFirstChild(e){return e=e.getTopBlocks(!0),e.length?e[0]:null}getParent(e){return null}getNextSibling(e){return null}getPreviousSibling(e){return null}isNavigable(e){return e.canBeFocused()&&!e.isMutator}isApplicable(e){return e instanceof be}},Ku=class{constructor(){this.rules=[new Qp,new tg,new eg,new og,new qm,new Qm,new Zm]}addNavigationPolicy(e){this.rules.push(e)}get(e){return this.rules.find(t=>t.isApplicable(e))}getFirstChild(e){let t;const o=(t=this.get(e))==null?void 0:t.getFirstChild(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getFirstChild(o)||this.getNextSibling(o)}getParent(e){let t;const o=(t=this.get(e))==null?void 0:t.getParent(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getParent(o)}getNextSibling(e){let t;const o=(t=this.get(e))==null?void 0:t.getNextSibling(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getNextSibling(o)}getPreviousSibling(e){let t;const o=(t=this.get(e))==null?void 0:t.getPreviousSibling(e);if(!o)return null;let s;return(s=this.get(o))!=null&&s.isNavigable(o)?o:this.getPreviousSibling(o)}},sg=class extends Ku{constructor(e){super(),this.rules.push(new Jp,new qp),this.rules=this.rules.map(t=>new Zp(t,e))}},ju=class{constructor(e,t,o,s,i){this.workspace=e,this.oldHostMetrics=this.corner_=this.vScroll=this.hScroll=null,t=t===void 0?!0:t,o=o===void 0?!0:o;const r=t&&o;t&&(this.hScroll=new q(e,!0,r,s,i)),o&&(this.vScroll=new q(e,!1,r,s,i)),r&&(this.corner_=m(h.RECT,{height:q.scrollbarThickness,width:q.scrollbarThickness,class:"blocklyScrollbarBackground"}),Qt(this.corner_,e.getBubbleCanvas()))}dispose(){F(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 e=this.workspace.getMetrics();if(e){var t=!1,o=!1;if(this.oldHostMetrics&&this.oldHostMetrics.viewWidth===e.viewWidth&&this.oldHostMetrics.viewHeight===e.viewHeight&&this.oldHostMetrics.absoluteTop===e.absoluteTop&&this.oldHostMetrics.absoluteLeft===e.absoluteLeft?(this.oldHostMetrics&&this.oldHostMetrics.scrollWidth===e.scrollWidth&&this.oldHostMetrics.viewLeft===e.viewLeft&&this.oldHostMetrics.scrollLeft===e.scrollLeft||(t=!0),this.oldHostMetrics&&this.oldHostMetrics.scrollHeight===e.scrollHeight&&this.oldHostMetrics.viewTop===e.viewTop&&this.oldHostMetrics.scrollTop===e.scrollTop||(o=!0)):o=t=!0,t||o){try{n.disable$$module$build$src$core$events$utils(),this.hScroll&&t&&this.hScroll.resize(e),this.vScroll&&o&&this.vScroll.resize(e)}finally{n.enable$$module$build$src$core$events$utils()}this.workspace.maybeFireViewportChangeEvent()}if(this.hScroll&&this.vScroll){if(!this.oldHostMetrics||this.oldHostMetrics.viewWidth!==e.viewWidth||this.oldHostMetrics.absoluteLeft!==e.absoluteLeft){let s;(s=this.corner_)==null||s.setAttribute("x",String(this.vScroll.position.x))}if(!this.oldHostMetrics||this.oldHostMetrics.viewHeight!==e.viewHeight||this.oldHostMetrics.absoluteTop!==e.absoluteTop){let s;(s=this.corner_)==null||s.setAttribute("y",String(this.hScroll.position.y))}}this.oldHostMetrics=e}}canScrollHorizontally(){return!!this.hScroll}canScrollVertically(){return!!this.vScroll}setOrigin(e,t){this.hScroll&&this.hScroll.setOrigin(e,t),this.vScroll&&this.vScroll.setOrigin(e,t)}set(e,t,o){this.hScroll&&this.hScroll.set(e,!1),this.vScroll&&this.vScroll.set(t,!1),(o||o===void 0)&&(e={},this.hScroll&&(e.x=this.hScroll.getRatio_()),this.vScroll&&(e.y=this.vScroll.getRatio_()),this.workspace.setMetrics(e))}setX(e){this.hScroll&&this.hScroll.set(e,!0)}setY(e){this.vScroll&&this.vScroll.set(e,!0)}setContainerVisible(e){this.hScroll&&this.hScroll.setContainerVisible(e),this.vScroll&&this.vScroll.setContainerVisible(e)}isVisible(){let e=!1;return this.hScroll&&(e=this.hScroll.isVisible()),this.vScroll&&(e=e||this.vScroll.isVisible()),e}setVisible(e){this.hScroll&&this.hScroll.setVisibleInternal(e),this.vScroll&&this.vScroll.setVisibleInternal(e)}resizeContent(e){this.hScroll&&this.hScroll.resizeContentHorizontal(e),this.vScroll&&this.vScroll.resizeContentVertical(e)}resizeView(e){this.hScroll&&this.hScroll.resizeViewHorizontal(e),this.vScroll&&this.vScroll.resizeViewVertical(e)}},gs="sep",ig=class{load(e,t){return e=new mn(0,t.horizontalLayout?"x":"y"),new ps(e,gs)}gapForItem(e,t){let o;return(o=parseInt(String(e.gap)))!=null?o:t}disposeItem(e){}getType(){return gs}};I(g.FLYOUT_INFLATER,gs,ig);var fn=class extends gn{constructor(e){super(),this.horizontalLayout=!1,this.boundEvents=[],this.reflowWrapper=null,this.contents=[],this.autoClose=!0,this.visible=!1,this.containerVisible=!0,this.CORNER_RADIUS=8,this.SCROLLBAR_MARGIN=2.5,this.height_=this.width_=0,this.dragAngleRange_=70,this.svgGroup_=this.svgBackground_=null,this.inflaters=new Map,e.setMetrics=this.setMetrics_.bind(this),this.workspace_=new be(e),this.workspace_.setMetricsManager(new jp(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.visible),this.workspace_.setNavigator(new sg(this)),this.id=_t(),this.RTL=!!e.RTL,this.toolboxPosition_=e.toolboxPosition,this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH,this.MARGIN=this.CORNER_RADIUS,this.GAP_X=this.MARGIN*3,this.GAP_Y=this.MARGIN*3}createDom(e){return this.svgGroup_=m(e,{class:"blocklyFlyout"}),this.svgGroup_.style.display="none",this.svgBackground_=m(h.PATH,{class:"blocklyFlyoutBackground"},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutBackgroundColour","fill"),this.workspace_.getThemeManager().subscribe(this.svgBackground_,"flyoutOpacity","fill-opacity"),this.svgGroup_}init(e){this.targetWorkspace=e,this.workspace_.targetWorkspace=e,this.workspace_.scrollbar=new ju(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(k(this.svgGroup_,"wheel",this,this.wheel_)),this.boundEvents.push(k(this.svgBackground_,"pointerdown",this,this.onMouseDown)),this.workspace_.getGesture=this.targetWorkspace.getGesture.bind(this.targetWorkspace),this.workspace_.setVariableMap(this.targetWorkspace.getVariableMap()),this.workspace_.createPotentialVariableMap(),e.getComponentManager().addComponent({component:this,weight:U.ComponentWeight.FLYOUT_WEIGHT,capabilities:[U.Capability.AUTOHIDEABLE,U.Capability.DELETE_AREA,U.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.targetWorkspace.getComponentManager().removeComponent(this.id);for(const e of this.boundEvents)x(e);this.boundEvents.length=0,this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&F(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}setAutoClose(e){this.autoClose=e,this.targetWorkspace.recordDragTargets(),this.targetWorkspace.resizeContents()}autoHide(e){!e&&this.targetWorkspace.getFlyout(!0)===this&&this.autoClose&&this.hide()}getTargetWorkspace(){return this.targetWorkspace}isVisible(){return this.visible}setVisible(e){const t=e!==this.isVisible();this.visible=e,t&&(this.autoClose||this.targetWorkspace.recordDragTargets(),this.updateDisplay())}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay()}getContents(){return this.contents}setContents(e){this.contents=e}updateDisplay(){let e;e=this.containerVisible?this.isVisible():!1,this.svgGroup_&&(this.svgGroup_.style.display=e?"block":"none");let t;(t=this.workspace_.scrollbar)==null||t.setContainerVisible(e)}positionAt_(e,t,o,s){let i;(i=this.svgGroup_)==null||i.setAttribute("width",`${e}`);let r;(r=this.svgGroup_)==null||r.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&Bi(this.svgGroup_,"translate("+o+"px,"+s+"px)"),(e=this.workspace_.scrollbar)&&(e.setOrigin(o,s),e.resize(),e.hScroll&&e.hScroll.setPosition(e.hScroll.position.x,e.hScroll.position.y),e.vScroll&&e.vScroll.setPosition(e.vScroll.position.x,e.vScroll.position.y))}hide(){this.isVisible()&&(this.setVisible(!1),this.reflowWrapper&&(this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowWrapper=null))}show(e){this.workspace_.setResizesEnabled(!1),this.hide(),this.clearOldBlocks(),typeof e=="string"&&(e=this.getDynamicCategoryContents(e)),this.setVisible(!0),e=xs(e),e=this.createFlyoutInfo(e),Bt(this.workspace_),this.setContents(e),this.layout_(e),this.horizontalLayout?this.height_=0:this.width_=0,this.reflow(),this.workspace_.setResizesEnabled(!0),this.reflowWrapper=t=>{t.type!==a.BLOCK_CHANGE&&t.type!==a.BLOCK_FIELD_INTERMEDIATE_CHANGE||this.reflow()},this.workspace_.addChangeListener(this.reflowWrapper)}createFlyoutInfo(e){const t=[],o=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const s of e)"custom"in s&&(e=this.getDynamicCategoryContents(s.custom),e=xs(e),t.push(...this.createFlyoutInfo(e))),e=s.kind.toLowerCase(),(e=this.getInflaterForType(e))&&(t.push(e.load(s,this)),(e=e.gapForItem(s,o))&&t.push(new ps(new mn(e,this.horizontalLayout?"x":"y"),gs)));return this.normalizeSeparators(t)}normalizeSeparators(e){for(let t=e.length-1;t>0;t--){const o=e[t].getType().toLowerCase(),s=e[t-1].getType().toLowerCase();o===gs&&s===gs&&e.splice(t-1,1)}return e}getDynamicCategoryContents(e){if(e=this.workspace_.targetWorkspace.getToolboxCategoryCallback(e),typeof e!="function")throw TypeError("Couldn't find a callback function when opening a toolbox category.");return e(this.workspace_.targetWorkspace)}clearOldBlocks(){this.getContents().forEach(t=>{let o;(o=this.getInflaterForType(t.getType()))==null||o.disposeItem(t)});let e;(e=this.workspace_.getPotentialVariableMap())==null||e.clear()}onMouseDown(e){const t=this.targetWorkspace.getGesture(e);t&&t.handleFlyoutStart(e,this)}isBlockCreatable(e){return e.isEnabled()&&!this.getTargetWorkspace().isReadOnly()}createBlock(e){let t=null;n.disable$$module$build$src$core$events$utils();var o=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{t=this.placeNewBlock(e)}finally{n.enable$$module$build$src$core$events$utils()}if(this.targetWorkspace.hideChaff(),e=Fs(this.targetWorkspace,o),z()){for(n.setGroup$$module$build$src$core$events$utils(!0),o=0;o<e.length;o++){const s=e[o];C(new(w(a.VAR_CREATE))(s))}C(new(w(a.BLOCK_CREATE))(t))}return this.autoClose&&this.hide(),t}reflow(){this.reflowWrapper&&this.workspace_.removeChangeListener(this.reflowWrapper),this.reflowInternal_(),this.reflowWrapper&&this.workspace_.addChangeListener(this.reflowWrapper)}isScrollable(){return this.workspace_.scrollbar?this.workspace_.scrollbar.isVisible():!1}placeNewBlock(e){var t=this.targetWorkspace;if(!e.getSvgRoot())throw Error("oldBlock is not rendered");const o=this.serializeBlock(e);return t.setResizesEnabled(!1),t=Pt(o,t),this.positionNewBlock(e,t),t}serializeBlock(e){return Be(e)}positionNewBlock(e,t){const o=this.targetWorkspace;var s=o.getOriginOffsetInPixels(),i=this.workspace_.getOriginOffsetInPixels();e=e.getRelativeToSurfaceXY(),e.scale(this.workspace_.scale),i=f.sum(i,e),s=f.difference(i,s),s.scale(1/o.scale),t.moveTo(new f(s.x,s.y))}getInflaterForType(e){if(this.inflaters.has(e)){var t;return(t=this.inflaters.get(e))!=null?t:null}return(t=Ve(g.FLYOUT_INFLATER,e))?(t=new t,this.inflaters.set(e,t),t):null}getFocusableElement(){throw Error("Flyouts are not directly focusable.")}getFocusableTree(){throw Error("Flyouts are not directly focusable.")}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!1}getRootFocusableNode(){throw Error("Flyouts are not directly focusable.")}getRestoredFocusableNode(e){throw Error("Flyouts are not directly focusable.")}getNestedTrees(){throw Error("Flyouts are not directly focusable.")}lookUpFocusableNode(e){throw Error("Flyouts are not directly focusable.")}onTreeFocus(e,t){}onTreeBlur(e){throw Error("Flyouts are not directly focusable.")}},rg=class{constructor(){this.isActive=!1,this.activeClassName="blocklyKeyboardNavigation"}setIsActive(e=!0){this.isActive=e,this.updateActiveVisualization()}getIsActive(){return this.isActive}updateActiveVisualization(){this.isActive?document.body.classList.add(this.activeClassName):document.body.classList.remove(this.activeClassName)}},bn=new rg,ng=class{constructor(e){this.workspace=e,this.horizontalScrollEnabled=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled=this.workspace.isMovableVertically(),this.startScrollXY_=new f(e.scrollX,e.scrollY)}dispose(){this.workspace=null}startDrag(){}endDrag(e){this.drag(e)}drag(e){if(e=f.sum(this.startScrollXY_,e),this.horizontalScrollEnabled&&this.verticalScrollEnabled)this.workspace.scroll(e.x,e.y);else if(this.horizontalScrollEnabled)this.workspace.scroll(e.x,this.workspace.scrollY);else if(this.verticalScrollEnabled)this.workspace.scroll(this.workspace.scrollX,e.y);else throw new TypeError("Invalid state.")}},ef=5,tf=6,_n=class{constructor(e,t){this.creatorWorkspace=t,this.mouseDownXY=new f(0,0),this.startWorkspace_=this.targetBlock=this.startComment=this.startBlock=this.startIcon=this.startField=this.startBubble=null,this.hasExceededDragRadius=!1,this.boundEvents=[],this.workspaceDragger=this.dragger=null,this.dragging=!1,this.flyout=null,this.multiTouch=this.isEnding_=this.gestureHasStarted=this.calledUpdateIsDragging=!1,this.cachedPoints=new Map,this.startDistance=this.previousScale=0,this.currentDropdownOwner=this.isPinchZoomEnabled=null,this.mostRecentEvent=e,this.currentDragDeltaXY=new f(0,0)}dispose(){Ee(),Bl(),this.creatorWorkspace.clearGesture();for(const e of this.boundEvents)x(e);this.boundEvents.length=0,this.workspaceDragger&&this.workspaceDragger.dispose()}updateFromEvent(e){const t=new f(e.clientX,e.clientY);this.updateDragDelta(t)&&(this.updateIsDragging(e),Je()),this.mostRecentEvent=e}updateDragDelta(e){return this.currentDragDeltaXY=f.difference(e,this.mouseDownXY),this.hasExceededDragRadius?!1:this.hasExceededDragRadius=f.magnitude(this.currentDragDeltaXY)>(this.flyout?n.config$$module$build$src$core$config.flyoutDragRadius:n.config$$module$build$src$core$config.dragRadius)}updateIsDraggingFromFlyout(){let e;if(!this.targetBlock||(e=this.flyout)==null||!e.isBlockCreatable(this.targetBlock))return!1;if(!this.flyout.targetWorkspace)throw Error(`Cannot update dragging from the flyout because the ' +
|
|
645
|
+
'flyout's target workspace is undefined`);return!this.flyout.isScrollable()||this.flyout.isDragTowardWorkspace(this.currentDragDeltaXY)?(this.startWorkspace_=this.flyout.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),n.getGroup$$module$build$src$core$events$utils()||n.setGroup$$module$build$src$core$events$utils(!0),this.startBlock=null,this.targetBlock=this.flyout.createBlock(this.targetBlock),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),!0):!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.dragging=!0,this.workspaceDragger=new ng(this.startWorkspace_),this.workspaceDragger.startDrag())}updateIsDragging(e){if(!this.startWorkspace_)throw Error("Cannot update dragging because the start workspace is undefined");if(this.calledUpdateIsDragging)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging=!0,this.flyout&&this.updateIsDraggingFromFlyout();const t=Ss();t&&Qo(t)&&t.isMovable()?(this.dragging=!0,this.dragger=this.createDragger(t,this.startWorkspace_),this.dragger.onDragStart(e),this.dragger.onDrag(e,this.currentDragDeltaXY)):this.updateIsDraggingWorkspace()}createDragger(e,t){return new(_e(g.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(e,t)}doStart(e){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,vs(e)?this.cancel():(this.gestureHasStarted=!0,Jo(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=ml(),this.startWorkspace_.hideChaff(!!this.flyout),this.startWorkspace_.markFocused(),this.mostRecentEvent=e,Ml(),We(e)?this.handleRightClick(e):(e.type.toLowerCase()==="pointerdown"&&e.pointerType!=="mouse"&&xn(e,this),this.mouseDownXY=new f(e.clientX,e.clientY),this.bindMouseEvents(e),this.isEnding_||this.handleTouchStart(e)))}bindMouseEvents(e){this.boundEvents.push(k(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(k(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(k(document,"pointerup",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&Je())}handleMove(e){this.isDragging()&&ys(e)||!this.isMultiTouch()?(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(e),Je())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!ys(e))return;if(this.updateFromEvent(e),Je(),this.isEnding_){console.log("Trying to end a gesture recursively.");return}this.isEnding_=!0,this.dragger?(bn.setIsActive(!1),this.dragger.onDragEnd(e,this.currentDragDeltaXY)):this.workspaceDragger?(bn.setIsActive(!1),this.workspaceDragger.endDrag(this.currentDragDeltaXY)):this.isBubbleClick()||this.isCommentClick()||(this.isFieldClick()?this.doFieldClick():this.isIconClick()?this.doIconClick():this.isBlockClick()?this.doBlockClick():this.isWorkspaceClick()&&this.doWorkspaceClick(e))}e.preventDefault(),e.stopPropagation(),this.dispose()}handleTouchStart(e){var t=Ro(e);this.cachedPoints.set(t,this.getTouchPoint(e));var o=Array.from(this.cachedPoints.keys());o.length===2&&(t=this.cachedPoints.get(o[0]),o=this.cachedPoints.get(o[1]),this.startDistance=f.distance(t,o),this.multiTouch=!0,e.preventDefault())}handleTouchMove(e){const t=Ro(e);this.cachedPoints.set(t,this.getTouchPoint(e)),this.isPinchZoomEnabled&&this.cachedPoints.size===2?this.handlePinch(e):(this.updateFromEvent(e),this.workspaceDragger?this.workspaceDragger.drag(this.currentDragDeltaXY):this.dragger&&this.dragger.onDrag(this.mostRecentEvent,this.currentDragDeltaXY),e.preventDefault(),e.stopPropagation())}handlePinch(e){var t=Array.from(this.cachedPoints.keys()),o=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),o=f.distance(o,t)/this.startDistance,this.previousScale>0&&this.previousScale<1/0){if(t=o-this.previousScale,t=t>0?t*ef:t*tf,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const s=this.startWorkspace_,i=Do(e,s.getParentSvg(),s.getInverseScreenCTM());s.zoom(i.x,i.y,t)}this.previousScale=o,e.preventDefault()}handleTouchEnd(e){e=Ro(e),this.cachedPoints.has(e)&&this.cachedPoints.delete(e),this.cachedPoints.size<2&&(this.cachedPoints.clear(),this.previousScale=0)}getTouchPoint(e){return this.startWorkspace_?new f(e.pageX,e.pageY):null}isMultiTouch(){return this.multiTouch}cancel(){this.isEnding_||(Je(),this.dragger?this.dragger.onDragEnd(this.mostRecentEvent,this.currentDragDeltaXY):this.workspaceDragger&&this.workspaceDragger.endDrag(this.currentDragDeltaXY),this.dispose())}handleRightClick(e){this.targetBlock?(this.bringBlockToFront(),this.targetBlock.workspace.hideChaff(!!this.flyout),this.targetBlock.showContextMenu(e)):this.startBubble?this.startBubble.showContextMenu(e):this.startComment?(this.startComment.workspace.hideChaff(),this.startComment.showContextMenu(e)):this.startWorkspace_&&!this.flyout&&(this.startWorkspace_.hideChaff(),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.startWorkspace_),this.startWorkspace_.showContextMenu(e)),e.preventDefault(),e.stopPropagation(),bn.setIsActive(!1),this.dispose()}handleWsStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace(t),this.mostRecentEvent=e,this.startBlock||this.startBubble||this.startComment?this.startBlock&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.startBlock):n.getFocusManager$$module$build$src$core$focus_manager().focusNode(t),this.doStart(e)}fireWorkspaceClick(e){C(new(w(a.CLICK))(null,e.id,"workspace"))}handleFlyoutStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleFlyoutStart, but the gesture had already been started.");this.setStartFlyout(t),this.handleWsStart(e,t.getWorkspace())}handleBlockStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBlockStart, but the gesture had already been started.");this.setStartBlock(t),this.mostRecentEvent=e}handleBubbleStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(t),this.mostRecentEvent=e}handleCommentStart(e,t){if(this.gestureHasStarted)throw Error("Tried to call gesture.handleCommentStart, but the gesture had already been started.");this.setStartComment(t),this.mostRecentEvent=e}doFieldClick(){if(!this.startField)throw Error("Cannot do a field click because the start field is undefined");this.bringBlockToFront(),this.currentDropdownOwner!==this.startField&&this.startField.showEditor(this.mostRecentEvent)}doIconClick(){if(!this.startIcon)throw Error("Cannot do an icon click because the start icon is undefined");this.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");if(this.flyout.isBlockCreatable(this.targetBlock)){n.getGroup$$module$build$src$core$events$utils()||n.setGroup$$module$build$src$core$events$utils(!0);var e=this.flyout.createBlock(this.targetBlock);e.snapToGrid(),e.bumpNeighbours(),n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");e=new(w(a.CLICK))(this.startBlock,this.startWorkspace_.id,"block"),C(e)}this.bringBlockToFront(),n.setGroup$$module$build$src$core$events$utils(!1)}doWorkspaceClick(e){this.fireWorkspaceClick(this.startWorkspace_||this.creatorWorkspace)}bringBlockToFront(){this.targetBlock&&!this.flyout&&(n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.targetBlock),this.targetBlock.bringToFront())}setStartField(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField||(this.startField=e)}setStartIcon(e){if(this.gestureHasStarted)throw Error("Tried to call gesture.setStartIcon, but the gesture had already been started.");this.startIcon||(this.startIcon=e)}setStartBubble(e){this.startBubble||(this.startBubble=e)}setStartComment(e){this.startComment||(this.startComment=e)}setStartBlock(e){this.startBlock||this.startBubble||(this.startBlock=e,e.isInFlyout&&e!==e.getRootBlock()?this.setTargetBlock(e.getRootBlock()):this.setTargetBlock(e))}setTargetBlock(e){e.isShadow()?this.setTargetBlock(e.getParent()):(this.targetBlock=e,n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e))}setStartWorkspace(e){this.startWorkspace_||(this.startWorkspace_=e)}setStartFlyout(e){this.flyout||(this.flyout=e)}isBubbleClick(){return!!this.startBubble&&!this.hasExceededDragRadius}isCommentClick(){return!!this.startComment&&!this.hasExceededDragRadius}isBlockClick(){return!!this.startBlock&&!this.hasExceededDragRadius&&!this.isFieldClick()&&!this.isIconClick()}isFieldClick(){return this.startField?this.startField.isClickable()&&!this.hasExceededDragRadius&&(!this.flyout||this.startField.isClickableInFlyout(this.flyout.autoClose)):!1}isIconClick(){if(!this.startIcon)return!1;const e=!this.flyout||!this.startIcon.isClickableInFlyout||this.startIcon.isClickableInFlyout(this.flyout.autoClose);return!this.hasExceededDragRadius&&e}isWorkspaceClick(){return!this.startBlock&&!this.startBubble&&!this.startField&&!this.hasExceededDragRadius}getCurrentDragger(){let e,t;return(t=(e=this.workspaceDragger)!=null?e:this.dragger)!=null?t:null}isDragging(){return this.dragging}hasStarted(){return this.gestureHasStarted}static inProgress(){const e=xo();for(let t=0,o;o=e[t];t++)if(o.currentGesture_)return!0;return!1}},Ju=class{constructor(e,t){this.pattern=e,this.scale=1;let o;this.spacing=(o=t.spacing)!=null?o:0;let s;this.length=(s=t.length)!=null?s:1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling;let i;this.snapToGrid=(i=t.snap)!=null?i:!1}setSpacing(e){this.spacing=e,this.update(this.scale)}getSpacing(){return this.spacing}setLength(e){this.length=e,this.update(this.scale)}getLength(){return this.length}setSnapToGrid(e){this.snapToGrid=e}shouldSnap(){return this.snapToGrid}getPatternId(){return this.pattern.id}update(e){this.scale=e;var t=this.spacing*e;this.pattern.setAttribute("width",`${t}`),this.pattern.setAttribute("height",`${t}`),t=Math.floor(this.spacing/2)+.5;let o=t-this.length/2,s=t+this.length/2;t*=e,o*=e,s*=e,this.setLineAttributes(this.line1,e,o,s,t,t),this.setLineAttributes(this.line2,e,t,t,o,s)}setLineAttributes(e,t,o,s,i,r){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${o}`),e.setAttribute("y1",`${i}`),e.setAttribute("x2",`${s}`),e.setAttribute("y2",`${r}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}alignXY(e){var t=this.getSpacing();const o=t/2,s=Math.round(Math.round((e.x-o)/t)*t+o);return t=Math.round(Math.round((e.y-o)/t)*t+o),s===e.x&&t===e.y?e:new f(s,t)}static createDom(e,t,o,s){e=m(h.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},o);let i,r;if(((i=t.length)!=null?i:1)>0&&((r=t.spacing)!=null?r:0)>0){m(h.LINE,{stroke:t.colour},e);let l;(l=t.length)!=null&&l&&m(h.LINE,{stroke:t.colour},e)}else m(h.LINE,{},e);return s&&s.style.setProperty("--blocklyGridPattern",`url(#${e.id})`),e}},of=class{constructor(e){this.workspace=e,this.layers=new Map,(e=e.getInjectionDiv())&&(this.dragLayer=this.createDragLayer(e),this.animationLayer=this.createAnimationLayer(e)),e=this.createLayer(Yt),b(e,"blocklyBlockCanvas"),e=this.createLayer(nn),b(e,"blocklyBubbleCanvas")}createDragLayer(e){const t=m(h.SVG,{class:"blocklyBlockDragSurface",xmlns:Qs,"xmlns:html":nt,"xmlns:xlink":Ie,version:"1.1"});return e.append(t),m(h.G,{},t)}createAnimationLayer(e){const t=m(h.SVG,{class:"blocklyAnimationLayer",xmlns:Qs,"xmlns:html":nt,"xmlns:xlink":Ie,version:"1.1"});return e.append(t),m(h.G,{},t)}appendToAnimationLayer(e){let t;const o=(t=this.dragLayer)==null?void 0:t.getAttribute("transform");if(o){let i;(i=this.animationLayer)==null||i.setAttribute("transform",o)}let s;(s=this.animationLayer)==null||s.appendChild(e.getSvgRoot())}translateLayers(e,t){e=`translate(${e.x}, ${e.y}) scale(${t})`;let o;(o=this.dragLayer)==null||o.setAttribute("transform",e);for(const[,s]of this.layers)s.setAttribute("transform",e)}moveToDragLayer(e){let t;(t=this.dragLayer)==null||t.appendChild(e.getSvgRoot()),e.canBeFocused()&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}moveOffDragLayer(e,t){this.append(e,t),e.canBeFocused()&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e)}append(e,t){this.layers.has(t)||this.createLayer(t),e=e.getSvgRoot();let o;if(((o=this.layers.get(t))==null?void 0:o.lastChild)!==e){let s;(s=this.layers.get(t))==null||s.appendChild(e)}}createLayer(e){const t=this.workspace.getSvgGroup(),o=m(h.G,{});let s=!1;const i=[...this.layers].sort((r,l)=>r[0]-l[0]);for(const[r,l]of i)if(e<r){t.insertBefore(o,l),s=!0;break}return s||t.appendChild(o),this.layers.set(e,o),o}hasLayer(e){return e===this.dragLayer||new Set(this.layers.values()).has(e)}getBlockLayer(){return this.layers.get(Yt)}getBubbleLayer(){return this.layers.get(nn)}},lg=class{constructor(){this.curNode=this.colour=null,this.type="marker"}getCurNode(){return this.curNode}setCurNode(e){this.curNode=e}dispose(){this.curNode=null}getSourceBlockFromNode(e){return e instanceof H?e:e instanceof L||e instanceof ae?e.getSourceBlock():null}getSourceBlock(){return this.getSourceBlockFromNode(this.getCurNode())}},Zu=class extends lg{constructor(e){super(),this.workspace=e,this.type="cursor",this.potentialNodes=null}next(){var e=this.getCurNode();return e?((e=this.getNextNode(e,t=>{let o;return t instanceof H&&!((o=t.outputConnection)!=null&&o.targetBlock())||t instanceof ct},!0))&&this.setCurNode(e),e):null}in(){var e=this.getCurNode();return e?((e=this.getNextNode(e,()=>!0,!0))&&this.setCurNode(e),e):null}prev(){var e=this.getCurNode();return e?((e=this.getPreviousNode(e,t=>{let o;return t instanceof H&&!((o=t.outputConnection)!=null&&o.targetBlock())||t instanceof ct},!0))&&this.setCurNode(e),e):null}out(){var e=this.getCurNode();return e?((e=this.getPreviousNode(e,()=>!0,!0))&&this.setCurNode(e),e):null}atEndOfLine(){var e=this.getCurNode();if(!e)return!1;const t=this.getNextNode(e,()=>!0,!0);return e=this.getNextNode(e,o=>{let s;return o instanceof H&&!((s=o.outputConnection)!=null&&s.targetBlock())},!0),t===e}getNextNodeImpl(e,t,o=new Set){if(!e||o.has(e))return null;let s=this.workspace.getNavigator().getFirstChild(e)||this.workspace.getNavigator().getNextSibling(e);for(var i=e;i&&!s&&(i=this.workspace.getNavigator().getParent(i),!!i);)s=this.workspace.getNavigator().getNextSibling(i);return t(s)?s:s?(o.add(e),this.getNextNodeImpl(s,t,o)):null}getNextNode(e,t,o){return!e||!o&&this.getLastNode()===e?null:this.getNextNodeImpl(e,t)}getPreviousNodeImpl(e,t,o=new Set){if(!e||o.has(e))return null;const s=this.getRightMostChild(this.workspace.getNavigator().getPreviousSibling(e),e)||this.workspace.getNavigator().getParent(e);return t(s)?s:s?(o.add(e),this.getPreviousNodeImpl(s,t,o)):null}getPreviousNode(e,t,o){return!e||!o&&this.getFirstNode()===e?null:this.getPreviousNodeImpl(e,t)}getRightMostChild(e,t){if(!e)return e;let o=this.workspace.getNavigator().getFirstChild(e);if(!o||o===t)return e;for(e=o;e&&e!==t;e=this.workspace.getNavigator().getNextSibling(o))o=e;return this.getRightMostChild(o,t)}preDelete(e){var t=this.getCurNode();t=t?[t]:[];var o;let s,i;const r=(i=(o=e.previousConnection)==null?void 0:o.targetConnection)!=null?i:(s=e.outputConnection)==null?void 0:s.targetConnection;r&&t.push(r),(o=e.getNextBlock())&&t.push(o),(e=e.getParent())&&t.push(e),t.push(this.workspace),this.potentialNodes=t}postDelete(){const e=this.potentialNodes;if(this.potentialNodes=null,!e)throw Error("must call preDelete first");for(const t of e){let o;if((o=this.getSourceBlockFromNode(t))==null||!o.disposed){this.setCurNode(t);return}}throw Error("no valid nodes in this.potentialNodes")}getCurNode(){return n.getFocusManager$$module$build$src$core$focus_manager().getFocusedNode()}setCurNode(e){n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e),e instanceof H?e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren()):e instanceof L?(e=e.getSourceBlock(),e.workspace.scrollBoundsIntoView(e.getBoundingRectangleWithoutChildren())):e instanceof ct&&e.workspace.scrollBoundsIntoView(e.getBoundingRectangle())}getFirstNode(){return this.workspace.getNavigator().getFirstChild(this.workspace)}getLastNode(){const e=this.getFirstNode();return this.getPreviousNode(e,()=>!0,!0)}};I(g.CURSOR,Ce,Zu);var qu=class{constructor(e){this.workspace=e,this.markers=new Map,this.cursor=new Zu(this.workspace)}registerMarker(e,t){this.markers.has(e)&&this.unregisterMarker(e),this.markers.set(e,t)}unregisterMarker(e){const t=this.markers.get(e);if(t)t.dispose(),this.markers.delete(e);else throw Error("Marker with ID "+e+" does not exist. Can only unregister markers that exist.")}getCursor(){return this.cursor}getMarker(e){return this.markers.get(e)||null}setCursor(e){this.cursor=e}dispose(){const e=Object.keys(this.markers);for(let t=0,o;o=e[t];t++)this.unregisterMarker(o);this.markers.clear(),this.cursor.dispose()}};qu.LOCAL_MARKER="local_marker_1";var Qu=class extends M{constructor(e,t,o){super(e,t,o,Qu.createTextArea()),this.workspace=e,this.anchor=t,this.ownerRect=o,this.resizePointerMoveListener=this.resizePointerUpListener=null,this.textChangeListeners=[],this.sizeChangeListeners=[],this.locationChangeListeners=[],this.text="",this.DEFAULT_SIZE=new N(160+M.DOUBLE_BORDER,80+M.DOUBLE_BORDER),this.MIN_SIZE=new N(45+M.DOUBLE_BORDER,20+M.DOUBLE_BORDER),this.editable=!0,b(this.svgRoot,"blocklyTextInputBubble"),this.textArea=this.getFocusableElement(),this.inputRoot=this.createEditor(this.contentContainer,this.textArea),this.resizeGroup=this.createResizeHandle(this.svgRoot,e),this.setSize(this.DEFAULT_SIZE,!0)}getText(){return this.text}setText(e){this.text=e,this.textArea.value=e,this.onTextChange()}setEditable(e){(this.editable=e)?this.textArea.removeAttribute("readonly"):this.textArea.setAttribute("readonly","")}isEditable(){return this.editable}addTextChangeListener(e){this.textChangeListeners.push(e)}addSizeChangeListener(e){this.sizeChangeListeners.push(e)}addLocationChangeListener(e){this.locationChangeListeners.push(e)}static createTextArea(){const e=document.createElementNS(nt,"textarea");return e.className="blocklyTextarea blocklyText",e}createEditor(e,t){e=m(h.FOREIGNOBJECT,{x:M.BORDER_WIDTH,y:M.BORDER_WIDTH},e);const o=document.createElementNS(nt,"body");return o.setAttribute("xmlns",nt),o.className="blocklyMinimalBody",t.setAttribute("dir",this.workspace.RTL?"RTL":"LTR"),o.appendChild(t),e.appendChild(o),this.bindTextAreaEvents(t),e}bindTextAreaEvents(e){k(e,"wheel",this,t=>{t.stopPropagation()}),k(e,"pointerdown",this,t=>{t.stopPropagation(),Ee()}),k(e,"change",this,this.onTextChange)}createResizeHandle(e,t){return e=m(h.IMAGE,{class:"blocklyResizeHandle",href:`${t.options.pathToMedia}resize-handle.svg`},e),k(e,"pointerdown",this,this.onResizePointerDown),e}setSize(e,t=!1){e.width=Math.max(e.width,this.MIN_SIZE.width),e.height=Math.max(e.height,this.MIN_SIZE.height);const o=e.width-M.DOUBLE_BORDER,s=e.height-M.DOUBLE_BORDER;this.inputRoot.setAttribute("width",`${o}`),this.inputRoot.setAttribute("height",`${s}`),this.resizeGroup.setAttribute("y",`${s}`),this.workspace.RTL?this.resizeGroup.setAttribute("x",`${-M.DOUBLE_BORDER}`):this.resizeGroup.setAttribute("x",`${o}`),super.setSize(e,t),this.onSizeChange()}getSize(){return super.getSize()}moveDuringDrag(e){super.moveDuringDrag(e),this.onLocationChange()}setPositionRelativeToAnchor(e,t){super.setPositionRelativeToAnchor(e,t),this.onLocationChange()}positionByRect(e=new D(0,0,0,0)){super.positionByRect(e),this.onLocationChange()}onResizePointerDown(e){this.bringToFront(),We(e)||(pr(this.workspace,e,new f(this.workspace.RTL?-this.getSize().width:this.getSize().width,this.getSize().height)),this.resizePointerUpListener=k(document,"pointerup",this,this.onResizePointerUp),this.resizePointerMoveListener=k(document,"pointermove",this,this.onResizePointerMove),this.workspace.hideChaff()),e.stopPropagation()}onResizePointerUp(e){Ee(),this.resizePointerUpListener&&(x(this.resizePointerUpListener),this.resizePointerUpListener=null),this.resizePointerMoveListener&&(x(this.resizePointerMoveListener),this.resizePointerMoveListener=null)}onResizePointerMove(e){e=gr(this.workspace,e),this.setSize(new N(this.workspace.RTL?-e.x:e.x,e.y),!1),this.onSizeChange()}onTextChange(){this.text=this.textArea.value;for(const e of this.textChangeListeners)e()}onSizeChange(){for(const e of this.sizeChangeListeners)e()}onLocationChange(){for(const e of this.locationChangeListeners)e()}};qe(`
|
|
646
|
+
.blocklyTextInputBubble .blocklyTextarea {
|
|
647
|
+
background-color: var(--commentFillColour);
|
|
648
|
+
border: 0;
|
|
649
|
+
box-sizing: border-box;
|
|
650
|
+
display: block;
|
|
651
|
+
outline: 0;
|
|
652
|
+
padding: 5px;
|
|
653
|
+
resize: none;
|
|
654
|
+
width: 100%;
|
|
655
|
+
height: 100%;
|
|
656
|
+
}
|
|
657
|
+
`);var eh={};eh.register=$c,eh.unregister=Ud;var th=17,cg=160,ug=80,Nt=class extends gi{constructor(e){super(e),this.sourceBlock=e,this.textInputBubble=null,this.text="",this.bubbleSize=new N(cg,ug),this.bubbleVisiblity=!1}getType(){return Nt.TYPE}initView(e){this.svgRoot||(super.initView(e),m(h.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},this.svgRoot),m(h.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),m(h.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},this.svgRoot),b(this.svgRoot,"blocklyCommentIcon"))}dispose(){super.dispose();let e;(e=this.textInputBubble)==null||e.dispose()}getWeight(){return Nt.WEIGHT}getSize(){return new N(th,th)}applyColour(){super.applyColour();const e=this.sourceBlock.getColour();let t;(t=this.textInputBubble)==null||t.setColour(e)}updateEditable(){const e=this,t=()=>super.updateEditable;return(0,$.asyncExecutePromiseGeneratorFunction)(function*(){t().call(e),e.bubbleIsVisible()&&(yield e.setBubbleVisible(!1),yield e.setBubbleVisible(!0))})}onLocationChange(e){const t=this.workspaceLocation;super.onLocationChange(e),this.bubbleLocation&&(e=f.difference(this.workspaceLocation,t),this.bubbleLocation=f.sum(this.bubbleLocation,e)),e=this.getAnchorLocation();let o;(o=this.textInputBubble)==null||o.setAnchorLocation(e)}setText(e){const t=this.text;C(new(w(a.BLOCK_CHANGE))(this.sourceBlock,"comment",null,t,e)),this.text=e;let o;(o=this.textInputBubble)==null||o.setText(this.text)}getText(){return this.text}setBubbleSize(e){this.bubbleSize=e;let t;(t=this.textInputBubble)==null||t.setSize(this.bubbleSize,!0)}getBubbleSize(){return this.bubbleSize}setBubbleLocation(e){this.bubbleLocation=e;let t;(t=this.textInputBubble)==null||t.moveDuringDrag(e)}getBubbleLocation(){return this.bubbleLocation}saveState(){if(this.text){const e={text:this.text,pinned:this.bubbleIsVisible(),height:this.bubbleSize.height,width:this.bubbleSize.width},t=this.getBubbleLocation();return t&&(e.x=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(t.x+this.bubbleSize.width):t.x,e.y=t.y),e}return null}loadState(e){let t;this.text=(t=e.text)!=null?t:"";let o,s;this.bubbleSize=new N((o=e.width)!=null?o:cg,(s=e.height)!=null?s:ug);let i;this.bubbleVisiblity=(i=e.pinned)!=null?i:!1,this.setBubbleVisible(this.bubbleVisiblity);let r=e.x;const l=e.y;tt().then(()=>{r&&l&&(r=this.sourceBlock.workspace.RTL?this.sourceBlock.workspace.getWidth()-(r+this.bubbleSize.width):r,this.setBubbleLocation(new f(r,l)))})}onClick(){super.onClick(),this.setBubbleVisible(!this.bubbleIsVisible())}isClickableInFlyout(){return!1}onTextChange(){if(this.textInputBubble){var e=this.textInputBubble.getText();this.text!==e&&(C(new(w(a.BLOCK_CHANGE))(this.sourceBlock,"comment",null,this.text,e)),this.text=e)}}onSizeChange(){this.textInputBubble&&(this.bubbleSize=this.textInputBubble.getSize())}onBubbleLocationChange(){this.textInputBubble&&(this.bubbleLocation=this.textInputBubble.getRelativeToSurfaceXY())}bubbleIsVisible(){return this.bubbleVisiblity}setBubbleVisible(e){const t=this;return(0,$.asyncExecutePromiseGeneratorFunction)(function*(){t.bubbleVisiblity!==e&&(t.bubbleVisiblity=e,yield tt(),!t.sourceBlock.rendered||t.sourceBlock.isInFlyout||t.sourceBlock.isInsertionMarker()||(e?(t.sourceBlock.isEditable()?t.showEditableBubble():t.showNonEditableBubble(),t.applyColour()):t.hideBubble(),C(new(w(a.BUBBLE_OPEN))(t.sourceBlock,e,"comment"))))})}getBubble(){return this.textInputBubble}showEditableBubble(){this.createBubble();let e;(e=this.textInputBubble)==null||e.addTextChangeListener(()=>this.onTextChange());let t;(t=this.textInputBubble)==null||t.addSizeChangeListener(()=>this.onSizeChange())}showNonEditableBubble(){this.createBubble();let e;(e=this.textInputBubble)==null||e.setEditable(!1)}createBubble(){this.textInputBubble=new Qu(this.sourceBlock.workspace,this.getAnchorLocation(),this.getBubbleOwnerRect()),this.textInputBubble.setText(this.getText()),this.textInputBubble.setSize(this.bubbleSize,!0),this.bubbleLocation&&this.textInputBubble.moveDuringDrag(this.bubbleLocation),this.textInputBubble.addTextChangeListener(()=>this.onTextChange()),this.textInputBubble.addSizeChangeListener(()=>this.onSizeChange()),this.textInputBubble.addLocationChangeListener(()=>this.onBubbleLocationChange())}hideBubble(){let e;(e=this.textInputBubble)==null||e.dispose(),this.textInputBubble=null}getAnchorLocation(){const e=th/2;return f.sum(this.workspaceLocation,new f(e,e))}getBubbleOwnerRect(){return this.sourceBlock.getBoundingRectangleWithoutChildren()}};Nt.TYPE=se.COMMENT,Nt.WEIGHT=3,$c(Nt.TYPE,Nt);var Kt={};Kt.CommentIcon=Nt,Kt.Icon=gi,Kt.IconType=se,Kt.MutatorIcon=n.MutatorIcon$$module$build$src$core$icons$mutator_icon,Kt.WarningIcon=at,Kt.exceptions=Vp,Kt.registry=eh,n.Names$$module$build$src$core$names=class{constructor(e,t){this.db=new Map,this.dbReverse=new Set,this.variableMap=null,this.variablePrefix=t||"",this.reservedWords=new Set(e?e.split(","):[])}reset(){this.db.clear(),this.dbReverse.clear(),this.variableMap=null}setVariableMap(e){this.variableMap=e}getNameForUserVariable(e){return this.variableMap?(e=this.variableMap.getVariableById(e))?e.getName():null:(console.warn(`Deprecated call to Names.prototype.getName without defining a variable map. To fix, add the following code in your generator's init() function:
|
|
658
|
+
Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(e){e=n.allUsedVarModels$$module$build$src$core$variables(e);for(let t=0;t<e.length;t++)this.getName(e[t].getId(),n.NameType$$module$build$src$core$names.VARIABLE)}populateProcedures(e){throw Error("The implementation of populateProcedures should be monkey-patched in by blockly.ts")}getName(e,t){let o=e;t===n.NameType$$module$build$src$core$names.VARIABLE&&(e=this.getNameForUserVariable(e))&&(o=e),e=o.toLowerCase();const s=t===n.NameType$$module$build$src$core$names.VARIABLE||t===n.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"";this.db.has(t)||this.db.set(t,new Map);const i=this.db.get(t);return i.has(e)?s+i.get(e):(t=this.getDistinctName(o,t),i.set(e,t.substr(s.length)),t)}getUserNames(e){let t;return(e=(t=this.db.get(e))==null?void 0:t.keys())?Array.from(e):[]}getDistinctName(e,t){e=this.safeName(e);let o=null,s,i;for(;this.dbReverse.has(e+((s=o)!=null?s:""))||this.reservedWords.has(e+((i=o)!=null?i:""));)o=o?o+1:2;let r;return e+=(r=o)!=null?r:"",this.dbReverse.add(e),(t===n.NameType$$module$build$src$core$names.VARIABLE||t===n.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE?this.variablePrefix:"")+e}safeName(e){return e?(e=encodeURI(e.replace(/ /g,"_")).replace(/[^\w]/g,"_"),"0123456789".includes(e[0])&&(e="my_"+e)):e=n.Msg$$module$build$src$core$msg.UNNAMED_KEY||"unnamed",e}static equals(e,t){return e.toLowerCase()===t.toLowerCase()}},(function(e){e=e.NameType||(e.NameType={}),e.DEVELOPER_VARIABLE="DEVELOPER_VARIABLE",e.VARIABLE="VARIABLE",e.PROCEDURE="PROCEDURE"})(n.Names$$module$build$src$core$names||(n.Names$$module$build$src$core$names={})),n.NameType$$module$build$src$core$names=n.Names$$module$build$src$core$names.NameType,n.Names$$module$build$src$core$names.DEVELOPER_VARIABLE_TYPE=n.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE,n.NameType$$module$build$src$core$names,n.Names$$module$build$src$core$names;var hg=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t?this:(super.set(e,t),yr(t)&&t.startPublishing(),this)}delete(e){const t=this.get(e);return e=super.delete(e),e&&(yr(t)&&t.stopPublishing(),e)}clear(){if(this.size)for(const e of this.keys())this.delete(e)}add(e){return this.set(e.getId(),e)}getProcedures(){return[...this.values()]}},En,fe;En="PROCEDURE",n.DEFAULT_ARG$$module$build$src$core$procedures="x",fe={CATEGORY_NAME:En,DEFAULT_ARG:n.DEFAULT_ARG$$module$build$src$core$procedures},fe.ObservableProcedureMap=hg,fe.allProcedures=Ks,fe.findLegalName=n.findLegalName$$module$build$src$core$procedures,fe.flyoutCategory=mc,fe.getCallers=_c,fe.getDefinition=n.getDefinition$$module$build$src$core$procedures,fe.internalFlyoutCategory=vr,fe.isNameUsed=gc,fe.isProcedureBlock=Ht,fe.mutateCallers=n.mutateCallers$$module$build$src$core$procedures,fe.mutatorOpenListener=bc,fe.rename=n.rename$$module$build$src$core$procedures;var sf=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(e){return Object.prototype.hasOwnProperty.call(this,e)||(this[e]=this.nextTypeValue_,this.nextTypeValue_<<=1),this[e]}isField(e){return(e.type&this.FIELD)>=1}isHat(e){return(e.type&this.HAT)>=1}isIcon(e){return(e.type&this.ICON)>=1}isSpacer(e){return(e.type&this.SPACER)>=1}isInRowSpacer(e){return(e.type&this.IN_ROW_SPACER)>=1}isSpacerRow(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isInput(e){return(e.type&this.INPUT)>=1}isExternalInput(e){return(e.type&this.EXTERNAL_VALUE_INPUT)>=1}isInlineInput(e){return(e.type&this.INLINE_INPUT)>=1}isStatementInput(e){return(e.type&this.STATEMENT_INPUT)>=1}isPreviousConnection(e){return(e.type&this.PREVIOUS_CONNECTION)>=1}isNextConnection(e){return(e.type&this.NEXT_CONNECTION)>=1}isPreviousOrNextConnection(e){return this.isPreviousConnection(e)||this.isNextConnection(e)}isRoundCorner(e){return(e.type&this.LEFT_ROUND_CORNER)>=1||(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.LEFT_ROUND_CORNER)>=1}isRightRoundedCorner(e){return this.isRoundCorner(e)&&(e.type&this.RIGHT_ROUND_CORNER)>=1}isLeftSquareCorner(e){return(e.type&this.LEFT_SQUARE_CORNER)>=1}isRightSquareCorner(e){return(e.type&this.RIGHT_SQUARE_CORNER)>=1}isCorner(e){return(e.type&this.CORNER)>=1}isJaggedEdge(e){return(e.type&this.JAGGED_EDGE)>=1}isRow(e){return(e.type&this.ROW)>=1}isBetweenRowSpacer(e){return(e.type&this.BETWEEN_ROW_SPACER)>=1}isTopRow(e){return(e.type&this.TOP_ROW)>=1}isBottomRow(e){return(e.type&this.BOTTOM_ROW)>=1}isTopOrBottomRow(e){return this.isTopRow(e)||this.isBottomRow(e)}isInputRow(e){return(e.type&this.INPUT_ROW)>=1}},u=new sf,dt=class{constructor(e){this.centerline=this.xPos=this.height=this.width=0,this.constants_=e,this.type=u.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},_i=class{constructor(e){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_=e,this.type=u.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let e=this.elements.length-1;e>=0;e--){const t=this.elements[e];if(u.isInput(t))return t}return null}measure(){throw Error("Unexpected attempt to measure a base Row.")}startsWithElemSpacer(){return!0}endsWithElemSpacer(){return!0}getFirstSpacer(){for(let e=0;e<this.elements.length;e++){const t=this.elements[e];if(u.isInRowSpacer(t))return t}return null}getLastSpacer(){for(let e=this.elements.length-1;e>=0;e--){const t=this.elements[e];if(u.isInRowSpacer(t))return t}return null}},oh=class extends _i{constructor(e){super(e),this.hasNextConnection=!1,this.connection=null,this.baseline=this.descenderHeight=0,this.type|=u.BOTTOM_ROW}hasLeftSquareCorner(e){return!!e.outputConnection||!!e.getNextBlock()}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,o=0;for(let s=0;s<this.elements.length;s++){const i=this.elements[s];t+=i.width,u.isSpacer(i)||(u.isNextConnection(i)?o=Math.max(o,i.height):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+o,this.descenderHeight=o,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},ko=class extends dt{constructor(e,t){super(e),this.connectionModel=t,this.type|=u.CONNECTION,this.shape=this.constants_.shapeFor(t),this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic,this.highlighted=t.isHighlighted()}},Tn=class extends ko{constructor(e,t){super(e,t.connection),this.input=t,this.connectionOffsetY=this.connectionOffsetX=0,this.type|=u.INPUT,this.align=t.align,(this.connectedBlock=t.connection&&t.connection.targetBlock()?t.connection.targetBlock():null)?(e=this.connectedBlock.getHeightWidth(),this.connectedBlockWidth=e.width,this.connectedBlockHeight=e.height):this.connectedBlockHeight=this.connectedBlockWidth=0}},sh=class extends Tn{constructor(e,t){super(e,t),this.height=0,this.type|=u.EXTERNAL_VALUE_INPUT,this.height=this.connectedBlock?this.connectedBlockHeight-this.constants_.TAB_OFFSET_FROM_TOP-this.constants_.MEDIUM_PADDING:this.shape.height,this.width=this.shape.width+this.constants_.EXTERNAL_VALUE_INPUT_PADDING,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP,this.connectionHeight=this.shape.height,this.connectionWidth=this.shape.width}},ih=class extends dt{constructor(e,t,o){super(e),this.field=t,this.parentInput=o,this.isEditable=t.EDITABLE,this.flipRtl=t.getFlipRtl(),this.type|=u.FIELD,e=this.field.getSize(),this.height=e.height,this.width=e.width}},ag=class extends dt{constructor(e){super(e),this.type|=u.HAT,this.height=this.constants_.START_HAT.height,this.width=this.constants_.START_HAT.width,this.ascenderHeight=this.height}},dg=class extends dt{constructor(e,t){super(e),this.icon=t,this.flipRtl=!1,this.type|=u.ICON,e=t.getSize(),this.height=e.height,this.width=e.width}},Oe=class extends dt{constructor(e,t){super(e),this.type|=u.SPACER|u.IN_ROW_SPACER,this.width=t,this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},rh=class extends Tn{constructor(e,t){super(e,t),this.type|=u.INLINE_INPUT,this.connectedBlock?(this.width=this.connectedBlockWidth,this.height=this.connectedBlockHeight):(this.height=this.constants_.EMPTY_INLINE_INPUT_HEIGHT,this.width=this.constants_.EMPTY_INLINE_INPUT_PADDING),this.connectionHeight=this.isDynamicShape?this.shape.height(this.height):this.shape.height,this.connectionWidth=this.isDynamicShape?this.shape.width(this.height):this.shape.width,this.connectedBlock||(this.width+=this.connectionWidth*(this.isDynamicShape?2:1)),this.connectionOffsetY="connectionOffsetY"in this.shape?this.shape.connectionOffsetY(this.connectionHeight):this.constants_.TAB_OFFSET_FROM_TOP,this.connectionOffsetX="connectionOffsetX"in this.shape?this.shape.connectionOffsetX(this.connectionWidth):0}},nh=class extends _i{constructor(e){super(e),this.connectedBlockWidths=0,this.type|=u.INPUT_ROW}measure(){this.width=this.minWidth,this.height=this.minHeight;let e=0;for(let t=0;t<this.elements.length;t++){const o=this.elements[t];this.width+=o.width,u.isInput(o)&&(u.isStatementInput(o)?e+=o.connectedBlockWidth:u.isExternalInput(o)&&o.connectedBlockWidth!==0&&(e+=o.connectedBlockWidth-o.connectionWidth)),u.isSpacer(o)||(this.height=Math.max(this.height,o.height))}this.connectedBlockWidths=e,this.widthWithConnectedBlocks=this.width+e}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},$g=class extends dt{constructor(e){super(e),this.type|=u.JAGGED_EDGE,this.height=this.constants_.JAGGED_TEETH.height,this.width=this.constants_.JAGGED_TEETH.width}},pg=class extends ko{constructor(e,t){super(e,t),this.type|=u.NEXT_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},gg=class extends ko{constructor(e,t){super(e,t),this.connectionOffsetX=0,this.type|=u.OUTPUT_CONNECTION,this.height=this.isDynamicShape?0:this.shape.height,this.startX=this.width=this.isDynamicShape?0:this.shape.width,this.connectionOffsetY=this.constants_.TAB_OFFSET_FROM_TOP}},mg=class extends ko{constructor(e,t){super(e,t),this.type|=u.PREVIOUS_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},Ei=class extends dt{constructor(e,t){super(e),this.type=(t&&t!=="left"?u.RIGHT_ROUND_CORNER:u.LEFT_ROUND_CORNER)|u.CORNER,this.width=this.constants_.CORNER_RADIUS,this.height=this.constants_.CORNER_RADIUS/2}},lh=class extends _i{constructor(e,t,o){super(e),this.height=t,this.width=o,this.precedesStatement=this.followsStatement=!1,this.widthWithConnectedBlocks=0,this.type|=u.SPACER|u.BETWEEN_ROW_SPACER,this.elements=[new Oe(this.constants_,o)]}measure(){}},Ti=class extends dt{constructor(e,t){super(e),this.type=(t&&t!=="left"?u.RIGHT_SQUARE_CORNER:u.LEFT_SQUARE_CORNER)|u.CORNER,this.width=this.height=this.constants_.NO_PADDING}},yn=class extends Tn{constructor(e,t){super(e,t),this.type|=u.STATEMENT_INPUT,this.height=this.connectedBlock?this.connectedBlockHeight+this.constants_.STATEMENT_BOTTOM_SPACER:this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT,this.width=this.constants_.STATEMENT_INPUT_NOTCH_OFFSET+this.shape.width}},ch=class extends _i{constructor(e){super(e),this.ascenderHeight=this.capline=0,this.hasPreviousConnection=!1,this.connection=null,this.type|=u.TOP_ROW}hasLeftSquareCorner(e){const t=(e.hat?e.hat==="cap":this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection,o=e.getPreviousBlock();return!!e.outputConnection||t||(o?o.getNextBlock()===e:!1)}hasRightSquareCorner(e){return!0}measure(){let e=0,t=0,o=0;for(let s=0;s<this.elements.length;s++){const i=this.elements[s];t+=i.width,u.isSpacer(i)||(u.isHat(i)?o=Math.max(o,i.ascenderHeight):e=Math.max(e,i.height))}this.width=Math.max(this.minWidth,t),this.height=Math.max(this.minHeight,e)+o,this.capline=this.ascenderHeight=o,this.widthWithConnectedBlocks=this.width}startsWithElemSpacer(){return!1}endsWithElemSpacer(){return!1}},vn=class{constructor(){this.NO_PADDING=0,this.SMALL_PADDING=3,this.MEDIUM_PADDING=5,this.MEDIUM_LARGE_PADDING=8,this.LARGE_PADDING=10,this.TAB_HEIGHT=15,this.TAB_OFFSET_FROM_TOP=5,this.TAB_VERTICAL_OVERLAP=2.5,this.TAB_WIDTH=8,this.NOTCH_WIDTH=15,this.NOTCH_HEIGHT=4,this.MIN_BLOCK_WIDTH=12,this.EMPTY_BLOCK_SPACER_HEIGHT=16,this.CORNER_RADIUS=8,this.NOTCH_OFFSET_LEFT=15,this.STATEMENT_BOTTOM_SPACER=0,this.STATEMENT_INPUT_PADDING_LEFT=20,this.BETWEEN_STATEMENT_PADDING_Y=4,this.ADD_START_HATS=!1,this.START_HAT_HEIGHT=15,this.START_HAT_WIDTH=100,this.SPACER_DEFAULT_HEIGHT=15,this.MIN_BLOCK_HEIGHT=24,this.EMPTY_INLINE_INPUT_PADDING=14.5,this.EXTERNAL_VALUE_INPUT_PADDING=2,this.JAGGED_TEETH_HEIGHT=12,this.JAGGED_TEETH_WIDTH=6,this.FIELD_TEXT_FONTSIZE=11,this.FIELD_TEXT_FONTWEIGHT="normal",this.FIELD_TEXT_FONTFAMILY="sans-serif",this.FIELD_TEXT_BASELINE=this.FIELD_TEXT_HEIGHT=-1,this.FIELD_BORDER_RECT_RADIUS=4,this.FIELD_BORDER_RECT_HEIGHT=16,this.FIELD_BORDER_RECT_X_PADDING=5,this.FIELD_BORDER_RECT_Y_PADDING=3,this.FIELD_BORDER_RECT_COLOUR="#fff",this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!1,this.FIELD_DROPDOWN_SVG_ARROW_SIZE=12,this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=!1,this.FIELD_COLOUR_DEFAULT_WIDTH=26,this.defs=null,this.embossFilterId="",this.embossFilter=null,this.disabledPatternId="",this.disabledPattern=null,this.debugFilterId="",this.cssNode=this.debugFilter=null,this.CURSOR_COLOUR="#cc0a0a",this.MARKER_COLOUR="#4286f4",this.CURSOR_WS_WIDTH=100,this.WS_CURSOR_HEIGHT=5,this.CURSOR_STACK_PADDING=10,this.CURSOR_BLOCK_PADDING=2,this.CURSOR_STROKE_WIDTH=4,this.FULL_BLOCK_FIELDS=!1,this.INSERTION_MARKER_COLOUR="#000000",this.INSERTION_MARKER_OPACITY=.2,this.SHAPES={PUZZLE:1,NOTCH:2},this.TALL_INPUT_FIELD_OFFSET_Y=this.MEDIUM_PADDING,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=this.DUMMY_INPUT_MIN_HEIGHT=this.TAB_HEIGHT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT,this.TOP_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.MEDIUM_PADDING,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.EMPTY_INLINE_INPUT_HEIGHT=this.TAB_HEIGHT+11,this.EMPTY_STATEMENT_INPUT_HEIGHT=this.MIN_BLOCK_HEIGHT,this.START_POINT=K(0,0),this.FIELD_TEXT_BASELINE_CENTER=!0,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_DROPDOWN_SVG_ARROW_DATAURI="data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMi43MSIgaGVpZ2h0PSI4Ljc5IiB2aWV3Qm94PSIwIDAgMTIuNzEgOC43OSI+PHRpdGxlPmRyb3Bkb3duLWFycm93PC90aXRsZT48ZyBvcGFjaXR5PSIwLjEiPjxwYXRoIGQ9Ik0xMi43MSwyLjQ0QTIuNDEsMi40MSwwLDAsMSwxMiw0LjE2TDguMDgsOC4wOGEyLjQ1LDIuNDUsMCwwLDEtMy40NSwwTDAuNzIsNC4xNkEyLjQyLDIuNDIsMCwwLDEsMCwyLjQ0LDIuNDgsMi40OCwwLDAsMSwuNzEuNzFDMSwwLjQ3LDEuNDMsMCw2LjM2LDBTMTEuNzUsMC40NiwxMiwuNzFBMi40NCwyLjQ0LDAsMCwxLDEyLjcxLDIuNDRaIiBmaWxsPSIjMjMxZjIwIi8+PC9nPjxwYXRoIGQ9Ik02LjM2LDcuNzlhMS40MywxLjQzLDAsMCwxLTEtLjQyTDEuNDIsMy40NWExLjQ0LDEuNDQsMCwwLDEsMC0yYzAuNTYtLjU2LDkuMzEtMC41Niw5Ljg3LDBhMS40NCwxLjQ0LDAsMCwxLDAsMkw3LjM3LDcuMzdBMS40MywxLjQzLDAsMCwxLDYuMzYsNy43OVoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=",this.FIELD_COLOUR_DEFAULT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT,this.FIELD_CHECKBOX_X_OFFSET=this.FIELD_BORDER_RECT_X_PADDING-3,this.randomIdentifier=String(Math.random()).substring(2)}init(){this.JAGGED_TEETH=this.makeJaggedTeeth(),this.NOTCH=this.makeNotch(),this.START_HAT=this.makeStartHat(),this.PUZZLE_TAB=this.makePuzzleTab(),this.INSIDE_CORNERS=this.makeInsideCorners(),this.OUTSIDE_CORNERS=this.makeOutsideCorners()}setTheme(e){this.blockStyles=Object.create(null);const t=e.blockStyles;for(const o in t)this.blockStyles[o]=this.validatedBlockStyle_(t[o]);this.setDynamicProperties_(e)}setDynamicProperties_(e){this.setFontConstants_(e),this.setComponentConstants_(e),this.ADD_START_HATS=e.startHats!==void 0?e.startHats:this.ADD_START_HATS}setFontConstants_(e){e.fontStyle&&e.fontStyle.family&&(this.FIELD_TEXT_FONTFAMILY=e.fontStyle.family),e.fontStyle&&e.fontStyle.weight&&(this.FIELD_TEXT_FONTWEIGHT=e.fontStyle.weight),e.fontStyle&&e.fontStyle.size&&(this.FIELD_TEXT_FONTSIZE=e.fontStyle.size),e=Pi("Hg",this.FIELD_TEXT_FONTSIZE+"pt",this.FIELD_TEXT_FONTWEIGHT,this.FIELD_TEXT_FONTFAMILY),this.FIELD_TEXT_HEIGHT=e.height,this.FIELD_TEXT_BASELINE=e.baseline}setComponentConstants_(e){this.CURSOR_COLOUR=e.getComponentStyle("cursorColour")||this.CURSOR_COLOUR,this.MARKER_COLOUR=e.getComponentStyle("markerColour")||this.MARKER_COLOUR,this.INSERTION_MARKER_COLOUR=e.getComponentStyle("insertionMarkerColour")||this.INSERTION_MARKER_COLOUR,this.INSERTION_MARKER_OPACITY=Number(e.getComponentStyle("insertionMarkerOpacity"))||this.INSERTION_MARKER_OPACITY}getBlockStyleForColour(e){const t="auto_"+e;return this.blockStyles[t]||(this.blockStyles[t]=this.createBlockStyle_(e)),{style:this.blockStyles[t],name:t}}getBlockStyle(e){return this.blockStyles[e||""]||(e&&e.startsWith("auto_")?this.getBlockStyleForColour(e.substring(5)).style:this.createBlockStyle_("#000000"))}createBlockStyle_(e){return this.validatedBlockStyle_({colourPrimary:e})}validatedBlockStyle_(e){const t={};return e&&Object.assign(t,e),e=Uo(t.colourPrimary||"#000"),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?Uo(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?Uo(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||"",t}generateSecondaryColour_(e){return lo("#fff",e,.6)||e}generateTertiaryColour_(e){return lo("#fff",e,.3)||e}dispose(){this.embossFilter&&F(this.embossFilter),this.disabledPattern&&F(this.disabledPattern),this.debugFilter&&F(this.debugFilter),this.cssNode=null}makeJaggedTeeth(){const e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH,o=jo([y(t,e/4),y(-t*2,e/2),y(t,e/4)]);return{height:e,width:t,path:o}}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=ve("c",[y(30,-e),y(70,-e),y(t,0)]);return{height:e*.75,width:t,path:o}}makePuzzleTab(){function e(r){r=r?-1:1;const l=-r;var c=o/2;const p=c+2.5,T=c+.5,Y=y(-t,r*c);return c=y(t,r*c),ve("c",[y(0,r*p),y(-t,l*T),Y])+ve("s",[y(t,l*2.5),c])}const t=this.TAB_WIDTH,o=this.TAB_HEIGHT,s=e(!0),i=e(!1);return{type:this.SHAPES.PUZZLE,width:t,height:o,pathDown:i,pathUp:s}}makeNotch(){function e(l){return jo([y(l*s,o),y(l*3,0),y(l*s,-o)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=(t-3)/2,i=e(1),r=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:i,pathRight:r}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=Z("a","0 0,0",e,y(-e,e)),o=Z("a","0 0,0",e,y(e,e));return{width:e,height:e,pathTop:t,pathBottom:o}}makeOutsideCorners(){const e=this.CORNER_RADIUS,t=K(0,e)+Z("a","0 0,1",e,y(e,-e)),o=Z("a","0 0,1",e,y(e,e)),s=Z("a","0 0,1",e,y(-e,-e)),i=Z("a","0 0,1",e,y(-e,e));return{topLeft:t,topRight:o,bottomRight:i,bottomLeft:s,rightHeight:e}}shapeFor(e){switch(e.type){case E.INPUT_VALUE:case E.OUTPUT_VALUE:return this.PUZZLE_TAB;case E.PREVIOUS_STATEMENT:case E.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type")}}createDom(e,t,o,s){this.injectCSS_(t,o),this.defs=m(h.DEFS,{},e),e=m(h.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs),m(h.FEGAUSSIANBLUR,{in:"SourceAlpha",stdDeviation:1,result:"blur"},e),t=m(h.FESPECULARLIGHTING,{in:"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e),m(h.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),m(h.FECOMPOSITE,{in:"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e),m(h.FECOMPOSITE,{in:"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter=e,e=m(h.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",width:10,height:10},this.defs),m(h.RECT,{width:10,height:10,fill:"#aaa"},e),m(h.PATH,{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},e),this.disabledPatternId=e.id,this.disabledPattern=e,this.createDebugFilter(),s&&(s.style.setProperty("--blocklyEmbossFilter",`url(#${this.embossFilterId})`),s.style.setProperty("--blocklyDisabledPattern",`url(#${this.disabledPatternId})`),s.style.setProperty("--blocklyDebugFilter",`url(#${this.debugFilterId})`))}createDebugFilter(){if(!this.debugFilter){const e=m(h.FILTER,{id:"blocklyDebugFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs),t=m(h.FECOMPONENTTRANSFER,{result:"outBlur"},e);m(h.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),m(h.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},e),m(h.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),this.debugFilterId=e.id,this.debugFilter=e}}injectCSS_(e,t){t=this.getCSS_(t),e="blockly-renderer-style-"+e,this.cssNode=document.getElementById(e);const o=t.join(`
|
|
659
|
+
`);this.cssNode?this.cssNode.firstChild.textContent=o:(t=document.createElement("style"),t.id=e,e=document.createTextNode(o),t.appendChild(e),document.head.insertBefore(t,document.head.firstChild),this.cssNode=t)}getCSS_(e){return[`${e} .blocklyText, `,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect,`,`${e} .blocklyEditableField>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text {`,"fill: #000;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${e} .blocklyEditableField:not(.blocklyEditing):hover>rect {`,"stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"}",`${e} .blocklySelected>.blocklyPath {`,"stroke: #fc3;","stroke-width: 3px;","}",`${e} .blocklyHighlightedConnectionPath {`,"stroke: #fc3;","}",`${e} .blocklyReplaceable .blocklyPath {`,"fill-opacity: .5;","}",`${e} .blocklyReplaceable .blocklyPathLight,`,`${e} .blocklyReplaceable .blocklyPathDark {`,"display: none;","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},Cn=class{constructor(e,t){this.inlinePath_=this.outlinePath_="",this.block_=e,this.info_=t,this.topLeft_=e.getRelativeToSurfaceXY(),this.constants_=t.getRenderer().getConstants()}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),this.block_.pathObject.setPath(this.outlinePath_+`
|
|
660
|
+
`+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren,this.block_.childlessWidth=this.info_.width}drawOutline_(){this.drawTop_();for(let e=1;e<this.info_.rows.length-1;e++){const t=this.info_.rows[e];t.hasJaggedEdge?this.drawJaggedEdge_(t):t.hasStatement?this.drawStatementInput_(t):t.hasExternalInput?this.drawValueInput_(t):this.drawRightSideRow_(t)}this.drawBottom_(),this.drawLeft_()}drawTop_(){const e=this.info_.topRow,t=e.elements;this.positionPreviousConnection_(),this.outlinePath_+=K(e.xPos,this.info_.startY);for(let o=0,s;s=t[o];o++)u.isLeftRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:u.isRightRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:u.isPreviousConnection(s)?this.outlinePath_+=s.shape.pathLeft:u.isHat(s)?this.outlinePath_+=this.constants_.START_HAT.path:u.isSpacer(s)&&(this.outlinePath_+=v("h",s.width));this.outlinePath_+=v("v",e.height)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+v("v",e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){const t=e.getLastInput();this.positionExternalValueConnection_(e);const o=Cr(t.shape)?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=v("H",t.xPos+t.width)+o+v("v",e.height-t.connectionHeight)}drawStatementInput_(e){var t=e.getLastInput();if(t){var o=t.xPos+t.notchOffset+t.shape.width;t=t.shape.pathRight+v("h",-(t.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop;var s=e.height-2*this.constants_.INSIDE_CORNERS.height;this.outlinePath_+=v("H",o)+t+v("v",s)+this.constants_.INSIDE_CORNERS.pathBottom+v("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=v("V",e.yPos+e.height)}drawBottom_(){const e=this.info_.bottomRow,t=e.elements;this.positionNextConnection_();let o=0,s="";for(let i=t.length-1,r;r=t[i];i--)u.isNextConnection(r)?s+=r.shape.pathRight:u.isLeftSquareCorner(r)?s+=v("H",e.xPos):u.isLeftRoundedCorner(r)?s+=this.constants_.OUTSIDE_CORNERS.bottomLeft:u.isRightRoundedCorner(r)?(s+=this.constants_.OUTSIDE_CORNERS.bottomRight,o=this.constants_.OUTSIDE_CORNERS.rightHeight):u.isSpacer(r)&&(s+=v("h",r.width*-1));this.outlinePath_+=v("V",e.baseline-o),this.outlinePath_+=s}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){const t=e.connectionOffsetY+e.height;e=Cr(e.shape)?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=v("V",t)+e}this.outlinePath_+="z"}drawInternals_(){for(let e=0,t;t=this.info_.rows[e];e++)for(let o=0,s;s=t.elements[o];o++)u.isInlineInput(s)?this.drawInlineInput_(s):(u.isIcon(s)||u.isField(s))&&this.layoutField_(s)}layoutField_(e){const t=e.centerline-e.height/2;let o=e.xPos;var s="";this.info_.RTL&&(o=-(o+e.width),e.flipRtl&&(o+=e.width,s="scale(-1 1)")),u.isIcon(e)?(s=e.icon,s.setOffsetInBlock(new f(o,t)),this.info_.isInsertionMarker&&s.hideForInsertionMarker()):(e=e.field.getSvgRoot(),e.setAttribute("transform","translate("+o+","+t+")"+s),this.info_.isInsertionMarker&&e.setAttribute("display","none"))}drawInlineInput_(e){const t=e.width,o=e.height,s=e.connectionOffsetY,i=e.connectionHeight+s;this.inlinePath_+=ce(e.xPos+e.connectionWidth,e.centerline-o/2)+v("v",s)+e.shape.pathDown+v("v",o-i)+v("h",t-e.connectionWidth)+v("v",-o)+"z",this.positionInlineInputConnection_(e)}positionInlineInputConnection_(e){const t=e.centerline-e.height/2;if(e.connectionModel){let o=e.xPos+e.connectionWidth+e.connectionOffsetX;this.info_.RTL&&(o*=-1),e.connectionModel.setOffsetInBlock(o,t+e.connectionOffsetY)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let o=e.xPos+e.statementEdge+t.notchOffset;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let o=e.xPos+e.width;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionPreviousConnection_(){const e=this.info_.topRow;if(e.connection){const t=e.xPos+e.notchOffset;e.connection.connectionModel.setOffsetInBlock(this.info_.RTL?-t:t,0)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,o=t.xPos;t.connectionModel.setOffsetInBlock(this.info_.RTL?-o:o,e.baseline)}}positionOutputConnection_(){if(this.info_.outputConnection){const e=this.info_.startX+this.info_.outputConnection.connectionOffsetX;this.block_.outputConnection.setOffsetInBlock(this.info_.RTL?-e:e,this.info_.outputConnection.connectionOffsetY)}}updateConnectionHighlights(){for(const e of this.info_.rows)for(const t of e.elements){if(!(t instanceof ko))continue;const o=this.drawConnectionHighlightPath(t);o&&(o.style.display=t.highlighted?"":"none")}}drawConnectionHighlightPath(e){const t=e.connectionModel;e=t.type===E.INPUT_VALUE||t.type===E.OUTPUT_VALUE?this.getExpressionConnectionHighlightPath(e):this.getStatementConnectionHighlightPath(e);const o=t.getSourceBlock();let s,i;return(i=(s=o.pathObject).addConnectionHighlight)==null?void 0:i.call(s,t,e,t.getOffsetInBlock(),o.RTL)}getExpressionConnectionHighlightPath(e){let t="";return Cr(e.shape)?t=e.shape.pathDown(e.height):jd(e.shape)&&(t=e.shape.pathDown),e=this.constants_.TAB_OFFSET_FROM_TOP,K(0,-e)+v("v",e)+t+v("v",e)}getStatementConnectionHighlightPath(e){if(!Jd(e.shape))throw Error("Statement connections should have notch shapes");const t=this.constants_.NOTCH_OFFSET_LEFT-this.constants_.CORNER_RADIUS;return K(-t,0)+v("h",t)+e.shape.pathLeft+v("h",t)}},yi=class{constructor(e,t){this.statementEdge=this.width=this.widthWithChildren=this.height=0,this.rows=[],this.inputRows=[],this.startY=this.startX=0,this.renderer_=e,this.block_=t,this.constants_=this.renderer_.getConstants(),this.outputConnection=t.outputConnection?new gg(this.constants_,t.outputConnection):null,this.isInline=t.getInputsInline()&&!t.isCollapsed(),this.isCollapsed=t.isCollapsed(),this.isInsertionMarker=t.isInsertionMarker(),this.RTL=t.RTL,this.topRow=new ch(this.constants_),this.bottomRow=new oh(this.constants_)}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}createRows_(){this.populateTopRow_(),this.rows.push(this.topRow);let e=new nh(this.constants_);this.inputRows.push(e);var t=this.block_.getIcons();for(let o=0,s;s=t[o];o++){const i=new dg(this.constants_,s);this.isCollapsed&&!s.isShownWhenCollapsed()||e.elements.push(i)}t=void 0;for(let o=0,s;s=this.block_.inputList[o];o++)if(s.isVisible()){this.shouldStartNewRow_(s,t)&&(this.rows.push(e),e=new nh(this.constants_),this.inputRows.push(e));for(let i=0,r;r=s.fieldRow[i];i++)e.elements.push(new ih(this.constants_,r,s));this.addInput_(s,e),t=s}this.isCollapsed&&(e.hasJaggedEdge=!0,e.elements.push(new $g(this.constants_))),(e.elements.length||e.hasDummyInput)&&this.rows.push(e),this.populateBottomRow_(),this.rows.push(this.bottomRow)}populateTopRow_(){var e=!!this.block_.previousConnection;const t=(this.block_.hat?this.block_.hat==="cap":this.constants_.ADD_START_HATS)&&!this.outputConnection&&!e;let o=this.topRow.hasLeftSquareCorner(this.block_)?Ti:Ei;this.topRow.elements.push(new o(this.constants_)),t?(e=new ag(this.constants_),this.topRow.elements.push(e)):e&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new mg(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection)),this.block_.inputList.length&&this.block_.inputList[0]instanceof Ae&&!this.block_.isCollapsed()?this.topRow.minHeight=this.constants_.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT:this.topRow.minHeight=this.constants_.TOP_ROW_MIN_HEIGHT,o=this.topRow.hasRightSquareCorner(this.block_)?Ti:Ei,this.topRow.elements.push(new o(this.constants_,"right"))}populateBottomRow_(){this.bottomRow.hasNextConnection=!!this.block_.nextConnection,this.bottomRow.minHeight=this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Ae?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT,this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new Ti(this.constants_)):this.bottomRow.elements.push(new Ei(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new pg(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection)),this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new Ti(this.constants_,"right")):this.bottomRow.elements.push(new Ei(this.constants_,"right"))}addInput_(e,t){this.isInline&&e instanceof n.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new rh(this.constants_,e)),t.hasInlineInput=!0):e instanceof Ae?(t.elements.push(new yn(this.constants_,e)),t.hasStatement=!0):e instanceof n.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new sh(this.constants_,e)),t.hasExternalInput=!0):(e instanceof ht||e instanceof Dt)&&(t.minHeight=Math.max(t.minHeight,e.getSourceBlock()&&e.getSourceBlock().isShadow()?this.constants_.DUMMY_INPUT_SHADOW_MIN_HEIGHT:this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),t.align===null&&(t.align=e.align)}shouldStartNewRow_(e,t){return t?t instanceof Dt||e instanceof Ae||t instanceof Ae?!0:e instanceof n.ValueInput$$module$build$src$core$inputs$value_input||e instanceof ht||t instanceof n.ValueInput$$module$build$src$core$inputs$value_input?!this.isInline:!1:!1}addElemSpacing_(){for(let e=0,t;t=this.rows[e];e++){const o=t.elements;if(t.elements=[],t.startsWithElemSpacer()&&t.elements.push(new Oe(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let s=0;s<o.length-1;s++){t.elements.push(o[s]);const i=this.getInRowSpacing_(o[s],o[s+1]);t.elements.push(new Oe(this.constants_,i))}t.elements.push(o[o.length-1]),t.endsWithElemSpacer()&&t.elements.push(new Oe(this.constants_,this.getInRowSpacing_(o[o.length-1],null)))}}}getInRowSpacing_(e,t){if(!e&&t&&u.isStatementInput(t))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(e&&u.isInput(e)&&!t){if(u.isExternalInput(e))return this.constants_.NO_PADDING;if(u.isInlineInput(e))return this.constants_.LARGE_PADDING;if(u.isStatementInput(e))return this.constants_.NO_PADDING}return e&&u.isLeftSquareCorner(e)&&t&&(u.isPreviousConnection(t)||u.isNextConnection(t))?t.notchOffset:e&&u.isLeftRoundedCorner(e)&&t&&(u.isPreviousConnection(t)||u.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&u.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING}computeBounds_(){let e=0,t=0,o=0;for(let i=0,r;r=this.rows[i];i++){if(r.measure(),t=Math.max(t,r.width),r.hasStatement){var s=r.getLastInput();let l,c;s=r.width-((c=(l=s)==null?void 0:l.width)!=null?c:0),e=Math.max(e,s)}o=Math.max(o,r.widthWithConnectedBlocks)}this.statementEdge=e,this.width=t;for(let i=0,r;r=this.rows[i];i++)r.hasStatement&&(r.statementEdge=this.statementEdge);this.widthWithChildren=Math.max(t,o),this.outputConnection&&(this.startX=this.outputConnection.width,this.width+=this.outputConnection.width,this.widthWithChildren+=this.outputConnection.width)}alignRowElements_(){for(let t=0,o;o=this.rows[t];t++)if(o.hasStatement)this.alignStatementRow_(o);else{var e=o.width;e=this.getDesiredRowWidth_(o)-e,e>0&&this.addAlignmentPadding_(o,e),u.isTopOrBottomRow(o)&&(o.widthWithConnectedBlocks=o.width)}}getDesiredRowWidth_(e){return this.width-this.startX}addAlignmentPadding_(e,t){const o=e.getFirstSpacer(),s=e.getLastSpacer();if((e.hasExternalInput||e.hasStatement)&&(e.widthWithConnectedBlocks+=t),e.align===n.Align$$module$build$src$core$inputs$align.LEFT&&s)s.width+=t;else if(e.align===n.Align$$module$build$src$core$inputs$align.CENTRE&&o&&s)o.width+=t/2,s.width+=t/2;else if(e.align===n.Align$$module$build$src$core$inputs$align.RIGHT&&o)o.width+=t;else if(s)s.width+=t;else return;e.width+=t}alignStatementRow_(e){const t=e.getLastInput();if(t){var o=e.width-t.width,s=this.statementEdge;o=s-o,o>0&&this.addAlignmentPadding_(e,o),o=e.width,s=this.getDesiredRowWidth_(e),t.width+=s-o,t.height=Math.max(t.height,e.height),e.width+=s-o,e.widthWithConnectedBlocks=Math.max(e.width,this.statementEdge+e.connectedBlockWidths)}}addRowSpacing_(){const e=this.rows;this.rows=[];for(let t=0;t<e.length;t++)this.rows.push(e[t]),t!==e.length-1&&this.rows.push(this.makeSpacerRow_(e[t],e[t+1]))}makeSpacerRow_(e,t){var o=this.getSpacerRowHeight_(e,t);const s=this.getSpacerRowWidth_(e,t);return o=new lh(this.constants_,o,s),e.hasStatement&&(o.followsStatement=!0),t.hasStatement&&(o.precedesStatement=!0),o}getSpacerRowWidth_(e,t){return this.width-this.startX}getSpacerRowHeight_(e,t){return this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){return u.isSpacer(t)?e.yPos+t.height/2:u.isBottomRow(e)?(e=e.yPos+e.height-e.descenderHeight,u.isNextConnection(t)?e+t.height/2:e-t.height/2):u.isTopRow(e)?u.isHat(t)?e.capline-t.height/2:e.capline+t.height/2:e.yPos+e.height/2}recordElemPositions_(e){let t=e.xPos;for(let o=0,s;s=e.elements[o];o++)u.isSpacer(s)&&(s.height=e.height),s.xPos=t,s.centerline=this.getElemCenterline_(e,s),t+=s.width}finalize_(){let e=0,t=0;for(let o=0,s;s=this.rows[o];o++)s.yPos=t,s.xPos=this.startX,t+=s.height,e=Math.max(e,s.widthWithConnectedBlocks),this.recordElemPositions_(s);if(this.outputConnection&&this.block_.nextConnection){const o=this.block_.nextConnection.targetBlock();o&&(e=Math.max(e,o.getHeightWidth().width))}this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline,this.bottomRow.baseline=t-this.bottomRow.descenderHeight}getMeasureableForConnection(e){let t;if(((t=this.outputConnection)==null?void 0:t.connectionModel)===e)return this.outputConnection;for(const o of this.rows)for(const s of o.elements)if(s instanceof ko&&s.connectionModel===e)return s;return null}},wn=class{constructor(e,t,o){this.connectionHighlights=new WeakMap,this.highlightOffsets=new WeakMap,this.constants=o,this.style=t,this.svgRoot=e,this.svgPath=m(h.PATH,{class:"blocklyPath"},this.svgRoot),this.setClass_("blocklyBlock",!0)}setPath(e){this.svgPath.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}applyColour(e){this.svgPath.setAttribute("stroke",this.style.colourTertiary),this.svgPath.setAttribute("fill",this.style.colourPrimary),this.updateShadow_(e.isShadow()),this.updateDisabled_(!e.isEnabled()||e.getInheritedDisabled())}setStyle(e){this.style=e}setClass_(e,t){e&&(t?b(this.svgRoot,e):O(this.svgRoot,e))}updateHighlighted(e){e?this.setClass_("blocklyHighlighted",!0):this.setClass_("blocklyHighlighted",!1)}updateShadow_(e){e?(this.setClass_("blocklyShadow",!0),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)):this.setClass_("blocklyShadow",!1)}updateDisabled_(e){this.setClass_("blocklyDisabled",e),this.setClass_("blocklyDisabledPattern",e)}updateSelected(e){this.setClass_("blocklySelected",e)}updateDraggingDelete(e){this.setClass_("blocklyDraggingDelete",e)}updateInsertionMarker(e){this.setClass_("blocklyInsertionMarker",e)}updateMovable(e){this.setClass_("blocklyDraggable",e)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e)}updateShapeForInputHighlight(e,t){}addConnectionHighlight(e,t,o,s){return o=`translate(${o.x}, ${o.y})`+(s?" scale(-1 1)":""),(s=this.connectionHighlights.get(e))?(s.setAttribute("d",t),s.setAttribute("transform",o),s):(t=m(h.PATH,{id:e.id,class:"blocklyHighlightedConnectionPath",style:"display: none;",d:t,transform:o},this.svgRoot),this.connectionHighlights.set(e,t),t)}removeConnectionHighlight(e){const t=this.connectionHighlights.get(e);t&&(F(t),this.connectionHighlights.delete(e))}},kn=class{constructor(e){this.overrides=null,this.name=e}getClassName(){return this.name+"-renderer"}init(e,t){this.constants_=this.makeConstants_(),t&&(this.overrides=t,Object.assign(this.constants_,t)),this.constants_.setTheme(e),this.constants_.init()}createDom(e,t,o){this.constants_.createDom(e,this.name+"-"+t.name,"."+this.getClassName()+"."+t.getClassName(),o)}refreshDom(e,t,o){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(t),this.constants_.init(),this.createDom(e,t,o)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new vn}makeRenderInfo_(e){return new yi(this,e)}makeDrawer_(e,t){return new Cn(e,t)}makePathObject(e,t){return new wn(e,t,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(e){return!0}orphanCanConnectAtEnd(e,t,o){return!!A.getConnectionForOrphanedConnection(e,o===E.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}render(e){const t=this.makeRenderInfo_(e);t.measure(),this.makeDrawer_(e,t).draw()}},B={};B.BottomRow=oh,B.Connection=ko,B.ConstantProvider=vn,B.Drawer=Cn,B.ExternalValueInput=sh,B.Field=ih,B.Hat=ag,B.Icon=dg,B.InRowSpacer=Oe,B.InlineInput=rh,B.InputConnection=Tn,B.InputRow=nh,B.JaggedEdge=$g,B.Measurable=dt,B.NextConnection=pg,B.OutputConnection=gg,B.PathObject=wn,B.PreviousConnection=mg,B.RenderInfo=yi,B.Renderer=kn,B.RoundCorner=Ei,B.Row=_i,B.SpacerRow=lh,B.SquareCorner=Ti,B.StatementInput=yn,B.TopRow=ch,B.Types=u,B.init=Ec,B.register=js,B.unregister=Zd;var fg=class{constructor(e,t){this.workspace=e,this.theme=t,this.subscribedWorkspaces=[],this.componentDB=new Map}getTheme(){return this.theme}setTheme(e){var t=this.theme;this.theme=e,(e=this.workspace.getInjectionDiv())&&(t&&(t=t.getClassName())&&O(e,t),(t=this.theme.getClassName())&&b(e,t));for(let o=0,s;s=this.subscribedWorkspaces[o];o++)s.refreshTheme();for(const[o,s]of this.componentDB)for(const i of s){e=i.element,t=i.propertyName;const r=this.theme&&this.theme.getComponentStyle(o);e.style.setProperty(t,r||"")}for(const o of this.subscribedWorkspaces)o.hideChaff()}subscribeWorkspace(e){this.subscribedWorkspaces.push(e)}unsubscribeWorkspace(e){if(!ke(this.subscribedWorkspaces,e))throw Error("Cannot unsubscribe a workspace that hasn't been subscribed.")}subscribe(e,t,o){this.componentDB.has(t)||this.componentDB.set(t,[]),this.componentDB.get(t).push({element:e,propertyName:o}),t=this.theme&&this.theme.getComponentStyle(t),e.style.setProperty(o,t||"")}unsubscribe(e){if(e)for(const[t,o]of this.componentDB){for(let s=o.length-1;s>=0;s--)o[s].element===e&&o.splice(s,1);o.length||this.componentDB.delete(t)}}dispose(){this.subscribedWorkspaces.length=0,this.componentDB.clear()}},uh="VARIABLE_DYNAMIC",jt={CATEGORY_NAME:uh};jt.flyoutCategory=Tc,jt.flyoutCategoryBlocks=yc,jt.internalFlyoutCategory=Sr,jt.onCreateVariableButtonClick_Colour=Ir,jt.onCreateVariableButtonClick_Number=kr,jt.onCreateVariableButtonClick_String=wr;var bg=class{canConnect(e,t,o,s){return this.canConnectWithReason(e,t,o,s)===A.CAN_CONNECT}canConnectWithReason(e,t,o,s){const i=this.doSafetyChecks(e,t);return i!==A.CAN_CONNECT?i:this.doTypeChecks(e,t)?o&&!this.doDragChecks(e,t,s||0)?A.REASON_DRAG_CHECKS_FAILED:A.CAN_CONNECT:A.REASON_CHECKS_FAILED}getErrorMessage(e,t,o){switch(e){case A.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case A.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case A.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case A.REASON_TARGET_NULL:return"Target connection is null.";case A.REASON_CHECKS_FAILED:return"Connection checks failed. "+(t+" expected "+t.getCheck()+", found "+o.getCheck());case A.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case A.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case A.REASON_PREVIOUS_AND_OUTPUT:return"Block would have an output and a previous connection.";default:return"Unknown connection failure: this should never happen!"}}doSafetyChecks(e,t){if(!e||!t)return A.REASON_TARGET_NULL;let o,s,i;return e.isSuperior()?(o=e.getSourceBlock(),s=t.getSourceBlock(),i=t):(s=e.getSourceBlock(),o=t.getSourceBlock(),i=e,e=t),o===s?A.REASON_SELF_CONNECTION:i.type!==wo[e.type]?A.REASON_WRONG_TYPE:o.workspace!==s.workspace?A.REASON_DIFFERENT_WORKSPACES:o.isShadow()&&!s.isShadow()?A.REASON_SHADOW_PARENT:i.type===E.OUTPUT_VALUE&&s.previousConnection&&s.previousConnection.isConnected()||i.type===E.PREVIOUS_STATEMENT&&s.outputConnection&&s.outputConnection.isConnected()?A.REASON_PREVIOUS_AND_OUTPUT:A.CAN_CONNECT}doTypeChecks(e,t){if(e=e.getCheck(),t=t.getCheck(),!e||!t)return!0;for(let o=0;o<e.length;o++)if(t.includes(e[o]))return!0;return!1}doDragChecks(e,t,o){if(e.distanceFrom(t)>o||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case E.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case E.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case E.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case E.NEXT_STATEMENT:if(t.isConnected()&&!e.getSourceBlock().nextConnection&&!t.targetBlock().isShadow()&&t.targetBlock().nextConnection||t.targetBlock()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;default:return!1}return!oi.includes(t)}canConnectToPrevious_(e,t){return e.targetConnection||oi.includes(t)?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};I(g.CONNECTION_CHECKER,Ce,bg);var ms=class{get isFlyout(){return this.internalIsFlyout}get isMutator(){return this.internalIsMutator}constructor(e){this.isClearing=this.internalIsMutator=this.internalIsFlyout=this.rendered=!1,this.MAX_UNDO=1024,this.connectionDBList=[],this.topBlocks=[],this.topComments=[],this.commentDB=new Map,this.listeners=[],this.undoStack_=[],this.redoStack_=[],this.blockDB=new Map,this.typedBlocksDB=new Map,this.procedureMap=new hg,this.readOnly=!1,this.potentialVariableMap=null,this.id=_t(),Gn(this),this.options=e||new ut({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(_e(g.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new(this.getVariableMapClass())(this),this.setIsReadOnly(this.options.readOnly)}dispose(){this.listeners.length=0,this.clear(),Vn(this)}sortObjects(e,t){const o=s=>({getBoundingRectangle:()=>{const i=s.getRelativeToSurfaceXY();return new D(i.y,i.y,i.x,i.x)},moveBy:()=>{}});return this.sortByOrigin(o(e),o(t))}sortByOrigin(e,t){const o=Math.sin(sr(ms.SCAN_ANGLE))*(this.RTL?-1:1);return e=e.getBoundingRectangle().getOrigin(),t=t.getBoundingRectangle().getOrigin(),e.y+o*e.x-(t.y+o*t.x)}addTopBlock(e){this.topBlocks.push(e)}removeTopBlock(e){if(!ke(this.topBlocks,e))throw Error("Block not present in workspace's list of top-most blocks.")}getTopBlocks(e=!1){const t=[].concat(this.topBlocks);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}addTypedBlock(e){this.typedBlocksDB.has(e.type)||this.typedBlocksDB.set(e.type,[]),this.typedBlocksDB.get(e.type).push(e)}removeTypedBlock(e){ke(this.typedBlocksDB.get(e.type),e),this.typedBlocksDB.get(e.type).length||this.typedBlocksDB.delete(e.type)}getBlocksByType(e,t=!1){return this.typedBlocksDB.has(e)?(e=this.typedBlocksDB.get(e).slice(0),t&&e&&e.length>1&&e.sort(this.sortObjects.bind(this)),e.filter(o=>!o.isInsertionMarker())):[]}addTopComment(e){this.topComments.push(e),this.commentDB.has(e.id)&&console.warn('Overriding an existing comment on this workspace, with id "'+e.id+'"'),this.commentDB.set(e.id,e)}removeTopComment(e){if(!ke(this.topComments,e))throw Error("Comment not present in workspace's list of top-most comments.");this.commentDB.delete(e.id)}getTopComments(e=!1){const t=[].concat(this.topComments);return e&&t.length>1&&t.sort(this.sortObjects.bind(this)),t}getAllBlocks(e=!1){if(e){var t=this.getTopBlocks(!0);e=[];for(let o=0;o<t.length;o++)e.push(...t[o].getDescendants(!0))}else for(e=this.getTopBlocks(!1),t=0;t<e.length;t++)e.push(...e[t].getChildren(!1));return e.filter(o=>!o.isInsertionMarker())}clear(){this.isClearing=!0;try{const e=n.getGroup$$module$build$src$core$events$utils();for(e||n.setGroup$$module$build$src$core$events$utils(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();n.setGroup$$module$build$src$core$events$utils(e),this.isFlyout||this.variableMap.clear(),this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}renameVariableById(e,t){le("Blockly.Workspace.renameVariableById","v12","v13","Blockly.Workspace.getVariableMap().renameVariable"),(e=this.variableMap.getVariableById(e))&&this.variableMap.renameVariable(e,t)}createVariable(e,t,o){return le("Blockly.Workspace.createVariable","v12","v13","Blockly.Workspace.getVariableMap().createVariable"),this.variableMap.createVariable(e,t??void 0,o??void 0)}getVariableUsesById(e){return le("Blockly.Workspace.getVariableUsesById","v12","v13","Blockly.Workspace.getVariableMap().getVariableUsesById"),Ho(this,e)}deleteVariableById(e){le("Blockly.Workspace.deleteVariableById","v12","v13","Blockly.Workspace.getVariableMap().deleteVariable");const t=this.variableMap.getVariableById(e);t?n.deleteVariable$$module$build$src$core$variables(this,t):console.warn(`Can't delete non-existent variable: ${e}`)}getVariable(e,t){return le("Blockly.Workspace.getVariable","v12","v13","Blockly.Workspace.getVariableMap().getVariable"),this.variableMap.getVariable(e,t)}getVariableById(e){return le("Blockly.Workspace.getVariableById","v12","v13","Blockly.Workspace.getVariableMap().getVariableById"),this.variableMap.getVariableById(e)}getVariablesOfType(e){return le("Blockly.Workspace.getVariablesOfType","v12","v13","Blockly.Workspace.getVariableMap().getVariablesOfType"),this.variableMap.getVariablesOfType(e??"")}getAllVariables(){return le("Blockly.Workspace.getAllVariables","v12","v13","Blockly.Workspace.getVariableMap().getAllVariables"),this.variableMap.getAllVariables()}getAllVariableNames(){return le("Blockly.Workspace.getAllVariableNames","v12","v13","Blockly.Workspace.getVariableMap().getAllVariables"),this.variableMap.getAllVariables().map(e=>e.getName())}getWidth(){return 0}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(e){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}remainingCapacity(){return isNaN(this.options.maxBlocks)?1/0:this.options.maxBlocks-this.getAllBlocks(!1).length}remainingCapacityOfType(e){return this.options.maxInstances?(this.options.maxInstances[e]!==void 0?this.options.maxInstances[e]:1/0)-this.getBlocksByType(e,!1).length:1/0}isCapacityAvailable(e){if(!this.hasBlockLimits())return!0;let t=0;for(const o in e){if(e[o]>this.remainingCapacityOfType(o))return!1;t+=e[o]}return!(t>this.remainingCapacity())}hasBlockLimits(){return this.options.maxBlocks!==1/0||!!this.options.maxInstances}getUndoStack(){return this.undoStack_}getRedoStack(){return this.redoStack_}undo(e){var t=e?this.redoStack_:this.undoStack_,o=e?this.undoStack_:this.redoStack_;const s=t.pop();if(s){for(var i=[s];t.length&&s.group&&s.group===t[t.length-1].group;){const r=t.pop();r&&i.push(r)}for(t=0;t<i.length;t++)o.push(i[t]);n.setRecordUndo$$module$build$src$core$events$utils(!1);try{for(o=0;o<i.length;o++)i[o].run(e)}finally{n.setRecordUndo$$module$build$src$core$events$utils(!0)}}}clearUndo(){this.undoStack_.length=0,this.redoStack_.length=0,Hn()}addChangeListener(e){return this.listeners.push(e),e}removeChangeListener(e){ke(this.listeners,e)}fireChangeListener(e){if(e.recordUndo)for(this.undoStack_.push(e),this.redoStack_.length=0;this.undoStack_.length>this.MAX_UNDO&&this.MAX_UNDO>=0;)this.undoStack_.shift();for(let t=0;t<this.listeners.length;t++)(0,this.listeners[t])(e)}getBlockById(e){return this.blockDB.get(e)||null}setBlockById(e,t){this.blockDB.set(e,t)}removeBlockById(e){this.blockDB.delete(e)}getCommentById(e){let t;return(t=this.commentDB.get(e))!=null?t:null}allInputsFilled(e){const t=this.getTopBlocks(!1);for(let o=0;o<t.length;o++)if(!t[o].allInputsFilled(e))return!1;return!0}getPotentialVariableMap(){return this.potentialVariableMap}createPotentialVariableMap(){this.potentialVariableMap=new(this.getVariableMapClass())(this,!0)}getVariableMap(){return this.variableMap}setVariableMap(e){this.variableMap=e}getProcedureMap(){return this.procedureMap}getRootWorkspace(){let e=null;const t=this.options.parentWorkspace;return this.isFlyout?t&&t.options&&(e=t.options.parentWorkspace):t&&(e=t),e}static getById(e){return xt(e)}static getAll(){return xo()}getVariableMapClass(){const e=_e(g.VARIABLE_MAP,this.options,!0);if(!e)throw Error("No variable map is registered.");return e}isReadOnly(){return this.readOnly}setIsReadOnly(e){this.readOnly=e,this.options.readOnly=e}};ms.SCAN_ANGLE=3;var rf=100,_g=class{constructor(e){this.parentWorkspace=e,this.sounds=new Map,this.lastSound=null,this.muted=!1}dispose(){this.sounds.clear()}load(e,t){if(e.length){try{var o=new globalThis.Audio}catch{return}for(let i=0;i<e.length;i++){const r=e[i],l=r.match(/\.(\w+)$/);if(l&&o.canPlayType("audio/"+l[1])){var s=new globalThis.Audio(r);break}}s&&this.sounds.set(t,s)}}preload(){for(const e of this.sounds.values()){e.volume=.01;const t=e.play();if(t!==void 0?t.then(e.pause).catch(function(){}):e.pause(),Fr||I$)break}}play(e,t){if(!this.muted){var o=this.sounds.get(e);o?(e=new Date,this.lastSound!==null&&e.getTime()-this.lastSound.getTime()<rf||(this.lastSound=e,o=Fr||su?o:o.cloneNode(),o.volume=t===void 0?1:t,o.play())):this.parentWorkspace&&this.parentWorkspace.getAudioManager().play(e,t)}}setMuted(e){this.muted=e}getMuted(){return this.muted}},nf=20,be=class extends ms{constructor(e){super(e),this.resizeHandlerWrapper=null,this.resizesEnabled=this.visible=this.rendered=!0,this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0,this.oldScale=this.scale=1,this.oldLeft=this.oldTop=0,this.inverseScreenCTM=this.targetWorkspace=this.dummyWheelListener=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=this.currentGesture_=this.toolbox=this.flyout=this.scrollbar=this.trashcan=null,this.inverseScreenCTMDirty=!0,this.highlightedBlocks=[],this.toolboxCategoryCallbacks=new Map,this.flyoutButtonCallbacks=new Map,this.cachedParentSvg=null,this.keyboardMoveInProgress=this.keyboardAccessibilityMode=!1,this.topBoundedElements=[],this.dragTargetAreas=[],this.zoomControls_=this.layerManager=null,this.navigator=new Ku,this.metricsManager=new(_e(g.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||be.setTopLevelWorkspaceMetrics,this.componentManager=new U,this.connectionDBList=hs.init(this.connectionChecker),this.audioManager=new _g(e.parentWorkspace),this.grid=this.options.gridPattern?new Ju(this.options.gridPattern,e.gridOptions):null,this.markerManager=new qu(this),ee&&qi&&this.registerToolboxCategoryCallback(Cu,qi),jt&&Sr&&this.registerToolboxCategoryCallback(uh,Sr),fe&&vr&&(this.registerToolboxCategoryCallback(En,vr),this.addChangeListener(bc)),this.addChangeListener(this.variableChangeCallback.bind(this)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new fg(this,this.options.theme||hn),this.themeManager_.subscribeWorkspace(this);let t;this.renderer=Ec(this.options.renderer||"geras",this.getTheme(),(t=this.options.rendererOverrides)!=null?t:void 0),this.cachedParentSvgSize=new N(0,0)}getMarkerManager(){return this.markerManager}getMetricsManager(){return this.metricsManager}setMetricsManager(e){this.metricsManager=e,this.getMetrics=this.metricsManager.getMetrics.bind(this.metricsManager)}getComponentManager(){return this.componentManager}getMarker(e){return this.markerManager.getMarker(e)}getCursor(){return this.markerManager.getCursor()}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(e){e||(e=hn),this.themeManager_.setTheme(e)}refreshTheme(){if(this.svgGroup_){var e=this.options.parentWorkspace===null;this.renderer.refreshDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0)}this.updateBlockStyles(this.getAllBlocks(!1).filter(t=>!!t.getStyleName())),this.refreshToolboxSelection(),this.toolbox&&this.toolbox.refreshTheme(),this.isVisible()&&this.setVisible(!0),e=new(w(a.THEME_CHANGE))(this.getTheme().name,this.id),C(e)}updateBlockStyles(e){for(let t=0,o;o=e[t];t++){const s=o.getStyleName();s&&o.setStyle(s)}}getInverseScreenCTM(){if(this.inverseScreenCTMDirty){const e=this.getParentSvg().getScreenCTM();e&&(this.inverseScreenCTM=e.inverse(),this.inverseScreenCTMDirty=!1)}return this.inverseScreenCTM}updateInverseScreenCTM(){this.inverseScreenCTMDirty=!0}isVisible(){return this.visible}getSvgXY(e){let t=0,o=0,s=1;(this.getCanvas().contains(e)||this.getBubbleCanvas().contains(e))&&(s=this.scale);do{const i=Os(e);(e===this.getCanvas()||e===this.getBubbleCanvas())&&(s=1),t+=i.x*s,o+=i.y*s,e=e.parentNode}while(e&&e!==this.getParentSvg()&&e!==this.getInjectionDiv());return new f(t,o)}getCachedParentSvgSize(){const e=this.cachedParentSvgSize;return new N(e.width,e.height)}getOriginOffsetInPixels(){return Hi(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let e=this.svgGroup_;for(;e;){if((" "+(e.getAttribute("class")||"")+" ").includes(" injectionDiv ")){this.injectionDiv=e;break}e=e.parentNode}}return this.injectionDiv}getSvgGroup(){return this.svgGroup_}getBlockCanvas(){return this.getCanvas()}setResizeHandlerWrapper(e){this.resizeHandlerWrapper=e}createDom(e,t){return this.injectionDiv||(this.injectionDiv=t??null),this.svgGroup_=m(h.G,{class:"blocklyWorkspace",id:this.id}),t&&oe(this.svgGroup_,Q.LABEL,n.Msg$$module$build$src$core$msg.WORKSPACE_ARIA_LABEL),e&&(this.svgBackground_=m(h.RECT,{height:"100%",width:"100%",class:e},this.svgGroup_),e==="blocklyMainBackground"&&this.grid?this.svgBackground_.style.fill="var(--blocklyGridPattern)":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill")),this.layerManager=new of(this),this.svgBlockCanvas_=this.layerManager.getBlockLayer(),this.svgBubbleCanvas_=this.layerManager.getBubbleLayer(),this.isFlyout||(k(this.svgGroup_,"pointerdown",this,this.onMouseDown,!1),this.dummyWheelListener=()=>{},document.body.addEventListener("wheel",this.dummyWheelListener),k(this.svgGroup_,"wheel",this,this.onMouseWheel)),this.options.hasCategories&&(this.toolbox=new(_e(g.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(e=_e(g.CURSOR,this.options))&&this.markerManager.setCursor(new e(this)),e=this.options.parentWorkspace===null,this.renderer.createDom(this.svgGroup_,this.getTheme(),e?this.getInjectionDiv():void 0),n.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!!this.injectionDiv||this.isFlyout),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&F(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.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 e=this.getParentSvg();e&&e.parentNode&&F(e.parentNode)}this.resizeHandlerWrapper&&(x(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null),this.dummyWheelListener&&(document.body.removeEventListener("wheel",this.dummyWheelListener),this.dummyWheelListener=null),n.getFocusManager$$module$build$src$core$focus_manager().isRegistered(this)&&n.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}addTrashcan(){this.trashcan=be.newTrashcan(this);const e=this.trashcan.createDom();this.svgGroup_.insertBefore(e,this.getCanvas())}static newTrashcan(e){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new Y$(this);const e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}copyOptionsForFlyout(){return new ut({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,plugins:this.options.plugins,modalInputs:this.options.modalInputs,move:{scrollbars:!0}})}addFlyout(e){const t=this.copyOptionsForFlyout();return t.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(_e(g.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(_e(g.FLYOUTS_VERTICAL_TOOLBOX,this.options,!0))(t),this.flyout.autoClose=!1,this.flyout.getWorkspace().setVisible(!0),this.flyout.createDom(e)}getFlyout(e){return this.flyout||e?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 e=this.componentManager.getComponents(U.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),o=[];for(let s=0,i;i=e[s];s++){i.position(t,o);const r=i.getBoundingRectangle();r&&o.push(r)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations()}updateScreenCalculationsIfScrolled(){const e=qn();f.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations())}getLayerManager(){return this.layerManager}getCanvas(){return this.layerManager.getBlockLayer()}setCachedParentSvgSize(e,t){const o=this.getParentSvg();e!=null&&(this.cachedParentSvgSize.width=e,o.setAttribute("data-cached-width",`${e}`)),t!=null&&(this.cachedParentSvgSize.height=t,o.setAttribute("data-cached-height",`${t}`))}getBubbleCanvas(){return this.layerManager.getBubbleLayer()}getParentSvg(){if(!this.cachedParentSvg){let e=this.svgGroup_;for(;e;){if(e.tagName==="svg"){this.cachedParentSvg=e;break}e=e.parentNode}}return this.cachedParentSvg}maybeFireViewportChangeEvent(){if(z()){var e=this.scale,t=-this.scrollY,o=-this.scrollX;if(!(e===this.oldScale&&Math.abs(t-this.oldTop)<1&&Math.abs(o-this.oldLeft)<1)){var s=new(w(a.VIEWPORT_CHANGE))(t,o,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=o,C(s)}}}translate(e,t){let o;(o=this.layerManager)==null||o.translateLayers(new f(e,t),this.scale);let s;(s=this.grid)==null||s.moveTo(e,t),this.maybeFireViewportChangeEvent()}getWidth(){const e=this.getMetrics();return e?e.viewWidth/this.scale:0}setVisible(e){this.visible=e,this.svgGroup_&&(this.scrollbar&&this.scrollbar.setContainerVisible(e),this.getFlyout()&&this.getFlyout().setContainerVisible(e),this.getParentSvg().style.display=e?"block":"none",this.toolbox&&this.toolbox.setVisible(e),e||this.hideChaff(!0))}render(){const e=this.getAllBlocks(!1);for(let t=e.length-1;t>=0;t--)e[t].queueRender();this.getTopBlocks().flatMap(t=>t.getDescendants(!1)).filter(t=>t.isInsertionMarker()).forEach(t=>t.queueRender())}highlightBlock(e,t){if(t===void 0){for(let o=0,s;s=this.highlightedBlocks[o];o++)s.setHighlighted(!1);this.highlightedBlocks.length=0}(e=e?this.getBlockById(e):null)&&((t=t===void 0||t)?this.highlightedBlocks.includes(e)||this.highlightedBlocks.push(e):ke(this.highlightedBlocks,e),e.setHighlighted(t))}variableChangeCallback(e){switch(e.type){case a.VAR_CREATE:case a.VAR_DELETE:case a.VAR_RENAME:case a.VAR_TYPE_CHANGE:this.refreshToolboxSelection()}}refreshToolboxSelection(){const e=this.isFlyout?this.targetWorkspace:this;e&&!e.currentGesture_&&e.toolbox&&e.toolbox.getFlyout()&&e.toolbox.refreshSelection()}recordDragTargets(){const e=this.componentManager.getComponents(U.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t=0,o;o=e[t];t++){const s=o.getClientRect();s&&this.dragTargetAreas.push({component:o,clientRect:s})}}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}newComment(e){throw Error("The implementation of newComment should be monkey-patched in by blockly.ts")}getDragTarget(e){for(let t=0,o;o=this.dragTargetAreas[t];t++)if(o.clientRect.contains(e.clientX,e.clientY))return o.component;return null}onMouseDown(e){const t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){pr(this,e,t)}moveDrag(e){return gr(this,e)}setKeyboardMoveInProgress(e){this.keyboardMoveInProgress=e}isDragging(){return this.keyboardMoveInProgress||this.currentGesture_!==null&&this.currentGesture_.isDragging()}isDraggable(){return this.options.moveOptions&&this.options.moveOptions.drag}isMovable(){return this.options.moveOptions&&!!this.options.moveOptions.scrollbars||this.options.moveOptions&&this.options.moveOptions.wheel||this.options.moveOptions&&this.options.moveOptions.drag||this.options.zoomOptions&&this.options.zoomOptions.wheel||this.options.zoomOptions&&this.options.zoomOptions.pinch}isMovableHorizontally(){const e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollHorizontally())}isMovableVertically(){const e=!!this.scrollbar;return this.isMovable()&&(!e||e&&this.scrollbar.canScrollVertically())}onMouseWheel(e){if(_n.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,o=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||o){var s=Cs(e);if(iu)var i=e.metaKey;t&&(e.ctrlKey||i||!o)?(s=-s.y/50,t=Do(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,s)):(t=this.scrollX-s.x,o=this.scrollY-s.y,e.shiftKey&&!s.x&&(t=this.scrollX-s.y,o=this.scrollY),this.scroll(t,o)),e.preventDefault()}}}getBlocksBoundingBox(){const e=this.getTopBoundedElements();if(!e.length)return new D(0,0,0,0);const t=e[0].getBoundingRectangle();for(let s=1;s<e.length;s++){var o=e[s];o.isInsertionMarker&&o.isInsertionMarker()||(o=o.getBoundingRectangle(),o.top<t.top&&(t.top=o.top),o.bottom>t.bottom&&(t.bottom=o.bottom),o.left<t.left&&(t.left=o.left),o.right>t.right&&(t.right=o.right))}return t}cleanUp(){this.setResizesEnabled(!1),n.setGroup$$module$build$src$core$events$utils(!0);var e=this.getTopBlocks(!0),t=e.filter(r=>r.isMovable());const o=e.filter(r=>!r.isMovable()).map(r=>r.getBoundingRectangle());e=function(r){for(const l of o)if(r.intersects(l))return l;return null};var s=0;const i=this.renderer.getConstants().MIN_BLOCK_HEIGHT;for(const r of t){for(t=r.getBoundingRectangle(),r.moveBy(-t.left,s-t.top,["cleanup"]),r.snapToGrid(),t=r.getBoundingRectangle(),s=e(t);s!=null;)s=s.top+s.getHeight()+i,r.moveBy(0,s-t.top,["cleanup"]),r.snapToGrid(),t=r.getBoundingRectangle(),s=e(t);s=r.getRelativeToSurfaceXY().y+r.getHeightWidth().height+i}n.setGroup$$module$build$src$core$events$utils(!1),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.isReadOnly()&&!this.isFlyout){var t=R.registry.getContextMenuOptions({workspace:this,focusedNode:this},e);this.configureContextMenu&&this.configureContextMenu(t,e);var o=e instanceof PointerEvent?new f(e.clientX,e.clientY):Lo(this,new f(5,5));Yo(e,t,this.RTL,this,o)}}updateToolbox(e){if(e=Gi(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(Vi(e)){if(!this.toolbox)throw Error("Existing toolbox has no categories. Can't change mode.");this.options.languageTree=e,this.toolbox.render(e)}else{if(!this.flyout)throw Error("Existing toolbox has categories. Can't change mode.");this.options.languageTree=e,this.flyout.show(e)}}else if(this.options.languageTree)throw Error("Can't nullify an existing toolbox.")}markFocused(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():(Is(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,o){o=Math.pow(this.options.zoomOptions.scaleSpeed,o);const s=this.scale*o;if(this.scale!==s){s>this.options.zoomOptions.maxScale?o=this.options.zoomOptions.maxScale/this.scale:s<this.options.zoomOptions.minScale&&(o=this.options.zoomOptions.minScale/this.scale);var i=this.getCanvas().getCTM(),r=this.getParentSvg().createSVGPoint();r.x=e,r.y=t,r=r.matrixTransform(i.inverse()),e=r.x,t=r.y,i=i.translate(e*(1-o),t*(1-o)).scale(o),this.scrollX=i.e,this.scrollY=i.f,this.setScale(s)}}zoomCenter(e){var t=this.getMetrics();let o;this.flyout?(o=t.svgWidth?t.svgWidth/2:0,t=t.svgHeight?t.svgHeight/2:0):(o=t.viewWidth/2+t.absoluteLeft,t=t.viewHeight/2+t.absoluteTop),this.zoom(o,t,e)}zoomToFit(){if(this.isMovable()){var e=this.getMetrics(),t=e.viewWidth;e=e.viewHeight;var o=this.getBlocksBoundingBox(),s=nf*2,i=o.right-o.left+s;if(o=o.bottom-o.top+s,i){this.flyout&&(this.horizontalLayout?(e+=this.flyout.getHeight(),o+=this.flyout.getHeight()/this.scale):(t+=this.flyout.getWidth(),i+=this.flyout.getWidth()/this.scale)),t/=i,e/=o,n.disable$$module$build$src$core$events$utils();try{this.setScale(Math.min(t,e)),this.scrollCenter()}finally{n.enable$$module$build$src$core$events$utils()}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){b(this.getCanvas(),"blocklyCanvasTransitioning"),b(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}endCanvasTransition(){O(this.getCanvas(),"blocklyCanvasTransitioning"),O(this.getBubbleCanvas(),"blocklyCanvasTransitioning")}scrollCenter(){if(this.isMovable()){var e=this.getMetrics(),t=(e.scrollWidth-e.viewWidth)/2,o=(e.scrollHeight-e.viewHeight)/2;t=-t-e.scrollLeft,o=-o-e.scrollTop,this.scroll(t,o)}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}centerOnBlock(e,t){if(this.isMovable()){var o=e?this.getBlockById(e):null;if(o){e=o.getRelativeToSurfaceXY(),o=t?{height:o.height,width:o.width}:o.getHeightWidth();var s=this.scale;t=(e.x+(this.RTL?-1:1)*o.width/2)*s,e=(e.y+o.height/2)*s,o=this.getMetrics(),this.scroll(-(t-o.viewWidth/2),-(e-o.viewHeight/2))}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}setScale(e){this.options.zoomOptions.maxScale&&e>this.options.zoomOptions.maxScale?e=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&e<this.options.zoomOptions.minScale&&(e=this.options.zoomOptions.minScale),this.scale=e,this.hideChaff(!1),(e=this.getFlyout(!1))&&e.isVisible()&&(e.reflow(),this.recordDragTargets()),this.grid&&this.grid.update(this.scale),e=this.getMetrics(),this.scrollX-=e.absoluteLeft,this.scrollY-=e.absoluteTop,e.viewLeft+=e.absoluteLeft,e.viewTop+=e.absoluteTop,this.scroll(this.scrollX,this.scrollY),this.scrollbar&&(this.flyout?this.scrollbar.resizeView(e):this.scrollbar.resizeContent(e))}getScale(){return this.scale}getAbsoluteScale(){const e=o=>{if(o.isFlyout){let s;const i=(s=o.targetWorkspace)==null?void 0:s.getFlyout();if(i instanceof fn)return i.getFlyoutScale()}return o.getScale()},t=(o,s)=>o.options.parentWorkspace&&o.options.parentWorkspace.getSvgGroup().contains(o.getSvgGroup())?t(o.options.parentWorkspace,s*e(o)):s*e(o);return t(this,1)}scroll(e,t){this.hideChaff(!0);const o=this.getMetrics();e=Math.min(e,-o.scrollLeft),t=Math.min(t,-o.scrollTop);const s=o.scrollTop+Math.max(0,o.scrollHeight-o.viewHeight);e=Math.max(e,-(o.scrollLeft+Math.max(0,o.scrollWidth-o.viewWidth))),t=Math.max(t,-s),this.scrollX=e,this.scrollY=t,this.scrollbar&&this.scrollbar.set(-(e+o.scrollLeft),-(t+o.scrollTop),!1),e+=o.absoluteLeft,t+=o.absoluteTop,this.translate(e,t)}getBlockById(e){return super.getBlockById(e)}getAllBlocks(e=!1){return super.getAllBlocks(e)}getTopBlocks(e=!1){return super.getTopBlocks(e)}addTopBlock(e){this.addTopBoundedElement(e),super.addTopBlock(e)}removeTopBlock(e){this.removeTopBoundedElement(e),super.removeTopBlock(e)}addTopComment(e){this.addTopBoundedElement(e),super.addTopComment(e)}removeTopComment(e){this.removeTopBoundedElement(e),super.removeTopComment(e)}getTopComments(e=!1){return super.getTopComments(e)}getCommentById(e){return super.getCommentById(e)}getRootWorkspace(){return super.getRootWorkspace()}addTopBoundedElement(e){this.topBoundedElements.push(e)}removeTopBoundedElement(e){ke(this.topBoundedElements,e)}getTopBoundedElements(e=!1){const t=[].concat(this.topBoundedElements);return e&&t.sort(this.sortByOrigin.bind(this)),t}setResizesEnabled(e){const t=!this.resizesEnabled&&e;this.resizesEnabled=e,t&&this.resizeContents()}clear(){this.setResizesEnabled(!1),super.clear(),this.topBoundedElements=[],this.setResizesEnabled(!0)}registerButtonCallback(e,t){if(typeof t!="function")throw TypeError("Button callbacks must be functions.");this.flyoutButtonCallbacks.set(e,t)}getButtonCallback(e){let t;return(t=this.flyoutButtonCallbacks.get(e))!=null?t:null}removeButtonCallback(e){this.flyoutButtonCallbacks.delete(e)}registerToolboxCategoryCallback(e,t){if(typeof t!="function")throw TypeError("Toolbox category callbacks must be functions.");this.toolboxCategoryCallbacks.set(e,t)}getToolboxCategoryCallback(e){return this.toolboxCategoryCallbacks.get(e)||null}removeToolboxCategoryCallback(e){this.toolboxCategoryCallbacks.delete(e)}getGesture(e){if(this.keyboardMoveInProgress)return e.preventDefault(),e.stopPropagation(),null;const t=e.type==="pointerdown";let o;return t&&((o=this.currentGesture_)!=null&&o.hasStarted())&&(console.warn("Tried to start the same gesture twice."),this.currentGesture_.cancel()),!this.currentGesture_&&t&&(this.currentGesture_=new _n(e,this)),this.currentGesture_}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(e=!1){Et(),Us(this),ot(),this.hideComponents(e)}hideComponents(e=!1){this.getComponentManager().getComponents(U.Capability.AUTOHIDEABLE,!0).forEach(t=>t.autoHide(e))}static setTopLevelWorkspaceMetrics(e){const t=this.getMetrics();typeof e.x=="number"&&(this.scrollX=-(t.scrollLeft+(t.scrollWidth-t.viewWidth)*e.x)),typeof e.y=="number"&&(this.scrollY=-(t.scrollTop+(t.scrollHeight-t.viewHeight)*e.y)),this.translate(this.scrollX+t.absoluteLeft,this.scrollY+t.absoluteTop)}addClass(e){this.injectionDiv&&b(this.injectionDiv,e)}removeClass(e){this.injectionDiv&&O(this.injectionDiv,e)}setIsReadOnly(e){super.setIsReadOnly(e),e?this.addClass("blocklyReadOnly"):this.removeClass("blocklyReadOnly")}scrollBoundsIntoView(e,t=10){if(!_n.inProgress()){var o=this.getScale(),s=this.getMetricsManager().getViewMetrics(!0);if(s=new D(s.top,s.top+s.height,s.left,s.left+s.width),!(e.left>=s.left&&e.top>=s.top&&e.right<=s.right&&e.bottom<=s.bottom)){e=e.clone(),e.top-=t,e.bottom+=t,e.left-=t,e.right+=t;var i=t=0;e.left<s.left?t=this.RTL?Math.min(s.left-e.left,s.right-e.right):s.left-e.left:e.right>s.right&&(t=this.RTL?s.right-e.right:Math.max(s.right-e.right,s.left-e.left)),e.top<s.top?i=s.top-e.top:e.bottom>s.bottom&&(i=Math.max(s.bottom-e.bottom,s.top-e.top)),this.scroll(this.scrollX+t*o,this.scrollY+i*o)}}}getFocusableElement(){return this.svgGroup_}getFocusableTree(){return this.isMutator&&this.options.parentWorkspace||this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(e)return null;let t;return(t=this.getTopBlocks(!0)[0])!=null?t:null}getNestedTrees(){const e=this.getAllBlocks().map(o=>o.getIcons()).flat().filter(o=>o instanceof n.MutatorIcon$$module$build$src$core$icons$mutator_icon&&o.bubbleIsVisible()).map(o=>{let s;return(s=o.getBubble())==null?void 0:s.getWorkspace()}).filter(o=>!!o),t=this.getFlyout(!0);return t&&e.push(t.getWorkspace()),e}searchForWorkspaceComment(e){for(const t of this.getTopComments())if(t instanceof ct&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}lookUpFocusableNode(e){var t;const o=(t=this.targetWorkspace)==null?void 0:t.getFlyout();if(this.isFlyout&&o){for(var s of o.getContents())if(t=s.getElement(),Oo(t)&&t.canBeFocused()&&t.getFocusableElement().id===e)return t}if(s=e.indexOf("_field_"),t=e.indexOf("_connection_"),s!==-1){var i=e.substring(0,s);if(i=this.getBlockById(i)){for(var r of i.getFields())if(r.canBeFocused()&&r.getFocusableElement().id===e)return r}return null}if(t!==-1){if(i=e.substring(0,t),i=this.getBlockById(i)){for(const c of i.getConnections_(!0))if(c.id===e)return c}return null}if(r=Math.max(e.indexOf(Pu),e.indexOf(xp),e.indexOf(Bp)),r!==-1&&(r=e.substring(0,r),r=this.searchForWorkspaceComment(r))){if(e.indexOf(Pu)>-1)return r.getEditorFocusableNode();var l;return(l=r.view.getCommentBarButtons().find(c=>c.getFocusableElement().id.includes(e)))!=null?l:null}if((l=this.getAllBlocks(!1).find(c=>c.getFocusableElement().id===e))||(l=this.searchForWorkspaceComment(e)))return l;l=this.getAllBlocks().map(c=>c.getIcons()).flat();for(i of l){if(i.canBeFocused()&&i.getFocusableElement().id===e)return i;if(ro(i)&&(l=i.getBubble())&&l.canBeFocused()&&l.getFocusableElement().id===e)return l}return null}onTreeFocus(e,t){}onTreeBlur(e){if(this.isFlyout&&this.targetWorkspace&&!n.getFocusManager$$module$build$src$core$focus_manager().ephemeralFocusTaken()){var t=this.targetWorkspace.getFlyout(),o=this.targetWorkspace.getToolbox();o&&e===o||(o&&o.clearSelection(),t&&dc(t)&&t.autoHide(!1))}}getNavigator(){return this.navigator}setNavigator(e){this.navigator=e}},fs=class extends es{constructor(e){super(),this.isBlank=typeof e>"u",e&&(this.varId=e.getId(),this.workspaceId=e.getWorkspace().id)}toJson(){const e=super.toJson();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");return e.varId=this.varId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new fs),t.varId=e.varId,t}},hh=class extends fs{constructor(e){super(e),this.type=a.VAR_CREATE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){const e=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new hh),t.varType=e.varType,t.varName=e.varName,t}run(e){var t=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=t.getVariableMap(),e?t.createVariable(this.varName,this.varType,this.varId):(e=t.getVariableById(this.varId))&&t.deleteVariable(e)}};I(g.EVENT,a.VAR_CREATE,hh);var Eg=class{constructor(e,t,o,s){this.workspace=e,this.name=t,this.type=o||"",this.id=s||_t()}getId(){return this.id}getName(){return this.name}setName(e){return this.name=e,this}getType(){return this.type}setType(e){return this.type=e,this}getWorkspace(){return this.workspace}save(){const e={name:this.getName(),id:this.getId()},t=this.getType();return t&&(e.type=t),e}static load(e,t){e=new this(t,e.name,e.type,e.id),t.getVariableMap().addVariable(e),C(new(w(a.VAR_CREATE))(e))}};I(g.VARIABLE_MODEL,Ce,Eg);var ah=class extends fs{constructor(e){super(e),this.type=a.VAR_DELETE,e&&(this.varType=e.getType(),this.varName=e.getName())}toJson(){const e=super.toJson();if(this.varType===void 0)throw Error("The var type is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");return e.varType=this.varType,e.varName=this.varName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ah),t.varType=e.varType,t.varName=e.varName,t}run(e){var t=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=t.getVariableMap(),e?(e=t.getVariableById(this.varId))&&t.deleteVariable(e):t.createVariable(this.varName,this.varType,this.varId)}};I(g.EVENT,a.VAR_DELETE,ah);var dh=class extends fs{constructor(e,t){super(e),this.type=a.VAR_RENAME,e&&(this.oldName=e.getName(),this.newName=typeof t>"u"?"":t)}toJson(){const e=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 e.oldName=this.oldName,e.newName=this.newName,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new dh),t.oldName=e.oldName,t.newName=e.newName,t}run(e){var t=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=t.getVariableMap();const o=t.getVariableById(this.varId);e?o&&t.renameVariable(o,this.newName):o&&t.renameVariable(o,this.oldName)}};I(g.EVENT,a.VAR_RENAME,dh);var Tg=class{constructor(e,t=!1){this.workspace=e,this.potentialMap=t,this.variableMap=new Map}clear(){for(const e of this.variableMap.values())for(const t of e.values())this.deleteVariable(t);if(this.variableMap.size!==0)throw Error("Non-empty variable map")}renameVariable(e,t){if(e.getName()===t)return e;var o=e.getType();o=this.getVariable(t,o);const s=this.workspace.getAllBlocks(!1);let i="";this.potentialMap||(i=n.getGroup$$module$build$src$core$events$utils())||n.setGroup$$module$build$src$core$events$utils(!0);try{o&&o.getId()!==e.getId()?this.renameVariableWithConflict(e,t,o,s):this.renameVariableAndUses(e,t,s)}finally{this.potentialMap||n.setGroup$$module$build$src$core$events$utils(i)}return e}changeVariableType(e,t){var o;(o=this.variableMap.get(e.getType()))==null||o.delete(e.getId()),e.setType(t);let s;return o=(s=this.variableMap.get(t))!=null?s:new Map,o.set(e.getId(),e),this.variableMap.has(t)||this.variableMap.set(t,o),e}renameVariableById(e,t){le("VariableMap.renameVariableById","v12","v13","VariableMap.renameVariable");const o=this.getVariableById(e);if(!o)throw Error("Tried to rename a variable that didn't exist. ID: "+e);this.renameVariable(o,t)}renameVariableAndUses(e,t,o){for(this.potentialMap||C(new(w(a.VAR_RENAME))(e,t)),e.setName(t),t=0;t<o.length;t++)o[t].updateVarName(e)}renameVariableWithConflict(e,t,o,s){const i=e.getType(),r=o.getName();for(t!==r&&this.renameVariableAndUses(o,t,s),t=0;t<s.length;t++)s[t].renameVarById(e.getId(),o.getId());this.potentialMap||C(new(w(a.VAR_DELETE))(e));let l;(l=this.variableMap.get(i))==null||l.delete(e.getId())}createVariable(e,t,o){var s=this.getVariable(e,t);if(s){if(o&&s.getId()!==o)throw Error('Variable "'+e+'" is already in use and its id is "'+s.getId()+'" which conflicts with the passed in id, "'+o+'".');return s}if(o&&this.getVariableById(o))throw Error('Variable id, "'+o+'", is already in use.');if(s=o||_t(),t=t||"",o=Ot(g.VARIABLE_MODEL,Ce,!0),!o)throw Error("No variable model is registered.");s=new o(this.workspace,e,t,s);let i;return e=(i=this.variableMap.get(t))!=null?i:new Map,e.set(s.getId(),s),this.variableMap.has(t)||this.variableMap.set(t,e),this.potentialMap||C(new(w(a.VAR_CREATE))(s)),s}addVariable(e){const t=e.getType();this.variableMap.has(t)||this.variableMap.set(t,new Map);let o;(o=this.variableMap.get(t))==null||o.set(e.getId(),e)}deleteVariable(e){const t=Ho(this.workspace,e.getId());let o="";this.potentialMap||(o=n.getGroup$$module$build$src$core$events$utils())||n.setGroup$$module$build$src$core$events$utils(!0);try{for(let i=0;i<t.length;i++)t[i].dispose(!0);const s=this.variableMap.get(e.getType());s&&s.has(e.getId())&&(s.delete(e.getId()),this.potentialMap||C(new(w(a.VAR_DELETE))(e)),s.size===0&&this.variableMap.delete(e.getType()))}finally{this.potentialMap||n.setGroup$$module$build$src$core$events$utils(o)}}deleteVariableById(e){le("VariableMap.deleteVariableById","v12","v13","Blockly.Variables.deleteVariable"),(e=this.getVariableById(e))&&n.deleteVariable$$module$build$src$core$variables(this.workspace,e)}getVariable(e,t){if(t=this.variableMap.get(t||""),!t)return null;let o;return(o=[...t.values()].find(s=>n.Names$$module$build$src$core$names.equals(s.getName(),e)))!=null?o:null}getVariableById(e){for(const t of this.variableMap.values())if(t.has(e)){let o;return(o=t.get(e))!=null?o:null}return null}getVariablesOfType(e){return(e=this.variableMap.get(e||""))?[...e.values()]:[]}getTypes(){return[...this.variableMap.keys()]}getAllVariables(){let e=[];for(const t of this.variableMap.values())e=e.concat(...t.values());return e}getAllVariableNames(){le("VariableMap.getAllVariableNames","v12","v13","Blockly.Variables.getAllVariables");const e=[];for(const t of this.variableMap.values())for(const o of t.values())e.push(o.getName());return e}getVariableUsesById(e){return le("VariableMap.getVariableUsesById","v12","v13","Blockly.Variables.getVariableUsesById"),Ho(this.workspace,e)}};I(g.VARIABLE_MAP,Ce,Tg);var $h=class extends lt{constructor(e,t){super(t),this.type=a.TRASHCAN_OPEN,this.isOpen=e}toJson(){const e=super.toJson();if(this.isOpen===void 0)throw Error("Whether this is already open or not is undefined. Either pass a value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new $h),t.isOpen=e.isOpen,t}};I(g.EVENT,a.TRASHCAN_OPEN,$h);var yg=class extends gn{constructor(e){super(),this.workspace=e,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,this.workspace.options.maxTrashcanContents<=0||(e=this.workspace.copyOptionsForFlyout(),this.workspace.horizontalLayout?(e.toolboxPosition=this.workspace.toolboxPosition===S.TOP?S.BOTTOM:S.TOP,this.flyout=new(_e(g.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===S.RIGHT?S.LEFT:S.RIGHT,this.flyout=new(_e(g.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=m(h.G,{class:"blocklyTrash"});let e;const t=String(Math.random()).substring(2);e=m(h.CLIPPATH,{id:"blocklyTrashBodyClipPath"+t},this.svgGroup),m(h.RECT,{width:bs,height:In,y:_s},e);const o=m(h.IMAGE,{width:Te.width,x:-ph,height:Te.height,y:-gh,"clip-path":"url(#blocklyTrashBodyClipPath"+t+")"},this.svgGroup);return o.setAttributeNS(Ie,"xlink:href",this.workspace.options.pathToMedia+Te.url),e=m(h.CLIPPATH,{id:"blocklyTrashLidClipPath"+t},this.svgGroup),m(h.RECT,{width:bs,height:_s},e),this.svgLid=m(h.IMAGE,{width:Te.width,x:-ph,height:Te.height,y:-gh,"clip-path":"url(#blocklyTrashLidClipPath"+t+")"},this.svgGroup),this.svgLid.setAttributeNS(Ie,"xlink:href",this.workspace.options.pathToMedia+Te.url),xe(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),xe(this.svgGroup,"pointerup",this,this.click),xe(o,"pointerover",this,this.mouseOver),xe(o,"pointerout",this,this.mouseOut),this.animateLid(),this.svgGroup}init(){if(this.workspace.options.maxTrashcanContents>0){const e=this.flyout.createDom(h.SVG);b(e,"blocklyTrashcanFlyout"),Qt(e,this.workspace.getParentSvg()),this.flyout.init(this.workspace)}this.workspace.getComponentManager().addComponent({component:this,weight:U.ComponentWeight.TRASHCAN_WEIGHT,capabilities:[U.Capability.AUTOHIDEABLE,U.Capability.DELETE_AREA,U.Capability.DRAG_TARGET,U.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan"),this.svgGroup&&F(this.svgGroup),this.lidTask&&clearTimeout(this.lidTask)}hasContents(){return!!this.contents.length}contentsIsOpen(){return!!this.flyout&&this.flyout.isVisible()}openFlyout(){if(!this.contentsIsOpen()){var e=this.contents.map(function(o){return JSON.parse(o)}),t=this.workspace.getParentSvg().style;t.cursor="wait",setTimeout(()=>{let o;(o=this.flyout)==null||o.show(e),t.cursor="";let s;(s=this.workspace.scrollbar)==null||s.setVisible(!1)},10),this.fireUiEvent(!0)}}closeFlyout(){if(this.contentsIsOpen()){var e;(e=this.flyout)==null||e.hide();var t;(t=this.workspace.scrollbar)==null||t.setVisible(!0),this.fireUiEvent(!1),this.workspace.recordDragTargets()}}autoHide(e){!e&&this.flyout&&this.closeFlyout()}emptyContents(){this.hasContents()&&(this.contents.length=0,this.setMinOpenness(0),this.closeFlyout())}position(e,t){if(this.initialized){var o=Xi(this.workspace,e);e=zi(o,new N(bs,In+_s),lf,vg,e,this.workspace),t=Yi(e,vg,o.vertical===kt.TOP?zt.DOWN:zt.UP,t),this.top=t.top,this.left=t.left;var s;(s=this.svgGroup)==null||s.setAttribute("transform","translate("+this.left+","+this.top+")");var i;(i=this.flyout)==null||i.position()}}getBoundingRectangle(){return new D(this.top,this.top+In+_s,this.left,this.left+bs)}getClientRect(){if(!this.svgGroup)return null;var e=this.svgGroup.getBoundingClientRect();const t=e.top+gh-Sn;return e=e.left+ph-Sn,new D(t,t+_s+In+2*Sn,e,e+bs+2*Sn)}onDragOver(e){this.setLidOpen(this.wouldDelete_)}onDragExit(e){this.setLidOpen(!1)}onDrop(e){setTimeout(this.setLidOpen.bind(this,!1),100)}setLidOpen(e){this.isLidOpen!==e&&(this.lidTask&&clearTimeout(this.lidTask),this.isLidOpen=e,this.animateLid())}animateLid(){const e=hf;var t=1/(e+1);this.lidOpen+=this.isLidOpen?t:-t,this.lidOpen=Math.min(Math.max(this.lidOpen,this.minOpenness),1),this.setLidAngle(this.lidOpen*wg),t=Cg+this.lidOpen*(af-Cg),this.svgGroup&&(this.svgGroup.style.opacity=`${t}`),this.lidOpen>this.minOpenness&&this.lidOpen<1&&(this.lidTask=setTimeout(this.animateLid.bind(this),uf/e))}setLidAngle(e){const t=this.workspace.toolboxPosition===S.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let o;(o=this.svgLid)==null||o.setAttribute("transform","rotate("+(t?-e:e)+","+(t?4:bs-4)+","+(_s-2)+")")}setMinOpenness(e){this.minOpenness=e,this.isLidOpen||this.setLidAngle(e*wg)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&!this.workspace.isDragging()&&this.openFlyout()}fireUiEvent(e){e=new(w(a.TRASHCAN_OPEN))(e,this.workspace.id),C(e)}blockMouseDownWhenOpenable(e){!this.contentsIsOpen()&&this.hasContents()&&e.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(e){if(!(this.workspace.options.maxTrashcanContents<=0||!Mn(e)||e.wasShadow)){if(!e.oldJson)throw Error("Encountered a delete event without proper oldJson");if(e=JSON.stringify(this.cleanBlockJson(e.oldJson)),!this.contents.includes(e)){for(this.contents.unshift(e);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(cf)}}}cleanBlockJson(e){function t(o){if(o){if(delete o.id,delete o.x,delete o.y,delete o.enabled,delete o.disabledReasons,o.icons&&o.icons.comment){var s=o.icons.comment;delete s.height,delete s.width,delete s.pinned}s=o.inputs;for(var i in s){var r=s[i];const l=r.block;r=r.shadow,l&&t(l),r&&t(r)}o.next&&(i=o.next,o=i.block,i=i.shadow,o&&t(o),i&&t(i))}}return e=JSON.parse(JSON.stringify(e)),t(e),Object.assign({},{kind:"BLOCK"},e)}},bs=47,In=44,_s=16,vg=20,lf=20,Sn=10,ph=0,gh=32,cf=.1,uf=80,hf=4,Cg=.4,af=.8,wg=45,vi=null,Ci=null,Rn=void 0,Ke={};Ke.BlockPaster=bi,Ke.copy=Rr,Ke.getLastCopiedData=Dr,Ke.getLastCopiedLocation=vc,Ke.getLastCopiedWorkspace=Nr,Ke.paste=Gt,Ke.registry=fu,Ke.setLastCopiedData=Qd,Ke.setLastCopiedLocation=t$,Ke.setLastCopiedWorkspace=e$;var Jt={};Jt.CollapseCommentBarButton=Lp,Jt.CommentBarButton=ln,Jt.CommentEditor=Mp,Jt.CommentView=pi,Jt.DeleteCommentBarButton=Pp,Jt.RenderedWorkspaceComment=ct,Jt.WorkspaceComment=cn;var $t;(function(e){e.ESCAPE="escape",e.DELETE="delete",e.COPY="copy",e.CUT="cut",e.PASTE="paste",e.UNDO="undo",e.REDO="redo"})($t||($t={})),Oc();var pt={};pt.names=$t,pt.registerCopy=Sc,pt.registerCut=Rc,pt.registerDefaultShortcuts=Oc,pt.registerDelete=kc,pt.registerEscape=wc,pt.registerPaste=Dc,pt.registerRedo=Ac,pt.registerUndo=Nc;var df=class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=j$}save(e){return e=e.getProcedureMap().getProcedures().map(t=>xc(t)),e.length?e:null}load(e,t){const o=t.getProcedureMap();for(const s of e)o.add(Lc(this.procedureModelClass,this.parameterModelClass,s,t))}clear(e){e.getProcedureMap().clear()}},Dn={};Dn.ProcedureSerializer=df,Dn.loadProcedure=Lc,Dn.saveProcedure=xc;var kg=class{constructor(){this.priority=K$}save(e){return e=e.getAllVariables().map(t=>t.save()),e.length?e:null}load(e,t){const o=Ot(g.VARIABLE_MODEL,Ce);e.forEach(s=>{o?.load(s,t)})}clear(e){e.getVariableMap().clear()}};Ls("variables",new kg);var Ig={};Ig.VariableSerializer=kg;var mh={};mh.load=s$,mh.save=o$;var $f={blocks:ui,exceptions:mo,priorities:Vm,procedures:Dn,registry:mu,variables:Ig,workspaceComments:Vr,workspaces:mh};"Blockly"in globalThis||(globalThis.Blockly={Msg:tp});var fh="label",Sg=class{load(e,t){return e=new ye(t.getWorkspace(),t.targetWorkspace,e,!0),e.show(),new ps(e,fh)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof ye&&e.dispose()}getType(){return fh}};I(g.FLYOUT_INFLATER,fh,Sg);var Rg=class extends vn{constructor(e){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,e&&(this.GRID_UNIT=e),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_(e){super.setFontConstants_(e),this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=this.FIELD_BORDER_RECT_HEIGHT=this.FIELD_TEXT_HEIGHT+this.FIELD_BORDER_RECT_Y_PADDING*2}init(){super.init(),this.HEXAGONAL=this.makeHexagonal(),this.ROUNDED=this.makeRounded(),this.SQUARED=this.makeSquared(),this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(e){super.setDynamicProperties_(e),this.SELECTED_GLOW_COLOUR=e.getComponentStyle("selectedGlowColour")||this.SELECTED_GLOW_COLOUR;const t=Number(e.getComponentStyle("selectedGlowSize"));this.SELECTED_GLOW_SIZE=t&&!isNaN(t)?t:this.SELECTED_GLOW_SIZE,this.REPLACEMENT_GLOW_COLOUR=e.getComponentStyle("replacementGlowColour")||this.REPLACEMENT_GLOW_COLOUR,this.REPLACEMENT_GLOW_SIZE=(e=Number(e.getComponentStyle("replacementGlowSize")))&&!isNaN(e)?e:this.REPLACEMENT_GLOW_SIZE}dispose(){super.dispose(),this.selectedGlowFilter&&F(this.selectedGlowFilter),this.replacementGlowFilter&&F(this.replacementGlowFilter)}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=ve("c",[y(25,-e),y(71,-e),y(t,0)]);return{height:e*.75,width:t,path:o}}makeHexagonal(){function e(o,s,i){var r=o/2;return r=r>t?t:r,i=i?-1:1,o=(s?-1:1)*o/2,rt(-i*r,o)+rt(i*r,o)}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(o){return o/=2,o>t?t:o},height(o){return o},connectionOffsetY(o){return o/2},connectionOffsetX(o){return-o},pathDown(o){return e(o,!1,!1)},pathUp(o){return e(o,!0,!1)},pathRightDown(o){return e(o,!1,!0)},pathRightUp(o){return e(o,!1,!0)}}}makeRounded(){function e(s,i,r){const l=s>o?s-o:0;s=(s>o?o:s)/2;const c=r===i?"0":"1";return Z("a","0 0,"+c,s,y((r?1:-1)*s,(i?-1:1)*s))+v("v",(i?-1:1)*l)+Z("a","0 0,"+c,s,y((r?-1:1)*s,(i?-1:1)*s))}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=t*2;return{type:this.SHAPES.ROUND,isDynamic:!0,width(s){return s/=2,s>t?t:s},height(s){return s},connectionOffsetY(s){return s/2},connectionOffsetX(s){return-s},pathDown(s){return e(s,!1,!1)},pathUp(s){return e(s,!0,!1)},pathRightDown(s){return e(s,!1,!0)},pathRightUp(s){return e(s,!1,!0)}}}makeSquared(){function e(o,s,i){o-=t*2;const r=i===s?"0":"1";return Z("a","0 0,"+r,t,y((i?1:-1)*t,(s?-1:1)*t))+v("v",(s?-1:1)*o)+Z("a","0 0,"+r,t,y((i?-1:1)*t,(s?-1:1)*t))}const t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(o){return t},height(o){return o},connectionOffsetY(o){return o/2},connectionOffsetX(o){return-o},pathDown(o){return e(o,!1,!1)},pathUp(o){return e(o,!0,!1)},pathRightDown(o){return e(o,!1,!0)},pathRightUp(o){return e(o,!1,!0)}}}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case E.INPUT_VALUE:case E.OUTPUT_VALUE:if(e=e.getSourceBlock().getOutputShape(),e!==null)switch(e){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return t&&t.includes("Boolean")?this.HEXAGONAL:t&&t.includes("Number")?this.ROUNDED:(t&&t.includes("String"),this.ROUNDED);case E.PREVIOUS_STATEMENT:case E.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(T){return ve("c",[y(T*i/2,0),y(T*i*3/4,l/2),y(T*i,l)])+jo([y(T*i,r)])+ve("c",[y(T*i/4,l/2),y(T*i/2,l),y(T*i,l)])+v("h",T*s)+ve("c",[y(T*i/2,0),y(T*i*3/4,-(l/2)),y(T*i,-l)])+jo([y(T*i,-r)])+ve("c",[y(T*i/4,-(l/2)),y(T*i/2,-l),y(T*i,-l)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=t/3,i=s/3,r=o/2,l=r/2,c=e(1),p=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:c,pathRight:p}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=Z("a","0 0,0",e,y(-e,e)),o=Z("a","0 0,1",e,y(-e,e)),s=Z("a","0 0,0",e,y(e,e)),i=Z("a","0 0,1",e,y(e,e));return{width:e,height:e,pathTop:t,pathBottom:s,rightWidth:e,rightHeight:e,pathTopRight:o,pathBottomRight:i}}generateSecondaryColour_(e){return lo("#000",e,.15)||e}generateTertiaryColour_(e){return lo("#000",e,.25)||e}createDom(e,t,o,s){super.createDom(e,t,o,s),e=m(h.DEFS,{},e),t=m(h.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),m(h.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},t),o=m(h.FECOMPONENTTRANSFER,{result:"outBlur"},t),m(h.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},o),m(h.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),m(h.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter=t,e=m(h.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),m(h.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=m(h.FECOMPONENTTRANSFER,{result:"outBlur"},e),m(h.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),m(h.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),m(h.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),m(h.FECOMPOSITE,{in:"SourceGraphic",in2:"outGlow",operator:"over"},e),this.replacementGlowFilterId=e.id,this.replacementGlowFilter=e,s&&(s.style.setProperty("--blocklySelectedGlowFilter",`url(#${this.selectedGlowFilterId})`),s.style.setProperty("--blocklyReplacementGlowFilter",`url(#${this.replacementGlowFilterId})`))}getCSS_(e){return[`${e} .blocklyText,`,`${e} .blocklyFlyoutLabelText {`,`font: ${this.FIELD_TEXT_FONTWEIGHT} ${this.FIELD_TEXT_FONTSIZE}pt ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e} .blocklyTextInputBubble textarea {`,"font-weight: normal;","}",`${e} .blocklyText {`,"fill: #fff;","}",`${e} .blocklyNonEditableField>rect:not(.blocklyDropdownRect),`,`${e} .blocklyEditableField>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${e} .blocklyNonEditableField>text,`,`${e} .blocklyEditableField>text,`,`${e} .blocklyNonEditableField>g>text,`,`${e} .blocklyEditableField>g>text {`,"fill: #575E75;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>rect,",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableField:not(.blocklyEditing):hover>.blocklyPath {","stroke: #fff;","stroke-width: 2;","}",`${e} .blocklyHtmlInput {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,`font-weight: ${this.FIELD_TEXT_FONTWEIGHT};`,"color: #575E75;","}",`${e} .blocklyDropdownText {`,"fill: #fff !important;","}",`${e}.blocklyWidgetDiv .blocklyMenuItem,`,`${e}.blocklyDropDownDiv .blocklyMenuItem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e}.blocklyDropDownDiv .blocklyMenuItemContent {`,"color: #fff;","}",`${e} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${e} .blocklyDisabledPattern > .blocklyOutlinePath {`,"fill: var(--blocklyDisabledPattern)","}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}",`${e} .blocklySelected>.blocklyPath.blocklyPathSelected {`,"fill: none;","filter: var(--blocklySelectedGlowFilter);","}",`${e} .blocklyReplaceable>.blocklyPath {`,"filter: var(--blocklyReplacementGlowFilter);","}"]}},Dg=class extends Cn{constructor(e,t){super(e,t)}draw(){const e=this.block_.pathObject;e.beginDrawing(),this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights(),e.setPath(this.outlinePath_+`
|
|
661
|
+
`+this.inlinePath_),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_(),this.info_.outputConnection&&(e.outputShapeType=this.info_.outputConnection.shape.type),e.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_(e){if(!(e.height<=0)){if(u.isSpacer(e)){const s=e.precedesStatement;var t=e.followsStatement;if(s||t){const i=this.constants_.INSIDE_CORNERS;var o=i.rightHeight;o=e.height-(s?o:0),t=t?i.pathBottomRight:"",e=o>0?v("V",e.yPos+o):"",this.outlinePath_+=t+e+(s?i.pathTopRight:"");return}}this.outlinePath_+=v("V",e.yPos+e.height)}}drawRightDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.outlinePath_+=this.info_.outputConnection.shape.pathRightDown(this.info_.outputConnection.height)}drawLeftDynamicConnection_(){if(!this.info_.outputConnection)throw Error("Cannot draw the output connection of a block that doesn't have one");this.positionOutputConnection_(),this.outlinePath_+=this.info_.outputConnection.shape.pathUp(this.info_.outputConnection.height),this.outlinePath_+="z"}drawFlatTop_(){const e=this.info_.topRow;this.positionPreviousConnection_(),this.outlinePath_+=K(e.xPos,this.info_.startY),this.outlinePath_+=v("h",e.width)}drawFlatBottom_(){const e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=v("V",e.baseline),this.outlinePath_+=v("h",-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);const t=e.input.name;e.connectedBlock||this.info_.isInsertionMarker||(e=ce(e.xPos+e.connectionWidth,e.centerline-e.height/2)+this.getInlineInputPath(e),this.block_.pathObject.setOutlinePath(t,e))}getInlineInputPath(e){const t=e.width-e.connectionWidth*2,o=e.height;return v("h",t)+e.shape.pathRightDown(o)+v("h",-t)+e.shape.pathUp(o)+"z"}drawStatementInput_(e){var t=e.getLastInput();const o=t.xPos+t.notchOffset+t.shape.width,s=this.constants_.INSIDE_CORNERS,i=t.shape.pathRight+v("h",-(t.notchOffset-s.width))+s.pathTop,r=e.height-2*s.height;t=s.pathBottom+v("h",t.notchOffset-s.width)+(t.connectedBottomNextConnection?"":t.shape.pathLeft),this.outlinePath_+=v("H",o)+i+v("v",r)+t+v("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}drawConnectionHighlightPath(e){const t=e.connectionModel;if(t.type===E.NEXT_STATEMENT||t.type===E.PREVIOUS_STATEMENT||t.type===E.OUTPUT_VALUE&&!e.isDynamicShape)return super.drawConnectionHighlightPath(e);e=t.type===E.INPUT_VALUE?ce(e.connectionWidth,-e.height/2)+this.getInlineInputPath(e):ce(e.width,-e.height/2)+e.shape.pathDown(e.height);const o=t.getSourceBlock();let s,i;return(i=(s=o.pathObject).addConnectionHighlight)==null?void 0:i.call(s,t,e,t.getOffsetInBlock(),o.RTL)}},Io=class extends L{constructor(e,t,o,s,i,r,l){if(super(L.SKIP_SETUP),this.imageElement=this.clickHandler=null,this.flipRtl=this.isDirty_=this.EDITABLE=!1,this.altText="",o=Number(J(o)),t=Number(J(t)),isNaN(o)||isNaN(t))throw Error("Height and width values of an image field must cast to numbers.");if(o<=0||t<=0)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new N(t,o+Io.Y_PADDING),this.imageHeight=o,typeof i=="function"&&(this.clickHandler=i),e!==L.SKIP_SETUP&&(l?this.configure_(l):(this.flipRtl=!!r,this.altText=J(s)||""),this.setValue(J(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl=e.flipRtl),e.alt&&(this.altText=J(e.alt))}initView(){this.imageElement=m(h.IMAGE,{height:this.imageHeight+"px",width:this.size_.width+"px",alt:this.altText},this.fieldGroup_),this.imageElement.setAttributeNS(Ie,"xlink:href",this.value_),this.fieldGroup_&&b(this.fieldGroup_,"blocklyImageField"),this.clickHandler&&(this.imageElement.style.cursor="pointer")}updateSize_(){}doClassValidation_(e){return typeof e!="string"?null:e}doValueUpdate_(e){this.value_=e,this.imageElement&&this.imageElement.setAttributeNS(Ie,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl}setAlt(e){e!==this.altText&&(this.altText=e||"",this.imageElement&&this.imageElement.setAttribute("alt",this.altText))}isClickable(){return super.isClickable()&&!!this.clickHandler}showEditor_(){this.clickHandler&&this.clickHandler(this)}setOnClickHandler(e){this.clickHandler=e}getText_(){return this.altText}static fromJson(e){if(!e.src||!e.width||!e.height)throw Error("src, width, and height values for an image field arerequired. The width and height must be non-zero.");return new this(e.src,e.width,e.height,void 0,void 0,void 0,e)}};Io.Y_PADDING=1,it("field_image",Io),Io.prototype.DEFAULT_VALUE="";var Es=class extends L{set size_(e){super.size_=e}get size_(){const e=super.size_;return e.width<14&&(e.width=14),e}constructor(e,t,o){super(L.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onInputWrapper=this.onKeyDownWrapper=this.valueWhenEditorWasOpened_=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,e!==L.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.spellcheck!==void 0&&(this.spellcheck_=e.spellcheck)}initView(){if(!this.getSourceBlock())throw new te;super.initView(),this.isFullBlockField()&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()),this.fieldGroup_&&b(this.fieldGroup_,"blocklyInputField")}isFullBlockField(){const e=this.getSourceBlock();if(!e)throw new te;let t;return this.fullBlockClickTarget_=!((t=this.getConstants())==null||!t.FULL_BLOCK_FIELDS)&&e.isSimpleReporter()}doValueInvalid_(e,t=!0){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,e=this.value_,this.value_=this.valueWhenEditorWasOpened_,this.sourceBlock_&&z()&&this.value_!==e&&t&&C(new(w(a.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,e,this.value_)))}doValueUpdate_(e){this.isTextValid_=this.isDirty_=!0,this.value_=e}applyColour(){const e=this.getSourceBlock();if(!e)throw new te;this.getConstants().FULL_BLOCK_FIELDS&&this.fieldGroup_&&(!this.isFullBlockField()&&this.borderRect_?(this.borderRect_.style.display="block",this.borderRect_.setAttribute("stroke",e.getColourTertiary())):(this.borderRect_.style.display="none",e.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR)))}getSize(){let e;return(e=this.getConstants())!=null&&e.FULL_BLOCK_FIELDS&&(this.render_(),this.isDirty_=!1),super.getSize()}onLocationChange(){this.isBeingEdited_&&this.resizeEditor_()}render_(){if(super.render_(),this.isBeingEdited_){var e=this.htmlInput_;this.isTextValid_?(O(e,"blocklyInvalidInput"),oe(e,Q.INVALID,!1)):(b(e,"blocklyInvalidInput"),oe(e,Q.INVALID,!0))}if(e=this.getSourceBlock(),!e)throw new te;this.getConstants().FULL_BLOCK_FIELDS&&e.applyColour()}setSpellcheck(e){e!==this.spellcheck_&&(this.spellcheck_=e,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(e,t=!1,o=!0){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(S$||su||Fr)?this.showPromptEditor():this.showInlineEditor(t,o)}showPromptEditor(){Zi(n.Msg$$module$build$src$core$msg.CHANGE_VALUE_TITLE,this.getText(),e=>{e!==null&&this.setValue(this.getValueFromEditorText_(e)),this.onFinishEditing_(this.value_)})}showInlineEditor(e,t){const o=this.getSourceBlock();if(!o)throw new te;$r(this,o.RTL,this.widgetDispose_.bind(this),this.workspace_,t),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,this.valueWhenEditorWasOpened_=this.value_,e||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var e=this.getSourceBlock();if(!e)throw new te;n.setGroup$$module$build$src$core$events$utils(!0);const t=zo();var o=this.getClickTarget_();if(!o)throw Error("A click target has not been set.");b(o,"blocklyEditing"),o=document.createElement("input"),o.className="blocklyHtmlInput",o.setAttribute("spellcheck",this.spellcheck_);const s=this.workspace_.getAbsoluteScale();var i=this.getConstants().FIELD_TEXT_FONTSIZE*s+"pt";return t.style.fontSize=i,o.style.fontSize=i,i=Es.BORDERRADIUS*s+"px",this.isFullBlockField()&&(i=this.getScaledBBox(),i=(i.bottom-i.top)/2+"px",e=e.getParent()?e.getParent().getColourTertiary():this.sourceBlock_.getColourTertiary(),o.style.border=1*s+"px solid "+e,t.style.borderRadius=i,t.style.transition="box-shadow 0.25s ease 0s",this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW&&(t.style.boxShadow="rgba(255, 255, 255, 0.3) 0 0 0 "+4*s+"px")),o.style.borderRadius=i,t.appendChild(o),o.value=o.defaultValue=this.getEditorText_(this.value_),o.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(o),o}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),this.sourceBlock_&&z()&&this.valueWhenEditorWasOpened_!==null&&this.valueWhenEditorWasOpened_!==this.value_&&(C(new(w(a.BLOCK_CHANGE))(this.sourceBlock_,"field",this.name||null,this.valueWhenEditorWasOpened_,this.value_)),this.valueWhenEditorWasOpened_=null),n.setGroup$$module$build$src$core$events$utils(!1),this.unbindInputEvents_();var e=zo().style;if(e.width="auto",e.height="auto",e.fontSize="",e.transition="",e.boxShadow="",this.htmlInput_=null,e=this.getClickTarget_(),!e)throw Error("A click target has not been set.");O(e,"blocklyEditing")}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper=k(e,"keydown",this,this.onHtmlInputKeyDown_),this.onInputWrapper=k(e,"input",this,this.onHtmlInputChange)}unbindInputEvents_(){this.onKeyDownWrapper&&(x(this.onKeyDownWrapper),this.onKeyDownWrapper=null),this.onInputWrapper&&(x(this.onInputWrapper),this.onInputWrapper=null)}onHtmlInputKeyDown_(e){if(e.key==="Enter")co(this),ot();else if(e.key==="Escape")this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value"),!1),co(this),ot();else if(e.key==="Tab"){e.preventDefault();var t,o=(t=this.workspace_)==null?void 0:t.getCursor();t=s=>(s instanceof Es||s instanceof H&&s.isSimpleReporter())&&s!==this.getSourceBlock(),e=e.shiftKey?o?.getPreviousNode(this,t,!1):o?.getNextNode(this,t,!1),e=e instanceof H&&e.isSimpleReporter()?e.getFields().next().value:e,e instanceof Es&&(co(this),ot(),o=e.getSourceBlock(),e.isFullBlockField()&&o&&o instanceof H?n.getFocusManager$$module$build$src$core$focus_manager().focusNode(o):n.getFocusManager$$module$build$src$core$focus_manager().focusNode(e),e.showEditor())}}onHtmlInputChange(e){e=this.value_,this.setValue(this.getValueFromEditorText_(this.htmlInput_.value),!1),this.sourceBlock_&&z()&&this.value_!==e&&C(new(w(a.BLOCK_FIELD_INTERMEDIATE_CHANGE))(this.sourceBlock_,this.name||null,e,this.value_))}setEditorValue_(e,t=!0){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(e)),this.setValue(e,t)}resizeEditor_(){tt().then(()=>{const e=this.getSourceBlock();if(!e)throw new te;const t=zo(),o=this.getScaledBBox();t.style.width=o.right-o.left+"px",t.style.height=o.bottom-o.top+"px";const s=o.top;t.style.left=`${e.RTL?o.right-t.offsetWidth:o.left}px`,t.style.top=`${s}px`})}repositionForWindowResize(){let e;const t=(e=this.getSourceBlock())==null?void 0:e.getRootBlock();return t instanceof H?(Zo(this.workspace_,this.workspace_.getMetricsManager().getViewMetrics(!0),t)||this.resizeEditor_(),!0):!1}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(e){return`${e}`}getValueFromEditorText_(e){return e}};Es.BORDERRADIUS=4,n.FieldTextInput$$module$build$src$core$field_textinput=class extends Es{constructor(e,t,o){super(e,t,o)}initView(){super.initView(),this.fieldGroup_&&b(this.fieldGroup_,"blocklyTextInputField")}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(J(e.text),void 0,e)}},it("field_input",n.FieldTextInput$$module$build$src$core$field_textinput),n.FieldTextInput$$module$build$src$core$field_textinput.prototype.DEFAULT_VALUE="",n.FieldTextInput$$module$build$src$core$field_textinput;var Ng=class extends oh{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){return!!e.outputConnection}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},Nn=class extends yn{constructor(e,t){if(super(e,t),this.connectedBottomNextConnection=!1,this.connectedBlock){for(e=this.connectedBlock;t=e.getNextBlock();)e=t;e.nextConnection||(this.height=this.connectedBlockHeight,this.connectedBottomNextConnection=!0)}}},Ag=class extends dt{constructor(e){super(e),this.width=this.height=0,this.type|=u.getType("RIGHT_CONNECTION")}},Og=class extends ch{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){const t=(e.hat?e.hat==="cap":this.constants_.ADD_START_HATS)&&!e.outputConnection&&!e.previousConnection;return!!e.outputConnection||t}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},xg=class extends yi{constructor(e,t){super(e,t),this.isInline=!0,this.renderer_=e,this.constants_=this.renderer_.getConstants(),this.topRow=new Og(this.constants_),this.bottomRow=new Ng(this.constants_),this.isMultiRow=!t.getInputsInline()||t.isCollapsed(),this.hasStatementInput=t.statementInputCount>0,this.rightSide=this.outputConnection?new Ag(this.constants_):null,this.rightAlignedDummyInputs=new WeakMap}getRenderer(){return this.renderer_}measure(){this.createRows_(),this.addElemSpacing_(),this.addRowSpacing_(),this.adjustXPosition_(),this.computeBounds_(),this.alignRowElements_(),this.finalize_()}shouldStartNewRow_(e,t){return t?t instanceof Dt||e instanceof Ae||t instanceof Ae?!0:e instanceof n.ValueInput$$module$build$src$core$inputs$value_input||e instanceof ht||e instanceof Dt?!this.isInline||this.isMultiRow:!1:!1}getDesiredRowWidth_(e){return e.hasStatement?this.width-this.startX-(this.constants_.INSIDE_CORNERS.rightWidth||0):super.getDesiredRowWidth_(e)}getInRowSpacing_(e,t){return e&&t||!this.outputConnection||!this.outputConnection.isDynamicShape||this.hasStatementInput||this.bottomRow.hasNextConnection?!e&&t&&u.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:e&&u.isLeftRoundedCorner(e)&&t&&(u.isPreviousConnection(t)||u.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&u.isLeftSquareCorner(e)&&t&&u.isHat(t)||e&&u.isField(e)&&e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(e,t){if(u.isTopRow(e)&&u.isBottomRow(t))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;const o=u.isInputRow(e)&&e.hasStatement,s=u.isInputRow(t)&&t.hasStatement;return s||o?(e=Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.INSIDE_CORNERS.rightHeight||0),s&&o?Math.max(e,this.constants_.DUMMY_INPUT_MIN_HEIGHT):e):u.isTopRow(e)?e.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):u.isBottomRow(t)?this.outputConnection?!t.hasNextConnection&&this.hasStatementInput?Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):this.constants_.NO_PADDING:Math.max(this.topRow.minHeight,Math.max(this.constants_.NOTCH_HEIGHT,this.constants_.CORNER_RADIUS))-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}getSpacerRowWidth_(e,t){const o=this.width-this.startX;return u.isInputRow(e)&&e.hasStatement||u.isInputRow(t)&&t.hasStatement?Math.max(o,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):o}getElemCenterline_(e,t){if(e.hasStatement&&!u.isSpacer(t)&&!u.isStatementInput(t))return e.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(u.isInlineInput(t)){const o=t.connectedBlock;if(o&&o.outputConnection&&o.nextConnection)return e.yPos+o.height/2}return super.getElemCenterline_(e,t)}addInput_(e,t){if((e instanceof ht||e instanceof Dt)&&t.hasDummyInput&&t.align===n.Align$$module$build$src$core$inputs$align.LEFT&&e.align===n.Align$$module$build$src$core$inputs$align.RIGHT)this.rightAlignedDummyInputs.set(t,e);else if(e instanceof Ae){t.elements.push(new Nn(this.constants_,e)),t.hasStatement=!0,t.align===null&&(t.align=e.align);return}super.addInput_(e,t)}addAlignmentPadding_(e,t){if(this.rightAlignedDummyInputs.get(e)){let o;for(let s=0;s<e.elements.length;s++){const i=e.elements[s];if(u.isSpacer(i)&&(o=i),u.isField(i)&&i.parentInput===this.rightAlignedDummyInputs.get(e))break}if(o){o.width+=t,e.width+=t;return}}super.addAlignmentPadding_(e,t)}adjustXPosition_(){const e=this.constants_.NOTCH_OFFSET_LEFT+this.constants_.NOTCH_WIDTH;let t=e;for(let i=2;i<this.rows.length-1;i+=2){var o=this.rows[i-1];const r=this.rows[i];var s=this.rows[i+1];if(o=i===2?!!this.topRow.hasPreviousConnection:!!o.followsStatement,s=i+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!s.precedesStatement,u.isInputRow(r)&&r.hasStatement){r.measure();let l,c;t=r.width-((c=(l=r.getLastInput())==null?void 0:l.width)!=null?c:0)+e}else if(o&&(i===2||s)&&u.isInputRow(r)&&!r.hasStatement){s=r.xPos,o=null;for(let l=0;l<r.elements.length;l++){const c=r.elements[l];u.isSpacer(c)&&(o=c),!(o&&(u.isField(c)||u.isInput(c))&&s<t)||u.isField(c)&&(c.field instanceof Co||c.field instanceof Io)||(o.width+=t-s),s+=c.width}}}}finalizeOutputConnection_(){if(this.outputConnection&&this.outputConnection.isDynamicShape){var e=this.outputConnection.shape;if("isDynamic"in e&&e.isDynamic){for(var t=0,o=0;o<this.rows.length;o++){const s=this.rows[o];s.yPos=t,t+=s.height}this.height=t,o=this.bottomRow.hasNextConnection?this.height-this.bottomRow.descenderHeight:this.height,t=e.height(o),o=e.width(o),this.outputConnection.height=t,this.outputConnection.width=o,this.outputConnection.startX=o,this.outputConnection.connectionOffsetY=e.connectionOffsetY(t),this.outputConnection.connectionOffsetX=e.connectionOffsetX(o),e=0,this.hasStatementInput||this.bottomRow.hasNextConnection||(e=o,this.rightSide.height=t,this.rightSide.width=e,this.rightSide.centerline=t/2,this.rightSide.xPos=this.width+e),this.startX=o,this.width+=o+e,this.widthWithChildren+=o+e}}}finalizeHorizontalAlignment_(){if(this.outputConnection&&!this.hasStatementInput&&!this.bottomRow.hasNextConnection){for(var e=0,t=0;t<this.rows.length;t++){var o=this.rows[t];if(!u.isInputRow(o))continue;e=o.elements[o.elements.length-2];let s=this.getNegativeSpacing_(o.elements[1]),i=this.getNegativeSpacing_(e);e=s+i;const r=this.constants_.MIN_BLOCK_WIDTH+this.outputConnection.width*2;this.width-e<r&&(e=this.width-r,s=e/2,i=e/2),o.elements.unshift(new Oe(this.constants_,-s)),o.elements.push(new Oe(this.constants_,-i))}if(e)for(this.width-=e,this.widthWithChildren-=e,this.rightSide.xPos-=e,t=0;t<this.rows.length;t++)o=this.rows[t],u.isTopOrBottomRow(o)&&(o.elements[1].width-=e),o.width-=e,o.widthWithConnectedBlocks-=e}}getNegativeSpacing_(e){if(!e||!this.outputConnection)return 0;const t=this.outputConnection.width;var o=this.outputConnection.shape.type;const s=this.constants_;if(this.inputRows.length>1)switch(o){case s.SHAPES.ROUND:return o=this.constants_.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=this.height/2>o?o:this.height/2,t-o*(1-Math.sin(Math.acos((o-this.constants_.SMALL_PADDING)/o)));default:return 0}if(u.isInlineInput(e)){const i=e.connectedBlock;return e=i?i.pathObject.outputShapeType:e.shape.type,e==null||i&&i.outputConnection&&(i.statementInputCount||i.nextConnection)||o===s.SHAPES.HEXAGONAL&&o!==e?0:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][e]}return u.isField(e)?o===s.SHAPES.ROUND&&e.field instanceof n.FieldTextInput$$module$build$src$core$field_textinput?t-2.75*s.GRID_UNIT:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][0]:u.isIcon(e)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let s=2;s<this.rows.length-1;s+=2){const i=this.rows[s-1],r=this.rows[s],l=this.rows[s+1];var e=s===2,t=s+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!l.precedesStatement;if(e?this.topRow.hasPreviousConnection:i.followsStatement){var o=r.elements[1];if(o=r.elements.length===3&&o instanceof ih&&(o.field instanceof Co||o.field instanceof Io),!e&&o)i.height-=this.constants_.SMALL_PADDING,l.height-=this.constants_.SMALL_PADDING,r.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)i.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t<r.elements.length;t++)if(o=r.elements[t],u.isInlineInput(o)&&o.connectedBlock&&!o.connectedBlock.isShadow()&&o.connectedBlock.getHeightWidth().height>=40){e=!0;break}e&&(i.height-=this.constants_.SMALL_PADDING,l.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_(),this.finalizeHorizontalAlignment_(),this.finalizeVerticalAlignment_(),super.finalize_(),this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},Lg=class extends wn{constructor(e,t,o){super(e,t,o),this.svgPathSelected=null,this.outlines=new Map,this.remainingOutlines=new Set,this.outputShapeType=null,this.constants=o}setPath(e){super.setPath(e),this.svgPathSelected&&this.svgPathSelected.setAttribute("d",e)}applyColour(e){super.applyColour(e);const t=e.getParent();e.isShadow()&&t&&this.svgPath.setAttribute("stroke",t.getColourTertiary());for(const o of this.outlines.values())o.setAttribute("fill",this.style.colourTertiary)}flipRTL(){super.flipRTL();for(const e of this.outlines.values())e.setAttribute("transform","scale(-1 1)")}updateSelected(e){this.setClass_("blocklySelected",e),e?this.svgPathSelected||(this.svgPathSelected=this.svgPath.cloneNode(!0),this.svgPathSelected.classList.add("blocklyPathSelected"),O(this.svgPathSelected,de.ACTIVE_FOCUS_NODE_CSS_CLASS_NAME),O(this.svgPathSelected,de.PASSIVE_FOCUS_NODE_CSS_CLASS_NAME),this.svgPathSelected.removeAttribute("tabindex"),this.svgPathSelected.removeAttribute("id"),this.svgRoot.appendChild(this.svgPathSelected)):this.svgPathSelected&&(this.svgRoot.removeChild(this.svgPathSelected),this.svgPathSelected=null)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e)}updateShapeForInputHighlight(e,t){e=e.getParentInput().name,(e=this.getOutlinePath(e))&&(t?e.setAttribute("filter","url(#"+this.constants.replacementGlowFilterId+")"):e.removeAttribute("filter"))}beginDrawing(){this.remainingOutlines.clear();for(const e of this.outlines.keys())this.remainingOutlines.add(e)}endDrawing(){if(this.remainingOutlines.size)for(const e of this.remainingOutlines)this.removeOutlinePath(e);this.remainingOutlines.clear()}setOutlinePath(e,t){e=this.getOutlinePath(e),e.setAttribute("d",t),e.setAttribute("fill",this.style.colourTertiary)}getOutlinePath(e){return this.outlines.has(e)||this.outlines.set(e,m(h.PATH,{class:"blocklyOutlinePath",d:""},this.svgRoot)),this.remainingOutlines.delete(e),this.outlines.get(e)}removeOutlinePath(e){let t,o;(t=this.outlines.get(e))==null||(o=t.parentNode)==null||o.removeChild(this.outlines.get(e)),this.outlines.delete(e)}},bh=class extends kn{constructor(e){super(e)}makeConstants_(){return new Rg}makeRenderInfo_(e){return new xg(this,e)}makeDrawer_(e,t){return new Dg(e,t)}makePathObject(e,t){return new Lg(e,t,this.getConstants())}getConstants(){return this.constants_}};js("zelos",bh);var Mg=class{constructor(e){this.staticConn=this.draggedConn=this.markerConn=this.fadedBlock=null,this.workspace=e.workspace}previewReplacement(e,t,o){n.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.fadedBlock=o,o.fadeForReplacement(!0),this.workspace.getRenderer().shouldHighlightConnection(t)&&(t.highlight(),this.staticConn=t)}finally{n.enable$$module$build$src$core$events$utils()}}previewConnection(e,t){if(e!==this.draggedConn||t!==this.staticConn){n.disable$$module$build$src$core$events$utils();try{this.hidePreview(),this.shouldUseMarkerPreview(e,t)&&(this.markerConn=this.previewMarker(e,t)),this.workspace.getRenderer().shouldHighlightConnection(t)&&t.highlight(),this.draggedConn=e,this.staticConn=t}finally{n.enable$$module$build$src$core$events$utils()}}}shouldUseMarkerPreview(e,t){return t.type===E.PREVIOUS_STATEMENT||t.type===E.NEXT_STATEMENT||!(this.workspace.getRenderer()instanceof bh)}previewMarker(e,t){const o=e.getSourceBlock(),s=this.createInsertionMarker(o),i=this.getMatchingConnection(o,s,e);if(!i)return null;s.queueRender(),Bt(),i.connect(t);const r={x:t.x-i.x,y:t.y-i.y},l=i.getOffsetInBlock().clone();return tt().then(()=>{if(!s.isDeadOrDying()){n.disable$$module$build$src$core$events$utils();try{s?.positionNearConnection(i,r,l),s?.getSvgRoot().setAttribute("visibility","visible")}finally{n.enable$$module$build$src$core$events$utils()}}}),i}createInsertionMarker(e){const t=Be(e,{addCoordinates:!1,addInputBlocks:!1,addNextBlocks:!1,doFullSerialization:!1});if(!t)throw Error(`Failed to serialize source block. ${e.toDevString()}`);e=Pt(t,this.workspace);for(const o of e.getDescendants(!1))o.setInsertionMarker(!0);return e.initSvg(),e.getSvgRoot().setAttribute("visibility","hidden"),e}getMatchingConnection(e,t,o){if(e=e.getConnections_(!0),t=t.getConnections_(!0),e.length!==t.length)return null;for(let s=0;s<e.length;s++)if(e[s]===o)return t[s];return null}hidePreview(){n.disable$$module$build$src$core$events$utils();try{this.staticConn&&(this.staticConn.unhighlight(),this.staticConn=null),this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null),this.markerConn&&(this.hideInsertionMarker(this.markerConn),this.draggedConn=this.markerConn=null)}finally{n.enable$$module$build$src$core$events$utils()}}hideInsertionMarker(e){const t=e.getSourceBlock(),o=t.outputConnection;let s;if((s=t.previousConnection)!=null&&s.targetConnection||o!=null&&o.targetConnection)t.unplug(!0);else{let i;(i=e.targetBlock())==null||i.unplug(!1)}t.dispose()}dispose(){this.hidePreview()}};I(g.CONNECTION_PREVIEWER,Ce,Mg);var Zt={};Zt.Align=n.Align$$module$build$src$core$inputs$align,Zt.DummyInput=ht,Zt.EndRowInput=Dt,Zt.Input=ds,Zt.StatementInput=Ae,Zt.ValueInput=n.ValueInput$$module$build$src$core$inputs$value_input,Zt.inputTypes=n.inputTypes$$module$build$src$core$inputs$input_types;var Bg=!1,Pg;n.CodeGenerator$$module$build$src$core$generator=class{constructor(e){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_=e,this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")}workspaceToCode(e){e||(console.warn("No workspace specified in workspaceToCode call. Guessing."),e=Me());var t=[];this.init(e),e=e.getTopBlocks(!0);for(let o=0,s;s=e[o];o++){let i=this.blockToCode(s);Array.isArray(i)&&(i=i[0]),i&&(s.outputConnection&&(i=this.scrubNakedValue(i),this.STATEMENT_PREFIX&&!s.suppressPrefixSuffix&&(i=this.injectId(this.STATEMENT_PREFIX,s)+i),this.STATEMENT_SUFFIX&&!s.suppressPrefixSuffix&&(i+=this.injectId(this.STATEMENT_SUFFIX,s))),t.push(i))}return t=t.join(`
|
|
662
|
+
`),t=this.finish(t),t=t.replace(/^\s+\n/,""),t=t.replace(/\n\s+$/,`
|
|
663
|
+
`),t=t.replace(/[ \t]+\n/g,`
|
|
664
|
+
`)}prefixLines(e,t){return t+e.replace(/(?!\n$)\n/g,`
|
|
665
|
+
`+t)}allNestedComments(e){const t=[];e=e.getDescendants(!0);for(let o=0;o<e.length;o++){const s=e[o].getCommentText();s&&t.push(s)}return t.length&&t.push(""),t.join(`
|
|
666
|
+
`)}blockToCode(e,t){if(this.isInitialized===!1&&console.warn("CodeGenerator init was not called before blockToCode was called."),!e)return"";if(!e.isEnabled())return t?"":this.blockToCode(e.getNextBlock());if(e.isInsertionMarker())return t?"":this.blockToCode(e.getChildren(!1)[0]);var o=this.forBlock[e.type];if(typeof o!="function")throw Error(`${this.name_} generator does not know how to generate code for block type "${e.type}".`);if(o=o.call(e,e,this),Array.isArray(o)){if(!e.outputConnection)throw TypeError("Expecting string from statement block: "+e.type);return[this.scrub_(e,o[0],t),o[1]]}if(typeof o=="string")return this.STATEMENT_PREFIX&&!e.suppressPrefixSuffix&&(o=this.injectId(this.STATEMENT_PREFIX,e)+o),this.STATEMENT_SUFFIX&&!e.suppressPrefixSuffix&&(o+=this.injectId(this.STATEMENT_SUFFIX,e)),this.scrub_(e,o,t);if(o===null)return"";throw SyntaxError("Invalid code generated: "+o)}valueToCode(e,t,o){if(isNaN(o))throw TypeError("Expecting valid order from block: "+e.type);var s=e.getInputTargetBlock(t);if(!s&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(!s||(t=this.blockToCode(s),t===""))return"";if(!Array.isArray(t))throw TypeError(`Expecting tuple from value block: ${s.type} See developers.google.com/blockly/guides/create-custom-blocks/generating-code for more information`);if(e=t[0],t=t[1],isNaN(t))throw TypeError("Expecting valid order from value block: "+s.type);if(!e)return"";s=!1;var i=Math.floor(o);const r=Math.floor(t);if(i<=r&&(i!==r||i!==0&&i!==99)){for(s=!0,i=0;i<this.ORDER_OVERRIDES.length;i++)if(this.ORDER_OVERRIDES[i][0]===o&&this.ORDER_OVERRIDES[i][1]===t){s=!1;break}}return s&&(e="("+e+")"),e}statementToCode(e,t){const o=e.getInputTargetBlock(t);if(!o&&!e.getInput(t))throw ReferenceError(`Input "${t}" doesn't exist on "${e.type}"`);if(e=this.blockToCode(o),typeof e!="string")throw TypeError("Expecting code from statement block: "+(o&&o.type));return e&&(e=this.prefixLines(e,this.INDENT)),e}addLoopTrap(e,t){return this.INFINITE_LOOP_TRAP&&(e=this.prefixLines(this.injectId(this.INFINITE_LOOP_TRAP,t),this.INDENT)+e),this.STATEMENT_SUFFIX&&!t.suppressPrefixSuffix&&(e=this.prefixLines(this.injectId(this.STATEMENT_SUFFIX,t),this.INDENT)+e),this.STATEMENT_PREFIX&&!t.suppressPrefixSuffix&&(e+=this.prefixLines(this.injectId(this.STATEMENT_PREFIX,t),this.INDENT)),e}injectId(e,t){return t=t.id.replace(/\$/g,"$$$$"),e.replace(/%1/g,"'"+t+"'")}addReservedWords(e){this.RESERVED_WORDS_+=e+","}provideFunction_(e,t){if(!this.definitions_[e]){const o=this.nameDB_.getDistinctName(e,n.NameType$$module$build$src$core$names.PROCEDURE);this.functionNames_[e]=o,Array.isArray(t)&&(t=t.join(`
|
|
667
|
+
`)),t=t.trim().replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,o);let s;for(;s!==t;)s=t,t=t.replace(/^(( {2})*) {2}/gm,"$1\0");t=t.replace(/\0/g,this.INDENT),this.definitions_[e]=t}return this.functionNames_[e]}getVariableName(e){return this.getName(e,n.NameType$$module$build$src$core$names.VARIABLE)}getProcedureName(e){return this.getName(e,n.NameType$$module$build$src$core$names.PROCEDURE)}getName(e,t){if(!this.nameDB_)throw Error("Name database is not defined. You must initialize `nameDB_` in your generator class and call `init` first.");return this.nameDB_.getName(e,t)}init(e){this.definitions_=Object.create(null),this.functionNames_=Object.create(null)}scrub_(e,t,o){return t}finish(e){return this.definitions_=Object.create(null),this.functionNames_=Object.create(null),e}scrubNakedValue(e){return e}},Pg={},Pg.CodeGenerator=n.CodeGenerator$$module$build$src$core$generator;var _h=class extends fn{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),o=t.getScrollMetrics(),s=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.y=="number"&&(this.workspace_.scrollY=-(o.top+(o.height-s.height)*e.y)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager();const t=e.getAbsoluteMetrics(),o=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===S.LEFT?e.width:o.width-this.getWidth():this.toolboxPosition_===S.LEFT?0:o.width:this.toolboxPosition_===S.LEFT?0:o.width+t.left-this.getWidth()}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=e.height;var t=this.getWidth()-this.CORNER_RADIUS;this.setBackgroundPath(t,e.height-2*this.CORNER_RADIUS),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===S.RIGHT;var s=e+this.CORNER_RADIUS;s=["M "+(o?s:0)+",0"],s.push("h",o?-e:e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,o?0:1,o?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("v",Math.max(0,t)),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,o?0:1,o?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("h",o?e:-e),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setY(0)}wheel_(e){var t=Cs(e);if(t.y){const o=this.workspace_.getMetricsManager(),s=o.getScrollMetrics();t=o.getViewMetrics().top-s.top+t.y;let i;(i=this.workspace_.scrollbar)==null||i.setY(t),Us(this.workspace_),ot()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;var t=this.MARGIN;const o=this.RTL?t:t+this.tabWidth_;for(const s of e)s.getElement().moveBy(o,t),t+=s.getElement().getBoundingRectangle().getHeight()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return e<t&&e>-t||e<-180+t||e>180-t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const e=this.svgGroup_.getBoundingClientRect(),t=e.left;return this.toolboxPosition_===S.LEFT?new D(-1e9,1e9,-1e9,t+e.width):new D(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((t,o)=>Math.max(t,o.getElement().getBoundingRectangle().getWidth()),0);if(e+=this.MARGIN*1.5+this.tabWidth_,e*=this.workspace_.scale,e+=q.scrollbarThickness,this.getWidth()!==e){if(this.RTL)for(const t of this.getContents()){const o=t.getElement().getBoundingRectangle().left,s=e/this.workspace_.scale-t.getElement().getBoundingRectangle().getWidth()-this.MARGIN-this.tabWidth_;t.getElement().moveBy(s-o,0)}this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==S.LEFT||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets()}}};_h.registryName="verticalFlyout",I(g.FLYOUTS_VERTICAL_TOOLBOX,Ce,_h);var Fg=class extends fn{constructor(e){super(e),this.horizontalLayout=!0}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),o=t.getScrollMetrics(),s=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.x=="number"&&(this.workspace_.scrollX=-(o.left+(o.width-s.width)*e.x)),this.workspace_.translate(this.workspace_.scrollX+t.left,this.workspace_.scrollY+t.top)}}getX(){return 0}getY(){if(!this.isVisible())return 0;var e=this.targetWorkspace.getMetricsManager();const t=e.getAbsoluteMetrics(),o=e.getViewMetrics();e=e.getToolboxMetrics();const s=this.toolboxPosition_===S.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?s?e.height:o.height-this.getHeight():s?0:o.height:s?0:o.height+t.top-this.getHeight()}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=e.width,e=e.width-2*this.CORNER_RADIUS;var t=this.getHeight()-this.CORNER_RADIUS;this.setBackgroundPath(e,t),e=this.getX(),t=this.getY(),this.positionAt_(this.getWidth(),this.getHeight(),e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===S.TOP,s=["M 0,"+(o?0:this.CORNER_RADIUS)];o?(s.push("h",e+2*this.CORNER_RADIUS),s.push("v",t),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("h",-e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,-this.CORNER_RADIUS,-this.CORNER_RADIUS)):(s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,-this.CORNER_RADIUS),s.push("h",e),s.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,1,this.CORNER_RADIUS,this.CORNER_RADIUS),s.push("v",t),s.push("h",-e-2*this.CORNER_RADIUS)),s.push("z"),this.svgBackground_.setAttribute("d",s.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setX(this.RTL?1/0:0)}wheel_(e){var t=Cs(e);if(t=t.x||t.y){const o=this.workspace_.getMetricsManager(),s=o.getScrollMetrics();t=o.getViewMetrics().left-s.left+t;let i;(i=this.workspace_.scrollbar)==null||i.setX(t),Us(this.workspace_),ot()}e.preventDefault(),e.stopPropagation()}layout_(e){this.workspace_.scale=this.targetWorkspace.scale;const t=this.MARGIN;let o=t+this.tabWidth_;this.RTL&&(e=e.reverse());for(const s of e)e=s.getElement().getBoundingRectangle(),e=this.RTL?o+e.getWidth():o,s.getElement().moveBy(e,t),o+=s.getElement().getBoundingRectangle().getWidth()}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return e<90+t&&e>90-t||e>-90-t&&e<-90+t}getClientRect(){if(!this.svgGroup_||this.autoClose||!this.isVisible())return null;const e=this.svgGroup_.getBoundingClientRect(),t=e.top;return this.toolboxPosition_===S.TOP?new D(-1e9,t+e.height,-1e9,1e9):new D(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=this.getContents().reduce((t,o)=>Math.max(t,o.getElement().getBoundingRectangle().getHeight()),0);e+=this.MARGIN*1.5,e*=this.workspace_.scale,e+=q.scrollbarThickness,this.getHeight()!==e&&(this.targetWorkspace.scrollbar||this.autoClose||this.targetWorkspace.getFlyout()!==this||this.toolboxPosition_!==S.TOP||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.resizeContents(),this.targetWorkspace.recordDragTargets())}};I(g.FLYOUTS_HORIZONTAL_TOOLBOX,Ce,Fg);var wi=class extends $e{constructor(e,t,o,s,i){super(L.SKIP_SETUP),this.defaultType="",this.variableTypes=[],this.variable=null,this.SERIALIZABLE=!0,this.menuGenerator_=wi.dropdownCreate,this.defaultVariableName=typeof e=="string"?e:"",this.size_=new N(0,0),e!==L.SKIP_SETUP&&(i?this.configure_(i):this.setTypes(o,s),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes(e.variableTypes,e.defaultType)}initModel(){var e=this.getSourceBlock();if(!e)throw new te;this.variable||(e=n.getOrCreateVariablePackage$$module$build$src$core$variables(e.workspace,null,this.defaultVariableName,this.defaultType),this.doValueUpdate_(e.getId()))}initView(){super.initView(),b(this.fieldGroup_,"blocklyVariableField")}shouldAddBorderRect_(){const e=this.getSourceBlock();if(!e)throw new te;return super.shouldAddBorderRect_()&&(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW||e.type!=="variables_get")}fromXml(e){var t=this.getSourceBlock();if(!t)throw new te;const o=e.getAttribute("id"),s=e.textContent,i=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=n.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,o,s,i),i!==null&&i!==t.getType())throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.getType()+", and does not match variable field that references it: "+st(e)+".");this.setValue(t.getId())}toXml(e){return this.initModel(),e.id=this.variable.getId(),e.textContent=this.variable.getName(),this.variable.getType()&&e.setAttribute("variabletype",this.variable.getType()),e}saveState(e){var t=this.saveLegacyState(wi);return t!==null||(this.initModel(),t={id:this.variable.getId()},e&&(t.name=this.variable.getName(),t.type=this.variable.getType())),t}loadState(e){const t=this.getSourceBlock();if(!t)throw new te;this.loadLegacyState(wi,e)||(e=n.getOrCreateVariablePackage$$module$build$src$core$variables(t.workspace,e.id||null,e.name,e.type||""),this.setValue(e.getId()))}setSourceBlock(e){if(e.isShadow())throw Error("Variable fields are not allowed to exist on shadow blocks.");super.setSourceBlock(e)}getValue(){return this.variable?this.variable.getId():null}getText(){return this.variable?this.variable.getName():""}getVariable(){return this.variable}getDefaultType(){return this.defaultType}getValidator(){return this.variable?this.validator_:null}doClassValidation_(e){if(e===null)return null;var t=this.getSourceBlock();if(!t)throw new te;return t=n.getVariable$$module$build$src$core$variables(t.workspace,e),t?(t=t.getType(),this.typeIsAllowed(t)?e:(console.warn("Variable type doesn't match this field! Type was "+t),null)):(console.warn("Variable id doesn't point to a real variable! ID was "+e),null)}doValueUpdate_(e){const t=this.getSourceBlock();if(!t)throw new te;this.variable=n.getVariable$$module$build$src$core$variables(t.workspace,e),super.doValueUpdate_(e)}typeIsAllowed(e){const t=this.getVariableTypes();if(!t)return!0;for(let o=0;o<t.length;o++)if(e===t[o])return!0;return!1}getVariableTypes(){if(this.variableTypes)return this.variableTypes;if(!this.sourceBlock_||this.sourceBlock_.isDeadOrDying())return[""];let e=this.sourceBlock_.workspace.getVariableMap().getTypes();if(this.sourceBlock_.isInFlyout){const t=this.sourceBlock_.workspace.getPotentialVariableMap();if(!t)return e;e=Array.from(new Set([...e,...t.getTypes()]))}return e}setTypes(e=null,t=""){var o=this.getText();if(Array.isArray(e)){if(e.length===0)throw Error(`'variableTypes' of field variable ${o} was an empty list. If you want to include all variable types, pass 'null' instead.`);o=!1;for(let s=0;s<e.length;s++)e[s]===t&&(o=!0);if(!o)throw Error("Invalid default type '"+t+"' in the definition of a FieldVariable")}else if(e!==null)throw Error(`'variableTypes' was not an array or null in the definition of FieldVariable ${o}`);this.defaultType=t,this.variableTypes=e}refreshVariableName(){this.forceRerender()}onItemSelected_(e,t){if(e=t.getValue(),this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(e===Uu&&this.variable){n.renameVariable$$module$build$src$core$variables(this.sourceBlock_.workspace,this.variable);return}if(e===zu&&this.variable){e=this.variable.getWorkspace(),n.deleteVariable$$module$build$src$core$variables(e,this.variable,this.sourceBlock_);return}}this.setValue(e)}referencesVariables(){return!0}static fromJson(e){return new this(J(e.variable),void 0,void 0,void 0,e)}static dropdownCreate(){if(!this.variable)throw Error("Tried to call dropdownCreate on a variable field with no variable selected.");const e=this.getText();let t=[];var o=this.getSourceBlock();if(o&&!o.isDeadOrDying()){o=o.workspace;const r=this.getVariableTypes();for(let l=0;l<r.length;l++){const c=r[l],p=o.getVariableMap().getVariablesOfType(c);if(t=t.concat(p),o.isFlyout){var s=void 0,i=void 0;t=t.concat((i=(s=o.getPotentialVariableMap())==null?void 0:s.getVariablesOfType(c))!=null?i:[])}}}for(t.sort(Fo),s=[],i=0;i<t.length;i++)s[i]=[t[i].getName(),t[i].getId()];return s.push([n.Msg$$module$build$src$core$msg.RENAME_VARIABLE,Uu]),n.Msg$$module$build$src$core$msg.DELETE_VARIABLE&&s.push([n.Msg$$module$build$src$core$msg.DELETE_VARIABLE.replace("%1",e),zu]),s}};it("field_variable",wi);var Eh=class extends Es{constructor(e,t,o,s,i,r){super(L.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces=null,this.spellcheck_=!1,e!==L.SKIP_SETUP&&(r?this.configure_(r):this.setConstraints(t,o,s),this.setValue(e),i&&this.setValidator(i))}configure_(e){super.configure_(e),this.setMinInternal(e.min),this.setMaxInternal(e.max),this.setPrecisionInternal(e.precision)}setConstraints(e,t,o){this.setMinInternal(e),this.setMaxInternal(t),this.setPrecisionInternal(o),this.setValue(this.getValue())}setMin(e){this.setMinInternal(e),this.setValue(this.getValue())}setMinInternal(e){e==null?this.min_=-1/0:(e=Number(e),isNaN(e)||(this.min_=e))}getMin(){return this.min_}setMax(e){this.setMaxInternal(e),this.setValue(this.getValue())}setMaxInternal(e){e==null?this.max_=1/0:(e=Number(e),isNaN(e)||(this.max_=e))}getMax(){return this.max_}setPrecision(e){this.setPrecisionInternal(e),this.setValue(this.getValue())}setPrecisionInternal(e){this.precision_=Number(e)||0;let t=String(this.precision_);t.includes("e")&&(t=this.precision_.toLocaleString("en-US",{maximumFractionDigits:20}));const o=t.indexOf(".");this.decimalPlaces=o===-1?e?0:null:t.length-o-1}getPrecision(){return this.precision_}doClassValidation_(e){return e===null||(e=`${e}`.replace(/O/gi,"0"),e=e.replace(/,/g,""),e=e.replace(/infinity/i,"Infinity"),e=Number(e||0),isNaN(e))?null:(e=Math.min(Math.max(e,this.min_),this.max_),this.precision_&&isFinite(e)&&(e=Math.round(e/this.precision_)*this.precision_),this.decimalPlaces!==null&&(e=Number(e.toFixed(this.decimalPlaces))),e)}widgetCreate_(){const e=super.widgetCreate_();return this.min_>-1/0&&(e.min=`${this.min_}`,oe(e,Q.VALUEMIN,this.min_)),this.max_<1/0&&(e.max=`${this.max_}`,oe(e,Q.VALUEMAX,this.max_)),e}initView(){super.initView(),this.fieldGroup_&&b(this.fieldGroup_,"blocklyNumberField")}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};it("field_number",Eh),Eh.prototype.DEFAULT_VALUE=0;var Hg=class extends Co{constructor(e,t,o){super(String(e??""),t,o),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(J(e.text),void 0,e)}};it("field_label_serializable",Hg);var So=class extends L{constructor(e,t,o){super(L.SKIP_SETUP),this.SERIALIZABLE=!0,this.value_=this.value_,this.checkChar=So.CHECK_CHAR,e!==L.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.checkCharacter&&(this.checkChar=e.checkCharacter)}saveState(){const e=this.saveLegacyState(So);return e!==null?e:this.getValueBoolean()}initView(){super.initView();const e=this.getTextElement();b(this.fieldGroup_,"blocklyCheckboxField"),e.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(e){this.checkChar=e||So.CHECK_CHAR,this.forceRerender()}showEditor_(){this.setValue(!this.value_)}doClassValidation_(e){return e===!0||e==="TRUE"?"TRUE":e===!1||e==="FALSE"?"FALSE":null}doValueUpdate_(e){this.value_=this.convertValueToBool(e),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(e){return typeof e=="string"?e==="TRUE":!!e}static fromJson(e){return new this(e.checked,void 0,e)}};So.CHECK_CHAR="✓",it("field_checkbox",So),So.prototype.DEFAULT_VALUE=!1;var Gg=class{constructor(e,t){this.draggable=e,this.workspace=t,this.dragTarget=null,this.startLoc=e.getRelativeToSurfaceXY()}onDragStart(e){n.getGroup$$module$build$src$core$events$utils()||n.setGroup$$module$build$src$core$events$utils(!0),this.draggable.startDrag(e)}onDrag(e,t){this.moveDraggable(e,t),t=this.getRoot(this.draggable),Pe(t)&&t.setDeleteStyle(this.wouldDeleteDraggable(e,t)),this.updateDragTarget(e)}updateDragTarget(e){e=this.workspace.getDragTarget(e);const t=this.getRoot(this.draggable);if(this.dragTarget!==e){let o;(o=this.dragTarget)==null||o.onDragExit(t),e?.onDragEnter(t)}e?.onDragOver(t),this.dragTarget=e}moveDraggable(e,t){t=this.pixelsToWorkspaceUnits(t),t=f.sum(this.startLoc,t),this.draggable.drag(t,e)}wouldDeleteDraggable(e,t){return(e=this.workspace.getDragTarget(e))&&this.workspace.getComponentManager().hasCapability(e.id,U.Capability.DELETE_AREA)?e.wouldDelete(t):!1}onDragEnd(e){const t=n.getGroup$$module$build$src$core$events$utils();var o=this.workspace.getDragTarget(e);const s=this.getRoot(this.draggable);if(o){let i;(i=this.dragTarget)==null||i.onDrop(s)}this.shouldReturnToStart(e,s)&&this.draggable.revertDrag(),(o=Pe(s)&&this.wouldDeleteDraggable(e,s))&&this.draggable instanceof H&&Er(this.draggable.getRootBlock()),this.draggable.endDrag(e),o&&Pe(s)&&(n.setGroup$$module$build$src$core$events$utils(t),s.dispose()),n.setGroup$$module$build$src$core$events$utils(!1),!o&&Oo(this.draggable)&&n.getFocusManager$$module$build$src$core$focus_manager().focusNode(this.draggable)}getRoot(e){return e instanceof H?e.getRootBlock():e}shouldReturnToStart(e,t){return(e=this.workspace.getDragTarget(e))?e.shouldPreventMove(t):!1}pixelsToWorkspaceUnits(e){return e=new f(e.x/this.workspace.scale,e.y/this.workspace.scale),this.workspace.isMutator&&e.scale(1/this.workspace.options.parentWorkspace.scale),e}};I(g.BLOCK_DRAGGER,Ce,Gg);var ki={};ki.BlockDragStrategy=Xp,ki.BubbleDragStrategy=Hp,ki.CommentDragStrategy=Ap,ki.Dragger=Gg;var Th=class extends lt{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=a.BLOCK_DRAG,e&&(this.blockId=e.id,this.isStart=t,this.blocks=o)}toJson(){const e=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.blockId===void 0)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");return e.isStart=this.isStart,e.blockId=this.blockId,e.blocks=this.blocks,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Th),t.isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};I(g.EVENT,a.BLOCK_DRAG,Th);var yh=class extends fo{constructor(e,t,o,s){super(e),this.type=a.BLOCK_FIELD_INTERMEDIATE_CHANGE,this.recordUndo=!1,e&&(this.name=t,this.oldValue=o,this.newValue=s)}toJson(){const e=super.toJson();if(!this.name)throw Error("The changed field name is undefined. Either pass a name to the constructor, or call fromJson.");return e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new yh),t.name=e.name,t.oldValue=e.oldValue,t.newValue=e.newValue,t}isNull(){return this.oldValue===this.newValue}run(e){var t=this.getEventWorkspace_();if(!this.blockId)throw Error("The block ID is undefined. Either pass a block to the constructor, or call fromJson");if(t=t.getBlockById(this.blockId),!t)throw Error("The associated block is undefined. Either pass a block to the constructor, or call fromJson");e=e?this.newValue:this.oldValue,(t=t.getField(this.name))?t.setValue(e):console.warn("Can't set non-existent field: "+this.name)}};I(g.EVENT,a.BLOCK_FIELD_INTERMEDIATE_CHANGE,yh);var vh=class extends fo{constructor(e){super(e),this.type=a.BLOCK_MOVE,e&&(e.isShadow()&&(this.recordUndo=!1),e=this.currentLocation(),this.oldParentId=e.parentId,this.oldInputName=e.inputName,this.oldCoordinate=e.coordinate)}toJson(){const e=super.toJson();return e.oldParentId=this.oldParentId,e.oldInputName=this.oldInputName,this.oldCoordinate&&(e.oldCoordinate=`${Math.round(this.oldCoordinate.x)}, ${Math.round(this.oldCoordinate.y)}`),e.newParentId=this.newParentId,e.newInputName=this.newInputName,this.newCoordinate&&(e.newCoordinate=`${Math.round(this.newCoordinate.x)}, ${Math.round(this.newCoordinate.y)}`),this.reason&&(e.reason=this.reason),this.recordUndo||(e.recordUndo=this.recordUndo),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new vh),t.oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(o=e.oldCoordinate.split(","),t.oldCoordinate=new f(Number(o[0]),Number(o[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(o=e.newCoordinate.split(","),t.newCoordinate=new f(Number(o[0]),Number(o[1]))),e.reason!==void 0&&(t.reason=e.reason),e.recordUndo!==void 0&&(t.recordUndo=e.recordUndo),t}recordNew(){const e=this.currentLocation();this.newParentId=e.parentId,this.newInputName=e.inputName,this.newCoordinate=e.coordinate}setReason(e){this.reason=e}currentLocation(){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 t=e.getBlockById(this.blockId);if(!t)throw Error("The block associated with the block move event could not be found");e={};const o=t.getParent();return o?(e.parentId=o.id,(t=o.getInputWithBlock(t))&&(e.inputName=t.name)):e.coordinate=t.getRelativeToSurfaceXY(),e}isNull(){return this.oldParentId===this.newParentId&&this.oldInputName===this.newInputName&&f.equals(this.oldCoordinate,this.newCoordinate)}run(e){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 o=t.getBlockById(this.blockId);if(o){var s=e?this.newParentId:this.oldParentId,i=e?this.newInputName:this.oldInputName;if(e=e?this.newCoordinate:this.oldCoordinate,s){var r=t.getBlockById(s);if(!r){console.warn("Can't connect to non-existent block: "+s);return}}if(o.getParent()&&o.unplug(),e)i=o.getRelativeToSurfaceXY(),o.moveBy(e.x-i.x,e.y-i.y,this.reason);else{t=o.outputConnection,(!t||o.previousConnection&&o.previousConnection.isConnected())&&(t=o.previousConnection);let l,c;o=(c=t)==null?void 0:c.type,i?(o=r.getInput(i))&&(l=o.connection):o===E.PREVIOUS_STATEMENT&&(l=r.nextConnection),l&&t?t.connect(l):console.warn("Can't connect to non-existent input: "+i)}}else console.warn("Can't move non-existent block: "+this.blockId)}};I(g.EVENT,a.BLOCK_MOVE,vh);var Ch=class extends lt{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=a.BUBBLE_OPEN,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=o)}toJson(){const e=super.toJson();if(this.isOpen===void 0)throw Error("Whether this event is for opening the bubble is undefined. Either pass the value to the constructor, or call fromJson");if(!this.bubbleType)throw Error("The type of bubble is undefined. Either pass the value to the constructor, or call fromJson");return e.isOpen=this.isOpen,e.bubbleType=this.bubbleType,e.blockId=this.blockId||"",e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ch),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},wh;(function(e){e.MUTATOR="mutator",e.COMMENT="comment",e.WARNING="warning"})(wh||(wh={})),I(g.EVENT,a.BUBBLE_OPEN,Ch);var gt=class extends es{constructor(e){super(),this.isBlank=!e,e&&(this.commentId=e.id,this.workspaceId=e.workspace.id,this.group=n.getGroup$$module$build$src$core$events$utils(),this.recordUndo=we())}toJson(){const e=super.toJson();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.commentId=this.commentId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new gt),t.commentId=e.commentId,t}static CommentCreateDeleteHelper(e,t){const o=e.getEventWorkspace_();if(t){if(!e.json)throw Error("Encountered a comment event without proper json");Ms(e.json,o)}else{if(!e.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=o.getCommentById(e.commentId))?t.dispose():console.warn("Can't delete non-existent comment: "+e.commentId)}}},kh=class extends gt{constructor(e,t,o){super(e),this.type=a.COMMENT_CHANGE,e&&(this.oldContents_=typeof t>"u"?"":t,this.newContents_=typeof o>"u"?"":o)}toJson(){const e=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 e.oldContents=this.oldContents_,e.newContents=this.newContents_,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new kh),t.oldContents_=e.oldContents,t.newContents_=e.newContents,t}isNull(){return this.oldContents_===this.newContents_}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){var o=e?this.newContents_:this.oldContents_;if(o===void 0)throw Error(e?"The new contents is undefined. Either pass a value to the constructor, or call fromJson":"The old contents is undefined. Either pass a value to the constructor, or call fromJson");t.setText(o)}else console.warn("Can't change non-existent comment: "+this.commentId)}};I(g.EVENT,a.COMMENT_CHANGE,kh);var Ih=class extends gt{constructor(e,t){super(e),this.newCollapsed=t,this.type=a.COMMENT_COLLAPSE}toJson(){const e=super.toJson();if(this.newCollapsed===void 0)throw Error("The new collapse value undefined. Either call recordNew, or call fromJson");return e.newCollapsed=this.newCollapsed,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ih),t.newCollapsed=e.newCollapsed,t}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(t=t.getCommentById(this.commentId))?t.setCollapsed(e?!!this.newCollapsed:!this.newCollapsed):console.warn("Can't collapse or uncollapse non-existent comment: "+this.commentId)}};I(g.EVENT,a.COMMENT_COLLAPSE,Ih);var Sh=class extends gt{constructor(e){super(e),this.type=a.COMMENT_CREATE,e&&(this.xml=Xs(e),this.json=Bo(e,{addCoordinates:!0}))}toJson(){const e=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=st(this.xml),e.json=this.json,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Sh),t.xml=n.textToDom$$module$build$src$core$utils$xml(e.xml),t.json=e.json,t}run(e){gt.CommentCreateDeleteHelper(this,e)}};I(g.EVENT,a.COMMENT_CREATE,Sh);var Rh=class extends gt{constructor(e){super(e),this.type=a.COMMENT_DELETE,e&&(this.xml=Xs(e),this.json=Bo(e,{addCoordinates:!0}))}run(e){gt.CommentCreateDeleteHelper(this,!e)}toJson(){const e=super.toJson();if(!this.xml)throw Error("The comment XML is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.json)throw Error("The comment JSON is undefined. Either pass a block to the constructor, or call fromJson");return e.xml=st(this.xml),e.json=this.json,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Rh),t.xml=n.textToDom$$module$build$src$core$utils$xml(e.xml),t.json=e.json,t}};I(g.EVENT,a.COMMENT_DELETE,Rh);var Dh=class extends lt{constructor(e,t){super(e?e.workspace.id:void 0),this.type=a.COMMENT_DRAG,e&&(this.commentId=e.id,this.isStart=t)}toJson(){const e=super.toJson();if(this.isStart===void 0)throw Error("Whether this event is the start of a drag is undefined. Either pass the value to the constructor, or call fromJson");if(this.commentId===void 0)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");return e.isStart=this.isStart,e.commentId=this.commentId,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Dh),t.isStart=e.isStart,t.commentId=e.commentId,t}};I(g.EVENT,a.COMMENT_DRAG,Dh);var Nh=class extends gt{constructor(e){super(e),this.type=a.COMMENT_MOVE,e&&(this.comment_=e,this.oldCoordinate_=e.getRelativeToSurfaceXY())}recordNew(){if(this.newCoordinate_)throw Error("Tried to record the new position of a comment on the same event twice.");if(!this.comment_)throw Error("The comment is undefined. Pass a comment to the constructor if you want to use the record functionality");this.newCoordinate_=this.comment_.getRelativeToSurfaceXY()}setReason(e){this.reason=e}setOldCoordinate(e){this.oldCoordinate_=e}toJson(){const e=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 e.oldCoordinate=`${Math.round(this.oldCoordinate_.x)}, ${Math.round(this.oldCoordinate_.y)}`,e.newCoordinate=Math.round(this.newCoordinate_.x)+","+Math.round(this.newCoordinate_.y),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Nh),o=e.oldCoordinate.split(","),t.oldCoordinate_=new f(Number(o[0]),Number(o[1])),o=e.newCoordinate.split(","),t.newCoordinate_=new f(Number(o[0]),Number(o[1])),t}isNull(){return f.equals(this.oldCoordinate_,this.newCoordinate_)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(e=e?this.newCoordinate_:this.oldCoordinate_,!e)throw Error("Either oldCoordinate_ or newCoordinate_ is undefined. Either pass a comment to the constructor and call recordNew, or call fromJson");t.moveTo(e)}else console.warn("Can't move non-existent comment: "+this.commentId)}};I(g.EVENT,a.COMMENT_MOVE,Nh);var Ah=class extends gt{constructor(e){super(e),this.type=a.COMMENT_RESIZE,e&&(this.oldSize=e.getSize())}recordCurrentSizeAsNewSize(){if(this.newSize)throw Error("Tried to record the new size of a comment on the same event twice.");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),!e)throw Error("The comment associated with the comment resize event could not be found");this.newSize=e.getSize()}toJson(){const e=super.toJson();if(!this.oldSize)throw Error("The old comment size is undefined. Either pass a comment to the constructor, or call fromJson");if(!this.newSize)throw Error("The new comment size is undefined. Either call recordCurrentSizeAsNewSize, or call fromJson");return e.oldWidth=Math.round(this.oldSize.width),e.oldHeight=Math.round(this.oldSize.height),e.newWidth=Math.round(this.newSize.width),e.newHeight=Math.round(this.newSize.height),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ah),t.oldSize=new N(e.oldWidth,e.oldHeight),t.newSize=new N(e.newWidth,e.newHeight),t}isNull(){return N.equals(this.oldSize,this.newSize)}run(e){var t=this.getEventWorkspace_();if(!this.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");if(t=t.getCommentById(this.commentId)){if(e=e?this.newSize:this.oldSize,!e)throw Error("Either oldSize or newSize is undefined. Either pass a comment to the constructor and call recordCurrentSizeAsNewSize, or call fromJson");t.setSize(e)}else console.warn("Can't resize non-existent comment: "+this.commentId)}};I(g.EVENT,a.COMMENT_RESIZE,Ah);var Oh=class extends lt{constructor(e,t,o){super(o),this.type=a.TOOLBOX_ITEM_SELECT,this.oldItem=e??void 0,this.newItem=t??void 0}toJson(){const e=super.toJson();return e.oldItem=this.oldItem,e.newItem=this.newItem,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Oh),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};I(g.EVENT,a.TOOLBOX_ITEM_SELECT,Oh);var xh=class extends fs{constructor(e,t,o){super(e),this.oldType=t,this.newType=o,this.type=a.VAR_TYPE_CHANGE}toJson(){const e=super.toJson();if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");return e.oldType=this.oldType,e.newType=this.newType,e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new xh),t.oldType=e.oldType,t.newType=e.newType,t}run(e){const t=this.getEventWorkspace_();if(!this.varId)throw Error("The var ID is undefined. Either pass a variable to the constructor, or call fromJson");if(!this.oldType||!this.newType)throw Error("The variable's types are undefined. Either pass them to the constructor, or call fromJson");const o=t.getVariableMap().getVariableById(this.varId);o&&(e?t.getVariableMap().changeVariableType(o,this.newType):t.getVariableMap().changeVariableType(o,this.oldType))}};I(g.EVENT,a.VAR_TYPE_CHANGE,xh);var Vg=class extends es{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=a.FINISHED_LOADING,this.isBlank=!!e,e&&(this.workspaceId=e.id)}};I(g.EVENT,a.FINISHED_LOADING,Vg);var Wg,Ug,zg,Xg,Yg,Kg,jg,Jg,Zg,qg,Qg,em,tm,om,sm,im,rm,nm,lm,cm,um,hm,am,dm,_;n.BLOCK_CHANGE$$module$build$src$core$events$events=a.BLOCK_CHANGE,n.BLOCK_CREATE$$module$build$src$core$events$events=a.BLOCK_CREATE,n.BLOCK_DELETE$$module$build$src$core$events$events=a.BLOCK_DELETE,Wg=a.BLOCK_DRAG,n.BLOCK_MOVE$$module$build$src$core$events$events=a.BLOCK_MOVE,Ug=a.BLOCK_FIELD_INTERMEDIATE_CHANGE,zg=a.BUBBLE_OPEN,Xg=a.BLOCK_CHANGE,Yg=a.CLICK,Kg=a.COMMENT_CHANGE,jg=a.COMMENT_CREATE,Jg=a.COMMENT_DELETE,Zg=a.COMMENT_MOVE,qg=a.COMMENT_RESIZE,Qg=a.COMMENT_DRAG,em=a.BLOCK_CREATE,tm=a.BLOCK_DELETE,om=a.FINISHED_LOADING,sm=a.BLOCK_MOVE,im=a.SELECTED,rm=a.THEME_CHANGE,nm=a.TOOLBOX_ITEM_SELECT,lm=a.TRASHCAN_OPEN,cm=a.UI,um=a.VAR_CREATE,hm=a.VAR_DELETE,am=a.VAR_RENAME,dm=a.VIEWPORT_CHANGE,_={},_.Abstract=es,_.BLOCK_CHANGE=n.BLOCK_CHANGE$$module$build$src$core$events$events,_.BLOCK_CREATE=n.BLOCK_CREATE$$module$build$src$core$events$events,_.BLOCK_DELETE=n.BLOCK_DELETE$$module$build$src$core$events$events,_.BLOCK_DRAG=Wg,_.BLOCK_FIELD_INTERMEDIATE_CHANGE=Ug,_.BLOCK_MOVE=n.BLOCK_MOVE$$module$build$src$core$events$events,_.BUBBLE_OPEN=zg,_.BUMP_EVENTS=N$,_.BlockBase=fo,_.BlockChange=bo,_.BlockCreate=Fu,_.BlockDelete=Wu,_.BlockDrag=Th,_.BlockFieldIntermediateChange=yh,_.BlockMove=vh,_.BubbleOpen=Ch,_.BubbleType=wh,_.CHANGE=Xg,_.CLICK=Yg,_.COMMENT_CHANGE=Kg,_.COMMENT_CREATE=jg,_.COMMENT_DELETE=Jg,_.COMMENT_DRAG=Qg,_.COMMENT_MOVE=Zg,_.COMMENT_RESIZE=qg,_.CREATE=em,_.Click=uu,_.ClickTarget=hu,_.CommentBase=gt,_.CommentChange=kh,_.CommentCollapse=Ih,_.CommentCreate=Sh,_.CommentDelete=Rh,_.CommentDrag=Dh,_.CommentMove=Nh,_.CommentResize=Ah,_.DELETE=tm,_.FINISHED_LOADING=om,_.FinishedLoading=Vg,_.MOVE=sm,_.SELECTED=im,_.Selected=Vu,_.THEME_CHANGE=rm,_.TOOLBOX_ITEM_SELECT=nm,_.TRASHCAN_OPEN=lm,_.ThemeChange=Hu,_.ToolboxItemSelect=Oh,_.TrashcanOpen=$h,_.UI=cm,_.UiBase=lt,_.VAR_CREATE=um,_.VAR_DELETE=hm,_.VAR_RENAME=am,_.VIEWPORT_CHANGE=dm,_.VarBase=fs,_.VarCreate=hh,_.VarDelete=ah,_.VarRename=dh,_.VarTypeChange=xh,_.ViewportChange=Gu,_.clearPendingUndo=Hn,_.disable=n.disable$$module$build$src$core$events$utils,_.disableOrphans=Xh,_.enable=n.enable$$module$build$src$core$events$utils,_.filter=Fn,_.fire=C,_.fromJson=zh,_.get=w,_.getDescendantIds=xi,_.getGroup=n.getGroup$$module$build$src$core$events$utils,_.getRecordUndo=we,_.isEnabled=z,_.setGroup=n.setGroup$$module$build$src$core$events$utils,_.setRecordUndo=n.setRecordUndo$$module$build$src$core$events$utils;var mt={};mt.BottomRow=Ng,mt.ConstantProvider=Rg,mt.Drawer=Dg,mt.PathObject=Lg,mt.RenderInfo=xg,mt.Renderer=bh,mt.RightConnectionShape=Ag,mt.StatementInput=Nn,mt.TopRow=Og,eu();var ne={};ne.registerCleanup=Pc,ne.registerCollapse=Hc,ne.registerCollapseExpandBlock=Yc,ne.registerComment=zc,ne.registerCommentCreate=Qc,ne.registerCommentDelete=Zc,ne.registerCommentDuplicate=qc,ne.registerCommentOptions=$$,ne.registerDefaultOptions=eu,ne.registerDelete=jc,ne.registerDeleteAll=Wc,ne.registerDisable=Kc,ne.registerDuplicate=Uc,ne.registerExpand=Gc,ne.registerHelp=Jc,ne.registerInline=Xc,ne.registerRedo=Bc,ne.registerUndo=Mc;var Lh="button",$m=class{load(e,t){return e=new ye(t.getWorkspace(),t.targetWorkspace,e,!1),e.show(),new ps(e,Lh)}gapForItem(e,t){return t}disposeItem(e){e=e.getElement(),e instanceof ye&&e.dispose()}getType(){return Lh}};I(g.FLYOUT_INFLATER,Lh,$m);var Ii={};Ii.Bubble=M,Ii.MiniWorkspaceBubble=St,Ii.TextBubble=Yp,Ii.TextInputBubble=Qu;var pf="WORKSPACE_AT_BLOCK_CAPACITY",Mh="block",pm=class{constructor(){this.permanentlyDisabledBlocks=new Set,this.listeners=new Map,this.capacityWrapper=this.filterFlyoutBasedOnCapacity.bind(this)}load(e,t){return this.setFlyout(t),e=this.createBlock(e,t.getWorkspace()),e.isEnabled()?this.updateStateBasedOnCapacity(e):this.permanentlyDisabledBlocks.add(e),e.getDescendants(!1).forEach(o=>o.isInFlyout=!0),this.addBlockListeners(e),new ps(e,Mh)}createBlock(e,t){return e.blockxml?(e=typeof e.blockxml=="string"?n.textToDom$$module$build$src$core$utils$xml(e.blockxml):e.blockxml,t=uo(e,t)):(e.enabled===void 0&&(e.enabled=e.disabled!=="true"&&e.disabled!==!0),e.disabledReasons===void 0&&e.enabled===!1&&(e.disabledReasons=[Fe]),"x"in e&&delete e.x,"y"in e&&delete e.y,t=Go(e,t)),t}gapForItem(e,t){let o;return e.gap?o=parseInt(String(e.gap)):e.blockxml&&(e=typeof e.blockxml=="string"?n.textToDom$$module$build$src$core$utils$xml(e.blockxml):e.blockxml,o=parseInt(e.getAttribute("gap"))),!o||isNaN(o)?t:o}disposeItem(e){e=e.getElement(),e instanceof H&&(this.removeListeners(e.id),e.dispose(!1,!1))}removeListeners(e){let t;((t=this.listeners.get(e))!=null?t:[]).forEach(o=>x(o)),this.listeners.delete(e)}setFlyout(e){if(this.flyout!==e){if(this.flyout){let o;(o=this.flyout.targetWorkspace)==null||o.removeChangeListener(this.capacityWrapper)}this.flyout=e;var t;(t=this.flyout.targetWorkspace)==null||t.addChangeListener(this.capacityWrapper)}}updateStateBasedOnCapacity(e){let t,o;const s=(t=this.flyout)==null||(o=t.targetWorkspace)==null?void 0:o.isCapacityAvailable(Ds(e));for(;e;)e.setDisabledReason(!s,pf),e=e.getNextBlock()}addBlockListeners(e){const t=[];t.push(k(e.getSvgRoot(),"pointerdown",e,o=>{let s,i;const r=(s=this.flyout)==null||(i=s.targetWorkspace)==null?void 0:i.getGesture(o);r&&this.flyout&&(r.setStartBlock(e),r.handleFlyoutStart(o,this.flyout))})),t.push(xe(e.getSvgRoot(),"pointermove",null,()=>{let o,s;!((o=this.flyout)==null||(s=o.targetWorkspace)==null)&&s.isDragging()||e.addSelect()})),t.push(xe(e.getSvgRoot(),"pointerleave",null,()=>{let o,s;!((o=this.flyout)==null||(s=o.targetWorkspace)==null)&&s.isDragging()||e.removeSelect()})),this.listeners.set(e.id,t)}filterFlyoutBasedOnCapacity(e){!this.flyout||e&&e.type!==a.BLOCK_CREATE&&e.type!==a.BLOCK_DELETE||this.flyout.getWorkspace().getTopBlocks(!1).forEach(t=>{this.permanentlyDisabledBlocks.has(t)||this.updateStateBasedOnCapacity(t)})}getType(){return Mh}};I(g.FLYOUT_INFLATER,Mh,pm);var gm=class extends vn{constructor(){super(),this.FIELD_TEXT_BASELINE_CENTER=!1,this.DARK_PATH_OFFSET=1,this.MAX_BOTTOM_WIDTH=30,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT/2}getCSS_(e){return super.getCSS_(e).concat([`${e} .blocklyInsertionMarker>.blocklyPathLight,`,`${e} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},mm=class{constructor(e){this.inlineSteps_=this.steps_="",this.info_=e,this.RTL_=this.info_.RTL,e=e.getRenderer(),this.constants_=e.getConstants(),this.highlightConstants_=e.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_+`
|
|
668
|
+
`+this.inlineSteps_}drawTopCorner(e){this.steps_+=K(e.xPos,this.info_.startY);for(let t=0,o;o=e.elements[t];t++)u.isLeftSquareCorner(o)?this.steps_+=this.highlightConstants_.START_POINT:u.isLeftRoundedCorner(o)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):u.isPreviousConnection(o)?this.steps_+=this.notchPaths_.pathLeft:u.isHat(o)?this.steps_+=this.startPaths_.path(this.RTL_):u.isSpacer(o)&&o.width!==0&&(this.steps_+=v("H",o.xPos+o.width-this.highlightOffset));this.steps_+=v("H",e.xPos+e.width-this.highlightOffset)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+v("v",e.height-this.jaggedTeethPaths_.height-this.highlightOffset))}drawValueInput(e){const t=e.getLastInput();if(this.RTL_){const o=e.height-t.connectionHeight;this.steps_+=ce(t.xPos+t.width-this.highlightOffset,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+v("v",o)}else this.steps_+=ce(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){const t=e.getLastInput();if(t)if(this.RTL_){const o=e.height-2*this.insideCornerPaths_.height;this.steps_+=ce(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+v("v",o)+this.insideCornerPaths_.pathBottom(this.RTL_)+rt(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=ce(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+rt(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){const t=e.xPos+e.width-this.highlightOffset;e instanceof lh&&e.followsStatement&&(this.steps_+=v("H",t)),this.RTL_&&(this.steps_+=v("H",t),e.height>this.highlightOffset&&(this.steps_+=v("V",e.yPos+e.height-this.highlightOffset)))}drawBottomRow(e){if(this.RTL_)this.steps_+=v("V",e.baseline-this.highlightOffset);else{const t=this.info_.bottomRow.elements[0];u.isLeftSquareCorner(t)?this.steps_+=ce(e.xPos+this.highlightOffset,e.baseline-this.highlightOffset):u.isLeftRoundedCorner(t)&&(this.steps_+=ce(e.xPos,e.baseline),this.steps_+=this.outsideCornerPaths_.bottomLeft())}}drawLeft(){var e=this.info_.outputConnection;e&&(e=e.connectionOffsetY+e.height,this.RTL_?this.steps_+=ce(this.info_.startX,e):(this.steps_+=ce(this.info_.startX+this.highlightOffset,this.info_.bottomRow.baseline-this.highlightOffset),this.steps_+=v("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,u.isLeftRoundedCorner(e.elements[0])?this.steps_+=v("V",this.outsideCornerPaths_.height):this.steps_+=v("V",e.capline+this.highlightOffset))}drawInlineInput(e){const t=this.highlightOffset,o=e.xPos+e.connectionWidth;var s=e.centerline-e.height/2;const i=e.width-e.connectionWidth,r=s+t;this.RTL_?(s=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=ce(o-t,r)+v("v",s)+this.puzzleTabPaths_.pathDown(this.RTL_)+v("v",e)+v("h",i)):this.inlineSteps_+=ce(e.xPos+e.width+t,r)+v("v",e.height)+v("h",-i)+ce(o,s+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},fm=class extends Cn{constructor(e,t){super(e,t),this.highlighter_=new mm(t)}draw(){this.drawOutline_(),this.drawInternals_(),this.updateConnectionHighlights();const e=this.block_.pathObject;e.setPath(this.outlinePath_+`
|
|
669
|
+
`+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),this.recordSizeOnBlock_()}drawTop_(){this.highlighter_.drawTopCorner(this.info_.topRow),this.highlighter_.drawRightSideRow(this.info_.topRow),super.drawTop_()}drawJaggedEdge_(e){this.highlighter_.drawJaggedEdge_(e),super.drawJaggedEdge_(e)}drawValueInput_(e){this.highlighter_.drawValueInput(e),super.drawValueInput_(e)}drawStatementInput_(e){this.highlighter_.drawStatementInput(e),super.drawStatementInput_(e)}drawRightSideRow_(e){this.highlighter_.drawRightSideRow(e),this.outlinePath_+=v("H",e.xPos+e.width)+v("V",e.yPos+e.height)}drawBottom_(){this.highlighter_.drawBottomRow(this.info_.bottomRow),super.drawBottom_()}drawLeft_(){this.highlighter_.drawLeft(),super.drawLeft_()}drawInlineInput_(e){this.highlighter_.drawInlineInput(e),super.drawInlineInput_(e)}positionInlineInputConnection_(e){const t=e.centerline-e.height/2;if(e.connectionModel){let o=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(o*=-1),e.connectionModel.setOffsetInBlock(o,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let o=e.xPos+e.statementEdge+t.notchOffset;o=this.info_.RTL?o*-1:o+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(o,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let o=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(o*=-1),t.connectionModel.setOffsetInBlock(o,e.yPos)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,o=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-o:o)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},bm=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=K(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 e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e+t)-t,s=K(o,o)+Z("a","0 0,0",e,y(-o-t,e-o)),i=Z("a","0 0,0",e+t,y(e+t,e+t)),r=K(o,-o)+Z("a","0 0,0",e+t,y(e-o,o+t));return{width:e+t,height:e,pathTop(l){return l?s:""},pathBottom(l){return l?i:r}}}makeOutsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e-t)+t,s=K(o,o)+Z("a","0 0,1",e-t,y(e-o,-o+t)),i=K(t,e)+Z("a","0 0,1",e-t,y(e,-e+t)),r=-o,l=K(o,r)+Z("a","0 0,1",e-t,y(-o+t,-r-e));return{height:e,topLeft(c){return c?s:i},bottomLeft(){return l}}}makePuzzleTab(){const e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,o=K(-2,-t+2.5+.9)+rt(e*-.45,-2.1),s=v("v",2.5)+K(-e*.97,2.5)+ve("q",[y(-e*.05,10),y(e*.3,9.5)])+K(e*.67,-1.9)+v("v",2.5),i=v("v",-1.5)+K(e*-.92,-.5)+ve("q",[y(e*-.19,-5.5),y(0,-11)])+K(e*.92,1),r=K(-5,t-.7)+rt(e*.46,-2.1);return{width:e,height:t,pathUp(l){return l?o:i},pathDown(l){return l?s:r}}}makeNotch(){return{pathLeft:v("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:rt(5.1,2.6)+K(-10.2,6.8)+rt(5.1,2.6),height:12,width:10.2}}makeStartHat(){const e=this.constantProvider.START_HAT.height,t=K(25,-8.7)+ve("c",[y(29.7,-6.2),y(57.2,-.5),y(75,8.7)]),o=ve("c",[y(17.8,-9.2),y(45.3,-14.9),y(75,-8.7)])+ce(100.5,e+.5);return{path(s){return s?t:o}}}},_m=class extends rh{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.width+=this.constants_.DARK_PATH_OFFSET,this.height+=this.constants_.DARK_PATH_OFFSET)}},Em=class extends yn{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Tm=class extends yi{constructor(e,t){super(e,t),this.renderer_=e}getRenderer(){return this.renderer_}populateBottomRow_(){super.populateBottomRow_(),this.block_.inputList.length&&this.block_.inputList[this.block_.inputList.length-1]instanceof Ae||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e instanceof n.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new _m(this.constants_,e)),t.hasInlineInput=!0):e instanceof Ae?(t.elements.push(new Em(this.constants_,e)),t.hasStatement=!0):e instanceof n.ValueInput$$module$build$src$core$inputs$value_input?(t.elements.push(new sh(this.constants_,e)),t.hasExternalInput=!0):(e instanceof ht||e instanceof Dt)&&(t.minHeight=Math.max(t.minHeight,this.constants_.DUMMY_INPUT_MIN_HEIGHT),t.hasDummyInput=!0),this.isInline||t.align!==null||(t.align=e.align)}addElemSpacing_(){let e=!1;for(let o=0,s;s=this.rows[o];o++)s.hasExternalInput&&(e=!0);for(let o=0,s;s=this.rows[o];o++){var t=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new Oe(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let i=0;i<t.length-1;i++){s.elements.push(t[i]);const r=this.getInRowSpacing_(t[i],t[i+1]);s.elements.push(new Oe(this.constants_,r))}s.elements.push(t[t.length-1]),s.endsWithElemSpacer()&&(t=this.getInRowSpacing_(t[t.length-1],null),e&&s.hasDummyInput&&(t+=this.constants_.TAB_WIDTH),s.elements.push(new Oe(this.constants_,t)))}}}getInRowSpacing_(e,t){if(!e)return t&&u.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&u.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&u.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!u.isInput(e)&&(!t||u.isStatementInput(t)))return u.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:u.isIcon(e)?this.constants_.LARGE_PADDING*2+1:u.isHat(e)?this.constants_.NO_PADDING:u.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:u.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:u.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(u.isInput(e)&&!t){if(u.isExternalInput(e))return this.constants_.NO_PADDING;if(u.isInlineInput(e))return this.constants_.LARGE_PADDING;if(u.isStatementInput(e))return this.constants_.NO_PADDING}if(!u.isInput(e)&&t&&u.isInput(t)){if(u.isField(e)&&e.isEditable){if(u.isInlineInput(t)||u.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(u.isInlineInput(t)||u.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(u.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(u.isIcon(e)&&t&&!u.isInput(t))return this.constants_.LARGE_PADDING;if(u.isInlineInput(e)&&t&&u.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(u.isLeftSquareCorner(e)&&t){if(u.isHat(t))return this.constants_.NO_PADDING;if(u.isPreviousConnection(t))return t.notchOffset;if(u.isNextConnection(t))return t.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(u.isLeftRoundedCorner(e)&&t){if(u.isPreviousConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS;if(u.isNextConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return u.isField(e)&&t&&u.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&u.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return u.isTopRow(e)&&u.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:u.isTopRow(e)||u.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||!e.hasStatement&&t.hasDummyInput||e.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(u.isSpacer(t))return e.yPos+t.height/2;if(u.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,u.isNextConnection(t)?e+t.height/2:e-t.height/2;if(u.isTopRow(e))return u.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return u.isField(t)||u.isIcon(t)?(o+=t.height/2,(e.hasInlineInput||e.hasStatement)&&t.height+this.constants_.TALL_INPUT_FIELD_OFFSET_Y<=e.height&&(o+=this.constants_.TALL_INPUT_FIELD_OFFSET_Y)):o=u.isInlineInput(t)?o+t.height/2:o+e.height/2,o}alignRowElements_(){if(this.isInline){var e=0,t=new WeakMap,o=null;for(let s=this.rows.length-1,i;i=this.rows[s];s--)t.set(i,e),u.isInputRow(i)&&(i.hasStatement&&this.alignStatementRow_(i),o&&o.hasStatement&&i.width<o.width?t.set(i,o.width):e=i.hasStatement?i.width:Math.max(e,i.width),o=i);e=0;for(let s=0,i;i=this.rows[s];s++)i.hasStatement?e=this.getDesiredRowWidth_(i):u.isSpacer(i)?i.width=Math.max(e,t.get(i)):(o=i.width,e=Math.max(e,t.get(i))-o,e>0&&this.addAlignmentPadding_(i,e),e=i.width)}else super.alignRowElements_()}getDesiredRowWidth_(e){return this.isInline&&e.hasStatement?this.statementEdge+this.constants_.MAX_BOTTOM_WIDTH+this.startX:super.getDesiredRowWidth_(e)}finalize_(){let e=0,t=0;for(let s=0,i;i=this.rows[s];s++){i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var o=t-this.topRow.ascenderHeight;i===this.bottomRow&&o<this.constants_.MIN_BLOCK_HEIGHT&&(o=this.constants_.MIN_BLOCK_HEIGHT-o,this.bottomRow.height+=o,t+=o),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(o=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,o.getHeightWidth().width-this.constants_.DARK_PATH_OFFSET)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX+this.constants_.DARK_PATH_OFFSET,this.width+=this.constants_.DARK_PATH_OFFSET,this.height=t+this.constants_.DARK_PATH_OFFSET,this.startY=this.topRow.capline}},ym=class extends wn{constructor(e,t,o){super(e,t,o),this.constants=o,this.colourDark="#000000",this.svgPathDark=m(h.PATH,{class:"blocklyPathDark",transform:"translate(1,1)"}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=m(h.PATH,{class:"blocklyPathLight"},this.svgRoot)}setPath(e){this.svgPath.setAttribute("d",e),this.svgPathDark.setAttribute("d",e)}setHighlightPath(e){this.svgPathLight.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)"),this.svgPathLight.setAttribute("transform","scale(-1 1)"),this.svgPathDark.setAttribute("transform","translate(1,1) scale(-1 1)")}applyColour(e){if(this.svgPathLight.style.display="",this.svgPathDark.style.display="",!this.style.colourTertiary)throw Error("The renderer did not properly initialize the tertiary colour of the block style");this.svgPathLight.setAttribute("stroke",this.style.colourTertiary),this.svgPathDark.setAttribute("fill",this.colourDark),super.applyColour(e),this.svgPath.setAttribute("stroke","none")}setStyle(e){this.style=e,this.colourDark=lo("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(e){super.updateHighlighted(e),this.svgPathLight.style.display=e?"none":"inline"}updateShadow_(e){if(e){if(this.svgPathLight.style.display="none",!this.style.colourSecondary)throw Error("The renderer did not properly initialize the secondary colour of the block style block style");this.svgPathDark.setAttribute("fill",this.style.colourSecondary),this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary)}}updateDisabled_(e){super.updateDisabled_(e),e&&this.svgPath.setAttribute("stroke","none")}},vm=class extends kn{constructor(e){super(e),this.highlightConstants=null}init(e,t){super.init(e,t),this.highlightConstants=this.makeHighlightConstants_(),this.highlightConstants.init()}refreshDom(e,t,o){super.refreshDom(e,t,o),this.getHighlightConstants().init()}makeConstants_(){return new gm}makeRenderInfo_(e){return new Tm(this,e)}makeDrawer_(e,t){return new fm(e,t)}makePathObject(e,t){return new ym(e,t,this.getConstants())}makeHighlightConstants_(){return new bm(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants)throw Error("Cannot access the highlight constants because init has not been called");return this.highlightConstants}};js("geras",vm);var ft={};ft.ConstantProvider=gm,ft.Drawer=fm,ft.HighlightConstantProvider=bm,ft.Highlighter=mm,ft.InlineInput=_m,ft.PathObject=ym,ft.RenderInfo=Tm,ft.Renderer=vm,ft.StatementInput=Em;var Cm=class extends yi{constructor(e,t){super(e,t)}getRenderer(){return this.renderer_}addElemSpacing_(){let e=!1;for(var t=0;t<this.rows.length;t++)if(this.rows[t].hasExternalInput){e=!0;break}for(t=0;t<this.rows.length;t++){const s=this.rows[t];var o=s.elements;if(s.elements=[],s.startsWithElemSpacer()&&s.elements.push(new Oe(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let i=0;i<o.length-1;i++){s.elements.push(o[i]);const r=this.getInRowSpacing_(o[i],o[i+1]);s.elements.push(new Oe(this.constants_,r))}s.elements.push(o[o.length-1]),s.endsWithElemSpacer()&&(o=this.getInRowSpacing_(o[o.length-1],null),e&&s.hasDummyInput&&(o+=this.constants_.TAB_WIDTH),s.elements.push(new Oe(this.constants_,o)))}}}getInRowSpacing_(e,t){if(!e)return t&&u.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&u.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&u.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!u.isInput(e)&&!t)return u.isField(e)&&e.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:u.isIcon(e)?this.constants_.LARGE_PADDING*2+1:u.isHat(e)?this.constants_.NO_PADDING:u.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:u.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:u.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(u.isInput(e)&&!t){if(u.isExternalInput(e))return this.constants_.NO_PADDING;if(u.isInlineInput(e))return this.constants_.LARGE_PADDING;if(u.isStatementInput(e))return this.constants_.NO_PADDING}if(!u.isInput(e)&&t&&u.isInput(t)){if(u.isField(e)&&e.isEditable){if(u.isInlineInput(t)||u.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(u.isInlineInput(t)||u.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(u.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(u.isIcon(e)&&t&&!u.isInput(t))return this.constants_.LARGE_PADDING;if(u.isInlineInput(e)&&t&&u.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(u.isLeftSquareCorner(e)&&t){if(u.isHat(t))return this.constants_.NO_PADDING;if(u.isPreviousConnection(t)||u.isNextConnection(t))return t.notchOffset}return u.isLeftRoundedCorner(e)&&t?t.notchOffset-this.constants_.CORNER_RADIUS:u.isField(e)&&t&&u.isField(t)&&e.isEditable===t.isEditable?e.width===0?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING:t&&u.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return u.isTopRow(e)&&u.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:u.isTopRow(e)||u.isBottomRow(t)?this.constants_.NO_PADDING:e.hasExternalInput&&t.hasExternalInput?this.constants_.LARGE_PADDING:!e.hasStatement&&t.hasStatement?this.constants_.BETWEEN_STATEMENT_PADDING_Y:e.hasStatement&&t.hasStatement||e.hasDummyInput||t.hasDummyInput?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getElemCenterline_(e,t){if(u.isSpacer(t))return e.yPos+t.height/2;if(u.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,u.isNextConnection(t)?e+t.height/2:e-t.height/2;if(u.isTopRow(e))return u.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return o=u.isField(t)&&e.hasStatement?o+(this.constants_.TALL_INPUT_FIELD_OFFSET_Y+t.height/2):o+e.height/2}finalize_(){let e=0,t=0;for(var o=0;o<this.rows.length;o++){const i=this.rows[o];i.yPos=t,i.xPos=this.startX,t+=i.height,e=Math.max(e,i.widthWithConnectedBlocks);var s=t-this.topRow.ascenderHeight;i===this.bottomRow&&s<this.constants_.MIN_BLOCK_HEIGHT&&(s=this.constants_.MIN_BLOCK_HEIGHT-s,this.bottomRow.height+=s,t+=s),this.recordElemPositions_(i)}this.outputConnection&&this.block_.nextConnection&&this.block_.nextConnection.isConnected()&&(o=this.block_.nextConnection.targetBlock())&&(e=Math.max(e,o.getHeightWidth().width)),this.bottomRow.baseline=t-this.bottomRow.descenderHeight,this.widthWithChildren=e+this.startX,this.height=t,this.startY=this.topRow.capline}},wm=class extends kn{constructor(e){super(e)}makeRenderInfo_(e){return new Cm(this,e)}};js("thrasos",wm);var Bh={};Bh.RenderInfo=Cm,Bh.Renderer=wm;var gf={colour_blocks:{colourPrimary:"#CF63CF",colourSecondary:"#C94FC9",colourTertiary:"#BD42BD"},list_blocks:{colourPrimary:"#9966FF",colourSecondary:"#855CD6",colourTertiary:"#774DCB"},logic_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC"},loop_blocks:{colourPrimary:"#0fBD8C",colourSecondary:"#0DA57A",colourTertiary:"#0B8E69"},math_blocks:{colourPrimary:"#59C059",colourSecondary:"#46B946",colourTertiary:"#389438"},procedure_blocks:{colourPrimary:"#FF6680",colourSecondary:"#FF4D6A",colourTertiary:"#FF3355"},text_blocks:{colourPrimary:"#FFBF00",colourSecondary:"#E6AC00",colourTertiary:"#CC9900"},variable_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},variable_dynamic_blocks:{colourPrimary:"#FF8C1A",colourSecondary:"#FF8000",colourTertiary:"#DB6E00"},hat_blocks:{colourPrimary:"#4C97FF",colourSecondary:"#4280D7",colourTertiary:"#3373CC",hat:"cap"}},mf={colour_category:{colour:"#CF63CF"},list_category:{colour:"#9966FF"},logic_category:{colour:"#4C97FF"},loop_category:{colour:"#0fBD8C"},math_category:{colour:"#59C059"},procedure_category:{colour:"#FF6680"},text_category:{colour:"#FFBF00"},variable_category:{colour:"#FF8C1A"},variable_dynamic_category:{colour:"#FF8C1A"}},ff=new vo("zelos",gf,mf),bf={Classic:hn,Zelos:ff},Ph=class{constructor(e,t,o){this.id_=e.toolboxitemid||Le(),this.level_=(this.parent_=o||null)?this.parent_.getLevel()+1:0,this.toolboxItemDef_=e,this.parentToolbox_=t,this.workspace_=this.parentToolbox_.getWorkspace()}init(){}getDiv(){return null}getClickTarget(){return null}getId(){return this.id_}getParent(){return null}getLevel(){return this.level_}isSelectable(){return!1}isCollapsible(){return!1}dispose(){}setVisible_(e){}getFocusableElement(){const e=this.getDiv();if(!e)throw Error("Trying to access toolbox item before DOM is initialized.");if(!(e instanceof HTMLElement))throw Error("Toolbox item div is unexpectedly not an HTML element.");return e}getFocusableTree(){return this.parentToolbox_}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}},je=class extends Ph{constructor(e,t,o){super(e,t,o),this.colour_=this.name_="",this.labelDom_=this.iconDom_=this.rowContents_=this.rowDiv_=this.htmlDiv_=null,this.isDisabled_=this.isHidden_=!1,this.flyoutItems_=[],this.cssConfig_=this.makeDefaultCssConfig_()}init(){this.parseCategoryDef_(this.toolboxItemDef_),this.parseContents_(this.toolboxItemDef_),this.createDom_(),this.toolboxItemDef_.hidden==="true"&&this.hide()}makeDefaultCssConfig_(){return{container:"blocklyToolboxCategoryContainer",row:"blocklyToolboxCategory",rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyToolboxCategoryIcon",label:"blocklyToolboxCategoryLabel",contents:"blocklyToolboxCategoryGroup",selected:"blocklyToolboxSelected",openicon:"blocklyToolboxCategoryIconOpen",closedicon:"blocklyToolboxCategoryIconClosed"}}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else if(e=e.contents)for(let t=0;t<e.length;t++){const o=e[t];Array.isArray(this.flyoutItems_)&&this.flyoutItems_.push(o)}}parseCategoryDef_(e){this.name_="name"in e?J(e.name):"",this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),et(this.htmlDiv_,Se.TREEITEM),oe(this.htmlDiv_,Q.SELECTED,!1),oe(this.htmlDiv_,Q.LEVEL,this.level_+1),this.rowDiv_=this.createRowContainer_(),this.rowDiv_.style.pointerEvents="auto",this.htmlDiv_.appendChild(this.rowDiv_),this.rowContents_=this.createRowContentsContainer_(),this.rowContents_.style.pointerEvents="none",this.rowDiv_.appendChild(this.rowContents_),this.iconDom_=this.createIconDom_(),et(this.iconDom_,Se.PRESENTATION),this.rowContents_.appendChild(this.iconDom_),this.labelDom_=this.createLabelDom_(this.name_),this.rowContents_.appendChild(this.labelDom_);const e=this.labelDom_.getAttribute("id");return e&&oe(this.htmlDiv_,Q.LABELLEDBY,e),this.addColourBorder_(this.colour_),this.htmlDiv_}createContainer_(){const e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();const t=this.cssConfig_.container;return t&&b(e,t),e}createRowContainer_(){const e=document.createElement("div");var t=this.cssConfig_.row;return t&&b(e,t),t=`${je.nestedPadding*this.getLevel()}px`,this.workspace_.RTL?e.style.paddingRight=t:e.style.paddingLeft=t,e}createRowContentsContainer_(){const e=document.createElement("div"),t=this.cssConfig_.rowcontentcontainer;return t&&b(e,t),e}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&b(e,t)}return e.style.display="inline-block",e}createLabelDom_(e){const t=document.createElement("span");return t.setAttribute("id",this.getId()+".label"),t.textContent=e,(e=this.cssConfig_.label)&&b(t,e),t}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_),this.addColourBorder_(this.colour_)}addColourBorder_(e){e&&(e=je.borderWidth+"px solid "+(e||"#ddd"),this.workspace_.RTL?this.rowDiv_.style.borderRight=e:this.rowDiv_.style.borderLeft=e)}getColour_(e){const t=e.categorystyle||e.categoryStyle;if((e=e.colour)&&t)console.warn('Toolbox category "'+this.name_+'" must not have both a style and a colour');else{if(t)return this.getColourfromStyle(t);if(e)return this.parseColour(e)}return""}getColourfromStyle(e){var t=this.workspace_.getTheme();if(e&&t){if((t=t.categoryStyles[e])&&t.colour)return this.parseColour(t.colour);console.warn('Style "'+e+'" must exist and contain a colour value')}return""}getClickTarget(){return this.rowDiv_}parseColour(e){if(e=J(e),e==null||e==="")return"";var t=Number(e);return isNaN(t)?(t=no(e))?t:(console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+e),""):Hl(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&Li(e,t),(t=this.cssConfig_.openicon)&&b(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&Li(e,t),(t=this.cssConfig_.closedicon)&&b(e,t)}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none",this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}hide(){this.setVisible_(!1)}show(){this.setVisible_(!0)}isVisible(){return!this.isHidden_&&this.allAncestorsExpanded_()}allAncestorsExpanded_(){let e=this;for(;e.getParent();)if(e=e.getParent(),!e.isExpanded())return!1;return!0}isSelectable(){return this.isVisible()&&!this.isDisabled_}onClick(e){}setSelected(e){if(this.rowDiv_){var t=this.cssConfig_.selected;if(e){const o=this.parseColour(je.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||o,t&&b(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor="",t&&O(this.rowDiv_,t);oe(this.htmlDiv_,Q.SELECTED,e)}}setDisabled(e){this.isDisabled_=e,this.getDiv().setAttribute("disabled",`${e}`),e?this.getDiv().setAttribute("disabled","true"):this.getDiv().removeAttribute("disabled")}getName(){return this.name_}getParent(){return this.parent_}getDiv(){return this.htmlDiv_}getContents(){return this.flyoutItems_}updateFlyoutContents(e){this.flyoutItems_=[],this.toolboxItemDef_=typeof e=="string"?{kind:this.toolboxItemDef_.kind,custom:e,id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden}:{kind:this.toolboxItemDef_.kind,name:"name"in this.toolboxItemDef_?this.toolboxItemDef_.name:"",contents:xs(e),id:this.toolboxItemDef_.id,categorystyle:this.toolboxItemDef_.categorystyle,colour:this.toolboxItemDef_.colour,cssconfig:this.toolboxItemDef_.cssconfig,hidden:this.toolboxItemDef_.hidden},this.parseContents_(this.toolboxItemDef_)}dispose(){F(this.htmlDiv_)}};je.registrationName="category",je.nestedPadding=19,je.borderWidth=8,je.defaultBackgroundColour="#57e",qe(`
|
|
670
|
+
.blocklyToolboxCategory:not(.blocklyToolboxSelected):hover {
|
|
671
|
+
background-color: rgba(255, 255, 255, .2);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.blocklyToolbox[layout="h"] .blocklyToolboxCategoryContainer {
|
|
675
|
+
margin: 1px 5px 1px 0;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.blocklyToolbox[dir="RTL"][layout="h"] .blocklyToolboxCategoryContainer {
|
|
679
|
+
margin: 1px 0 1px 5px;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
.blocklyToolboxCategory {
|
|
683
|
+
height: 22px;
|
|
684
|
+
line-height: 22px;
|
|
685
|
+
margin-bottom: 3px;
|
|
686
|
+
padding-right: 8px;
|
|
687
|
+
white-space: nowrap;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
.blocklyToolbox[dir="RTL"] .blocklyToolboxCategory {
|
|
691
|
+
margin-left: 8px;
|
|
692
|
+
padding-right: 0;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.blocklyToolboxCategoryIcon {
|
|
696
|
+
background-image: url(<<<PATH>>>/sprites.png);
|
|
697
|
+
height: 16px;
|
|
698
|
+
vertical-align: middle;
|
|
699
|
+
visibility: hidden;
|
|
700
|
+
width: 16px;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
.blocklyToolboxCategoryIconClosed {
|
|
704
|
+
background-position: -32px -1px;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.blocklyToolbox[dir="RTL"] .blocklyToolboxCategoryIconClosed {
|
|
708
|
+
background-position: 0 -1px;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {
|
|
712
|
+
background-position: -32px -17px;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.blocklyToolbox[dir="RTL"] .blocklyToolboxSelected>.blocklyToolboxCategoryIconClosed {
|
|
716
|
+
background-position: 0 -17px;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.blocklyToolboxCategoryIconOpen {
|
|
720
|
+
background-position: -16px -1px;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.blocklyToolboxSelected>.blocklyToolboxCategoryIconOpen {
|
|
724
|
+
background-position: -16px -17px;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.blocklyToolboxCategoryLabel {
|
|
728
|
+
cursor: default;
|
|
729
|
+
font: 16px sans-serif;
|
|
730
|
+
padding: 0 3px;
|
|
731
|
+
vertical-align: middle;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
.blocklyToolboxDelete .blocklyToolboxCategoryLabel {
|
|
735
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
.blocklyToolboxSelected .blocklyToolboxCategoryLabel {
|
|
739
|
+
color: #fff;
|
|
740
|
+
}
|
|
741
|
+
`),I(g.TOOLBOX_ITEM,je.registrationName,je);var Si=class extends Ph{constructor(e,t){super(e,t),this.cssConfig_={container:"blocklyTreeSeparator"},this.htmlDiv=null,Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}init(){this.createDom_()}createDom_(){const e=document.createElement("div");e.tabIndex=-1,e.id=this.getId();const t=this.cssConfig_.container;return t&&b(e,t),this.htmlDiv=e}getDiv(){return this.htmlDiv}dispose(){F(this.htmlDiv)}};Si.registrationName="sep",qe(`
|
|
742
|
+
.blocklyTreeSeparator {
|
|
743
|
+
border-bottom: solid #e5e5e5 1px;
|
|
744
|
+
height: 0;
|
|
745
|
+
margin: 5px 0;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.blocklyToolbox[layout="h"] .blocklyTreeSeparator {
|
|
749
|
+
border-right: solid #e5e5e5 1px;
|
|
750
|
+
border-bottom: none;
|
|
751
|
+
height: auto;
|
|
752
|
+
margin: 0 5px 0 5px;
|
|
753
|
+
padding: 5px 0;
|
|
754
|
+
width: 0;
|
|
755
|
+
}
|
|
756
|
+
`),I(g.TOOLBOX_ITEM,Si.registrationName,Si);var Ts=class extends je{constructor(e,t,o){super(e,t,o),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){const e=super.makeDefaultCssConfig_();return e.contents="blocklyToolboxCategoryGroup",e}parseContents_(e){if("custom"in e)this.flyoutItems_=e.custom;else{const t=e.contents;if(t){this.flyoutItems_=[],e=!0;for(let o=0;o<t.length;o++){const s=t[o];!Ri(g.TOOLBOX_ITEM,s.kind)||s.kind.toLowerCase()===Si.registrationName&&e?(this.flyoutItems_.push(s),e=!0):(this.createToolboxItem(s),e=!1)}}}}createToolboxItem(e){let t=e.kind;t.toUpperCase()==="CATEGORY"&&Wi(e)&&(t=Ts.registrationName),e=new(Ve(g.TOOLBOX_ITEM,t))(e,this.parentToolbox_,this),this.toolboxItems_.push(e)}init(){super.init(),this.setExpanded(this.toolboxItemDef_.expanded==="true"||this.toolboxItemDef_.expanded===!0)}createDom_(){super.createDom_();const e=this.getChildToolboxItems();return this.subcategoriesDiv_=this.createSubCategoriesDom_(e),et(this.subcategoriesDiv_,Se.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),oe(this.htmlDiv_,Q.EXPANDED,!1),this.htmlDiv_}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&b(e,t),e.style.visibility="visible"}return e.style.display="inline-block",e}createSubCategoriesDom_(e){const t=document.createElement("div");t.style.display="none";var o=this.cssConfig_.contents;for(o&&b(t,o),o=0;o<e.length;o++){const s=e[o];s.init();const i=s.getDiv();if(t.appendChild(i),s.getClickTarget){let r;(r=s.getClickTarget())==null||r.setAttribute("id",s.getId())}}return t}setExpanded(e){if(this.expanded_!==e){if(this.expanded_=e)this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_);else{let t;(t=this.parentToolbox_.getFlyout())==null||t.setVisible(!1),this.subcategoriesDiv_.style.display="none",this.closeIcon_(this.iconDom_)}oe(this.htmlDiv_,Q.EXPANDED,e),this.parentToolbox_.handleToolboxItemResize()}}setVisible_(e){this.htmlDiv_.style.display=e?"block":"none";const t=this.getChildToolboxItems();for(let o=0;o<t.length;o++)t[o].setVisible_(e);this.isHidden_=!e,this.parentToolbox_.getSelectedItem()===this&&this.parentToolbox_.clearSelection()}isExpanded(){return this.expanded_}isCollapsible(){return!0}onClick(e){this.toggleExpanded()}toggleExpanded(){this.setExpanded(!this.expanded_)}getDiv(){return this.htmlDiv_}getChildToolboxItems(){return this.toolboxItems_}};Ts.registrationName="collapsibleCategory",I(g.TOOLBOX_ITEM,Ts.registrationName,Ts);var km=class extends gn{constructor(e){super(),this.id="toolbox",this.contentsDiv_=this.HtmlDiv=null,this.isVisible_=!1,this.height_=this.width_=0,this.flyout=null,this.contents=new Map,this.previouslySelectedItem_=this.selectedItem_=null,this.boundEvents_=[],this.workspace_=e,this.toolboxDef_=e.options.languageTree||{contents:[]},this.horizontalLayout=e.options.horizontalLayout,this.RTL=e.options.RTL,this.toolboxPosition=e.options.toolboxPosition}onShortcut(e){return!1}init(){var e=this.workspace_;const t=e.getParentSvg();this.flyout=this.createFlyout_(),this.HtmlDiv=this.createDom_(this.workspace_);const o=this.flyout.createDom("svg");b(o,"blocklyToolboxFlyout"),Qt(o,t),this.setVisible(!0),this.flyout.init(e),this.render(this.toolboxDef_),e=e.getThemeManager(),e.subscribe(this.HtmlDiv,"toolboxBackgroundColour","background-color"),e.subscribe(this.HtmlDiv,"toolboxForegroundColour","color"),this.workspace_.getComponentManager().addComponent({component:this,weight:U.ComponentWeight.TOOLBOX_WEIGHT,capabilities:[U.Capability.AUTOHIDEABLE,U.Capability.DELETE_AREA,U.Capability.DRAG_TARGET]}),n.getFocusManager$$module$build$src$core$focus_manager().registerTree(this,!0)}createDom_(e){e=e.getParentSvg();const t=this.createContainer_();return t.id=Le(),this.contentsDiv_=this.createContentsContainer_(),et(this.contentsDiv_,Se.TREE),t.appendChild(this.contentsDiv_),e.parentNode.insertBefore(t,e),this.attachEvents_(t,this.contentsDiv_),t}createContainer_(){const e=document.createElement("div");return e.setAttribute("layout",this.isHorizontal()?"h":"v"),b(e,"blocklyToolbox"),e.setAttribute("dir",this.RTL?"RTL":"LTR"),e}createContentsContainer_(){const e=document.createElement("div");return b(e,"blocklyToolboxCategoryGroup"),this.isHorizontal()&&(e.style.flexDirection="row"),e}attachEvents_(e,t){e=k(e,"pointerdown",this,this.onClick_,!1),this.boundEvents_.push(e),t=k(t,"keydown",this,this.onKeyDown_,!1),this.boundEvents_.push(t)}onClick_(e){if(We(e)||e.target===this.HtmlDiv)Me().hideChaff(!1);else{var t=e.target.getAttribute("id");t&&(t=this.getToolboxItemById(t),t.isSelectable()&&(this.setSelectedItem(t),t.onClick(e))),Me().hideChaff(!0)}Ee()}onKeyDown_(e){let t=!1;switch(e.key){case"ArrowDown":t=this.selectNext();break;case"ArrowUp":t=this.selectPrevious();break;case"ArrowLeft":t=this.selectParent();break;case"ArrowRight":t=this.selectChild();break;case"Enter":case" ":this.selectedItem_&&this.selectedItem_.isCollapsible()&&(this.selectedItem_.toggleExpanded(),t=!0);break;default:t=!1}!t&&this.selectedItem_&&this.selectedItem_.onKeyDown&&(t=this.selectedItem_.onKeyDown(e)),t&&e.preventDefault()}createFlyout_(){const e=this.workspace_,t=e.copyOptionsForFlyout();return t.toolboxPosition=e.options.toolboxPosition,new(e.horizontalLayout?_e(g.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):_e(g.FLYOUTS_VERTICAL_TOOLBOX,e.options,!0))(t)}render(e){this.toolboxDef_=e,this.contents.forEach(t=>t.dispose()),this.contents.clear(),this.renderContents_(e.contents),this.position(),this.handleToolboxItemResize()}renderContents_(e){const t=document.createDocumentFragment();for(let o=0;o<e.length;o++)this.createToolboxItem(e[o],t);this.contentsDiv_.appendChild(t)}createToolboxItem(e,t){var o=e.kind;o.toUpperCase()==="CATEGORY"&&Wi(e)&&(o=Ts.registrationName),(o=Ve(g.TOOLBOX_ITEM,o.toLowerCase()))&&(e=new o(e,this),e.init(),this.addToolboxItem_(e),(o=e.getDiv())&&t.appendChild(o),e.getClickTarget()&&e.getClickTarget().setAttribute("id",e.getId()))}addToolboxItem_(e){if(this.contents.set(e.getId(),e),e.isCollapsible()){e=e.getChildToolboxItems();for(let t=0;t<e.length;t++)this.addToolboxItem_(e[t])}}getToolboxItems(){return[...this.contents.values()]}addStyle(e){e&&this.HtmlDiv&&b(this.HtmlDiv,e)}removeStyle(e){e&&this.HtmlDiv&&O(this.HtmlDiv,e)}getClientRect(){if(!this.HtmlDiv||!this.isVisible_)return null;var e=this.HtmlDiv.getBoundingClientRect();const t=e.top,o=t+e.height,s=e.left;return e=s+e.width,this.toolboxPosition===S.TOP?new D(-1e7,o,-1e7,1e7):this.toolboxPosition===S.BOTTOM?new D(t,1e7,-1e7,1e7):this.toolboxPosition===S.LEFT?new D(-1e7,1e7,-1e7,e):new D(-1e7,1e7,s,1e7)}wouldDelete(e){return e instanceof H?this.updateWouldDelete_(!e.getParent()&&e.isDeletable()):this.updateWouldDelete_(Pe(e)&&e.isDeletable()),this.wouldDelete_}onDragEnter(e){this.updateCursorDeleteStyle_(!0)}onDragExit(e){this.updateCursorDeleteStyle_(!1)}onDrop(e){this.updateCursorDeleteStyle_(!1)}updateWouldDelete_(e){e!==this.wouldDelete_&&(this.updateCursorDeleteStyle_(!1),this.wouldDelete_=e,this.updateCursorDeleteStyle_(!0))}updateCursorDeleteStyle_(e){const t=this.wouldDelete_?"blocklyToolboxDelete":"blocklyToolboxGrab";e?this.addStyle(t):this.removeStyle(t)}getToolboxItemById(e){return this.contents.get(e)||null}getWidth(){return this.width_}getHeight(){return this.height_}getFlyout(){return this.flyout}getWorkspace(){return this.workspace_}getSelectedItem(){return this.selectedItem_}getPreviouslySelectedItem(){return this.previouslySelectedItem_}isHorizontal(){return this.horizontalLayout}position(){const e=this.workspace_.getMetrics(),t=this.HtmlDiv;t&&(this.horizontalLayout?(t.style.left="0",t.style.height="auto",t.style.width="100%",this.height_=t.offsetHeight,this.width_=e.viewWidth,this.toolboxPosition===S.TOP?t.style.top="0":t.style.bottom="0"):(this.toolboxPosition===S.RIGHT?t.style.right="0":t.style.left="0",t.style.height="100%",this.width_=t.offsetWidth,this.height_=e.viewHeight),this.flyout.position())}handleToolboxItemResize(){const e=this.workspace_;var t=this.HtmlDiv.getBoundingClientRect();const o=this.getFlyout(),s=this.toolboxPosition===S.LEFT?e.scrollX+t.width+(o!=null&&o.isVisible()?o.getWidth():0):e.scrollX;t=this.toolboxPosition===S.TOP?e.scrollY+t.height+(o!=null&&o.isVisible()?o.getHeight():0):e.scrollY,e.translate(s,t),oo(e)}clearSelection(){this.setSelectedItem(null)}refreshTheme(){this.contents.forEach(e=>{e.refreshTheme&&e.refreshTheme()})}refreshSelection(){this.selectedItem_&&this.selectedItem_.isSelectable()&&this.selectedItem_.getContents().length&&this.flyout.show(this.selectedItem_.getContents())}setVisible(e){this.isVisible_!==e&&(this.HtmlDiv.style.display=e?"block":"none",this.isVisible_=e,this.workspace_.recordDragTargets())}autoHide(e){!e&&this.flyout&&this.flyout.autoClose&&this.clearSelection()}setSelectedItem(e){const t=this.selectedItem_;!e&&!t||e&&!m$(e)||(this.shouldDeselectItem_(t,e)&&t!==null&&this.deselectItem_(t),this.shouldSelectItem_(t,e)&&e!==null&&this.selectItem_(t,e),this.updateFlyout_(t,e),this.fireSelectEvent(t,e))}shouldDeselectItem_(e,t){return e!==null&&(!e.isCollapsible()||e!==t)}shouldSelectItem_(e,t){return t!==null&&t!==e}deselectItem_(e){this.selectedItem_=null,this.previouslySelectedItem_=e,e.setSelected(!1),oe(this.contentsDiv_,Q.ACTIVEDESCENDANT,"")}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),oe(this.contentsDiv_,Q.ACTIVEDESCENDANT,t.getId())}selectItemByPosition(e){(e=this.getToolboxItems()[e])&&this.setSelectedItem(e)}updateFlyout_(e,t){t&&(e!==t||t.isCollapsible())&&t.getContents().length?(this.flyout.show(t.getContents()),this.flyout.scrollToStart()):this.flyout.hide()}fireSelectEvent(e,t){const o=e&&e.getName();let s=t&&t.getName();e===t&&(s=null),e=new(w(a.TOOLBOX_ITEM_SELECT))(o,s,this.workspace_.id),C(e)}selectParent(){return this.selectedItem_?this.selectedItem_.isCollapsible()&&this.selectedItem_.isExpanded()?(this.selectedItem_.toggleExpanded(),!0):this.selectedItem_.getParent()&&this.selectedItem_.getParent().isSelectable()?(this.setSelectedItem(this.selectedItem_.getParent()),!0):!1:!1}selectChild(){if(!this.selectedItem_||!this.selectedItem_.isCollapsible())return!1;const e=this.selectedItem_;return e.isExpanded()?this.selectNext():e.toggleExpanded(),!0}selectNext(){if(!this.selectedItem_)return!1;const e=[...this.contents.values()];let t=e.indexOf(this.selectedItem_)+1;if(t>-1&&t<e.length){let o=e[t];for(;o&&!o.isSelectable();)o=e[++t];if(o&&o.isSelectable())return this.setSelectedItem(o),!0}return!1}selectPrevious(){if(!this.selectedItem_)return!1;const e=[...this.contents.values()];let t=e.indexOf(this.selectedItem_)-1;if(t>-1&&t<e.length){let o=e[t];for(;o&&!o.isSelectable();)o=e[--t];if(o&&o.isSelectable())return this.setSelectedItem(o),!0}return!1}dispose(){this.workspace_.getComponentManager().removeComponent("toolbox"),this.flyout.dispose(),this.contents.forEach(e=>e.dispose());for(let e=0;e<this.boundEvents_.length;e++)x(this.boundEvents_[e]);this.boundEvents_=[],this.contents.clear(),this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),F(this.HtmlDiv)),n.getFocusManager$$module$build$src$core$focus_manager().unregisterTree(this)}getFocusableElement(){if(!this.HtmlDiv)throw Error("Toolbox DOM has not yet been created.");return this.HtmlDiv}getFocusableTree(){return this}onNodeFocus(){}onNodeBlur(){}canBeFocused(){return!0}getRootFocusableNode(){return this}getRestoredFocusableNode(e){if(!e||e===this){let t;return(t=this.getToolboxItems().find(o=>o.isSelectable()))!=null?t:null}return null}getNestedTrees(){return[]}lookUpFocusableNode(e){return this.getToolboxItemById(e)}onTreeFocus(e,t){e!==this?this.getSelectedItem()!==e&&this.setSelectedItem(e):this.clearSelection()}onTreeBlur(e){let t;e&&e===((t=this.flyout)==null?void 0:t.getWorkspace())||(this.clearSelection(),this.flyout&&dc(this.flyout)&&this.flyout.autoHide(!1))}};qe(`
|
|
757
|
+
.blocklyToolboxDelete {
|
|
758
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
.blocklyToolboxGrab {
|
|
762
|
+
cursor: url("<<<PATH>>>/handclosed.cur"), auto;
|
|
763
|
+
cursor: grabbing;
|
|
764
|
+
cursor: -webkit-grabbing;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/* Category tree in Toolbox. */
|
|
768
|
+
.blocklyToolbox {
|
|
769
|
+
box-sizing: border-box;
|
|
770
|
+
user-select: none;
|
|
771
|
+
-ms-user-select: none;
|
|
772
|
+
-webkit-user-select: none;
|
|
773
|
+
background-color: #ddd;
|
|
774
|
+
overflow-x: visible;
|
|
775
|
+
overflow-y: auto;
|
|
776
|
+
padding: 4px 0 4px 0;
|
|
777
|
+
position: absolute;
|
|
778
|
+
z-index: 70; /* so blocks go under toolbox when dragging */
|
|
779
|
+
-webkit-tap-highlight-color: transparent; /* issue #1345 */
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
.blocklyToolboxCategoryGroup {
|
|
783
|
+
display: flex;
|
|
784
|
+
flex-wrap: wrap;
|
|
785
|
+
flex-direction: column;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
.blocklyToolboxCategoryGroup:focus {
|
|
789
|
+
outline: none;
|
|
790
|
+
}
|
|
791
|
+
`),I(g.TOOLBOX,Ce,km);var _f="12.2.0",Ef=E.INPUT_VALUE,Tf=E.OUTPUT_VALUE,yf=E.NEXT_STATEMENT,vf=E.PREVIOUS_STATEMENT,Cf=S.TOP,wf=S.BOTTOM,kf=S.LEFT,If=S.RIGHT;ms.prototype.newBlock=function(e,t){return new $s(this,e,t)},be.prototype.newBlock=function(e,t){return new H(this,e,t)},ms.prototype.newComment=function(e){return new cn(this,e)},be.prototype.newComment=function(e){return new ct(this,e)},be.newTrashcan=function(e){return new yg(e)},St.prototype.newWorkspaceSvg=function(e){return new be(e)},n.Names$$module$build$src$core$names.prototype.populateProcedures=function(e){e=Ks(e),e=e[0].concat(e[1]);for(let t=0;t<e.length;t++)this.getName(e[t][0],n.Names$$module$build$src$core$names.NameType.PROCEDURE)};var d={};return d.Block=$s,d.BlockFlyoutInflater=pm,d.BlockNavigationPolicy=Qp,d.BlockSvg=H,d.Blocks=W,d.ButtonFlyoutInflater=$m,d.COLLAPSED_FIELD_NAME=zr,d.COLLAPSED_INPUT_NAME=ni,d.COLLAPSE_CHARS=Wp,d.CodeGenerator=n.CodeGenerator$$module$build$src$core$generator,d.CollapsibleToolboxCategory=Ts,d.ComponentManager=U,d.Connection=A,d.ConnectionChecker=bg,d.ConnectionDB=hs,d.ConnectionNavigationPolicy=eg,d.ConnectionType=E,d.ContextMenu=yo,d.ContextMenuItems=ne,d.ContextMenuRegistry=R,d.Css=$u,d.DELETE_VARIABLE_ID=zu,d.DeleteArea=gn,d.DragTarget=Kp,d.DropDownDiv=ge,d.Events=_,d.Extensions=Ye,d.Field=L,d.FieldCheckbox=So,d.FieldDropdown=$e,d.FieldImage=Io,d.FieldLabel=Co,d.FieldLabelSerializable=Hg,d.FieldNavigationPolicy=tg,d.FieldNumber=Eh,d.FieldTextInput=n.FieldTextInput$$module$build$src$core$field_textinput,d.FieldVariable=wi,d.Flyout=fn,d.FlyoutButton=ye,d.FlyoutButtonNavigationPolicy=Jp,d.FlyoutItem=ps,d.FlyoutMetricsManager=jp,d.FlyoutNavigationPolicy=Zp,d.FlyoutNavigator=sg,d.FlyoutSeparator=mn,d.FlyoutSeparatorNavigationPolicy=qp,d.FocusManager=de,d.FocusableTreeTraverser=he,d.Generator=n.CodeGenerator$$module$build$src$core$generator,d.Gesture=_n,d.Grid=Ju,d.HorizontalFlyout=Fg,d.INPUT_VALUE=Ef,d.Input=ds,d.InsertionMarkerPreviewer=Mg,d.KeyboardNavigationController=rg,d.LabelFlyoutInflater=Sg,d.LineCursor=Zu,d.Marker=lg,d.MarkerManager=qu,d.Menu=_u,d.MenuItem=Ur,d.MetricsManager=Yu,d.Msg=n.Msg$$module$build$src$core$msg,d.NEXT_STATEMENT=yf,d.Names=n.Names$$module$build$src$core$names,d.Navigator=Ku,d.OPPOSITE_TYPE=wo,d.OUTPUT_VALUE=Tf,d.Options=ut,d.PREVIOUS_STATEMENT=vf,d.PROCEDURE_CATEGORY_NAME=En,d.Procedures=fe,d.RENAME_VARIABLE_ID=Uu,d.RenderedConnection=ae,d.Scrollbar=q,d.ScrollbarPair=ju,d.SeparatorFlyoutInflater=ig,d.ShortcutItems=pt,d.ShortcutRegistry=G,d.TOOLBOX_AT_BOTTOM=wf,d.TOOLBOX_AT_LEFT=kf,d.TOOLBOX_AT_RIGHT=If,d.TOOLBOX_AT_TOP=Cf,d.Theme=vo,d.ThemeManager=fg,d.Themes=bf,d.Toast=go,d.Toolbox=km,d.ToolboxCategory=je,d.ToolboxItem=Ph,d.ToolboxSeparator=Si,d.Tooltip=Re,d.Touch=ao,d.Trashcan=yg,d.UnattachedFieldError=te,d.VARIABLE_CATEGORY_NAME=Cu,d.VARIABLE_DYNAMIC_CATEGORY_NAME=uh,d.VERSION=_f,d.VariableMap=Tg,d.VariableModel=Eg,d.Variables=ee,d.VariablesDynamic=jt,d.VerticalFlyout=_h,d.WidgetDiv=Xe,d.Workspace=ms,d.WorkspaceAudio=_g,d.WorkspaceDragger=ng,d.WorkspaceNavigationPolicy=og,d.WorkspaceSvg=be,d.Xml=me,d.ZoomControls=Y$,d.blockAnimations=fi,d.blockRendering=B,d.browserEvents=yt,d.bubbles=Ii,d.bumpObjects=pn,d.clipboard=Ke,d.comments=Jt,d.common=re,d.config=n.config$$module$build$src$core$config,d.constants=zm,d.defineBlocksWithJsonArray=Un,d.dialog=It,d.dragging=ki,d.fieldRegistry=un,d.geras=ft,d.getFocusManager=n.getFocusManager$$module$build$src$core$focus_manager,d.getMainWorkspace=Me,d.getSelected=Ss,d.hasBubble=ro,d.hideChaff=f$,d.icons=Kt,d.inject=i$,d.inputs=Zt,d.isCopyable=Js,d.isDeletable=Pe,d.isDraggable=Qo,d.isIcon=rc,d.isObservable=yr,d.isPaster=p$,d.isRenderedElement=g$,d.isSelectable=Fi,d.isSerializable=Bs,d.isVariableBackedParameterModel=nl,d.keyboardNavigationController=bn,d.layers=Xm,d.navigateBlock=Ue,d.navigateStacks=qo,d.procedures=fe,d.registry=Tt,d.renderManagement=Yr,d.serialization=$f,d.setLocale=vu,d.setParentContainer=Wn,d.svgResize=oo,d.thrasos=Bh,d.uiPosition=po,d.utils=X,d.zelos=mt,d.__namespace__=n,d})})(An)),An.exports}exports.requireBlockly_compressed=Nf;
|
|
792
|
+
//# sourceMappingURL=blockly_compressed-BSXJbxOI.cjs.map
|