@johnnycubides/catalejo-vue3-desktop-v2 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/assets/@lezer-6dgAjmMZ.js +1 -0
- package/dist/assets/@vue-SIJfIzG2.js +17 -0
- package/dist/assets/Inter-italic.var-DhD-tpjY.woff2 +0 -0
- package/dist/assets/Inter-roman.var-C-r5W2Hj.woff2 +0 -0
- package/dist/assets/blockly-C3KDyeBl.js +1603 -0
- package/dist/assets/codemirror-CPly2f-x.js +23 -0
- package/dist/assets/crelt-C8TCjufn.js +1 -0
- package/dist/assets/index-CCtfKVc_.js +18 -0
- package/dist/assets/index-DPWq3wfr.css +1 -0
- package/dist/assets/primeicons-B7yeMe2z.css +1 -0
- package/dist/assets/primeicons-C6QP2o4f.woff2 +0 -0
- package/dist/assets/primeicons-DMOk5skT.eot +0 -0
- package/dist/assets/primeicons-Dr5RGzOO.svg +345 -0
- package/dist/assets/primeicons-MpK4pl85.ttf +0 -0
- package/dist/assets/primeicons-WjwUDZjB.woff +0 -0
- package/dist/assets/primevue-BBIBCcHR.js +97 -0
- package/dist/assets/primevue-VvdNDlPa.css +1 -0
- package/dist/assets/style-mod-Bc2inJdb.js +3 -0
- package/dist/assets/vue-demi-l0sNRNKZ.js +1 -0
- package/dist/assets/vue-l0sNRNKZ.js +1 -0
- package/dist/assets/w3c-keyname-Vcq4gwWv.js +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +24 -0
- package/dist/media/1x1.gif +0 -0
- package/dist/media/click.mp3 +0 -0
- package/dist/media/click.ogg +0 -0
- package/dist/media/click.wav +0 -0
- package/dist/media/delete.mp3 +0 -0
- package/dist/media/delete.ogg +0 -0
- package/dist/media/delete.wav +0 -0
- package/dist/media/disconnect.mp3 +0 -0
- package/dist/media/disconnect.ogg +0 -0
- package/dist/media/disconnect.wav +0 -0
- package/dist/media/dropdown-arrow.svg +1 -0
- package/dist/media/handclosed.cur +0 -0
- package/dist/media/handdelete.cur +0 -0
- package/dist/media/handopen.cur +0 -0
- package/dist/media/pilcrow.png +0 -0
- package/dist/media/quote0.png +0 -0
- package/dist/media/quote1.png +0 -0
- package/dist/media/sprites.png +0 -0
- package/dist/media/sprites.svg +74 -0
- package/dist/plugins/plugins.d.ts +1 -0
- package/dist/plugins/plugins.js +7 -0
- package/package.json +49 -0
|
@@ -0,0 +1,1603 @@
|
|
|
1
|
+
function Hu(q,xe){for(var n=0;n<xe.length;n++){const _=xe[n];if(typeof _!="string"&&!Array.isArray(_)){for(const r in _)if(r!=="default"&&!(r in q)){const $e=Object.getOwnPropertyDescriptor(_,r);$e&&Object.defineProperty(q,r,$e.get?$e:{enumerable:!0,get:()=>_[r]})}}}return Object.freeze(Object.defineProperty(q,Symbol.toStringTag,{value:"Module"}))}var Ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vu(q){return q&&q.__esModule&&Object.prototype.hasOwnProperty.call(q,"default")?q.default:q}var Ug={exports:{}},Lu={exports:{}},ku={exports:{}},Du={exports:{}},Mu={exports:{}},Ag;function $i(){return Ag||(Ag=1,function(q,xe){(function(n,_){q.exports=_()})(Ve,function(){var n={},_,r,$e,he,u,c,l,d,g,b,N,G,Q,de,Y,Re,_e,et,$o,nr,Pt,Eo,Ei,lr,mi,oo,ft,We,tt,x,fi,mo,Fe,Z,ve,Ie,Oe,K,C,bi,Bo,hs,ds,F,_s,Ri,Ii,Oi,bt,Ce,fo,bo,I,U,ps,se,xo,re,Rt,Fo,so,Bt,xt,ct,h,T,m,O,S,te,Uo,Wu,Si,Xu,Yn,gs,ju,vi,Yu,Ci,Kn,zn,Ku,Ni,Ts,Jn,yi,zu,qn,Zn,Ju,qu,Ho,ar,cr,Zu,Ai,Qn,Ft,Ut,ur,$s,el,Qu,eh,th,oh,w,Ye,ce,hr,ro,Vo,dr,Tt,tl,_r,sh,ol,Ht,rh,Ro,sl,rl,Li,il,$t,pr,nl,ki,Di,ll,ih,al,gr,nh,lh,Io,cl,Vt,ah,ch,uh,Es,hh,Wo,ul,dh,_h,ph,gh,Th,hl,$h,Eh,Mi,mh,fh,dl,wi,bh,Wt,Rh,Ih,Oh,Sh,vh,Ch,Nh,_l,Oo,Gi,pl,yh,Ah,Lh,kh,Dh,Mh,wh,Gh,gl,Ph,Bh,xh,Fh,ms,Tl,fs,$l,El,ml,bs,Pi,Bi,Uh,Tr,fl,bl,Rl,Il,Ol,Sl,Hh,$r,vl,Rs,xi,It,Cl,Vh,Wh,Er,Nl,yl,Al,Xh,Fi,Ll,jh,kl,Yh,Kh,zh,Jh,Is,Dl,Ml,mr,wl,qh,Zh,Gl,Pl,So,Bl,xl,Qh,ed,td,od,Fl,sd,Ul,rd,vo,fr,Ui,Hi,Xo,Vi,Wi,Xi,Ee,br,jo,Yo,id,Hl,ji,Ot,Vl,Yi,Wl,Xl,nd,ld,ut,ad,Ki,cd,St,ge,ud,hd,jl,dd,_d,io,pd,Rr,gd,Ir,zi,Td,Ji,$d,qi,Yl,Kl,Ed,md,zl,Zi,fd,bd,Rd,Jl,Qi,ql,en,Id,Or,Od,Sd,Ke,Zl,Ql,ea,ta,oa,sa,Os,Sr,ra,vd,tn,Cd,Ss,Nd,on,vr,yd,Ad,ia,Cr,Ld,kd,Dd,Md,Nr,na,wd,la,aa,Gd,yr,P,ot,Ue,Te,Xt,vs,D,Ne,Pd,ca,Bd,ua,ha,da,_a,pa,ga,Ta,$a,Ea,sn,Ar,ma,xd,fa,ba,Ra,Ia,Oa,Sa,va,Fd,Ca,Co,rn,nn,Na,ya,Ud,Aa,Hd,ln,La,ka,Vd,Da,Wd,Xd,jd,Ma,Lr,Yd,Cs,Kd,zd,wa,Ga,Pa,Ba,an,xa,cn,un,hn,Jd,qd,Zd,Qd,e_,t_,o_,s_,Fa,Ua,Ha,Va,r_,i_,Wa,Xa,ja,Ya,Ka,za,Ja,qa,n_,l_,a_,c_,u_,h_,d_,__,p_,g_,T_,$_,E_,m_,f_,b_,R_,I_,O_,S_,v_,C_,N_,y_,B;_=function(e,t,o,s){e=e+" was deprecated in "+t+" and will be deleted in "+o+".",s&&(e+=`
|
|
2
|
+
Use `+s+" instead."),console.warn(e)},r=function(e,t,o,s){if(!(e instanceof A)&&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 a=No[e],p=dn[e];if(a||(a=No[e]=Object.create(null),p=dn[e]=Object.create(null)),$e(e,o),!s&&a[i])throw Error('Name "'+i+'" with type "'+e+'" already registered.');a[i]=o,p[i]=t},$e=function(e,t){switch(e){case String(A.FIELD):if(typeof t.fromJson!="function")throw Error('Type "'+e+'" must have a fromJson function')}},he=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();const o=No[e];o&&o[t]?(delete No[e][t],delete dn[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},u=function(e,t,o){e=`${e}`.toLowerCase(),t=t.toLowerCase();const s=No[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]},c=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=No[e])?!!e[t]:!1},l=function(e,t,o){return u(e,t,o)},d=function(e,t,o){return u(e,t,o)},g=function(e,t,o){e=`${e}`.toLowerCase();var s=No[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=dn[e],o=Object.create(null);for(const i of Object.keys(s))o[e[i]]=s[i];return o},b=function(e,t,o){return t=t.plugins[String(e)]||no,typeof t=="function"?t:l(e,t,o)},N=function(e){return Ns[e]||null},G=function(){const e=[];for(const t in Ns)e.push(Ns[t]);return e},Q=function(e){Ns[e.id]=e},de=function(e){delete Ns[e.id]},Y=function(){return A_},Re=function(e){A_=e},_e=function(){return Za},et=function(e){Za=e},$o=function(){return L_},nr=function(e){L_=e},Pt=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()}},Eo=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,a;a=s[i];i++)o[a.type]?o[a.type]++:o[a.type]=1;return o},Ei=function(e){return function(){this.jsonInit(e)}},lr=function(e){Qa.defineBlocksWithJsonArrayInternal(e)},mi=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:Ei(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 rt&&console.warn(`Block definiton "${t}" overwrites previous definition.`),rt[t]=o}},oo=function(){return"blockly-"+(Jg++).toString(36)},ft=function(){return D_.genUid()},We=function(e){kr=e},tt=function(){return kr},x=function(e){oc.fireInternal(e)},fi=function(e){if(Oe()){if(!Ds.length)try{requestAnimationFrame(()=>{setTimeout(mo,0)})}catch{setTimeout(mo,0)}Ds.push(e)}},mo=function(){const e=Fe(Ds,!0);Ds.length=0;for(let t=0,o;o=e[t];t++){if(!o.workspaceId)continue;const s=N(o.workspaceId);s&&s.fireChangeListener(o)}},Fe=function(e,t){e=e.slice(),t||e.reverse();const o=[],s=Object.create(null);for(let p=0,$;$=e[p];p++)if(!$.isNull()){var i=[$.isUiEvent?Mr:$.type,$.blockId,$.workspaceId].join(" "),a=s[i];const v=a?a.event:null;a?$.type===ze&&a.index===p-1?(i=$,v.newParentId=i.newParentId,v.newInputName=i.newInputName,v.newCoordinate=i.newCoordinate,a.index=p):$.type===Ge&&$.element===v.element&&$.name===v.name?v.newValue=$.newValue:$.type===Jo?(a=$,v.viewTop=a.viewTop,v.viewLeft=a.viewLeft,v.scale=a.scale,v.oldScale=a.oldScale):($.type!==Ao||v.type!==lo)&&(s[i]={event:$,index:p},o.push($)):(s[i]={event:$,index:p},o.push($))}e=o.filter(function(p){return!p.isNull()}),t||e.reverse();for(let p=1,$;$=e[p];p++)$.type===Ge&&$.element==="mutation"&&e.unshift(e.splice(p,1)[0]);return e},Z=function(){for(let e=0,t;t=Ds[e];e++)t.recordUndo=!1},ve=function(){ec++},Ie=function(){ec--},Oe=function(){return ec===0},K=function(){return M_},C=function(e){oc.setGroupInternal(e)},bi=function(e){M_=typeof e=="boolean"?e?ft():"":e},Bo=function(e){const t=[];e=e.getDescendants(!1);for(let o=0,s;s=e[o];o++)t[o]=s.id;return t},hs=function(e,t){var o=F(e.type);if(!o)throw Error("Unknown event type.");return ds(o)?o.fromJson(e,t):(o=new o,o.fromJson(e),o.workspaceId=t.id,o)},ds=function(e){return Object.getOwnPropertyDescriptors(e).fromJson&&typeof e.fromJson=="function"},F=function(e){const t=l(A.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},_s=function(e){if((e.type===ze||e.type===He)&&e.workspaceId){var t=N(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){const o=kr;try{kr=!1;const s=e.getParent();if(s&&s.isEnabled()){const i=e.getDescendants(!1);for(let a=0,p;p=i[a];a++)p.setEnabled(!0)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setEnabled(!1),e=e.getNextBlock();while(e)}finally{kr=o}}}},Ri=function(e){({document:Zo=Zo,DOMParser:pn=pn,XMLSerializer:gn=gn}=e)},Ii=function(){return _("Blockly.utils.xml.getDocument","version 9","version 10"),Zo},Oi=function(e){_("Blockly.utils.xml.setDocument","version 9","version 10"),Zo=e},n.createElement$$module$build$src$core$utils$xml=function(e){return Zo.createElementNS(sc,e)},bt=function(e){return Zo.createTextNode(e)},Ce=function(e){const t=fo(e);if(!t||!t.documentElement||t.getElementsByTagName("parsererror").length)throw Error("textToDom was unable to parse: "+e);return t.documentElement},fo=function(e){return new pn().parseFromString(e,"text/xml")},bo=function(e){return new gn().serializeToString(e)},I=function(e,t,o){e=document.createElementNS(Ms,`${e}`);for(const s in t)e.setAttribute(s,`${t[s]}`);return o&&o.appendChild(e),e},U=function(e,t){return t=t.split(" "),t.every(o=>e.classList.contains(o))?!1:(e.classList.add(...t),!0)},ps=function(e,t){e.classList.remove(...t.split(" "))},se=function(e,t){return t=t.split(" "),t.every(o=>!e.classList.contains(o))?!1:(e.classList.remove(...t),!0)},xo=function(e,t){return e.classList.contains(t)},re=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},Rt=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)},Fo=function(e,t){return!!(e.compareDocumentPosition(t)&Yt.DOCUMENT_POSITION_CONTAINED_BY)},so=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},Bt=function(){rc++,Nt||(Nt=Object.create(null))},xt=function(){rc--,rc||(Nt=null)},ct=function(e){const t=e.textContent+`
|
|
3
|
+
`+e.className.baseVal;let o;if(Nt&&(o=Nt[t]))return o;try{o=e.getComputedTextLength()}catch{return 8*e.textContent.length}return Nt&&(Nt[t]=o),o},h=function(e,t,o,s){return T(e,t+"pt",o,s)},T=function(e,t,o,s){const i=e.textContent;e=i+`
|
|
4
|
+
`+e.className.baseVal;var a;return Nt&&(a=Nt[e])||(Tn||(a=document.createElement("canvas"),a.className="blocklyComputeCanvas",document.body.appendChild(a),Tn=a.getContext("2d")),Tn.font=o+" "+t+" "+s,a=i?Tn.measureText(i).width:0,Nt&&(Nt[e]=a)),a},m=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.setAttribute("style","position: fixed; top: 0; left: 0; display: flex;"),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},O=function(e,t){w_(e,t)},S=function(e){w_=e},te=function(e,t){B_.confirmInternal(e,t)},Uo=function(e,t){G_(e,t)},Wu=function(e){G_=e},Si=function(e,t,o){P_(e,t,o)},Xu=function(e){P_=e},Yn=function(e){return e.getVariableModel!==void 0},gs=function(e){return e.getProcedureDef!==void 0},ju=function(e){return e.getProcedureCall!==void 0&&e.renameProcedure!==void 0},vi=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 a=s[i];a.getId()&&t.add(a)}}return Array.from(t.values())},Yu=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 a=0;a<o.length;a++)t.add(o[a])}}return Array.from(t.values())},Ci=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){Ts(s.getTargetWorkspace())}),t.push(o),e=Kn(e),t=t.concat(e)},Kn=function(e){e=e.getVariablesOfType("");const t=[];if(0<e.length){var o=e[e.length-1];if(rt.variables_set){var s=n.createElement$$module$build$src$core$utils$xml("block");s.setAttribute("type","variables_set"),s.setAttribute("gap",rt.math_change?"8":"24"),s.appendChild(Ho(o)),t.push(s)}if(rt.math_change&&(s=n.createElement$$module$build$src$core$utils$xml("block"),s.setAttribute("type","math_change"),s.setAttribute("gap",rt.variables_get?"20":"8"),s.appendChild(Ho(o)),o=Ce('<value name="DELTA"><shadow type="math_number"><field name="NUM">1</field></shadow></value>'),s.appendChild(o),t.push(s)),rt.variables_get){e.sort(Ur.compareByName);for(let i=0,a;a=e[i];i++)o=n.createElement$$module$build$src$core$utils$xml("block"),o.setAttribute("type","variables_get"),o.setAttribute("gap","8"),o.appendChild(Ho(a)),t.push(o)}}return t},zn=function(e){return lc.generateUniqueNameInternal(e)},Ku=function(e){return Ni(En.charAt(0),e.getAllVariableNames())},Ni=function(e,t){if(!t.length)return e;const o=En;let s="",i=o.indexOf(e);for(;;){let a=!1;for(let p=0;p<t.length;p++)if(t[p].toLowerCase()===e){a=!0;break}if(!a)break;i++,i===o.length&&(i=0,s=`${Number(s)+1}`),e=o.charAt(i)+s}return e},Ts=function(e,t,o){function s(a){yi(H.NEW_VARIABLE_TITLE,a,function(p){if(p){var $=qn(p,e);if($){if($.type===i)var v=H.VARIABLE_ALREADY_EXISTS.replace("%1",$.name);else v=H.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE,v=v.replace("%1",$.name).replace("%2",$.type);O(v,function(){s(p)})}else e.createVariable(p,i),t&&t(p)}else t&&t(null)})}const i=o||"";s("")},Jn=function(e,t,o){function s(i){const a=H.RENAME_VARIABLE_TITLE.replace("%1",t.name);yi(a,i,function(p){if(p){var $=zu(p,t.type,e),v=Zn(t.name,p,e);if($||v){var k="";$?k=H.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE.replace("%1",$.name).replace("%2",$.type):v&&(k=H.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER.replace("%1",p).replace("%2",v)),O(k,function(){s(p)})}else e.renameVariableById(t.getId(),p),o&&o(p)}else o&&o(null)})}s("")},yi=function(e,t,o){Si(e,t,function(s){s&&(s=s.replace(/[\s\xa0]+/g," ").trim(),s===H.RENAME_VARIABLE||s===H.NEW_VARIABLE)&&(s=null),o(s)})},zu=function(e,t,o){o=o.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let s=0,i;i=o[s];s++)if(i.name.toLowerCase()===e&&i.type!==t)return i;return null},qn=function(e,t){t=t.getVariableMap().getAllVariables(),e=e.toLowerCase();for(let o=0,s;s=t[o];o++)if(s.name.toLowerCase()===e)return s;return null},Zn=function(e,t,o){return o.getProcedureMap().getProcedures().length?Ju(e,t,o):qu(e,t,o)},Ju=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getProcedureMap().getProcedures();for(const i of o){var s=i.getParameters().filter(Yn).map(a=>a.getVariableModel().name);if(s&&(o=s.some(a=>a.toLowerCase()===e),s=s.some(a=>a.toLowerCase()===t),o&&s))return i.getName()}return null},qu=function(e,t,o){e=e.toLowerCase(),t=t.toLowerCase(),o=o.getAllBlocks(!1);for(const i of o){if(!gs(i))continue;o=i.getProcedureDef();var s=o[1];const a=s.some(p=>p.toLowerCase()===e);if(s=s.some(p=>p.toLowerCase()===t),a&&s)return o[0]}return null},Ho=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.type),e=bt(e.name),t.appendChild(e),t},ar=function(e,t,o,s){let i=cr(e,t,o,s);return i||(i=Zu(e,t,o,s)),i},cr=function(e,t,o,s){const i=e.getPotentialVariableMap();let a=null;if(t&&(a=e.getVariableById(t),!a&&i&&(a=i.getVariableById(t)),a))return a;if(o){if(s===void 0)throw Error("Tried to look up a variable by name without a type");a=e.getVariable(o,s),!a&&i&&(a=i.getVariable(o,s))}return a},Zu=function(e,t,o,s){const i=e.getPotentialVariableMap();return o||(o=zn(e.isFlyout?e.targetWorkspace:e)),i?i.createVariable(o,s,t):e.createVariable(o,s,t)},Ai=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.indexOf(i)===-1&&o.push(i)}return o},Qn=function(e,t){Ft(),fn=setTimeout(function(){t&&t.handleRightClick(e)},qg)},Ft=function(){fn&&(clearTimeout(fn),fn=0)},Ut=function(){mn=null},ur=function(e){return!e.type.startsWith("pointer")||e instanceof PointerEvent&&el(e)},$s=function(e){return`${e.pointerId}`},el=function(e){const t=$s(e);return mn?mn===t:e.type==="pointerdown"?(mn=t,!0):!1},Qu=function(e){if(_("setClientFromTouch()","version 9","version 10"),e.type.startsWith("touch")&&e.changedTouches){const t=e.changedTouches[0];e.clientX=t.clientX,e.clientY=t.clientY}},eh=function(e){return _("isMouseOrTouchEvent()","version 9","version 10"),e.type.startsWith("touch")||e.type.startsWith("mouse")||e.type.startsWith("pointer")},th=function(e){return _("isTouchEvent()","version 9","version 10"),e.type.startsWith("touch")||e.type.startsWith("pointer")},oh=function(e){_("splitEventByTouches()","version 9","version 10");const t=[];if(e.changedTouches)for(let o=0;o<e.changedTouches.length;o++)t[o]={type:e.type,changedTouches:[e.changedTouches[o]],target:e.target,stopPropagation(){e.stopPropagation()},preventDefault(){e.preventDefault()}};else t.push(e);return t},w=function(e,t,o,s,i,a){function p($){(i||ur($))&&(o?s.call(o,$):s($))}if(a!==void 0&&_("The opt_noPreventDefault argument of conditionalBind","version 9","version 10"),a=[],t in Qo)for(let $=0;$<Qo[t].length;$++){const v=Qo[t][$];e.addEventListener(v,p,!1),a.push([e,v,p])}else e.addEventListener(t,p,!1),a.push([e,t,p]);return a},Ye=function(e,t,o,s){function i(p){o?s.call(o,p):s(p)}const a=[];if(t in Qo)for(let p=0;p<Qo[t].length;p++){const $=Qo[t][p];e.addEventListener($,i,!1),a.push([e,$,i])}else e.addEventListener(t,i,!1),a.push([e,t,i]);return a},ce=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},hr=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},ro=function(e){return e.ctrlKey&&dc?!0:e.button===2},Vo=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)},dr=function(e){switch(e.deltaMode){default:return{x:e.deltaX,y:e.deltaY};case 1:return{x:e.deltaX*K_,y:e.deltaY*K_};case 2:return{x:e.deltaX*z_,y:e.deltaY*z_}}},Tt=function(e){if(pc)throw Error("CSS already injected");gc+=`
|
|
5
|
+
`+e},tl=function(e,t){pc||(pc=!0,e&&(e=t.replace(/[\\/]$/,""),t=gc.replace(/<<<PATH>>>/g,e),gc="",e=document.createElement("style"),e.id="blockly-common-style",t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},_r=function(e){return J_.getSizeInternal(e)},sh=function(e){if(Ht(e,"display")!=="none")return ol(e);const t=e.style,o=t.display,s=t.visibility,i=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";const a=e.offsetWidth;return e=e.offsetHeight,t.display=o,t.position=i,t.visibility=s,new Pe(a,e)},ol=function(e){return new Pe(e.offsetWidth,e.offsetHeight)},Ht=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},rh=function(e,t){return _("Blockly.utils.style.getCascadedStyle","version 9","version 10"),e.currentStyle?e.currentStyle[t]:""},Ro=function(e){const t=new L(0,0);e=e.getBoundingClientRect();var o=document.documentElement;return o=new L(window.pageXOffset||o.scrollLeft,window.pageYOffset||o.scrollTop),t.x=e.left+o.x,t.y=e.top+o.y,t},sl=function(){const e=document.body,t=document.documentElement;return new L(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},rl=function(e){const t=parseFloat(Ht(e,"borderLeftWidth")),o=parseFloat(Ht(e,"borderRightWidth")),s=parseFloat(Ht(e,"borderTopWidth"));return e=parseFloat(Ht(e,"borderBottomWidth")),new Se(s,e,t,o)},Li=function(e,t,o){e=il(e,t,o),t.scrollLeft=e.x,t.scrollTop=e.y},il=function(e,t,o){var s=Ro(e),i=Ro(t),a=rl(t);const p=s.x-i.x-a.left;return s=s.y-i.y-a.top,i=ol(e),e=t.clientWidth-i.width,i=t.clientHeight-i.height,a=t.scrollLeft,t=t.scrollTop,o?(a+=p-e/2,t+=s-i/2):(a+=Math.min(p,Math.max(p-e,0)),t+=Math.min(s,Math.max(s-i,0))),new L(a,t)},$t=function(e){const t=new L(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(q_))&&(t.x+=Number(o[1]),o[3]&&(t.y+=Number(o[3]))),(e=e.getAttribute("style"))&&-1<e.indexOf("translate")&&(e=e.match(Z_))&&(t.x+=Number(e[1]),e[3]&&(t.y+=Number(e[3]))),t},pr=function(e){let t=0,o=0;for(;e;){const s=$t(e);if(t+=s.x,o+=s.y,(" "+(e.getAttribute("class")||"")+" ").indexOf(" injectionDiv ")!==-1)break;e=e.parentNode}return new L(t,o)},nl=function(){return _("Blockly.utils.svgMath.is3dSupported","version 9","version 10"),!0},ki=function(){const e=sl();return new Se(e.y,document.documentElement.clientHeight+e.y,e.x,document.documentElement.clientWidth+e.x)},Di=function(){const e=document.documentElement,t=window;return new L(t.pageXOffset||e.scrollLeft,t.pageYOffset||e.scrollTop)},ll=function(e,t){var o=t.x;t=t.y;const s=e.getInjectionDiv().getBoundingClientRect();return o=new L(o-s.left,t-s.top),t=e.getOriginOffsetInPixels(),L.difference(o,t).scale(1/e.scale)},ih=function(e,t){const o=n.createElement$$module$build$src$core$utils$xml("xml");var s=al(vi(e));s.hasChildNodes()&&o.appendChild(s),s=e.getTopComments(!0);for(let i=0;i<s.length;i++)o.appendChild(s[i].toXmlWithXY(t));for(e=e.getTopBlocks(!0),s=0;s<e.length;s++)o.appendChild(gr(e[s],t));return o},al=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(bt(s.name)),s.type&&i.setAttribute("type",s.type),i.id=s.getId(),t.appendChild(i)}return t},gr=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=Io(e,t),dl(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},nh=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},lh=function(e,t){for(let o=0;o<e.inputList.length;o++){const s=e.inputList[o];for(let i=0;i<s.fieldRow.length;i++){const a=nh(s.fieldRow[i]);a&&t.appendChild(a)}}},Io=function(e,t){if(e.isInsertionMarker())return(t=e.getChildren(!1)[0])?Io(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(lh(e,o),s=e.getCommentText()){var i=e.commentModel.size,a=e.commentModel.pinned,p=n.createElement$$module$build$src$core$utils$xml("comment");p.appendChild(bt(s)),p.setAttribute("pinned",`${a}`),p.setAttribute("h",String(i.height)),p.setAttribute("w",String(i.width)),o.appendChild(p)}for(e.data&&(s=n.createElement$$module$build$src$core$utils$xml("data"),s.appendChild(bt(e.data)),o.appendChild(s)),s=0;s<e.inputList.length;s++){i=e.inputList[s];var $=void 0;if(a=!0,i.type!==X.DUMMY){p=i.connection.targetBlock(),i.type===X.VALUE?$=n.createElement$$module$build$src$core$utils$xml("value"):i.type===X.STATEMENT&&($=n.createElement$$module$build$src$core$utils$xml("statement"));const k=i.connection.getShadowDom();!k||p&&p.isShadow()||$.appendChild(cl(k,t)),p&&(p=Io(p,t),p.nodeType===Yt.ELEMENT_NODE&&($.appendChild(p),a=!1)),$.setAttribute("name",i.name),a||o.appendChild($)}}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","true"),e.isDeletable()||e.isShadow()||o.setAttribute("deletable","false"),e.isMovable()||e.isShadow()||o.setAttribute("movable","false"),e.isEditable()||o.setAttribute("editable","false"),$=e.getNextBlock();let v;return $&&(s=Io($,t),s.nodeType===Yt.ELEMENT_NODE&&(v=n.createElement$$module$build$src$core$utils$xml("next"),v.appendChild(s),o.appendChild(v))),e=e.nextConnection&&e.nextConnection.getShadowDom(),!e||$&&$.isShadow()||v.appendChild(cl(e,t)),o},cl=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===Yt.TEXT_NODE&&s.data.trim()===""&&((i=o)==null?void 0:i.firstChild)!==s&&re(s)}o&&(s=o,o=o.nextSibling,s.nodeType===Yt.TEXT_NODE&&s.data.trim()===""&&re(s))}return e},Vt=function(e){return bo(e).replace(/<(\w+)([^<]*)\/>/g,"<$1$2></$1>")},ah=function(e){e=Vt(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(`
|
|
6
|
+
`),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>"),e.replace(/^\n/,"")},ch=function(e){return _("Blockly.Xml.textToDom","version 9","version 10","Use Blockly.utils.xml.textToDom instead"),Ce(e)},uh=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=Es(e,t),t.setResizesEnabled(!0),e},Es=function(e,t){let o=0;t.RTL&&(o=t.getWidth());const s=[];Bt();const i=K();i||C(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);let a=!0;try{for(let p=0,$;$=e.childNodes[p];p++){const v=$.nodeName.toLowerCase(),k=$;if(v==="block"||v==="shadow"&&!tt()){const fe=Wo(k,t);s.push(fe.id);let be;const at=parseInt((be=k.getAttribute("x"))!=null?be:"10",10);let rr;const ir=parseInt((rr=k.getAttribute("y"))!=null?rr:"10",10);isNaN(at)||isNaN(ir)||fe.moveBy(t.RTL?o-at:at,ir),a=!1}else{if(v==="shadow")throw TypeError("Shadow block cannot be a top-level block.");if(v==="comment")t.rendered?Xe.fromXmlRendered(k,t,o):Kt.fromXml(k,t);else if(v==="variables"){if(a)ul(k,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.");a=!1}}}}finally{C(i),xt()}return t.setResizesEnabled&&t.setResizesEnabled(!0),x(new(F(ks))(t)),s},hh=function(e,t){if(!t.getBlocksBoundingBox)return Es(e,t);var o=t.getBlocksBoundingBox();if(e=Es(e,t),o&&o.top!==o.bottom){var s=o.bottom;o=t.RTL?o.right:o.left;var i=1/0;let a=-1/0,p=1/0;for(let $=0;$<e.length;$++){const v=t.getBlockById(e[$]).getRelativeToSurfaceXY();v.y<p&&(p=v.y),v.x<i&&(i=v.x),v.x>a&&(a=v.x)}for(s=s-p+10,o=t.RTL?o-a:o-i,i=0;i<e.length;i++)t.getBlockById(e[i]).moveBy(o,s)}return e},Wo=function(e,t){ve();var o=t.getAllVariables();let s;try{if(s=Mi(e,t),t.rendered){const i=s,a=s.getDescendants(!1);i.setConnectionTracking(!1);for(let p=a.length-1;0<=p;p--)a[p].initSvg();for(let p=a.length-1;0<=p;p--)a[p].render(!1);setTimeout(function(){i.disposed||i.setConnectionTracking(!0)},1),i.updateDisabled(),t.resizeContents()}else{const i=s.getDescendants(!1);for(let a=i.length-1;0<=a;a--)i[a].initModel()}}finally{Ie()}if(Oe()){for(e=Ai(t,o),t=0;t<e.length;t++)o=e[t],x(new(F(zo))(o));x(new(F(He))(s))}return s},ul=function(e,t){for(let s=0;s<e.children.length;s++){var o=e.children[s];const i=o.getAttribute("type"),a=o.getAttribute("id");if(o=o.textContent,!o)break;t.createVariable(o,i,a)}},dh=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!==Yt.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},_h=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},ph=function(e,t){for(let s=0;s<e.length;s++){var o=e[s];const i=o.textContent,a=o.getAttribute("pinned")==="true";let p;const $=parseInt((p=o.getAttribute("w"))!=null?p:"50",10);let v;if(o=parseInt((v=o.getAttribute("h"))!=null?v:"50",10),t.setCommentText(i),t.commentModel.pinned=a,isNaN($)||isNaN(o)||(t.commentModel.size=new Pe($,o)),a&&t.getCommentIcon&&!t.isInFlyout){const k=t;setTimeout(function(){k.getCommentIcon().setVisible(!0)},1)}}},gh=function(e,t){for(let o=0;o<e.length;o++)t.data=e[o].textContent},Th=function(e,t){for(let o=0;o<e.length;o++){const s=e[o],i=s.getAttribute("name");i?mh(t,i,s):console.warn(`Ignoring unnamed field in block ${t.type}`)}},hl=function(e){let t=null,o=null;for(let s=0;s<e.childNodes.length;s++){const i=e.childNodes[s];dl(i)&&(i.nodeName.toLowerCase()==="block"?t=i:i.nodeName.toLowerCase()==="shadow"&&(o=i))}return{childBlockElement:t,childShadowElement:o}},$h=function(e,t,o,s){for(let a=0;a<e.length;a++){var i=e[a];const p=i.getAttribute("name"),$=p?o.getInput(p):null;if(!$){console.warn("Ignoring non-existent input "+p+" in block "+s);break}if(i=hl(i),i.childBlockElement){if(!$.connection)throw TypeError("Input connection does not exist.");Mi(i.childBlockElement,t,$.connection,!1)}if(i.childShadowElement){let v;(v=$.connection)==null||v.setShadowDom(i.childShadowElement)}}},Eh=function(e,t,o){for(let s=0;s<e.length;s++){const i=hl(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.");Mi(i.childBlockElement,t,o.nextConnection,!0)}i.childShadowElement&&o.nextConnection&&o.nextConnection.setShadowDom(i.childShadowElement)}},Mi=function(e,t,o,s){var i;const a=e.getAttribute("type");if(!a)throw TypeError("Block type unspecified: "+e.outerHTML);var p=(i=e.getAttribute("id"))!=null?i:void 0;i=t.newBlock(a,p),p=dh(e);const $=_h(p.mutation,i);if(ph(p.comment,i),gh(p.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(Th(p.field,i),$h(p.input,t,i,a),Eh(p.next,t,i),$&&i.initSvg(),(t=e.getAttribute("inline"))&&i.setInputsInline(t==="true"),(t=e.getAttribute("disabled"))&&i.setEnabled(t!=="true"&&t!=="disabled"),(t=e.getAttribute("deletable"))&&i.setDeletable(t==="true"),(t=e.getAttribute("movable"))&&i.setMovable(t==="true"),(t=e.getAttribute("editable"))&&i.setEditable(t==="true"),(t=e.getAttribute("collapsed"))&&i.setCollapsed(t==="true"),e.nodeName.toLowerCase()==="shadow"){for(e=i.getChildren(!1),t=0;t<e.length;t++)if(!e[t].isShadow())throw TypeError("Shadow block not allowed non-shadow child.");if(i.getVarModels().length)throw TypeError("Shadow blocks cannot have variable references.");i.setShadow(!0)}return i},mh=function(e,t,o){const s=e.getField(t);s?s.fromXml(o):console.warn("Ignoring non-existent field "+t+" in block "+e.type)},fh=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}}},dl=function(e){return e.nodeType===Yt.ELEMENT_NODE},wi=function(e,t){r(A.SERIALIZER,e,t)},bh=function(e){he(A.SERIALIZER,e)},Wt=function(e,{addCoordinates:t=!1,addInputBlocks:o=!0,addNextBlocks:s=!0,doFullSerialization:i=!0}={}){if(e.isInsertionMarker())return null;const a={type:e.type,id:e.id};return t&&Ih(e,a),Rh(e,a),Oh(e,a),Sh(e,a),vh(e,a,i),o&&Ch(e,a,i),s&&Nh(e,a,i),a},Rh=function(e,t){e.isCollapsed()&&(t.collapsed=!0),e.isEnabled()||(t.enabled=!1),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)},Ih=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)},Oh=function(e,t){e.saveExtraState?(e=e.saveExtraState(),e!==null&&(t.extraState=e)):e.mutationToDom&&(e=e.mutationToDom(),e!==null&&(t.extraState=Vt(e).replace(' xmlns="https://developers.google.com/blockly/xml"',"")))},Sh=function(e,t){e.getCommentText()&&(t.icons={comment:{text:e.getCommentText(),pinned:e.commentModel.pinned,height:Math.round(e.commentModel.size.height),width:Math.round(e.commentModel.size.width)}})},vh=function(e,t,o){const s=Object.create(null);for(let i=0;i<e.inputList.length;i++){const a=e.inputList[i];for(let p=0;p<a.fieldRow.length;p++){const $=a.fieldRow[p];$.isSerializable()&&(s[$.name]=$.saveState(o))}}Object.keys(s).length&&(t.fields=s)},Ch=function(e,t,o){const s=Object.create(null);for(let i=0;i<e.inputList.length;i++){const a=e.inputList[i];if(a.type===X.DUMMY)continue;const p=_l(a.connection,o);p&&(s[a.name]=p)}Object.keys(s).length&&(t.inputs=s)},Nh=function(e,t,o){e.nextConnection&&(e=_l(e.nextConnection,o))&&(t.next=e)},_l=function(e,t){const o=e.getShadowState(!0);if(e=e.targetBlock(),!o&&!e)return null;const s=Object.create(null);return o&&(s.shadow=o),e&&!e.isShadow()&&(s.block=Wt(e,{doFullSerialization:t})),s},Oo=function(e,t,{recordUndo:o=!1}={}){return Gi(e,t,{recordUndo:o})},Gi=function(e,t,{parentConnection:o,isShadow:s=!1,recordUndo:i=!1}={}){const a=tt();We(i),(i=K())||C(!0),ve();const p=pl(e,t,{parentConnection:o,isShadow:s});return Ie(),x(new(F(He))(p)),C(i),We(a),t.rendered&&setTimeout(()=>{p.disposed||p.setConnectionTracking(!0)},1),p},pl=function(e,t,{parentConnection:o,isShadow:s=!1}={}){if(!e.type)throw new Q_(e);const i=t.newBlock(e.type,e.id);return i.setShadow(s),yh(i,e),Ah(i,e),Lh(i,e),kh(o,i,e),Dh(i,e),Mh(i,e),wh(i,e),Gh(i,e),Ph(i,t.rendered),i},yh=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)},Ah=function(e,t){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.setEnabled(!1),t.inline!==void 0&&e.setInputsInline(t.inline),t.data!==void 0&&(e.data=t.data)},Lh=function(e,t){t.extraState&&(e.loadExtraState?e.loadExtraState(t.extraState):e.domToMutation&&e.domToMutation(Ce(t.extraState)))},kh=function(e,t,o){if(e){if(e.getSourceBlock().isShadow()&&!t.isShadow())throw new tp(o);if(e.type===X.VALUE){var s=t.outputConnection;if(!s)throw new Vr("output",t,o)}else if(s=t.previousConnection,!s)throw new Vr("previous",t,o);if(!e.connect(s)){const i=t.workspace.connectionChecker;throw new ep(i.getErrorMessage(i.canConnectWithReason(s,e,!1),s,e),e.type===X.VALUE?"output connection":"previous connection",t,o)}}},Dh=function(e,t){t.icons&&(t=t.icons.comment)&&(e.setCommentText(t.text),"pinned"in t&&(e.commentModel.pinned=t.pinned),"width"in t&&"height"in t&&(e.commentModel.size=new Pe(t.width,t.height)),t.pinned&&e.rendered&&!e.isInFlyout&&setTimeout(()=>e.getCommentIcon().setVisible(!0),1))},Mh=function(e,t){if(t.fields){var o=Object.keys(t.fields);for(let s=0;s<o.length;s++){const i=o[s],a=t.fields[i],p=e.getField(i);p?p.loadState(a):console.warn(`Ignoring non-existant field ${i} in block ${e.type}`)}}},wh=function(e,t){if(t.inputs){var o=Object.keys(t.inputs);for(let s=0;s<o.length;s++){const i=o[s],a=e.getInput(i);if(!a||!a.connection)throw new Vr(i,e,t);gl(a.connection,t.inputs[i])}}},Gh=function(e,t){if(t.next){if(!e.nextConnection)throw new Vr("next",e,t);gl(e.nextConnection,t.next)}},gl=function(e,t){t.shadow&&e.setShadowState(t.shadow),t.block&&pl(t.block,e.getSourceBlock().workspace,{parentConnection:e})},Ph=function(e,t){if(t)for(e.setConnectionTracking(!1),e.initSvg(),e.render(!1),e=e.getIcons(),t=0;t<e.length;t++)e[t].computeIconLocation();else e.initModel()},Bh=function(e,t){if(!e||!t)throw Error("Cannot connect null connections.");e.targetConnection=t,t.targetConnection=e},xh=function(e,t){let o=null;t=t.outputConnection;const s=t==null?void 0:t.getConnectionChecker();for(let i=0,a;a=e.inputList[i];i++){const p=a.connection;let $;if(p&&(($=s)!=null&&$.canConnect(t,p,!1))){if(o)return null;o=p}}return o},Fh=function(e,t){let o;for(;o=xh(e,t);)if(e=o.targetBlock(),!e||e.isShadow())return o;return null},ms=function(e){return e*Math.PI/180},Tl=function(e){return 180*e/Math.PI},fs=function(e,t,o){if(o<e){const s=o;o=e,e=s}return Math.max(e,Math.min(t,o))},$l=function(){ne||(ne=document.createElement("div"),ne.className="blocklyDropDownDiv",($o()||document.body).appendChild(ne),Hs=document.createElement("div"),Hs.className="blocklyDropDownContent",ne.appendChild(Hs),os=document.createElement("div"),os.className="blocklyDropDownArrow",ne.appendChild(os),ne.style.opacity="0",ne.style.transition="transform "+Nn+"s, opacity "+Nn+"s",ne.addEventListener("focusin",function(){U(ne,"blocklyFocused")}),ne.addEventListener("focusout",function(){se(ne,"blocklyFocused")}))},El=function(e){Oc=e},ml=function(){return ko},bs=function(){return Hs},Pi=function(){Hs.textContent="",Hs.style.width=""},Bi=function(e,t){ne.style.backgroundColor=e,ne.style.borderColor=t},Uh=function(e,t,o,s){return Rl(fl(t),e,o,s)},Tr=function(e,t,o){return cp=!0,Rl(bl(e),e,t,o)},fl=function(e){var t=e.getSvgRoot();const o=e.workspace.scale,s=e.height*o;return e=e.width*o,t=Ro(t),new Se(t.y,t.y+s,t.x,t.x+e)},bl=function(e){return e=e.getScaledBBox(),new Se(e.top,e.bottom,e.left,e.right)},Rl=function(e,t,o,s){const i=e.left+(e.right-e.left)/2,a=e.bottom;e=e.top,s&&(e+=s),s=t.getSourceBlock();let p=s.workspace;for(;p.options.parentWorkspace;)p=p.options.parentWorkspace;return El(p.getParentSvg().parentNode),Il(t,s.RTL,i,a,i,e,o)},Il=function(e,t,o,s,i,a,p){return ko=e,ts=p||null,ne.style.direction=t?"rtl":"ltr",e=Y(),Fs=e.getRenderer().getClassName(),Us=e.getTheme().getClassName(),Fs&&U(ne,Fs),Us&&U(ne,Us),Cl(o,s,i,a)},Ol=function(e,t,o,s){return e=$r(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t,finalX:e.divX,finalY:t+Rc,arrowX:e.arrowX,arrowY:-(Xr/2+bc),arrowAtTop:!0,arrowVisible:!0}},Sl=function(e,t,o,s){return e=$r(e,o.left,o.right,s.width),{initialX:e.divX,initialY:t-s.height,finalX:e.divX,finalY:t-s.height-Rc,arrowX:e.arrowX,arrowY:s.height-2*bc-Xr/2,arrowAtTop:!1,arrowVisible:!0}},Hh=function(e,t,o){return e=$r(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}},$r=function(e,t,o,s){return t=fs(t,e-s/2,o-s),e=e-Xr/2-t,o=ap,e=fs(o,e,s-o-Xr),{arrowX:e,divX:t}},vl=function(){return!!ko},Rs=function(e,t){return ko===e?(t?It():xi(),!0):!1},xi=function(){ne.style.transform="translate(0, 0)",ne.style.opacity="0",Ic=setTimeout(function(){It()},1e3*Nn),ts&&(ts(),ts=null)},It=function(){vl()&&(Ic&&clearTimeout(Ic),ne.style.transform="",ne.style.left="",ne.style.top="",ne.style.opacity="0",ne.style.display="none",ne.style.backgroundColor="",ne.style.borderColor="",ts&&(ts(),ts=null),Pi(),ko=null,Fs&&(se(ne,Fs),Fs=""),Us&&(se(ne,Us),Us=""),Y().markFocused())},Cl=function(e,t,o,s){e=Sc.getPositionMetrics(e,t,o,s),e.arrowVisible?(os.style.display="",os.style.transform="translate("+e.arrowX+"px,"+e.arrowY+"px) rotate(45deg)",os.setAttribute("class",e.arrowAtTop?"blocklyDropDownArrow blocklyArrowTop":"blocklyDropDownArrow blocklyArrowBottom")):os.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 ne.style.left=t+"px",ne.style.top=o+"px",ne.style.display="block",ne.style.opacity="1",ne.style.transform="translate("+(s-t)+"px,"+(i-o)+"px)",!!e.arrowAtTop},Vh=function(){if(ko){var e=ko.getSourceBlock();e=cp?bl(ko):fl(e);const t=e.left+(e.right-e.left)/2;Cl(t,e.bottom,t,e.top)}else xi()},Wh=function(e,t){return _("Blockly.utils.string.startsWith()","April 2022","April 2023","Use built-in string.startsWith"),e.startsWith(t)},Er=function(e){return e.length?e.reduce(function(t,o){return t.length<o.length?t:o}).length:0},Nl=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||Er(e);let s;for(s=0;s<t;s++){for(var i=e[0][s],a=1;a<e.length;a++)if(i!==e[a][s])return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((a=e[i][s])&&a!==" ")return o;return t},yl=function(e,t){if(!e.length)return 0;if(e.length===1)return e[0].length;let o=0;t=t||Er(e);let s;for(s=0;s<t;s++){for(var i=e[0].substr(-s-1,1),a=1;a<e.length;a++)if(i!==e[a].substr(-s-1,1))return o;i===" "&&(o=s+1)}for(i=1;i<e.length;i++)if((a=e[i].charAt(e[i].length-s-1))&&a!==" ")return o;return t},Al=function(e,t){e=e.split(`
|
|
7
|
+
`);for(let o=0;o<e.length;o++)e[o]=Xh(e[o],t);return e.join(`
|
|
8
|
+
`)},Xh=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 a,p=1;do{s=i,a=e,e=[],i=o.length/p;let $=1;for(let v=0;v<o.length-1;v++)$<(v+1.5)/i?($++,e[v]=!0):e[v]=!1;e=Ll(o,e,t),i=Fi(o,e,t),e=jh(o,e),p++}while(i>s);return a},Fi=function(e,t,o){const s=[0],i=[];for(var a=0;a<e.length;a++)s[s.length-1]+=e[a].length,t[a]===!0?(s.push(0),i.push(e[a].charAt(e[a].length-1))):t[a]===!1&&s[s.length-1]++;for(e=Math.max(...s),t=0,a=0;a<s.length;a++)t-=2*Math.pow(Math.abs(o-s[a]),1.5),t-=Math.pow(e-s[a],1.5),".?!".indexOf(i[a])!==-1?t+=o/3:",;)]}".indexOf(i[a])!==-1&&(t+=o/4);return 1<s.length&&s[s.length-1]<=s[s.length-2]&&(t+=.5),t},Ll=function(e,t,o){let s=Fi(e,t,o),i;for(let a=0;a<t.length-1;a++){if(t[a]===t[a+1])continue;const p=[].concat(t);p[a]=!p[a],p[a+1]=!p[a+1];const $=Fi(e,p,o);$>s&&(s=$,i=p)}return i?Ll(e,i,o):t},jh=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]?`
|
|
9
|
+
`:" ");return o.join("")},kl=function(e){return/^\s*-?\d+(\.\d+)?\s*$/.test(e)},Yh=function(e){yn=e},Kh=function(){return yn},zh=function(){return Yr},Jh=function(){return ke},Is=function(e){if(e=Dl(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""},Dl=function(e){for(;e&&e.tooltip;){if(typeof e.tooltip=="string"||typeof e.tooltip=="function")return e;e=e.tooltip}return null},Ml=function(){ke||(ke=document.createElement("div"),ke.className="blocklyTooltipDiv",($o()||document.body).appendChild(ke))},mr=function(e){e.mouseOverWrapper_=Ye(e,"pointerover",null,qh),e.mouseOutWrapper_=Ye(e,"pointerout",null,Zh),e.addEventListener("pointermove",Gl,!1)},wl=function(e){e&&(ce(e.mouseOverWrapper_),ce(e.mouseOutWrapper_),e.removeEventListener("pointermove",Gl))},qh=function(e){Vs||(e=Dl(e.currentTarget),Et!==e&&(So(),Kr=null,Et=e),clearTimeout(hp))},Zh=function(e){Vs||(hp=setTimeout(function(){Kr=Et=null,So()},1),clearTimeout(ss),ss=0)},Gl=function(e){if(Et&&Et.tooltip&&!Vs)if(Yr){const t=vc-e.pageX;e=Cc-e.pageY,Math.sqrt(t*t+e*e)>dp&&So()}else Kr!==Et&&(clearTimeout(ss),vc=e.pageX,Cc=e.pageY,ss=setTimeout(od,_p))},Pl=function(){Kr=Et=null,So()},So=function(){Yr&&(Yr=!1,ke&&(ke.style.display="none")),ss&&(clearTimeout(ss),ss=0)},Bl=function(){So(),Vs=!0},xl=function(){Vs=!1},Qh=function(){ke&&Et&&(typeof yn=="function"?yn(ke,Et):ed())},ed=function(){var e=Is(Et);e=Al(e,up),e=e.split(`
|
|
10
|
+
`);for(let t=0;t<e.length;t++){const o=document.createElement("div");o.appendChild(document.createTextNode(e[t])),ke.appendChild(o)}},td=function(e){const t=document.documentElement.clientWidth,o=document.documentElement.clientHeight;let s=vc;s=e?s-(Nc+ke.offsetWidth):s+Nc;let i=Cc+yc;return i+ke.offsetHeight>o+window.scrollY&&(i-=ke.offsetHeight+2*yc),e?s=Math.max(An-window.scrollX,s):s+ke.offsetWidth>t+window.scrollX-2*An&&(s=t-ke.offsetWidth-2*An),{x:s,y:i}},od=function(){if(!Vs&&(Kr=Et,ke)){ke.textContent="",Qh();var e=Et.RTL;ke.style.direction=e?"rtl":"ltr",ke.style.display="block",Yr=!0;var{x:t,y:o}=td(e);ke.style.left=t+"px",ke.style.top=o+"px"}},Fl=function(){return Ac},sd=function(e){Ac=e},Ul=function(){return Lc},rd=function(e){Lc=e},vo=function(e){e=`${e}`.toLowerCase().trim();var t=pp[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]),0<=e&&256>e&&0<=t&&256>t&&0<=o&&256>o)?fr(e,t,o):null},fr=function(e,t,o){return t=e<<16|t<<8|o,16>e?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},Ui=function(e){return e=vo(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},Hi=function(e,t,o){let s=0,i=0,a=0;if(t===0)a=i=s=o;else{const p=Math.floor(e/60),$=e/60-p;e=o*(1-t);const v=o*(1-t*$);switch(t=o*(1-t*(1-$)),p){case 1:s=v,i=o,a=e;break;case 2:s=e,i=o,a=t;break;case 3:s=e,i=v,a=o;break;case 4:s=t,i=e,a=o;break;case 5:s=o,i=e,a=v;break;case 6:case 0:s=o,i=t,a=e}}return fr(Math.floor(s),Math.floor(i),Math.floor(a))},Xo=function(e,t,o){return e=vo(e),!e||(t=vo(t),!t)?null:(e=Ui(e),t=Ui(t),fr(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]))))},Vi=function(e){return Hi(e,Ac,255*Lc)},Wi=function(e,t){const o=[];var s=e.split("");s.push("");var i=0;e=[];let a=null;for(let v=0;v<s.length;v++){var p=s[v];if(i===0)p==="%"?((i=e.join(""))&&o.push(i),e.length=0,i=1):e.push(p);else if(i===1)p==="%"?(e.push(p),i=0):t&&"0"<=p&&"9">=p?(i=2,a=p,(p=e.join(""))&&o.push(p),e.length=0):p==="{"?i=3:(e.push("%",p),i=0);else if(i===2)if("0"<=p&&"9">=p)a+=p;else{var $=void 0;o.push(parseInt(($=a)!=null?$:"",10)),v--,i=0}else i===3&&(p===""?(e.splice(0,0,"%{"),v--,i=0):p!=="}"?e.push(p):(i=e.join(""),/[A-Z]\w*/i.test(i)?(p=i.toUpperCase(),(p=p.startsWith("BKY_")?p.substring(4):null)&&p in H?(i=H[p],typeof i=="string"?Array.prototype.push.apply(o,Wi(i,t)):t?o.push(`${i}`):o.push(i)):o.push("%{"+i+"}")):o.push("%{"+i+"}"),i=e.length=0))}for((t=e.join(""))&&o.push(t),$=[],e.length=0,s=0;s<o.length;s++)typeof o[s]=="string"?e.push(o[s]):((t=e.join(""))&&$.push(t),e.length=0,$.push(o[s]));return(t=e.join(""))&&$.push(t),e.length=0,$},Xi=function(e){return Wi(e,!0)},Ee=function(e){return typeof e!="string"?e:(e=Wi(e,!1),e.length?String(e[0]):"")},br=function(e){let t=!0;const o=H,s=e.match(/%{BKY_[A-Z]\w*}/ig);if(s)for(let i=0;i<s.length;i++){const a=s[i].toUpperCase();o[a.slice(6,-1)]===void 0&&(console.warn("No message string for "+s[i]+" in "+e),t=!1)}return t},jo=function(e){const t=typeof e=="string"?Ee(e):e;var o=Number(t);if(!isNaN(o)&&0<=o&&360>=o)return{hue:o,hex:Hi(o,Fl(),255*Ul())};if(o=vo(t))return{hue:null,hex:o};throw o='Invalid colour: "'+t+'"',e!==t&&(o+=' (from "'+e+'")'),Error(o)},Yo=function(){return At},id=function(e){At=e},Hl=function(){At||(At=document.createElement("div"),At.className="blocklyWidgetDiv",($o()||document.body).appendChild(At))},ji=function(e,t,o){Ot(),Ln=e,kn=o,(e=At)&&(e.style.direction=t?"rtl":"ltr",e.style.display="block",t=Y(),Ws=t.getRenderer().getClassName(),Xs=t.getTheme().getClassName(),Ws&&U(e,Ws),Xs&&U(e,Xs))},Ot=function(){if(Vl()){Ln=null;var e=At;e&&(e.style.display="none",e.style.left="",e.style.top="",kn&&kn(),kn=null,e.textContent="",Ws&&(se(e,Ws),Ws=""),Xs&&(se(e,Xs),Xs=""),Y().markFocused())}},Vl=function(){return!!Ln},Yi=function(e){Ln===e&&Ot()},Wl=function(e,t,o){At.style.left=e+"px",At.style.top=t+"px",At.style.height=o+"px"},Xl=function(e,t,o,s){const i=ld(e,t,o);e=nd(e,t,o,s),0>i?Wl(e,0,o.height+i):Wl(e,i,o.height)},nd=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)},ld=function(e,t,o){return t.bottom+o.height>=e.bottom?t.top-o.height:t.bottom},ut=function(e,t){r(A.FIELD,e,t)},ad=function(e){he(A.FIELD,e)},Ki=function(e){return kc.fromJsonInternal(e)},cd=function(e){const t=d(A.FIELD,e.type);if(t){if(typeof t.fromJson!="function")throw new TypeError("returned Field was not a IRegistrableField");return t.fromJson(e)}return 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},St=function(e,t){e.setAttribute(oT,t)},ge=function(e,t,o){Array.isArray(o)&&(o=o.join(" ")),e.setAttribute(tT+t,`${o}`)},ud=function(e){let t=!1;const o=e.map(([p,$])=>typeof p=="string"?[Ee(p),$]:(t=!0,[p.alt!==null?Object.assign({},p,{alt:Ee(p.alt)}):Object.assign({},p),$]));if(t||2>e.length)return{options:o};var s=o.map(([p])=>p),i=Er(s);e=Nl(s,i);const a=yl(s,i);return!e&&!a||i<=e+a?{options:o}:(i=e?s[0].substring(0,e-1):void 0,s=a?s[0].substr(1-a):void 0,{options:hd(o,e,a),prefix:i,suffix:s})},hd=function(e,t,o){return e.map(([s,i])=>[s.substring(t,s.length-o),i])},jl=function(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)?typeof s[1]!="string"?(t=!0,console.error("Invalid option["+o+"]: Each FieldDropdown option id must be a string. Found "+s[1]+" in: ",s)):s[0]&&typeof s[0]!="string"&&typeof s[0].src!="string"&&(t=!0,console.error("Invalid option["+o+"]: Each FieldDropdown option must have a string label or image description. Found"+s[0]+" in: ",s)):(t=!0,console.error("Invalid option["+o+"]: Each FieldDropdown option must be an array. Found: ",s))}if(t)throw TypeError("Found invalid FieldDropdown options.")},dd=function(e,t){_("Blockly.utils.object.inherits","version 9","version 10"),e.superClass_=t.prototype,Object.setPrototypeOf(e,t),e.prototype=Object.create(t.prototype),e.prototype.constructor=e},_d=function(e,t){_("Blockly.utils.object.mixin","May 2022","May 2023","Object.assign");for(const o in t)e[o]=t[o]},io=function(e,t){for(const o in t)e[o]=t[o]!==null&&typeof t[o]=="object"?io(e[o]||Object.create(null),t[o]):t[o];return e},pd=function(e){return _("Blockly.utils.object.values","version 9","version 10","Object.values"),Object.values(e)},Rr=function(e){return e?((e instanceof Element||typeof e=="string")&&(e=Kl(e),e=$d(e)),gd(e),e):null},gd=function(e){const t=e.kind;if(e=e.contents,t&&t!==Tp&&t!==Bc)throw Error("Invalid toolbox kind "+t+". Please supply either "+Tp+" or "+Bc);if(!e)throw Error("Toolbox must have a contents attribute.")},Ir=function(e){return e?e.contents?e.contents:Array.isArray(e)&&0<e.length&&!e[0].nodeType?e:qi(e):[]},zi=function(e){return $p.hasCategoriesInternal(e)},Td=function(e){if(!e)return!1;const t=e.kind;return t?t===Bc:!!e.contents.filter(function(o){return o.kind.toUpperCase()==="CATEGORY"}).length},Ji=function(e){return e&&e.contents?!!e.contents.filter(function(t){return t.kind.toUpperCase()==="CATEGORY"}).length:!1},$d=function(e){const t={contents:qi(e)};return e instanceof Node&&Yl(e,t),t},qi=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 a=i.tagName.toUpperCase();e.kind=a,a==="BLOCK"?e.blockxml=i:i.childNodes&&0<i.childNodes.length&&(e.contents=qi(i)),Yl(i,e),t.push(e)}return t},Yl=function(e,t){for(let o=0;o<e.attributes.length;o++){const s=e.attributes[o];-1<s.nodeName.indexOf("css-")?(t.cssconfig=t.cssconfig||{},t.cssconfig[s.nodeName.replace("css-","")]=s.value):t[s.nodeName]=s.value}},Kl=function(e){let t=null;if(e)if(typeof e=="string"){if(t=Ce(e),t.nodeName.toLowerCase()!=="xml")throw TypeError("Toolbox should be an <xml> document.")}else e instanceof Element&&(t=e);return t},n.register$$module$build$src$core$extensions=function(e,t){if(typeof e!="string"||e.trim()==="")throw Error('Error: Invalid extension name "'+e+'"');if(js[e])throw Error('Error: Extension "'+e+'" is already registered.');if(typeof t!="function")throw Error('Error: Extension "'+e+'" must be a function');js[e]=t},Ed=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+'": ';ql(i,t);const a=Jl(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(){a&&this.setMutator(new n.Mutator$$module$build$src$core$mutator(s||[],this)),this.mixin(t),o&&o.apply(this)})},md=function(e){zl(e)?delete js[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')},zl=function(e){return!!js[e]},Zi=function(e,t,o){const s=js[e];if(typeof s!="function")throw Error('Error: Extension "'+e+'" not found.');let i;if(o?fd(e,t):i=en(t),s.apply(t),o)ql('Error after applying mutator "'+e+'": ',t);else if(!Id(i,t))throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')},fd=function(e,t){if(en(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)},bd=function(e,t){return Qi(e.mutationToDom,e.domToMutation,t+" mutationToDom/domToMutation")},Rd=function(e,t){return Qi(e.saveExtraState,e.loadExtraState,t+" saveExtraState/loadExtraState")},Jl=function(e,t){return Qi(e.compose,e.decompose,t+" compose/decompose")},Qi=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")},ql=function(e,t){const o=bd(t,e),s=Rd(t,e);if(!o&&!s)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");Jl(t,e)},en=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},Id=function(e,t){if(t=en(t),t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(e[o]!==t[o])return!1;return!0},Or=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 typeof document=="object"&&Or(function(){for(const s in t)br(t[s])}),function(){this.type&&o.indexOf(this.type)===-1&&(Od(this,e,t),o.push(this.type)),this.setTooltip((function(){var s=String(this.getFieldValue(e));let i=t[s];return i===null?o.indexOf(this.type)===-1&&(s="No tooltip mapping for value "+s+" of field "+e,this.type!==null&&(s+=" of block type "+this.type),console.warn(s+".")):i=Ee(i),i}).bind(this))}},Od=function(e,t,o){var s=e.getField(t);if(s instanceof Jt&&!s.isOptionListDynamic()){s=s.getOptions();for(let i=0;i<s.length;i++){const a=s[i][1];o[a]===null&&console.warn("No tooltip mapping for value "+a+" of field "+t+" of block type "+e.type)}}},n.buildTooltipWithFieldText$$module$build$src$core$extensions=function(e,t){return typeof document=="object"&&Or(function(){br(e)}),function(){this.setTooltip((function(){const o=this.getField(t);return Ee(e).replace("%1",o?o.getText():"")}).bind(this))}},Sd=function(){const e=this.tooltip;this.setTooltip((function(){const t=this.getParent();return t&&t.getInputsInline()&&t.tooltip||e}).bind(this))},Ke=function(e,t){return t=e.indexOf(t),t===-1?!1:(e.splice(t,1),!0)},Zl=function(e){if(!(100<e.getDescendants(!1).length)){var t=e.workspace,o=e.getSvgRoot();t.getAudioManager().play("delete");var s=t.getSvgXY(o);o=o.cloneNode(!0),o.setAttribute("transform","translate("+s.x+","+s.y+")"),t.getParentSvg().appendChild(o),Ql(o,{x:s.x,y:s.y,width:e.width,height:e.height},t.RTL,new Date,t.scale)}},Ql=function(e,t,o,s,i){const a=(new Date().getTime()-s.getTime())/150;1<a?re(e):(e.setAttribute("transform","translate("+(t.x+(o?-1:1)*t.width*i/2*a)+","+(t.y+t.height*i*a)+") scale("+(1-a)*i+")"),setTimeout(Ql,10,e,t,o,s,i))},ea=function(e){const t=e.workspace,o=t.scale;if(t.getAudioManager().play("click"),!(1>o)){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),e=I(f.CIRCLE,{cx:s.x,cy:s.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg()),ta(e,new Date,o)}},ta=function(e,t,o){const s=(new Date().getTime()-t.getTime())/150;1<s?re(e):(e.setAttribute("r",String(25*s*o)),e.style.opacity=String(1-s),Zr=setTimeout(ta,10,e,t,o))},oa=function(e){if(Os(),e.workspace.getAudioManager().play("disconnect"),!(1>e.workspace.scale)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),Qr=e,sa(e,t,new Date)}},sa=function(e,t,o){const s=(new Date().getTime()-o.getTime())/200;let i="";1>=s&&(i=`skewX(${Math.round(Math.sin(s*Math.PI*3)*(1-s)*t)})`,Zr=setTimeout(sa,10,e,t,o)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${i}`)},Os=function(){Qr&&(Zr&&(clearTimeout(Zr),Zr=null),Qr.getSvgRoot().setAttribute("transform",Qr.getTranslation()),Qr=null)},Sr=function(e,t,o){const s=o.getBoundingRectangle(),i=s.right-s.left,a=fs(t.top,s.top,t.top+t.height-(s.bottom-s.top))-s.top;let p=t.left;return t=t.left+t.width-i,e.RTL?p=Math.min(t,p):t=Math.max(p,t),(e=fs(p,s.left,t)-s.left)||a?(o.moveBy(e,a),!0):!1},ra=function(e){return t=>{var o=e.getMetricsManager();if(o.hasFixedEdges()&&!e.isDragging()){var s;if(tc.indexOf((s=t.type)!=null?s:"")!==-1){s=o.getScrollMetrics(!0);const i=vd(e,t);i&&(o=K()||!1,C(t.group),Sr(e,s,i)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),C(o))}else t.type===Jo&&t.scale&&t.oldScale&&t.scale>t.oldScale&&tn(e)}}},vd=function(e,t){let o=null;switch(t.type){case He:case ze:(o=e.getBlockById(t.blockId))&&(o=o.getRootBlock());break;case qo:case ao:o=e.getCommentById(t.commentId)}return o},tn=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++)Sr(e,t,i)}},Cd=function(e){const t=[];e=e.getDescendants(!1);for(let o=0,s;s=e[o];o++){const i=s.getIcons();for(let a=0;a<i.length;a++){const p={location:i[a].getIconLocation(),icon:i[a]};t.push(p)}}return t},Ss=function(e){Uc.copyInternal(e)},Nd=function(e){_o=e.toCopyData()},on=function(){if(!_o)return null;let e=_o.source;return e.isFlyout&&(e=e.targetWorkspace),_o.typeCounts&&e.isCapacityAvailable(_o.typeCounts)?e.paste(_o.saveInfo):null},vr=function(e){return Uc.duplicateInternal(e)},yd=function(e){const t=_o;Ss(e);let o,s,i;return e=(i=(o=e.toCopyData())==null||(s=o.source)==null?void 0:s.paste(_o.saveInfo))!=null?i:null,_o=t,e},Ad=function(){return oi},ia=function(e){oi=e},Cr=function(e,t,o){if(ji(Hc,o,na),t.length){var s=Ld(t,o);si=s,kd(s,e,o),setTimeout(function(){s.focus()},1),oi=null}else Nr()},Ld=function(e,t){const o=new Dc;o.setRole(lt.MENU);for(let s=0;s<e.length;s++){const i=e[s],a=new Mc(i.text);a.setRightToLeft(t),a.setRole(lt.MENUITEM),o.addChild(a),a.setEnabled(i.enabled),i.enabled&&a.onAction(function(){Nr(),requestAnimationFrame(()=>{setTimeout(()=>{i.callback(i.scope)},0)})},{})}return o},kd=function(e,t,o){const s=ki();t=new Se(t.clientY+s.top,t.clientY+s.top,t.clientX+s.left,t.clientX+s.left),Dd(e);const i=e.getSize();o&&(t.left+=i.width,t.right+=i.width,s.left+=i.width,s.right+=i.width),Xl(s,t,i,o),e.focus()},Dd=function(e){var t=Yo();if(!t)throw Error("Attempting to create a context menu when widget div is null");t=e.render(t),U(t,"blocklyContextMenu"),w(t,"contextmenu",null,Md),e.focus()},Md=function(e){e.preventDefault(),e.stopPropagation()},Nr=function(){Yi(Hc),oi=null},na=function(){si&&(si.dispose(),si=null)},wd=function(e,t){return()=>{ve();let o;try{o=Wo(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+=2*n.config$$module$build$src$core$config.snapRadius,o.moveBy(s.x,s.y)}finally{Ie()}Oe()&&!o.isShadow()&&x(new(F(He))(o)),o.select()}},la=function(e){return{text:H.REMOVE_COMMENT,enabled:!0,callback:function(){C(!0),e.dispose(),C(!1)}}},aa=function(e){return{text:H.DUPLICATE_COMMENT,enabled:!0,callback:function(){vr(e)}}},Gd=function(e,t){const o={enabled:!0};return o.text=H.ADD_COMMENT,o.callback=function(){const s=new Xe(e,H.WORKSPACE_COMMENT_DEFAULT_TEXT,Xe.DEFAULT_SIZE,Xe.DEFAULT_SIZE);var i=e.getInjectionDiv().getBoundingClientRect();i=new L(t.clientX-i.left,t.clientY-i.top);const a=e.getOriginOffsetInPixels();i=L.difference(i,a),i.scale(1/e.scale),s.moveBy(i.x,i.y),e.rendered&&(s.initSvg(),s.render(),s.select())},o},yr=function(e){let t=e.outputConnection;return(!t||e.previousConnection&&e.previousConnection.isConnected())&&(t=e.previousConnection),t},P=function(e,t){return" "+e+","+t+" "},ot=function(e,t){return" "+e+t.join("")},Ue=function(e,t){return" M "+e+","+t+" "},Te=function(e,t){return" m "+e+","+t+" "},Xt=function(e,t){return" l "+e+","+t+" "},vs=function(e){return" l"+e.join("")},D=function(e,t){return" "+e+" "+t+" "},Ne=function(e,t,o,s){return e+" "+o+" "+o+" "+t+s},Pd=function(e){ca(e),Yc||(Yc=window.requestAnimationFrame(Bd))},ca=function(e){Pn.add(e);const t=e.getParent();t?ca(t):Gn.add(e)},Bd=function(){const e=new Set([...Gn].map(t=>t.workspace));for(const t of Gn)t.isDisposed()||t.getParent()||(ua(t),ha(t,t.getRelativeToSurfaceXY()));for(const t of e)t.resizeContents();Gn.clear(),Pn=new Set,Yc=0},ua=function(e){if(Pn.has(e)){for(const t of e.getChildren(!1))ua(t);e.renderEfficiently()}},ha=function(e,t){for(const o of e.getConnections_(!1)){e=o.moveToOffset(t);const s=o.targetBlock();o.isSuperior()&&s&&(e||Pn.has(s))&&ha(s,L.sum(t,s.relativeCoords))}},da=function(){le.registry.register({displayText(){return H.UNDO},preconditionFn(e){return 0<e.workspace.getUndoStack().length?"enabled":"disabled"},callback(e){e.workspace.undo(!1)},scopeType:le.ScopeType.WORKSPACE,id:"undoWorkspace",weight:1})},_a=function(){le.registry.register({displayText(){return H.REDO},preconditionFn(e){return 0<e.workspace.getRedoStack().length?"enabled":"disabled"},callback(e){e.workspace.undo(!0)},scopeType:le.ScopeType.WORKSPACE,id:"redoWorkspace",weight:2})},pa=function(){le.registry.register({displayText(){return H.CLEAN_UP},preconditionFn(e){return e.workspace.isMovable()?1<e.workspace.getTopBlocks(!1).length?"enabled":"disabled":"hidden"},callback(e){e.workspace.cleanUp()},scopeType:le.ScopeType.WORKSPACE,id:"cleanWorkspace",weight:3})},ga=function(e,t){function o(a){i--,a.setCollapsed(e),i===0&&C(!1)}let s=0,i=0;C(!0);for(let a=0;a<t.length;a++){let p=t[a];for(;p;)i++,setTimeout(o.bind(null,p),s),p=p.getNextBlock(),s+=10}},Ta=function(){le.registry.register({displayText(){return H.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){ga(!0,e.workspace.getTopBlocks(!0))},scopeType:le.ScopeType.WORKSPACE,id:"collapseWorkspace",weight:4})},$a=function(){le.registry.register({displayText(){return H.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){ga(!1,e.workspace.getTopBlocks(!0))},scopeType:le.ScopeType.WORKSPACE,id:"expandWorkspace",weight:5})},Ea=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++)Ea(e[o],t)}},sn=function(e){const t=[];e=e.getTopBlocks(!0);for(let o=0;o<e.length;o++)Ea(e[o],t);return t},Ar=function(e,t){t?C(t):(C(!0),t=K());const o=e.shift();o&&(o.isDeadOrDying()?Ar(e,t):(o.dispose(!1,!0),setTimeout(Ar,10,e,t))),C(!1)},ma=function(){le.registry.register({displayText(e){return e.workspace?(e=sn(e.workspace).length,e===1?H.DELETE_BLOCK:H.DELETE_X_BLOCKS.replace("%1",`${e}`)):""},preconditionFn(e){return e.workspace&&0<sn(e.workspace).length?"enabled":"disabled"},callback(e){if(e.workspace){e.workspace.cancelCurrentGesture();var t=sn(e.workspace);2>t.length?Ar(t):te(H.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),function(o){o&&Ar(t)})}},scopeType:le.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},xd=function(){da(),_a(),pa(),Ta(),$a(),ma()},fa=function(){le.registry.register({displayText(){return H.DUPLICATE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden"},callback(e){e.block&&vr(e.block)},scopeType:le.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},ba=function(){le.registry.register({displayText(e){return e.block.getCommentIcon()?H.REMOVE_COMMENT:H.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.getCommentIcon()?e.setCommentText(null):e.setCommentText("")},scopeType:le.ScopeType.BLOCK,id:"blockComment",weight:2})},Ra=function(){le.registry.register({displayText(e){return e.block.getInputsInline()?H.EXTERNAL_INPUTS:H.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].type!==X.STATEMENT&&e.inputList[t].type!==X.STATEMENT)return"enabled"}return"hidden"},callback(e){e.block.setInputsInline(!e.block.getInputsInline())},scopeType:le.ScopeType.BLOCK,id:"blockInline",weight:3})},Ia=function(){le.registry.register({displayText(e){return e.block.isCollapsed()?H.EXPAND_BLOCK:H.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:le.ScopeType.BLOCK,id:"blockCollapseExpand",weight:4})},Oa=function(){le.registry.register({displayText(e){return e.block.isEnabled()?H.DISABLE_BLOCK:H.ENABLE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.workspace.options.disable&&e.isEditable()?e.getInheritedDisabled()?"disabled":"enabled":"hidden"},callback(e){e=e.block;const t=K();t||C(!0),e.setEnabled(!e.isEnabled()),C(t)},scopeType:le.ScopeType.BLOCK,id:"blockDisable",weight:5})},Sa=function(){le.registry.register({displayText(e){var t=e.block;return e=t.getDescendants(!1).length,(t=t.getNextBlock())&&(e-=t.getDescendants(!1).length),e===1?H.DELETE_BLOCK:H.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:le.ScopeType.BLOCK,id:"blockDelete",weight:6})},va=function(){le.registry.register({displayText(){return H.HELP},preconditionFn(e){return e=e.block,(typeof e.helpUrl=="function"?e.helpUrl():e.helpUrl)?"enabled":"hidden"},callback(e){e.block.showHelp()},scopeType:le.ScopeType.BLOCK,id:"blockHelp",weight:7})},Fd=function(){fa(),ba(),Ra(),Ia(),Oa(),Sa(),va()},Ca=function(){xd(),Fd()},Co=function(e){return e.getProcedureModel!==void 0&&e.doProcedureUpdate!==void 0&&e.isProcedureDef!==void 0},rn=function(e){return e.startPublishing!==void 0&&e.stopPublishing!==void 0},nn=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=>{!Co(s)&&gs(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=>{!Co(s)&&gs(s)&&o.push(s.getProcedureDef())}),t.sort(Na),o.sort(Na),[t,o]},Na=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},ya=function(e,t){if(t.isInFlyout)return e;for(e=e||H.UNNAMED_KEY||"unnamed";!Ud(e,t.workspace,t);){const o=e.match(/^(.*?)(\d+)$/);e=o?o[1]+(parseInt(o[2])+1):e+"2"}return e},Ud=function(e,t,o){return!Aa(e,t,o)},Aa=function(e,t,o){for(const s of t.getAllBlocks(!1))if(s!==o&&gs(s)&&Ze.equals(s.getProcedureDef()[0],e))return!0;o=o&&Co(o)?o==null?void 0:o.getProcedureModel():void 0;for(const s of t.getProcedureMap().getProcedures())if(s!==o&&Ze.equals(s.getName(),e))return!0;return!1},Hd=function(e){var t=this.getSourceBlock();if(!t)throw new Le;e=e.trim();const o=ya(e,t);Co(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},ln=function(e){function t(a,p){for(let v=0;v<a.length;v++){var $=a[v][0];const k=a[v][1],fe=n.createElement$$module$build$src$core$utils$xml("block");fe.setAttribute("type",p),fe.setAttribute("gap","16");const be=n.createElement$$module$build$src$core$utils$xml("mutation");for(be.setAttribute("name",$),fe.appendChild(be),$=0;$<k.length;$++){const at=n.createElement$$module$build$src$core$utils$xml("arg");at.setAttribute("name",k[$]),be.appendChild(at)}o.push(fe)}}const o=[];if(rt.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(bt(H.PROCEDURES_DEFNORETURN_PROCEDURE)),s.appendChild(i),o.push(s)}return rt.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(bt(H.PROCEDURES_DEFRETURN_PROCEDURE)),s.appendChild(i),o.push(s)),rt.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=nn(e),t(e[0],"procedures_callnoreturn"),t(e[1],"procedures_callreturn"),o},La=function(e){var t=[],o=e.getBlocksByType("procedures_mutatorarg",!1);for(let a=0,p;p=o[a];a++)t.push(p.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=Ni(_u,t),t=bt(t),i.appendChild(t),s.appendChild(i),o.appendChild(s),e.updateToolbox(o)},ka=function(e){if(e.type===lo&&e.bubbleType==="mutator"&&e.isOpen&&e.blockId){e=N(e.workspaceId).getBlockById(e.blockId);var t=e.type;(t==="procedures_defnoreturn"||t==="procedures_defreturn")&&(e=e.mutator.getWorkspace(),La(e),e.addChangeListener(Vd))}},Vd=function(e){(e.type===He||e.type===jt||e.type===Ge)&&(e=N(e.workspaceId),La(e))},Da=function(e,t){return t.getAllBlocks(!1).filter(o=>Wd(o,e)||ju(o)&&Ze.equals(o.getProcedureCall(),e))},Wd=function(e,t){return Co(e)&&!e.isProcedureDef()&&e.getProcedureModel()&&Ze.equals(e.getProcedureModel().getName(),t)},Xd=function(e){const t=tt();var o=e.getProcedureDef()[0];const s=e.mutationToDom(!0);e=Da(o,e.workspace);for(let a=0,p;p=e[a];a++){o=(o=p.mutationToDom())&&bo(o),p.domToMutation&&p.domToMutation(s);var i=p.mutationToDom();i=i&&bo(i),o!==i&&(We(!1),x(new(F(Ge))(p,"mutation",null,o,i)),We(t))}},jd=function(e,t){for(const o of t.getAllBlocks(!1))if(Co(o)&&o.isProcedureDef()&&Ze.equals(o.getProcedureModel().getName(),e)||gs(o)&&Ze.equals(o.getProcedureDef()[0],e))return o;return null},Ma=function(e){return e.isDynamic},Lr=function(){return Up},Yd=function(){_("Blockly.blockRendering.debug.stopDebugger()","version 8","version 10","the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)"),Up=!1},Cs=function(e,t){r(A.RENDERER,e,t)},Kd=function(e){he(A.RENDERER,e)},zd=function(){_("Blockly.blockRendering.stopDebugger()","September 2021","September 2022","the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)"),Yd()},wa=function(e,t,o){return e=new(l(A.RENDERER,e))(e),e.init(t,o),e},Ga=function(e){Ts(e.getTargetWorkspace(),void 0,"String")},Pa=function(e){Ts(e.getTargetWorkspace(),void 0,"Number")},Ba=function(e){Ts(e.getTargetWorkspace(),void 0,"Colour")},an=function(e){let t=[],o=document.createElement("button");return o.setAttribute("text",H.NEW_STRING_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),t.push(o),o=document.createElement("button"),o.setAttribute("text",H.NEW_NUMBER_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),t.push(o),o=document.createElement("button"),o.setAttribute("text",H.NEW_COLOUR_VARIABLE),o.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),t.push(o),e.registerButtonCallback("CREATE_VARIABLE_STRING",Ga),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",Pa),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",Ba),e=xa(e),t=t.concat(e)},xa=function(e){e=e.getAllVariables();const t=[];if(0<e.length){if(rt.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(Ho(o)),t.push(s)}if(rt.variables_get_dynamic){e.sort(Ur.compareByName);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(Ho(i)),t.push(o)}}return t},cn=function(e,t,o,s,i,a){const p=a.scrollbar&&a.scrollbar.canScrollVertically();return e.horizontal===Zs.LEFT?(o=i.absoluteMetrics.left+o,p&&a.RTL&&(o+=me.scrollbarThickness)):(o=i.absoluteMetrics.left+i.viewMetrics.width-t.width-o,p&&!a.RTL&&(o-=me.scrollbarThickness)),e.vertical===To.TOP?e=i.absoluteMetrics.top+s:(e=i.absoluteMetrics.top+i.viewMetrics.height-t.height-s,a.scrollbar&&a.scrollbar.canScrollHorizontally()&&(e-=me.scrollbarThickness)),new Se(e,e+t.height,o,o+t.width)},un=function(e,t){return{horizontal:t.toolboxMetrics.position===V.LEFT||e.horizontalLayout&&!e.RTL?Zs.RIGHT:Zs.LEFT,vertical:t.toolboxMetrics.position===V.BOTTOM?To.TOP:To.BOTTOM}},hn=function(e,t,o,s){const i=e.left,a=e.right-e.left,p=e.bottom-e.top;for(let $=0;$<s.length;$++){const v=s[$];e.intersects(v)&&(e=o===Po.UP?v.top-p-t:v.bottom+t,e=new Se(e,e+p,i,i+a),$=-1)}return e},Jd=function(e){e.resizeContents()},qd=function(e,t){if(typeof e=="string"&&(e=document.getElementById(e)||document.querySelector(e)),!e||!Fo(document,e))throw Error("Error: container is not in current document.");t=new kt(t||{});const o=document.createElement("div");o.className="injectionDiv",o.tabIndex=0,ge(o,pe.LABEL,H.WORKSPACE_ARIA_LABEL),e.appendChild(o),e=Zd(o,t);const s=new fp(o),i=new jp(o),a=Qd(e,t,s,i);return e_(a),Re(a),Pt(a),o.addEventListener("focusin",function(){Re(a)}),a},Zd=function(e,t){e.setAttribute("dir","LTR"),tl(t.hasCss,t.pathToMedia),e=I(f.SVG,{xmlns:Ms,"xmlns:html":Ct,"xmlns:xlink":it,version:"1.1",class:"blocklySvg",tabindex:"0"},e);const o=I(f.DEFS,{},e),s=String(Math.random()).substring(2);return t.gridPattern=du.createDom(s,t.gridOptions,o),e},Qd=function(e,t,o,s){t.parentWorkspace=null,t=new Mt(t,o,s),o=t.options,t.scale=o.zoomOptions.startScale,e.appendChild(t.createDom("blocklyMainBackground")),s=t.getInjectionDiv();var i=t.getRenderer().getClassName();return i&&U(s,i),(i=t.getTheme().getClassName())&&U(s,i),!o.hasCategories&&o.languageTree&&(s=t.addFlyout(f.SVG),Rt(s,e)),o.hasTrashcan&&t.addTrashcan(),o.zoomOptions&&o.zoomOptions.controls&&t.addZoomControls(),t.getThemeManager().subscribe(e,"workspaceBackgroundColour","background-color"),t.translate(0,0),t.addChangeListener(ra(t)),Pt(t),Hl(),$l(),Ml(),t},e_=function(e){const t=e.options;var o=e.getParentSvg();if(w(o.parentNode,"contextmenu",null,function(s){hr(s)||s.preventDefault()}),o=w(window,"resize",null,function(){e.hideChaff(!0),Pt(e),tn(e)}),e.setResizeHandlerWrapper(o),o_(),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 hu(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&&s_(t.pathToMedia,e)},t_=function(e){const t=Y();t&&!(hr(e)||t.rendered&&!t.isVisible())&&ue.registry.onKeyDown(t,e)},o_=function(){Yp||(w(document,"scroll",null,function(){const e=G();for(let t=0,o;o=e[t];t++)o instanceof Mt&&o.updateInverseScreenCTM()}),w(document,"keydown",null,t_),Ye(document,"touchend",null,Ft),Ye(document,"touchcancel",null,Ft),Gs&&w(window,"orientationchange",document,function(){Pt(Y())})),Yp=!0},s_=function(e,t){function o(){for(;i.length;)ce(i.pop());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(w(document,"pointermove",null,o,!0)),i.push(w(document,"touchstart",null,o,!0))},Fa=function(e){const t={id:e.getId(),name:e.getName(),returnTypes:e.getReturnTypes()};return e.getParameters().length&&(t.parameters=e.getParameters().map(o=>Ua(o))),t},Ua=function(e){const t={id:e.getId(),name:e.getName()};return e.getTypes().length&&(t.types=e.getTypes()),t},Ha=function(e,t,o,s){if(e=new e(s,o.name,o.id).setReturnTypes(o.returnTypes),!o.parameters)return e;for(const[i,a]of o.parameters.entries())e.insertParameter(Va(t,a,s),i);return e},Va=function(e,t,o){return e=new e(o,t.name,t.id),t.types&&e.setTypes(t.types),e},r_=function(e){const t=Object.create(null),o=g(A.SERIALIZER,!0);for(const s in o){let i;const a=(i=o[s])==null?void 0:i.save(e);a&&(t[s]=a)}return t},i_=function(e,t,{recordUndo:o=!1}={}){var s=g(A.SERIALIZER,!0);if(s){s=Object.entries(s).sort((a,p)=>p[1].priority-a[1].priority);var i=tt();We(o),(o=K())||C(!0),Bt(),t instanceof Mt&&t.setResizesEnabled(!1);for(const[,a]of s.reverse()){let p;(p=a)==null||p.clear(t)}for(let[a,p]of s.reverse())if(e[a]){let $;($=p)==null||$.load(e[a],t)}t instanceof Mt&&t.setResizesEnabled(!0),xt(),x(new(F(ks))(t)),C(o),We(i)}},Wa=function(){ue.registry.register({name:eo.ESCAPE,preconditionFn(e){return!e.options.readOnly},callback(e){return e.hideChaff(),!0},keyCodes:[J.ESC]})},Xa=function(){ue.registry.register({name:eo.DELETE,preconditionFn(e){const t=_e();return!e.options.readOnly&&t!=null&&t.isDeletable()},callback(e,t){return t.preventDefault(),qt.inProgress()?!1:(_e().checkAndDelete(),!0)},keyCodes:[J.DELETE,J.BACKSPACE]})},ja=function(){const e=ue.registry.createSerializedKey(J.C,[J.CTRL]),t=ue.registry.createSerializedKey(J.C,[J.ALT]),o=ue.registry.createSerializedKey(J.C,[J.META]);ue.registry.register({name:eo.COPY,preconditionFn(s){const i=_e();return!s.options.readOnly&&!qt.inProgress()&&i!=null&&i.isDeletable()&&i.isMovable()},callback(s,i){return i.preventDefault(),s.hideChaff(),Ss(_e()),!0},keyCodes:[e,t,o]})},Ya=function(){const e=ue.registry.createSerializedKey(J.X,[J.CTRL]),t=ue.registry.createSerializedKey(J.X,[J.ALT]),o=ue.registry.createSerializedKey(J.X,[J.META]);ue.registry.register({name:eo.CUT,preconditionFn(s){const i=_e();return!s.options.readOnly&&!qt.inProgress()&&i!=null&&i instanceof mt&&i.isDeletable()&&i.isMovable()&&!i.workspace.isFlyout},callback(){const s=_e();return s?(Ss(s),s.checkAndDelete(),!0):!1},keyCodes:[e,t,o]})},Ka=function(){const e=ue.registry.createSerializedKey(J.V,[J.CTRL]),t=ue.registry.createSerializedKey(J.V,[J.ALT]),o=ue.registry.createSerializedKey(J.V,[J.META]);ue.registry.register({name:eo.PASTE,preconditionFn(s){return!s.options.readOnly&&!qt.inProgress()},callback(){return!!on()},keyCodes:[e,t,o]})},za=function(){const e=ue.registry.createSerializedKey(J.Z,[J.CTRL]),t=ue.registry.createSerializedKey(J.Z,[J.ALT]),o=ue.registry.createSerializedKey(J.Z,[J.META]);ue.registry.register({name:eo.UNDO,preconditionFn(s){return!s.options.readOnly&&!qt.inProgress()},callback(s){return s.hideChaff(),s.undo(!1),!0},keyCodes:[e,t,o]})},Ja=function(){const e=ue.registry.createSerializedKey(J.Z,[J.SHIFT,J.CTRL]),t=ue.registry.createSerializedKey(J.Z,[J.SHIFT,J.ALT]),o=ue.registry.createSerializedKey(J.Z,[J.SHIFT,J.META]),s=ue.registry.createSerializedKey(J.Y,[J.CTRL]);ue.registry.register({name:eo.REDO,preconditionFn(i){return!qt.inProgress()&&!i.options.readOnly},callback(i){return i.hideChaff(),i.undo(!0),!0},keyCodes:[e,t,o,s]})},qa=function(){Wa(),Xa(),ja(),Ya(),Ka(),za(),Ja()},n_=function(e){return e.isSelectable()},l_=function(e){return _("Blockly.utils.getRelativeXY","December 2021","December 2022","Blockly.utils.svgMath.getRelativeXY"),$t(e)},a_=function(e){return _("Blockly.utils.getInjectionDivXY_","December 2021","December 2022","Blockly.utils.svgMath.getInjectionDivXY"),pr(e)},c_=function(e){return _("Blockly.utils.tokenizeInterpolation","December 2021","December 2022","Blockly.utils.parsing.tokenizeInterpolation"),Xi(e)},u_=function(e){return _("Blockly.utils.replaceMessageReferences","December 2021","December 2022","Blockly.utils.parsing.replaceMessageReferences"),Ee(e)},h_=function(e){return _("Blockly.utils.checkMessageReferences","December 2021","December 2022","Blockly.utils.parsing.checkMessageReferences"),br(e)},d_=function(){return _("Blockly.utils.is3dSupported","December 2021","December 2022","Blockly.utils.svgMath.is3dSupported"),nl()},__=function(){return _("Blockly.utils.getViewportBBox","December 2021","December 2022","Blockly.utils.svgMath.getViewportBBox"),ki()},p_=function(e,t){return _("Blockly.utils.arrayRemove","December 2021","December 2022","Blockly.array.removeElem"),Ke(e,t)},g_=function(){return _("Blockly.utils.getDocumentScroll","December 2021","December 2022","Blockly.utils.svgMath.getDocumentScroll"),Di()},T_=function(e,t){return _("Blockly.utils.getBlockTypeCounts","December 2021","December 2022","Blockly.common.getBlockTypeCounts"),Eo(e,t)},$_=function(e,t){return _("Blockly.utils.screenToWsCoordinates","December 2021","December 2022","Blockly.utils.svgMath.screenToWsCoordinates"),ll(e,t)},E_=function(e){return _("Blockly.utils.parseBlockColour","December 2021","December 2022","Blockly.utils.parsing.parseBlockColour"),jo(e)},m_=function(e){_("Blockly.utils.runAfterPageLoad","December 2021","December 2022"),Or(e)},f_=function(e){Y().hideChaff(e)},b_=function(e){_("Blockly.resizeSvgContents","December 2021","December 2022","Blockly.WorkspaceSvg.resizeSvgContents"),Jd(e)},R_=function(e){_("Blockly.copy","December 2021","December 2022","Blockly.clipboard.copy"),Ss(e)},I_=function(){return _("Blockly.paste","December 2021","December 2022","Blockly.clipboard.paste"),!!on()},O_=function(e){_("Blockly.duplicate","December 2021","December 2022","Blockly.clipboard.duplicate"),vr(e)},S_=function(e){return _("Blockly.isNumber","December 2021","December 2022","Blockly.utils.string.isNumber"),kl(e)},v_=function(e){return _("Blockly.hueToHex","December 2021","December 2022","Blockly.utils.colour.hueToHex"),Vi(e)},C_=function(e,t,o,s){return _("Blockly.bindEvent_","December 2021","December 2022","Blockly.browserEvents.bind"),Ye(e,t,o,s)},N_=function(e){return _("Blockly.unbindEvent_","December 2021","December 2022","Blockly.browserEvents.unbind"),ce(e)},y_=function(e,t,o,s,i,a){return _("Blockly.bindEventWithChecks_","December 2021","December 2022","Blockly.browserEvents.conditionalBind"),w(e,t,o,s,i)},B=B||{},B.scope={},B.ASSUME_ES5=!1,B.ASSUME_NO_NATIVE_MAP=!1,B.ASSUME_NO_NATIVE_SET=!1,B.SIMPLE_FROUND_POLYFILL=!1,B.ISOLATE_POLYFILLS=!1,B.FORCE_POLYFILL_PROMISE=!1,B.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,B.defineProperty=B.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(e,t,o){return e==Array.prototype||e==Object.prototype||(e[t]=o.value),e},B.getGlobal=function(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof Ve=="object"&&Ve];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")},B.global=B.getGlobal(this),B.IS_SYMBOL_NATIVE=typeof Symbol=="function"&&typeof Symbol("x")=="symbol",B.TRUST_ES6_POLYFILLS=!B.ISOLATE_POLYFILLS||B.IS_SYMBOL_NATIVE,B.polyfills={},B.propertyToPolyfillSymbol={},B.POLYFILL_PREFIX="$jscp$",B.polyfill=function(e,t,o,s){t&&(B.ISOLATE_POLYFILLS?B.polyfillIsolated(e,t,o,s):B.polyfillUnisolated(e,t,o,s))},B.polyfillUnisolated=function(e,t,o,s){for(o=B.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&&B.defineProperty(o,e,{configurable:!0,writable:!0,value:t})},B.polyfillIsolated=function(e,t,o,s){var i=e.split(".");e=i.length===1,s=i[0],s=!e&&s in B.polyfills?B.polyfills:B.global;for(var a=0;a<i.length-1;a++){var p=i[a];if(!(p in s))return;s=s[p]}i=i[i.length-1],o=B.IS_SYMBOL_NATIVE&&o==="es6"?s[i]:null,t=t(o),t!=null&&(e?B.defineProperty(B.polyfills,i,{configurable:!0,writable:!0,value:t}):t!==o&&(B.propertyToPolyfillSymbol[i]===void 0&&(o=1e9*Math.random()>>>0,B.propertyToPolyfillSymbol[i]=B.IS_SYMBOL_NATIVE?B.global.Symbol(i):B.POLYFILL_PREFIX+o+"$"+i),B.defineProperty(s,B.propertyToPolyfillSymbol[i],{configurable:!0,writable:!0,value:t})))},B.polyfill("globalThis",function(e){return e||B.global},"es_2020","es3"),B.polyfill("Object.getOwnPropertyDescriptors",function(e){return e||function(t){for(var o={},s=Reflect.ownKeys(t),i=0;i<s.length;i++)o[s[i]]=Object.getOwnPropertyDescriptor(t,s[i]);return o}},"es8","es5"),B.arrayIteratorImpl=function(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}},B.arrayIterator=function(e){return{next:B.arrayIteratorImpl(e)}},B.initSymbol=function(){},B.iteratorPrototype=function(e){return e={next:e},e[Symbol.iterator]=function(){return this},e},B.iteratorFromArray=function(e,t){e instanceof String&&(e+="");var o=0,s=!1,i={next:function(){if(!s&&o<e.length){var a=o++;return{value:t(a,e[a]),done:!1}}return s=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i},B.polyfill("Array.prototype.values",function(e){return e||function(){return B.iteratorFromArray(this,function(t,o){return o})}},"es8","es3"),B.owns=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},B.polyfill("Object.values",function(e){return e||function(t){var o=[],s;for(s in t)B.owns(t,s)&&o.push(t[s]);return o}},"es8","es3"),B.polyfill("Array.prototype.flat",function(e){return e||function(t){t=t===void 0?1:t;for(var o=[],s=0;s<this.length;s++){var i=this[s];Array.isArray(i)&&0<t?(i=Array.prototype.flat.call(i,t-1),o.push.apply(o,i)):o.push(i)}return o}},"es9","es5"),B.polyfill("Object.entries",function(e){return e||function(t){var o=[],s;for(s in t)B.owns(t,s)&&o.push([s,t[s]]);return o}},"es8","es3");var st=st||{};st.global=globalThis||root,st.define=function(e,t){return t},st.DEBUG=!1,st.DISALLOW_TEST_ONLY_CODE=!st.DEBUG,st.provide=function(e){},st.module=function(e){},st.module.get=function(e){},st.module.declareLegacyNamespace=function(){},st.setTestOnly=function(e){if(st.DISALLOW_TEST_ONLY_CODE)throw e=e||"",Error("Importing test-only code into non-debug environment"+(e?": "+e:"."))},st.require=function(e){},st.requireType=function(e){};var we={};we.warn=_;var No=Object.create(null),zg={typeMap:No},dn=Object.create(null),no="default",A=class{constructor(e){this.name=e}toString(){return this.name}};A.CONNECTION_CHECKER=new A("connectionChecker"),A.CURSOR=new A("cursor"),A.EVENT=new A("event"),A.FIELD=new A("field"),A.RENDERER=new A("renderer"),A.TOOLBOX=new A("toolbox"),A.THEME=new A("theme"),A.TOOLBOX_ITEM=new A("toolboxItem"),A.FLYOUTS_VERTICAL_TOOLBOX=new A("flyoutsVerticalToolbox"),A.FLYOUTS_HORIZONTAL_TOOLBOX=new A("flyoutsHorizontalToolbox"),A.METRICS_MANAGER=new A("metricsManager"),A.BLOCK_DRAGGER=new A("blockDragger"),A.SERIALIZER=new A("serializer");var vt={};vt.DEFAULT=no,vt.TEST_ONLY=zg,vt.Type=A,vt.getAllItems=g,vt.getClass=l,vt.getClassFromOptions=b,vt.getObject=d,vt.hasItem=c,vt.register=r,vt.unregister=he;var rt=Object.create(null),Ns,A_,Za,L_,Ko,Qa;Ns=Object.create(null),Za=null,Ko=[],Qa={defineBlocksWithJsonArrayInternal:mi},n.module$build$src$core$common={},n.module$build$src$core$common.TEST_ONLY=Qa,n.module$build$src$core$common.createBlockDefinitionsFromJsonArray=n.createBlockDefinitionsFromJsonArray$$module$build$src$core$common,n.module$build$src$core$common.defineBlocks=n.defineBlocks$$module$build$src$core$common,n.module$build$src$core$common.defineBlocksWithJsonArray=lr,n.module$build$src$core$common.draggingConnections=Ko,n.module$build$src$core$common.getAllWorkspaces=G,n.module$build$src$core$common.getBlockTypeCounts=Eo,n.module$build$src$core$common.getMainWorkspace=Y,n.module$build$src$core$common.getParentContainer=$o,n.module$build$src$core$common.getSelected=_e,n.module$build$src$core$common.getWorkspaceById=N,n.module$build$src$core$common.registerWorkspace=Q,n.module$build$src$core$common.setMainWorkspace=Re,n.module$build$src$core$common.setParentContainer=nr,n.module$build$src$core$common.setSelected=et,n.module$build$src$core$common.svgResize=Pt,n.module$build$src$core$common.unregisterWorkpace=de;var k_="!#$%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",D_={genUid:()=>{const e=k_.length,t=[];for(let o=0;20>o;o++)t[o]=k_.charAt(Math.random()*e);return t.join("")}},Jg=0,_n={};_n.TEST_ONLY=D_,_n.genUid=ft,_n.getNextUniqueId=oo;var M_="",kr=!0,ec=0,He="create",jt="delete",Ge="change",ze="move",zo="var_create",ys="var_delete",Dr="var_rename",Mr="ui",As="drag",yo="selected",Ao="click",wr="marker_move",lo="bubble_open",Gr="trashcan_open",Pr="toolbox_item_select",Br="theme_change",Jo="viewport_change",qo="comment_create",Ls="comment_delete",xr="comment_change",ao="comment_move",ks="finished_loading",tc=[He,ze,qo,ao],Ds=[],oc={FIRE_QUEUE:Ds,fireNow:mo,fireInternal:fi,setGroupInternal:bi},j={};j.BLOCK_CHANGE=Ge,j.BLOCK_CREATE=He,j.BLOCK_DELETE=jt,j.BLOCK_DRAG=As,j.BLOCK_MOVE=ze,j.BUBBLE_OPEN=lo,j.BUMP_EVENTS=tc,j.CHANGE=Ge,j.CLICK=Ao,j.COMMENT_CHANGE=xr,j.COMMENT_CREATE=qo,j.COMMENT_DELETE=Ls,j.COMMENT_MOVE=ao,j.CREATE=He,j.DELETE=jt,j.FINISHED_LOADING=ks,j.MARKER_MOVE=wr,j.MOVE=ze,j.SELECTED=yo,j.TEST_ONLY=oc,j.THEME_CHANGE=Br,j.TOOLBOX_ITEM_SELECT=Pr,j.TRASHCAN_OPEN=Gr,j.UI=Mr,j.VAR_CREATE=zo,j.VAR_DELETE=ys,j.VAR_RENAME=Dr,j.VIEWPORT_CHANGE=Jo,j.clearPendingUndo=Z,j.disable=ve,j.disableOrphans=_s,j.enable=Ie,j.filter=Fe,j.fire=x,j.fromJson=hs,j.get=F,j.getDescendantIds=Bo,j.getGroup=K,j.getRecordUndo=tt,j.isEnabled=Oe,j.setGroup=C,j.setRecordUndo=We;var X;(function(e){e[e.VALUE=1]="VALUE",e[e.STATEMENT=3]="STATEMENT",e[e.DUMMY=5]="DUMMY"})(X||(X={})),n.module$build$src$core$input_types={},n.module$build$src$core$input_types.inputTypes=X;var Pe=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}},Zo,pn,gn,sc;({document:Zo,DOMParser:pn,XMLSerializer:gn}=globalThis),sc="https://developers.google.com/blockly/xml",n.module$build$src$core$utils$xml={},n.module$build$src$core$utils$xml.NAME_SPACE=sc,n.module$build$src$core$utils$xml.createElement=n.createElement$$module$build$src$core$utils$xml,n.module$build$src$core$utils$xml.createTextNode=bt,n.module$build$src$core$utils$xml.domToText=bo,n.module$build$src$core$utils$xml.getDocument=Ii,n.module$build$src$core$utils$xml.injectDependencies=Ri,n.module$build$src$core$utils$xml.setDocument=Oi,n.module$build$src$core$utils$xml.textToDom=Ce,n.module$build$src$core$utils$xml.textToDomDocument=fo;var Ms="http://www.w3.org/2000/svg",Ct="http://www.w3.org/1999/xhtml",it="http://www.w3.org/1999/xlink",Yt;(function(e){e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_POSITION_CONTAINED_BY=16]="DOCUMENT_POSITION_CONTAINED_BY"})(Yt||(Yt={}));var Nt=null,rc=0,Tn=null,De={};De.HTML_NS=Ct,De.NodeType=Yt,De.SVG_NS=Ms,De.XLINK_NS=it,De.addClass=U,De.containsNode=Fo,De.createSvgElement=I,De.getFastTextWidth=h,De.getFastTextWidthWithSizeString=T,De.getTextWidth=ct,De.hasClass=xo,De.insertAfter=Rt,De.measureFontMetrics=m,De.removeClass=se,De.removeClasses=ps,De.removeNode=re,De.setCssTransform=so,De.startTextWidthCache=Bt,De.stopTextWidthCache=xt;var w_=function(e,t){window.alert(e),t&&t()},G_=function(e,t){t(window.confirm(e))},P_=function(e,t,o){o(window.prompt(e,t))},B_={confirmInternal:Uo},nt={};nt.TEST_ONLY=B_,nt.alert=O,nt.confirm=te,nt.prompt=Si,nt.setAlert=S,nt.setConfirm=Wu,nt.setPrompt=Xu;var H,ic;H=Object.create(null),ic=function(e){Object.keys(e).forEach(function(t){H[t]=e[t]})},n.module$build$src$core$msg={},n.module$build$src$core$msg.Msg=H,n.module$build$src$core$msg.setLocale=ic;var ws=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=K(),this.recordUndo=tt()}toJson(){return{type:this.type,group:this.group}}fromJson(e){_("Blockly.Events.Abstract.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),this.isBlank=!1,this.group=e.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=N(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},Fr=class extends ws{constructor(e){super(),this.isBlank=typeof e>"u",e&&(this.varId=e.getId(),this.workspaceId=e.workspace.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}fromJson(e){_("Blockly.Events.VarBase.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.varId=e.varId}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Fr),t.varId=e.varId,t}},nc=class extends Fr{constructor(e){super(e),this.type=zo,e&&(this.varType=e.type,this.varName=e.name)}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}fromJson(e){_("Blockly.Events.VarCreate.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.varType=e.varType,this.varName=e.varName}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new nc),t.varType=e.varType,t.varName=e.varName,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.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");e?t.createVariable(this.varName,this.varType,this.varId):t.deleteVariableById(this.varId)}};r(A.EVENT,zo,nc);var Ur=class{constructor(e,t,o,s){this.workspace=e,this.name=t,this.type=o||"",this.id_=s||ft()}getId(){return this.id_}static compareByName(e,t){return e.name.localeCompare(t.name,void 0,{sensitivity:"base"})}},$n,En,lc;$n="VARIABLE",En="ijkmnopqrstuvwxyzabcdefgh",lc={generateUniqueNameInternal:Ku},n.module$build$src$core$variables={},n.module$build$src$core$variables.CATEGORY_NAME=$n,n.module$build$src$core$variables.TEST_ONLY=lc,n.module$build$src$core$variables.VAR_LETTER_OPTIONS=En,n.module$build$src$core$variables.allDeveloperVariables=Yu,n.module$build$src$core$variables.allUsedVarModels=vi,n.module$build$src$core$variables.createVariableButtonHandler=Ts,n.module$build$src$core$variables.flyoutCategory=Ci,n.module$build$src$core$variables.flyoutCategoryBlocks=Kn,n.module$build$src$core$variables.generateUniqueName=zn,n.module$build$src$core$variables.generateUniqueNameFromOptions=Ni,n.module$build$src$core$variables.generateVariableFieldDom=Ho,n.module$build$src$core$variables.getAddedVariables=Ai,n.module$build$src$core$variables.getOrCreateVariablePackage=ar,n.module$build$src$core$variables.getVariable=cr,n.module$build$src$core$variables.nameUsedWithAnyType=qn,n.module$build$src$core$variables.nameUsedWithConflictingParam=Zn,n.module$build$src$core$variables.promptName=yi,n.module$build$src$core$variables.renameVariable=Jn;var L=class{constructor(e,t){this.x=e,this.y=t}clone(){return new L(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 L(e.x-t.x,e.y-t.y)}static sum(e,t){return new L(e.x+t.x,e.y+t.y)}},Kt=class{constructor(e,t,o,s,i){this.workspace=e,this.editable_=this.movable_=this.deletable_=!0,this.disposed_=!1,this.isComment=!0,this.id=i&&!e.getCommentById(i)?i:ft(),e.addTopComment(this),this.xy_=new L(0,0),this.height_=o,this.width_=s,this.RTL=e.RTL,this.content_=t,Kt.fireCreateEvent(this)}dispose(){this.disposed_||(Oe()&&x(new(F(Ls))(this)),this.workspace.removeTopComment(this),this.disposed_=!0)}getHeight(){return this.height_}setHeight(e){this.height_=e}getWidth(){return this.width_}setWidth(e){this.width_=e}getRelativeToSurfaceXY(){return new L(this.xy_.x,this.xy_.y)}moveBy(e,t){const o=new(F(ao))(this);this.xy_.translate(e,t),o.recordNew(),x(o)}isDeletable(){return this.deletable_&&!(this.workspace&&this.workspace.options.readOnly)}setDeletable(e){this.deletable_=e}isMovable(){return this.movable_&&!(this.workspace&&this.workspace.options.readOnly)}setMovable(e){this.movable_=e}isEditable(){return this.editable_&&!(this.workspace&&this.workspace.options.readOnly)}setEditable(e){this.editable_=e}getContent(){return this.content_}setContent(e){this.content_!==e&&(x(new(F(xr))(this,this.content_,e)),this.content_=e)}toXmlWithXY(e){return e=this.toXml(e),e.setAttribute("x",String(Math.round(this.xy_.x))),e.setAttribute("y",String(Math.round(this.xy_.y))),e.setAttribute("h",String(this.height_)),e.setAttribute("w",String(this.width_)),e}toXml(e){const t=n.createElement$$module$build$src$core$utils$xml("comment");return e||(t.id=this.id),t.textContent=this.getContent(),t}static fireCreateEvent(e){if(Oe()){const t=K();t||C(!0);try{x(new(F(qo))(e))}finally{C(t)}}}static fromXml(e,t){var o=Kt.parseAttributes(e);return t=new Kt(t,o.content,o.h,o.w,o.id),o=e.getAttribute("x"),e=e.getAttribute("y"),o=o?parseInt(o,10):NaN,e=e?parseInt(e,10):NaN,isNaN(o)||isNaN(e)||t.moveBy(o,e),Kt.fireCreateEvent(t),t}static parseAttributes(e){const t=e.getAttribute("h"),o=e.getAttribute("w"),s=e.getAttribute("x"),i=e.getAttribute("y"),a=e.getAttribute("id");if(!a)throw Error("No ID present in XML comment definition.");let p;return{id:a,h:t?parseInt(t):100,w:o?parseInt(o):100,x:s?parseInt(s):NaN,y:i?parseInt(i):NaN,content:(p=e.textContent)!=null?p:""}}},yt=class extends ws{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=typeof e>"u",this.workspaceId=e||""}},ac=class extends yt{constructor(e,t,o){super(o),this.type=yo,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}fromJson(e){_("Blockly.Events.Selected.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldElementId=e.oldElementId,this.newElementId=e.newElementId}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ac),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};r(A.EVENT,yo,ac);var qg=750,x_="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),mn=null,Qo={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},fn=0,ht={};ht.TOUCH_ENABLED=x_,ht.TOUCH_MAP=Qo,ht.checkTouchIdentifier=el,ht.clearTouchIdentifier=Ut,ht.getTouchIdentifierFromEvent=$s,ht.isMouseOrTouchEvent=eh,ht.isTouchEvent=th,ht.longStart=Qn,ht.longStop=Ft,ht.setClientFromTouch=Qu,ht.shouldHandleEvent=ur,ht.splitEventByTouches=oh;var cc,F_,U_,H_,bn,Rn,uc,V_,W_,X_;(function(e){function t(s){return o.indexOf(s.toUpperCase())!==-1}cc=e;const o=cc.toUpperCase();F_=t("JavaFX"),U_=t("WebKit"),H_=t("Gecko")&&!U_,bn=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Rn=t("iPad")||t("Macintosh")&&0<e,uc=t("iPhone")&&!Rn,V_=t("Macintosh"),W_=Rn||bn&&!t("Mobile")||t("Silk"),X_=!W_&&(uc||bn)})(globalThis.navigator&&globalThis.navigator.userAgent||"");var Zg=cc,j_=F_,hc=H_,In=bn,Gs=Rn,Y_=uc,dc=V_,_c=X_,co={};co.ANDROID=In,co.GECKO=hc,co.IPAD=Gs,co.IPHONE=Y_,co.JavaFx=j_,co.MAC=dc,co.MOBILE=_c,co.raw=Zg;var K_=40,z_=125,uo={};uo.bind=Ye,uo.conditionalBind=w,uo.getScrollDeltaPixels=dr,uo.isRightButton=ro,uo.isTargetInput=hr,uo.mouseToSvg=Vo,uo.unbind=ce;var pc=!1,gc=`
|
|
11
|
+
.blocklySvg {
|
|
12
|
+
background-color: #fff;
|
|
13
|
+
outline: none;
|
|
14
|
+
overflow: hidden; /* IE overflows by default. */
|
|
15
|
+
position: absolute;
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.blocklyWidgetDiv {
|
|
20
|
+
display: none;
|
|
21
|
+
position: absolute;
|
|
22
|
+
z-index: 99999; /* big value for bootstrap3 compatibility */
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.injectionDiv {
|
|
26
|
+
height: 100%;
|
|
27
|
+
position: relative;
|
|
28
|
+
overflow: hidden; /* So blocks in drag surface disappear at edges */
|
|
29
|
+
touch-action: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.blocklyNonSelectable {
|
|
33
|
+
user-select: none;
|
|
34
|
+
-ms-user-select: none;
|
|
35
|
+
-webkit-user-select: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.blocklyWsDragSurface {
|
|
39
|
+
display: none;
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 0;
|
|
42
|
+
left: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Added as a separate rule with multiple classes to make it more specific
|
|
46
|
+
than a bootstrap rule that selects svg:root. See issue #1275 for context.
|
|
47
|
+
*/
|
|
48
|
+
.blocklyWsDragSurface.blocklyOverflowVisible {
|
|
49
|
+
overflow: visible;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.blocklyBlockDragSurface {
|
|
53
|
+
display: none;
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 0;
|
|
56
|
+
left: 0;
|
|
57
|
+
right: 0;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
overflow: visible !important;
|
|
60
|
+
z-index: 50; /* Display below toolbox, but above everything else. */
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.blocklyBlockCanvas.blocklyCanvasTransitioning,
|
|
64
|
+
.blocklyBubbleCanvas.blocklyCanvasTransitioning {
|
|
65
|
+
transition: transform .5s;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.blocklyTooltipDiv {
|
|
69
|
+
background-color: #ffffc7;
|
|
70
|
+
border: 1px solid #ddc;
|
|
71
|
+
box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);
|
|
72
|
+
color: #000;
|
|
73
|
+
display: none;
|
|
74
|
+
font: 9pt sans-serif;
|
|
75
|
+
opacity: .9;
|
|
76
|
+
padding: 2px;
|
|
77
|
+
position: absolute;
|
|
78
|
+
z-index: 100000; /* big value for bootstrap3 compatibility */
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.blocklyDropDownDiv {
|
|
82
|
+
position: absolute;
|
|
83
|
+
left: 0;
|
|
84
|
+
top: 0;
|
|
85
|
+
z-index: 1000;
|
|
86
|
+
display: none;
|
|
87
|
+
border: 1px solid;
|
|
88
|
+
border-color: #dadce0;
|
|
89
|
+
background-color: #fff;
|
|
90
|
+
border-radius: 2px;
|
|
91
|
+
padding: 4px;
|
|
92
|
+
box-shadow: 0 0 3px 1px rgba(0,0,0,.3);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.blocklyDropDownDiv.blocklyFocused {
|
|
96
|
+
box-shadow: 0 0 6px 1px rgba(0,0,0,.3);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.blocklyDropDownContent {
|
|
100
|
+
max-height: 300px; /* @todo: spec for maximum height. */
|
|
101
|
+
overflow: auto;
|
|
102
|
+
overflow-x: hidden;
|
|
103
|
+
position: relative;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.blocklyDropDownArrow {
|
|
107
|
+
position: absolute;
|
|
108
|
+
left: 0;
|
|
109
|
+
top: 0;
|
|
110
|
+
width: 16px;
|
|
111
|
+
height: 16px;
|
|
112
|
+
z-index: -1;
|
|
113
|
+
background-color: inherit;
|
|
114
|
+
border-color: inherit;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.blocklyDropDownButton {
|
|
118
|
+
display: inline-block;
|
|
119
|
+
float: left;
|
|
120
|
+
padding: 0;
|
|
121
|
+
margin: 4px;
|
|
122
|
+
border-radius: 4px;
|
|
123
|
+
outline: none;
|
|
124
|
+
border: 1px solid;
|
|
125
|
+
transition: box-shadow .1s;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.blocklyArrowTop {
|
|
130
|
+
border-top: 1px solid;
|
|
131
|
+
border-left: 1px solid;
|
|
132
|
+
border-top-left-radius: 4px;
|
|
133
|
+
border-color: inherit;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.blocklyArrowBottom {
|
|
137
|
+
border-bottom: 1px solid;
|
|
138
|
+
border-right: 1px solid;
|
|
139
|
+
border-bottom-right-radius: 4px;
|
|
140
|
+
border-color: inherit;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.blocklyResizeSE {
|
|
144
|
+
cursor: se-resize;
|
|
145
|
+
fill: #aaa;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.blocklyResizeSW {
|
|
149
|
+
cursor: sw-resize;
|
|
150
|
+
fill: #aaa;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.blocklyResizeLine {
|
|
154
|
+
stroke: #515A5A;
|
|
155
|
+
stroke-width: 1;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.blocklyHighlightedConnectionPath {
|
|
159
|
+
fill: none;
|
|
160
|
+
stroke: #fc3;
|
|
161
|
+
stroke-width: 4px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.blocklyPathLight {
|
|
165
|
+
fill: none;
|
|
166
|
+
stroke-linecap: round;
|
|
167
|
+
stroke-width: 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.blocklySelected>.blocklyPathLight {
|
|
171
|
+
display: none;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.blocklyDraggable {
|
|
175
|
+
cursor: grab;
|
|
176
|
+
cursor: -webkit-grab;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.blocklyDragging {
|
|
180
|
+
cursor: grabbing;
|
|
181
|
+
cursor: -webkit-grabbing;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Changes cursor on mouse down. Not effective in Firefox because of
|
|
185
|
+
https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */
|
|
186
|
+
.blocklyDraggable:active {
|
|
187
|
+
cursor: grabbing;
|
|
188
|
+
cursor: -webkit-grabbing;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Change the cursor on the whole drag surface in case the mouse gets
|
|
192
|
+
ahead of block during a drag. This way the cursor is still a closed hand.
|
|
193
|
+
*/
|
|
194
|
+
.blocklyBlockDragSurface .blocklyDraggable {
|
|
195
|
+
cursor: grabbing;
|
|
196
|
+
cursor: -webkit-grabbing;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.blocklyDragging.blocklyDraggingDelete {
|
|
200
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.blocklyDragging>.blocklyPath,
|
|
204
|
+
.blocklyDragging>.blocklyPathLight {
|
|
205
|
+
fill-opacity: .8;
|
|
206
|
+
stroke-opacity: .8;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.blocklyDragging>.blocklyPathDark {
|
|
210
|
+
display: none;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.blocklyDisabled>.blocklyPath {
|
|
214
|
+
fill-opacity: .5;
|
|
215
|
+
stroke-opacity: .5;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.blocklyDisabled>.blocklyPathLight,
|
|
219
|
+
.blocklyDisabled>.blocklyPathDark {
|
|
220
|
+
display: none;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.blocklyInsertionMarker>.blocklyPath,
|
|
224
|
+
.blocklyInsertionMarker>.blocklyPathLight,
|
|
225
|
+
.blocklyInsertionMarker>.blocklyPathDark {
|
|
226
|
+
fill-opacity: .2;
|
|
227
|
+
stroke: none;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.blocklyMultilineText {
|
|
231
|
+
font-family: monospace;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.blocklyNonEditableText>text {
|
|
235
|
+
pointer-events: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.blocklyFlyout {
|
|
239
|
+
position: absolute;
|
|
240
|
+
z-index: 20;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.blocklyText text {
|
|
244
|
+
cursor: default;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/*
|
|
248
|
+
Don't allow users to select text. It gets annoying when trying to
|
|
249
|
+
drag a block and selected text moves instead.
|
|
250
|
+
*/
|
|
251
|
+
.blocklySvg text,
|
|
252
|
+
.blocklyBlockDragSurface text {
|
|
253
|
+
user-select: none;
|
|
254
|
+
-ms-user-select: none;
|
|
255
|
+
-webkit-user-select: none;
|
|
256
|
+
cursor: inherit;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.blocklyHidden {
|
|
260
|
+
display: none;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.blocklyFieldDropdown:not(.blocklyHidden) {
|
|
264
|
+
display: block;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.blocklyIconGroup {
|
|
268
|
+
cursor: default;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.blocklyIconGroup:not(:hover),
|
|
272
|
+
.blocklyIconGroupReadonly {
|
|
273
|
+
opacity: .6;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.blocklyIconShape {
|
|
277
|
+
fill: #00f;
|
|
278
|
+
stroke: #fff;
|
|
279
|
+
stroke-width: 1px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.blocklyIconSymbol {
|
|
283
|
+
fill: #fff;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.blocklyMinimalBody {
|
|
287
|
+
margin: 0;
|
|
288
|
+
padding: 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.blocklyHtmlInput {
|
|
292
|
+
border: none;
|
|
293
|
+
border-radius: 4px;
|
|
294
|
+
height: 100%;
|
|
295
|
+
margin: 0;
|
|
296
|
+
outline: none;
|
|
297
|
+
padding: 0;
|
|
298
|
+
width: 100%;
|
|
299
|
+
text-align: center;
|
|
300
|
+
display: block;
|
|
301
|
+
box-sizing: border-box;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* Remove the increase and decrease arrows on the field number editor */
|
|
305
|
+
input.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,
|
|
306
|
+
input.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {
|
|
307
|
+
-webkit-appearance: none;
|
|
308
|
+
margin: 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
input[type=number] {
|
|
312
|
+
-moz-appearance: textfield;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.blocklyMainBackground {
|
|
316
|
+
stroke-width: 1;
|
|
317
|
+
stroke: #c6c6c6; /* Equates to #ddd due to border being off-pixel. */
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.blocklyMutatorBackground {
|
|
321
|
+
fill: #fff;
|
|
322
|
+
stroke: #ddd;
|
|
323
|
+
stroke-width: 1;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.blocklyFlyoutBackground {
|
|
327
|
+
fill: #ddd;
|
|
328
|
+
fill-opacity: .8;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.blocklyMainWorkspaceScrollbar {
|
|
332
|
+
z-index: 20;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.blocklyFlyoutScrollbar {
|
|
336
|
+
z-index: 30;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.blocklyScrollbarHorizontal,
|
|
340
|
+
.blocklyScrollbarVertical {
|
|
341
|
+
position: absolute;
|
|
342
|
+
outline: none;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.blocklyScrollbarBackground {
|
|
346
|
+
opacity: 0;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.blocklyScrollbarHandle {
|
|
350
|
+
fill: #ccc;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,
|
|
354
|
+
.blocklyScrollbarHandle:hover {
|
|
355
|
+
fill: #bbb;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/* Darken flyout scrollbars due to being on a grey background. */
|
|
359
|
+
/* By contrast, workspace scrollbars are on a white background. */
|
|
360
|
+
.blocklyFlyout .blocklyScrollbarHandle {
|
|
361
|
+
fill: #bbb;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.blocklyFlyout .blocklyScrollbarBackground:hover+.blocklyScrollbarHandle,
|
|
365
|
+
.blocklyFlyout .blocklyScrollbarHandle:hover {
|
|
366
|
+
fill: #aaa;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.blocklyInvalidInput {
|
|
370
|
+
background: #faa;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.blocklyVerticalMarker {
|
|
374
|
+
stroke-width: 3px;
|
|
375
|
+
fill: rgba(255,255,255,.5);
|
|
376
|
+
pointer-events: none;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.blocklyComputeCanvas {
|
|
380
|
+
position: absolute;
|
|
381
|
+
width: 0;
|
|
382
|
+
height: 0;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.blocklyNoPointerEvents {
|
|
386
|
+
pointer-events: none;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.blocklyContextMenu {
|
|
390
|
+
border-radius: 4px;
|
|
391
|
+
max-height: 100%;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.blocklyDropdownMenu {
|
|
395
|
+
border-radius: 2px;
|
|
396
|
+
padding: 0 !important;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.blocklyDropdownMenu .blocklyMenuItem {
|
|
400
|
+
/* 28px on the left for icon or checkbox. */
|
|
401
|
+
padding-left: 28px;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/* BiDi override for the resting state. */
|
|
405
|
+
.blocklyDropdownMenu .blocklyMenuItemRtl {
|
|
406
|
+
/* Flip left/right padding for BiDi. */
|
|
407
|
+
padding-left: 5px;
|
|
408
|
+
padding-right: 28px;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.blocklyWidgetDiv .blocklyMenu {
|
|
412
|
+
background: #fff;
|
|
413
|
+
border: 1px solid transparent;
|
|
414
|
+
box-shadow: 0 0 3px 1px rgba(0,0,0,.3);
|
|
415
|
+
font: normal 13px Arial, sans-serif;
|
|
416
|
+
margin: 0;
|
|
417
|
+
outline: none;
|
|
418
|
+
padding: 4px 0;
|
|
419
|
+
position: absolute;
|
|
420
|
+
overflow-y: auto;
|
|
421
|
+
overflow-x: hidden;
|
|
422
|
+
max-height: 100%;
|
|
423
|
+
z-index: 20000; /* Arbitrary, but some apps depend on it... */
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.blocklyWidgetDiv .blocklyMenu.blocklyFocused {
|
|
427
|
+
box-shadow: 0 0 6px 1px rgba(0,0,0,.3);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.blocklyDropDownDiv .blocklyMenu {
|
|
431
|
+
background: inherit; /* Compatibility with gapi, reset from goog-menu */
|
|
432
|
+
border: inherit; /* Compatibility with gapi, reset from goog-menu */
|
|
433
|
+
font: normal 13px "Helvetica Neue", Helvetica, sans-serif;
|
|
434
|
+
outline: none;
|
|
435
|
+
position: relative; /* Compatibility with gapi, reset from goog-menu */
|
|
436
|
+
z-index: 20000; /* Arbitrary, but some apps depend on it... */
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/* State: resting. */
|
|
440
|
+
.blocklyMenuItem {
|
|
441
|
+
border: none;
|
|
442
|
+
color: #000;
|
|
443
|
+
cursor: pointer;
|
|
444
|
+
list-style: none;
|
|
445
|
+
margin: 0;
|
|
446
|
+
/* 7em on the right for shortcut. */
|
|
447
|
+
min-width: 7em;
|
|
448
|
+
padding: 6px 15px;
|
|
449
|
+
white-space: nowrap;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/* State: disabled. */
|
|
453
|
+
.blocklyMenuItemDisabled {
|
|
454
|
+
color: #ccc;
|
|
455
|
+
cursor: inherit;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/* State: hover. */
|
|
459
|
+
.blocklyMenuItemHighlight {
|
|
460
|
+
background-color: rgba(0,0,0,.1);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/* State: selected/checked. */
|
|
464
|
+
.blocklyMenuItemCheckbox {
|
|
465
|
+
height: 16px;
|
|
466
|
+
position: absolute;
|
|
467
|
+
width: 16px;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.blocklyMenuItemSelected .blocklyMenuItemCheckbox {
|
|
471
|
+
background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px;
|
|
472
|
+
float: left;
|
|
473
|
+
margin-left: -24px;
|
|
474
|
+
position: static; /* Scroll with the menu. */
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.blocklyMenuItemRtl .blocklyMenuItemCheckbox {
|
|
478
|
+
float: right;
|
|
479
|
+
margin-right: -24px;
|
|
480
|
+
}
|
|
481
|
+
`,Tc={};Tc.inject=tl,Tc.register=Tt;var Se=class{constructor(e,t,o,s){this.top=e,this.bottom=t,this.left=o,this.right=s}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.top>e.bottom||this.bottom<e.top)}},f=class{constructor(e){this.tagName=e}toString(){return this.tagName}};f.ANIMATE=new f("animate"),f.CIRCLE=new f("circle"),f.CLIPPATH=new f("clipPath"),f.DEFS=new f("defs"),f.FECOMPOSITE=new f("feComposite"),f.FECOMPONENTTRANSFER=new f("feComponentTransfer"),f.FEFLOOD=new f("feFlood"),f.FEFUNCA=new f("feFuncA"),f.FEGAUSSIANBLUR=new f("feGaussianBlur"),f.FEPOINTLIGHT=new f("fePointLight"),f.FESPECULARLIGHTING=new f("feSpecularLighting"),f.FILTER=new f("filter"),f.FOREIGNOBJECT=new f("foreignObject"),f.G=new f("g"),f.IMAGE=new f("image"),f.LINE=new f("line"),f.PATH=new f("path"),f.PATTERN=new f("pattern"),f.POLYGON=new f("polygon"),f.RECT=new f("rect"),f.SVG=new f("svg"),f.TEXT=new f("text"),f.TSPAN=new f("tspan");var J_={getSizeInternal:sh},zt={};zt.TEST_ONLY=J_,zt.getBorderBox=rl,zt.getCascadedStyle=rh,zt.getComputedStyle=Ht,zt.getContainerOffsetToScrollInto=il,zt.getPageOffset=Ro,zt.getSize=_r,zt.getViewportPageOffset=sl,zt.scrollIntoContainerView=Li;var q_=/translate\(\s*([-+\d.e]+)([ ,]\s*([-+\d.e]+)\s*)?/,Z_=/transform:\s*translate(?:3d)?\(\s*([-+\d.e]+)\s*px([ ,]\s*([-+\d.e]+)\s*px)?/,Qg={XY_REGEX:q_,XY_STYLE_REGEX:Z_},Lo={};Lo.TEST_ONLY=Qg,Lo.getDocumentScroll=Di,Lo.getInjectionDivXY=pr,Lo.getRelativeXY=$t,Lo.getViewportBBox=ki,Lo.is3dSupported=nl,Lo.screenToWsCoordinates=ll;var Me=8,On=3,eT=2,Xe=class extends Kt{constructor(e,t,o,s,i){super(e,t,o,s,i),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.eventsInit_=!1,this.deleteIconBorder_=this.deleteGroup_=this.resizeGroup_=this.foreignObject_=this.svgHandleTarget_=this.svgRectTarget_=this.textarea_=null,this.rendered_=this.autoLayout_=this.focused_=!1,this.svgGroup_=I(f.G,{class:"blocklyComment"}),this.workspace=e,this.svgRect_=I(f.RECT,{class:"blocklyCommentRect",x:0,y:0,rx:On,ry:On}),this.svgGroup_.appendChild(this.svgRect_),this.useDragSurface_=!!e.getBlockDragSurface(),this.render()}dispose(){this.disposed_||(_e()===this&&(this.unselect(),this.workspace.cancelCurrentGesture()),Oe()&&x(new(F(Ls))(this)),re(this.svgGroup_),this.disposeInternal_(),ve(),super.dispose(),Ie())}initSvg(e){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");this.workspace.options.readOnly||this.eventsInit_||(w(this.svgRectTarget_,"pointerdown",this,this.pathMouseDown_),w(this.svgHandleTarget_,"pointerdown",this,this.pathMouseDown_)),this.eventsInit_=!0,this.updateMovable(),this.getSvgRoot().parentNode||this.workspace.getBubbleCanvas().appendChild(this.getSvgRoot()),!e&&this.textarea_&&this.textarea_.select()}pathMouseDown_(e){const t=this.workspace.getGesture(e);t&&t.handleBubbleStart(e,this)}showContextMenu(e){throw Error("The implementation of showContextMenu should be monkey-patched in by blockly.ts")}select(){if(_e()!==this){var e=null;if(_e()){e=_e().id,ve();try{_e().unselect()}finally{Ie()}}e=new(F(yo))(e,this.id,this.workspace.id),x(e),et(this),this.addSelect()}}unselect(){if(_e()===this){var e=new(F(yo))(this.id,null,this.workspace.id);x(e),et(null),this.removeSelect(),this.blurFocus()}}addSelect(){U(this.svgGroup_,"blocklySelected"),this.setFocus()}removeSelect(){U(this.svgGroup_,"blocklySelected"),this.blurFocus()}addFocus(){U(this.svgGroup_,"blocklyFocused")}removeFocus(){se(this.svgGroup_,"blocklyFocused")}getRelativeToSurfaceXY(){let e=0,t=0;const o=this.useDragSurface_?this.workspace.getBlockDragSurface().getGroup():null;let s=this.getSvgRoot();if(s)do{var i=$t(s);e+=i.x,t+=i.y,this.useDragSurface_&&this.workspace.getBlockDragSurface().getCurrentBlock()===s&&(i=this.workspace.getBlockDragSurface().getSurfaceTranslation(),e+=i.x,t+=i.y),s=s.parentNode}while(s&&s!==this.workspace.getBubbleCanvas()&&s!==o);return this.xy_=new L(e,t)}moveBy(e,t){const o=new(F(ao))(this),s=this.getRelativeToSurfaceXY();this.translate(s.x+e,s.y+t),this.xy_=new L(s.x+e,s.y+t),o.recordNew(),x(o),this.workspace.resizeContents()}translate(e,t){this.xy_=new L(e,t),this.getSvgRoot().setAttribute("transform","translate("+e+","+t+")")}moveToDragSurface(){if(this.useDragSurface_){var e=this.getRelativeToSurfaceXY();this.clearTransformAttributes_(),this.workspace.getBlockDragSurface().translateSurface(e.x,e.y),this.workspace.getBlockDragSurface().setBlocksAndShow(this.getSvgRoot())}}moveDuringDrag(e,t){e?e.translateSurface(t.x,t.y):(e=`translate(${t.x}, ${t.y})`,this.getSvgRoot().setAttribute("transform",e))}moveTo(e,t){this.translate(e,t)}clearTransformAttributes_(){this.getSvgRoot().removeAttribute("transform")}getBoundingRectangle(){var e=this.getRelativeToSurfaceXY();const t=this.getHeightWidth(),o=e.y,s=e.y+t.height;let i;return this.RTL?(i=e.x-t.width,e=e.x):(i=e.x,e=e.x+t.width),new Se(o,s,i,e)}updateMovable(){this.isMovable()?U(this.svgGroup_,"blocklyDraggable"):se(this.svgGroup_,"blocklyDraggable")}setMovable(e){super.setMovable(e),this.updateMovable()}setEditable(e){super.setEditable(e),this.textarea_&&(this.textarea_.readOnly=!e)}setDragging(e){e?U(this.getSvgRoot(),"blocklyDragging"):se(this.getSvgRoot(),"blocklyDragging")}getSvgRoot(){return this.svgGroup_}getContent(){return this.textarea_?this.textarea_.value:this.content_}setContent(e){super.setContent(e),this.textarea_&&(this.textarea_.value=e)}setDeleteStyle(e){e?U(this.svgGroup_,"blocklyDraggingDelete"):se(this.svgGroup_,"blocklyDraggingDelete")}setAutoLayout(e){}toXmlWithXY(e){let t=0;this.workspace.RTL&&(t=this.workspace.getWidth()),e=this.toXml(e);const o=this.getRelativeToSurfaceXY();return e.setAttribute("x",String(Math.round(this.workspace.RTL?t-o.x:o.x))),e.setAttribute("y",String(Math.round(o.y))),e.setAttribute("h",String(this.getHeight())),e.setAttribute("w",String(this.getWidth())),e}toCopyData(){return{saveInfo:this.toXmlWithXY(),source:this.workspace,typeCounts:null}}getHeightWidth(){return{width:this.getWidth(),height:this.getHeight()}}render(){if(!this.rendered_){var e=this.getHeightWidth(),t=this.createEditor_();this.svgGroup_.appendChild(t),this.svgHandleTarget_=I(f.RECT,{class:"blocklyCommentHandleTarget",x:0,y:0}),this.svgGroup_.appendChild(this.svgHandleTarget_),this.svgRectTarget_=I(f.RECT,{class:"blocklyCommentTarget",x:0,y:0,rx:On,ry:On}),this.svgGroup_.appendChild(this.svgRectTarget_),this.addResizeDom_(),this.isDeletable()&&this.addDeleteDom_(),this.setSize_(e.width,e.height),this.textarea_.value=this.content_,this.rendered_=!0,this.resizeGroup_&&w(this.resizeGroup_,"pointerdown",this,this.resizeMouseDown_),this.isDeletable()&&(w(this.deleteGroup_,"pointerdown",this,this.deleteMouseDown_),w(this.deleteGroup_,"pointerout",this,this.deleteMouseOut_),w(this.deleteGroup_,"pointerup",this,this.deleteMouseUp_))}}createEditor_(){this.foreignObject_=I(f.FOREIGNOBJECT,{x:0,y:Xe.TOP_OFFSET,class:"blocklyCommentForeignObject"});const e=document.createElementNS(Ct,"body");e.setAttribute("xmlns",Ct),e.className="blocklyMinimalBody";const t=document.createElementNS(Ct,"textarea");return t.className="blocklyCommentTextarea",t.setAttribute("dir",this.RTL?"RTL":"LTR"),t.readOnly=!this.isEditable(),e.appendChild(t),this.textarea_=t,this.foreignObject_.appendChild(e),w(t,"wheel",this,function(o){o.stopPropagation()}),w(t,"change",this,function(o){this.setContent(t.value)}),this.foreignObject_}addResizeDom_(){this.resizeGroup_=I(f.G,{class:this.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.svgGroup_),I(f.POLYGON,{points:`0,${Me} ${Me},${Me} ${Me},0`},this.resizeGroup_),I(f.LINE,{class:"blocklyResizeLine",x1:Me/3,y1:Me-1,x2:Me-1,y2:Me/3},this.resizeGroup_),I(f.LINE,{class:"blocklyResizeLine",x1:2*Me/3,y1:Me-1,x2:Me-1,y2:2*Me/3},this.resizeGroup_)}addDeleteDom_(){this.deleteGroup_=I(f.G,{class:"blocklyCommentDeleteIcon"},this.svgGroup_),this.deleteIconBorder_=I(f.CIRCLE,{class:"blocklyDeleteIconShape",r:"7",cx:"7.5",cy:"7.5"},this.deleteGroup_),I(f.LINE,{x1:"5",y1:"10",x2:"10",y2:"5",stroke:"#fff","stroke-width":"2"},this.deleteGroup_),I(f.LINE,{x1:"5",y1:"5",x2:"10",y2:"10",stroke:"#fff","stroke-width":"2"},this.deleteGroup_)}resizeMouseDown_(e){this.unbindDragEvents_(),ro(e)||(this.workspace.startDrag(e,new L(this.workspace.RTL?-this.width_:this.width_,this.height_)),this.onMouseUpWrapper_=w(document,"pointerup",this,this.resizeMouseUp_),this.onMouseMoveWrapper_=w(document,"pointermove",this,this.resizeMouseMove_),this.workspace.hideChaff()),e.stopPropagation()}deleteMouseDown_(e){this.deleteIconBorder_&&U(this.deleteIconBorder_,"blocklyDeleteIconHighlighted"),e.stopPropagation()}deleteMouseOut_(e){this.deleteIconBorder_&&se(this.deleteIconBorder_,"blocklyDeleteIconHighlighted")}deleteMouseUp_(e){this.dispose(),e.stopPropagation()}unbindDragEvents_(){this.onMouseUpWrapper_&&(ce(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(ce(this.onMouseMoveWrapper_),this.onMouseMoveWrapper_=null)}resizeMouseUp_(e){Ut(),this.unbindDragEvents_()}resizeMouseMove_(e){this.autoLayout_=!1,e=this.workspace.moveDrag(e),this.setSize_(this.RTL?-e.x:e.x,e.y)}resizeComment_(){const e=this.getHeightWidth(),t=Xe.TOP_OFFSET,o=2*eT;let s;(s=this.foreignObject_)==null||s.setAttribute("width",String(e.width));let i;if((i=this.foreignObject_)==null||i.setAttribute("height",String(e.height-t)),this.RTL){let a;(a=this.foreignObject_)==null||a.setAttribute("x",String(-e.width))}this.textarea_&&(this.textarea_.style.width=e.width-o+"px",this.textarea_.style.height=e.height-o-t+"px")}setSize_(e,t){e=Math.max(e,45),t=Math.max(t,20+Xe.TOP_OFFSET),this.width_=e,this.height_=t,this.svgRect_.setAttribute("width",`${e}`),this.svgRect_.setAttribute("height",`${t}`);let o;(o=this.svgRectTarget_)==null||o.setAttribute("width",`${e}`);let s;(s=this.svgRectTarget_)==null||s.setAttribute("height",`${t}`);let i;(i=this.svgHandleTarget_)==null||i.setAttribute("width",`${e}`);let a;if((a=this.svgHandleTarget_)==null||a.setAttribute("height",String(Xe.TOP_OFFSET)),this.RTL){this.svgRect_.setAttribute("transform","scale(-1 1)");let p;(p=this.svgRectTarget_)==null||p.setAttribute("transform","scale(-1 1)")}if(this.resizeGroup_)if(this.RTL){this.resizeGroup_.setAttribute("transform","translate("+(-e+Me)+","+(t-Me)+") scale(-1 1)");let p;(p=this.deleteGroup_)==null||p.setAttribute("transform","translate("+(-e+Me)+","+-Me+") scale(-1 1)")}else{this.resizeGroup_.setAttribute("transform","translate("+(e-Me)+","+(t-Me)+")");let p;(p=this.deleteGroup_)==null||p.setAttribute("transform","translate("+(e-Me)+","+-Me+")")}this.resizeComment_()}disposeInternal_(){this.svgHandleTarget_=this.svgRectTarget_=this.foreignObject_=this.textarea_=null,this.disposed_=!0}setFocus(){this.focused_=!0,setTimeout(()=>{this.disposed_||(this.textarea_.focus(),this.addFocus(),this.svgRectTarget_&&U(this.svgRectTarget_,"blocklyCommentTargetFocused"),this.svgHandleTarget_&&U(this.svgHandleTarget_,"blocklyCommentHandleTargetFocused"))},0)}blurFocus(){this.focused_=!1,setTimeout(()=>{this.disposed_||(this.textarea_.blur(),this.removeFocus(),this.svgRectTarget_&&se(this.svgRectTarget_,"blocklyCommentTargetFocused"),this.svgHandleTarget_&&se(this.svgHandleTarget_,"blocklyCommentHandleTargetFocused"))},0)}static fromXmlRendered(e,t,o){ve();let s;try{const i=Kt.parseAttributes(e);if(s=new Xe(t,i.content,i.h,i.w,i.id),t.rendered&&(s.initSvg(!0),s.render()),!isNaN(i.x)&&!isNaN(i.y))if(t.RTL){const a=o||t.getWidth();s.moveBy(a-i.x,i.y)}else s.moveBy(i.x,i.y)}finally{Ie()}return Kt.fireCreateEvent(s),s}};Xe.DEFAULT_SIZE=100,Xe.TOP_OFFSET=10,Tt(`
|
|
482
|
+
.blocklyCommentForeignObject {
|
|
483
|
+
position: relative;
|
|
484
|
+
z-index: 0;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.blocklyCommentRect {
|
|
488
|
+
fill: #E7DE8E;
|
|
489
|
+
stroke: #bcA903;
|
|
490
|
+
stroke-width: 1px;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.blocklyCommentTarget {
|
|
494
|
+
fill: transparent;
|
|
495
|
+
stroke: #bcA903;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.blocklyCommentTargetFocused {
|
|
499
|
+
fill: none;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.blocklyCommentHandleTarget {
|
|
503
|
+
fill: none;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.blocklyCommentHandleTargetFocused {
|
|
507
|
+
fill: transparent;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.blocklyFocused>.blocklyCommentRect {
|
|
511
|
+
fill: #B9B272;
|
|
512
|
+
stroke: #B9B272;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
.blocklySelected>.blocklyCommentTarget {
|
|
516
|
+
stroke: #fc3;
|
|
517
|
+
stroke-width: 3px;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.blocklyCommentDeleteIcon {
|
|
521
|
+
cursor: pointer;
|
|
522
|
+
fill: #000;
|
|
523
|
+
display: none;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.blocklySelected > .blocklyCommentDeleteIcon {
|
|
527
|
+
display: block;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.blocklyDeleteIconShape {
|
|
531
|
+
fill: #000;
|
|
532
|
+
stroke: #000;
|
|
533
|
+
stroke-width: 1px;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.blocklyDeleteIconShape.blocklyDeleteIconHighlighted {
|
|
537
|
+
stroke: #fc3;
|
|
538
|
+
}
|
|
539
|
+
`),n.module$build$src$core$xml={},n.module$build$src$core$xml.appendDomToWorkspace=hh,n.module$build$src$core$xml.blockToDom=Io,n.module$build$src$core$xml.blockToDomWithXY=gr,n.module$build$src$core$xml.clearWorkspaceAndLoadFromXml=uh,n.module$build$src$core$xml.deleteNext=fh,n.module$build$src$core$xml.domToBlock=Wo,n.module$build$src$core$xml.domToPrettyText=ah,n.module$build$src$core$xml.domToText=Vt,n.module$build$src$core$xml.domToVariables=ul,n.module$build$src$core$xml.domToWorkspace=Es,n.module$build$src$core$xml.textToDom=ch,n.module$build$src$core$xml.variablesToDom=al,n.module$build$src$core$xml.workspaceToDom=ih;var Hr=class extends Error{},Q_=class extends Hr{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},Vr=class extends Hr{constructor(e,t,o){super(`The block ${t.toDevString()} is missing a(n) ${e}
|
|
540
|
+
connection`),this.block=t,this.state=o}},ep=class extends Hr{constructor(e,t,o,s){super(`The block ${o.toDevString()} could not connect its
|
|
541
|
+
${t} to its parent, because: ${e}`),this.childBlock=o,this.childState=s}},tp=class extends Hr{constructor(e){super(`Encountered a real block which is defined as a child of a shadow
|
|
542
|
+
block. It is an invariant of Blockly that shadow blocks only have shadow
|
|
543
|
+
children`),this.state=e}},Ps={};Ps.BadConnectionCheck=ep,Ps.DeserializationError=Hr,Ps.MissingBlockType=Q_,Ps.MissingConnection=Vr,Ps.RealChildOfShadow=tp;var op=100,sp=75,rp=50,Sn={};Sn.BLOCKS=rp,Sn.PROCEDURES=sp,Sn.VARIABLES=op;var $c={};$c.register=wi,$c.unregister=bh;var ip=class{constructor(){this.priority=rp}save(e){const t=[];for(const o of e.getTopBlocks(!1))(e=Wt(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)Oo(o,t,{recordUndo:tt()})}clear(e){for(const t of e.getTopBlocks(!1))t.dispose(!1)}};wi("blocks",new ip);var Wr={};Wr.BlockSerializer=ip,Wr.append=Oo,Wr.appendInternal=Gi,Wr.save=Wt;var Bs=class extends ws{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}fromJson(e){_("Blockly.Events.BlockBase.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.blockId=e.blockId}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Bs),t.blockId=e.blockId,t}},Ec=class extends Bs{constructor(e){super(e),this.type=He,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=gr(e),this.ids=Bo(e),this.json=Wt(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=Vt(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}fromJson(e){_("Blockly.Events.BlockCreate.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.xml=Ce(e.xml),this.ids=e.ids,this.json=e.json,e.recordUndo!==void 0&&(this.recordUndo=e.recordUndo)}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Ec),t.xml=Ce(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(e)Oo(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)}}};r(A.EVENT,He,Ec);var np=class extends ws{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.type=ks,this.isBlank=!!e,e&&(this.workspaceId=e.id)}toJson(){const e=super.toJson();if(!this.workspaceId)throw Error("The workspace ID is undefined. Either pass a workspace to the constructor, or call fromJson");return e.workspaceId=this.workspaceId,e}fromJson(e){super.fromJson(e),this.workspaceId=e.workspaceId}};r(A.EVENT,ks,np);var lp=class extends yt{constructor(e,t,o,s){super(e?e.workspace.id:void 0),this.type=Mr,this.blockId=e?e.id:null,this.element=typeof t>"u"?"":t,this.oldValue=typeof o>"u"?"":o,this.newValue=typeof s>"u"?"":s}toJson(){const e=super.toJson();return e.element=this.element,this.newValue!==void 0&&(e.newValue=this.newValue),this.blockId&&(e.blockId=this.blockId),e}fromJson(e){super.fromJson(e),this.element=e.element,this.newValue=e.newValue,this.blockId=e.blockId}};r(A.EVENT,Mr,lp);var es=class extends Bs{constructor(e,t,o,s,i){super(e),this.type=Ge,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,e}fromJson(e){_("Blockly.Events.BlockChange.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.element=e.element,this.name=e.name,this.oldValue=e.oldValue,this.newValue=e.newValue}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new es),t.element=e.element,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");switch(t.mutator&&t.mutator.setVisible(!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":t.setEnabled(!e);break;case"inline":t.setInputsInline(!!e);break;case"mutation":const o=es.getExtraBlockState_(t);t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(Ce(e||"<mutation/>")),x(new es(t,"mutation",null,o,e));break;default:console.warn("Unknown change type: "+this.element)}}static getExtraBlockState_(e){return e.saveExtraState?(e=e.saveExtraState())?JSON.stringify(e):"":e.mutationToDom&&(e=e.mutationToDom())?Vt(e):""}};r(A.EVENT,Ge,es);var mc=class extends Bs{constructor(e){if(super(e),this.type=jt,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.oldXml=gr(e),this.ids=Bo(e),this.wasShadow=e.isShadow(),this.oldJson=Wt(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=Vt(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}fromJson(e){_("Blockly.Events.BlockDelete.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldXml=Ce(e.oldXml),this.ids=e.ids,this.wasShadow=e.wasShadow||this.oldXml.tagName.toLowerCase()==="shadow",this.oldJson=e.oldJson,e.recordUndo!==void 0&&(this.recordUndo=e.recordUndo)}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new mc),t.oldXml=Ce(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 Oo(this.oldJson,t)}};r(A.EVENT,jt,mc);var M;(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"})(M||(M={})),n.module$build$src$core$connection_type={},n.module$build$src$core$connection_type.ConnectionType=M;var ie=class{constructor(e,t){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}connect_(e){const t=M.INPUT_VALUE,o=this.getSourceBlock();var s=e.getSourceBlock();e.isConnected()&&e.disconnectInternal(!1);let i;if(this.isConnected()){const p=this.stashShadowState_(),$=this.targetBlock();$.isShadow()?$.dispose(!1):(this.disconnectInternal(),i=$),this.applyShadowState_(p)}let a;Oe()&&(a=new(F(ze))(s)),Bh(this,e),s.setParent(o),a&&(a.recordNew(),x(a)),i&&(e=this.type===t?i.outputConnection:i.previousConnection)&&((s=ie.getConnectionForOrphanedConnection(s,e))?e.connect(s):e.onFailedConnect(this))}dispose(){if(this.isConnected()){this.setShadowStateInternal_();const e=this.targetBlock();e&&!e.isDeadOrDying()&&e.unplug()}this.disposed=!0}getSourceBlock(){return this.sourceBlock_}isSuperior(){return this.type===M.INPUT_VALUE||this.type===M.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=K();t||C(!0),this.isSuperior()?this.connect_(e):e.connect_(this),C(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=K();s||C(!0);let i;Oe()&&(i=new(F(ze))(o.getSourceBlock()));const a=this.targetConnection;a&&(a.targetConnection=null),this.targetConnection=null,e&&o.getSourceBlock().setParent(null),i&&(i.recordNew(),x(i)),o.getSourceBlock().isShadow()||t.respawnShadow_(),C(s)}getParentAndChildConnections(){return this.targetConnection?this.isSuperior()?{parentConnection:this,childConnection:this.targetConnection}:{parentConnection:this.targetConnection,childConnection:this}:{}}respawnShadow_(){this.createShadowBlock_(!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()?Io(this.targetBlock()):this.shadowDom_}setShadowState(e){this.setShadowStateInternal_({shadowState:e})}getShadowState(e){return e&&this.targetBlock()&&this.targetBlock().isShadow()?Wt(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,(e=this.targetBlock())?e.isShadow()?(e.dispose(!1),this.getSourceBlock().isDeadOrDying()||(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=Gi(o,t.workspace,{parentConnection:e?this:void 0,isShadow:!0,recordUndo:!1});if(s){if(t=Wo(s,t.workspace),e)if(this.type===M.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===M.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_=Io(e),this.shadowState_=Wt(e))}static getConnectionForOrphanedConnection(e,t){if(t.type===M.OUTPUT_VALUE)return Fh(e,t.getSourceBlock());e=e.lastConnectionInStack(!0);const o=t.getConnectionChecker();return e&&o.canConnect(t,e,!1)?e:null}};ie.CAN_CONNECT=0,ie.REASON_SELF_CONNECTION=1,ie.REASON_WRONG_TYPE=2,ie.REASON_TARGET_NULL=3,ie.REASON_CHECKS_FAILED=4,ie.REASON_DIFFERENT_WORKSPACES=5,ie.REASON_SHADOW_PARENT=6,ie.REASON_DRAG_CHECKS_FAILED=7,ie.REASON_PREVIOUS_AND_OUTPUT=8;var xs="_TEMP_COLLAPSED_INPUT",vn="_TEMP_COLLAPSED_FIELD",fc={};fc.COLLAPSED_FIELD_NAME=vn,fc.COLLAPSED_INPUT_NAME=xs;var Cn={};Cn.clamp=fs,Cn.toDegrees=Tl,Cn.toRadians=ms;var Xr=16,bc=1,ap=12,Rc=16,Nn=.25,Ic=null,ts=null,Fs="",Us="",ne,Hs,os,Oc=null,ko=null,cp=null,Sc={getBoundsInfo:function(){const e=Ro(Oc),t=_r(Oc);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=Sc.getBoundsInfo(),a=_r(ne);return t+a.height<i.bottom?Ol(e,t,i,a):s-a.height>i.top?Sl(o,s,i,a):t+a.height<document.documentElement.clientHeight?Ol(e,t,i,a):s-a.height>document.documentElement.clientTop?Sl(o,s,i,a):Hh(e,i,a)}},ye={};ye.ANIMATION_TIME=Nn,ye.ARROW_HORIZONTAL_PADDING=ap,ye.ARROW_SIZE=Xr,ye.BORDER_SIZE=bc,ye.PADDING_Y=Rc,ye.TEST_ONLY=Sc,ye.clearContent=Pi,ye.createDom=$l,ye.getContentDiv=bs,ye.getOwner=ml,ye.getPositionX=$r,ye.hide=xi,ye.hideIfOwner=Rs,ye.hideWithoutAnimation=It,ye.isVisible=vl,ye.repositionForWindowResize=Vh,ye.setBoundsElement=El,ye.setColour=Bi,ye.show=Il,ye.showPositionedByBlock=Uh,ye.showPositionedByField=Tr;var jr=class{constructor(e){this.workspace=e,this.cursorSvg_=this.cursor_=null,this.markers=new Map,this.markerSvg_=null}registerMarker(e,t){this.markers.has(e)&&this.unregisterMarker(e),t.setDrawer(this.workspace.getRenderer().makeMarkerDrawer(this.workspace,t)),this.setMarkerSvg(t.getDrawer().createDom()),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_&&this.cursor_.getDrawer()&&this.cursor_.getDrawer().dispose(),(this.cursor_=e)&&(e=this.workspace.getRenderer().makeMarkerDrawer(this.workspace,this.cursor_),this.cursor_.setDrawer(e),this.setCursorSvg(this.cursor_.getDrawer().createDom()))}setCursorSvg(e){e?(this.workspace.getBlockCanvas().appendChild(e),this.cursorSvg_=e):this.cursorSvg_=null}setMarkerSvg(e){e?this.workspace.getBlockCanvas()&&(this.cursorSvg_?this.workspace.getBlockCanvas().insertBefore(e,this.cursorSvg_):this.workspace.getBlockCanvas().appendChild(e)):this.markerSvg_=null}updateMarkers(){this.workspace.keyboardAccessibilityMode&&this.cursorSvg_&&this.workspace.getCursor().draw()}dispose(){const e=Object.keys(this.markers);for(let t=0,o;o=e[t];t++)this.unregisterMarker(o);this.markers.clear(),this.cursor_&&(this.cursor_.dispose(),this.cursor_=null)}};jr.LOCAL_MARKER="local_marker_1",n.module$build$src$core$utils$string={},n.module$build$src$core$utils$string.commonWordPrefix=Nl,n.module$build$src$core$utils$string.commonWordSuffix=yl,n.module$build$src$core$utils$string.isNumber=kl,n.module$build$src$core$utils$string.shortestStringLength=Er,n.module$build$src$core$utils$string.startsWith=Wh,n.module$build$src$core$utils$string.wrap=Al;var yn=void 0,Yr=!1,Vs=!1,up=50,hp=0,ss=0,vc=0,Cc=0,Et=null,Kr=null,Nc=0,yc=10,dp=10,_p=750,An=5,ke=null,Ae={};Ae.HOVER_MS=_p,Ae.LIMIT=up,Ae.MARGINS=An,Ae.OFFSET_X=Nc,Ae.OFFSET_Y=yc,Ae.RADIUS_OK=dp,Ae.bindMouseEvents=mr,Ae.block=Bl,Ae.createDom=Ml,Ae.dispose=Pl,Ae.getCustomTooltip=Kh,Ae.getDiv=Jh,Ae.getTooltipOfObject=Is,Ae.hide=So,Ae.isVisible=zh,Ae.setCustomTooltip=Yh,Ae.unbindMouseEvents=wl,Ae.unblock=xl;var Ac=.45,Lc=.65,pp={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"},je={};je.blend=Xo,je.getHsvSaturation=Fl,je.getHsvValue=Ul,je.hexToRgb=Ui,je.hsvToHex=Hi,je.hueToHex=Vi,je.names=pp,je.parse=vo,je.rgbToHex=fr,je.setHsvSaturation=sd,je.setHsvValue=rd;var zr={};zr.checkMessageReferences=br,zr.parseBlockColour=jo,zr.replaceMessageReferences=Ee,zr.tokenizeInterpolation=Xi;var Ln=null,kn=null,Ws="",Xs="",At,Lt={};Lt.createDom=Hl,Lt.getDiv=Yo,Lt.hide=Ot,Lt.hideIfOwner=Yi,Lt.isVisible=Vl,Lt.positionWithAnchor=Xl,Lt.show=ji,Lt.testOnly_setDiv=id;var ee=class{constructor(e,t,o){this.DEFAULT_VALUE=null,this.name=void 0,this.constants_=this.mouseDownWrapper_=this.textContent_=this.textElement_=this.borderRect_=this.fieldGroup_=this.markerSvg_=this.cursorSvg_=this.tooltip_=this.validator_=null,this.disposed=!1,this.maxDisplayLength=50,this.sourceBlock_=null,this.enabled_=this.visible_=this.isDirty_=!0,this.suffixField=this.prefixField=this.clickTarget_=null,this.EDITABLE=!0,this.SERIALIZABLE=!1,this.CURSOR="",this.value_="DEFAULT_VALUE"in new.target.prototype?new.target.prototype.DEFAULT_VALUE:this.DEFAULT_VALUE,this.size_=new Pe(0,0),e!==ee.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(Ee(e.tooltip))}setSourceBlock(e){if(this.sourceBlock_)throw Error("Field already bound to a block");this.sourceBlock_=e}getConstants(){return!this.constants_&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()&&this.sourceBlock_.workspace.rendered&&(this.constants_=this.sourceBlock_.workspace.getRenderer().getConstants()),this.constants_}getSourceBlock(){return this.sourceBlock_}init(){this.fieldGroup_||(this.fieldGroup_=I(f.G,{}),this.isVisible()||(this.fieldGroup_.style.display="none"),this.sourceBlock_.getSvgRoot().appendChild(this.fieldGroup_),this.initView(),this.updateEditable(),this.setTooltip(this.tooltip_),this.bindEvents_(),this.initModel())}initView(){this.createBorderRect_(),this.createTextElement_()}initModel(){}createBorderRect_(){this.borderRect_=I(f.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_=I(f.TEXT,{class:"blocklyText"},this.fieldGroup_),this.getConstants().FIELD_TEXT_BASELINE_CENTER&&this.textElement_.setAttribute("dominant-baseline","central"),this.textContent_=document.createTextNode(""),this.textElement_.appendChild(this.textContent_)}bindEvents_(){const e=this.getClickTarget_();if(!e)throw Error("A click target has not been set.");mr(e),this.mouseDownWrapper_=w(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(ee),e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(ee,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||""),bo(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(Ce(t)),!0):!1}dispose(){Rs(this),Yi(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||re(this.fieldGroup_),this.disposed=!0}updateEditable(){const e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(U(e,"blocklyEditableText"),se(e,"blocklyNonEditableText"),e.style.cursor=this.CURSOR):(U(e,"blocklyNonEditableText"),se(e,"blocklyEditableText"),e.style.cursor=""))}setEnabled(e){this.enabled_=e,this.updateEditable()}isEnabled(){return this.enabled_}isClickable(){return this.enabled_&&!!this.sourceBlock_&&this.sourceBlock_.isEditable()&&this.showEditor_!==ee.prototype.showEditor_}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){}updateSize_(e){const t=this.getConstants();e=e!==void 0?e:this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let o=2*e,s=t.FIELD_TEXT_HEIGHT,i=0;this.textElement_&&(i=h(this.textElement_,t.FIELD_TEXT_FONTSIZE,t.FIELD_TEXT_FONTWEIGHT,t.FIELD_TEXT_FONTFAMILY),o+=i),this.borderRect_&&(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.visible_&&this.size_.width===0&&(this.render_(),this.size_.width!==0&&console.warn("Deprecated use of setting size_.width to 0 to rerender a field. Set field.isDirty_ to true instead.")),this.size_):new Pe(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new Le;if(this.borderRect_){var o=this.borderRect_.getBoundingClientRect();e=Ro(this.borderRect_),t=o.width,o=o.height}else{o=this.sourceBlock_.getHeightWidth();const s=t.workspace.scale;e=this.getAbsoluteXY_(),t=(o.width+1)*s,o=(o.height+1)*s,hc?(e.x+=1.5*s,e.y+=1.5*s):(e.x-=.5*s,e.y-=.5*s)}return new Se(e.y,e.y+o,e.x,e.x+t)}getDisplayText_(){let e=this.getText();return e?(e.length>this.maxDisplayLength&&(e=e.substring(0,this.maxDisplayLength-2)+"…"),e=e.replace(/\s/g,ee.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+=""),e):ee.NBSP}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(),this.sourceBlock_.bumpNeighbours())}setValue(e){if(e!==null){var t=this.doClassValidation_(e);if(e=this.processValidation_(e,t),!(e instanceof Error)){var o;t=(o=this.getValidator())==null?void 0:o.call(this,e),o=this.processValidation_(e,t),o instanceof Error||(e=this.sourceBlock_,e&&e.disposed||(t=this.getValue(),t===o?this.doValueUpdate_(o):(this.doValueUpdate_(o),e&&Oe()&&x(new(F(Ge))(e,"field",this.name||null,t,o)),this.isDirty_&&this.forceRerender())))}}}processValidation_(e,t){return t===null?(this.doValueInvalid_(e),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){}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 Is(e||{tooltip:this.tooltip_})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Ro(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null;const t=this.getSourceBlock();if(!t)throw new Le;const o=t.inputList;for(let s=0;s<t.inputList.length;s++){const i=o[s],a=i.fieldRow;for(let p=0;p<a.length;p++)if(a[p]===this){e=i;break}}return e}getFlipRtl(){return!1}isTabNavigable(){return!1}onShortcut(e){return!1}setCursorSvg(e){if(e){if(!this.fieldGroup_)throw Error(`The field group is ${this.fieldGroup_}.`);this.fieldGroup_.appendChild(e),this.cursorSvg_=e}else this.cursorSvg_=null}setMarkerSvg(e){if(e){if(!this.fieldGroup_)throw Error(`The field group is ${this.fieldGroup_}.`);this.fieldGroup_.appendChild(e),this.markerSvg_=e}else this.markerSvg_=null}updateMarkers_(){var e=this.getSourceBlock();if(!e)throw new Le;e=e.workspace,e.keyboardAccessibilityMode&&this.cursorSvg_&&e.getCursor().draw(),e.keyboardAccessibilityMode&&this.markerSvg_&&e.getMarker(jr.LOCAL_MARKER).draw()}};ee.NBSP=" ",ee.SKIP_SETUP=Symbol("SKIP_SETUP");var Le=class extends Error{constructor(){super("The field has not yet been attached to its input. Call appendField to attach it.")}},kc;kc={fromJsonInternal:cd},n.module$build$src$core$field_registry={},n.module$build$src$core$field_registry.TEST_ONLY=kc,n.module$build$src$core$field_registry.fromJson=Ki,n.module$build$src$core$field_registry.register=ut,n.module$build$src$core$field_registry.unregister=ad;var tT="aria-",oT="role",lt;(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"})(lt||(lt={}));var pe;(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"})(pe||(pe={}));var Jr={};Jr.Role=lt,Jr.State=pe,Jr.setRole=St,Jr.setState=ge;var Dc=class{constructor(){this.menuItems=[],this.roleName=this.element=this.onKeyDownHandler=this.mouseLeaveHandler=this.mouseEnterHandler=this.clickHandler=this.mouseOverHandler=this.highlightedItem=this.openingCoords=null}addChild(e){this.menuItems.push(e)}render(e){const t=document.createElement("div");t.className="blocklyMenu goog-menu blocklyNonSelectable",t.tabIndex=0,this.roleName&&St(t,this.roleName),this.element=t;for(let o=0,s;s=this.menuItems[o];o++)t.appendChild(s.createDom());return this.mouseOverHandler=w(t,"pointerover",this,this.handleMouseOver,!0),this.clickHandler=w(t,"pointerup",this,this.handleClick,!0),this.mouseEnterHandler=w(t,"pointerenter",this,this.handleMouseEnter,!0),this.mouseLeaveHandler=w(t,"pointerleave",this,this.handleMouseLeave,!0),this.onKeyDownHandler=w(t,"keydown",this,this.handleKeyEvent),e.appendChild(t),t}getElement(){return this.element}focus(){const e=this.getElement();e&&(e.focus({preventScroll:!0}),U(e,"blocklyFocused"))}blur(){const e=this.getElement();e&&(e.blur(),se(e,"blocklyFocused"))}setRole(e){this.roleName=e}dispose(){this.mouseOverHandler&&(ce(this.mouseOverHandler),this.mouseOverHandler=null),this.clickHandler&&(ce(this.clickHandler),this.clickHandler=null),this.mouseEnterHandler&&(ce(this.mouseEnterHandler),this.mouseEnterHandler=null),this.mouseLeaveHandler&&(ce(this.mouseLeaveHandler),this.mouseLeaveHandler=null),this.onKeyDownHandler&&(ce(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")){for(let o=0,s;s=this.menuItems[o];o++)if(s.getElement()===e)return s}e=e.parentElement}return null}setHighlighted(e){var t=this.highlightedItem;t&&(t.setHighlighted(!1),this.highlightedItem=null),e&&(e.setHighlighted(!0),this.highlightedItem=e,t=this.getElement(),Li(e.getElement(),t),ge(t,pe.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(0>e?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;let o;for(;o=this.menuItems[e];){if(o.isEnabled()){this.setHighlighted(o);break}e+=t}}handleMouseOver(e){(e=this.getMenuItem(e.target))&&(e.isEnabled()?this.highlightedItem!==e&&this.setHighlighted(e):this.setHighlighted(null))}handleClick(e){const t=this.openingCoords;if(this.openingCoords=null,t&&typeof e.clientX=="number"){const o=new L(e.clientX,e.clientY);if(1>L.distance(t,o))return}(e=this.getMenuItem(e.target))&&e.performAction()}handleMouseEnter(e){this.focus()}handleMouseLeave(e){this.getElement()&&(this.blur(),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();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=_r(e);return t.height=e.scrollHeight,t}},Mc=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=oo(),this.element=e,e.className="blocklyMenuItem goog-menuitem "+(this.enabled?"":"blocklyMenuItemDisabled goog-menuitem-disabled ")+(this.checked?"blocklyMenuItemSelected goog-option-selected ":"")+(this.highlight?"blocklyMenuItemHighlight goog-menuitem-highlight ":"")+(this.rightToLeft?"blocklyMenuItemRtl goog-menuitem-rtl ":"");const t=document.createElement("div");if(t.className="blocklyMenuItemContent goog-menuitem-content",this.checkable){var o=document.createElement("div");o.className="blocklyMenuItemCheckbox goog-menuitem-checkbox",t.appendChild(o)}return o=this.content,typeof this.content=="string"&&(o=document.createTextNode(this.content)),t.appendChild(o),e.appendChild(t),this.roleName&&St(e,this.roleName),ge(e,pe.SELECTED,this.checkable&&this.checked||!1),ge(e,pe.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?(U(t,"blocklyMenuItemHighlight"),U(t,"goog-menuitem-highlight")):(se(t,"blocklyMenuItemHighlight"),se(t,"goog-menuitem-highlight")))}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}performAction(){this.isEnabled()&&this.actionHandler&&this.actionHandler(this)}onAction(e,t){this.actionHandler=e.bind(t)}},Jt=class extends ee{constructor(e,t,o){super(ee.SKIP_SETUP),this.svgArrow_=this.arrow_=this.imageElement_=this.menu_=this.selectedMenuItem_=null,this.SERIALIZABLE=!0,this.CURSOR="default",this.clickTarget_=this.suffixField=this.prefixField=this.generatedOptions_=null,e!==ee.SKIP_SETUP&&(Array.isArray(e)?(jl(e),e=ud(e),this.menuGenerator_=e.options,this.prefixField=e.prefix||null,this.suffixField=e.suffix||null):this.menuGenerator_=e,this.selectedOption_=this.getOptions(!1)[0],o&&this.configure_(o),this.setValue(this.selectedOption_[1]),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(Jt,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement_=I(f.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&U(this.borderRect_,"blocklyDropdownRect")}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_=I(f.TSPAN,{},this.textElement_);let e;this.arrow_.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?Jt.ARROW_CHAR+" ":" "+Jt.ARROW_CHAR));let t;(t=this.getSourceBlock())!=null&&t.RTL?this.getTextElement().insertBefore(this.arrow_,this.textContent_):this.getTextElement().appendChild(this.arrow_)}createSVGArrow_(){this.svgArrow_=I(f.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),this.svgArrow_.setAttributeNS(it,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new Le;this.dropdownCreate_(),this.menu_.openingCoords=e&&typeof e.clientX=="number"?new L(e.clientX,e.clientY):null,Pi(),e=this.menu_.render(bs()),U(e,"blocklyDropdownMenu"),this.getConstants().FIELD_DROPDOWN_COLOURED_DIV&&(e=t.isShadow()?t.getParent().getColour():t.getColour(),t=t.isShadow()?t.getParent().style.colourTertiary:this.sourceBlock_.style.colourTertiary,Bi(e,t)),Tr(this,this.dropdownDispose_.bind(this)),this.menu_.focus(),this.selectedMenuItem_&&(this.menu_.setHighlighted(this.selectedMenuItem_),Li(this.selectedMenuItem_.getElement(),bs(),!0)),this.applyColour()}dropdownCreate_(){const e=this.getSourceBlock();if(!e)throw new Le;const t=new Dc;t.setRole(lt.LISTBOX),this.menu_=t;const o=this.getOptions(!1);this.selectedMenuItem_=null;for(let i=0;i<o.length;i++){const[a,p]=o[i];if(typeof a=="object"){var s=new Image(a.width,a.height);s.src=a.src,s.alt=a.alt||""}else s=a;s=new Mc(s,p),s.setRole(lt.OPTION),s.setRightToLeft(e.RTL),s.setCheckable(!0),t.addChild(s),s.setChecked(p===this.value_),p===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){Rs(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_(),jl(this.generatedOptions_),this.generatedOptions_)}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_.style;this.borderRect_&&(this.borderRect_.setAttribute("stroke",e.colourTertiary),this.menu_?this.borderRect_.setAttribute("fill",e.colourTertiary):this.borderRect_.setAttribute("fill","transparent")),this.sourceBlock_&&this.arrow_&&(this.sourceBlock_.isShadow()?this.arrow_.style.fill=e.colourSecondary:this.arrow_.style.fill=e.colourPrimary)}render_(){this.getTextContent().nodeValue="",this.imageElement_.style.display="none";const e=this.selectedOption_&&this.selectedOption_[0];e&&typeof e=="object"?this.renderSelectedImage_(e):this.renderSelectedText_(),this.positionBorderRect_()}renderSelectedImage_(e){const t=this.getSourceBlock();if(!t)throw new Le;this.imageElement_.style.display="",this.imageElement_.setAttributeNS(it,"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+rT);s=s?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let a;a=this.svgArrow_?this.positionSVGArrow_(e+s,i/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):h(this.arrow_,this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY),this.size_.width=e+a+2*s,this.size_.height=i;let p=0;t.RTL?this.imageElement_.setAttribute("x",`${s+a}`):(p=e+a,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement_.setAttribute("x",`${s}`)),this.imageElement_.setAttribute("y",String(i/2-o/2)),this.positionTextElement_(p+s,e+a)}renderSelectedText_(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();U(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=h(this.getTextElement(),this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY);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+2*t,this.size_.height=e,this.positionTextElement_(t,o)}positionSVGArrow_(e,t){if(!this.svgArrow_)return 0;const o=this.getSourceBlock();if(!o)throw new Le;const s=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,i=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,a=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow_.setAttribute("transform","translate("+(o.RTL?s:e+i)+","+t+")"),a+i}getText_(){if(!this.selectedOption_)return null;const e=this.selectedOption_[0];return typeof e=="object"?e.alt:e}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)}};Jt.CHECKMARK_OVERHANG=25,Jt.MAX_MENU_HEIGHT_VH=.45,Jt.ARROW_CHAR="▾";var sT=5,rT=2*sT;ut("field_dropdown",Jt);var wc=class extends yt{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=lo,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}fromJson(e){_("Blockly.Events.BubbleOpen.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.isOpen=e.isOpen,this.bubbleType=e.bubbleType,this.blockId=e.blockId}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new wc),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},Gc;(function(e){e.MUTATOR="mutator",e.COMMENT="comment",e.WARNING="warning"})(Gc||(Gc={})),r(A.EVENT,lo,wc);var me=class{constructor(e,t,o,s,i){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new L(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new L(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=o||!1,this.margin=i!==void 0?i:me.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),s&&(e+=" "+s),this.outerSvg=I(f.SVG,{class:e}),s=I(f.G,{},this.outerSvg),this.svgBackground=I(f.RECT,{class:"blocklyScrollbarBackground"},s),e=Math.floor((me.scrollbarThickness-5)/2),this.svgHandle=I(f.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"),Rt(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=w(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=w(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const e=me.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(),ce(this.onMouseDownBarWrapper_),ce(this.onMouseDownHandleWrapper_),re(this.outerSvg),this.workspace.getThemeManager().unsubscribe(this.svgHandle)}constrainHandleLength(e){return e=0>=e||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=0>=e||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,so(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&&me.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-2*this.margin;this.pair&&(t-=me.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=me.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-me.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-2*this.margin;this.pair&&(t-=me.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-me.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){const t=e!==this.isVisible();if(this.pair)throw Error("Unable to toggle visibility of paired scrollbars.");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(),Ut(),this.cleanUp(),ro(e))e.stopPropagation();else{var t=Vo(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var o=pr(this.svgHandle);o=this.horizontal?o.x:o.y;var s=this.handlePosition,i=.95*this.handleLength;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(),ro(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.workspace.setupDragSurface(),this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=w(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=w(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(){this.workspace.resetDragSurface(),Ut(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(ce(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(ce(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 L(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}};me.scrollbarThickness=x_?25:15,me.DEFAULT_SCROLLBAR_MARGIN=.5;var W=class{constructor(e,t,o,s,i,a){this.resizeGroup=this.bubbleBack=this.bubbleArrow=this.bubbleGroup=null,this.height=this.width=this.relativeTop=this.relativeLeft=0,this.autoLayout=!0,this.onMouseDownResizeWrapper=this.onMouseDownBubbleWrapper=this.moveCallback=this.resizeCallback=null,this.rendered=this.disposed=!1,this.workspace_=e,this.content_=t,this.shape_=o,o=W.ARROW_ANGLE,this.workspace_.RTL&&(o=-o),this.arrowRadians=ms(o),e.getBubbleCanvas().appendChild(this.createDom(t,!(!i||!a))),this.setAnchorLocation(s),i&&a||(e=this.content_.getBBox(),i=e.width+2*W.BORDER_WIDTH,a=e.height+2*W.BORDER_WIDTH),this.setBubbleSize(i,a),this.positionBubble(),this.renderArrow(),this.rendered=!0}createDom(e,t){this.bubbleGroup=I(f.G,{});var o={filter:"url(#"+this.workspace_.getRenderer().getConstants().embossFilterId+")"};return j_&&(o={}),o=I(f.G,o,this.bubbleGroup),this.bubbleArrow=I(f.PATH,{},o),this.bubbleBack=I(f.RECT,{class:"blocklyDraggable",x:0,y:0,rx:W.BORDER_WIDTH,ry:W.BORDER_WIDTH},o),t?(this.resizeGroup=I(f.G,{class:this.workspace_.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.bubbleGroup),t=2*W.BORDER_WIDTH,I(f.POLYGON,{points:`0,${t} ${t},${t} ${t},0`},this.resizeGroup),I(f.LINE,{class:"blocklyResizeLine",x1:t/3,y1:t-1,x2:t-1,y2:t/3},this.resizeGroup),I(f.LINE,{class:"blocklyResizeLine",x1:2*t/3,y1:t-1,x2:t-1,y2:2*t/3},this.resizeGroup)):this.resizeGroup=null,this.workspace_.options.readOnly||(this.onMouseDownBubbleWrapper=w(this.bubbleBack,"pointerdown",this,this.bubbleMouseDown),this.resizeGroup&&(this.onMouseDownResizeWrapper=w(this.resizeGroup,"pointerdown",this,this.resizeMouseDown))),this.bubbleGroup.appendChild(e),this.bubbleGroup}getSvgRoot(){return this.bubbleGroup}setSvgId(e){let t;(t=this.bubbleGroup)==null||t.setAttribute("data-block-id",e)}bubbleMouseDown(e){const t=this.workspace_.getGesture(e);t&&t.handleBubbleStart(e,this)}showContextMenu(e){}isDeletable(){return!1}setDeleteStyle(e){}resizeMouseDown(e){this.promote(),W.unbindDragEvents(),ro(e)||(this.workspace_.startDrag(e,new L(this.workspace_.RTL?-this.width:this.width,this.height)),W.onMouseUpWrapper=w(document,"pointerup",this,W.bubbleMouseUp),W.onMouseMoveWrapper=w(document,"pointermove",this,this.resizeMouseMove),this.workspace_.hideChaff()),e.stopPropagation()}resizeMouseMove(e){this.autoLayout=!1,e=this.workspace_.moveDrag(e),this.setBubbleSize(this.workspace_.RTL?-e.x:e.x,e.y),this.workspace_.RTL&&this.positionBubble()}registerResizeEvent(e){this.resizeCallback=e}registerMoveEvent(e){this.moveCallback=e}promote(){let e;const t=(e=this.bubbleGroup)==null?void 0:e.parentNode;return(t==null?void 0:t.lastChild)!==this.bubbleGroup&&this.bubbleGroup?(t==null||t.appendChild(this.bubbleGroup),!0):!1}setAnchorLocation(e){this.anchorXY=e,this.rendered&&this.positionBubble()}layoutBubble(){var e=this.workspace_.getMetricsManager().getViewMetrics(!0),t=this.getOptimalRelativeLeft(e),o=this.getOptimalRelativeTop(e),s=this.shape_.getBBox();const i={x:t,y:-this.height-this.workspace_.getRenderer().getConstants().MIN_BLOCK_HEIGHT},a={x:-this.width-30,y:o};o={x:s.width,y:o};var p={x:t,y:s.height};t=s.width<s.height?o:p,s=s.width<s.height?p:o,o=this.getOverlap(i,e),p=this.getOverlap(a,e);const $=this.getOverlap(t,e);e=this.getOverlap(s,e),e=Math.max(o,p,$,e),o===e?(this.relativeLeft=i.x,this.relativeTop=i.y):p===e?(this.relativeLeft=a.x,this.relativeTop=a.y):$===e?(this.relativeLeft=t.x,this.relativeTop=t.y):(this.relativeLeft=s.x,this.relativeTop=s.y)}getOverlap(e,t){var o=this.workspace_.RTL?this.anchorXY.x-e.x-this.width:e.x+this.anchorXY.x;return e=e.y+this.anchorXY.y,Math.max(0,Math.min(1,(Math.min(o+this.width,t.left+t.width)-Math.max(o,t.left))*(Math.min(e+this.height,t.top+t.height)-Math.max(e,t.top))/(this.width*this.height)))}getOptimalRelativeLeft(e){let t=-this.width/4;if(this.width>e.width)return t;if(this.workspace_.RTL){var o=this.anchorXY.x-t,s=e.left+e.width;e=e.left+me.scrollbarThickness/this.workspace_.scale,o-this.width<e?t=-(e-this.anchorXY.x+this.width):o>s&&(t=-(s-this.anchorXY.x))}else{o=t+this.anchorXY.x,s=o+this.width;const i=e.left;e=e.left+e.width-me.scrollbarThickness/this.workspace_.scale,o<i?t=i-this.anchorXY.x:s>e&&(t=e-this.anchorXY.x-this.width)}return t}getOptimalRelativeTop(e){let t=-this.height/4;if(this.height>e.height)return t;const o=this.anchorXY.y+t,s=o+this.height,i=e.top;e=e.top+e.height-me.scrollbarThickness/this.workspace_.scale;const a=this.anchorXY.y;return o<i?t=i-a:s>e&&(t=e-a-this.height),t}positionBubble(){let e=this.anchorXY.x;e=this.workspace_.RTL?e-(this.relativeLeft+this.width):e+this.relativeLeft,this.moveTo(e,this.relativeTop+this.anchorXY.y)}moveTo(e,t){let o;(o=this.bubbleGroup)==null||o.setAttribute("transform","translate("+e+","+t+")")}setDragging(e){!e&&this.moveCallback&&this.moveCallback()}getBubbleSize(){return new Pe(this.width,this.height)}setBubbleSize(e,t){const o=2*W.BORDER_WIDTH;e=Math.max(e,o+45),t=Math.max(t,o+20),this.width=e,this.height=t;let s;(s=this.bubbleBack)==null||s.setAttribute("width",`${e}`);let i;(i=this.bubbleBack)==null||i.setAttribute("height",`${t}`),this.resizeGroup&&(this.workspace_.RTL?this.resizeGroup.setAttribute("transform","translate("+2*W.BORDER_WIDTH+","+(t-o)+") scale(-1 1)"):this.resizeGroup.setAttribute("transform","translate("+(e-o)+","+(t-o)+")")),this.autoLayout&&this.layoutBubble(),this.positionBubble(),this.renderArrow(),this.resizeCallback&&this.resizeCallback()}renderArrow(){const e=[];var t=this.width/2,o=this.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 a=Math.sqrt(i*i+s*s),p=Math.acos(s/a);0>i&&(p=2*Math.PI-p);var $=p+Math.PI/2;$>2*Math.PI&&($-=2*Math.PI);var v=Math.sin($);const be=Math.cos($);var k=this.getBubbleSize();$=(k.width+k.height)/W.ARROW_THICKNESS,$=Math.min($,k.width,k.height)/4,k=1-W.ANCHOR_RADIUS/a,s=t+k*s,i=o+k*i,k=t+$*be;const at=o+$*v;t-=$*be,o-=$*v,v=p+this.arrowRadians,v>2*Math.PI&&(v-=2*Math.PI),p=Math.sin(v)*a/W.ARROW_BEND,a=Math.cos(v)*a/W.ARROW_BEND,e.push("M"+k+","+at),e.push("C"+(k+a)+","+(at+p)+" "+s+","+i+" "+s+","+i),e.push("C"+s+","+i+" "+(t+a)+","+(o+p)+" "+t+","+o)}e.push("z");let fe;(fe=this.bubbleArrow)==null||fe.setAttribute("d",e.join(" "))}setColour(e){let t;(t=this.bubbleBack)==null||t.setAttribute("fill",e);let o;(o=this.bubbleArrow)==null||o.setAttribute("fill",e)}dispose(){this.onMouseDownBubbleWrapper&&ce(this.onMouseDownBubbleWrapper),this.onMouseDownResizeWrapper&&ce(this.onMouseDownResizeWrapper),W.unbindDragEvents(),re(this.bubbleGroup),this.disposed=!0}moveDuringDrag(e,t){e?e.translateSurface(t.x,t.y):this.moveTo(t.x,t.y),this.relativeLeft=this.workspace_.RTL?this.anchorXY.x-t.x-this.width:t.x-this.anchorXY.x,this.relativeTop=t.y-this.anchorXY.y,this.renderArrow()}getRelativeToSurfaceXY(){return new L(this.workspace_.RTL?-this.relativeLeft+this.anchorXY.x-this.width:this.anchorXY.x+this.relativeLeft,this.anchorXY.y+this.relativeTop)}setAutoLayout(e){this.autoLayout=e}static unbindDragEvents(){W.onMouseUpWrapper&&(ce(W.onMouseUpWrapper),W.onMouseUpWrapper=null),W.onMouseMoveWrapper&&(ce(W.onMouseMoveWrapper),W.onMouseMoveWrapper=null)}static bubbleMouseUp(e){Ut(),W.unbindDragEvents()}static textToDom(e){const t=I(f.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:W.BORDER_WIDTH});e=e.split(`
|
|
544
|
+
`);for(let o=0;o<e.length;o++){const s=I(f.TSPAN,{dy:"1em",x:W.BORDER_WIDTH},t),i=document.createTextNode(e[o]);s.appendChild(i)}return t}static createNonEditableBubble(e,t,o){if(o=new W(t.workspace,e,t.pathObject.svgPath,o,null,null),o.setSvgId(t.id),t.RTL){t=e.getBBox().width;for(let s=0,i;i=e.childNodes[s];s++)i.setAttribute("text-anchor","end"),i.setAttribute("x",String(t+W.BORDER_WIDTH))}return o}};W.BORDER_WIDTH=6,W.ARROW_THICKNESS=5,W.ARROW_ANGLE=20,W.ARROW_BEND=4,W.ANCHOR_RADIUS=8,W.onMouseUpWrapper=null,W.onMouseMoveWrapper=null;var Pc,gp;Pc=28,n.config$$module$build$src$core$config={dragRadius:5,flyoutDragRadius:10,snapRadius:Pc,connectingSnapRadius:Pc,currentConnectionPreference:8,bumpDelay:250},gp={},gp.config=n.config$$module$build$src$core$config;var Dn=class{constructor(e){this.iconGroup_=null,this.collapseHidden=!0,this.SIZE=17,this.iconXY_=this.bubble_=null,e||_("Calling the Icon constructor with a null block","version 9","version 10","a non-null block"),this.block_=e}createIcon(){this.iconGroup_||(this.iconGroup_=I(f.G,{class:"blocklyIconGroup"}),this.getBlock().isInFlyout&&U(this.iconGroup_,"blocklyIconGroupReadonly"),this.drawIcon_(this.iconGroup_),this.getBlock().getSvgRoot().appendChild(this.iconGroup_),w(this.iconGroup_,"pointerup",this,this.iconClick_),this.updateEditable())}dispose(){this.getBlock().isDeadOrDying()||re(this.iconGroup_),this.setVisible(!1)}updateEditable(){}isVisible(){return!!this.bubble_}iconClick_(e){this.getBlock().workspace.isDragging()||this.getBlock().isInFlyout||ro(e)||this.setVisible(!this.isVisible())}applyColour(){this.bubble_&&this.isVisible()&&this.bubble_.setColour(this.getBlock().style.colourPrimary)}setIconLocation(e){this.iconXY_=e,this.bubble_&&this.isVisible()&&this.bubble_.setAnchorLocation(e)}computeIconLocation(){var e=this.getBlock().getRelativeToSurfaceXY();const t=$t(this.iconGroup_);e=new L(e.x+t.x+this.SIZE/2,e.y+t.y+this.SIZE/2),L.equals(this.getIconLocation(),e)||this.setIconLocation(e)}getIconLocation(){return this.iconXY_}getCorrectedSize(){return new Pe(this.SIZE,this.SIZE-2)}drawIcon_(e){}setVisible(e){}getBlock(){if(!this.block_)throw Error("Block is not set for this icon.");return this.block_}},qr={};qr.deepMerge=io,qr.inherits=dd,qr.mixin=_d,qr.values=pd;var rs=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),r(A.THEME,e,this)}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 rs(e);let s=t.base;if(s){if(typeof s=="string"){let i;s=(i=d(A.THEME,s))!=null?i:void 0}s instanceof rs&&(io(o,s),o.name=e)}return io(o.blockStyles,t.blockStyles),io(o.categoryStyles,t.categoryStyles),io(o.componentStyles,t.componentStyles),io(o.fontStyle,t.fontStyle),t.startHats!==null&&(o.startHats=t.startHats),o}},iT={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"}},nT={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"}},Mn=new rs("classic",iT,nT),Bc="categoryToolbox",Tp="flyoutToolbox",V;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM",e[e.LEFT=2]="LEFT",e[e.RIGHT=3]="RIGHT"})(V||(V={}));var $p={hasCategoriesInternal:Td},Do={};Do.Position=V,Do.TEST_ONLY=$p,Do.convertFlyoutDefToJsonArray=Ir,Do.convertToolboxDefToJson=Rr,Do.hasCategories=zi,Do.isCategoryCollapsible=Ji,Do.parseToolboxTree=Kl;var kt=class{constructor(e){this.gridPattern=null,this.getMetrics=this.setMetrics=void 0;let t=null,o=!1;var s=!1,i=!1,a=!1,p=!1,$=!1;const v=!!e.readOnly;if(!v){var k;t=Rr((k=e.toolbox)!=null?k:null),o=zi(t),s=e.trashcan,s=s===void 0?o:s,i=e.collapse,i=i===void 0?o:i,a=e.comments,a=a===void 0?o:a,p=e.disable,p=p===void 0?o:p,$=e.sounds,$=$===void 0?!0:$}k=e.maxTrashcanContents,s?k===void 0&&(k=32):k=0;const fe=!!e.rtl;let be=e.horizontalLayout;be===void 0&&(be=!1);var at=e.toolboxPosition!=="end";at=be?at?V.TOP:V.BOTTOM:at===fe?V.RIGHT:V.LEFT;let rr=e.css;rr===void 0&&(rr=!0);let ir="https://blockly-demo.appspot.com/static/media/";e.media?ir=e.media.endsWith("/")?e.media:e.media+"/":"path"in e&&(_("path","Nov 2014","Jul 2023","media"),ir=e.path+"media/");const vg=e.oneBasedIndex,FT=e.renderer||"geras",UT=e.plugins||{};let Au=e.modalInputs;Au===void 0&&(Au=!0),this.RTL=fe,this.oneBasedIndex=vg===void 0?!0:vg,this.collapse=i,this.comments=a,this.disable=p,this.readOnly=v,this.maxBlocks=e.maxBlocks||1/0;let Cg;this.maxInstances=(Cg=e.maxInstances)!=null?Cg:null,this.modalInputs=Au,this.pathToMedia=ir,this.hasCategories=o,this.moveOptions=kt.parseMoveOptions_(e,o),this.hasScrollbars=!!this.moveOptions.scrollbars,this.hasTrashcan=s,this.maxTrashcanContents=k,this.hasSounds=$,this.hasCss=rr,this.horizontalLayout=be,this.languageTree=t,this.gridOptions=kt.parseGridOptions_(e),this.zoomOptions=kt.parseZoomOptions_(e),this.toolboxPosition=at,this.theme=kt.parseThemeOptions_(e),this.renderer=FT;let Ng;this.rendererOverrides=(Ng=e.rendererOverrides)!=null?Ng:null;let yg;this.parentWorkspace=(yg=e.parentWorkspace)!=null?yg:null,this.plugins=UT}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=0<t.spacing&&!!e.snap,t}static parseThemeOptions_(e){return e=e.theme||Mn,typeof e=="string"?d(A.THEME,e):e instanceof rs?e:rs.defineTheme(e.name||"builtin"+oo(),e)}},Ep;n.Mutator$$module$build$src$core$mutator=class extends Dn{constructor(e,t){t||_("Calling the Mutator constructor without passing the block it is attached to","version 9","version 10","the constructor by passing the list of subblocks and the block instance to attach the mutator to"),super(t??null),this.workspace_=null,this.workspaceHeight=this.workspaceWidth=0,this.updateWorkspacePid=this.sourceListener=this.rootBlock=this.svgDialog=null,this.quarkNames=e}setBlock(e){this.block_=e}getWorkspace(){return this.workspace_}drawIcon_(e){I(f.RECT,{class:"blocklyIconShape",rx:"4",ry:"4",height:"16",width:"16"},e),I(f.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"},e),I(f.CIRCLE,{class:"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},e)}iconClick_(e){this.getBlock().isEditable()&&super.iconClick_(e)}createEditor(){if(this.svgDialog=I(f.SVG,{x:W.BORDER_WIDTH,y:W.BORDER_WIDTH}),this.quarkNames.length){var e=n.createElement$$module$build$src$core$utils$xml("xml");for(let s=0,i;i=this.quarkNames[s];s++){var t=n.createElement$$module$build$src$core$utils$xml("block");t.setAttribute("type",i),e.appendChild(t)}}else e=null;var o=this.getBlock();return t=new kt({disable:!1,parentWorkspace:o.workspace,media:o.workspace.options.pathToMedia,rtl:o.RTL,horizontalLayout:!1,renderer:o.workspace.options.renderer,rendererOverrides:o.workspace.options.rendererOverrides}),t.toolboxPosition=o.RTL?V.RIGHT:V.LEFT,(o=!!e)&&(t.languageTree=Rr(e)),this.workspace_=this.newWorkspaceSvg(t),this.workspace_.internalIsMutator=!0,this.workspace_.addChangeListener(_s),e=o?this.workspace_.addFlyout(f.G):null,t=this.workspace_.createDom("blocklyMutatorBackground"),e&&t.insertBefore(e,this.workspace_.svgBlockCanvas_),this.svgDialog.appendChild(t),this.svgDialog}newWorkspaceSvg(e){throw Error("The implementation of newWorkspaceSvg should be monkey-patched in by blockly.ts")}updateEditable(){super.updateEditable(),this.getBlock().isInFlyout||(this.getBlock().isEditable()?this.iconGroup_&&se(this.iconGroup_,"blocklyIconGroupReadonly"):(this.setVisible(!1),this.iconGroup_&&U(this.iconGroup_,"blocklyIconGroupReadonly")))}resizeBubble(){if(this.workspace_){var e=2*W.BORDER_WIDTH,t=this.workspace_.getCanvas(),o=t.getBBox(),s=o.width+o.x,i=o.height+3*e,a=this.workspace_.getFlyout();if(a){const p=a.getWorkspace().getMetricsManager().getScrollMetrics();i=Math.max(i,p.height+20),s+=a.getWidth()}(a=this.getBlock().RTL)&&(s=-o.x),s+=3*e,(Math.abs(this.workspaceWidth-s)>e||Math.abs(this.workspaceHeight-i)>e)&&(this.workspaceWidth=s,this.workspaceHeight=i,this.bubble_.setBubbleSize(s+e,i+e),this.svgDialog.setAttribute("width",`${s}`),this.svgDialog.setAttribute("height",`${i}`),this.workspace_.setCachedParentSvgSize(s,i)),a&&t.setAttribute("transform",`translate(${this.workspaceWidth}, 0)`),this.workspace_.resize()}}onBubbleMove(){this.workspace_&&this.workspace_.recordDragTargets()}setVisible(e){if(e!==this.isVisible()){var t=this.getBlock();if(e){this.bubble_=new W(t.workspace,this.createEditor(),t.pathObject.svgPath,this.iconXY_,null,null);var o=this.workspace_;this.bubble_.setSvgId(t.id),this.bubble_.registerMoveEvent(this.onBubbleMove.bind(this));var s=o.options.languageTree;const i=o.getFlyout();s&&(i.init(o),i.show(s)),this.rootBlock=t.decompose(o),s=this.rootBlock.getDescendants(!1);for(let p=0,$;$=s[p];p++)$.render();this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1);let a;if(i?(s=2*i.CORNER_RADIUS,a=this.rootBlock.RTL?i.getWidth()+s:s):a=s=16,t.RTL&&(a=-a),this.rootBlock.moveBy(a,s),t.saveConnections){const p=this.rootBlock;t.saveConnections(p),this.sourceListener=()=>{const $=this.getBlock();$.saveConnections&&$.saveConnections(p)},t.workspace.addChangeListener(this.sourceListener)}this.resizeBubble(),s=this.workspaceChanged.bind(this),o.addChangeListener(s),i&&i.getWorkspace().addChangeListener(s),this.updateWorkspace(),this.applyColour()}else this.svgDialog=null,this.workspace_.dispose(),this.rootBlock=this.workspace_=null,(o=this.bubble_)==null||o.dispose(),this.bubble_=null,this.workspaceHeight=this.workspaceWidth=0,this.sourceListener&&(t.workspace.removeChangeListener(this.sourceListener),this.sourceListener=null);x(new(F(lo))(t,e,"mutator"))}}workspaceChanged(e){this.shouldIgnoreMutatorEvent_(e)||this.updateWorkspacePid||(this.updateWorkspacePid=setTimeout(()=>{this.updateWorkspacePid=null,this.updateWorkspace()},0))}shouldIgnoreMutatorEvent_(e){return e.isUiEvent||e.type===He||e.type===Ge&&e.element==="disabled"}updateWorkspace(){if(!this.workspace_.isDragging()){var e=this.workspace_.getTopBlocks(!1);for(let s=0,i;i=e[s];s++){var t=i.getRelativeToSurfaceXY();if(20>t.y&&i.moveBy(0,20-t.y),i.RTL){var o=-20;const a=this.workspace_.getFlyout();a&&(o-=a.getWidth()),t.x>o&&i.moveBy(o-t.x,0)}else 20>t.x&&i.moveBy(20-t.x,0)}}if(this.rootBlock&&this.rootBlock.workspace===this.workspace_){(e=K())||C(!0);const s=this.getBlock();if(t=es.getExtraBlockState_(s),s.compose(this.rootBlock),o=es.getExtraBlockState_(s),t!==o){x(new(F(Ge))(s,"mutation",null,t,o));const i=K();setTimeout(function(){const a=K();C(i),s.bumpNeighbours(),C(a)},n.config$$module$build$src$core$config.bumpDelay)}this.workspace_.isDragging()||setTimeout(()=>this.resizeBubble(),0),C(e)}}dispose(){this.getBlock().mutator=null,super.dispose()}updateBlockStyle(){var e=this.workspace_;if(e&&e.getAllBlocks(!1)){const t=e.getAllBlocks(!1);for(let o=0,s;s=t[o];o++)s.setStyle(s.getStyleName());if(e=e.getFlyout()){e=e.getWorkspace().getAllBlocks(!1);for(let o=0,s;s=e[o];o++)s.setStyle(s.getStyleName())}}}static reconnect(e,t,o){if(!e||!e.getSourceBlock().workspace)return!1;o=t.getInput(o).connection;const s=e.targetBlock();return s&&s!==t||!o||o.targetConnection===e?!1:(o.isConnected()&&o.disconnect(),o.connect(e),!0)}static findParentWs(e){let t=null;if(e&&e.options){const o=e.options.parentWorkspace;e.isFlyout?o&&o.options&&(t=o.options.parentWorkspace):o&&(t=o)}return t}},Ep={},Ep.Mutator=n.Mutator$$module$build$src$core$mutator;var js=Object.create(null),lT={allExtensions:js};n.register$$module$build$src$core$extensions("parent_tooltip_when_inline",Sd),n.module$build$src$core$extensions={},n.module$build$src$core$extensions.TEST_ONLY=lT,n.module$build$src$core$extensions.apply=Zi,n.module$build$src$core$extensions.buildTooltipForDropdown=n.buildTooltipForDropdown$$module$build$src$core$extensions,n.module$build$src$core$extensions.buildTooltipWithFieldText=n.buildTooltipWithFieldText$$module$build$src$core$extensions,n.module$build$src$core$extensions.isRegistered=zl,n.module$build$src$core$extensions.register=n.register$$module$build$src$core$extensions,n.module$build$src$core$extensions.registerMixin=Ed,n.module$build$src$core$extensions.registerMutator=n.registerMutator$$module$build$src$core$extensions,n.module$build$src$core$extensions.runAfterPageLoad=Or,n.module$build$src$core$extensions.unregister=md;var Mo=class extends ee{constructor(e,t,o){super(ee.SKIP_SETUP),this.class_=null,this.EDITABLE=!1,e!==ee.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_&&U(this.getTextElement(),this.class_)}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class_&&se(this.textElement_,this.class_),e&&U(this.textElement_,e)),this.class_=e}static fromJson(e){return new this(Ee(e.text),void 0,e)}};ut("field_label",Mo),Mo.prototype.DEFAULT_VALUE="";var Ys=class{constructor(e,t,o,s){if(this.type=e,this.name=t,this.connection=s,this.fieldRow=[],this.align=n.Align$$module$build$src$core$input.LEFT,this.visible=!0,e!==X.DUMMY&&!t)throw Error("Value inputs and statement inputs must have non-empty name.");this.sourceBlock=o}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,o){if(0>e||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return(t||t===""&&o)&&(typeof t=="string"&&(t=Ki({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.rendered&&(t.init(),t.applyColour()),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(),this.sourceBlock.bumpNeighbours())),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(),this.sourceBlock.bumpNeighbours()),!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 s=0,i;i=this.fieldRow[s];s++)i.setVisible(e);if(this.connection){var o=this.connection;e?t=o.startTrackingAll():o.stopTrackingAll(),(o=o.targetBlock())&&(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(){if(this.sourceBlock.workspace.rendered)for(let e=0;e<this.fieldRow.length;e++)this.fieldRow[e].init()}dispose(){for(let e=0,t;t=this.fieldRow[e];e++)t.dispose();this.connection&&this.connection.dispose()}},xc;(function(e){e=e.Align||(e.Align={}),e[e.LEFT=-1]="LEFT",e[e.CENTRE=0]="CENTRE",e[e.RIGHT=1]="RIGHT"})(Ys||(Ys={})),n.Align$$module$build$src$core$input=Ys.Align,xc={},xc.Align=n.Align$$module$build$src$core$input,xc.Input=Ys;var mp={};mp.removeElem=Ke;var Ks=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.disabled=!1,this.tooltip="",this.contextMenu=!0,this.parentBlock_=null,this.childBlocks_=[],this.editable_=this.movable_=this.deletable_=!0,this.collapsed_=this.isShadow_=!1,this.outputShape_=null,this.disposing=!1,this.comment=null,this.isInsertionMarker_=!1,this.onchangeWrapper_=this.helpUrl=this.rendered=null,this.statementInputCount=0,this.workspace=e,this.id=o&&!e.getBlockById(o)?o:ft(),e.setBlockById(this.id,this),this.commentModel={text:null,pinned:!1,size:new Pe(160,80)},this.xy_=new L(0,0),this.isInFlyout=e.isFlyout,this.isInMutator=e.isMutator,this.RTL=e.RTL,t){if(this.type=t,o=rt[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===Ks&&this.doInit_()}doInit_(){const e=K();e||C(!0);const t=tt();try{typeof this.init=="function"&&(We(!1),this.init(),We(t)),Oe()&&x(new(F(He))(this))}finally{C(e),We(t)}this.inputsInlineDefault=this.inputsInline,typeof this.onchange=="function"&&this.setOnChange(this.onchange)}dispose(e){this.isDeadOrDying()||(this.onchangeWrapper_&&this.workspace.removeChangeListener(this.onchangeWrapper_),this.unplug(e),Oe()&&x(new(F(jt))(this)),this.workspace.removeTopBlock(this),this.disposeInternal())}disposeInternal(){if(!this.isDeadOrDying()){this.onchangeWrapper_&&this.workspace.removeChangeListener(this.onchangeWrapper_),ve();try{this.workspace.removeTypedBlock(this),this.workspace.removeBlockById(this.id),this.disposing=!0,this.childBlocks_.forEach(e=>e.disposeInternal()),this.inputList.forEach(e=>e.dispose()),this.inputList.length=0,this.getConnections_(!0).forEach(e=>e.dispose())}finally{Ie(),typeof this.destroy=="function"&&this.destroy(),this.disposed=!0}}}isDeadOrDying(){return this.disposing||this.disposed}initModel(){for(let e=0,t;t=this.inputList[e];e++)for(let o=0,s;s=t.fieldRow[o];o++)s.initModel&&s.initModel()}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==null||e.disconnect(),this.workspace.connectionChecker.canConnect(e,t,!1)?t.connect(e):e==null||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===M.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==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()}getFirstStatementConnection(){for(let e=0,t;t=this.inputList[e];e++)if(t.connection&&t.connection.type===M.NEXT_STATEMENT)return t.connection;return null}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.isShadow_&&!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnDeletable(){return this.deletable_}setDeletable(e){this.deletable_=e}isMovable(){return this.movable_&&!this.isShadow_&&!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnMovable(){return this.movable_}setMovable(e){this.movable_=e}isDuplicatable(){return this.workspace.hasBlockLimits()?this.workspace.isCapacityAvailable(Eo(this,!0)):!0}isShadow(){return this.isShadow_}setShadow(e){this.isShadow_=e}isInsertionMarker(){return this.isInsertionMarker_}setInsertionMarker(e){this.isInsertionMarker_=e}isEditable(){return this.editable_&&!this.isDeadOrDying()&&!this.workspace.options.readOnly}isOwnEditable(){return this.editable_}setEditable(e){this.editable_=e;for(let t=0,o;o=this.inputList[t];t++)for(let s=0,i;i=o.fieldRow[s];s++)i.updateEditable()}isDisposed(){return this.disposed}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 Is(this)}getColour(){return this.colour_}getStyleName(){return this.styleName_}getHue(){return this.hue_}setColour(e){e=jo(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(let t=0,o;o=this.inputList[t];t++)for(let s=0,i;i=o.fieldRow[s];s++)if(i.name===e)return i;return null}getVars(){const e=[];for(let t=0,o;o=this.inputList[t];t++)for(let s=0,i;i=o.fieldRow[s];s++)i.referencesVariables()&&e.push(i.getValue());return e}getVarModels(){const e=[];for(let t=0,o;o=this.inputList[t];t++)for(let s=0,i;i=o.fieldRow[s];s++)if(i.referencesVariables()){const a=this.workspace.getVariableById(i.getValue());a&&e.push(a)}return e}updateVarName(e){for(let t=0,o;o=this.inputList[t];t++)for(let s=0,i;i=o.fieldRow[s];s++)i.referencesVariables()&&e.getId()===i.getValue()&&i.refreshVariableName()}renameVarById(e,t){for(let o=0,s;s=this.inputList[o];o++)for(let i=0,a;a=s.fieldRow[i];i++)a.referencesVariables()&&e===a.getValue()&&a.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_(M.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_(M.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_(M.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&&(x(new(F(Ge))(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].type===X.DUMMY&&this.inputList[e].type===X.DUMMY)return!1;for(e=1;e<this.inputList.length;e++)if(this.inputList[e-1].type===X.VALUE&&this.inputList[e].type===X.DUMMY)return!0;return!1}setOutputShape(e){this.outputShape_=e}getOutputShape(){return this.outputShape_}isEnabled(){return!this.disabled}setEnabled(e){if(this.isEnabled()!==e){const t=this.disabled;this.disabled=!e,x(new(F(Ge))(this,"disabled",null,t,!e))}}getInheritedDisabled(){let e=this.getSurroundParent();for(;e;){if(e.disabled)return!0;e=e.getSurroundParent()}return!1}isCollapsed(){return this.collapsed_}setCollapsed(e){this.collapsed_!==e&&(x(new(F(Ge))(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!=xs){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 a=o.getCheck();!a&&o.targetConnection&&(a=o.targetConnection.getCheck()),(o=!!a&&(a.indexOf("Boolean")!==-1||a.indexOf("Number")!==-1))&&t.push("("),t.push(...i.toTokens(e)),o&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput_(X.VALUE,e)}appendStatementInput(e){return this.appendInput_(X.STATEMENT,e)}appendDummyInput(e){return this.appendInput_(X.DUMMY,e||"")}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.");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.");e.style?this.jsonInitStyle_(e,t):this.jsonInitColour_(e,t);for(var o=0;e["message"+o]!==void 0;)this.interpolate_(e["message"+o],e["args"+o]||[],e["lastDummyAlign"+o],t),o++;if(e.inputsInline!==void 0&&this.setInputsInline(e.inputsInline),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=Ee(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=Ee(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&&Zi(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;t<e.length;t++)Zi(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=Xi(e),this.validateTokens_(e,t.length),t=this.interpolateArguments_(e,t,o),o=[];for(let i=0,a;a=t[i];i++)if(this.isInputKeyword_(a.type)){if(e=this.inputFromJson_(a,s)){for(let p=0,$;$=o[p];p++)e.appendField($[0],$[1]);o.length=0}}else(e=this.fieldFromJson_(a))&&o.push([e,a.name])}validateTokens_(e,t){const o=[];let s=0;for(let i=0;i<e.length;i++){const a=e[i];if(typeof a=="number"){if(1>a||a>t)throw Error('Block "'+this.type+'": Message index %'+a+" out of range.");if(o[a])throw Error('Block "'+this.type+'": Message index %'+a+" duplicated.");o[a]=!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 i=0;i<e.length;i++){let a=e[i];typeof a=="number"&&(a=t[a-1]),!(typeof a=="string"&&(a=this.stringToFieldJson_(a),!a))&&s.push(a)}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=Ki(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$input.LEFT,RIGHT:n.Align$$module$build$src$core$input.RIGHT,CENTRE:n.Align$$module$build$src$core$input.CENTRE,CENTER:n.Align$$module$build$src$core$input.CENTRE};let s=null;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)}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"}stringToFieldJson_(e){return(e=e.trim())?{type:"field_label",text:e}:null}appendInput_(e,t){let o=null;return(e===X.VALUE||e===X.STATEMENT)&&(o=this.makeConnection_(e)),e===X.STATEMENT&&this.statementInputCount++,e=new Ys(e,t,this,o),this.inputList.push(e),e}moveInputBefore(e,t){if(e!==t){var o=-1,s=t?-1:this.inputList.length;for(let i=0,a;a=this.inputList[i];i++)if(a.name===e){if(o=i,s!==-1)break}else if(t&&a.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.type===X.STATEMENT&&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(){return this.commentModel.text}setCommentText(e){this.commentModel.text!==e&&(x(new(F(Ge))(this,"comment",null,this.commentModel.text,e)),this.comment=this.commentModel.text=e)}setWarningText(e,t){}setMutator(e){}getRelativeToSurfaceXY(){return this.xy_}moveBy(e,t){if(this.parentBlock_)throw Error("Block has parent.");const o=new(F(ze))(this);this.xy_.translate(e,t),o.recordNew(),x(o)}makeConnection_(e){return new ie(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}};Ks.COLLAPSED_INPUT_NAME=xs,Ks.COLLAPSED_FIELD_NAME=vn;var Zr=null,Qr=null,ei={};ei.connectionUiEffect=ea,ei.disconnectUiEffect=oa,ei.disconnectUiStop=Os,ei.disposeUiEffect=Zl;var fp=class{constructor(e){this.container=e,this.scale=1,this.surfaceXY=new L(0,0),this.childSurfaceXY=new L(0,0),this.svg=I(f.SVG,{xmlns:Ms,"xmlns:html":Ct,"xmlns:xlink":it,version:"1.1",class:"blocklyBlockDragSurface"},this.container),this.dragGroup=I(f.G,{},this.svg)}createDom(){_("BlockDragSurfaceSvg createDom","June 2022","June 2023")}setBlocksAndShow(e){if(this.dragGroup.childNodes.length)throw Error("Already dragging a block.");this.dragGroup.appendChild(e),this.svg.style.display="block",this.surfaceXY=new L(0,0)}translateAndScaleGroup(e,t,o){this.scale=o,e=Math.round(e),t=Math.round(t),this.childSurfaceXY.x=e,this.childSurfaceXY.y=t,this.dragGroup.setAttribute("transform","translate("+e+","+t+") scale("+o+")")}translateSurfaceInternal_(){const e=Math.round(this.surfaceXY.x),t=Math.round(this.surfaceXY.y);this.svg.style.display="block",so(this.svg,"translate3d("+e+"px, "+t+"px, 0)")}translateBy(e,t){this.surfaceXY=new L(this.surfaceXY.x+e,this.surfaceXY.y+t),this.translateSurfaceInternal_()}translateSurface(e,t){this.surfaceXY=new L(e*this.scale,t*this.scale),this.translateSurfaceInternal_()}getSurfaceTranslation(){const e=$t(this.svg);return new L(e.x/this.scale,e.y/this.scale)}getGroup(){return this.dragGroup}getSvgRoot(){return this.svg}getCurrentBlock(){return this.dragGroup.firstChild}getWsTranslation(){return this.childSurfaceXY.clone()}clearAndHide(e){const t=this.getCurrentBlock();if(t&&(e?e.appendChild(t):this.dragGroup.removeChild(t)),this.svg.style.display="none",this.dragGroup.childNodes.length)throw Error("Drag group was not cleared.");this.surfaceXY=new L(0,0)}},Fc=class extends yt{constructor(e,t,o){super(e?e.workspace.id:void 0),this.type=As,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}fromJson(e){_("Blockly.Events.BlockDrag.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.isStart=e.isStart,this.blockId=e.blockId,this.blocks=e.blocks}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Fc),t.isStart=e.isStart,t.blockId=e.blockId,t.blocks=e.blocks,t}};r(A.EVENT,As,Fc);var wn={};wn.bumpIntoBounds=Sr,wn.bumpIntoBoundsHandler=ra,wn.bumpTopObjectsIntoBounds=tn;var ho=class{constructor(e){this.name_=e}toString(){return this.name_}};ho.POSITIONABLE=new ho("positionable"),ho.DRAG_TARGET=new ho("drag_target"),ho.DELETE_AREA=new ho("delete_area"),ho.AUTOHIDEABLE=new ho("autohideable");var Be=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 a;(a=this.capabilityToComponentIds.get(i))==null||a.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.indexOf(t)!==-1}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,a){return i.weight-a.weight}),s.forEach(function(i){o.push(i.component)})}else e.forEach(s=>{o.push(this.componentData.get(s).component)});return o}};Be.Capability=ho;var bp="The insertion marker manager tried to create a marker but the result is missing %1. If you are using a mutator, make sure your domToMutation method is properly defined.",dt=class{constructor(e){this.activeCandidate=this.lastMarker=this.lastOnStack=null,this.wouldDeleteBlock=!1,this.fadedBlock=this.highlightedBlock=this.markerConnection=null,et(e),this.topBlock=e,this.workspace=e.workspace,this.firstMarker=this.createMarkerBlock(this.topBlock),this.availableConnections=this.initAvailableConnections(),this.lastOnStack&&(this.lastMarker=this.createMarkerBlock(this.lastOnStack.getSourceBlock()))}dispose(){this.availableConnections.length=0,this.disposeInsertionMarker(this.firstMarker),this.disposeInsertionMarker(this.lastMarker)}updateAvailableConnections(){this.availableConnections=this.initAvailableConnections()}wouldConnectBlock(){return!!this.activeCandidate}applyConnections(){if(this.activeCandidate){var{local:e,closest:t}=this.activeCandidate;if(e.connect(t),ve(),this.hidePreview(),Ie(),this.topBlock.rendered){const o=e.isSuperior()?t:e;ea(o.getSourceBlock());const s=this.topBlock.getRootBlock();requestAnimationFrame(()=>{setTimeout(()=>{s.bringToFront()},0)})}}}update(e,t){const o=this.getCandidate(e);((this.wouldDeleteBlock=this.shouldDelete(!!o,t))||this.shouldUpdatePreviews(o,e))&&(ve(),this.maybeHidePreview(o),this.maybeShowPreview(o),Ie())}createMarkerBlock(e){var t=e.type;ve();let o;try{if(o=this.workspace.newBlock(t),o.setInsertionMarker(!0),e.saveExtraState){var s=e.saveExtraState();s&&o.loadExtraState&&o.loadExtraState(s)}else if(e.mutationToDom){const i=e.mutationToDom();i&&o.domToMutation&&o.domToMutation(i)}for(t=0;t<e.inputList.length;t++){const i=e.inputList[t];if(i.name===xs)continue;const a=o.inputList[t];if(!a)throw Error(bp.replace("%1","an input"));for(s=0;s<i.fieldRow.length;s++){const p=i.fieldRow[s],$=a.fieldRow[s];if(!$)throw Error(bp.replace("%1","a field"));$.setValue(p.getValue())}}o.setCollapsed(e.isCollapsed()),o.setInputsInline(e.getInputsInline()),o.initSvg(),o.getSvgRoot().setAttribute("visibility","hidden")}finally{Ie()}return o}initAvailableConnections(){const e=this.topBlock.getConnections_(!1),t=this.topBlock.lastConnectionInStack(!0);return t&&t!==this.topBlock.nextConnection&&(e.push(t),this.lastOnStack=t),e}shouldUpdatePreviews(e,t){if(!e)return!!this.activeCandidate;if(!this.activeCandidate)return!0;const{local:o,closest:s}=this.activeCandidate;if(s===e.closest&&o===e.local)return!1;const i=o.x+t.x-s.x;return t=o.y+t.y-s.y,e.radius<Math.sqrt(i*i+t*t)-n.config$$module$build$src$core$config.currentConnectionPreference}getCandidate(e){this.markerConnection&&this.markerConnection.isConnected()||this.updateAvailableConnections();let t=this.getStartRadius(),o=null;for(let s=0;s<this.availableConnections.length;s++){const i=this.availableConnections[s],a=i.closest(t,e);a.connection&&(o={closest:a.connection,local:i,radius:a.radius},t=a.radius)}return o}getStartRadius(){return this.activeCandidate?n.config$$module$build$src$core$config.connectingSnapRadius:n.config$$module$build$src$core$config.snapRadius}shouldDelete(e,t){return t&&this.workspace.getComponentManager().hasCapability(t.id,Be.Capability.DELETE_AREA)?t.wouldDelete(this.topBlock,e):!1}maybeShowPreview(e){if(!this.wouldDeleteBlock&&e){var t=e.closest,o;t===((o=this.activeCandidate)==null?void 0:o.closest)||t.getSourceBlock().isInsertionMarker()?console.log("Trying to connect to an insertion marker"):(this.activeCandidate=e,this.showPreview(this.activeCandidate))}}showPreview(e){const t=this.workspace.getRenderer();switch(t.getConnectionPreviewMethod(e.closest,e.local,this.topBlock)){case dt.PREVIEW_TYPE.INPUT_OUTLINE:this.showInsertionInputOutline(e);break;case dt.PREVIEW_TYPE.INSERTION_MARKER:this.showInsertionMarker(e);break;case dt.PREVIEW_TYPE.REPLACEMENT_FADE:this.showReplacementFade(e)}t.shouldHighlightConnection(e.closest)&&e.closest.highlight()}maybeHidePreview(e){if(!e)this.hidePreview();else if(this.activeCandidate){const t=this.activeCandidate.local!==e.local;(this.activeCandidate.closest!==e.closest||t||this.wouldDeleteBlock)&&this.hidePreview()}this.activeCandidate=this.markerConnection=null}hidePreview(){let e;const t=(e=this.activeCandidate)==null?void 0:e.closest;t&&t.targetBlock()&&this.workspace.getRenderer().shouldHighlightConnection(t)&&t.unhighlight(),this.hideReplacementFade(),this.hideInsertionInputOutline(),this.hideInsertionMarker()}showInsertionMarker(e){const{local:t,closest:o}=e;let s=(e=this.lastOnStack&&t===this.lastOnStack)?this.lastMarker:this.firstMarker;if(!s)throw Error("Cannot show the insertion marker because there is no insertion marker block");let i;try{i=s.getMatchingConnection(t.getSourceBlock(),t)}catch{if(e&&this.lastOnStack?(this.disposeInsertionMarker(this.lastMarker),s=this.lastMarker=this.createMarkerBlock(this.lastOnStack.getSourceBlock())):(this.disposeInsertionMarker(this.firstMarker),s=this.firstMarker=this.createMarkerBlock(this.topBlock)),!s)throw Error("Cannot show the insertion marker because there is no insertion marker block");i=s.getMatchingConnection(t.getSourceBlock(),t)}if(!i)throw Error("Cannot show the insertion marker because there is no associated connection");if(i===this.markerConnection)throw Error("Made it to showInsertionMarker_ even though the marker isn't changing");s.render(),s.rendered=!0,s.getSvgRoot().setAttribute("visibility","visible"),i&&o&&s.positionNearConnection(i,o),o&&i.connect(o),this.markerConnection=i}hideInsertionMarker(){if(this.markerConnection){var e=this.markerConnection,t=e.getSourceBlock(),o=t.outputConnection,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)}if(e.targetConnection)throw Error("markerConnection still connected at the end of disconnectInsertionMarker");this.markerConnection=null,(e=t.getSvgRoot())&&e.setAttribute("visibility","hidden")}}showInsertionInputOutline(e){e=e.closest,this.highlightedBlock=e.getSourceBlock(),this.highlightedBlock.highlightShapeForInput(e,!0)}hideInsertionInputOutline(){if(this.highlightedBlock){if(!this.activeCandidate)throw Error("Cannot hide the insertion marker outline because there is no active candidate");this.highlightedBlock.highlightShapeForInput(this.activeCandidate.closest,!1),this.highlightedBlock=null}}showReplacementFade(e){if(this.fadedBlock=e.closest.targetBlock(),!this.fadedBlock)throw Error("Cannot show the replacement fade because the closest connection does not have a target block");this.fadedBlock.fadeForReplacement(!0)}hideReplacementFade(){this.fadedBlock&&(this.fadedBlock.fadeForReplacement(!1),this.fadedBlock=null)}getInsertionMarkers(){const e=[];return this.firstMarker&&e.push(this.firstMarker),this.lastMarker&&e.push(this.lastMarker),e}disposeInsertionMarker(e){if(e){ve();try{e.dispose()}finally{Ie()}}}};(function(e){e=e.PREVIEW_TYPE||(e.PREVIEW_TYPE={}),e[e.INSERTION_MARKER=0]="INSERTION_MARKER",e[e.INPUT_OUTLINE=1]="INPUT_OUTLINE",e[e.REPLACEMENT_FADE=2]="REPLACEMENT_FADE"})(dt||(dt={})),dt.PREVIEW_TYPE;var Rp=class{constructor(e,t){this.dragTarget_=null,this.wouldDeleteBlock_=!1,this.draggingBlock_=e,this.draggedConnectionManager_=new dt(this.draggingBlock_),this.workspace_=t,this.startXY_=this.draggingBlock_.getRelativeToSurfaceXY(),this.dragIconData_=Cd(e)}dispose(){this.dragIconData_.length=0,this.draggedConnectionManager_&&this.draggedConnectionManager_.dispose()}startDrag(e,t){K()||C(!0),this.fireDragStartEvent_(),this.workspace_.isMutator&&this.draggingBlock_.bringToFront(),Bt(),this.workspace_.setResizesEnabled(!1),Os(),this.shouldDisconnect_(t)&&this.disconnectBlock_(t,e),this.draggingBlock_.setDragging(!0),this.draggingBlock_.moveToDragSurface()}shouldDisconnect_(e){return!!(this.draggingBlock_.getParent()||e&&this.draggingBlock_.nextConnection&&this.draggingBlock_.nextConnection.targetBlock())}disconnectBlock_(e,t){this.draggingBlock_.unplug(e),e=this.pixelsToWorkspaceUnits_(t),e=L.sum(this.startXY_,e),this.draggingBlock_.translate(e.x,e.y),oa(this.draggingBlock_),this.draggedConnectionManager_.updateAvailableConnections()}fireDragStartEvent_(){const e=new(F(As))(this.draggingBlock_,!0,this.draggingBlock_.getDescendants(!1));x(e)}drag(e,t){t=this.pixelsToWorkspaceUnits_(t);var o=L.sum(this.startXY_,t);this.draggingBlock_.moveDuringDrag(o),this.dragIcons_(t),o=this.dragTarget_,this.dragTarget_=this.workspace_.getDragTarget(e),this.draggedConnectionManager_.update(t,this.dragTarget_),e=this.wouldDeleteBlock_,this.wouldDeleteBlock_=this.draggedConnectionManager_.wouldDeleteBlock,e!==this.wouldDeleteBlock_&&this.updateCursorDuringBlockDrag_(),this.dragTarget_!==o&&(o&&o.onDragExit(this.draggingBlock_),this.dragTarget_&&this.dragTarget_.onDragEnter(this.draggingBlock_)),this.dragTarget_&&this.dragTarget_.onDragOver(this.draggingBlock_)}endDrag(e,t){this.drag(e,t),this.dragIconData_=[],this.fireDragEndEvent_(),xt(),Os(),e=null,this.dragTarget_&&this.dragTarget_.shouldPreventMove(this.draggingBlock_)?t=this.startXY_:(t=this.getNewLocationAfterDrag_(t),e=t.delta,t=t.newLocation),this.draggingBlock_.moveOffDragSurface(t),this.dragTarget_&&this.dragTarget_.onDrop(this.draggingBlock_),this.maybeDeleteBlock_()||(this.draggingBlock_.setDragging(!1),e?this.updateBlockAfterMove_():Sr(this.draggingBlock_.workspace,this.workspace_.getMetricsManager().getScrollMetrics(!0),this.draggingBlock_)),this.workspace_.setResizesEnabled(!0),C(!1)}getNewLocationAfterDrag_(e){e=this.pixelsToWorkspaceUnits_(e);const t=L.sum(this.startXY_,e);return{delta:e,newLocation:t}}maybeDeleteBlock_(){return this.wouldDeleteBlock_?(this.fireMoveEvent_(),this.draggingBlock_.dispose(!1,!0),Ko.length=0,!0):!1}updateBlockAfterMove_(){this.fireMoveEvent_(),this.draggedConnectionManager_.wouldConnectBlock()?this.draggedConnectionManager_.applyConnections():this.draggingBlock_.queueRender(),this.draggingBlock_.scheduleSnapAndBump()}fireDragEndEvent_(){const e=new(F(As))(this.draggingBlock_,!1,this.draggingBlock_.getDescendants(!1));x(e)}updateToolboxStyle_(e){const t=this.workspace_.getToolbox();if(t){const o=this.draggingBlock_.isDeletable()?"blocklyToolboxDelete":"blocklyToolboxGrab";e&&typeof t.removeStyle=="function"?t.removeStyle(o):e||typeof t.addStyle!="function"||t.addStyle(o)}}fireMoveEvent_(){if(!this.draggingBlock_.isDeadOrDying()){var e=new(F(ze))(this.draggingBlock_);e.oldCoordinate=this.startXY_,e.recordNew(),x(e)}}updateCursorDuringBlockDrag_(){this.draggingBlock_.setDeleteStyle(this.wouldDeleteBlock_)}pixelsToWorkspaceUnits_(e){return e=new L(e.x/this.workspace_.scale,e.y/this.workspace_.scale),this.workspace_.isMutator&&e.scale(1/this.workspace_.options.parentWorkspace.scale),e}dragIcons_(e){for(let t=0;t<this.dragIconData_.length;t++){const o=this.dragIconData_[t];o.icon.setIconLocation(L.sum(o.location,e))}}getInsertionMarkers(){return this.draggedConnectionManager_&&this.draggedConnectionManager_.getInsertionMarkers?this.draggedConnectionManager_.getInsertionMarkers():[]}};r(A.BLOCK_DRAGGER,no,Rp);var Ip=class extends Dn{constructor(e){super(e),this.cachedText="",this.boundEvents=[],this.paragraphElement_=this.textarea_=this.foreignObject=null,this.model=e.commentModel;let t;this.model.text=(t=this.model.text)!=null?t:"",this.createIcon()}drawIcon_(e){I(f.CIRCLE,{class:"blocklyIconShape",r:"8",cx:"8",cy:"8"},e),I(f.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"},e),I(f.RECT,{class:"blocklyIconSymbol",x:"6.8",y:"10.78",height:"2",width:"2"},e)}createEditor(){this.foreignObject=I(f.FOREIGNOBJECT,{x:W.BORDER_WIDTH,y:W.BORDER_WIDTH});const e=document.createElementNS(Ct,"body");e.setAttribute("xmlns",Ct),e.className="blocklyMinimalBody";const t=this.textarea_=document.createElementNS(Ct,"textarea");t.className="blocklyCommentTextarea",t.setAttribute("dir",this.getBlock().RTL?"RTL":"LTR");let o;return t.value=(o=this.model.text)!=null?o:"",this.resizeTextarea(),e.appendChild(t),this.foreignObject.appendChild(e),this.boundEvents.push(w(t,"focus",this,this.startEdit,!0)),this.boundEvents.push(w(t,"wheel",this,function(s){s.stopPropagation()})),this.boundEvents.push(w(t,"change",this,function(s){this.cachedText!==this.model.text&&x(new(F(Ge))(this.getBlock(),"comment",null,this.cachedText,this.model.text))})),this.boundEvents.push(w(t,"input",this,function(s){this.model.text=t.value})),setTimeout(t.focus.bind(t),0),this.foreignObject}updateEditable(){super.updateEditable(),this.isVisible()&&(this.disposeBubble(),this.createBubble())}onBubbleResize(){this.isVisible()&&this.bubble_&&(this.model.size=this.bubble_.getBubbleSize(),this.resizeTextarea())}resizeTextarea(){if(this.textarea_&&this.foreignObject){var e=this.model.size,t=2*W.BORDER_WIDTH,o=e.width-t;e=e.height-t,this.foreignObject.setAttribute("width",`${o}`),this.foreignObject.setAttribute("height",`${e}`),this.textarea_.style.width=o-4+"px",this.textarea_.style.height=e-4+"px"}}setVisible(e){e!==this.isVisible()&&(x(new(F(lo))(this.getBlock(),e,"comment")),(this.model.pinned=e)?this.createBubble():this.disposeBubble())}createBubble(){this.getBlock().isEditable()?this.createEditableBubble():this.createNonEditableBubble()}createEditableBubble(){const e=this.getBlock();this.bubble_=new W(e.workspace,this.createEditor(),e.pathObject.svgPath,this.iconXY_,this.model.size.width,this.model.size.height),this.bubble_.setSvgId(e.id),this.bubble_.registerResizeEvent(this.onBubbleResize.bind(this)),this.applyColour()}createNonEditableBubble(){let e;this.paragraphElement_=W.textToDom((e=this.model.text)!=null?e:""),this.bubble_=W.createNonEditableBubble(this.paragraphElement_,this.getBlock(),this.iconXY_),this.applyColour()}disposeBubble(){for(const e of this.boundEvents)ce(e);this.boundEvents.length=0,this.bubble_&&(this.bubble_.dispose(),this.bubble_=null),this.paragraphElement_=this.foreignObject=this.textarea_=null}startEdit(e){let t;(t=this.bubble_)!=null&&t.promote()&&this.textarea_.focus(),this.cachedText=this.model.text}getBubbleSize(){return this.model.size}setBubbleSize(e,t){this.bubble_?this.bubble_.setBubbleSize(e,t):(this.model.size.width=e,this.model.size.height=t)}updateText(){if(this.textarea_){let e;this.textarea_.value=(e=this.model.text)!=null?e:""}else this.paragraphElement_&&(this.paragraphElement_.firstChild.textContent=this.model.text)}dispose(){this.getBlock().comment=null,super.dispose()}};Tt(`
|
|
545
|
+
.blocklyCommentTextarea {
|
|
546
|
+
background-color: #fef49c;
|
|
547
|
+
border: 0;
|
|
548
|
+
display: block;
|
|
549
|
+
margin: 0;
|
|
550
|
+
outline: 0;
|
|
551
|
+
padding: 3px;
|
|
552
|
+
resize: none;
|
|
553
|
+
text-overflow: hidden;
|
|
554
|
+
}
|
|
555
|
+
`);var _o=null,Uc={duplicateInternal:yd,copyInternal:Nd},ti={};ti.TEST_ONLY=Uc,ti.copy=Ss,ti.duplicate=vr,ti.paste=on;var oi,Hc,si;oi=null,Hc={},si=null,n.module$build$src$core$contextmenu={},n.module$build$src$core$contextmenu.callbackFactory=wd,n.module$build$src$core$contextmenu.commentDeleteOption=la,n.module$build$src$core$contextmenu.commentDuplicateOption=aa,n.module$build$src$core$contextmenu.dispose=na,n.module$build$src$core$contextmenu.getCurrentBlock=Ad,n.module$build$src$core$contextmenu.hide=Nr,n.module$build$src$core$contextmenu.setCurrentBlock=ia,n.module$build$src$core$contextmenu.show=Cr,n.module$build$src$core$contextmenu.workspaceCommentOption=Gd;var le=class{constructor(){this.registry_=new Map,this.reset()}reset(){this.registry_.clear()}register(e){if(this.registry_.has(e.id))throw Error('Menu item with ID "'+e.id+'" is already registered.');this.registry_.set(e.id,e)}unregister(e){if(!this.registry_.has(e))throw Error('Menu item with ID "'+e+'" not found.');this.registry_.delete(e)}getItem(e){let t;return(t=this.registry_.get(e))!=null?t:null}getContextMenuOptions(e,t){const o=[];for(const i of this.registry_.values())if(e===i.scopeType){var s=i.preconditionFn(t);s!=="hidden"&&(s={text:typeof i.displayText=="function"?i.displayText(t):i.displayText,enabled:s==="enabled",callback:i.callback,scope:t,weight:i.weight},o.push(s))}return o.sort(function(i,a){return i.weight-a.weight}),o}};(function(e){var t=e.ScopeType||(e.ScopeType={});t.BLOCK="block",t.WORKSPACE="workspace",e.registry=new e})(le||(le={})),le.ScopeType;var Op=30,Sp=!0,is=[];is[M.INPUT_VALUE]=M.OUTPUT_VALUE,is[M.OUTPUT_VALUE]=M.INPUT_VALUE,is[M.NEXT_STATEMENT]=M.PREVIOUS_STATEMENT,is[M.PREVIOUS_STATEMENT]=M.NEXT_STATEMENT;var Vc="RENAME_VARIABLE_ID",Wc="DELETE_VARIABLE_ID",y=class{constructor(e,t,o){if(this.wsCoordinate_=null,!t)throw Error("Cannot create a node without a location.");this.type_=e,this.isConnection_=y.isConnectionType_(e),this.location_=t,this.processParams_(o||null)}processParams_(e){e&&e.wsCoordinate&&(this.wsCoordinate_=e.wsCoordinate)}getLocation(){return this.location_}getType(){return this.type_}getWsCoordinate(){return this.wsCoordinate_}isConnection(){return this.isConnection_}findNextForInput_(){var e=this.location_.getParentInput();const t=e.getSourceBlock();for(e=t.inputList.indexOf(e),e+=1;e<t.inputList.length;e++){const o=t.inputList[e],s=o.fieldRow;for(let i=0;i<s.length;i++){const a=s[i];if(a.isClickable()||y.NAVIGATE_ALL_FIELDS)return y.createFieldNode(a)}if(o.connection)return y.createInputNode(o)}return null}findNextForField_(){var e=this.location_,t=e.getParentInput();const o=e.getSourceBlock();if(!o)throw Error("The current AST location is not associated with a block");var s=o.inputList.indexOf(t);for(e=t.fieldRow.indexOf(e)+1;s<o.inputList.length;s++){t=o.inputList[s];const i=t.fieldRow;for(;e<i.length;){if(i[e].isClickable()||y.NAVIGATE_ALL_FIELDS)return y.createFieldNode(i[e]);e++}if(e=0,t.connection)return y.createInputNode(t)}return null}findPrevForInput_(){const e=this.location_.getParentInput(),t=e.getSourceBlock();for(var o=t.inputList.indexOf(e);0<=o;o--){var s=t.inputList[o];if(s.connection&&s!==e)return y.createInputNode(s);s=s.fieldRow;for(let i=s.length-1;0<=i;i--){const a=s[i];if(a.isClickable()||y.NAVIGATE_ALL_FIELDS)return y.createFieldNode(a)}}return null}findPrevForField_(){var e=this.location_;const t=e.getParentInput(),o=e.getSourceBlock();if(!o)throw Error("The current AST location is not associated with a block");var s=o.inputList.indexOf(t);for(e=t.fieldRow.indexOf(e)-1;0<=s;s--){var i=o.inputList[s];if(i.connection&&i!==t)return y.createInputNode(i);for(i=i.fieldRow;-1<e;){if(i[e].isClickable()||y.NAVIGATE_ALL_FIELDS)return y.createFieldNode(i[e]);e--}0<=s-1&&(e=o.inputList[s-1].fieldRow.length-1)}return null}navigateBetweenStacks_(e){var t=this.getLocation();if(t.getSourceBlock){var o=t.getSourceBlock();o&&(t=o)}if(!t||t.isDeadOrDying())return null;o=t.getRootBlock(),t=o.workspace.getTopBlocks(!0);for(let s=0;s<t.length;s++)if(o.id===t[s].id)return e=s+(e?1:-1),e===-1||e===t.length?null:y.createStackNode(t[e]);throw Error("Couldn't find "+(e?"next":"previous")+" stack?!")}findTopASTNodeForBlock_(e){const t=yr(e);return t?y.createConnectionNode(t):y.createBlockNode(e)}getOutAstNodeForBlock_(e){if(!e)return null;e=e.getTopStackBlock();const t=yr(e);return t&&t.targetConnection&&t.targetConnection.getParentInput()?y.createInputNode(t.targetConnection.getParentInput()):y.createStackNode(e)}findFirstFieldOrInput_(e){e=e.inputList;for(let t=0;t<e.length;t++){const o=e[t],s=o.fieldRow;for(let i=0;i<s.length;i++){const a=s[i];if(a.isClickable()||y.NAVIGATE_ALL_FIELDS)return y.createFieldNode(a)}if(o.connection)return y.createInputNode(o)}return null}getSourceBlock(){return this.getType()===y.types.BLOCK?this.getLocation():this.getType()===y.types.STACK?this.getLocation():this.getType()===y.types.WORKSPACE?null:this.getLocation().getSourceBlock()}next(){switch(this.type_){case y.types.STACK:return this.navigateBetweenStacks_(!0);case y.types.OUTPUT:return y.createBlockNode(this.location_.getSourceBlock());case y.types.FIELD:return this.findNextForField_();case y.types.INPUT:return this.findNextForInput_();case y.types.BLOCK:const e=this.location_.nextConnection;if(!e)break;return y.createConnectionNode(e);case y.types.PREVIOUS:return y.createBlockNode(this.location_.getSourceBlock());case y.types.NEXT:return y.createConnectionNode(this.location_.targetConnection)}return null}in(){switch(this.type_){case y.types.WORKSPACE:const e=this.location_.getTopBlocks(!0);if(0<e.length)return y.createStackNode(e[0]);break;case y.types.STACK:return this.findTopASTNodeForBlock_(this.location_);case y.types.BLOCK:return this.findFirstFieldOrInput_(this.location_);case y.types.INPUT:return y.createConnectionNode(this.location_.targetConnection)}return null}prev(){switch(this.type_){case y.types.STACK:return this.navigateBetweenStacks_(!1);case y.types.FIELD:return this.findPrevForField_();case y.types.INPUT:return this.findPrevForInput_();case y.types.BLOCK:var e=yr(this.location_);if(!e)break;return y.createConnectionNode(e);case y.types.PREVIOUS:if((e=this.location_.targetConnection)&&!e.getParentInput())return y.createConnectionNode(e);break;case y.types.NEXT:return y.createBlockNode(this.location_.getSourceBlock())}return null}out(){switch(this.type_){case y.types.STACK:var e=this.location_,t=e.getRelativeToSurfaceXY();return t=new L(t.x,t.y+y.DEFAULT_OFFSET_Y),y.createWorkspaceNode(e.workspace,t);case y.types.OUTPUT:return e=this.location_,(t=e.targetConnection)?y.createConnectionNode(t):y.createStackNode(e.getSourceBlock());case y.types.FIELD:if(e=this.location_.getSourceBlock(),!e)throw Error("The current AST location is not associated with a block");return y.createBlockNode(e);case y.types.INPUT:return y.createBlockNode(this.location_.getSourceBlock());case y.types.BLOCK:return this.getOutAstNodeForBlock_(this.location_);case y.types.PREVIOUS:return this.getOutAstNodeForBlock_(this.location_.getSourceBlock());case y.types.NEXT:return this.getOutAstNodeForBlock_(this.location_.getSourceBlock())}return null}static isConnectionType_(e){switch(e){case y.types.PREVIOUS:case y.types.NEXT:case y.types.INPUT:case y.types.OUTPUT:return!0}return!1}static createFieldNode(e){return e?new y(y.types.FIELD,e):null}static createConnectionNode(e){if(!e)return null;const t=e.type;return t===M.INPUT_VALUE||t===M.NEXT_STATEMENT&&e.getParentInput()?y.createInputNode(e.getParentInput()):t===M.NEXT_STATEMENT?new y(y.types.NEXT,e):t===M.OUTPUT_VALUE?new y(y.types.OUTPUT,e):t===M.PREVIOUS_STATEMENT?new y(y.types.PREVIOUS,e):null}static createInputNode(e){return e&&e.connection?new y(y.types.INPUT,e.connection):null}static createBlockNode(e){return e?new y(y.types.BLOCK,e):null}static createStackNode(e){return e?new y(y.types.STACK,e):null}static createWorkspaceNode(e,t){return t&&e?new y(y.types.WORKSPACE,e,{wsCoordinate:t}):null}static createTopNode(e){const t=yr(e);return t?y.createConnectionNode(t):y.createBlockNode(e)}};y.NAVIGATE_ALL_FIELDS=!1,y.DEFAULT_OFFSET_Y=-20,function(e){e=e.types||(e.types={}),e.FIELD="field",e.BLOCK="block",e.INPUT="input",e.OUTPUT="output",e.NEXT="next",e.PREVIOUS="previous",e.STACK="stack",e.WORKSPACE="workspace"}(y||(y={}));var vp=class{constructor(){this.drawer_=this.curNode_=this.colour=null,this.type="marker"}setDrawer(e){this.drawer_=e}getDrawer(){return this.drawer_}getCurNode(){return this.curNode_}setCurNode(e){const t=this.curNode_;this.curNode_=e,this.drawer_&&this.drawer_.draw(t,this.curNode_)}draw(){this.drawer_&&this.drawer_.draw(this.curNode_,this.curNode_)}hide(){this.drawer_&&this.drawer_.hide()}dispose(){this.getDrawer()&&this.getDrawer().dispose()}},Xc=class extends vp{constructor(){super(),this.type="cursor"}next(){var e=this.getCurNode();if(!e)return null;for(e=e.next();e&&e.next()&&(e.getType()===y.types.NEXT||e.getType()===y.types.BLOCK);)e=e.next();return e&&this.setCurNode(e),e}in(){var e=this.getCurNode();if(!e)return null;(e.getType()===y.types.PREVIOUS||e.getType()===y.types.OUTPUT)&&(e=e.next());let t,o;return(e=(o=(t=e)==null?void 0:t.in())!=null?o:null)&&this.setCurNode(e),e}prev(){var e=this.getCurNode();if(!e)return null;for(e=e.prev();e&&e.prev()&&(e.getType()===y.types.NEXT||e.getType()===y.types.BLOCK);)e=e.prev();return e&&this.setCurNode(e),e}out(){var e=this.getCurNode();return e?((e=e.out())&&e.getType()===y.types.BLOCK&&(e=e.prev()||e),e&&this.setCurNode(e),e):null}};r(A.CURSOR,no,Xc);var ri=class extends Xc{constructor(){super()}next(){var e=this.getCurNode();return e?((e=this.getNextNode_(e,this.validNode_))&&this.setCurNode(e),e):null}in(){return this.next()}prev(){var e=this.getCurNode();return e?((e=this.getPreviousNode_(e,this.validNode_))&&this.setCurNode(e),e):null}out(){return this.prev()}getNextNode_(e,t){if(!e)return null;const o=e.in()||e.next();return t(o)?o:o?this.getNextNode_(o,t):(e=this.findSiblingOrParent_(e.out()),t(e)?e:e?this.getNextNode_(e,t):null)}getPreviousNode_(e,t){if(!e)return null;let o=e.prev();return o=o?this.getRightMostChild_(o):e.out(),t(o)?o:o?this.getPreviousNode_(o,t):null}validNode_(e){let t=!1;return e=e&&e.getType(),(e===y.types.OUTPUT||e===y.types.INPUT||e===y.types.FIELD||e===y.types.NEXT||e===y.types.PREVIOUS||e===y.types.WORKSPACE)&&(t=!0),t}findSiblingOrParent_(e){if(!e)return null;const t=e.next();return t||this.findSiblingOrParent_(e.out())}getRightMostChild_(e){if(!e.in())return e;for(e=e.in();e&&e.next();)e=e.next();return this.getRightMostChild_(e)}};ri.registrationName="basicCursor",r(A.CURSOR,ri.registrationName,ri);var Cp=class extends ri{validNode_(e){let t=!1;const o=e&&e.getType();return e&&(e=e.getLocation(),o===y.types.FIELD&&e&&e.isTabNavigable()&&e.isClickable()&&(t=!0)),t}},po={};po.arc=Ne,po.curve=ot,po.line=vs,po.lineOnAxis=D,po.lineTo=Xt,po.moveBy=Te,po.moveTo=Ue,po.point=P;var jc=10,Je=class extends ie{constructor(e,t){super(e,t),this.targetConnection=this.highlightPath=null,this.db_=e.workspace.connectionDBList[t],this.dbOpposite_=e.workspace.connectionDBList[is[t]],this.offsetInBlock_=new L(0,0),this.trackedState_=Je.TrackedState.WILL_TRACK}dispose(){super.dispose(),this.trackedState_===Je.TrackedState.TRACKED&&this.db_.removeConnection(this,this.y)}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){if(!this.sourceBlock_.workspace.isDragging()){var t=this.sourceBlock_.getRootBlock();if(!t.isInFlyout){var o=!1;if(!t.isMovable()){if(t=e.getSourceBlock().getRootBlock(),!t.isMovable())return;e=this,o=!0}var s=_e()==t;s||t.addSelect();var i=e.x+n.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*jc)-this.x,a=e.y+n.config$$module$build$src$core$config.snapRadius+Math.floor(Math.random()*jc)-this.y;o&&(a=-a),t.RTL&&(i=e.x-n.config$$module$build$src$core$config.snapRadius-Math.floor(Math.random()*jc)-this.x),t.moveBy(i,a),s||t.removeSelect()}}}moveTo(e,t){let o=!1;return this.trackedState_===Je.TrackedState.WILL_TRACK?(this.db_.addConnection(this,t),this.trackedState_=Je.TrackedState.TRACKED,o=!0):this.trackedState_===Je.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_}tighten(){const e=this.targetConnection.x-this.x,t=this.targetConnection.y-this.y;if(e!==0||t!==0){const s=this.targetBlock();var o=s.getSvgRoot();if(!o)throw Error("block is not rendered.");o=$t(o),s.translate(o.x-e,o.y-t),s.moveConnections(-e,-t)}}tightenEfficiently(){var e=this.targetConnection;const t=this.targetBlock();e&&t&&(e=L.difference(this.offsetInBlock_,e.offsetInBlock_),t.translate(e.x,e.y))}closest(e,t){return this.dbOpposite_.searchForClosest(this,e,t)}highlight(){if(!this.highlightPath){var e=this.sourceBlock_.workspace.getRenderer().getConstants(),t=e.shapeFor(this);this.type===M.INPUT_VALUE||this.type===M.OUTPUT_VALUE?(e=e.TAB_OFFSET_FROM_TOP,t=Te(0,-e)+D("v",e)+t.pathDown+D("v",e)):(e=e.NOTCH_OFFSET_LEFT-e.CORNER_RADIUS,t=Te(-e,0)+D("h",e)+t.pathLeft+D("h",e)),e=this.offsetInBlock_,this.highlightPath=I(f.PATH,{class:"blocklyHighlightedConnectionPath",d:t,transform:`translate(${e.x}, ${e.y})`+(this.sourceBlock_.RTL?" scale(-1 1)":"")},this.sourceBlock_.getSvgRoot())}}unhighlight(){this.highlightPath&&(re(this.highlightPath),this.highlightPath=null)}setTracking(e){e&&this.trackedState_===Je.TrackedState.TRACKED||!e&&this.trackedState_===Je.TrackedState.UNTRACKED||this.sourceBlock_.isInFlyout||(e?(this.db_.addConnection(this,this.y),this.trackedState_=Je.TrackedState.TRACKED):(this.trackedState_===Je.TrackedState.TRACKED&&this.db_.removeConnection(this,this.y),this.trackedState_=Je.TrackedState.UNTRACKED))}stopTrackingAll(){if(this.setTracking(!1),this.targetConnection){const o=this.targetBlock().getDescendants(!1);for(let s=0;s<o.length;s++){var e=o[s],t=e.getConnections_(!0);for(let i=0;i<t.length;i++)t[i].setTracking(!1);for(e=e.getIcons(),t=0;t<e.length;t++)e[t].setVisible(!1)}}}startTrackingAll(){this.setTracking(!0);let e=[];if(this.type!==M.INPUT_VALUE&&this.type!==M.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(tt()){const o=K();setTimeout((function(){t.isDisposed()||t.getParent()||(C(o),this.bumpAwayFrom(e),C(!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=t.getSourceBlock(),i=o.getSourceBlock();super.disconnectInternal(e),s.rendered&&s.queueRender(),i.rendered&&(i.updateDisabled(),i.queueRender(),i.getSvgRoot().style.display="block")}}respawnShadow_(){super.respawnShadow_();var e=this.targetBlock();e&&(e.initSvg(),e.render(!1),e=this.getSourceBlock(),e.rendered&&e.queueRender())}neighbours(e){return this.dbOpposite_.getNeighbours(this,e)}connect_(e){super.connect_(e);var t=this.getSourceBlock();e=e.getSourceBlock();const o=t.rendered,s=e.rendered;o&&t.updateDisabled(),s&&e.updateDisabled(),o&&s&&(this.type===M.NEXT_STATEMENT||this.type===M.PREVIOUS_STATEMENT?e.queueRender():t.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(),this.sourceBlock_.bumpNeighbours())}};(function(e){e=e.TrackedState||(e.TrackedState={}),e[e.WILL_TRACK=-1]="WILL_TRACK",e[e.UNTRACKED=0]="UNTRACKED",e[e.TRACKED=1]="TRACKED"})(Je||(Je={})),Je.TrackedState;var Np=class extends Dn{constructor(e){super(e),this.paragraphElement=null,this.collapseHidden=!1,this.createIcon(),this.text=Object.create(null)}drawIcon_(e){I(f.PATH,{class:"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},e),I(f.PATH,{class:"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},e),I(f.RECT,{class:"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},e)}setVisible(e){e!==this.isVisible()&&(x(new(F(lo))(this.getBlock(),e,"warning")),e?this.createBubble():this.disposeBubble())}createBubble(){this.paragraphElement=W.textToDom(this.getText()),this.bubble_=W.createNonEditableBubble(this.paragraphElement,this.getBlock(),this.iconXY_),this.applyColour()}disposeBubble(){this.bubble_&&(this.bubble_.dispose(),this.bubble_=null),this.paragraphElement=null}setText(e,t){this.text[t]!==e&&(e?this.text[t]=e:delete this.text[t],this.isVisible()&&(this.setVisible(!1),this.setVisible(!0)))}getText(){const e=[];for(const t in this.text)e.push(this.text[t]);return e.join(`
|
|
556
|
+
`)}dispose(){this.getBlock().warning=null,super.dispose()}},Gn=new Set,Pn=new WeakSet,Yc=0,mt=class extends Ks{constructor(e,t,o){super(e,t,o),this.renderingDebugger=null,this.width=this.height=0,this.warningTextDb=new Map,this.warning=this.commentIcon_=this.mutator=null,this.eventsInit_=this.renderIsInProgress_=this.visuallyDisabled=this.rendered=!1,this.translation="",this.bumpNeighboursPid=0,this.relativeCoords=new L(0,0),this.workspace=e,this.svgGroup_=I(f.G,{}),this.style=e.getRenderer().getConstants().getBlockStyle(null),this.pathObject=e.getRenderer().makePathObject(this.svgGroup_,this.style),this.useDragSurface_=!!e.getBlockDragSurface(),e=this.pathObject.svgPath,e.tooltip=this,mr(e),this.svgGroup_.setAttribute("data-id",this.id),this.doInit_()}initSvg(){if(!this.workspace.rendered)throw TypeError("Workspace is headless.");for(let t=0,o;o=this.inputList[t];t++)o.init();var e=this.getIcons();for(let t=0;t<e.length;t++)e[t].createIcon();this.applyColour(),this.pathObject.updateMovable(this.isMovable()),e=this.getSvgRoot(),this.workspace.options.readOnly||this.eventsInit_||!e||w(e,"pointerdown",this,this.onMouseDown_),this.eventsInit_=!0,e.parentNode||this.workspace.getCanvas().appendChild(e)}getColourSecondary(){return this.style.colourSecondary}getColourTertiary(){return this.style.colourTertiary}select(){if(this.isShadow()&&this.getParent())this.getParent().select();else if(_e()!==this){var e=null;if(_e()){e=_e().id,ve();try{_e().unselect()}finally{Ie()}}e=new(F(yo))(e,this.id,this.workspace.id),x(e),et(this),this.addSelect()}}unselect(){if(_e()===this){var e=new(F(yo))(this.id,null,this.workspace.id);e.workspaceId=this.workspace.id,x(e),et(null),this.removeSelect()}}getIcons(){const e=[];return this.mutator&&e.push(this.mutator),this.commentIcon_&&e.push(this.commentIcon_),this.warning&&e.push(this.warning),e}setParent(e){const t=this.parentBlock_;if(e!==t){Bt(),super.setParent(e),xt();var o=this.getSvgRoot();if(!this.workspace.isClearing&&o){var s=this.getRelativeToSurfaceXY();e?e.getSvgRoot().appendChild(o):t&&(this.workspace.getCanvas().appendChild(o),this.translate(s.x,s.y)),this.applyColour()}}}getRelativeToSurfaceXY(){let e=0,t=0;const o=this.useDragSurface_?this.workspace.getBlockDragSurface().getGroup():null;let s=this.getSvgRoot();if(s)do{var i=$t(s);e+=i.x,t+=i.y,this.useDragSurface_&&this.workspace.getBlockDragSurface().getCurrentBlock()===s&&(i=this.workspace.getBlockDragSurface().getSurfaceTranslation(),e+=i.x,t+=i.y),s=s.parentNode}while(s&&s!==this.workspace.getCanvas()&&s!==o);return new L(e,t)}moveBy(e,t){if(this.parentBlock_)throw Error("Block has parent.");const o=Oe();let s=null;o&&(s=new(F(ze))(this));const i=this.getRelativeToSurfaceXY();this.translate(i.x+e,i.y+t),this.moveConnections(e,t),o&&s&&(s.recordNew(),x(s)),this.workspace.resizeContents()}translate(e,t){this.translation=`translate(${e}, ${t})`,this.relativeCoords=new L(e,t),this.getSvgRoot().setAttribute("transform",this.getTranslation())}getTranslation(){return this.translation}moveToDragSurface(){if(this.useDragSurface_){var e=this.getRelativeToSurfaceXY();this.clearTransformAttributes_(),this.workspace.getBlockDragSurface().translateSurface(e.x,e.y),(e=this.getSvgRoot())&&this.workspace.getBlockDragSurface().setBlocksAndShow(e)}}moveTo(e){const t=this.getRelativeToSurfaceXY();this.moveBy(e.x-t.x,e.y-t.y)}moveOffDragSurface(e){this.useDragSurface_&&(this.translate(e.x,e.y),this.workspace.getBlockDragSurface().clearAndHide(this.workspace.getCanvas()))}moveDuringDrag(e){this.useDragSurface_?this.workspace.getBlockDragSurface().translateSurface(e.x,e.y):(this.translate(e.x,e.y),this.getSvgRoot().setAttribute("transform",this.getTranslation()))}clearTransformAttributes_(){this.getSvgRoot().removeAttribute("transform")}snapToGrid(){if(!(this.isDeadOrDying()||this.workspace.isDragging()||this.getParent()||this.isInFlyout)){var e=this.workspace.getGrid();if(e&&e.shouldSnap()){var t=e.getSpacing(),o=t/2,s=this.getRelativeToSurfaceXY();e=Math.round(Math.round((s.x-o)/t)*t+o-s.x),t=Math.round(Math.round((s.y-o)/t)*t+o-s.y),(e||t)&&this.moveBy(e,t)}}}getBoundingRectangle(){const e=this.getRelativeToSurfaceXY(),t=this.getHeightWidth();let o,s;return this.RTL?(o=e.x-t.width,s=e.x):(o=e.x,s=e.x+t.width),new Se(e.y,e.y+t.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_())}updateCollapsed_(){var e=this.isCollapsed();const t=xs,o=vn;for(let i=0,a;a=this.inputList[i];i++)a.name!==t&&a.setVisible(!e);if(e){e=this.getIcons();for(let i=0,a;a=e[i];i++)a.setVisible(!1);e=this.toString(Op);var s=this.getField(o);s?s.setValue(e):(this.getInput(t)||this.appendDummyInput(t)).appendField(new Mo(e),o)}else this.updateDisabled(),this.removeInput(t)}tab(e,t){const o=new Cp;o.setCurNode(y.createFieldNode(e)),e=o.getCurNode(),t?o.next():o.prev(),(t=o.getCurNode())&&t!==e&&(t.getLocation().showEditor(),this.workspace.keyboardAccessibilityMode&&this.workspace.getCursor().setCurNode(t))}onMouseDown_(e){const 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(){if(this.workspace.options.readOnly||!this.contextMenu)return null;const e=le.registry.getContextMenuOptions(le.ScopeType.BLOCK,{block:this});return this.customContextMenu&&this.customContextMenu(e),e}showContextMenu(e){const t=this.generateContextMenu();t&&t.length&&(Cr(e,t,this.RTL),ia(this))}moveConnections(e,t){if(this.rendered){for(var o=this.getConnections_(!1),s=0;s<o.length;s++)o[s].moveBy(e,t);for(o=this.getIcons(),s=0;s<o.length;s++)o[s].computeIconLocation();for(o=0;o<this.childBlocks_.length;o++)this.childBlocks_[o].moveConnections(e,t)}}setDragging(e){e?(this.translation="",Ko.push(...this.getConnections_(!0)),U(this.svgGroup_,"blocklyDragging")):(Ko.length=0,se(this.svgGroup_,"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=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.isDeadOrDying()||(Pl(),Nr(),t&&this.rendered&&(this.unplug(e),Zl(this)),super.dispose(!!e),re(this.svgGroup_))}disposeInternal(){this.isDeadOrDying()||(super.disposeInternal(),this.rendered=!1,_e()===this&&(this.unselect(),this.workspace.cancelCurrentGesture()),[...this.warningTextDb.values()].forEach(e=>clearTimeout(e)),this.warningTextDb.clear(),this.getIcons().forEach(e=>e.dispose()))}checkAndDelete(){this.workspace.isFlyout||(C(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),C(!1))}toCopyData(){return this.isInsertionMarker_?null:{saveInfo:Wt(this,{addCoordinates:!0,addNextBlocks:!1}),source:this.workspace,typeCounts:Eo(this,!0)}}applyColour(){this.pathObject.applyColour(this);const e=this.getIcons();for(let t=0;t<e.length;t++)e[t].applyColour();for(let t=0,o;o=this.inputList[t];t++)for(let s=0,i;i=o.fieldRow[s];s++)i.applyColour()}updateDisabled(){const e=!this.isEnabled()||this.getInheritedDisabled();if(this.visuallyDisabled!==e){this.applyColour(),this.visuallyDisabled=e;for(const t of this.getChildren(!1))t.updateDisabled()}}getCommentIcon(){return this.commentIcon_}setCommentText(e){this.commentModel.text!==e&&(super.setCommentText(e),e=e!==null,!!this.commentIcon_===e?this.commentIcon_.updateText():(e?this.comment=this.commentIcon_=new Ip(this):(this.commentIcon_.dispose(),this.comment=this.commentIcon_=null),this.rendered&&(this.render(),this.bumpNeighbours())))}setWarningText(e,t){const o=t||"";if(o)this.warningTextDb.has(o)&&(clearTimeout(this.warningTextDb.get(o)),this.warningTextDb.delete(o));else{for(var s of this.warningTextDb.values())clearTimeout(s);this.warningTextDb.clear()}if(this.workspace.isDragging())this.warningTextDb.set(o,setTimeout(()=>{this.isDeadOrDying()||(this.warningTextDb.delete(o),this.setWarningText(e,o))},100));else{if(this.isInFlyout&&(e=null),t=!1,typeof e=="string"){s=this.getSurroundParent();let i=null;for(;s;)s.isCollapsed()&&(i=s),s=s.getSurroundParent();i&&i.setWarningText(H.COLLAPSED_WARNINGS_WARNING,mt.COLLAPSED_WARNING_ID),this.warning||(this.warning=new Np(this),t=!0),this.warning.setText(e,o)}else this.warning&&!o?(this.warning.dispose(),t=!0):this.warning&&(t=this.warning.getText(),this.warning.setText("",o),(s=this.warning.getText())||this.warning.dispose(),t=t!==s);t&&this.rendered&&(this.render(),this.bumpNeighbours())}}setMutator(e){this.mutator&&this.mutator!==e&&this.mutator.dispose(),e&&(e.setBlock(this),this.mutator=e,e.createIcon()),this.rendered&&(this.render(),this.bumpNeighbours())}setEnabled(e){this.isEnabled()!==e&&(super.setEnabled(e),this.rendered&&!this.getInheritedDisabled()&&this.updateDisabled())}setHighlighted(e){this.rendered&&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_),this.pathObject.setStyle(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_=e,t)this.hat=t.hat,this.pathObject.setStyle(t),this.colour_=t.colourPrimary,this.style=t,this.applyColour();else throw Error("Invalid style name: "+e)}bringToFront(){let e=this;do{const t=e.getSvgRoot(),o=t.parentNode,s=o.childNodes;s[s.length-1]!==t&&o.appendChild(t),e=e.getParent()}while(e)}setPreviousStatement(e,t){super.setPreviousStatement(e,t),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setNextStatement(e,t){super.setNextStatement(e,t),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setOutput(e,t){super.setOutput(e,t),this.rendered&&(this.queueRender(),this.bumpNeighbours())}setInputsInline(e){super.setInputsInline(e),this.rendered&&(this.queueRender(),this.bumpNeighbours())}removeInput(e,t){return e=super.removeInput(e,t),this.rendered&&(this.queueRender(),this.bumpNeighbours()),e}moveNumberedInputBefore(e,t){super.moveNumberedInputBefore(e,t),this.rendered&&(this.queueRender(),this.bumpNeighbours())}appendInput_(e,t){return e=super.appendInput_(e,t),this.rendered&&(this.queueRender(),this.bumpNeighbours()),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((e||this.rendered)&&(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 Je(this,e)}getNextBlock(){return super.getNextBlock()}getPreviousBlock(){return super.getPreviousBlock()}bumpNeighbours(){if(!this.bumpNeighboursPid){var e=K();this.bumpNeighboursPid=setTimeout(()=>{const t=K();C(e),this.getRootBlock().bumpNeighboursInternal(),C(t),this.bumpNeighboursPid=0},n.config$$module$build$src$core$config.bumpDelay)}}bumpNeighboursInternal(){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.bumpNeighboursInternal()}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):t.bumpAwayFrom(o)))}}scheduleSnapAndBump(){const e=K();setTimeout(()=>{C(e),this.snapToGrid(),C(!1)},n.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(e,t){e.type!==M.NEXT_STATEMENT&&e.type!==M.INPUT_VALUE||this.moveBy(t.x-e.x,t.y-e.y)}getFirstStatementConnection(){return super.getFirstStatementConnection()}getChildren(e){return super.getChildren(e)}queueRender(){Pd(this)}render(e){if(!this.renderIsInProgress_){this.renderIsInProgress_=!0;try{if(this.rendered=!0,Bt(),this.isCollapsed()&&this.updateCollapsed_(),this.workspace.getRenderer().render(this),this.updateConnectionLocations(),e!==!1){const t=this.getParent();t?t.render(!0):this.workspace.resizeContents()}xt(),this.updateMarkers_()}finally{this.renderIsInProgress_=!1}}}renderEfficiently(){this.rendered=!0,Bt(),this.isCollapsed()&&this.updateCollapsed_(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),xt(),this.updateMarkers_()}tightenChildrenEfficiently(){for(const e of this.inputList){const t=e.connection;t&&t.tightenEfficiently()}this.nextConnection&&this.nextConnection.tightenEfficiently()}updateMarkers_(){this.workspace.keyboardAccessibilityMode&&this.pathObject.cursorSvg&&this.workspace.getCursor().draw(),this.workspace.keyboardAccessibilityMode&&this.pathObject.markerSvg&&this.workspace.getMarker(jr.LOCAL_MARKER).draw();for(const e of this.inputList)for(const t of e.fieldRow)t.updateMarkers_()}updateConnectionLocations(){const e=this.getRelativeToSurfaceXY();this.previousConnection&&this.previousConnection.moveToOffset(e),this.outputConnection&&this.outputConnection.moveToOffset(e);for(let t=0;t<this.inputList.length;t++){const o=this.inputList[t].connection;o&&(o.moveToOffset(e),o.isConnected()&&o.tighten())}this.nextConnection&&(this.nextConnection.moveToOffset(e),this.nextConnection.isConnected()&&this.nextConnection.tighten())}setCursorSvg(e){this.pathObject.setCursorSvg(e)}setMarkerSvg(e){this.pathObject.setMarkerSvg(e)}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)}};mt.INLINE=-1,mt.COLLAPSED_WARNING_ID="TEMP_COLLAPSED_WARNING_";var yp=class{constructor(e,t){this.bubble=e,this.workspace=t,this.dragTarget_=null,this.wouldDeleteBubble_=!1,this.startXY_=this.bubble.getRelativeToSurfaceXY(),this.dragSurface_=t.getBlockDragSurface()}startBubbleDrag(){K()||C(!0),this.workspace.setResizesEnabled(!1),this.bubble.setAutoLayout(!1),this.dragSurface_&&(this.bubble.moveTo(0,0),this.dragSurface_.translateSurface(this.startXY_.x,this.startXY_.y),this.dragSurface_.setBlocksAndShow(this.bubble.getSvgRoot())),this.bubble.setDragging&&this.bubble.setDragging(!0)}dragBubble(e,t){t=this.pixelsToWorkspaceUnits_(t),t=L.sum(this.startXY_,t),this.bubble.moveDuringDrag(this.dragSurface_,t),t=this.dragTarget_,this.dragTarget_=this.workspace.getDragTarget(e),e=this.wouldDeleteBubble_,this.wouldDeleteBubble_=this.shouldDelete_(this.dragTarget_),e!==this.wouldDeleteBubble_&&this.updateCursorDuringBubbleDrag_(),this.dragTarget_!==t&&(t&&t.onDragExit(this.bubble),this.dragTarget_&&this.dragTarget_.onDragEnter(this.bubble)),this.dragTarget_&&this.dragTarget_.onDragOver(this.bubble)}shouldDelete_(e){return e&&this.workspace.getComponentManager().hasCapability(e.id,Be.Capability.DELETE_AREA)?e.wouldDelete(this.bubble,!1):!1}updateCursorDuringBubbleDrag_(){this.bubble.setDeleteStyle(this.wouldDeleteBubble_)}endBubbleDrag(e,t){this.dragBubble(e,t),this.dragTarget_&&this.dragTarget_.shouldPreventMove(this.bubble)?e=this.startXY_:(e=this.pixelsToWorkspaceUnits_(t),e=L.sum(this.startXY_,e)),this.bubble.moveTo(e.x,e.y),this.dragTarget_&&this.dragTarget_.onDrop(this.bubble),this.wouldDeleteBubble_?(this.fireMoveEvent_(),this.bubble.dispose()):(this.dragSurface_&&this.dragSurface_.clearAndHide(this.workspace.getBubbleCanvas()),this.bubble.setDragging&&this.bubble.setDragging(!1),this.fireMoveEvent_()),this.workspace.setResizesEnabled(!0),C(!1)}fireMoveEvent_(){if(this.bubble instanceof Xe){const e=new(F(ao))(this.bubble);e.setOldCoordinate(this.startXY_),e.recordNew(),x(e)}}pixelsToWorkspaceUnits_(e){return e=new L(e.x/this.workspace.scale,e.y/this.workspace.scale),this.workspace.isMutator&&e.scale(1/this.workspace.options.parentWorkspace.scale),e}},Ap=class{canConnect(e,t,o,s){return this.canConnectWithReason(e,t,o,s)===ie.CAN_CONNECT}canConnectWithReason(e,t,o,s){const i=this.doSafetyChecks(e,t);return i!==ie.CAN_CONNECT?i:this.doTypeChecks(e,t)?o&&!this.doDragChecks(e,t,s||0)?ie.REASON_DRAG_CHECKS_FAILED:ie.CAN_CONNECT:ie.REASON_CHECKS_FAILED}getErrorMessage(e,t,o){switch(e){case ie.REASON_SELF_CONNECTION:return"Attempted to connect a block to itself.";case ie.REASON_DIFFERENT_WORKSPACES:return"Blocks not on same workspace.";case ie.REASON_WRONG_TYPE:return"Attempt to connect incompatible types.";case ie.REASON_TARGET_NULL:return"Target connection is null.";case ie.REASON_CHECKS_FAILED:return"Connection checks failed. "+(t+" expected "+t.getCheck()+", found "+o.getCheck());case ie.REASON_SHADOW_PARENT:return"Connecting non-shadow to shadow block.";case ie.REASON_DRAG_CHECKS_FAILED:return"Drag checks failed.";case ie.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 ie.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?ie.REASON_SELF_CONNECTION:i.type!==is[e.type]?ie.REASON_WRONG_TYPE:o.workspace!==s.workspace?ie.REASON_DIFFERENT_WORKSPACES:o.isShadow()&&!s.isShadow()?ie.REASON_SHADOW_PARENT:i.type===M.OUTPUT_VALUE&&s.previousConnection&&s.previousConnection.isConnected()||i.type===M.PREVIOUS_STATEMENT&&s.outputConnection&&s.outputConnection.isConnected()?ie.REASON_PREVIOUS_AND_OUTPUT:ie.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.indexOf(e[o])!==-1)return!0;return!1}doDragChecks(e,t,o){if(e.distanceFrom(t)>o||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case M.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case M.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case M.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case M.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 Ko.indexOf(t)===-1}canConnectToPrevious_(e,t){return e.targetConnection||Ko.indexOf(t)!==-1?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};r(A.CONNECTION_CHECKER,no,Ap);var zs=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(;0<=s&&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(k){const fe=i-s[k].x,be=a-s[k].y;return Math.sqrt(fe*fe+be*be)<=t&&v.push(s[k]),be<t}const s=this.connections_,i=e.x,a=e.y;e=0;let p=s.length-2,$=p;for(;e<$;)s[$].y<a?e=$:p=$,$=Math.floor((e+p)/2);const v=[];if(p=e=$,s.length){for(;0<=e&&o(e);)e--;do p++;while(p<s.length&&o(p))}return v}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 a=this.calculateIndexForYPos_(e.y);o=null;let p=t,$,v=a-1;for(;0<=v&&this.isInYRange_(v,e.y,t);)$=this.connections_[v],this.connectionChecker.canConnect(e,$,!0,p)&&(o=$,p=$.distanceFrom(e)),v--;for(;a<this.connections_.length&&this.isInYRange_(a,e.y,t);)$=this.connections_[a],this.connectionChecker.canConnect(e,$,!0,p)&&(o=$,p=$.distanceFrom(e)),a++;return e.x=i,e.y=s,{connection:o,radius:p}}static init(e){const t=[];return t[M.INPUT_VALUE]=new zs(e),t[M.OUTPUT_VALUE]=new zs(e),t[M.NEXT_STATEMENT]=new zs(e),t[M.PREVIOUS_STATEMENT]=new zs(e),t}},Kc=class extends Bs{constructor(e){super(e),this.type=ze,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.recordUndo||(e.recordUndo=this.recordUndo),e}fromJson(e){if(_("Blockly.Events.BlockMove.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldParentId=e.oldParentId,this.oldInputName=e.oldInputName,e.oldCoordinate){var t=e.oldCoordinate.split(",");this.oldCoordinate=new L(Number(t[0]),Number(t[1]))}this.newParentId=e.newParentId,this.newInputName=e.newInputName,e.newCoordinate&&(t=e.newCoordinate.split(","),this.newCoordinate=new L(Number(t[0]),Number(t[1]))),e.recordUndo!==void 0&&(this.recordUndo=e.recordUndo)}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Kc),t.oldParentId=e.oldParentId,t.oldInputName=e.oldInputName,e.oldCoordinate&&(o=e.oldCoordinate.split(","),t.oldCoordinate=new L(Number(o[0]),Number(o[1]))),t.newParentId=e.newParentId,t.newInputName=e.newInputName,e.newCoordinate&&(o=e.newCoordinate.split(","),t.newCoordinate=new L(Number(o[0]),Number(o[1]))),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}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&&L.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 a=t.getBlockById(s);if(!a){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);else{t=o.outputConnection,(!t||o.previousConnection&&o.previousConnection.isConnected())&&(t=o.previousConnection);let p,$;o=($=t)==null?void 0:$.type,i?(o=a.getInput(i))&&(p=o.connection):o===M.PREVIOUS_STATEMENT&&(p=a.nextConnection),p&&t?t.connect(p):console.warn("Can't connect to non-existent input: "+i)}}else console.warn("Can't move non-existent block: "+this.blockId)}};r(A.EVENT,ze,Kc);var zc=class extends yt{constructor(e,t,o){t=e?e.workspace.id:t,t===null&&(t=void 0),super(t),this.type=Ao,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}fromJson(e){_("Blockly.Events.Click.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.targetType=e.targetType,this.blockId=e.blockId}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new zc),t.targetType=e.targetType,t.blockId=e.blockId,t}},Jc;(function(e){e.BLOCK="block",e.WORKSPACE="workspace",e.ZOOM_CONTROLS="zoom_controls"})(Jc||(Jc={})),r(A.EVENT,Ao,zc);var wo=class extends ws{constructor(e){super(),this.isBlank=!e,e&&(this.commentId=e.id,this.workspaceId=e.workspace.id,this.group=K(),this.recordUndo=tt())}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}fromJson(e){_("Blockly.Events.CommentBase.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.commentId=e.commentId}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new wo),t.commentId=e.commentId,t}static CommentCreateDeleteHelper(e,t){var o=e.getEventWorkspace_();if(t){if(t=n.createElement$$module$build$src$core$utils$xml("xml"),!e.xml)throw Error("Ecountered a comment event without proper xml");t.appendChild(e.xml),Es(t,o)}else{if(!e.commentId)throw Error("The comment ID is undefined. Either pass a comment to the constructor, or call fromJson");(o=o.getCommentById(e.commentId))?o.dispose():console.warn("Can't uncreate non-existent comment: "+e.commentId)}}},qc=class extends wo{constructor(e,t,o){super(e),this.type=xr,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}fromJson(e){_("Blockly.Events.CommentChange.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldContents_=e.oldContents,this.newContents_=e.newContents}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new qc),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)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.setContent(o)}else console.warn("Can't change non-existent comment: "+this.commentId)}};r(A.EVENT,xr,qc);var Zc=class extends wo{constructor(e){super(e),this.type=qo,e&&(this.xml=e.toXmlWithXY())}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");return e.xml=Vt(this.xml),e}fromJson(e){_("Blockly.Events.CommentCreate.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.xml=Ce(e.xml)}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Zc),t.xml=Ce(e.xml),t}run(e){wo.CommentCreateDeleteHelper(this,e)}};r(A.EVENT,qo,Zc);var Qc=class extends wo{constructor(e){super(e),this.type=Ls,e&&(this.xml=e.toXmlWithXY())}run(e){wo.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");return e.xml=Vt(this.xml),e}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new Qc),t.xml=Ce(e.xml),t}};r(A.EVENT,Ls,Qc);var eu=class extends wo{constructor(e){super(e),this.type=ao,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()}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}fromJson(e){_("Blockly.Events.CommentMove.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e);let t=e.oldCoordinate.split(",");this.oldCoordinate_=new L(Number(t[0]),Number(t[1])),t=e.newCoordinate.split(","),this.newCoordinate_=new L(Number(t[0]),Number(t[1]))}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new eu),o=e.oldCoordinate.split(","),t.oldCoordinate_=new L(Number(o[0]),Number(o[1])),o=e.newCoordinate.split(","),t.newCoordinate_=new L(Number(o[0]),Number(o[1])),t}isNull(){return L.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");var o=t.getRelativeToSurfaceXY();t.moveBy(e.x-o.x,e.y-o.y)}else console.warn("Can't move non-existent comment: "+this.commentId)}};r(A.EVENT,ao,eu);var tu=class extends yt{constructor(e,t,o,s){let i=e?e.workspace.id:void 0;s&&s.getType()===y.types.WORKSPACE&&(i=s.getLocation().id),super(i),this.type=wr,this.blockId=e==null?void 0:e.id,this.oldNode=o||void 0,this.newNode=s,this.isCursor=t}toJson(){const e=super.toJson();if(this.isCursor===void 0)throw Error("Whether this is a cursor event or not is undefined. Either pass a value to the constructor, or call fromJson");if(!this.newNode)throw Error("The new node is undefined. Either pass a node to the constructor, or call fromJson");return e.isCursor=this.isCursor,e.blockId=this.blockId,e.oldNode=this.oldNode,e.newNode=this.newNode,e}fromJson(e){_("Blockly.Events.MarkerMove.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.isCursor=e.isCursor,this.blockId=e.blockId,this.oldNode=e.oldNode,this.newNode=e.newNode}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new tu),t.isCursor=e.isCursor,t.blockId=e.blockId,t.oldNode=e.oldNode,t.newNode=e.newNode,t}};r(A.EVENT,wr,tu);var ou=class extends yt{constructor(e,t){super(t),this.type=Br,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}fromJson(e){_("Blockly.Events.ThemeChange.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.themeName=e.themeName}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ou),t.themeName=e.themeName,t}};r(A.EVENT,Br,ou);var su=class extends yt{constructor(e,t,o){super(o),this.type=Pr,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}fromJson(e){_("Blockly.Events.ToolboxItemSelect.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldItem=e.oldItem,this.newItem=e.newItem}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new su),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};r(A.EVENT,Pr,su);var ru=class extends yt{constructor(e,t){super(t),this.type=Gr,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}fromJson(e){_("Blockly.Events.TrashcanOpen.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.isOpen=e.isOpen}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new ru),t.isOpen=e.isOpen,t}};r(A.EVENT,Gr,ru);var iu=class extends Fr{constructor(e){super(e),this.type=ys,e&&(this.varType=e.type,this.varName=e.name)}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}fromJson(e){_("Blockly.Events.VarDelete.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.varType=e.varType,this.varName=e.varName}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new iu),t.varType=e.varType,t.varName=e.varName,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.varName)throw Error("The var name is undefined. Either pass a variable to the constructor, or call fromJson");e?t.deleteVariableById(this.varId):t.createVariable(this.varName,this.varType,this.varId)}};r(A.EVENT,ys,iu);var nu=class extends Fr{constructor(e,t){super(e),this.type=Dr,e&&(this.oldName=e.name,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}fromJson(e){_("Blockly.Events.VarRename.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldName=e.oldName,this.newName=e.newName}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new nu),t.oldName=e.oldName,t.newName=e.newName,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.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");e?t.renameVariableById(this.varId,this.newName):t.renameVariableById(this.varId,this.oldName)}};r(A.EVENT,Dr,nu);var lu=class extends yt{constructor(e,t,o,s,i){super(s),this.type=Jo,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}fromJson(e){_("Blockly.Events.Viewport.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.viewTop=e.viewTop,this.viewLeft=e.viewLeft,this.scale=e.scale,this.oldScale=e.oldScale}static fromJson(e,t,o){return t=super.fromJson(e,t,o??new lu),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};r(A.EVENT,Jo,lu),n.module$build$src$core$events$events={},n.module$build$src$core$events$events.Abstract=ws,n.module$build$src$core$events$events.BLOCK_CHANGE=Ge,n.module$build$src$core$events$events.BLOCK_CREATE=He,n.module$build$src$core$events$events.BLOCK_DELETE=jt,n.module$build$src$core$events$events.BLOCK_DRAG=As,n.module$build$src$core$events$events.BLOCK_MOVE=ze,n.module$build$src$core$events$events.BUBBLE_OPEN=lo,n.module$build$src$core$events$events.BUMP_EVENTS=tc,n.module$build$src$core$events$events.BlockBase=Bs,n.module$build$src$core$events$events.BlockChange=es,n.module$build$src$core$events$events.BlockCreate=Ec,n.module$build$src$core$events$events.BlockDelete=mc,n.module$build$src$core$events$events.BlockDrag=Fc,n.module$build$src$core$events$events.BlockMove=Kc,n.module$build$src$core$events$events.BubbleOpen=wc,n.module$build$src$core$events$events.BubbleType=Gc,n.module$build$src$core$events$events.CHANGE=Ge,n.module$build$src$core$events$events.CLICK=Ao,n.module$build$src$core$events$events.COMMENT_CHANGE=xr,n.module$build$src$core$events$events.COMMENT_CREATE=qo,n.module$build$src$core$events$events.COMMENT_DELETE=Ls,n.module$build$src$core$events$events.COMMENT_MOVE=ao,n.module$build$src$core$events$events.CREATE=He,n.module$build$src$core$events$events.Click=zc,n.module$build$src$core$events$events.ClickTarget=Jc,n.module$build$src$core$events$events.CommentBase=wo,n.module$build$src$core$events$events.CommentChange=qc,n.module$build$src$core$events$events.CommentCreate=Zc,n.module$build$src$core$events$events.CommentDelete=Qc,n.module$build$src$core$events$events.CommentMove=eu,n.module$build$src$core$events$events.DELETE=jt,n.module$build$src$core$events$events.FINISHED_LOADING=ks,n.module$build$src$core$events$events.FinishedLoading=np,n.module$build$src$core$events$events.MARKER_MOVE=wr,n.module$build$src$core$events$events.MOVE=ze,n.module$build$src$core$events$events.MarkerMove=tu,n.module$build$src$core$events$events.SELECTED=yo,n.module$build$src$core$events$events.Selected=ac,n.module$build$src$core$events$events.THEME_CHANGE=Br,n.module$build$src$core$events$events.TOOLBOX_ITEM_SELECT=Pr,n.module$build$src$core$events$events.TRASHCAN_OPEN=Gr,n.module$build$src$core$events$events.ThemeChange=ou,n.module$build$src$core$events$events.ToolboxItemSelect=su,n.module$build$src$core$events$events.TrashcanOpen=ru,n.module$build$src$core$events$events.UI=Mr,n.module$build$src$core$events$events.Ui=lp,n.module$build$src$core$events$events.UiBase=yt,n.module$build$src$core$events$events.VAR_CREATE=zo,n.module$build$src$core$events$events.VAR_DELETE=ys,n.module$build$src$core$events$events.VAR_RENAME=Dr,n.module$build$src$core$events$events.VIEWPORT_CHANGE=Jo,n.module$build$src$core$events$events.VarBase=Fr,n.module$build$src$core$events$events.VarCreate=nc,n.module$build$src$core$events$events.VarDelete=iu,n.module$build$src$core$events$events.VarRename=nu,n.module$build$src$core$events$events.ViewportChange=lu,n.module$build$src$core$events$events.clearPendingUndo=Z,n.module$build$src$core$events$events.disable=ve,n.module$build$src$core$events$events.disableOrphans=_s,n.module$build$src$core$events$events.enable=Ie,n.module$build$src$core$events$events.filter=Fe,n.module$build$src$core$events$events.fire=x,n.module$build$src$core$events$events.fromJson=hs,n.module$build$src$core$events$events.get=F,n.module$build$src$core$events$events.getDescendantIds=Bo,n.module$build$src$core$events$events.getGroup=K,n.module$build$src$core$events$events.getRecordUndo=tt,n.module$build$src$core$events$events.isEnabled=Oe,n.module$build$src$core$events$events.setGroup=C,n.module$build$src$core$events$events.setRecordUndo=We,Ca();var qe={};qe.registerCleanup=pa,qe.registerCollapse=Ta,qe.registerCollapseExpandBlock=Ia,qe.registerComment=ba,qe.registerDefaultOptions=Ca,qe.registerDelete=Sa,qe.registerDeleteAll=ma,qe.registerDisable=Oa,qe.registerDuplicate=fa,qe.registerExpand=$a,qe.registerHelp=va,qe.registerInline=Ra,qe.registerRedo=_a,qe.registerUndo=da;var Lp=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},Bn=class extends Lp{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e,t){return e instanceof mt?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e&&!t)):this.updateWouldDelete_(e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},ii=class extends ee{constructor(e,t,o){super(ee.SKIP_SETUP),this.spellcheck_=!0,this.htmlInput_=null,this.isTextValid_=this.isBeingEdited_=!1,this.onKeyInputWrapper_=this.onKeyDownWrapper_=null,this.fullBlockClickTarget_=!1,this.workspace_=null,this.SERIALIZABLE=!0,this.CURSOR="text",e!==ee.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(){const e=this.getSourceBlock();if(!e)throw new Le;if(this.getConstants().FULL_BLOCK_FIELDS){let t=0,o=0;for(let s=0,i;i=e.inputList[s];s++){for(let a=0;i.fieldRow[a];a++)t++;i.connection&&o++}this.fullBlockClickTarget_=1>=t&&e.outputConnection&&!o}else this.fullBlockClickTarget_=!1;this.fullBlockClickTarget_?this.clickTarget_=this.sourceBlock_.getSvgRoot():this.createBorderRect_(),this.createTextElement_()}doValueInvalid_(e){this.isBeingEdited_&&(this.isDirty_=!0,this.isTextValid_=!1,e=this.value_,this.value_=this.htmlInput_.getAttribute("data-untyped-default-value"),this.sourceBlock_&&Oe()&&x(new(F(Ge))(this.sourceBlock_,"field",this.name||null,e,this.value_)))}doValueUpdate_(e){this.isTextValid_=this.isDirty_=!0,this.value_=e}applyColour(){if(this.sourceBlock_&&this.getConstants().FULL_BLOCK_FIELDS){var e=this.sourceBlock_;this.borderRect_?this.borderRect_.setAttribute("stroke",e.style.colourTertiary):e.pathObject.svgPath.setAttribute("fill",this.getConstants().FIELD_BORDER_RECT_COLOUR)}}render_(){if(super.render_(),this.isBeingEdited_){this.resizeEditor_();const e=this.htmlInput_;this.isTextValid_?(se(e,"blocklyInvalidInput"),ge(e,pe.INVALID,!1)):(U(e,"blocklyInvalidInput"),ge(e,pe.INVALID,!0))}}setSpellcheck(e){e!==this.spellcheck_&&(this.spellcheck_=e,this.htmlInput_&&this.htmlInput_.setAttribute("spellcheck",this.spellcheck_))}showEditor_(e,t=!1){this.workspace_=this.sourceBlock_.workspace,!t&&this.workspace_.options.modalInputs&&(_c||In||Gs)?this.showPromptEditor_():this.showInlineEditor_(t)}showPromptEditor_(){Si(H.CHANGE_VALUE_TITLE,this.getText(),e=>{e!==null&&this.setValue(this.getValueFromEditorText_(e))})}showInlineEditor_(e){const t=this.getSourceBlock();if(!t)throw new Le;ji(this,t.RTL,this.widgetDispose_.bind(this)),this.htmlInput_=this.widgetCreate_(),this.isBeingEdited_=!0,e||(this.htmlInput_.focus({preventScroll:!0}),this.htmlInput_.select())}widgetCreate_(){var e=this.getSourceBlock();if(!e)throw new Le;C(!0);const t=Yo();var o=this.getClickTarget_();if(!o)throw Error("A click target has not been set.");U(o,"editing"),o=document.createElement("input"),o.className="blocklyHtmlInput",o.setAttribute("spellcheck",this.spellcheck_);const s=this.workspace_.getScale();var i=this.getConstants().FIELD_TEXT_FONTSIZE*s+"pt";return t.style.fontSize=i,o.style.fontSize=i,i=ii.BORDERRADIUS*s+"px",this.fullBlockClickTarget_&&(i=this.getScaledBBox(),i=(i.bottom-i.top)/2+"px",e=e.getParent()?e.getParent().style.colourTertiary:this.sourceBlock_.style.colourTertiary,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_),C(!1),this.unbindInputEvents_();var e=Yo().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.");se(e,"editing")}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper_=w(e,"keydown",this,this.onHtmlInputKeyDown_),this.onKeyInputWrapper_=w(e,"input",this,this.onHtmlInputChange_)}unbindInputEvents_(){this.onKeyDownWrapper_&&(ce(this.onKeyDownWrapper_),this.onKeyDownWrapper_=null),this.onKeyInputWrapper_&&(ce(this.onKeyInputWrapper_),this.onKeyInputWrapper_=null)}onHtmlInputKeyDown_(e){e.key==="Enter"?(Ot(),It()):e.key==="Escape"?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value")),Ot(),It()):e.key==="Tab"&&(Ot(),It(),this.sourceBlock_.tab(this,!e.shiftKey),e.preventDefault())}onHtmlInputChange_(e){this.setValue(this.getValueFromEditorText_(this.htmlInput_.value))}setEditorValue_(e){this.isDirty_=!0,this.isBeingEdited_&&(this.htmlInput_.value=this.getEditorText_(e)),this.setValue(e)}resizeEditor_(){var e=this.getSourceBlock();if(!e)throw new Le;const t=Yo(),o=this.getScaledBBox();t.style.width=o.right-o.left+"px",t.style.height=o.bottom-o.top+"px",e=new L(e.RTL?o.right-t.offsetWidth:o.left,o.top),t.style.left=e.x+"px",t.style.top=e.y+"px"}isTabNavigable(){return!0}getText_(){return this.isBeingEdited_&&this.htmlInput_?this.htmlInput_.value:null}getEditorText_(e){return`${e}`}getValueFromEditorText_(e){return e}};ii.BORDERRADIUS=4;var z=class extends ii{constructor(e,t,o){super(ee.SKIP_SETUP),this.clockwise=z.CLOCKWISE,this.offset=z.OFFSET,this.wrap=z.WRAP,this.round=z.ROUND,this.boundEvents=[],this.symbol_=this.gauge=this.line=null,e!==ee.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){switch(super.configure_(e),e.mode){case xn.COMPASS:this.clockwise=!0,this.offset=90;break;case xn.PROTRACTOR:this.clockwise=!1,this.offset=0}e.clockwise&&(this.clockwise=e.clockwise),e.offset&&(this.offset=e.offset),e.wrap&&(this.wrap=e.wrap),e.round&&(this.round=e.round)}initView(){super.initView(),this.symbol_=I(f.TSPAN,{}),this.symbol_.appendChild(document.createTextNode("°")),this.getTextElement().appendChild(this.symbol_)}render_(){super.render_(),this.updateGraph()}showEditor_(e){super.showEditor_(e,_c||In||Gs),e=this.dropdownCreate(),bs().appendChild(e),this.sourceBlock_ instanceof mt&&Bi(this.sourceBlock_.style.colourPrimary,this.sourceBlock_.style.colourTertiary),Tr(this,this.dropdownDispose.bind(this)),this.updateGraph()}dropdownCreate(){const e=I(f.SVG,{xmlns:Ms,"xmlns:html":Ct,"xmlns:xlink":it,version:"1.1",height:2*z.HALF+"px",width:2*z.HALF+"px",style:"touch-action: none"}),t=I(f.CIRCLE,{cx:z.HALF,cy:z.HALF,r:z.RADIUS,class:"blocklyAngleCircle"},e);this.gauge=I(f.PATH,{class:"blocklyAngleGauge"},e),this.line=I(f.LINE,{x1:z.HALF,y1:z.HALF,class:"blocklyAngleLine"},e);for(let o=0;360>o;o+=15)I(f.LINE,{x1:z.HALF+z.RADIUS,y1:z.HALF,x2:z.HALF+z.RADIUS-(o%45===0?10:5),y2:z.HALF,class:"blocklyAngleMarks",transform:"rotate("+o+","+z.HALF+","+z.HALF+")"},e);return this.boundEvents.push(w(e,"click",this,this.hide)),this.boundEvents.push(w(t,"pointerdown",this,this.onMouseMove_,!0)),this.boundEvents.push(w(t,"pointermove",this,this.onMouseMove_,!0)),e}dropdownDispose(){for(const e of this.boundEvents)ce(e);this.boundEvents.length=0,this.line=this.gauge=null}hide(){Rs(this),Ot()}onMouseMove_(e){var t=this.gauge.ownerSVGElement.getBoundingClientRect();const o=e.clientX-t.left-z.HALF;e=e.clientY-t.top-z.HALF,t=Math.atan(-e/o),isNaN(t)||(t=Tl(t),0>o?t+=180:0<e&&(t+=360),t=this.clockwise?this.offset+360-t:360-(this.offset-t),this.displayMouseOrKeyboardValue(t))}displayMouseOrKeyboardValue(e){this.round&&(e=Math.round(e/this.round)*this.round),e=this.wrapValue(e),e!==this.value_&&this.setEditorValue_(e)}updateGraph(){if(this.gauge&&this.line){var e=Number(this.getText())+this.offset,t=ms(e%360);e=["M ",z.HALF,",",z.HALF];var o=z.HALF,s=z.HALF;if(!isNaN(t)){const i=Number(this.clockwise),a=ms(this.offset),p=Math.cos(a)*z.RADIUS,$=Math.sin(a)*-z.RADIUS;i&&(t=2*a-t),o+=Math.cos(t)*z.RADIUS,s-=Math.sin(t)*z.RADIUS,t=Math.abs(Math.floor((t-a)/Math.PI)%2),i&&(t=1-t),e.push(" l ",p,",",$," A ",z.RADIUS,",",z.RADIUS," 0 ",t," ",i," ",o,",",s," z")}this.gauge.setAttribute("d",e.join("")),this.line.setAttribute("x2",`${o}`),this.line.setAttribute("y2",`${s}`)}}onHtmlInputKeyDown_(e){super.onHtmlInputKeyDown_(e);var t=this.getSourceBlock();if(!t)throw new Le;let o=0;switch(e.key){case"ArrowLeft":o=t.RTL?1:-1;break;case"ArrowRight":o=t.RTL?-1:1;break;case"ArrowDown":o=-1;break;case"ArrowUp":o=1}o&&(t=this.getValue(),this.displayMouseOrKeyboardValue(t+o*this.round),e.preventDefault(),e.stopPropagation())}doClassValidation_(e){return e=Number(e),isNaN(e)||!isFinite(e)?null:this.wrapValue(e)}wrapValue(e){return e%=360,0>e&&(e+=360),e>this.wrap&&(e-=360),e}static fromJson(e){return new this(e.angle,void 0,e)}};z.HALF=50,z.RADIUS=z.HALF-1,z.CLOCKWISE=!1,z.OFFSET=0,z.WRAP=360,z.ROUND=15,ut("field_angle",z),z.prototype.DEFAULT_VALUE=0,Tt(`
|
|
557
|
+
.blocklyAngleCircle {
|
|
558
|
+
stroke: #444;
|
|
559
|
+
stroke-width: 1;
|
|
560
|
+
fill: #ddd;
|
|
561
|
+
fill-opacity: 0.8;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
.blocklyAngleMarks {
|
|
565
|
+
stroke: #444;
|
|
566
|
+
stroke-width: 1;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.blocklyAngleGauge {
|
|
570
|
+
fill: #f88;
|
|
571
|
+
fill-opacity: 0.8;
|
|
572
|
+
pointer-events: none;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.blocklyAngleLine {
|
|
576
|
+
stroke: #f00;
|
|
577
|
+
stroke-width: 2;
|
|
578
|
+
stroke-linecap: round;
|
|
579
|
+
pointer-events: none;
|
|
580
|
+
}
|
|
581
|
+
`);var xn;(function(e){e.COMPASS="compass",e.PROTRACTOR="protractor"})(xn||(xn={}));var ns=class extends ee{constructor(e,t,o){super(ee.SKIP_SETUP),this.SERIALIZABLE=!0,this.CURSOR="default",this.value_=this.value_,this.checkChar_=ns.CHECK_CHAR,e!==ee.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(ns);return e!==null?e:this.getValueBoolean()}initView(){super.initView();const e=this.getTextElement();U(e,"blocklyCheckbox"),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||ns.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)}};ns.CHECK_CHAR="✓",ut("field_checkbox",ns),ns.prototype.DEFAULT_VALUE=!1;var _t=class extends ee{constructor(e,t,o){super(ee.SKIP_SETUP),this.highlightedIndex=this.picker=null,this.boundEvents=[],this.SERIALIZABLE=!0,this.CURSOR="default",this.isDirty_=!1,this.titles=this.colours=null,this.columns=0,e!==ee.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.colourOptions&&(this.colours=e.colourOptions),e.colourTitles&&(this.titles=e.colourTitles),e.columns&&(this.columns=e.columns)}initView(){this.size_=new Pe(this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT),this.getConstants().FIELD_COLOUR_FULL_BLOCK?this.sourceBlock_ instanceof mt&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()):(this.createBorderRect_(),this.getBorderRect().style.fillOpacity="1")}applyColour(){this.getConstants().FIELD_COLOUR_FULL_BLOCK?this.sourceBlock_ instanceof mt&&(this.sourceBlock_.pathObject.svgPath.setAttribute("fill",this.getValue()),this.sourceBlock_.pathObject.svgPath.setAttribute("stroke","#fff")):this.borderRect_&&(this.borderRect_.style.fill=this.getValue())}doClassValidation_(e){return typeof e!="string"?null:vo(e)}doValueUpdate_(e){this.value_=e,this.borderRect_?this.borderRect_.style.fill=e:this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_ instanceof mt&&(this.sourceBlock_.pathObject.svgPath.setAttribute("fill",e),this.sourceBlock_.pathObject.svgPath.setAttribute("stroke","#fff"))}getText(){let e=this.value_;return/^#(.)\1(.)\2(.)\3$/.test(e)&&(e="#"+e[1]+e[3]+e[5]),e}setColours(e,t){return this.colours=e,t&&(this.titles=t),this}setColumns(e){return this.columns=e,this}showEditor_(){this.dropdownCreate(),bs().appendChild(this.picker),Tr(this,this.dropdownDispose.bind(this)),this.picker.focus({preventScroll:!0})}onClick(e){e=(e=e.target)&&e.getAttribute("data-colour"),e!==null&&(this.setValue(e),Rs(this))}onKeyDown(e){let t=!0;var o;switch(e.key){case"ArrowUp":this.moveHighlightBy(0,-1);break;case"ArrowDown":this.moveHighlightBy(0,1);break;case"ArrowLeft":this.moveHighlightBy(-1,0);break;case"ArrowRight":this.moveHighlightBy(1,0);break;case"Enter":(o=this.getHighlighted())&&(o=o.getAttribute("data-colour"),o!==null&&this.setValue(o)),It();break;default:t=!1}t&&e.stopPropagation()}moveHighlightBy(e,t){if(this.highlightedIndex){var o=this.colours||_t.COLOURS,s=this.columns||_t.COLUMNS,i=this.highlightedIndex%s,a=Math.floor(this.highlightedIndex/s);i+=e,a+=t,0>e?0>i&&0<a?(i=s-1,a--):0>i&&(i=0):0<e?i>s-1&&a<Math.floor(o.length/s)-1?(i=0,a++):i>s-1&&i--:0>t?0>a&&(a=0):0<t&&a>Math.floor(o.length/s)-1&&(a=Math.floor(o.length/s)-1),this.setHighlightedCell(this.picker.childNodes[a].childNodes[i],a*s+i)}}onMouseMove(e){const t=(e=e.target)&&Number(e.getAttribute("data-index"));t!==null&&t!==this.highlightedIndex&&this.setHighlightedCell(e,t)}onMouseEnter(){let e;(e=this.picker)==null||e.focus({preventScroll:!0})}onMouseLeave(){var e;(e=this.picker)==null||e.blur(),(e=this.getHighlighted())&&se(e,"blocklyColourHighlighted")}getHighlighted(){if(!this.highlightedIndex)return null;const e=this.columns||_t.COLUMNS,t=this.picker.childNodes[Math.floor(this.highlightedIndex/e)];return t?t.childNodes[this.highlightedIndex%e]:null}setHighlightedCell(e,t){const o=this.getHighlighted();o&&se(o,"blocklyColourHighlighted"),U(e,"blocklyColourHighlighted"),this.highlightedIndex=t,(e=e.getAttribute("id"))&&this.picker&&ge(this.picker,pe.ACTIVEDESCENDANT,e)}dropdownCreate(){const e=this.columns||_t.COLUMNS,t=this.colours||_t.COLOURS,o=this.titles||_t.TITLES,s=this.getValue(),i=document.createElement("table");i.className="blocklyColourTable",i.tabIndex=0,i.dir="ltr",St(i,lt.GRID),ge(i,pe.EXPANDED,!0),ge(i,pe.ROWCOUNT,Math.floor(t.length/e)),ge(i,pe.COLCOUNT,e);let a;for(let p=0;p<t.length;p++){p%e===0&&(a=document.createElement("tr"),St(a,lt.ROW),i.appendChild(a));const $=document.createElement("td");a.appendChild($),$.setAttribute("data-colour",t[p]),$.title=o[p]||t[p],$.id=oo(),$.setAttribute("data-index",`${p}`),St($,lt.GRIDCELL),ge($,pe.LABEL,t[p]),ge($,pe.SELECTED,t[p]===s),$.style.backgroundColor=t[p],t[p]===s&&($.className="blocklyColourSelected",this.highlightedIndex=p)}this.boundEvents.push(w(i,"pointerdown",this,this.onClick,!0)),this.boundEvents.push(w(i,"pointermove",this,this.onMouseMove,!0)),this.boundEvents.push(w(i,"pointerenter",this,this.onMouseEnter,!0)),this.boundEvents.push(w(i,"pointerleave",this,this.onMouseLeave,!0)),this.boundEvents.push(w(i,"keydown",this,this.onKeyDown,!1)),this.picker=i}dropdownDispose(){for(const e of this.boundEvents)ce(e);this.boundEvents.length=0,this.highlightedIndex=this.picker=null}static fromJson(e){return new this(e.colour,void 0,e)}};_t.COLOURS="#ffffff #cccccc #c0c0c0 #999999 #666666 #333333 #000000 #ffcccc #ff6666 #ff0000 #cc0000 #990000 #660000 #330000 #ffcc99 #ff9966 #ff9900 #ff6600 #cc6600 #993300 #663300 #ffff99 #ffff66 #ffcc66 #ffcc33 #cc9933 #996633 #663333 #ffffcc #ffff33 #ffff00 #ffcc00 #999900 #666600 #333300 #99ff99 #66ff99 #33ff33 #33cc00 #009900 #006600 #003300 #99ffff #33ffff #66cccc #00cccc #339999 #336666 #003333 #ccffff #66ffff #33ccff #3366ff #3333ff #000099 #000066 #ccccff #9999ff #6666cc #6633ff #6600cc #333399 #330099 #ffccff #ff99ff #cc66cc #cc33cc #993399 #663366 #330033".split(" "),_t.TITLES=[],_t.COLUMNS=7,_t.prototype.DEFAULT_VALUE=_t.COLOURS[0],ut("field_colour",_t),Tt(`
|
|
582
|
+
.blocklyColourTable {
|
|
583
|
+
border-collapse: collapse;
|
|
584
|
+
display: block;
|
|
585
|
+
outline: none;
|
|
586
|
+
padding: 1px;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
.blocklyColourTable>tr>td {
|
|
590
|
+
border: 0.5px solid #888;
|
|
591
|
+
box-sizing: border-box;
|
|
592
|
+
cursor: pointer;
|
|
593
|
+
display: inline-block;
|
|
594
|
+
height: 20px;
|
|
595
|
+
padding: 0;
|
|
596
|
+
width: 20px;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
.blocklyColourTable>tr>td.blocklyColourHighlighted {
|
|
600
|
+
border-color: #eee;
|
|
601
|
+
box-shadow: 2px 2px 7px 2px rgba(0, 0, 0, 0.3);
|
|
602
|
+
position: relative;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.blocklyColourSelected, .blocklyColourSelected:hover {
|
|
606
|
+
border-color: #eee !important;
|
|
607
|
+
outline: 1px solid #333;
|
|
608
|
+
position: relative;
|
|
609
|
+
}
|
|
610
|
+
`);var ls=class extends ee{constructor(e,t,o,s,i,a,p){if(super(ee.SKIP_SETUP),this.imageElement_=this.clickHandler_=null,this.flipRtl_=this.isDirty_=this.EDITABLE=!1,this.altText_="",o=Number(Ee(o)),t=Number(Ee(t)),isNaN(o)||isNaN(t))throw Error("Height and width values of an image field must cast to numbers.");if(0>=o||0>=t)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new Pe(t,o+ls.Y_PADDING),this.imageHeight_=o,typeof i=="function"&&(this.clickHandler_=i),e!==ee.SKIP_SETUP&&(p?this.configure_(p):(this.flipRtl_=!!a,this.altText_=Ee(s)||""),this.setValue(Ee(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl_=e.flipRtl),e.alt&&(this.altText_=Ee(e.alt))}initView(){this.imageElement_=I(f.IMAGE,{height:this.imageHeight_+"px",width:this.size_.width+"px",alt:this.altText_},this.fieldGroup_),this.imageElement_.setAttributeNS(it,"xlink:href",this.value_),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(it,"xlink:href",this.value_)}getFlipRtl(){return this.flipRtl_}setAlt(e){e!==this.altText_&&(this.altText_=e||"",this.imageElement_&&this.imageElement_.setAttribute("alt",this.altText_))}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)}};ls.Y_PADDING=1,ut("field_image",ls),ls.prototype.DEFAULT_VALUE="";var kp=class extends Mo{constructor(e,t,o){super(String(e??""),t,o),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(Ee(e.text),void 0,e)}};ut("field_label_serializable",kp);var Js=class extends ii{constructor(e,t,o){super(e,t,o)}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(Ee(e.text),void 0,e)}};ut("field_input",Js),Js.prototype.DEFAULT_VALUE="";var au=class extends Js{constructor(e,t,o){super(ee.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,e!==ee.SKIP_SETUP&&(o&&this.configure_(o),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.maxLines&&this.setMaxLines(e.maxLines)}toXml(e){return e.textContent=this.getValue().replace(/\n/g," "),e}fromXml(e){this.setValue(e.textContent.replace(/ /g,`
|
|
611
|
+
`))}saveState(){const e=this.saveLegacyState(au);return e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(ee,e)||this.setValue(e)}initView(){this.createBorderRect_(),this.textGroup=I(f.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const e=this.getSourceBlock();if(!e)throw new Le;let t=this.getText();if(!t)return ee.NBSP;const o=t.split(`
|
|
612
|
+
`);t="";const s=this.isOverflowedY_?this.maxLines_:o.length;for(let i=0;i<s;i++){let a=o[i];a.length>this.maxDisplayLength?a=a.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&i===s-1&&(a=a.substring(0,a.length-3)+"..."),a=a.replace(/\s/g,ee.NBSP),t+=a,i!==s-1&&(t+=`
|
|
613
|
+
`)}return e.RTL&&(t+=""),t}doValueUpdate_(e){super.doValueUpdate_(e),this.value_!==null&&(this.isOverflowedY_=this.value_.split(`
|
|
614
|
+
`).length>this.maxLines_)}render_(){var e=this.getSourceBlock();if(!e)throw new Le;for(var t,o=this.textGroup;t=o.firstChild;)o.removeChild(t);t=this.getDisplayText_().split(`
|
|
615
|
+
`);let s=0;for(let i=0;i<t.length;i++){const a=this.getConstants().FIELD_TEXT_HEIGHT+this.getConstants().FIELD_BORDER_RECT_Y_PADDING;I(f.TEXT,{class:"blocklyText blocklyMultilineText",x:this.getConstants().FIELD_BORDER_RECT_X_PADDING,y:s+this.getConstants().FIELD_BORDER_RECT_Y_PADDING,dy:this.getConstants().FIELD_TEXT_BASELINE},o).appendChild(document.createTextNode(t[i])),s+=a}this.isBeingEdited_&&(o=this.htmlInput_,this.isOverflowedY_?U(o,"blocklyHtmlTextAreaInputOverflowedY"):se(o,"blocklyHtmlTextAreaInputOverflowedY")),this.updateSize_(),this.isBeingEdited_&&(e.RTL?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),e=this.htmlInput_,this.isTextValid_?(se(e,"blocklyInvalidInput"),ge(e,pe.INVALID,!1)):(U(e,"blocklyInvalidInput"),ge(e,pe.INVALID,!0)))}updateSize_(){var e=this.textGroup.childNodes;const t=this.getConstants().FIELD_TEXT_FONTSIZE,o=this.getConstants().FIELD_TEXT_FONTWEIGHT,s=this.getConstants().FIELD_TEXT_FONTFAMILY;let i=0,a=0;for(var p=0;p<e.length;p++){var $=h(e[p],t,o,s);$>i&&(i=$),a+=this.getConstants().FIELD_TEXT_HEIGHT+(0<p?this.getConstants().FIELD_BORDER_RECT_Y_PADDING:0)}if(this.isBeingEdited_){for(e=String(this.value_).split(`
|
|
616
|
+
`),p=I(f.TEXT,{class:"blocklyText blocklyMultilineText"}),$=0;$<e.length;$++){e[$].length>this.maxDisplayLength&&(e[$]=e[$].substring(0,this.maxDisplayLength)),p.textContent=e[$];const v=h(p,t,o,s);v>i&&(i=v)}i+=this.htmlInput_.offsetWidth-this.htmlInput_.clientWidth}this.borderRect_&&(a+=2*this.getConstants().FIELD_BORDER_RECT_Y_PADDING,i+=2*this.getConstants().FIELD_BORDER_RECT_X_PADDING,this.borderRect_.setAttribute("width",`${i}`),this.borderRect_.setAttribute("height",`${a}`)),this.size_.width=i,this.size_.height=a,this.positionBorderRect_()}showEditor_(e,t){super.showEditor_(e,t),this.forceRerender()}widgetCreate_(){const e=Yo(),t=this.workspace_.getScale(),o=document.createElement("textarea");o.className="blocklyHtmlInput blocklyHtmlTextAreaInput",o.setAttribute("spellcheck",String(this.spellcheck_));var s=this.getConstants().FIELD_TEXT_FONTSIZE*t+"pt";e.style.fontSize=s,o.style.fontSize=s,o.style.borderRadius=Js.BORDERRADIUS*t+"px",s=this.getConstants().FIELD_BORDER_RECT_X_PADDING*t;const i=this.getConstants().FIELD_BORDER_RECT_Y_PADDING*t/2;return o.style.padding=i+"px "+s+"px "+i+"px "+s+"px",s=this.getConstants().FIELD_TEXT_HEIGHT+this.getConstants().FIELD_BORDER_RECT_Y_PADDING,o.style.lineHeight=s*t+"px",e.appendChild(o),o.value=o.defaultValue=this.getEditorText_(this.value_),o.setAttribute("data-untyped-default-value",String(this.value_)),o.setAttribute("data-old-value",""),hc?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(o),o}setMaxLines(e){typeof e=="number"&&0<e&&e!==this.maxLines_&&(this.maxLines_=e,this.forceRerender())}getMaxLines(){return this.maxLines_}onHtmlInputKeyDown_(e){e.key!=="Enter"&&super.onHtmlInputKeyDown_(e)}static fromJson(e){return new this(Ee(e.text),void 0,e)}};ut("field_multilinetext",au),Tt(`
|
|
617
|
+
.blocklyHtmlTextAreaInput {
|
|
618
|
+
font-family: monospace;
|
|
619
|
+
resize: none;
|
|
620
|
+
overflow: hidden;
|
|
621
|
+
height: 100%;
|
|
622
|
+
text-align: left;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
.blocklyHtmlTextAreaInputOverflowedY {
|
|
626
|
+
overflow-y: scroll;
|
|
627
|
+
}
|
|
628
|
+
`);var cu=class extends ii{constructor(e,t,o,s,i,a){super(ee.SKIP_SETUP),this.min_=-1/0,this.max_=1/0,this.precision_=0,this.decimalPlaces_=null,this.spellcheck_=!1,e!==ee.SKIP_SETUP&&(a?this.configure_(a):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.indexOf("e")!==-1&&(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/ig,"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 e.type="number",-1/0<this.min_&&(e.min=`${this.min_}`,ge(e,pe.VALUEMIN,this.min_)),1/0>this.max_&&(e.max=`${this.max_}`,ge(e,pe.VALUEMAX,this.max_)),e}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};ut("field_number",cu),cu.prototype.DEFAULT_VALUE=0;var ni=class extends Jt{constructor(e,t,o,s,i){super(ee.SKIP_SETUP),this.defaultType_="",this.variableTypes=[],this.variable_=null,this.SERIALIZABLE=!0,this.menuGenerator_=ni.dropdownCreate,this.defaultVariableName=typeof e=="string"?e:"",this.size_=new Pe(0,0),e!==ee.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 Le;this.variable_||(e=ar(e.workspace,null,this.defaultVariableName,this.defaultType_),this.doValueUpdate_(e.getId()))}shouldAddBorderRect_(){const e=this.getSourceBlock();if(!e)throw new Le;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 Le;const o=e.getAttribute("id"),s=e.textContent,i=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=ar(t.workspace,o,s,i),i!==null&&i!==t.type)throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.type+", and does not match variable field that references it: "+Vt(e)+".");this.setValue(t.getId())}toXml(e){return this.initModel(),e.id=this.variable_.getId(),e.textContent=this.variable_.name,this.variable_.type&&e.setAttribute("variabletype",this.variable_.type),e}saveState(e){var t=this.saveLegacyState(ni);return t!==null||(this.initModel(),t={id:this.variable_.getId()},e&&(t.name=this.variable_.name,t.type=this.variable_.type)),t}loadState(e){const t=this.getSourceBlock();if(!t)throw new Le;this.loadLegacyState(ni,e)||(e=ar(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_.name:""}getVariable(){return this.variable_}getValidator(){return this.variable_?this.validator_:null}doClassValidation_(e){if(e===null)return null;var t=this.getSourceBlock();if(!t)throw new Le;return t=cr(t.workspace,e),t?(t=t.type,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 Le;this.variable_=cr(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_(){var e=this.variableTypes;if(e===null&&this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying())return this.sourceBlock_.workspace.getVariableTypes();if(e=e||[""],e.length===0)throw e=this.getText(),Error("'variableTypes' of field variable "+e+" was an empty list");return e}setTypes_(e=null,t=""){if(Array.isArray(e)){let 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 in the definition of a FieldVariable");this.defaultType_=t,this.variableTypes=e}refreshVariableName(){this.forceRerender()}onItemSelected_(e,t){if(e=t.getValue(),this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying()){if(e===Vc){Jn(this.sourceBlock_.workspace,this.variable_);return}if(e===Wc){this.sourceBlock_.workspace.deleteVariableById(this.variable_.getId());return}}this.setValue(e)}referencesVariables(){return!0}static fromJson(e){return new this(Ee(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=[];if(this.sourceBlock_&&!this.sourceBlock_.isDeadOrDying())for(var o=this.getVariableTypes_(),s=0;s<o.length;s++){const i=this.sourceBlock_.workspace.getVariablesOfType(o[s]);t=t.concat(i)}for(t.sort(Ur.compareByName),o=[],s=0;s<t.length;s++)o[s]=[t[s].name,t[s].getId()];return o.push([H.RENAME_VARIABLE,Vc]),H.DELETE_VARIABLE&&o.push([H.DELETE_VARIABLE.replace("%1",e),Wc]),o}};ut("field_variable",ni);var Dt=class{constructor(e,t,o,s){this.workspace=e,this.targetWorkspace=t,this.isLabel_=s,this.onMouseUpWrapper=null,this.height=this.width=0,this.svgText=this.svgGroup=null,this.text=o.text,this.position=new L(0,0),this.callbackKey=o.callbackKey||o.callbackkey,this.cssClass=o["web-class"]||null,this.info=o}createDom(){var e=this.isLabel_?"blocklyFlyoutLabel":"blocklyFlyoutButton";this.cssClass&&(e+=" "+this.cssClass),this.svgGroup=I(f.G,{class:e},this.workspace.getCanvas());let t;this.isLabel_||(t=I(f.RECT,{class:"blocklyFlyoutButtonShadow",rx:Dt.BORDER_RADIUS,ry:Dt.BORDER_RADIUS,x:1,y:1},this.svgGroup)),e=I(f.RECT,{class:this.isLabel_?"blocklyFlyoutLabelBackground":"blocklyFlyoutButtonBackground",rx:Dt.BORDER_RADIUS,ry:Dt.BORDER_RADIUS},this.svgGroup);const o=I(f.TEXT,{class:this.isLabel_?"blocklyFlyoutLabelText":"blocklyText",x:0,y:0,"text-anchor":"middle"},this.svgGroup);var s=Ee(this.text);this.workspace.RTL&&(s+=""),o.textContent=s,this.isLabel_&&(this.svgText=o,this.workspace.getThemeManager().subscribe(this.svgText,"flyoutForegroundColour","fill"));const i=Ht(o,"fontSize"),a=Ht(o,"fontWeight"),p=Ht(o,"fontFamily");if(this.width=T(o,i,a,p),s=m(s,i,a,p),this.height=s.height,!this.isLabel_){this.width+=2*Dt.TEXT_MARGIN_X,this.height+=2*Dt.TEXT_MARGIN_Y;let $;($=t)==null||$.setAttribute("width",String(this.width));let v;(v=t)==null||v.setAttribute("height",String(this.height))}return e.setAttribute("width",String(this.width)),e.setAttribute("height",String(this.height)),o.setAttribute("x",String(this.width/2)),o.setAttribute("y",String(this.height/2-s.height/2+s.baseline)),this.updateTransform(),this.onMouseUpWrapper=w(this.svgGroup,"pointerup",this,this.onMouseUp),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()}isLabel(){return this.isLabel_}getPosition(){return this.position}getButtonText(){return this.text}getTargetWorkspace(){return this.targetWorkspace}dispose(){this.onMouseUpWrapper&&ce(this.onMouseUpWrapper),this.svgGroup&&re(this.svgGroup),this.svgText&&this.workspace.getThemeManager().unsubscribe(this.svgText)}onMouseUp(e){(e=this.targetWorkspace.getGesture(e))&&e.cancel(),this.isLabel_&&this.callbackKey?console.warn("Labels should not have callbacks. Label text: "+this.text):this.isLabel_||this.callbackKey&&this.targetWorkspace.getButtonCallback(this.callbackKey)?this.isLabel_||(e=this.targetWorkspace.getButtonCallback(this.callbackKey))&&e(this):console.warn("Buttons should have callbacks. Button text: "+this.text)}};Dt.TEXT_MARGIN_X=5,Dt.TEXT_MARGIN_Y=2,Dt.BORDER_RADIUS=4,Tt(`
|
|
629
|
+
.blocklyFlyoutButton {
|
|
630
|
+
fill: #888;
|
|
631
|
+
cursor: default;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
.blocklyFlyoutButtonShadow {
|
|
635
|
+
fill: #666;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.blocklyFlyoutButton:hover {
|
|
639
|
+
fill: #aaa;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.blocklyFlyoutLabel {
|
|
643
|
+
cursor: default;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
.blocklyFlyoutLabelBackground {
|
|
647
|
+
opacity: 0;
|
|
648
|
+
}
|
|
649
|
+
`);var uu=class{constructor(e){this.workspace_=e}getDimensionsPx_(e){let t=0,o=0;return e&&(t=e.getWidth(),o=e.getHeight()),new Pe(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;const t=this.getToolboxMetrics(),o=this.getFlyoutMetrics(!0),s=!!this.workspace_.getToolbox(),i=!!this.workspace_.getFlyout(!0);var a=s?t.position:o.position,p=a===V.LEFT;return a=a===V.TOP,s&&p?e=t.width:i&&p&&(e=o.width),p=0,s&&a?p=t.height:i&&a&&(p=o.height),{top:p,left:e}}getViewMetrics(e){e=e?this.workspace_.scale:1;const t=this.getSvgMetrics(),o=this.getToolboxMetrics(),s=this.getFlyoutMetrics(!0),i=this.workspace_.getToolbox()?o.position:s.position;return this.workspace_.getToolbox()?i===V.TOP||i===V.BOTTOM?t.height-=o.height:(i===V.LEFT||i===V.RIGHT)&&(t.width-=o.width):this.workspace_.getFlyout(!0)&&(i===V.TOP||i===V.BOTTOM?t.height-=s.height:(i===V.LEFT||i===V.RIGHT)&&(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 a=i/2,p=e/2;return{top:Math.min(t.top-p,o-e),bottom:Math.max(o+p,t.top+e),left:Math.min(t.left-a,s-i),right:Math.max(s+a,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(),a=this.getContentMetrics(),p=this.getScrollMetrics(!1,i,a);return{contentHeight:a.height,contentWidth:a.width,contentTop:a.top,contentLeft:a.left,scrollHeight:p.height,scrollWidth:p.width,scrollTop:p.top,scrollLeft:p.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}}};r(A.METRICS_MANAGER,no,uu);var Dp=class extends uu{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}}},hu=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 a=t&&o;t&&(this.hScroll=new me(e,!0,a,s,i)),o&&(this.vScroll=new me(e,!1,a,s,i)),a&&(this.corner_=I(f.RECT,{height:me.scrollbarThickness,width:me.scrollbarThickness,class:"blocklyScrollbarBackground"}),Rt(this.corner_,e.getBubbleCanvas()))}dispose(){re(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{ve(),this.hScroll&&t&&this.hScroll.resize(e),this.vScroll&&o&&this.vScroll.resize(e)}finally{Ie()}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}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)}},Mp=class{constructor(e){this.workspace=e,this.horizontalScrollEnabled_=this.workspace.isMovableHorizontally(),this.verticalScrollEnabled_=this.workspace.isMovableVertically(),this.startScrollXY_=new L(e.scrollX,e.scrollY)}dispose(){this.workspace=null}startDrag(){_e()&&_e().unselect(),this.workspace.setupDragSurface()}endDrag(e){this.drag(e),this.workspace.resetDragSurface()}drag(e){if(e=L.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.")}},aT=5,cT=6,qt=class{constructor(e,t){this.creatorWorkspace=t,this.mouseDownXY_=new L(0,0),this.startWorkspace_=this.targetBlock_=this.startBlock_=this.startField_=this.startBubble_=null,this.hasExceededDragRadius_=!1,this.boundEvents=[],this.flyout_=this.workspaceDragger_=this.blockDragger_=this.bubbleDragger_=null,this.isMultiTouch_=this.isEnding_=this.hasStarted_=this.calledUpdateIsDragging_=!1,this.cachedPoints=new Map,this.startDistance_=this.previousScale_=0,this.currentDropdownOwner=this.isPinchZoomEnabled_=null,this.mostRecentEvent_=e,this.currentDragDeltaXY_=new L(0,0),this.healStack_=!Sp}dispose(){Ut(),xl(),this.creatorWorkspace.clearGesture();for(const e of this.boundEvents)ce(e);this.boundEvents.length=0,this.blockDragger_&&this.blockDragger_.dispose(),this.workspaceDragger_&&this.workspaceDragger_.dispose()}updateFromEvent_(e){const t=new L(e.clientX,e.clientY);this.updateDragDelta_(t)&&(this.updateIsDragging_(),Ft()),this.mostRecentEvent_=e}updateDragDelta_(e){return this.currentDragDeltaXY_=L.difference(e,this.mouseDownXY_),this.hasExceededDragRadius_?!1:this.hasExceededDragRadius_=L.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 ' +
|
|
650
|
+
'flyout's target workspace is undefined`);return!this.flyout_.isScrollable()||this.flyout_.isDragTowardWorkspace(this.currentDragDeltaXY_)?(this.startWorkspace_=this.flyout_.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),K()||C(!0),this.startBlock_=null,this.targetBlock_=this.flyout_.createBlock(this.targetBlock_),this.targetBlock_.select(),!0):!1}updateIsDraggingBubble_(){return this.startBubble_?(this.startDraggingBubble_(),!0):!1}updateIsDraggingBlock_(){if(!this.targetBlock_)return!1;if(this.flyout_){if(this.updateIsDraggingFromFlyout_())return this.startDraggingBlock_(),!0}else if(this.targetBlock_.isMovable())return this.startDraggingBlock_(),!0;return!1}updateIsDraggingWorkspace_(){if(!this.startWorkspace_)throw Error("Cannot update dragging the workspace because the start workspace is undefined");(this.flyout_?this.flyout_.isScrollable():this.startWorkspace_&&this.startWorkspace_.isDraggable())&&(this.workspaceDragger_=new Mp(this.startWorkspace_),this.workspaceDragger_.startDrag())}updateIsDragging_(){if(this.calledUpdateIsDragging_)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging_=!0,this.updateIsDraggingBubble_()||this.updateIsDraggingBlock_()||this.updateIsDraggingWorkspace_()}startDraggingBlock_(){this.blockDragger_=new(b(A.BLOCK_DRAGGER,this.creatorWorkspace.options,!0))(this.targetBlock_,this.startWorkspace_),this.blockDragger_.startDrag(this.currentDragDeltaXY_,this.healStack_),this.blockDragger_.drag(this.mostRecentEvent_,this.currentDragDeltaXY_)}startDraggingBubble_(){if(!this.startBubble_)throw Error("Cannot update dragging the bubble because the start bubble is undefined");if(!this.startWorkspace_)throw Error("Cannot update dragging the bubble because the start workspace is undefined");this.bubbleDragger_=new yp(this.startBubble_,this.startWorkspace_),this.bubbleDragger_.startBubbleDrag(),this.bubbleDragger_.dragBubble(this.mostRecentEvent_,this.currentDragDeltaXY_)}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,hr(e)?this.cancel():(this.hasStarted_=!0,Os(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=ml(),this.startWorkspace_.hideChaff(!!this.flyout_),this.startWorkspace_.markFocused(),this.mostRecentEvent_=e,Bl(),this.targetBlock_&&this.targetBlock_.select(),ro(e)?this.handleRightClick(e):(e.type.toLowerCase()==="pointerdown"&&e.pointerType!=="mouse"&&Qn(e,this),this.mouseDownXY_=new L(e.clientX,e.clientY),this.healStack_=e.altKey||e.ctrlKey||e.metaKey,this.bindMouseEvents(e),this.isEnding_||this.handleTouchStart(e)))}bindMouseEvents(e){this.boundEvents.push(w(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(w(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(w(document,"pointerup",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&Ft())}handleMove(e){this.isDragging()&&ur(e)||!this.isMultiTouch()?(this.updateFromEvent_(e),this.workspaceDragger_?this.workspaceDragger_.drag(this.currentDragDeltaXY_):this.blockDragger_?this.blockDragger_.drag(this.mostRecentEvent_,this.currentDragDeltaXY_):this.bubbleDragger_&&this.bubbleDragger_.dragBubble(this.mostRecentEvent_,this.currentDragDeltaXY_),e.preventDefault(),e.stopPropagation()):this.isMultiTouch()&&(this.handleTouchMove(e),Ft())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!ur(e))return;if(this.updateFromEvent_(e),Ft(),this.isEnding_){console.log("Trying to end a gesture recursively.");return}this.isEnding_=!0,this.bubbleDragger_?this.bubbleDragger_.endBubbleDrag(e,this.currentDragDeltaXY_):this.blockDragger_?this.blockDragger_.endDrag(e,this.currentDragDeltaXY_):this.workspaceDragger_?this.workspaceDragger_.endDrag(this.currentDragDeltaXY_):this.isBubbleClick_()?this.doBubbleClick_():this.isFieldClick_()?this.doFieldClick_():this.isBlockClick_()?this.doBlockClick_():this.isWorkspaceClick_()&&this.doWorkspaceClick_(e)}e.preventDefault(),e.stopPropagation(),this.dispose()}handleTouchStart(e){var t=$s(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_=L.distance(t,o),this.isMultiTouch_=!0,e.preventDefault())}handleTouchMove(e){const t=$s(e);this.cachedPoints.set(t,this.getTouchPoint(e)),this.isPinchZoomEnabled_&&this.cachedPoints.size===2?this.handlePinch_(e):this.handleMove(e)}handlePinch_(e){var t=Array.from(this.cachedPoints.keys()),o=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),o=L.distance(o,t)/this.startDistance_,0<this.previousScale_&&1/0>this.previousScale_){if(t=o-this.previousScale_,t=0<t?t*aT:t*cT,!this.startWorkspace_)throw Error("Cannot handle a pinch because the start workspace is undefined");const s=this.startWorkspace_,i=Vo(e,s.getParentSvg(),s.getInverseScreenCTM());s.zoom(i.x,i.y,t)}this.previousScale_=o,e.preventDefault()}handleTouchEnd(e){e=$s(e),this.cachedPoints.has(e)&&this.cachedPoints.delete(e),2>this.cachedPoints.size&&(this.cachedPoints.clear(),this.previousScale_=0)}getTouchPoint(e){return this.startWorkspace_?new L(e.pageX,e.pageY):null}isMultiTouch(){return this.isMultiTouch_}cancel(){this.isEnding_||(Ft(),this.bubbleDragger_?this.bubbleDragger_.endBubbleDrag(this.mostRecentEvent_,this.currentDragDeltaXY_):this.blockDragger_?this.blockDragger_.endDrag(this.mostRecentEvent_,this.currentDragDeltaXY_):this.workspaceDragger_&&this.workspaceDragger_.endDrag(this.currentDragDeltaXY_),this.dispose())}handleRightClick(e){this.targetBlock_?(this.bringBlockToFront_(),this.targetBlock_.workspace.hideChaff(!!this.flyout_),this.targetBlock_.showContextMenu(e)):this.startBubble_?this.startBubble_.showContextMenu(e):this.startWorkspace_&&!this.flyout_&&(this.startWorkspace_.hideChaff(),this.startWorkspace_.showContextMenu(e)),e.preventDefault(),e.stopPropagation(),this.dispose()}handleWsStart(e,t){if(this.hasStarted_)throw Error("Tried to call gesture.handleWsStart, but the gesture had already been started.");this.setStartWorkspace_(t),this.mostRecentEvent_=e,this.doStart(e)}fireWorkspaceClick_(e){x(new(F(Ao))(null,e.id,"workspace"))}handleFlyoutStart(e,t){if(this.hasStarted_)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.hasStarted_)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.hasStarted_)throw Error("Tried to call gesture.handleBubbleStart, but the gesture had already been started.");this.setStartBubble(t),this.mostRecentEvent_=e}doBubbleClick_(){this.startBubble_ instanceof Xe&&(this.startBubble_.setFocus(),this.startBubble_.select())}doFieldClick_(){if(!this.startField_)throw Error("Cannot do a field click because the start field is undefined");this.currentDropdownOwner!==this.startField_&&this.startField_.showEditor(this.mostRecentEvent_),this.bringBlockToFront_()}doBlockClick_(){if(this.flyout_&&this.flyout_.autoClose){if(!this.targetBlock_)throw Error("Cannot do a block click because the target block is undefined");this.targetBlock_.isEnabled()&&(K()||C(!0),this.flyout_.createBlock(this.targetBlock_).scheduleSnapAndBump())}else{if(!this.startWorkspace_)throw Error("Cannot do a block click because the start workspace is undefined");const e=new(F(Ao))(this.startBlock_,this.startWorkspace_.id,"block");x(e)}this.bringBlockToFront_(),C(!1)}doWorkspaceClick_(e){e=this.creatorWorkspace,_e()&&_e().unselect(),this.fireWorkspaceClick_(this.startWorkspace_||e)}bringBlockToFront_(){this.targetBlock_&&!this.flyout_&&this.targetBlock_.bringToFront()}setStartField(e){if(this.hasStarted_)throw Error("Tried to call gesture.setStartField, but the gesture had already been started.");this.startField_||(this.startField_=e)}setStartBubble(e){this.startBubble_||(this.startBubble_=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}setStartWorkspace_(e){this.startWorkspace_||(this.startWorkspace_=e)}setStartFlyout_(e){this.flyout_||(this.flyout_=e)}isBubbleClick_(){return!!this.startBubble_&&!this.hasExceededDragRadius_}isBlockClick_(){return!!this.startBlock_&&!this.hasExceededDragRadius_&&!this.isFieldClick_()}isFieldClick_(){return(this.startField_?this.startField_.isClickable():!1)&&!this.hasExceededDragRadius_&&(!this.flyout_||!this.flyout_.autoClose)}isWorkspaceClick_(){return!this.startBlock_&&!this.startBubble_&&!this.startField_&&!this.hasExceededDragRadius_}isDragging(){return!!this.workspaceDragger_||!!this.blockDragger_||!!this.bubbleDragger_}hasStarted(){return this.hasStarted_}getInsertionMarkers(){return this.blockDragger_?this.blockDragger_.getInsertionMarkers():[]}getCurrentDragger(){let e,t;return(t=(e=this.blockDragger_)!=null?e:this.workspaceDragger_)!=null?t:this.bubbleDragger_}static inProgress(){const e=G();for(let t=0,o;o=e[t];t++)if(o.currentGesture_)return!0;return!1}},du=class{constructor(e,t){this.pattern=e;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}shouldSnap(){return this.snapToGrid}getSpacing(){return this.spacing}getPatternId(){return this.pattern.id}update(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,a){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${o}`),e.setAttribute("y1",`${i}`),e.setAttribute("x2",`${s}`),e.setAttribute("y2",`${a}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}static createDom(e,t,o){e=I(f.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},o);let s,i;if(0<((s=t.length)!=null?s:1)&&0<((i=t.spacing)!=null?i:0)){I(f.LINE,{stroke:t.colour},e);let a;(a=t.length)!=null&&a&&I(f.LINE,{stroke:t.colour},e)}else I(f.LINE,{},e);return e}},Ze=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.name: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:
|
|
651
|
+
Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(e){e=vi(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 a;return e+=(a=o)!=null?a:"",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".indexOf(e[0])!==-1&&(e="my_"+e)):e=H.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"})(Ze||(Ze={})),n.NameType$$module$build$src$core$names=Ze.NameType,Ze.DEVELOPER_VARIABLE_TYPE=n.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE,n.module$build$src$core$names={},n.module$build$src$core$names.NameType=n.NameType$$module$build$src$core$names,n.module$build$src$core$names.Names=Ze;var wp=class extends Map{constructor(){super()}set(e,t){return this.get(e)===t?this:(super.set(e,t),rn(t)&&t.startPublishing(),this)}delete(e){const t=this.get(e);return e=super.delete(e),e&&(rn(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()]}},Fn,_u;Fn="PROCEDURE",_u="x",n.module$build$src$core$procedures={},n.module$build$src$core$procedures.CATEGORY_NAME=Fn,n.module$build$src$core$procedures.DEFAULT_ARG=_u,n.module$build$src$core$procedures.ObservableProcedureMap=wp,n.module$build$src$core$procedures.allProcedures=nn,n.module$build$src$core$procedures.findLegalName=ya,n.module$build$src$core$procedures.flyoutCategory=ln,n.module$build$src$core$procedures.getCallers=Da,n.module$build$src$core$procedures.getDefinition=jd,n.module$build$src$core$procedures.isNameUsed=Aa,n.module$build$src$core$procedures.isProcedureBlock=Co,n.module$build$src$core$procedures.mutateCallers=Xd,n.module$build$src$core$procedures.mutatorOpenListener=ka,n.module$build$src$core$procedures.rename=Hd;var uT=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}isHat(e){return e.type&this.HAT}isIcon(e){return e.type&this.ICON}isSpacer(e){return e.type&this.SPACER}isInRowSpacer(e){return e.type&this.IN_ROW_SPACER}isInput(e){return e.type&this.INPUT}isExternalInput(e){return e.type&this.EXTERNAL_VALUE_INPUT}isInlineInput(e){return e.type&this.INLINE_INPUT}isStatementInput(e){return e.type&this.STATEMENT_INPUT}isPreviousConnection(e){return e.type&this.PREVIOUS_CONNECTION}isNextConnection(e){return e.type&this.NEXT_CONNECTION}isPreviousOrNextConnection(e){return e.type&(this.PREVIOUS_CONNECTION|this.NEXT_CONNECTION)}isLeftRoundedCorner(e){return e.type&this.LEFT_ROUND_CORNER}isRightRoundedCorner(e){return e.type&this.RIGHT_ROUND_CORNER}isLeftSquareCorner(e){return e.type&this.LEFT_SQUARE_CORNER}isRightSquareCorner(e){return e.type&this.RIGHT_SQUARE_CORNER}isCorner(e){return e.type&this.CORNER}isJaggedEdge(e){return e.type&this.JAGGED_EDGE}isRow(e){return e.type&this.ROW}isBetweenRowSpacer(e){return e.type&this.BETWEEN_ROW_SPACER}isTopRow(e){return e.type&this.TOP_ROW}isBottomRow(e){return e.type&this.BOTTOM_ROW}isTopOrBottomRow(e){return e.type&(this.TOP_ROW|this.BOTTOM_ROW)}isInputRow(e){return e.type&this.INPUT_ROW}},E=new uT,Zt=class{constructor(e){this.centerline=this.xPos=this.height=this.width=0,this.constants_=e,this.type=E.NONE,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}},li=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=E.ROW,this.notchOffset=this.constants_.NOTCH_OFFSET_LEFT}getLastInput(){for(let e=this.elements.length-1;0<=e;e--){const t=this.elements[e];if(E.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(E.isSpacer(t))return t}return null}getLastSpacer(){for(let e=this.elements.length-1;0<=e;e--){const t=this.elements[e];if(E.isSpacer(t))return t}return null}},pu=class extends li{constructor(e){super(e),this.hasNextConnection=!1,this.connection=null,this.baseline=this.descenderHeight=0,this.type|=E.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,E.isSpacer(i)||(E.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}},as=class extends Zt{constructor(e,t){super(e),this.connectionModel=t,this.shape=this.constants_.shapeFor(t),this.isDynamicShape="isDynamic"in this.shape&&this.shape.isDynamic,this.type|=E.CONNECTION}},go=class extends as{constructor(e,t){super(e,t.connection),this.input=t,this.connectionOffsetY=this.connectionOffsetX=0,this.type|=E.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}},Un=class extends go{constructor(e,t){super(e,t),this.height=0,this.type|=E.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}},cs=class extends Zt{constructor(e,t,o){super(e),this.field=t,this.parentInput=o,this.isEditable=t.EDITABLE,this.flipRtl=t.getFlipRtl(),this.type|=E.FIELD,e=this.field.getSize(),this.height=e.height,this.width=e.width}},gu=class extends Zt{constructor(e){super(e),this.type|=E.HAT,this.height=this.constants_.START_HAT.height,this.width=this.constants_.START_HAT.width,this.ascenderHeight=this.height}},Gp=class extends Zt{constructor(e,t){super(e),this.icon=t,this.flipRtl=!1,this.isVisible=t.isVisible(),this.type|=E.ICON,e=t.getCorrectedSize(),this.height=e.height,this.width=e.width}},pt=class extends Zt{constructor(e,t){super(e),this.type=this.type|E.SPACER|E.IN_ROW_SPACER,this.width=t,this.height=this.constants_.SPACER_DEFAULT_HEIGHT}},Tu=class extends go{constructor(e,t){super(e,t),this.type|=E.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}},ai=class extends go{constructor(e,t){super(e,t),this.type|=E.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}},$u=class extends li{constructor(e){super(e),this.connectedBlockWidths=0,this.type|=E.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,E.isInput(o)&&o instanceof go&&(E.isStatementInput(o)&&o instanceof ai?e+=o.connectedBlockWidth:E.isExternalInput(o)&&o instanceof Un&&o.connectedBlockWidth!==0&&(e+=o.connectedBlockWidth-o.connectionWidth)),E.isSpacer(o)||(this.height=Math.max(this.height,o.height))}this.connectedBlockWidths=e,this.widthWithConnectedBlocks=this.width+e}endsWithElemSpacer(){return!this.hasExternalInput&&!this.hasStatement}},Pp=class extends Zt{constructor(e){super(e),this.type|=E.JAGGED_EDGE,this.height=this.constants_.JAGGED_TEETH.height,this.width=this.constants_.JAGGED_TEETH.width}},Bp=class extends as{constructor(e,t){super(e,t),this.type|=E.NEXT_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},xp=class extends as{constructor(e,t){super(e,t),this.connectionOffsetX=0,this.type|=E.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}},Fp=class extends as{constructor(e,t){super(e,t),this.type|=E.PREVIOUS_CONNECTION,this.height=this.shape.height,this.width=this.shape.width}},ci=class extends Zt{constructor(e,t){super(e),this.type=(t&&t!=="left"?E.RIGHT_ROUND_CORNER:E.LEFT_ROUND_CORNER)|E.CORNER,this.width=this.constants_.CORNER_RADIUS,this.height=this.constants_.CORNER_RADIUS/2}},Eu=class extends li{constructor(e,t,o){super(e),this.height=t,this.width=o,this.precedesStatement=this.followsStatement=!1,this.widthWithConnectedBlocks=0,this.type=this.type|E.SPACER|E.BETWEEN_ROW_SPACER,this.elements=[new pt(this.constants_,o)]}measure(){}},ui=class extends Zt{constructor(e,t){super(e),this.type=(t&&t!=="left"?E.RIGHT_SQUARE_CORNER:E.LEFT_SQUARE_CORNER)|E.CORNER,this.width=this.height=this.constants_.NO_PADDING}},mu=class extends li{constructor(e){super(e),this.ascenderHeight=this.capline=0,this.hasPreviousConnection=!1,this.connection=null,this.type|=E.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,E.isSpacer(i)||(E.isHat(i)&&i instanceof gu?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}},hi=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=Te(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=m("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.indexOf("auto_")===0?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=jo(t.colourPrimary||"#000"),t.colourPrimary=e.hex,t.colourSecondary=t.colourSecondary?jo(t.colourSecondary).hex:this.generateSecondaryColour_(t.colourPrimary),t.colourTertiary=t.colourTertiary?jo(t.colourTertiary).hex:this.generateTertiaryColour_(t.colourPrimary),t.hat=t.hat||"",t}generateSecondaryColour_(e){return Xo("#fff",e,.6)||e}generateTertiaryColour_(e){return Xo("#fff",e,.3)||e}dispose(){this.embossFilter_&&re(this.embossFilter_),this.disabledPattern_&&re(this.disabledPattern_),this.debugFilter_&&re(this.debugFilter_),this.cssNode_=null}makeJaggedTeeth(){const e=this.JAGGED_TEETH_HEIGHT,t=this.JAGGED_TEETH_WIDTH,o=vs([P(t,e/4),P(2*-t,e/2),P(t,e/4)]);return{height:e,width:t,path:o}}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=ot("c",[P(30,-e),P(70,-e),P(t,0)]);return{height:e,width:t,path:o}}makePuzzleTab(){function e(a){a=a?-1:1;const p=-a;var $=o/2;const v=$+2.5,k=$+.5,fe=P(-t,a*$);return $=P(t,a*$),ot("c",[P(0,a*v),P(-t,p*k),fe])+ot("s",[P(t,2.5*p),$])}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(p){return vs([P(p*s,o),P(3*p,0),P(p*s,-o)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=(t-3)/2,i=e(1),a=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:i,pathRight:a}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=Ne("a","0 0,0",e,P(-e,e)),o=Ne("a","0 0,0",e,P(e,e));return{width:e,height:e,pathTop:t,pathBottom:o}}makeOutsideCorners(){const e=this.CORNER_RADIUS,t=Te(0,e)+Ne("a","0 0,1",e,P(e,-e)),o=Ne("a","0 0,1",e,P(e,e)),s=Ne("a","0 0,1",e,P(-e,-e)),i=Ne("a","0 0,1",e,P(-e,e));return{topLeft:t,topRight:o,bottomRight:i,bottomLeft:s,rightHeight:e}}shapeFor(e){switch(e.type){case M.INPUT_VALUE:case M.OUTPUT_VALUE:return this.PUZZLE_TAB;case M.PREVIOUS_STATEMENT:case M.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown connection type")}}createDom(e,t,o){this.injectCSS_(t,o),this.defs_=I(f.DEFS,{},e),e=I(f.FILTER,{id:"blocklyEmbossFilter"+this.randomIdentifier},this.defs_),I(f.FEGAUSSIANBLUR,{in:"SourceAlpha",stdDeviation:1,result:"blur"},e),t=I(f.FESPECULARLIGHTING,{in:"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},e),I(f.FEPOINTLIGHT,{x:-5e3,y:-1e4,z:2e4},t),I(f.FECOMPOSITE,{in:"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},e),I(f.FECOMPOSITE,{in:"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},e),this.embossFilterId=e.id,this.embossFilter_=e,e=I(f.PATTERN,{id:"blocklyDisabledPattern"+this.randomIdentifier,patternUnits:"userSpaceOnUse",width:10,height:10},this.defs_),I(f.RECT,{width:10,height:10,fill:"#aaa"},e),I(f.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()}createDebugFilter(){if(!this.debugFilter_){const e=I(f.FILTER,{id:"blocklyDebugFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},this.defs_),t=I(f.FECOMPONENTTRANSFER,{result:"outBlur"},e);I(f.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),I(f.FEFLOOD,{"flood-color":"#ff0000","flood-opacity":.5,result:"outColor"},e),I(f.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(`
|
|
652
|
+
`);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} .blocklyNonEditableText>rect,`,`${e} .blocklyEditableText>rect {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"fill-opacity: .6;","stroke: none;","}",`${e} .blocklyNonEditableText>text,`,`${e} .blocklyEditableText>text {`,"fill: #000;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #000;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #000;","}",`${e} .blocklyEditableText:not(.editing):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;","}"]}},Up=!1,gt=class{constructor(e){this.constants=e,this.debugElements_=[],this.svgRoot_=null,this.randomColour_=""}clearElems(){for(let e=0;e<this.debugElements_.length;e++)re(this.debugElements_[e]);this.debugElements_=[]}drawSpacerRow(e,t,o){if(gt.config.rowSpacers){var s=Math.abs(e.height),i=0>e.height;i&&(t-=s),this.debugElements_.push(I(f.RECT,{class:"rowSpacerRect blockRenderDebug",x:o?-(e.xPos+e.width):e.xPos,y:t,width:e.width,height:s,stroke:i?"black":"blue",fill:"blue","fill-opacity":"0.5","stroke-width":"1px"},this.svgRoot_))}}drawSpacerElem(e,t,o){if(gt.config.elemSpacers){t=Math.abs(e.width);var s=0>e.width,i=s?e.xPos-t:e.xPos;o&&(i=-(i+t)),this.debugElements_.push(I(f.RECT,{class:"elemSpacerRect blockRenderDebug",x:i,y:e.centerline-e.height/2,width:t,height:e.height,stroke:"pink",fill:s?"black":"pink","fill-opacity":"0.5","stroke-width":"1px"},this.svgRoot_))}}drawRenderedElem(e,t){if(gt.config.elems){let o=e.xPos;t&&(o=-(o+e.width)),t=e.centerline-e.height/2,this.debugElements_.push(I(f.RECT,{class:"rowRenderingRect blockRenderDebug",x:o,y:t,width:e.width,height:e.height,stroke:"black",fill:"none","stroke-width":"1px"},this.svgRoot_)),E.isField(e)&&e instanceof cs&&e.field instanceof Mo&&this.debugElements_.push(I(f.RECT,{class:"rowRenderingRect blockRenderDebug",x:o,y:t+this.constants.FIELD_TEXT_BASELINE,width:e.width,height:"0.1px",stroke:"red",fill:"none","stroke-width":"0.5px"},this.svgRoot_))}E.isInput(e)&&e instanceof go&>.config.connections&&this.drawConnection(e.connectionModel)}drawConnection(e){if(gt.config.connections){var t="",o=0,s="";e.type===M.INPUT_VALUE?(o=4,t="magenta",s="none"):e.type===M.OUTPUT_VALUE?(o=2,s=t="magenta"):e.type===M.NEXT_STATEMENT?(o=4,t="goldenrod",s="none"):e.type===M.PREVIOUS_STATEMENT&&(o=2,s=t="goldenrod"),this.debugElements_.push(I(f.CIRCLE,{class:"blockRenderDebug",cx:e.getOffsetInBlock().x,cy:e.getOffsetInBlock().y,r:o,fill:s,stroke:t},this.svgRoot_))}}drawRenderedRow(e,t,o){gt.config.rows&&(this.debugElements_.push(I(f.RECT,{class:"elemRenderingRect blockRenderDebug",x:o?-(e.xPos+e.width):e.xPos,y:e.yPos,width:e.width,height:e.height,stroke:"red",fill:"none","stroke-width":"1px"},this.svgRoot_)),E.isTopOrBottomRow(e)||gt.config.connectedBlockBounds&&this.debugElements_.push(I(f.RECT,{class:"connectedBlockWidth blockRenderDebug",x:o?-(e.xPos+e.widthWithConnectedBlocks):e.xPos,y:e.yPos,width:e.widthWithConnectedBlocks,height:e.height,stroke:this.randomColour_,fill:"none","stroke-width":"1px","stroke-dasharray":"3,3"},this.svgRoot_)))}drawRowWithElements(e,t,o){for(let s=0;s<e.elements.length;s++){const i=e.elements[s];i?E.isSpacer(i)?this.drawSpacerElem(i,e.height,o):this.drawRenderedElem(i,o):console.warn("A row has an undefined or null element.",e,i)}this.drawRenderedRow(e,t,o)}drawBoundingBox(e){if(gt.config.blockBounds){var t=e.RTL?-e.width:0;this.debugElements_.push(I(f.RECT,{class:"blockBoundingBox blockRenderDebug",x:t,y:0,width:e.width,height:e.height,stroke:"black",fill:"none","stroke-width":"1px","stroke-dasharray":"5,5"},this.svgRoot_)),gt.config.connectedBlockBounds&&(t=e.RTL?-e.widthWithChildren:0,this.debugElements_.push(I(f.RECT,{class:"blockRenderDebug",x:t,y:0,width:e.widthWithChildren,height:e.height,stroke:"#DF57BC",fill:"none","stroke-width":"1px","stroke-dasharray":"3,3"},this.svgRoot_)))}}drawDebug(e,t){this.clearElems(),this.svgRoot_=e.getSvgRoot(),this.randomColour_="#"+Math.floor(16777215*Math.random()).toString(16);let o=0;for(let s=0;s<t.rows.length;s++){const i=t.rows[s];E.isBetweenRowSpacer(i)?this.drawSpacerRow(i,o,t.RTL):this.drawRowWithElements(i,o,t.RTL),o+=i.height}e.previousConnection&&this.drawConnection(e.previousConnection),e.nextConnection&&this.drawConnection(e.nextConnection),e.outputConnection&&this.drawConnection(e.outputConnection),t.rightSide&&this.drawRenderedElem(t.rightSide,t.RTL),this.drawBoundingBox(t),this.drawRender(e.pathObject.svgPath)}drawRender(e){gt.config.render&&(e.setAttribute("filter","url(#"+this.constants.debugFilterId+")"),setTimeout(function(){e.setAttribute("filter","")},100))}};gt.config={rowSpacers:!0,elemSpacers:!0,rows:!0,elems:!0,connections:!0,blockBounds:!0,connectedBlockBounds:!0,render:!0};var di=class{constructor(e,t){this.inlinePath_=this.outlinePath_="",this.block_=e,this.info_=t,this.topLeft_=e.getRelativeToSurfaceXY(),this.constants_=t.getRenderer().getConstants()}draw(){if(this.hideHiddenIcons_(),this.drawOutline_(),this.drawInternals_(),this.block_.pathObject.setPath(this.outlinePath_+`
|
|
653
|
+
`+this.inlinePath_),this.info_.RTL&&this.block_.pathObject.flipRTL(),Lr()){let e;(e=this.block_.renderingDebugger)==null||e.drawDebug(this.block_,this.info_)}this.recordSizeOnBlock_()}recordSizeOnBlock_(){this.block_.height=this.info_.height,this.block_.width=this.info_.widthWithChildren}hideHiddenIcons_(){for(let e=0,t;t=this.info_.hiddenIcons[e];e++){let o;(o=t.icon.iconGroup_)==null||o.setAttribute("display","none")}}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_+=Te(e.xPos,this.info_.startY);for(let o=0,s;s=t[o];o++)E.isLeftRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topLeft:E.isRightRoundedCorner(s)?this.outlinePath_+=this.constants_.OUTSIDE_CORNERS.topRight:E.isPreviousConnection(s)&&s instanceof as?this.outlinePath_+=s.shape.pathLeft:E.isHat(s)?this.outlinePath_+=this.constants_.START_HAT.path:E.isSpacer(s)&&(this.outlinePath_+=D("h",s.width));this.outlinePath_+=D("v",e.height)}drawJaggedEdge_(e){this.outlinePath_+=this.constants_.JAGGED_TEETH.path+D("v",e.height-this.constants_.JAGGED_TEETH.height)}drawValueInput_(e){const t=e.getLastInput();this.positionExternalValueConnection_(e);const o=Ma(t.shape)?t.shape.pathDown(t.height):t.shape.pathDown;this.outlinePath_+=D("H",t.xPos+t.width)+o+D("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+D("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_+=D("H",o)+t+D("v",s)+this.constants_.INSIDE_CORNERS.pathBottom+D("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}}drawRightSideRow_(e){this.outlinePath_+=D("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,a;a=t[i];i--)E.isNextConnection(a)&&a instanceof as?s+=a.shape.pathRight:E.isLeftSquareCorner(a)?s+=D("H",e.xPos):E.isLeftRoundedCorner(a)?s+=this.constants_.OUTSIDE_CORNERS.bottomLeft:E.isRightRoundedCorner(a)?(s+=this.constants_.OUTSIDE_CORNERS.bottomRight,o=this.constants_.OUTSIDE_CORNERS.rightHeight):E.isSpacer(a)&&(s+=D("h",-1*a.width));this.outlinePath_+=D("V",e.baseline-o),this.outlinePath_+=s}drawLeft_(){var e=this.info_.outputConnection;if(this.positionOutputConnection_(),e){const t=e.connectionOffsetY+e.height;e=Ma(e.shape)?e.shape.pathUp(e.height):e.shape.pathUp,this.outlinePath_+=D("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++)E.isInlineInput(s)?this.drawInlineInput_(s):(E.isIcon(s)||E.isField(s))&&this.layoutField_(s)}layoutField_(e){const t=E.isField(e)?e.field.getSvgRoot():e.icon.iconGroup_,o=e.centerline-e.height/2;let s=e.xPos,i="";this.info_.RTL&&(s=-(s+e.width),e.flipRtl&&(s+=e.width,i="scale(-1 1)")),E.isIcon(e)?(t.setAttribute("display","block"),t.setAttribute("transform","translate("+s+","+o+")"),e.icon.computeIconLocation()):t.setAttribute("transform","translate("+s+","+o+")"+i),this.info_.isInsertionMarker&&t.setAttribute("display","none")}drawInlineInput_(e){const t=e.width,o=e.height,s=e.connectionOffsetY,i=e.connectionHeight+s;this.inlinePath_+=Ue(e.xPos+e.connectionWidth,e.centerline-o/2)+D("v",s)+e.shape.pathDown+D("v",o-i)+D("h",t-e.connectionWidth)+D("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)}}},qs=class{constructor(e,t){this.statementEdge=this.width=this.widthWithChildren=this.height=0,this.rows=[],this.inputRows=[],this.hiddenIcons=[],this.startY=this.startX=0,this.renderer_=e,this.block_=t,this.constants_=this.renderer_.getConstants(),this.outputConnection=t.outputConnection?new xp(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 mu(this.constants_),this.bottomRow=new pu(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 $u(this.constants_);this.inputRows.push(e);var t=this.block_.getIcons();for(let o=0,s;s=t[o];o++){const i=new Gp(this.constants_,s);this.isCollapsed&&s.collapseHidden?this.hiddenIcons.push(i):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 $u(this.constants_),this.inputRows.push(e));for(let i=0,a;a=s.fieldRow[i];i++)e.elements.push(new cs(this.constants_,a,s));this.addInput_(s,e),t=s}this.isCollapsed&&(e.hasJaggedEdge=!0,e.elements.push(new Pp(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_)?ui:ci;this.topRow.elements.push(new o(this.constants_)),t?(e=new gu(this.constants_),this.topRow.elements.push(e),this.topRow.capline=e.ascenderHeight):e&&(this.topRow.hasPreviousConnection=!0,this.topRow.connection=new Fp(this.constants_,this.block_.previousConnection),this.topRow.elements.push(this.topRow.connection)),this.block_.inputList.length&&this.block_.inputList[0].type===X.STATEMENT&&!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_)?ui:ci,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].type===X.STATEMENT?this.constants_.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT:this.constants_.BOTTOM_ROW_MIN_HEIGHT,this.bottomRow.hasLeftSquareCorner(this.block_)?this.bottomRow.elements.push(new ui(this.constants_)):this.bottomRow.elements.push(new ci(this.constants_)),this.bottomRow.hasNextConnection&&(this.bottomRow.connection=new Bp(this.constants_,this.block_.nextConnection),this.bottomRow.elements.push(this.bottomRow.connection)),this.bottomRow.hasRightSquareCorner(this.block_)?this.bottomRow.elements.push(new ui(this.constants_,"right")):this.bottomRow.elements.push(new ci(this.constants_,"right"))}addInput_(e,t){this.isInline&&e.type===X.VALUE?(t.elements.push(new Tu(this.constants_,e)),t.hasInlineInput=!0):e.type===X.STATEMENT?(t.elements.push(new ai(this.constants_,e)),t.hasStatement=!0):e.type===X.VALUE?(t.elements.push(new Un(this.constants_,e)),t.hasExternalInput=!0):e.type===X.DUMMY&&(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?e.type===X.STATEMENT||t.type===X.STATEMENT?!0:e.type===X.VALUE||e.type===X.DUMMY?!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 pt(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 pt(this.constants_,i))}t.elements.push(o[o.length-1]),t.endsWithElemSpacer()&&t.elements.push(new pt(this.constants_,this.getInRowSpacing_(o[o.length-1],null)))}}}getInRowSpacing_(e,t){if(!e&&t&&E.isStatementInput(t))return this.constants_.STATEMENT_INPUT_PADDING_LEFT;if(e&&E.isInput(e)&&!t){if(E.isExternalInput(e))return this.constants_.NO_PADDING;if(E.isInlineInput(e))return this.constants_.LARGE_PADDING;if(E.isStatementInput(e))return this.constants_.NO_PADDING}return e&&E.isLeftSquareCorner(e)&&t&&(E.isPreviousConnection(t)||E.isNextConnection(t))?t.notchOffset:e&&E.isLeftRoundedCorner(e)&&t&&(E.isPreviousConnection(t)||E.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:this.constants_.MEDIUM_PADDING}computeBounds_(){let e=0,t=0,o=0;for(let i=0,a;a=this.rows[i];i++){if(a.measure(),t=Math.max(t,a.width),a.hasStatement){var s=a.getLastInput();let p,$;s=a.width-(($=(p=s)==null?void 0:p.width)!=null?$:0),e=Math.max(e,s)}o=Math.max(o,a.widthWithConnectedBlocks)}this.statementEdge=e,this.width=t;for(let i=0,a;a=this.rows[i];i++)a.hasStatement&&(a.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,0<e&&this.addAlignmentPadding_(o,e),E.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$input.LEFT&&s)s.width+=t;else if(e.align===n.Align$$module$build$src$core$input.CENTRE&&o&&s)o.width+=t/2,s.width+=t/2;else if(e.align===n.Align$$module$build$src$core$input.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,0<o&&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 Eu(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 E.isSpacer(t)?e.yPos+t.height/2:E.isBottomRow(e)?(e=e.yPos+e.height-e.descenderHeight,E.isNextConnection(t)?e+t.height/2:e-t.height/2):E.isTopRow(e)?E.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++)E.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}},hT="blocklyCursor",dT="blocklyMarker",_T=.75,fu=class{constructor(e,t,o){this.workspace=e,this.marker=o,this.markerSvgRect_=this.markerSvgLine_=this.markerInput_=this.markerBlock_=this.svgGroup_=this.markerSvg_=this.currentMarkerSvg=this.parent_=null,this.constants_=t,e=this.isCursor()?this.constants_.CURSOR_COLOUR:this.constants_.MARKER_COLOUR,this.colour_=o.colour||e}getSvgRoot(){return this.svgGroup_}getMarker(){return this.marker}isCursor(){return this.marker.type==="cursor"}createDom(){const e=this.isCursor()?hT:dT;return this.svgGroup_=I(f.G,{class:e}),this.createDomInternal_(),this.svgGroup_}setParent_(e){this.isCursor()?(this.parent_&&this.parent_.setCursorSvg(null),e.setCursorSvg(this.getSvgRoot())):(this.parent_&&this.parent_.setMarkerSvg(null),e.setMarkerSvg(this.getSvgRoot())),this.parent_=e}draw(e,t){if(t){this.constants_=this.workspace.getRenderer().getConstants();var o=this.isCursor()?this.constants_.CURSOR_COLOUR:this.constants_.MARKER_COLOUR;this.colour_=this.marker.colour||o,this.applyColour_(t),this.showAtLocation_(t),this.fireMarkerEvent_(e,t),e=this.currentMarkerSvg.childNodes[0],e!==void 0&&e.beginElement&&e.beginElement()}else this.hide()}showAtLocation_(e){const t=e.getLocation().type;e.getType()===y.types.BLOCK?this.showWithBlock_(e):e.getType()===y.types.OUTPUT?this.showWithOutput_(e):t===M.INPUT_VALUE?this.showWithInput_(e):t===M.NEXT_STATEMENT?this.showWithNext_(e):e.getType()===y.types.PREVIOUS?this.showWithPrevious_(e):e.getType()===y.types.FIELD?this.showWithField_(e):e.getType()===y.types.WORKSPACE?this.showWithCoordinates_(e):e.getType()===y.types.STACK&&this.showWithStack_(e)}showWithBlockPrevOutput_(e){e=e.getSourceBlock();const t=e.width;var o=e.height,s=o*_T;const i=this.constants_.CURSOR_BLOCK_PADDING;e.previousConnection?(o=this.constants_.shapeFor(e.previousConnection),this.positionPrevious_(t,i,s,o)):e.outputConnection?(s=this.constants_.shapeFor(e.outputConnection),this.positionOutput_(t,o,s)):this.positionBlock_(t,i,s),this.setParent_(e),this.showCurrent_()}showWithBlock_(e){this.showWithBlockPrevOutput_(e)}showWithPrevious_(e){this.showWithBlockPrevOutput_(e)}showWithOutput_(e){this.showWithBlockPrevOutput_(e)}showWithCoordinates_(e){var t=e.getWsCoordinate();e=t.x,t=t.y,this.workspace.RTL&&(e-=this.constants_.CURSOR_WS_WIDTH),this.positionLine_(e,t,this.constants_.CURSOR_WS_WIDTH),this.setParent_(this.workspace),this.showCurrent_()}showWithField_(e){e=e.getLocation();const t=e.getSize().width,o=e.getSize().height;this.positionRect_(0,0,t,o),this.setParent_(e),this.showCurrent_()}showWithInput_(e){e=e.getLocation();const t=e.getSourceBlock();this.positionInput_(e),this.setParent_(t),this.showCurrent_()}showWithNext_(e){var t=e.getLocation();e=t.getSourceBlock();let o=0;t=t.getOffsetInBlock().y;const s=e.getHeightWidth().width;this.workspace.RTL&&(o=-s),this.positionLine_(o,t,s),this.setParent_(e),this.showCurrent_()}showWithStack_(e){e=e.getLocation();var t=e.getHeightWidth();const o=t.width+this.constants_.CURSOR_STACK_PADDING;t=t.height+this.constants_.CURSOR_STACK_PADDING;const s=-this.constants_.CURSOR_STACK_PADDING/2,i=-this.constants_.CURSOR_STACK_PADDING/2;let a=s;this.workspace.RTL&&(a=-(o+s)),this.positionRect_(a,i,o,t),this.setParent_(e),this.showCurrent_()}showCurrent_(){this.hide(),this.currentMarkerSvg&&(this.currentMarkerSvg.style.display="")}positionBlock_(e,t,o){if(e=Te(-t,o)+D("V",-t)+D("H",e+2*t)+D("V",o),!this.markerBlock_)throw Error("createDom should be called before positioning the marker");this.markerBlock_.setAttribute("d",e),this.workspace.RTL&&this.flipRtl_(this.markerBlock_),this.currentMarkerSvg=this.markerBlock_}positionInput_(e){const t=e.getOffsetInBlock().x,o=e.getOffsetInBlock().y;e=Ue(0,0)+this.constants_.shapeFor(e).pathDown,this.markerInput_.setAttribute("d",e),this.markerInput_.setAttribute("transform","translate("+t+","+o+")"+(this.workspace.RTL?" scale(-1 1)":"")),this.currentMarkerSvg=this.markerInput_}positionLine_(e,t,o){if(!this.markerSvgLine_)throw Error("createDom should be called before positioning the line");this.markerSvgLine_.setAttribute("x",`${e}`),this.markerSvgLine_.setAttribute("y",`${t}`),this.markerSvgLine_.setAttribute("width",`${o}`),this.currentMarkerSvg=this.markerSvgLine_}positionOutput_(e,t,o){if(!this.markerBlock_)throw Error("createDom should be called before positioning the output");e=Te(e,0)+D("h",-(e-o.width))+D("v",this.constants_.TAB_OFFSET_FROM_TOP)+o.pathDown+D("V",t)+D("H",e),this.markerBlock_.setAttribute("d",e),this.workspace.RTL&&this.flipRtl_(this.markerBlock_),this.currentMarkerSvg=this.markerBlock_}positionPrevious_(e,t,o,s){if(!this.markerBlock_)throw Error("createDom should be called before positioning the previous connection marker");e=Te(-t,o)+D("V",-t)+D("H",this.constants_.NOTCH_OFFSET_LEFT)+s.pathLeft+D("H",e+2*t)+D("V",o),this.markerBlock_.setAttribute("d",e),this.workspace.RTL&&this.flipRtl_(this.markerBlock_),this.currentMarkerSvg=this.markerBlock_}positionRect_(e,t,o,s){if(!this.markerSvgRect_)throw Error("createDom should be called before positioning the rect");this.markerSvgRect_.setAttribute("x",`${e}`),this.markerSvgRect_.setAttribute("y",`${t}`),this.markerSvgRect_.setAttribute("width",`${o}`),this.markerSvgRect_.setAttribute("height",`${s}`),this.currentMarkerSvg=this.markerSvgRect_}flipRtl_(e){e.setAttribute("transform","scale(-1 1)")}hide(){if(!(this.markerSvgLine_&&this.markerSvgRect_&&this.markerInput_&&this.markerBlock_))throw Error("createDom should be called before hiding the marker");this.markerSvgLine_.style.display="none",this.markerSvgRect_.style.display="none",this.markerInput_.style.display="none",this.markerBlock_.style.display="none"}fireMarkerEvent_(e,t){const o=t.getSourceBlock();e=new(F(wr))(o,this.isCursor(),e,t),x(e)}getBlinkProperties_(){return{attributeType:"XML",attributeName:"fill",dur:"1s",values:this.colour_+";transparent;transparent;",repeatCount:"indefinite"}}createDomInternal_(){if(this.markerSvg_=I(f.G,{width:this.constants_.CURSOR_WS_WIDTH,height:this.constants_.WS_CURSOR_HEIGHT},this.svgGroup_),this.markerSvgLine_=I(f.RECT,{width:this.constants_.CURSOR_WS_WIDTH,height:this.constants_.WS_CURSOR_HEIGHT,style:"display: none"},this.markerSvg_),this.markerSvgRect_=I(f.RECT,{class:"blocklyVerticalMarker",rx:10,ry:10,style:"display: none"},this.markerSvg_),this.markerInput_=I(f.PATH,{transform:"",style:"display: none"},this.markerSvg_),this.markerBlock_=I(f.PATH,{transform:"",style:"display: none",fill:"none","stroke-width":this.constants_.CURSOR_STROKE_WIDTH},this.markerSvg_),this.isCursor()){const e=this.getBlinkProperties_();I(f.ANIMATE,e,this.markerSvgLine_),I(f.ANIMATE,e,this.markerInput_),I(f.ANIMATE,Object.assign({},e,{attributeName:"stroke"}),this.markerBlock_)}return this.markerSvg_}applyColour_(e){if(!(this.markerSvgLine_&&this.markerSvgRect_&&this.markerInput_&&this.markerBlock_))throw Error("createDom should be called before applying color to the markerj");this.markerSvgLine_.setAttribute("fill",this.colour_),this.markerSvgRect_.setAttribute("stroke",this.colour_),this.markerInput_.setAttribute("fill",this.colour_),this.markerBlock_.setAttribute("stroke",this.colour_),this.isCursor()&&(e=this.colour_+";transparent;transparent;",this.markerSvgLine_.firstElementChild.setAttribute("values",e),this.markerInput_.firstElementChild.setAttribute("values",e),this.markerBlock_.firstElementChild.setAttribute("values",e))}dispose(){this.svgGroup_&&re(this.svgGroup_)}},Hn=class{constructor(e,t,o){this.markerSvg=this.cursorSvg=null,this.constants=o,this.style=t,this.svgRoot=e,this.svgPath=I(f.PATH,{class:"blocklyPath"},this.svgRoot)}setPath(e){this.svgPath.setAttribute("d",e)}flipRTL(){this.svgPath.setAttribute("transform","scale(-1 1)")}setCursorSvg(e){e?(this.svgRoot.appendChild(e),this.cursorSvg=e):this.cursorSvg=null}setMarkerSvg(e){e?(this.cursorSvg?this.svgRoot.insertBefore(e,this.cursorSvg):this.svgRoot.appendChild(e),this.markerSvg=e):this.markerSvg=null}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?U(this.svgRoot,e):se(this.svgRoot,e))}updateHighlighted(e){e?this.svgPath.setAttribute("filter","url(#"+this.constants.embossFilterId+")"):this.svgPath.setAttribute("filter","none")}updateShadow_(e){e&&(this.svgPath.setAttribute("stroke","none"),this.svgPath.setAttribute("fill",this.style.colourSecondary))}updateDisabled_(e){this.setClass_("blocklyDisabled",e),e&&this.svgPath.setAttribute("fill","url(#"+this.constants.disabledPatternId+")")}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){}},_i=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){this.constants_.createDom(e,this.name+"-"+t.name,"."+this.getClassName()+"."+t.getClassName())}refreshDom(e,t){const o=this.getConstants();o.dispose(),this.constants_=this.makeConstants_(),this.overrides&&Object.assign(this.constants_,this.overrides),this.constants_.randomIdentifier=o.randomIdentifier,this.constants_.setTheme(t),this.constants_.init(),this.createDom(e,t)}dispose(){this.constants_&&this.constants_.dispose()}makeConstants_(){return new hi}makeRenderInfo_(e){return new qs(this,e)}makeDrawer_(e,t){return new di(e,t)}makeDebugger_(){return new gt(this.getConstants())}makeMarkerDrawer(e,t){return new fu(e,this.getConstants(),t)}makePathObject(e,t){return new Hn(e,t,this.constants_)}getConstants(){return this.constants_}shouldHighlightConnection(e){return!0}orphanCanConnectAtEnd(e,t,o){return!!ie.getConnectionForOrphanedConnection(e,o===M.OUTPUT_VALUE?t.outputConnection:t.previousConnection)}getConnectionPreviewMethod(e,t,o){return t.type===M.OUTPUT_VALUE||t.type===M.PREVIOUS_STATEMENT?!e.isConnected()||this.orphanCanConnectAtEnd(o,e.targetBlock(),t.type)?dt.PREVIEW_TYPE.INSERTION_MARKER:dt.PREVIEW_TYPE.REPLACEMENT_FADE:dt.PREVIEW_TYPE.INSERTION_MARKER}render(e){Lr()&&!e.renderingDebugger&&(e.renderingDebugger=this.makeDebugger_());const t=this.makeRenderInfo_(e);t.measure(),this.makeDrawer_(e,t).draw()}},ae={};ae.BottomRow=pu,ae.Connection=as,ae.ConstantProvider=hi,ae.Debug=gt,ae.Drawer=di,ae.ExternalValueInput=Un,ae.Field=cs,ae.Hat=gu,ae.Icon=Gp,ae.InRowSpacer=pt,ae.InlineInput=Tu,ae.InputConnection=go,ae.InputRow=$u,ae.JaggedEdge=Pp,ae.MarkerSvg=fu,ae.Measurable=Zt,ae.NextConnection=Bp,ae.OutputConnection=xp,ae.PathObject=Hn,ae.PreviousConnection=Fp,ae.RenderInfo=qs,ae.Renderer=_i,ae.RoundCorner=ci,ae.Row=li,ae.SpacerRow=Eu,ae.SquareCorner=ui,ae.StatementInput=ai,ae.TopRow=mu,ae.Types=E,ae.init=wa,ae.register=Cs,ae.stopDebugger=zd,ae.unregister=Kd;var Hp=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())&&se(e,t),(t=this.theme.getClassName())&&U(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 a=this.theme&&this.theme.getComponentStyle(o);e.style.setProperty(t,a||"")}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;0<=s;s--)o[s].element===e&&o.splice(s,1);o.length||this.componentDB.delete(t)}}dispose(){this.subscribedWorkspaces_.length=0,this.componentDB.clear()}},bu="VARIABLE_DYNAMIC",Go={};Go.CATEGORY_NAME=bu,Go.flyoutCategory=an,Go.flyoutCategoryBlocks=xa,Go.onCreateVariableButtonClick_Colour=Ba,Go.onCreateVariableButtonClick_Number=Pa,Go.onCreateVariableButtonClick_String=Ga;var Ru=class{constructor(e){this.workspace=e,this.variableMap=new Map}clear(){for(const e of this.variableMap.values())for(;0<e.length;)this.deleteVariable(e[0]);if(this.variableMap.size!==0)throw Error("Non-empty variable map")}renameVariable(e,t){if(e.name!==t){var o=this.getVariable(t,e.type),s=this.workspace.getAllBlocks(!1),i=K();i||C(!0);try{o&&o.getId()!==e.getId()?this.renameVariableWithConflict_(e,t,o,s):this.renameVariableAndUses_(e,t,s)}finally{C(i)}}}renameVariableById(e,t){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(x(new(F(Dr))(e,t)),e.name=t,t=0;t<o.length;t++)o[t].updateVarName(e)}renameVariableWithConflict_(e,t,o,s){const i=e.type;for(t!==o.name&&this.renameVariableAndUses_(o,t,s),t=0;t<s.length;t++)s[t].renameVarById(e.getId(),o.getId());x(new(F(ys))(e)),Ke(this.variableMap.get(i),e)}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.');return s=o||ft(),t=t||"",s=new Ur(this.workspace,e,t,s),e=this.variableMap.get(t)||[],e.push(s),this.variableMap.delete(t),this.variableMap.set(t,e),x(new(F(zo))(s)),s}deleteVariable(e){const t=e.getId(),o=this.variableMap.get(e.type);if(o){for(let s=0;s<o.length;s++)if(o[s].getId()===t){o.splice(s,1),x(new(F(ys))(e)),o.length===0&&this.variableMap.delete(e.type);break}}}deleteVariableById(e){const t=this.getVariableById(e);if(t){var o=t.name;const s=this.getVariableUsesById(e);for(let i=0,a;a=s[i];i++)if(a.type==="procedures_defnoreturn"||a.type==="procedures_defreturn"){e=String(a.getFieldValue("NAME")),o=H.CANNOT_DELETE_VARIABLE_PROCEDURE.replace("%1",o).replace("%2",e),O(o);return}1<s.length?(o=H.DELETE_VARIABLE_CONFIRMATION.replace("%1",String(s.length)).replace("%2",o),te(o,i=>{i&&t&&this.deleteVariableInternal(t,s)})):this.deleteVariableInternal(t,s)}else console.warn("Can't delete non-existent variable: "+e)}deleteVariableInternal(e,t){const o=K();o||C(!0);try{for(let s=0;s<t.length;s++)t[s].dispose(!0);this.deleteVariable(e)}finally{C(o)}}getVariable(e,t){if(t=this.variableMap.get(t||"")){for(let o=0,s;s=t[o];o++)if(Ze.equals(s.name,e))return s}return null}getVariableById(e){for(const t of this.variableMap.values())for(const o of t)if(o.getId()===e)return o;return null}getVariablesOfType(e){return(e=this.variableMap.get(e||""))?e.slice():[]}getVariableTypes(e){const t=new Set(this.variableMap.keys());if(e&&e.getPotentialVariableMap())for(const o of e.getPotentialVariableMap().variableMap.keys())t.add(o);return t.has("")||t.add(""),Array.from(t.values())}getAllVariables(){let e=[];for(const t of this.variableMap.values())e=e.concat(t);return e}getAllVariableNames(){return Array.from(this.variableMap.values()).flat().map(e=>e.name)}getVariableUsesById(e){const t=[],o=this.workspace.getAllBlocks(!1);for(let s=0;s<o.length;s++){const i=o[s].getVarModels();if(i)for(let a=0;a<i.length;a++)i[a].getId()===e&&t.push(o[s])}return t}},pi=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 wp,this.potentialVariableMap=null,this.id=ft(),Q(this),this.options=e||new kt({}),this.RTL=!!this.options.RTL,this.horizontalLayout=!!this.options.horizontalLayout,this.toolboxPosition=this.options.toolboxPosition,this.connectionChecker=new(b(A.CONNECTION_CHECKER,this.options,!0))(this),this.variableMap=new Ru(this)}dispose(){this.listeners.length=0,this.clear(),de(this)}sortObjects_(e,t){const o=Math.sin(ms(pi.SCAN_ANGLE))*(this.RTL?-1:1);return e=e.getRelativeToSurfaceXY(),t=t.getRelativeToSurfaceXY(),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){const t=[].concat(this.topBlocks);return e&&1<t.length&&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){return this.typedBlocksDB.has(e)?(e=this.typedBlocksDB.get(e).slice(0),t&&e&&1<e.length&&e.sort(this.sortObjects_.bind(this)),e.filter(function(o){return!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){const t=[].concat(this.topComments);return e&&1<t.length&&t.sort(this.sortObjects_.bind(this)),t}getAllBlocks(e){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(function(o){return!o.isInsertionMarker()})}clear(){this.isClearing=!0;try{const e=K();for(e||C(!0);this.topBlocks.length;)this.topBlocks[0].dispose(!1);for(;this.topComments.length;)this.topComments[this.topComments.length-1].dispose();C(e),this.variableMap.clear(),this.potentialVariableMap&&this.potentialVariableMap.clear()}finally{this.isClearing=!1}}renameVariableById(e,t){this.variableMap.renameVariableById(e,t)}createVariable(e,t,o){return this.variableMap.createVariable(e,t,o)}getVariableUsesById(e){return this.variableMap.getVariableUsesById(e)}deleteVariableById(e){this.variableMap.deleteVariableById(e)}getVariable(e,t){return this.variableMap.getVariable(e,t)}getVariableById(e){return this.variableMap.getVariableById(e)}getVariablesOfType(e){return this.variableMap.getVariablesOfType(e)}getVariableTypes(){return this.variableMap.getVariableTypes(this)}getAllVariables(){return this.variableMap.getAllVariables()}getAllVariableNames(){return this.variableMap.getAllVariableNames()}getWidth(){return 0}newBlock(e,t){throw Error("The implementation of newBlock 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 a=t.pop();a&&i.push(a)}for(t=0;t<i.length;t++)o.push(i[t]);i=Fe(i,e),We(!1);try{for(o=0;o<i.length;o++)i[o].run(e)}finally{We(!0)}}}clearUndo(){this.undoStack_.length=0,this.redoStack_.length=0,Z()}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&&0<=this.MAX_UNDO;)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 Ru(this)}getVariableMap(){return this.variableMap}setVariableMap(e){this.variableMap=e}getProcedureMap(){return this.procedureMap}static getById(e){return N(e)}static getAll(){return G()}};pi.SCAN_ANGLE=3;var pT=100,Vp=class{constructor(e){this.parentWorkspace=e,this.sounds=new Map,this.lastSound_=null}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 a=e[i],p=a.match(/\.(\w+)$/);if(p&&o.canPlayType("audio/"+p[1])){var s=new globalThis.Audio(a);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(),Gs||Y_)break}}play(e,t){var o=this.sounds.get(e);o?(e=new Date,this.lastSound_!==null&&e.getTime()-this.lastSound_.getTime()<pT||(this.lastSound_=e,o=Gs||In?o:o.cloneNode(),o.volume=t===void 0?1:t,o.play())):this.parentWorkspace&&this.parentWorkspace.getAudioManager().play(e,t)}},To;(function(e){e[e.TOP=0]="TOP",e[e.BOTTOM=1]="BOTTOM"})(To||(To={}));var Zs;(function(e){e[e.LEFT=0]="LEFT",e[e.RIGHT=1]="RIGHT"})(Zs||(Zs={}));var Po;(function(e){e[e.UP=0]="UP",e[e.DOWN=1]="DOWN"})(Po||(Po={}));var us={};us.bumpDirection=Po,us.bumpPositionRect=hn,us.getCornerOppositeToolbox=un,us.getStartPositionRect=cn,us.horizontalPosition=Zs,us.verticalPosition=To;var Qe={width:96,height:124,url:"sprites.png"},Wp=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=I(f.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:2,capabilities:[Be.Capability.POSITIONABLE]}),this.initialized=!0}dispose(){this.workspace.getComponentManager().removeComponent("zoomControls"),this.svgGroup&&re(this.svgGroup);for(const e of this.boundEvents)ce(e);this.boundEvents.length=0}getBoundingRectangle(){let e=this.SMALL_SPACING+2*this.HEIGHT;return this.zoomResetGroup&&(e+=this.LARGE_SPACING+this.HEIGHT),new Se(this.top,this.top+e,this.left,this.left+this.WIDTH)}position(e,t){if(this.initialized){var o=un(this.workspace,e),s=this.SMALL_SPACING+2*this.HEIGHT;if(this.zoomResetGroup&&(s+=this.LARGE_SPACING+this.HEIGHT),e=cn(o,new Pe(this.WIDTH,s),this.MARGIN_HORIZONTAL,this.MARGIN_VERTICAL,e,this.workspace),o=o.vertical,t=hn(e,this.MARGIN_VERTICAL,o===To.TOP?Po.DOWN:Po.UP,t),o===To.TOP){var i=this.SMALL_SPACING+this.HEIGHT,a;(a=this.zoomInGroup)==null||a.setAttribute("transform","translate(0, "+i+")"),this.zoomResetGroup&&this.zoomResetGroup.setAttribute("transform","translate(0, "+(i+this.LARGE_SPACING+this.HEIGHT)+")")}else{a=this.zoomResetGroup?this.LARGE_SPACING+this.HEIGHT:0;let $;($=this.zoomInGroup)==null||$.setAttribute("transform","translate(0, "+a+")"),a=a+this.SMALL_SPACING+this.HEIGHT,(i=this.zoomOutGroup)==null||i.setAttribute("transform","translate(0, "+a+")")}this.top=t.top,this.left=t.left;var p;(p=this.svgGroup)==null||p.setAttribute("transform","translate("+this.left+","+this.top+")")}}createZoomOutSvg(e){this.zoomOutGroup=I(f.G,{class:"blocklyZoom"},this.svgGroup);const t=I(f.CLIPPATH,{id:"blocklyZoomoutClipPath"+e},this.zoomOutGroup);I(f.RECT,{width:32,height:32},t),I(f.IMAGE,{width:Qe.width,height:Qe.height,x:-64,y:-92,"clip-path":"url(#blocklyZoomoutClipPath"+e+")"},this.zoomOutGroup).setAttributeNS(it,"xlink:href",this.workspace.options.pathToMedia+Qe.url),this.boundEvents.push(w(this.zoomOutGroup,"pointerdown",null,this.zoom.bind(this,-1)))}createZoomInSvg(e){this.zoomInGroup=I(f.G,{class:"blocklyZoom"},this.svgGroup);const t=I(f.CLIPPATH,{id:"blocklyZoominClipPath"+e},this.zoomInGroup);I(f.RECT,{width:32,height:32},t),I(f.IMAGE,{width:Qe.width,height:Qe.height,x:-32,y:-92,"clip-path":"url(#blocklyZoominClipPath"+e+")"},this.zoomInGroup).setAttributeNS(it,"xlink:href",this.workspace.options.pathToMedia+Qe.url),this.boundEvents.push(w(this.zoomInGroup,"pointerdown",null,this.zoom.bind(this,1)))}zoom(e,t){this.workspace.markFocused(),this.workspace.zoomCenter(e),this.fireZoomEvent(),Ut(),t.stopPropagation(),t.preventDefault()}createZoomResetSvg(e){this.zoomResetGroup=I(f.G,{class:"blocklyZoom"},this.svgGroup);const t=I(f.CLIPPATH,{id:"blocklyZoomresetClipPath"+e},this.zoomResetGroup);I(f.RECT,{width:32,height:32},t),I(f.IMAGE,{width:Qe.width,height:Qe.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+e+")"},this.zoomResetGroup).setAttributeNS(it,"xlink:href",this.workspace.options.pathToMedia+Qe.url),this.boundEvents.push(w(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(),Ut(),e.stopPropagation(),e.preventDefault()}fireZoomEvent(){const e=new(F(Ao))(null,this.workspace.id,"zoom_controls");x(e)}};Tt(`
|
|
654
|
+
.blocklyZoom>image, .blocklyZoom>svg>image {
|
|
655
|
+
opacity: .4;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
.blocklyZoom>image:hover, .blocklyZoom>svg>image:hover {
|
|
659
|
+
opacity: .6;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.blocklyZoom>image:active, .blocklyZoom>svg>image:active {
|
|
663
|
+
opacity: .8;
|
|
664
|
+
}
|
|
665
|
+
`);var gT=20,Mt=class extends pi{constructor(e,t,o){super(e),this.resizeHandlerWrapper=null,this.resizesEnabled=this.isVisible_=this.rendered=!0,this.startScrollY=this.startScrollX=this.scrollY=this.scrollX=0,this.dragDeltaXY=null,this.oldScale=this.scale=1,this.oldLeft=this.oldTop=0,this.workspaceDragSurface=this.blockDragSurface=this.currentGesture_=this.toolbox_=this.flyout=this.scrollbar=this.trashcan=null,this.isDragSurfaceActive=!1,this.inverseScreenCTM=this.targetWorkspace=this.configureContextMenu=this.lastRecordedPageScroll=this.injectionDiv=null,this.inverseScreenCTMDirty=!0,this.highlightedBlocks=[],this.toolboxCategoryCallbacks=new Map,this.flyoutButtonCallbacks=new Map,this.cachedParentSvg=null,this.keyboardAccessibilityMode=!1,this.topBoundedElements=[],this.dragTargetAreas=[],this.zoomControls_=null,this.metricsManager=new(b(A.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||Mt.setTopLevelWorkspaceMetrics_,this.componentManager=new Be,this.connectionDBList=zs.init(this.connectionChecker),t&&(this.blockDragSurface=t),o&&(this.workspaceDragSurface=o),this.useWorkspaceDragSurface=!!this.workspaceDragSurface,this.audioManager=new Vp(e.parentWorkspace),this.grid=this.options.gridPattern?new du(this.options.gridPattern,e.gridOptions):null,this.markerManager=new jr(this),n.module$build$src$core$variables&&Ci&&this.registerToolboxCategoryCallback($n,Ci),Go&&an&&this.registerToolboxCategoryCallback(bu,an),n.module$build$src$core$procedures&&ln&&(this.registerToolboxCategoryCallback(Fn,ln),this.addChangeListener(ka)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new Hp(this,this.options.theme||Mn),this.themeManager_.subscribeWorkspace(this);let s;this.renderer=wa(this.options.renderer||"geras",this.getTheme(),(s=this.options.rendererOverrides)!=null?s:void 0),this.cachedParentSvgSize=new Pe(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}setCursorSvg(e){this.markerManager.setCursorSvg(e)}setMarkerSvg(e){this.markerManager.setMarkerSvg(e)}getMarker(e){return this.markerManager?this.markerManager.getMarker(e):null}getCursor(){return this.markerManager?this.markerManager.getCursor():null}getRenderer(){return this.renderer}getThemeManager(){return this.themeManager_}getTheme(){return this.themeManager_.getTheme()}setTheme(e){e||(e=Mn),this.themeManager_.setTheme(e)}refreshTheme(){this.svgGroup_&&this.renderer.refreshDom(this.svgGroup_,this.getTheme()),this.updateBlockStyles_(this.getAllBlocks(!1).filter(function(t){return!!t.getStyleName()})),this.refreshToolboxSelection(),this.toolbox_&&this.toolbox_.refreshTheme(),this.isVisible()&&this.setVisible(!0);const e=new(F(Br))(this.getTheme().name,this.id);x(e)}updateBlockStyles_(e){for(let t=0,o;o=e[t];t++){const s=o.getStyleName();if(s){const i=o;i.setStyle(s),i.mutator&&i.mutator.updateBlockStyle()}}}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.isVisible_}getSvgXY(e){let t=0,o=0,s=1;(Fo(this.getCanvas(),e)||Fo(this.getBubbleCanvas(),e))&&(s=this.scale);do{const i=$t(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());return new L(t,o)}getCachedParentSvgSize(){const e=this.cachedParentSvgSize;return new Pe(e.width,e.height)}getOriginOffsetInPixels(){return pr(this.getCanvas())}getInjectionDiv(){if(!this.injectionDiv){let e=this.svgGroup_;for(;e;){if((" "+(e.getAttribute("class")||"")+" ").indexOf(" injectionDiv ")!==-1){this.injectionDiv=e;break}e=e.parentNode}}return this.injectionDiv}getBlockCanvas(){return this.svgBlockCanvas_}setResizeHandlerWrapper(e){this.resizeHandlerWrapper=e}createDom(e){return this.svgGroup_=I(f.G,{class:"blocklyWorkspace"}),e&&(this.svgBackground_=I(f.RECT,{height:"100%",width:"100%",class:e},this.svgGroup_),e==="blocklyMainBackground"&&this.grid?this.svgBackground_.style.fill="url(#"+this.grid.getPatternId()+")":this.themeManager_.subscribe(this.svgBackground_,"workspaceBackgroundColour","fill")),this.svgBlockCanvas_=I(f.G,{class:"blocklyBlockCanvas"},this.svgGroup_),this.svgBubbleCanvas_=I(f.G,{class:"blocklyBubbleCanvas"},this.svgGroup_),this.isFlyout||(w(this.svgGroup_,"pointerdown",this,this.onMouseDown_,!1),document.body.addEventListener("wheel",function(){}),w(this.svgGroup_,"wheel",this,this.onMouseWheel_)),this.options.hasCategories&&(this.toolbox_=new(b(A.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(e=b(A.CURSOR,this.options))&&this.markerManager.setCursor(new e),this.renderer.createDom(this.svgGroup_,this.getTheme()),this.svgGroup_}dispose(){if(this.rendered=!1,this.currentGesture_&&this.currentGesture_.cancel(),this.svgGroup_&&re(this.svgGroup_),this.toolbox_&&(this.toolbox_.dispose(),this.toolbox_=null),this.flyout&&(this.flyout.dispose(),this.flyout=null),this.trashcan&&(this.trashcan.dispose(),this.trashcan=null),this.scrollbar&&(this.scrollbar.dispose(),this.scrollbar=null),this.zoomControls_&&this.zoomControls_.dispose(),this.audioManager&&this.audioManager.dispose(),this.grid&&(this.grid=null),this.renderer.dispose(),this.markerManager&&this.markerManager.dispose(),super.dispose(),this.themeManager_&&(this.themeManager_.unsubscribeWorkspace(this),this.themeManager_.unsubscribe(this.svgBackground_),this.options.parentWorkspace||this.themeManager_.dispose()),this.connectionDBList.length=0,this.toolboxCategoryCallbacks.clear(),this.flyoutButtonCallbacks.clear(),!this.options.parentWorkspace){const e=this.getParentSvg();e&&e.parentNode&&re(e.parentNode)}this.resizeHandlerWrapper&&(ce(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null)}addTrashcan(){this.trashcan=Mt.newTrashcan(this);const e=this.trashcan.createDom();this.svgGroup_.insertBefore(e,this.svgBlockCanvas_)}static newTrashcan(e){throw Error("The implementation of newTrashcan should be monkey-patched in by blockly.ts")}addZoomControls(){this.zoomControls_=new Wp(this);const e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}addFlyout(e){const t=new kt({parentWorkspace:this,rtl:this.RTL,oneBasedIndex:this.options.oneBasedIndex,horizontalLayout:this.horizontalLayout,renderer:this.options.renderer,rendererOverrides:this.options.rendererOverrides,move:{scrollbars:!0}});return t.toolboxPosition=this.options.toolboxPosition,this.flyout=this.horizontalLayout?new(b(A.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(b(A.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(Be.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),o=[];for(let s=0,i;i=e[s];s++){i.position(t,o);const a=i.getBoundingRectangle();a&&o.push(a)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations_()}updateScreenCalculationsIfScrolled(){const e=Di();L.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations_())}getCanvas(){return this.svgBlockCanvas_}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.svgBubbleCanvas_}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(Oe()){var e=this.scale,t=-this.scrollY,o=-this.scrollX;if(!(e===this.oldScale&&1>Math.abs(t-this.oldTop)&&1>Math.abs(o-this.oldLeft))){var s=new(F(Jo))(t,o,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=o,x(s)}}}translate(e,t){if(this.useWorkspaceDragSurface&&this.isDragSurfaceActive){var o;(o=this.workspaceDragSurface)==null||o.translateSurface(e,t)}else o="translate("+e+","+t+") scale("+this.scale+")",this.svgBlockCanvas_.setAttribute("transform",o),this.svgBubbleCanvas_.setAttribute("transform",o);this.blockDragSurface&&this.blockDragSurface.translateAndScaleGroup(e,t,this.scale),this.grid&&this.grid.moveTo(e,t),this.maybeFireViewportChangeEvent()}resetDragSurface(){if(this.useWorkspaceDragSurface){this.isDragSurfaceActive=!1;var e=this.workspaceDragSurface.getSurfaceTranslation();this.workspaceDragSurface.clearAndHide(this.svgGroup_),e="translate("+e.x+","+e.y+") scale("+this.scale+")",this.svgBlockCanvas_.setAttribute("transform",e),this.svgBubbleCanvas_.setAttribute("transform",e)}}setupDragSurface(){if(this.useWorkspaceDragSurface&&!this.isDragSurfaceActive){this.isDragSurfaceActive=!0;var e=this.svgBlockCanvas_.previousSibling,t,o=parseInt((t=this.getParentSvg().getAttribute("width"))!=null?t:"0"),s;t=parseInt((s=this.getParentSvg().getAttribute("height"))!=null?s:"0"),s=$t(this.getCanvas()),this.workspaceDragSurface.setContentsAndShow(this.getCanvas(),this.getBubbleCanvas(),e,o,t,this.scale),this.workspaceDragSurface.translateSurface(s.x,s.y)}}getBlockDragSurface(){return this.blockDragSurface}getWidth(){const e=this.getMetrics();return e?e.viewWidth/this.scale:0}setVisible(e){if(this.isVisible_=e,this.svgGroup_)if(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){e=this.getAllBlocks(!1);for(let t=e.length-1;0<=t;t--)e[t].markDirty();this.render(),this.toolbox_&&this.toolbox_.position()}else this.hideChaff(!0)}render(){for(var e=this.getAllBlocks(!1),t=e.length-1;0<=t;t--)e[t].render(!1);if(this.currentGesture_)for(e=this.currentGesture_.getInsertionMarkers(),t=0;t<e.length;t++)e[t].render(!1);this.markerManager.updateMarkers()}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.indexOf(e)===-1&&this.highlightedBlocks.push(e):Ke(this.highlightedBlocks,e),e.setHighlighted(t))}paste(e){if(!this.rendered||!e.type&&!e.tagName)return null;this.currentGesture_&&this.currentGesture_.cancel();const t=K();t||C(!0);let o;try{o=e.type?this.pasteBlock_(null,e):e.tagName.toLowerCase()==="comment"?this.pasteWorkspaceComment_(e):this.pasteBlock_(e,null)}finally{C(t)}return o}pasteBlock_(e,t){ve();let o;try{let s=0,i=0;if(e){o=Wo(e,this);let a;s=parseInt((a=e.getAttribute("x"))!=null?a:"0"),this.RTL&&(s=-s);let p;i=parseInt((p=e.getAttribute("y"))!=null?p:"0")}else t&&(o=Oo(t,this),s=t.x||10,this.RTL&&(s=this.getWidth()-s),i=t.y||10);if(!isNaN(s)&&!isNaN(i)){let a;do{a=!1;const p=this.getAllBlocks(!1);for(let $=0,v;v=p[$];$++){const k=v.getRelativeToSurfaceXY();if(1>=Math.abs(s-k.x)&&1>=Math.abs(i-k.y)){a=!0;break}}if(!a){const $=o.getConnections_(!1);for(let v=0,k;k=$[v];v++)if(k.closest(n.config$$module$build$src$core$config.snapRadius,new L(s,i)).connection){a=!0;break}}a&&(s=this.RTL?s-n.config$$module$build$src$core$config.snapRadius:s+n.config$$module$build$src$core$config.snapRadius,i+=2*n.config$$module$build$src$core$config.snapRadius)}while(a);o.moveTo(new L(s,i))}}finally{Ie()}return Oe()&&!o.isShadow()&&x(new(F(He))(o)),o.select(),o}pasteWorkspaceComment_(e){ve();let t;try{t=Xe.fromXmlRendered(e,this);let o,s=parseInt((o=e.getAttribute("x"))!=null?o:"0"),i,a=parseInt((i=e.getAttribute("y"))!=null?i:"0");isNaN(s)||isNaN(a)||(this.RTL&&(s=-s),t.moveBy(s+50,a+50))}finally{Ie()}return Oe()&&Kt.fireCreateEvent(t),t.select(),t}refreshToolboxSelection(){const e=this.isFlyout?this.targetWorkspace:this;e&&!e.currentGesture_&&e.toolbox_&&e.toolbox_.getFlyout()&&e.toolbox_.refreshSelection()}renameVariableById(e,t){super.renameVariableById(e,t),this.refreshToolboxSelection()}deleteVariableById(e){super.deleteVariableById(e),this.refreshToolboxSelection()}createVariable(e,t,o){return e=super.createVariable(e,t,o),this.refreshToolboxSelection(),e}recordDragTargets(){const e=this.componentManager.getComponents(Be.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")}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){e=Vo(e,this.getParentSvg(),this.getInverseScreenCTM()),e.x/=this.scale,e.y/=this.scale,this.dragDeltaXY=L.difference(t,e)}moveDrag(e){return e=Vo(e,this.getParentSvg(),this.getInverseScreenCTM()),e.x/=this.scale,e.y/=this.scale,L.sum(this.dragDeltaXY,e)}isDragging(){return 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(qt.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=dr(e);if(dc)var i=e.metaKey;t&&(e.ctrlKey||i||!o)?(s=-s.y/50,t=Vo(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 Se(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),C(!0);const e=this.getTopBlocks(!0);let t=0;for(let o=0,s;s=e[o];o++){if(!s.isMovable())continue;const i=s.getRelativeToSurfaceXY();s.moveBy(-i.x,t-i.y),s.snapToGrid(),t=s.getRelativeToSurfaceXY().y+s.getHeightWidth().height+this.renderer.getConstants().MIN_BLOCK_HEIGHT}C(!1),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.options.readOnly&&!this.isFlyout){var t=le.registry.getContextMenuOptions(le.ScopeType.WORKSPACE,{workspace:this});this.configureContextMenu&&this.configureContextMenu(t,e),Cr(e,t,this.RTL)}}updateToolbox(e){if(e=Rr(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(zi(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():(Re(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(),a=this.getParentSvg().createSVGPoint();a.x=e,a.y=t,a=a.matrixTransform(i.inverse()),e=a.x,t=a.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=2*gT,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,ve();try{this.setScale(Math.min(t,e)),this.scrollCenter()}finally{Ie()}this.maybeFireViewportChangeEvent()}}else console.warn("Tried to move a non-movable workspace. This could result in blocks becoming inaccessible.")}beginCanvasTransition(){U(this.svgBlockCanvas_,"blocklyCanvasTransitioning"),U(this.svgBubbleCanvas_,"blocklyCanvasTransitioning")}endCanvasTransition(){se(this.svgBlockCanvas_,"blocklyCanvasTransitioning"),se(this.svgBubbleCanvas_,"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.options.parentWorkspace?this.options.parentWorkspace.getScale():this.scale}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){return super.getAllBlocks(e)}getTopBlocks(e){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)}addTopBoundedElement(e){this.topBoundedElements.push(e)}removeTopBoundedElement(e){Ke(this.topBoundedElements,e)}getTopBoundedElements(){return[].concat(this.topBoundedElements)}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){const t=e.type==="pointerdown",o=this.currentGesture_;return o?t&&o.hasStarted()?(console.warn("Tried to start the same gesture twice."),o.cancel(),null):o:t?this.currentGesture_=new qt(e,this):null}clearGesture(){this.currentGesture_=null}cancelCurrentGesture(){this.currentGesture_&&this.currentGesture_.cancel()}getAudioManager(){return this.audioManager}getGrid(){return this.grid}hideChaff(e){So(),Ot(),It();const t=!!e;this.getComponentManager().getComponents(Be.Capability.AUTOHIDEABLE,!0).forEach(o=>o.autoHide(t))}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)}},Qs;(function(e){e.BLOCK="block",e.BUTTON="button"})(Qs||(Qs={}));var Vn=class extends Bn{constructor(e){super(),this.horizontalLayout=!1,this.boundEvents=[],this.filterWrapper=this.reflowWrapper=null,this.mats=[],this.buttons_=[],this.listeners=[],this.permanentlyDisabled=[],this.recycledBlocks=[],this.autoClose=!0,this.isVisible_=!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,e.setMetrics=this.setMetrics_.bind(this),this.workspace_=new Mt(e),this.workspace_.setMetricsManager(new Dp(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.isVisible_),this.id=ft(),this.RTL=!!e.RTL,this.toolboxPosition_=e.toolboxPosition,this.tabWidth_=this.workspace_.getRenderer().getConstants().TAB_WIDTH,this.rectMap_=new WeakMap,this.MARGIN=this.CORNER_RADIUS,this.GAP_X=3*this.MARGIN,this.GAP_Y=3*this.MARGIN}createDom(e){return this.svgGroup_=I(e,{class:"blocklyFlyout",style:"display: none"}),this.svgBackground_=I(f.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 hu(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(w(this.svgGroup_,"wheel",this,this.wheel_)),this.autoClose||(this.filterWrapper=this.filterForCapacity.bind(this),this.targetWorkspace.addChangeListener(this.filterWrapper)),this.boundEvents.push(w(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:1,capabilities:[Be.Capability.DELETE_AREA,Be.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.workspace_.getComponentManager().removeComponent(this.id);for(const e of this.boundEvents)ce(e);this.boundEvents.length=0,this.filterWrapper&&this.targetWorkspace.removeChangeListener(this.filterWrapper),this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&re(this.svgGroup_)}getWidth(){return this.width_}getHeight(){return this.height_}getFlyoutScale(){return this.targetWorkspace.scale}getWorkspace(){return this.workspace_}isVisible(){return this.isVisible_}setVisible(e){const t=e!==this.isVisible();this.isVisible_=e,t&&(this.autoClose||this.workspace_.recordDragTargets(),this.updateDisplay())}setContainerVisible(e){const t=e!==this.containerVisible;this.containerVisible=e,t&&this.updateDisplay()}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 a;(a=this.svgGroup_)==null||a.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&so(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(){if(this.isVisible()){this.setVisible(!1);for(const e of this.listeners)ce(e);this.listeners.length=0,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=Ir(e),e=this.createFlyoutInfo(e),this.layout_(e.contents,e.gaps),this.horizontalLayout?this.height_=0:this.width_=0,this.workspace_.setResizesEnabled(!0),this.reflow(),this.filterForCapacity(),this.position(),this.reflowWrapper=this.reflow.bind(this),this.workspace_.addChangeListener(this.reflowWrapper),this.emptyRecycledBlocks()}createFlyoutInfo(e){const t=[],o=[];this.permanentlyDisabled.length=0;const s=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const i of e){if("custom"in i){e=this.getDynamicCategoryContents(i.custom),e=Ir(e);const{contents:a,gaps:p}=this.createFlyoutInfo(e);t.push(...a),o.push(...p)}switch(i.kind.toUpperCase()){case"BLOCK":e=i;const a=this.createFlyoutBlock(e);t.push({type:Qs.BLOCK,block:a}),this.addBlockGap(e,o,s);break;case"SEP":this.addSeparatorGap(i,o,s);break;case"LABEL":e=this.createButton(i,!0),t.push({type:Qs.BUTTON,button:e}),o.push(s);break;case"BUTTON":e=this.createButton(i,!1),t.push({type:Qs.BUTTON,button:e}),o.push(s)}}return{contents:t,gaps:o}}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)}createButton(e,t){return new Dt(this.workspace_,this.targetWorkspace,e,t)}createFlyoutBlock(e){let t;return e.blockxml?(e=typeof e.blockxml=="string"?Ce(e.blockxml):e.blockxml,(t=this.getRecycledBlock(e.getAttribute("type")))||(t=Wo(e,this.workspace_))):(t=this.getRecycledBlock(e.type),t||(e.enabled===void 0&&(e.enabled=e.disabled!=="true"&&e.disabled!==!0),t=Oo(e,this.workspace_))),t.isEnabled()||this.permanentlyDisabled.push(t),t}getRecycledBlock(e){let t=-1;for(let o=0;o<this.recycledBlocks.length;o++)if(this.recycledBlocks[o].type===e){t=o;break}return t===-1?void 0:this.recycledBlocks.splice(t,1)[0]}addBlockGap(e,t,o){let s;e.gap?s=parseInt(String(e.gap)):e.blockxml&&(e=typeof e.blockxml=="string"?Ce(e.blockxml):e.blockxml,s=parseInt(e.getAttribute("gap"))),t.push(!s||isNaN(s)?o:s)}addSeparatorGap(e,t,o){e=parseInt(String(e.gap)),!isNaN(e)&&0<t.length?t[t.length-1]=e:t.push(o)}clearOldBlocks(){var e=this.workspace_.getTopBlocks(!1);for(let o=0,s;s=e[o];o++)this.blockIsRecyclable_(s)?this.recycleBlock(s):s.dispose(!1,!1);for(e=0;e<this.mats.length;e++){const o=this.mats[e];o&&(wl(o),re(o))}this.mats.length=0;for(let o=0,s;s=this.buttons_[o];o++)s.dispose();this.buttons_.length=0;let t;(t=this.workspace_.getPotentialVariableMap())==null||t.clear()}emptyRecycledBlocks(){for(let e=0;e<this.recycledBlocks.length;e++)this.recycledBlocks[e].dispose();this.recycledBlocks=[]}blockIsRecyclable_(e){return!1}recycleBlock(e){const t=e.getRelativeToSurfaceXY();e.moveBy(-t.x,-t.y),this.recycledBlocks.push(e)}addBlockListeners_(e,t,o){this.listeners.push(w(e,"pointerdown",null,this.blockMouseDown(t))),this.listeners.push(w(o,"pointerdown",null,this.blockMouseDown(t))),this.listeners.push(Ye(e,"pointerenter",t,t.addSelect)),this.listeners.push(Ye(e,"pointerleave",t,t.removeSelect)),this.listeners.push(Ye(o,"pointerenter",t,t.addSelect)),this.listeners.push(Ye(o,"pointerleave",t,t.removeSelect))}blockMouseDown(e){return t=>{const o=this.targetWorkspace.getGesture(t);o&&(o.setStartBlock(e),o.handleFlyoutStart(t,this))}}onMouseDown(e){const t=this.targetWorkspace.getGesture(e);t&&t.handleFlyoutStart(e,this)}isBlockCreatable(e){return e.isEnabled()}createBlock(e){let t=null;ve();var o=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{t=this.placeNewBlock(e)}finally{Ie()}if(this.targetWorkspace.hideChaff(),e=Ai(this.targetWorkspace,o),Oe()){for(C(!0),o=0;o<e.length;o++){const s=e[o];x(new(F(zo))(s))}x(new(F(He))(t))}return this.autoClose?this.hide():this.filterForCapacity(),t}initFlyoutButton_(e,t,o){const s=e.createDom();e.moveTo(t,o),e.show(),this.listeners.push(w(s,"pointerdown",this,this.onMouseDown)),this.buttons_.push(e)}createRect_(e,t,o,s,i){return t=I(f.RECT,{"fill-opacity":0,x:t,y:o,height:s.height,width:s.width}),t.tooltip=e,mr(t),this.workspace_.getCanvas().insertBefore(t,e.getSvgRoot()),this.rectMap_.set(e,t),this.mats[i]=t}moveRectToBlock_(e,t){const o=t.getHeightWidth();e.setAttribute("width",String(o.width)),e.setAttribute("height",String(o.height)),t=t.getRelativeToSurfaceXY(),e.setAttribute("y",String(t.y)),e.setAttribute("x",String(this.RTL?t.x-o.width:t.x))}filterForCapacity(){const e=this.workspace_.getTopBlocks(!1);for(let t=0,o;o=e[t];t++)if(this.permanentlyDisabled.indexOf(o)===-1){const s=this.targetWorkspace.isCapacityAvailable(Eo(o));for(;o;)o.setEnabled(s),o=o.getNextBlock()}}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=Wt(e);return t.setResizesEnabled(!1),t=Oo(o,t),this.positionNewBlock(e,t),t}positionNewBlock(e,t){const o=this.targetWorkspace;var s=o.getOriginOffsetInPixels(),i=this.workspace_.getOriginOffsetInPixels();e=e.getRelativeToSurfaceXY(),e.scale(this.workspace_.scale),i=L.sum(i,e),s=L.difference(i,s),s.scale(1/o.scale),t.moveTo(new L(s.x,s.y))}};Vn.FlyoutItemType=Qs;var Xp=class extends Vn{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_===V.TOP;return this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?s?e.height:o.height-this.height_:s?0:o.height:s?0:o.height+t.top-this.height_}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.width_=e.width,this.setBackgroundPath(e.width-2*this.CORNER_RADIUS,this.height_-this.CORNER_RADIUS),e=this.getX();var t=this.getY();this.positionAt_(this.width_,this.height_,e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===V.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=dr(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),Ot(),It()}e.preventDefault(),e.stopPropagation()}layout_(e,t){this.workspace_.scale=this.targetWorkspace.scale;const o=this.MARGIN;let s=o+this.tabWidth_;this.RTL&&(e=e.reverse());for(let $=0,v;v=e[$];$++)if(v.type==="block"){var i=v.block,a=i.getDescendants(!1);for(let fe=0,be;be=a[fe];fe++)be.isInFlyout=!0;i.render(),a=i.getSvgRoot();const k=i.getHeightWidth();var p=i.outputConnection?this.tabWidth_:0;p=this.RTL?s+k.width:s-p,i.moveBy(p,o),p=this.createRect_(i,p,o,k,$),s+=k.width+t[$],this.addBlockListeners_(a,i,p)}else v.type==="button"&&(i=v.button,this.initFlyoutButton_(i,s,o),s+=i.width+t[$])}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_===V.TOP?new Se(-1e9,t+e.height,-1e9,1e9):new Se(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=0;const t=this.workspace_.getTopBlocks(!1);for(let s=0,i;i=t[s];s++)e=Math.max(e,i.getHeightWidth().height);const o=this.buttons_;for(let s=0,i;i=o[s];s++)e=Math.max(e,i.height);if(e+=1.5*this.MARGIN,e*=this.workspace_.scale,e+=me.scrollbarThickness,this.height_!==e){for(let s=0,i;i=t[s];s++)this.rectMap_.has(i)&&this.moveRectToBlock_(this.rectMap_.get(i),i);this.targetWorkspace.toolboxPosition!==this.toolboxPosition_||this.toolboxPosition_!==V.TOP||this.targetWorkspace.getToolbox()||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.recordDragTargets()}}};r(A.FLYOUTS_HORIZONTAL_TOOLBOX,no,Xp);var Iu=class extends Vn{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_===V.LEFT?e.width:o.width-this.width_:this.toolboxPosition_===V.LEFT?0:o.width:this.toolboxPosition_===V.LEFT?0:o.width+t.left-this.width_}getY(){return 0}position(){if(this.isVisible()&&this.targetWorkspace.isVisible()){var e=this.targetWorkspace.getMetricsManager().getViewMetrics();this.height_=e.height,this.setBackgroundPath(this.width_-this.CORNER_RADIUS,e.height-2*this.CORNER_RADIUS),e=this.getX();var t=this.getY();this.positionAt_(this.width_,this.height_,e,t)}}setBackgroundPath(e,t){const o=this.toolboxPosition_===V.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=dr(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),Ot(),It()}e.preventDefault(),e.stopPropagation()}layout_(e,t){this.workspace_.scale=this.targetWorkspace.scale;var o=this.MARGIN;const s=this.RTL?o:o+this.tabWidth_;for(let $=0,v;v=e[$];$++)if(v.type==="block"){var i=v.block,a=i.getDescendants(!1);for(let fe=0,be;be=a[fe];fe++)be.isInFlyout=!0;i.render(),a=i.getSvgRoot();const k=i.getHeightWidth();var p=i.outputConnection?s-this.tabWidth_:s;i.moveBy(p,o),p=this.createRect_(i,this.RTL?p-k.width:p,o,k,$),this.addBlockListeners_(a,i,p),o+=k.height+t[$]}else v.type==="button"&&(i=v.button,this.initFlyoutButton_(i,s,o),o+=i.height+t[$])}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_===V.LEFT?new Se(-1e9,1e9,-1e9,t+e.width):new Se(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=0;var t=this.workspace_.getTopBlocks(!1);for(let s=0,i;i=t[s];s++){var o=i.getHeightWidth().width;i.outputConnection&&(o-=this.tabWidth_),e=Math.max(e,o)}for(let s=0,i;i=this.buttons_[s];s++)e=Math.max(e,i.width);if(e+=1.5*this.MARGIN+this.tabWidth_,e*=this.workspace_.scale,e+=me.scrollbarThickness,this.width_!==e){for(let s=0,i;i=t[s];s++){if(this.RTL){o=i.getRelativeToSurfaceXY().x;let a=e/this.workspace_.scale-this.MARGIN;i.outputConnection||(a-=this.tabWidth_),i.moveBy(a-o,0)}this.rectMap_.has(i)&&this.moveRectToBlock_(this.rectMap_.get(i),i)}if(this.RTL)for(let s=0,i;i=this.buttons_[s];s++)t=i.getPosition().y,i.moveTo(e/this.workspace_.scale-i.width-this.MARGIN-this.tabWidth_,t);this.targetWorkspace.toolboxPosition!==this.toolboxPosition_||this.toolboxPosition_!==V.LEFT||this.targetWorkspace.getToolbox()||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.recordDragTargets()}}};Iu.registryName="verticalFlyout",r(A.FLYOUTS_VERTICAL_TOOLBOX,no,Iu),n.CodeGenerator$$module$build$src$core$generator=class{constructor(e){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=Y());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(`
|
|
666
|
+
`),t=this.finish(t),t=t.replace(/^\s+\n/,""),t=t.replace(/\n\s+$/,`
|
|
667
|
+
`),t=t.replace(/[ \t]+\n/g,`
|
|
668
|
+
`)}prefixLines(e,t){return t+e.replace(/(?!\n$)\n/g,`
|
|
669
|
+
`+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(`
|
|
670
|
+
`)}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[e.type];if(typeof o!="function")throw Error('Language "'+this.name_+'" does not know how to generate code for block type "'+e.type+'".');if(o=o.call(e,e),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||(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 a=Math.floor(t);if(i<=a&&(i!==a||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){if(e=e.getInputTargetBlock(t),t=this.blockToCode(e),typeof t!="string")throw TypeError("Expecting code from statement block: "+(e&&e.type));return t&&(t=this.prefixLines(t,this.INDENT)),t}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(`
|
|
671
|
+
`)),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]}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}},Object.defineProperties(n.CodeGenerator$$module$build$src$core$generator.prototype,{variableDB_:{get(){return _("variableDB_","version 9","version 10","nameDB_"),this.nameDB_},set(e){_("variableDB_","version 9","version 10","nameDB_"),this.nameDB_=e}}}),n.CodeGenerator$$module$build$src$core$generator;var ue=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)&&0<t.length)for(let o=0;o<t.length;o++)this.addKeyMapping(t[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-1<i?(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 io(Object.create(null),e)}onKeyDown(e,t){var o=this.serializeKeyEvent_(t);if(o=this.getShortcutNamesByKeyCode(o),!o)return!1;for(let s=0,i;i=o[s];s++){const a=this.shortcuts.get(i);let p,$;if((p=a)==null||!p.preconditionFn||($=a)!=null&&$.preconditionFn(e)){let v,k;if((v=a)!=null&&v.callback&&((k=a)!=null&&k.callback(e,t,a)))return!0}}return!1}getShortcutNamesByKeyCode(e){return this.keyMap.get(e)||[]}getKeyCodesByShortcutName(e){const t=[];for(const[o,s]of this.keyMap)-1<s.indexOf(e)&&t.push(o);return t}serializeKeyEvent_(e){let t="";for(const o in ue.modifierKeys)e.getModifierState(o)&&(t!==""&&(t+="+"),t+=o);return t!==""&&e.keyCode?t=t+"+"+e.keyCode:e.keyCode&&(t=String(e.keyCode)),t}checkModifiers_(e){for(let t=0,o;o=e[t];t++)if(!(o in ue.modifierKeys))throw Error(o+" is not a valid modifier key.")}createSerializedKey(e,t){let o="";if(t){this.checkModifiers_(t);for(const s in ue.modifierKeys)-1<t.indexOf(ue.modifierKeys[s])&&(o!==""&&(o+="+"),o+=s)}return o!==""&&e?o=o+"+"+e:e&&(o=`${e}`),o}};ue.registry=new ue,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"}(ue||(ue={}));var jp=class{constructor(e){this.container=e,this.previousSibling=null,this.createDom()}createDom(){this.SVG||(this.SVG=I(f.SVG,{xmlns:Ms,"xmlns:html":Ct,"xmlns:xlink":it,version:"1.1",class:"blocklyWsDragSurface blocklyOverflowVisible"}),this.container.appendChild(this.SVG))}translateSurface(e,t){e=Math.round(e),t=Math.round(t),this.SVG.style.display="block",so(this.SVG,"translate3d("+e+"px, "+t+"px, 0)")}getSurfaceTranslation(){return $t(this.SVG)}clearAndHide(e){if(!e)throw Error("Couldn't clear and hide the drag surface: missing new surface.");const t=this.SVG.childNodes[0],o=this.SVG.childNodes[1];if(!t||!o||!t.classList.contains("blocklyBlockCanvas")&&o.classList.contains("blocklyBubbleCanvas"))throw Error("Couldn't clear and hide the drag surface. A node was missing.");if(this.previousSibling!==null?Rt(t,this.previousSibling):e.insertBefore(t,e.firstChild),Rt(o,t),this.SVG.style.display="none",this.SVG.childNodes.length)throw Error("Drag surface was not cleared.");so(this.SVG,""),this.previousSibling=null}setContentsAndShow(e,t,o,s,i,a){if(this.SVG.childNodes.length)throw Error("Already dragging a block.");this.previousSibling=o,e.setAttribute("transform","translate(0, 0) scale("+a+")"),t.setAttribute("transform","translate(0, 0) scale("+a+")"),this.SVG.setAttribute("width",String(s)),this.SVG.setAttribute("height",String(i)),this.SVG.appendChild(e),this.SVG.appendChild(t),this.SVG.style.display="block"}},Yp=!1,Kp=class extends hi{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;","}"])}},zp=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_+`
|
|
672
|
+
`+this.inlineSteps_}drawTopCorner(e){this.steps_+=Te(e.xPos,this.info_.startY);for(let t=0,o;o=e.elements[t];t++)E.isLeftSquareCorner(o)?this.steps_+=this.highlightConstants_.START_POINT:E.isLeftRoundedCorner(o)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):E.isPreviousConnection(o)?this.steps_+=this.notchPaths_.pathLeft:E.isHat(o)?this.steps_+=this.startPaths_.path(this.RTL_):E.isSpacer(o)&&o.width!==0&&(this.steps_+=D("H",o.xPos+o.width-this.highlightOffset_));this.steps_+=D("H",e.xPos+e.width-this.highlightOffset_)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+D("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_+=Ue(t.xPos+t.width-this.highlightOffset_,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+D("v",o)}else this.steps_+=Ue(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_+=Ue(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+D("v",o)+this.insideCornerPaths_.pathBottom(this.RTL_)+Xt(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=Ue(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Xt(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){const t=e.xPos+e.width-this.highlightOffset_;e instanceof Eu&&e.followsStatement&&(this.steps_+=D("H",t)),this.RTL_&&(this.steps_+=D("H",t),e.height>this.highlightOffset_&&(this.steps_+=D("V",e.yPos+e.height-this.highlightOffset_)))}drawBottomRow(e){if(this.RTL_)this.steps_+=D("V",e.baseline-this.highlightOffset_);else{const t=this.info_.bottomRow.elements[0];E.isLeftSquareCorner(t)?this.steps_+=Ue(e.xPos+this.highlightOffset_,e.baseline-this.highlightOffset_):E.isLeftRoundedCorner(t)&&(this.steps_+=Ue(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_+=Ue(this.info_.startX,e):(this.steps_+=Ue(this.info_.startX+this.highlightOffset_,this.info_.bottomRow.baseline-this.highlightOffset_),this.steps_+=D("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,E.isLeftRoundedCorner(e.elements[0])?this.steps_+=D("V",this.outsideCornerPaths_.height):this.steps_+=D("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,a=s+t;this.RTL_?(s=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=Ue(o-t,a)+D("v",s)+this.puzzleTabPaths_.pathDown(this.RTL_)+D("v",e)+D("h",i)):this.inlineSteps_+=Ue(e.xPos+e.width+t,a)+D("v",e.height)+D("h",-i)+Ue(o,s+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Jp=class extends di{constructor(e,t){super(e,t),this.highlighter_=new zp(t)}draw(){this.hideHiddenIcons_(),this.drawOutline_(),this.drawInternals_();const e=this.block_.pathObject;if(e.setPath(this.outlinePath_+`
|
|
673
|
+
`+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),Lr()){let t,o;(t=this.block_)==null||(o=t.renderingDebugger)==null||o.drawDebug(this.block_,this.info_)}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_+=D("H",e.xPos+e.width)+D("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?-1*o: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)}}},qp=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=Te(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=Te(o,o)+Ne("a","0 0,0",e,P(-o-t,e-o)),i=Ne("a","0 0,0",e+t,P(e+t,e+t)),a=Te(o,-o)+Ne("a","0 0,0",e+t,P(e-o,o+t));return{width:e+t,height:e,pathTop(p){return p?s:""},pathBottom(p){return p?i:a}}}makeOutsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,o=(1-Math.SQRT1_2)*(e-t)+t,s=Te(o,o)+Ne("a","0 0,1",e-t,P(e-o,-o+t)),i=Te(t,e)+Ne("a","0 0,1",e-t,P(e,-e+t)),a=-o,p=Te(o,a)+Ne("a","0 0,1",e-t,P(-o+t,-a-e));return{height:e,topLeft($){return $?s:i},bottomLeft(){return p}}}makePuzzleTab(){const e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,o=Te(-2,-t+3.4)+Xt(-.45*e,-2.1),s=D("v",2.5)+Te(.97*-e,2.5)+ot("q",[P(.05*-e,10),P(.3*e,9.5)])+Te(.67*e,-1.9)+D("v",2.5),i=D("v",-1.5)+Te(-.92*e,-.5)+ot("q",[P(-.19*e,-5.5),P(0,-11)])+Te(.92*e,1),a=Te(-5,t-.7)+Xt(.46*e,-2.1);return{width:e,height:t,pathUp(p){return p?o:i},pathDown(p){return p?s:a}}}makeNotch(){return{pathLeft:D("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Xt(5.1,2.6)+Te(-10.2,6.8)+Xt(5.1,2.6),height:12,width:10.2}}makeStartHat(){const e=this.constantProvider.START_HAT.height,t=Te(25,-8.7)+ot("c",[P(29.7,-6.2),P(57.2,-.5),P(75,8.7)]),o=ot("c",[P(17.8,-9.2),P(45.3,-14.9),P(75,-8.7)])+Ue(100.5,e+.5);return{path(s){return s?t:o}}}},Zp=class extends Tu{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)}},Qp=class extends ai{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},eg=class extends qs{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].type===X.STATEMENT||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e.type===X.VALUE?(t.elements.push(new Zp(this.constants_,e)),t.hasInlineInput=!0):e.type===X.STATEMENT?(t.elements.push(new Qp(this.constants_,e)),t.hasStatement=!0):e.type===X.VALUE?(t.elements.push(new Un(this.constants_,e)),t.hasExternalInput=!0):e.type===X.DUMMY&&(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 pt(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let i=0;i<t.length-1;i++){s.elements.push(t[i]);const a=this.getInRowSpacing_(t[i],t[i+1]);s.elements.push(new pt(this.constants_,a))}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 pt(this.constants_,t)))}}}getInRowSpacing_(e,t){if(!e)return t&&E.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&E.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&E.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!E.isInput(e)&&(!t||E.isStatementInput(t)))return E.isField(e)&&e.isEditable?this.constants_.MEDIUM_PADDING:E.isIcon(e)?2*this.constants_.LARGE_PADDING+1:E.isHat(e)?this.constants_.NO_PADDING:E.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:E.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:E.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(E.isInput(e)&&!t){if(E.isExternalInput(e))return this.constants_.NO_PADDING;if(E.isInlineInput(e))return this.constants_.LARGE_PADDING;if(E.isStatementInput(e))return this.constants_.NO_PADDING}if(!E.isInput(e)&&t&&E.isInput(t)){if(E.isField(e)&&e.isEditable){if(E.isInlineInput(t)||E.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(E.isInlineInput(t)||E.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(E.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(E.isIcon(e)&&t&&!E.isInput(t))return this.constants_.LARGE_PADDING;if(E.isInlineInput(e)&&t&&E.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(E.isLeftSquareCorner(e)&&t){if(E.isHat(t))return this.constants_.NO_PADDING;if(E.isPreviousConnection(t))return t.notchOffset;if(E.isNextConnection(t))return t.notchOffset+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}if(E.isLeftRoundedCorner(e)&&t){if(E.isPreviousConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS;if(E.isNextConnection(t))return t.notchOffset-this.constants_.CORNER_RADIUS+(this.RTL?1:-1)*this.constants_.DARK_PATH_OFFSET/2}return E.isField(e)&&t&&E.isField(t)&&e.isEditable===t.isEditable||t&&E.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return E.isTopRow(e)&&E.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:E.isTopRow(e)||E.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(E.isSpacer(t))return e.yPos+t.height/2;if(E.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,E.isNextConnection(t)?e+t.height/2:e-t.height/2;if(E.isTopRow(e))return E.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return E.isField(t)||E.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=E.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),E.isInputRow(i)&&(i.hasStatement&&this.alignStatementRow_(i),o&&o.hasStatement&&i.width<o.width?t.set(i,o.width):e=i.width,o=i);e=0;for(let s=0,i;i=this.rows[s];s++)i.hasStatement?e=this.getDesiredRowWidth_(i):E.isSpacer(i)?i.width=Math.max(e,t.get(i)):(o=i.width,e=Math.max(e,t.get(i))-o,0<e&&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}},tg=class extends Hn{constructor(e,t,o){super(e,t,o),this.constants=o,this.colourDark="#000000",this.svgPathDark=I(f.PATH,{class:"blocklyPathDark",transform:"translate(1,1)"}),this.svgRoot.insertBefore(this.svgPathDark,this.svgPath),this.svgPathLight=I(f.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=Xo("#000",this.style.colourPrimary,.2)||this.colourDark}updateHighlighted(e){e?(this.svgPath.setAttribute("filter","url(#"+this.constants.embossFilterId+")"),this.svgPathLight.style.display="none"):(this.svgPath.setAttribute("filter","none"),this.svgPathLight.style.display="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")}},og=class extends _i{constructor(e){super(e),this.highlightConstants_=null}init(e,t){super.init(e,t),this.highlightConstants_=this.makeHighlightConstants_(),this.highlightConstants_.init()}refreshDom(e,t){super.refreshDom(e,t),this.getHighlightConstants().init()}makeConstants_(){return new Kp}makeRenderInfo_(e){return new eg(this,e)}makeDrawer_(e,t){return new Jp(e,t)}makePathObject(e,t){return new tg(e,t,this.getConstants())}makeHighlightConstants_(){return new qp(this.getConstants())}getHighlightConstants(){if(!this.highlightConstants_)throw Error("Cannot access the highlight constants because init has not been called");return this.highlightConstants_}};Cs("geras",og);var Qt={};Qt.ConstantProvider=Kp,Qt.Drawer=Jp,Qt.HighlightConstantProvider=qp,Qt.Highlighter=zp,Qt.InlineInput=Zp,Qt.PathObject=tg,Qt.RenderInfo=eg,Qt.Renderer=og,Qt.StatementInput=Qp;var sg=class extends hi{constructor(){super()}},rg=class extends di{constructor(e,t){super(e,t)}},ig=class extends qs{constructor(e,t){super(e,t)}getRenderer(){return this.renderer_}},ng=class extends _i{constructor(e){super(e)}makeConstants_(){return new sg}makeRenderInfo_(e){return new ig(this,e)}makeDrawer_(e,t){return new rg(e,t)}};Cs("minimalist",ng);var gi={};gi.ConstantProvider=sg,gi.Drawer=rg,gi.RenderInfo=ig,gi.Renderer=ng;var lg=class extends qs{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 pt(this.constants_,this.getInRowSpacing_(null,o[0]))),o.length){for(let i=0;i<o.length-1;i++){s.elements.push(o[i]);const a=this.getInRowSpacing_(o[i],o[i+1]);s.elements.push(new pt(this.constants_,a))}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 pt(this.constants_,o)))}}}getInRowSpacing_(e,t){if(!e)return t&&E.isField(t)&&t.isEditable?this.constants_.MEDIUM_PADDING:t&&E.isInlineInput(t)?this.constants_.MEDIUM_LARGE_PADDING:t&&E.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:this.constants_.LARGE_PADDING;if(!E.isInput(e)&&!t)return E.isField(e)&&e.isEditable?this.constants_.MEDIUM_PADDING:E.isIcon(e)?2*this.constants_.LARGE_PADDING+1:E.isHat(e)?this.constants_.NO_PADDING:E.isPreviousOrNextConnection(e)?this.constants_.LARGE_PADDING:E.isLeftRoundedCorner(e)?this.constants_.MIN_BLOCK_WIDTH:E.isJaggedEdge(e)?this.constants_.NO_PADDING:this.constants_.LARGE_PADDING;if(E.isInput(e)&&!t){if(E.isExternalInput(e))return this.constants_.NO_PADDING;if(E.isInlineInput(e))return this.constants_.LARGE_PADDING;if(E.isStatementInput(e))return this.constants_.NO_PADDING}if(!E.isInput(e)&&t&&E.isInput(t)){if(E.isField(e)&&e.isEditable){if(E.isInlineInput(t)||E.isExternalInput(t))return this.constants_.SMALL_PADDING}else{if(E.isInlineInput(t)||E.isExternalInput(t))return this.constants_.MEDIUM_LARGE_PADDING;if(E.isStatementInput(t))return this.constants_.LARGE_PADDING}return this.constants_.LARGE_PADDING-1}if(E.isIcon(e)&&t&&!E.isInput(t))return this.constants_.LARGE_PADDING;if(E.isInlineInput(e)&&t&&E.isField(t))return t.isEditable?this.constants_.MEDIUM_PADDING:this.constants_.LARGE_PADDING;if(E.isLeftSquareCorner(e)&&t){if(E.isHat(t))return this.constants_.NO_PADDING;if(E.isPreviousConnection(t)||E.isNextConnection(t))return t.notchOffset}return E.isLeftRoundedCorner(e)&&t?t.notchOffset-this.constants_.CORNER_RADIUS:E.isField(e)&&t&&E.isField(t)&&e.isEditable===t.isEditable||t&&E.isJaggedEdge(t)?this.constants_.LARGE_PADDING:this.constants_.MEDIUM_PADDING}getSpacerRowHeight_(e,t){return E.isTopRow(e)&&E.isBottomRow(t)?this.constants_.EMPTY_BLOCK_SPACER_HEIGHT:E.isTopRow(e)||E.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(E.isSpacer(t))return e.yPos+t.height/2;if(E.isBottomRow(e))return e=e.yPos+e.height-e.descenderHeight,E.isNextConnection(t)?e+t.height/2:e-t.height/2;if(E.isTopRow(e))return E.isHat(t)?e.capline-t.height/2:e.capline+t.height/2;let o=e.yPos;return o=E.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}},ag=class extends _i{constructor(e){super(e)}makeRenderInfo_(e){return new lg(this,e)}};Cs("thrasos",ag);var Ou={};Ou.RenderInfo=lg,Ou.Renderer=ag;var cg=class extends hi{constructor(){super(),this.GRID_UNIT=4,this.CURSOR_COLOUR="#ffa200",this.CURSOR_RADIUS=5,this.JAGGED_TEETH_WIDTH=this.JAGGED_TEETH_HEIGHT=0,this.START_HAT_HEIGHT=22,this.START_HAT_WIDTH=96,this.SHAPES={HEXAGONAL:1,ROUND:2,SQUARE:3,PUZZLE:4,NOTCH:5},this.SHAPE_IN_SHAPE_PADDING={1:{0:5*this.GRID_UNIT,1:2*this.GRID_UNIT,2:5*this.GRID_UNIT,3:5*this.GRID_UNIT},2:{0:3*this.GRID_UNIT,1:3*this.GRID_UNIT,2:1*this.GRID_UNIT,3:2*this.GRID_UNIT},3:{0:2*this.GRID_UNIT,1:2*this.GRID_UNIT,2:2*this.GRID_UNIT,3:2*this.GRID_UNIT}},this.FULL_BLOCK_FIELDS=!0,this.FIELD_TEXT_FONTWEIGHT="bold",this.FIELD_TEXT_FONTFAMILY='"Helvetica Neue", "Segoe UI", Helvetica, sans-serif',this.FIELD_COLOUR_FULL_BLOCK=this.FIELD_TEXTINPUT_BOX_SHADOW=this.FIELD_DROPDOWN_SVG_ARROW=this.FIELD_DROPDOWN_COLOURED_DIV=this.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW=!0,this.SELECTED_GLOW_COLOUR="#fff200",this.SELECTED_GLOW_SIZE=.5,this.REPLACEMENT_GLOW_COLOUR="#fff200",this.REPLACEMENT_GLOW_SIZE=2,this.selectedGlowFilterId="",this.selectedGlowFilter_=null,this.replacementGlowFilterId="",this.SQUARED=this.ROUNDED=this.HEXAGONAL=this.replacementGlowFilter_=null,this.SMALL_PADDING=this.GRID_UNIT,this.MEDIUM_PADDING=2*this.GRID_UNIT,this.MEDIUM_LARGE_PADDING=3*this.GRID_UNIT,this.LARGE_PADDING=4*this.GRID_UNIT,this.CORNER_RADIUS=1*this.GRID_UNIT,this.NOTCH_WIDTH=9*this.GRID_UNIT,this.NOTCH_HEIGHT=2*this.GRID_UNIT,this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT=3*this.GRID_UNIT,this.MIN_BLOCK_WIDTH=2*this.GRID_UNIT,this.MIN_BLOCK_HEIGHT=12*this.GRID_UNIT,this.EMPTY_STATEMENT_INPUT_HEIGHT=6*this.GRID_UNIT,this.TOP_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.TOP_ROW_PRECEDES_STATEMENT_MIN_HEIGHT=this.LARGE_PADDING,this.BOTTOM_ROW_MIN_HEIGHT=this.CORNER_RADIUS,this.BOTTOM_ROW_AFTER_STATEMENT_MIN_HEIGHT=6*this.GRID_UNIT,this.STATEMENT_BOTTOM_SPACER=-this.NOTCH_HEIGHT,this.STATEMENT_INPUT_SPACER_MIN_WIDTH=40*this.GRID_UNIT,this.STATEMENT_INPUT_PADDING_LEFT=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_PADDING=4*this.GRID_UNIT,this.EMPTY_INLINE_INPUT_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_MIN_HEIGHT=8*this.GRID_UNIT,this.DUMMY_INPUT_SHADOW_MIN_HEIGHT=6*this.GRID_UNIT,this.CURSOR_WS_WIDTH=20*this.GRID_UNIT,this.FIELD_TEXT_FONTSIZE=3*this.GRID_UNIT,this.FIELD_BORDER_RECT_RADIUS=this.CORNER_RADIUS,this.FIELD_BORDER_RECT_X_PADDING=2*this.GRID_UNIT,this.FIELD_BORDER_RECT_Y_PADDING=1.625*this.GRID_UNIT,this.FIELD_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_BORDER_RECT_HEIGHT=8*this.GRID_UNIT,this.FIELD_DROPDOWN_SVG_ARROW_PADDING=this.FIELD_BORDER_RECT_X_PADDING,this.FIELD_COLOUR_DEFAULT_WIDTH=2*this.GRID_UNIT,this.FIELD_COLOUR_DEFAULT_HEIGHT=4*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+2*this.FIELD_BORDER_RECT_Y_PADDING}init(){super.init(),this.HEXAGONAL=this.makeHexagonal(),this.ROUNDED=this.makeRounded(),this.SQUARED=this.makeSquared(),this.STATEMENT_INPUT_NOTCH_OFFSET=this.NOTCH_OFFSET_LEFT+this.INSIDE_CORNERS.rightWidth}setDynamicProperties_(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_&&re(this.selectedGlowFilter_),this.replacementGlowFilter_&&re(this.replacementGlowFilter_)}makeStartHat(){const e=this.START_HAT_HEIGHT,t=this.START_HAT_WIDTH,o=ot("c",[P(25,-e),P(71,-e),P(t,0)]);return{height:e,width:t,path:o}}makeHexagonal(){function e(o,s,i){var a=o/2;return a=a>t?t:a,i=i?-1:1,o=(s?-1:1)*o/2,Xt(-i*a,o)+Xt(i*a,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,a){const p=s>o?s-o:0;return s=(s>o?o:s)/2,Ne("a","0 0,1",s,P((i?-1:1)*s,(i?-1:1)*s))+D("v",(a?1:-1)*p)+Ne("a","0 0,1",s,P((i?1:-1)*s,(i?-1:1)*s))}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,o=2*t;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){return o-=2*t,Ne("a","0 0,1",t,P((s?-1:1)*t,(s?-1:1)*t))+D("v",(i?1:-1)*o)+Ne("a","0 0,1",t,P((s?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 M.INPUT_VALUE:case M.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.indexOf("Boolean")!==-1?this.HEXAGONAL:t&&t.indexOf("Number")!==-1?this.ROUNDED:(t&&t.indexOf("String"),this.ROUNDED);case M.PREVIOUS_STATEMENT:case M.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(k){return ot("c",[P(k*i/2,0),P(k*i*3/4,p/2),P(k*i,p)])+vs([P(k*i,a)])+ot("c",[P(k*i/4,p/2),P(k*i/2,p),P(k*i,p)])+D("h",k*s)+ot("c",[P(k*i/2,0),P(k*i*3/4,-(p/2)),P(k*i,-p)])+vs([P(k*i,-a)])+ot("c",[P(k*i/4,-(p/2)),P(k*i/2,-p),P(k*i,-p)])}const t=this.NOTCH_WIDTH,o=this.NOTCH_HEIGHT,s=t/3,i=s/3,a=o/2,p=a/2,$=e(1),v=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:o,pathLeft:$,pathRight:v}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=Ne("a","0 0,0",e,P(-e,e)),o=Ne("a","0 0,1",e,P(-e,e)),s=Ne("a","0 0,0",e,P(e,e)),i=Ne("a","0 0,1",e,P(e,e));return{width:e,height:e,pathTop:t,pathBottom:s,rightWidth:e,rightHeight:e,pathTopRight:o,pathBottomRight:i}}generateSecondaryColour_(e){return Xo("#000",e,.15)||e}generateTertiaryColour_(e){return Xo("#000",e,.25)||e}createDom(e,t,o){super.createDom(e,t,o),e=I(f.DEFS,{},e),t=I(f.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),I(f.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},t),o=I(f.FECOMPONENTTRANSFER,{result:"outBlur"},t),I(f.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},o),I(f.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),I(f.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter_=t,e=I(f.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),I(f.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=I(f.FECOMPONENTTRANSFER,{result:"outBlur"},e),I(f.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),I(f.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),I(f.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),I(f.FECOMPOSITE,{in:"SourceGraphic",in2:"outGlow",operator:"over"},e),this.replacementGlowFilterId=e.id,this.replacementGlowFilter_=e}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} .blocklyNonEditableText>rect:not(.blocklyDropdownRect),`,`${e} .blocklyEditableText>rect:not(.blocklyDropdownRect) {`,`fill: ${this.FIELD_BORDER_RECT_COLOUR};`,"}",`${e} .blocklyNonEditableText>text,`,`${e} .blocklyEditableText>text,`,`${e} .blocklyNonEditableText>g>text,`,`${e} .blocklyEditableText>g>text {`,"fill: #575E75;","}",`${e} .blocklyFlyoutLabelText {`,"fill: #575E75;","}",`${e} .blocklyText.blocklyBubbleText {`,"fill: #575E75;","}",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):hover>rect,",`${e} .blocklyDraggable:not(.blocklyDisabled)`," .blocklyEditableText:not(.editing):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 .goog-menuitem,`,`${e}.blocklyDropDownDiv .goog-menuitem {`,`font-family: ${this.FIELD_TEXT_FONTFAMILY};`,"}",`${e}.blocklyDropDownDiv .goog-menuitem-content {`,"color: #fff;","}",`${e} .blocklyHighlightedConnectionPath {`,`stroke: ${this.SELECTED_GLOW_COLOUR};`,"}",`${e} .blocklyDisabled > .blocklyOutlinePath {`,`fill: url(#blocklyDisabledPattern${this.randomIdentifier})`,"}",`${e} .blocklyInsertionMarker>.blocklyPath {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"]}},ug=class extends di{constructor(e,t){super(e,t)}draw(){const e=this.block_.pathObject;if(e.beginDrawing(),this.hideHiddenIcons_(),this.drawOutline_(),this.drawInternals_(),e.setPath(this.outlinePath_+`
|
|
674
|
+
`+this.inlinePath_),this.info_.RTL&&e.flipRTL(),Lr()){let t,o;(t=this.block_)==null||(o=t.renderingDebugger)==null||o.drawDebug(this.block_,this.info_)}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(!(0>=e.height))if(E.isSpacer(e)&&(e.precedesStatement||e.followsStatement)){var t=this.constants_.INSIDE_CORNERS.rightHeight;t=e.height-(e.precedesStatement?t:0),this.outlinePath_+=(e.followsStatement?this.constants_.INSIDE_CORNERS.pathBottomRight:"")+(0<t?D("V",e.yPos+t):"")+(e.precedesStatement?this.constants_.INSIDE_CORNERS.pathTopRight:"")}else this.outlinePath_+=D("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_+=Te(e.xPos,this.info_.startY),this.outlinePath_+=D("h",e.width)}drawFlatBottom_(){const e=this.info_.bottomRow;this.positionNextConnection_(),this.outlinePath_+=D("V",e.baseline),this.outlinePath_+=D("h",-e.width)}drawInlineInput_(e){this.positionInlineInputConnection_(e);const t=e.input.name;if(!e.connectedBlock&&!this.info_.isInsertionMarker){var o=e.width-2*e.connectionWidth;e=Ue(e.xPos+e.connectionWidth,e.centerline-e.height/2)+D("h",o)+e.shape.pathRightDown(e.height)+D("h",-o)+e.shape.pathUp(e.height)+"z",this.block_.pathObject.setOutlinePath(t,e)}}drawStatementInput_(e){var t=e.getLastInput();const o=t.xPos+t.notchOffset+t.shape.width,s=t.shape.pathRight+D("h",-(t.notchOffset-this.constants_.INSIDE_CORNERS.width))+this.constants_.INSIDE_CORNERS.pathTop,i=e.height-2*this.constants_.INSIDE_CORNERS.height;t=this.constants_.INSIDE_CORNERS.pathBottom+D("h",t.notchOffset-this.constants_.INSIDE_CORNERS.width)+(t.connectedBottomNextConnection?"":t.shape.pathLeft),this.outlinePath_+=D("H",o)+s+D("v",i)+t+D("H",e.xPos+e.width),this.positionStatementInputConnection_(e)}},hg=class extends pu{constructor(e){super(e)}endsWithElemSpacer(){return!1}hasLeftSquareCorner(e){return!!e.outputConnection}hasRightSquareCorner(e){return!!e.outputConnection&&!e.statementInputCount&&!e.nextConnection}},dg=class extends ai{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)}}},_g=class extends Zt{constructor(e){super(e),this.width=this.height=0,this.type|=E.getType("RIGHT_CONNECTION")}},pg=class extends mu{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}},gg=class extends qs{constructor(e,t){super(e,t),this.isInline=!0,this.renderer_=e,this.constants_=this.renderer_.getConstants(),this.topRow=new pg(this.constants_),this.bottomRow=new hg(this.constants_),this.isMultiRow=!t.getInputsInline()||t.isCollapsed(),this.hasStatementInput=0<t.statementInputCount,this.rightSide=this.outputConnection?new _g(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?e.type===X.STATEMENT||t.type===X.STATEMENT?!0:e.type===X.VALUE||e.type===X.DUMMY?!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&&E.isStatementInput(t)?this.constants_.STATEMENT_INPUT_PADDING_LEFT:e&&E.isLeftRoundedCorner(e)&&t&&(E.isPreviousConnection(t)||E.isNextConnection(t))?t.notchOffset-this.constants_.CORNER_RADIUS:e&&E.isLeftSquareCorner(e)&&t&&E.isHat(t)?this.constants_.NO_PADDING:this.constants_.MEDIUM_PADDING:this.constants_.NO_PADDING}getSpacerRowHeight_(e,t){if(E.isTopRow(e)&&E.isBottomRow(t))return this.constants_.EMPTY_BLOCK_SPACER_HEIGHT;const o=E.isInputRow(e)&&e.hasStatement,s=E.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):E.isTopRow(e)?e.hasPreviousConnection||this.outputConnection&&!this.hasStatementInput?this.constants_.NO_PADDING:Math.abs(this.constants_.NOTCH_HEIGHT-this.constants_.CORNER_RADIUS):E.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 E.isInputRow(e)&&e.hasStatement||E.isInputRow(t)&&t.hasStatement?Math.max(o,this.constants_.STATEMENT_INPUT_SPACER_MIN_WIDTH):o}getElemCenterline_(e,t){if(e.hasStatement&&!E.isSpacer(t)&&!E.isStatementInput(t))return e.yPos+this.constants_.EMPTY_STATEMENT_INPUT_HEIGHT/2;if(E.isInlineInput(t)&&t instanceof go){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.type===X.DUMMY&&t.hasDummyInput&&t.align===n.Align$$module$build$src$core$input.LEFT&&e.align===n.Align$$module$build$src$core$input.RIGHT)this.rightAlignedDummyInputs_.set(t,e);else if(e.type===X.STATEMENT){t.elements.push(new dg(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(E.isSpacer(i)&&(o=i),E.isField(i)&&i instanceof cs&&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 a=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,E.isInputRow(a)&&a.hasStatement){a.measure();let p,$;t=a.width-(($=(p=a.getLastInput())==null?void 0:p.width)!=null?$:0)+e}else if(o&&(i===2||s)&&E.isInputRow(a)&&!a.hasStatement){s=a.xPos,o=null;for(let p=0;p<a.elements.length;p++){const $=a.elements[p];E.isSpacer($)&&(o=$),o&&(E.isField($)||E.isInput($))&&s<t&&!(E.isField($)&&$ instanceof cs&&($.field instanceof Mo||$.field instanceof ls))&&(o.width+=t-s),s+=$.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(!E.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 a=this.constants_.MIN_BLOCK_WIDTH+2*this.outputConnection.width;this.width-e<a&&(e=this.width-a,s=e/2,i=e/2),o.elements.unshift(new pt(this.constants_,-s)),o.elements.push(new pt(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],E.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.isMultiRow&&1<this.inputRows.length)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(E.isInlineInput(e)&&e instanceof go){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 E.isField(e)&&e instanceof cs?o===s.SHAPES.ROUND&&e.field instanceof Js?t-2.75*s.GRID_UNIT:t-this.constants_.SHAPE_IN_SHAPE_PADDING[o][0]:E.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],a=this.rows[s],p=this.rows[s+1];var e=s===2,t=s+2>=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!p.precedesStatement;if(e?this.topRow.hasPreviousConnection:i.followsStatement){var o=a.elements[1];if(o=a.elements.length===3&&o instanceof cs&&(o.field instanceof Mo||o.field instanceof ls),!e&&o)i.height-=this.constants_.SMALL_PADDING,p.height-=this.constants_.SMALL_PADDING,a.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)i.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t<a.elements.length;t++)if(o=a.elements[t],o instanceof go&&E.isInlineInput(o)&&o.connectedBlock&&!o.connectedBlock.isShadow()&&40<=o.connectedBlock.getHeightWidth().height){e=!0;break}e&&(i.height-=this.constants_.SMALL_PADDING,p.height-=this.constants_.SMALL_PADDING)}}}}finalize_(){this.finalizeOutputConnection_(),this.finalizeHorizontalAlignment_(),this.finalizeVerticalAlignment_(),super.finalize_(),this.rightSide&&(this.widthWithChildren+=this.rightSide.width)}},Tg=class extends fu{constructor(e,t,o){super(e,t,o),this.markerCircle_=null}showWithInputOutput_(e){const t=e.getSourceBlock();e=e.getLocation().getOffsetInBlock(),this.positionCircle_(e.x,e.y),this.setParent_(t),this.showCurrent_()}showWithOutput_(e){this.showWithInputOutput_(e)}showWithInput_(e){this.showWithInputOutput_(e)}showWithBlock_(e){e=e.getLocation();const t=e.getHeightWidth();this.positionRect_(0,0,t.width,t.height),this.setParent_(e),this.showCurrent_()}positionCircle_(e,t){let o;(o=this.markerCircle_)==null||o.setAttribute("cx",`${e}`);let s;(s=this.markerCircle_)==null||s.setAttribute("cy",`${t}`),this.currentMarkerSvg=this.markerCircle_}hide(){super.hide(),this.markerCircle_&&(this.markerCircle_.style.display="none")}createDomInternal_(){if(super.createDomInternal_(),this.markerCircle_=I(f.CIRCLE,{r:this.constants_.CURSOR_RADIUS,style:"display: none","stroke-width":this.constants_.CURSOR_STROKE_WIDTH},this.markerSvg_),this.isCursor()){const e=this.getBlinkProperties_();I(f.ANIMATE,e,this.markerCircle_)}return this.markerSvg_}applyColour_(e){super.applyColour_(e);let t;(t=this.markerCircle_)==null||t.setAttribute("fill",this.colour_);let o;if((o=this.markerCircle_)==null||o.setAttribute("stroke",this.colour_),this.isCursor()){e=this.colour_+";transparent;transparent;";let s;(s=this.markerCircle_)==null||s.firstElementChild.setAttribute("values",e)}}},$g=class extends Hn{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.style.colourTertiary);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_.setAttribute("fill","none"),this.svgPathSelected_.setAttribute("filter","url(#"+this.constants.selectedGlowFilterId+")"),this.svgRoot.appendChild(this.svgPathSelected_)):this.svgPathSelected_&&(this.svgRoot.removeChild(this.svgPathSelected_),this.svgPathSelected_=null)}updateReplacementFade(e){this.setClass_("blocklyReplaceable",e),e?this.svgPath.setAttribute("filter","url(#"+this.constants.replacementGlowFilterId+")"):this.svgPath.removeAttribute("filter")}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,I(f.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)}},Eg=class extends _i{constructor(e){super(e)}makeConstants_(){return new cg}makeRenderInfo_(e){return new gg(this,e)}makeDrawer_(e,t){return new ug(e,t)}makeMarkerDrawer(e,t){return new Tg(e,this.getConstants(),t)}makePathObject(e,t){return new $g(e,t,this.getConstants())}getConstants(){return this.constants_}shouldHighlightConnection(e){return e.type!==M.INPUT_VALUE&&e.type!==M.OUTPUT_VALUE}getConnectionPreviewMethod(e,t,o){return t.type===M.OUTPUT_VALUE?e.isConnected()?dt.PREVIEW_TYPE.REPLACEMENT_FADE:dt.PREVIEW_TYPE.INPUT_OUTLINE:super.getConnectionPreviewMethod(e,t,o)}};Cs("zelos",Eg);var wt={};wt.BottomRow=hg,wt.ConstantProvider=cg,wt.Drawer=ug,wt.MarkerSvg=Tg,wt.PathObject=$g,wt.RenderInfo=gg,wt.Renderer=Eg,wt.RightConnectionShape=_g,wt.StatementInput=dg,wt.TopRow=pg;var TT=class{constructor(e,t){this.procedureModelClass=e,this.parameterModelClass=t,this.priority=sp}save(e){return e=e.getProcedureMap().getProcedures().map(t=>Fa(t)),e.length?e:null}load(e,t){const o=t.getProcedureMap();for(const s of e)o.add(Ha(this.procedureModelClass,this.parameterModelClass,s,t))}clear(e){e.getProcedureMap().clear()}},er={};er.ProcedureSerializer=TT,er.loadParameter=Va,er.loadProcedure=Ha,er.saveParameter=Ua,er.saveProcedure=Fa;var mg=class{constructor(){this.priority=op}save(e){const t=[];for(const o of e.getAllVariables())e={name:o.name,id:o.getId()},o.type&&(e.type=o.type),t.push(e);return t.length?t:null}load(e,t){for(const o of e)t.createVariable(o.name,o.type,o.id)}clear(e){e.getVariableMap().clear()}};wi("variables",new mg);var fg={};fg.VariableSerializer=mg;var Su={};Su.load=i_,Su.save=r_;var $T={blocks:Wr,exceptions:Ps,priorities:Sn,procedures:er,registry:$c,variables:fg,workspaces:Su},J;(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"})(J||(J={}));var eo;(function(e){e.ESCAPE="escape",e.DELETE="delete",e.COPY="copy",e.CUT="cut",e.PASTE="paste",e.UNDO="undo",e.REDO="redo"})(eo||(eo={})),qa();var to={};to.names=eo,to.registerCopy=ja,to.registerCut=Ya,to.registerDefaultShortcuts=qa,to.registerDelete=Xa,to.registerEscape=Wa,to.registerPaste=Ka,to.registerRedo=Ja,to.registerUndo=za;var ET={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"}},mT={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"}},fT=new rs("zelos",ET,mT),vu={};vu.Classic=Mn,vu.Zelos=fT;var Cu=class{constructor(e,t,o){this.id_=e.toolboxitemid||oo(),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){}},Gt=class extends Cu{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:"blocklyToolboxCategory",row:"blocklyTreeRow",rowcontentcontainer:"blocklyTreeRowContentContainer",icon:"blocklyTreeIcon",label:"blocklyTreeLabel",contents:"blocklyToolboxContents",selected:"blocklyTreeSelected",openicon:"blocklyTreeIconOpen",closedicon:"blocklyTreeIconClosed"}}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?Ee(e.name):"",this.colour_=this.getColour_(e),Object.assign(this.cssConfig_,e.cssconfig||e.cssConfig)}createDom_(){this.htmlDiv_=this.createContainer_(),St(this.htmlDiv_,lt.TREEITEM),ge(this.htmlDiv_,pe.SELECTED,!1),ge(this.htmlDiv_,pe.LEVEL,this.level_),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_(),St(this.iconDom_,lt.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&&ge(this.htmlDiv_,pe.LABELLEDBY,e),this.addColourBorder_(this.colour_),this.htmlDiv_}createContainer_(){const e=document.createElement("div"),t=this.cssConfig_.container;return t&&U(e,t),e}createRowContainer_(){const e=document.createElement("div");var t=this.cssConfig_.row;return t&&U(e,t),t=`${Gt.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&&U(e,t),e}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&U(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)&&U(t,e),t}refreshTheme(){this.colour_=this.getColour_(this.toolboxItemDef_),this.addColourBorder_(this.colour_)}addColourBorder_(e){e&&(e=Gt.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=Ee(e),e==null||e==="")return"";var t=Number(e);return isNaN(t)?(t=vo(e))?t:(console.warn('Toolbox category "'+this.name_+'" has unrecognized colour attribute: '+e),""):Vi(t)}openIcon_(e){if(e){var t=this.cssConfig_.closedicon;t&&ps(e,t),(t=this.cssConfig_.openicon)&&U(e,t)}}closeIcon_(e){if(e){var t=this.cssConfig_.openicon;t&&ps(e,t),(t=this.cssConfig_.closedicon)&&U(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_(Gt.defaultBackgroundColour);this.rowDiv_.style.backgroundColor=this.colour_||o,t&&U(this.rowDiv_,t)}else this.rowDiv_.style.backgroundColor="",t&&se(this.rowDiv_,t);ge(this.htmlDiv_,pe.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:Ir(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(){re(this.htmlDiv_)}};Gt.registrationName="category",Gt.nestedPadding=19,Gt.borderWidth=8,Gt.defaultBackgroundColour="#57e",Tt(`
|
|
675
|
+
.blocklyTreeRow:not(.blocklyTreeSelected):hover {
|
|
676
|
+
background-color: rgba(255, 255, 255, .2);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.blocklyToolboxDiv[layout="h"] .blocklyToolboxCategory {
|
|
680
|
+
margin: 1px 5px 1px 0;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
.blocklyToolboxDiv[dir="RTL"][layout="h"] .blocklyToolboxCategory {
|
|
684
|
+
margin: 1px 0 1px 5px;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.blocklyTreeRow {
|
|
688
|
+
height: 22px;
|
|
689
|
+
line-height: 22px;
|
|
690
|
+
margin-bottom: 3px;
|
|
691
|
+
padding-right: 8px;
|
|
692
|
+
white-space: nowrap;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {
|
|
696
|
+
margin-left: 8px;
|
|
697
|
+
padding-right: 0;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.blocklyTreeIcon {
|
|
701
|
+
background-image: url(<<<PATH>>>/sprites.png);
|
|
702
|
+
height: 16px;
|
|
703
|
+
vertical-align: middle;
|
|
704
|
+
visibility: hidden;
|
|
705
|
+
width: 16px;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.blocklyTreeIconClosed {
|
|
709
|
+
background-position: -32px -1px;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.blocklyToolboxDiv[dir="RTL"] .blocklyTreeIconClosed {
|
|
713
|
+
background-position: 0 -1px;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
.blocklyTreeSelected>.blocklyTreeIconClosed {
|
|
717
|
+
background-position: -32px -17px;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
.blocklyToolboxDiv[dir="RTL"] .blocklyTreeSelected>.blocklyTreeIconClosed {
|
|
721
|
+
background-position: 0 -17px;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.blocklyTreeIconOpen {
|
|
725
|
+
background-position: -16px -1px;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.blocklyTreeSelected>.blocklyTreeIconOpen {
|
|
729
|
+
background-position: -16px -17px;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.blocklyTreeLabel {
|
|
733
|
+
cursor: default;
|
|
734
|
+
font: 16px sans-serif;
|
|
735
|
+
padding: 0 3px;
|
|
736
|
+
vertical-align: middle;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.blocklyToolboxDelete .blocklyTreeLabel {
|
|
740
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
.blocklyTreeSelected .blocklyTreeLabel {
|
|
744
|
+
color: #fff;
|
|
745
|
+
}
|
|
746
|
+
`),r(A.TOOLBOX_ITEM,Gt.registrationName,Gt);var Ti=class extends Cu{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"),t=this.cssConfig_.container;return t&&U(e,t),this.htmlDiv_=e}getDiv(){return this.htmlDiv_}dispose(){re(this.htmlDiv_)}};Ti.registrationName="sep",Tt(`
|
|
747
|
+
.blocklyTreeSeparator {
|
|
748
|
+
border-bottom: solid #e5e5e5 1px;
|
|
749
|
+
height: 0;
|
|
750
|
+
margin: 5px 0;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.blocklyToolboxDiv[layout="h"] .blocklyTreeSeparator {
|
|
754
|
+
border-right: solid #e5e5e5 1px;
|
|
755
|
+
border-bottom: none;
|
|
756
|
+
height: auto;
|
|
757
|
+
margin: 0 5px 0 5px;
|
|
758
|
+
padding: 5px 0;
|
|
759
|
+
width: 0;
|
|
760
|
+
}
|
|
761
|
+
`),r(A.TOOLBOX_ITEM,Ti.registrationName,Ti);var tr=class extends Gt{constructor(e,t,o){super(e,t,o),this.subcategoriesDiv_=null,this.expanded_=!1,this.toolboxItems_=[]}makeDefaultCssConfig_(){const e=super.makeDefaultCssConfig_();return e.contents="blocklyToolboxContents",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];!c(A.TOOLBOX_ITEM,s.kind)||s.kind.toLowerCase()===Ti.registrationName&&e?(this.flyoutItems_.push(s),e=!0):(this.createToolboxItem_(s),e=!1)}}}}createToolboxItem_(e){let t=e.kind;t.toUpperCase()==="CATEGORY"&&Ji(e)&&(t=tr.registrationName),e=new(l(A.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),St(this.subcategoriesDiv_,lt.GROUP),this.htmlDiv_.appendChild(this.subcategoriesDiv_),this.closeIcon_(this.iconDom_),ge(this.htmlDiv_,pe.EXPANDED,!1),this.htmlDiv_}createIconDom_(){const e=document.createElement("span");if(!this.parentToolbox_.isHorizontal()){const t=this.cssConfig_.icon;t&&U(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&&U(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 a;(a=s.getClickTarget())==null||a.setAttribute("id",s.getId())}}return t}setExpanded(e){this.expanded_!==e&&((this.expanded_=e)?(this.subcategoriesDiv_.style.display="block",this.openIcon_(this.iconDom_)):(this.subcategoriesDiv_.style.display="none",this.closeIcon_(this.iconDom_)),ge(this.htmlDiv_,pe.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_}};tr.registrationName="collapsibleCategory",r(A.TOOLBOX_ITEM,tr.registrationName,tr);var bg=class extends Bn{constructor(e){super(),this.id="toolbox",this.contentsDiv_=this.HtmlDiv=null,this.isVisible_=!1,this.contents_=[],this.height_=this.width_=0,this.previouslySelectedItem_=this.selectedItem_=this.flyout_=null,this.boundEvents_=[],this.workspace_=e,this.toolboxDef_=e.options.languageTree||{contents:[]},this.horizontalLayout_=e.options.horizontalLayout,this.RTL=e.options.RTL,this.contentMap_=Object.create(null),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_),Rt(this.flyout_.createDom("svg"),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:1,capabilities:[Be.Capability.AUTOHIDEABLE,Be.Capability.DELETE_AREA,Be.Capability.DRAG_TARGET]})}createDom_(e){e=e.getParentSvg();const t=this.createContainer_();return this.contentsDiv_=this.createContentsContainer_(),this.contentsDiv_.tabIndex=0,St(this.contentsDiv_,lt.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"),U(e,"blocklyToolboxDiv"),U(e,"blocklyNonSelectable"),e.setAttribute("dir",this.RTL?"RTL":"LTR"),e}createContentsContainer_(){const e=document.createElement("div");return U(e,"blocklyToolboxContents"),this.isHorizontal()&&(e.style.flexDirection="row"),e}attachEvents_(e,t){e=w(e,"pointerdown",this,this.onClick_,!1),this.boundEvents_.push(e),t=w(t,"keydown",this,this.onKeyDown_,!1),this.boundEvents_.push(t)}onClick_(e){if(ro(e)||e.target===this.HtmlDiv)Y().hideChaff(!1);else{var t=e.target.getAttribute("id");t&&(t=this.getToolboxItemById(t),t.isSelectable()&&(this.setSelectedItem(t),t.onClick(e))),Y().hideChaff(!0)}Ut()}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=new kt({parentWorkspace:e,rtl:e.RTL,oneBasedIndex:e.options.oneBasedIndex,horizontalLayout:e.horizontalLayout,renderer:e.options.renderer,rendererOverrides:e.options.rendererOverrides,move:{scrollbars:!0}});return t.toolboxPosition=e.options.toolboxPosition,new(e.horizontalLayout?b(A.FLYOUTS_HORIZONTAL_TOOLBOX,e.options,!0):b(A.FLYOUTS_VERTICAL_TOOLBOX,e.options,!0))(t)}render(e){this.toolboxDef_=e;for(let t=0;t<this.contents_.length;t++){const o=this.contents_[t];o&&o.dispose()}this.contents_=[],this.contentMap_=Object.create(null),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"&&Ji(e)&&(o=tr.registrationName),(o=l(A.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_.push(e),this.contentMap_[e.getId()]=e,e.isCollapsible()){e=e.getChildToolboxItems();for(let t=0;t<e.length;t++)this.addToolboxItem_(e[t])}}getToolboxItems(){return this.contents_}addStyle(e){e&&this.HtmlDiv&&U(this.HtmlDiv,e)}removeStyle(e){e&&this.HtmlDiv&&se(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===V.TOP?new Se(-1e7,o,-1e7,1e7):this.toolboxPosition===V.BOTTOM?new Se(t,1e7,-1e7,1e7):this.toolboxPosition===V.LEFT?new Se(-1e7,1e7,-1e7,e):new Se(-1e7,1e7,s,1e7)}wouldDelete(e,t){return e instanceof mt?this.updateWouldDelete_(!e.getParent()&&e.isDeletable()):this.updateWouldDelete_(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.contentMap_[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===V.TOP?t.style.top="0":t.style.bottom="0"):(this.toolboxPosition===V.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_,t=this.HtmlDiv.getBoundingClientRect();e.translate(this.toolboxPosition===V.LEFT?e.scrollX+t.width:e.scrollX,this.toolboxPosition===V.TOP?e.scrollY+t.height:e.scrollY),Pt(e)}clearSelection(){this.setSelectedItem(null)}refreshTheme(){for(let e=0;e<this.contents_.length;e++){const t=this.contents_[e];t.refreshTheme&&t.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&&!n_(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),ge(this.contentsDiv_,pe.ACTIVEDESCENDANT,"")}selectItem_(e,t){this.selectedItem_=t,this.previouslySelectedItem_=e,t.setSelected(!0),ge(this.contentsDiv_,pe.ACTIVEDESCENDANT,t.getId())}selectItemByPosition(e){-1<e&&e<this.contents_.length&&(e=this.contents_[e],e.isSelectable()&&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(F(Pr))(o,s,this.workspace_.id),x(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;let e=this.contents_.indexOf(this.selectedItem_)+1;if(-1<e&&e<this.contents_.length){let t=this.contents_[e];for(;t&&!t.isSelectable();)t=this.contents_[++e];if(t&&t.isSelectable())return this.setSelectedItem(t),!0}return!1}selectPrevious_(){if(!this.selectedItem_)return!1;let e=this.contents_.indexOf(this.selectedItem_)-1;if(-1<e&&e<this.contents_.length){let t=this.contents_[e];for(;t&&!t.isSelectable();)t=this.contents_[--e];if(t&&t.isSelectable())return this.setSelectedItem(t),!0}return!1}dispose(){this.workspace_.getComponentManager().removeComponent("toolbox"),this.flyout_.dispose();for(var e=0;e<this.contents_.length;e++)this.contents_[e].dispose();for(e=0;e<this.boundEvents_.length;e++)ce(this.boundEvents_[e]);this.boundEvents_=[],this.contents_=[],this.HtmlDiv&&(this.workspace_.getThemeManager().unsubscribe(this.HtmlDiv),re(this.HtmlDiv))}};Tt(`
|
|
762
|
+
.blocklyToolboxDelete {
|
|
763
|
+
cursor: url("<<<PATH>>>/handdelete.cur"), auto;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.blocklyToolboxGrab {
|
|
767
|
+
cursor: url("<<<PATH>>>/handclosed.cur"), auto;
|
|
768
|
+
cursor: grabbing;
|
|
769
|
+
cursor: -webkit-grabbing;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/* Category tree in Toolbox. */
|
|
773
|
+
.blocklyToolboxDiv {
|
|
774
|
+
background-color: #ddd;
|
|
775
|
+
overflow-x: visible;
|
|
776
|
+
overflow-y: auto;
|
|
777
|
+
padding: 4px 0 4px 0;
|
|
778
|
+
position: absolute;
|
|
779
|
+
z-index: 70; /* so blocks go under toolbox when dragging */
|
|
780
|
+
-webkit-tap-highlight-color: transparent; /* issue #1345 */
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.blocklyToolboxContents {
|
|
784
|
+
display: flex;
|
|
785
|
+
flex-wrap: wrap;
|
|
786
|
+
flex-direction: column;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.blocklyToolboxContents:focus {
|
|
790
|
+
outline: none;
|
|
791
|
+
}
|
|
792
|
+
`),r(A.TOOLBOX,no,bg);var Rg=class extends Bn{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,0>=this.workspace.options.maxTrashcanContents||(e=new kt({scrollbars:!0,parentWorkspace:this.workspace,rtl:this.workspace.RTL,oneBasedIndex:this.workspace.options.oneBasedIndex,renderer:this.workspace.options.renderer,rendererOverrides:this.workspace.options.rendererOverrides,move:{scrollbars:!0}}),this.workspace.horizontalLayout?(e.toolboxPosition=this.workspace.toolboxPosition===V.TOP?V.BOTTOM:V.TOP,this.flyout=new(b(A.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===V.RIGHT?V.LEFT:V.RIGHT,this.flyout=new(b(A.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete.bind(this)))}createDom(){this.svgGroup=I(f.G,{class:"blocklyTrash"});let e;const t=String(Math.random()).substring(2);e=I(f.CLIPPATH,{id:"blocklyTrashBodyClipPath"+t},this.svgGroup),I(f.RECT,{width:or,height:Wn,y:sr},e);const o=I(f.IMAGE,{width:Qe.width,x:-Nu,height:Qe.height,y:-yu,"clip-path":"url(#blocklyTrashBodyClipPath"+t+")"},this.svgGroup);return o.setAttributeNS(it,"xlink:href",this.workspace.options.pathToMedia+Qe.url),e=I(f.CLIPPATH,{id:"blocklyTrashLidClipPath"+t},this.svgGroup),I(f.RECT,{width:or,height:sr},e),this.svgLid=I(f.IMAGE,{width:Qe.width,x:-Nu,height:Qe.height,y:-yu,"clip-path":"url(#blocklyTrashLidClipPath"+t+")"},this.svgGroup),this.svgLid.setAttributeNS(it,"xlink:href",this.workspace.options.pathToMedia+Qe.url),Ye(this.svgGroup,"pointerdown",this,this.blockMouseDownWhenOpenable),Ye(this.svgGroup,"pointerup",this,this.click),Ye(o,"pointerover",this,this.mouseOver),Ye(o,"pointerout",this,this.mouseOut),this.animateLid(),this.svgGroup}init(){0<this.workspace.options.maxTrashcanContents&&(Rt(this.flyout.createDom(f.SVG),this.workspace.getParentSvg()),this.flyout.init(this.workspace)),this.workspace.getComponentManager().addComponent({component:this,weight:1,capabilities:[Be.Capability.AUTOHIDEABLE,Be.Capability.DELETE_AREA,Be.Capability.DRAG_TARGET,Be.Capability.POSITIONABLE]}),this.initialized=!0,this.setLidOpen(!1)}dispose(){this.workspace.getComponentManager().removeComponent("trashcan"),this.svgGroup&&re(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=""},10),this.fireUiEvent(!0)}}closeFlyout(){if(this.contentsIsOpen()){var e;(e=this.flyout)==null||e.hide(),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=un(this.workspace,e);e=cn(o,new Pe(or,Wn+sr),bT,Ig,e,this.workspace),t=hn(e,Ig,o.vertical===To.TOP?Po.DOWN:Po.UP,t),this.top=t.top,this.left=t.left;var s;(s=this.svgGroup)==null||s.setAttribute("transform","translate("+this.left+","+this.top+")")}}getBoundingRectangle(){return new Se(this.top,this.top+Wn+sr,this.left,this.left+or)}getClientRect(){if(!this.svgGroup)return null;var e=this.svgGroup.getBoundingClientRect();const t=e.top+yu-Xn;return e=e.left+Nu-Xn,new Se(t,t+sr+Wn+2*Xn,e,e+or+2*Xn)}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=OT;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*Sg),t=Og+this.lidOpen*(ST-Og),this.svgGroup&&(this.svgGroup.style.opacity=`${t}`),this.lidOpen>this.minOpenness&&1>this.lidOpen&&(this.lidTask=setTimeout(this.animateLid.bind(this),IT/e))}setLidAngle(e){const t=this.workspace.toolboxPosition===V.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let o;(o=this.svgLid)==null||o.setAttribute("transform","rotate("+(t?-e:e)+","+(t?4:or-4)+","+(sr-2)+")")}setMinOpenness(e){this.minOpenness=e,this.isLidOpen||this.setLidAngle(e*Sg)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents()&&this.openFlyout()}fireUiEvent(e){e=new(F(Gr))(e,this.workspace.id),x(e)}blockMouseDownWhenOpenable(e){!this.contentsIsOpen()&&this.hasContents()&&e.stopPropagation()}mouseOver(){this.hasContents()&&this.setLidOpen(!0)}mouseOut(){this.setLidOpen(!1)}onDelete(e){if(!(0>=this.workspace.options.maxTrashcanContents||e.type!==jt||e.type!==jt||e.wasShadow)){if(!e.oldJson)throw Error("Encountered a delete event without proper oldJson");if(e=JSON.stringify(this.cleanBlockJson(e.oldJson)),this.contents.indexOf(e)===-1){for(this.contents.unshift(e);this.contents.length>this.workspace.options.maxTrashcanContents;)this.contents.pop();this.setMinOpenness(RT)}}}cleanBlockJson(e){function t(o){if(o){if(delete o.id,delete o.x,delete o.y,delete o.enabled,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 a=s[i];const p=a.block;a=a.shadow,p&&t(p),a&&t(a)}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)}},or=47,Wn=44,sr=16,Ig=20,bT=20,Xn=10,Nu=0,yu=32,RT=.1,IT=80,OT=4,Og=.4,ST=.8,Sg=45,oe={};oe.Coordinate=L,oe.KeyCodes=J,oe.Rect=Se,oe.Size=Pe,oe.Svg=f,oe.aria=Jr,oe.array=mp,oe.arrayRemove=p_,oe.browserEvents=uo,oe.checkMessageReferences=h_,oe.colour=je,oe.deprecation=we,oe.dom=De,oe.extensions=n.module$build$src$core$extensions,oe.getBlockTypeCounts=T_,oe.getDocumentScroll=g_,oe.getInjectionDivXY_=a_,oe.getRelativeXY=l_,oe.getViewportBBox=__,oe.idGenerator=_n,oe.is3dSupported=d_,oe.math=Cn,oe.object=qr,oe.parseBlockColour=E_,oe.parsing=zr,oe.replaceMessageReferences=u_,oe.runAfterPageLoad=m_,oe.screenToWsCoordinates=$_,oe.string=n.module$build$src$core$utils$string,oe.style=zt,oe.svgMath=Lo,oe.svgPaths=po,oe.tokenizeInterpolation=c_,oe.toolbox=Do,oe.userAgent=co,oe.xml=n.module$build$src$core$utils$xml;var vT="9.3.1",CT=n.Align$$module$build$src$core$input.LEFT,NT=n.Align$$module$build$src$core$input.CENTRE,yT=n.Align$$module$build$src$core$input.RIGHT,AT=M.INPUT_VALUE,LT=M.OUTPUT_VALUE,kT=M.NEXT_STATEMENT,DT=M.PREVIOUS_STATEMENT,MT=X.DUMMY,wT=V.TOP,GT=V.BOTTOM,PT=V.LEFT,BT=V.RIGHT;pi.prototype.newBlock=function(e,t){return new Ks(this,e,t)},Mt.prototype.newBlock=function(e,t){return new mt(this,e,t)},Mt.newTrashcan=function(e){return new Rg(e)},Xe.prototype.showContextMenu=function(e){if(!this.workspace.options.readOnly){var t=[];this.isDeletable()&&this.isMovable()&&(t.push(aa(this)),t.push(la(this))),Cr(e,t,this.RTL)}},n.Mutator$$module$build$src$core$mutator.prototype.newWorkspaceSvg=function(e){return new Mt(e)},Ze.prototype.populateProcedures=function(e){e=nn(e),e=e[0].concat(e[1]);for(let t=0;t<e.length;t++)this.getName(e[t][0],Ze.NameType.PROCEDURE)};var xT=M,R={};return R.ALIGN_CENTRE=NT,R.ALIGN_LEFT=CT,R.ALIGN_RIGHT=yT,R.ASTNode=y,R.BasicCursor=ri,R.Block=Ks,R.BlockDragSurfaceSvg=fp,R.BlockDragger=Rp,R.BlockSvg=mt,R.Blocks=rt,R.Bubble=W,R.BubbleDragger=yp,R.COLLAPSED_FIELD_NAME=vn,R.COLLAPSED_INPUT_NAME=xs,R.COLLAPSE_CHARS=Op,R.CodeGenerator=n.CodeGenerator$$module$build$src$core$generator,R.CollapsibleToolboxCategory=tr,R.Comment=Ip,R.ComponentManager=Be,R.Connection=ie,R.ConnectionChecker=Ap,R.ConnectionDB=zs,R.ConnectionType=M,R.ContextMenu=n.module$build$src$core$contextmenu,R.ContextMenuItems=qe,R.ContextMenuRegistry=le,R.Css=Tc,R.Cursor=Xc,R.DELETE_VARIABLE_ID=Wc,R.DRAG_STACK=Sp,R.DUMMY_INPUT=MT,R.DeleteArea=Bn,R.DragTarget=Lp,R.DropDownDiv=ye,R.Events=n.module$build$src$core$events$events,R.Extensions=n.module$build$src$core$extensions,R.Field=ee,R.FieldAngle=z,R.FieldCheckbox=ns,R.FieldColour=_t,R.FieldDropdown=Jt,R.FieldImage=ls,R.FieldLabel=Mo,R.FieldLabelSerializable=kp,R.FieldMultilineInput=au,R.FieldNumber=cu,R.FieldTextInput=Js,R.FieldVariable=ni,R.Flyout=Vn,R.FlyoutButton=Dt,R.FlyoutMetricsManager=Dp,R.Generator=n.CodeGenerator$$module$build$src$core$generator,R.Gesture=qt,R.Grid=du,R.HorizontalFlyout=Xp,R.INPUT_VALUE=AT,R.Icon=Dn,R.Input=Ys,R.InsertionMarkerManager=dt,R.Marker=vp,R.MarkerManager=jr,R.Menu=Dc,R.MenuItem=Mc,R.MetricsManager=uu,R.Msg=H,R.Mutator=n.Mutator$$module$build$src$core$mutator,R.NEXT_STATEMENT=kT,R.Names=Ze,R.OPPOSITE_TYPE=is,R.OUTPUT_VALUE=LT,R.Options=kt,R.PREVIOUS_STATEMENT=DT,R.PROCEDURE_CATEGORY_NAME=Fn,R.Procedures=n.module$build$src$core$procedures,R.RENAME_VARIABLE_ID=Vc,R.RenderedConnection=Je,R.Scrollbar=me,R.ScrollbarPair=hu,R.ShortcutItems=to,R.ShortcutRegistry=ue,R.TOOLBOX_AT_BOTTOM=GT,R.TOOLBOX_AT_LEFT=PT,R.TOOLBOX_AT_RIGHT=BT,R.TOOLBOX_AT_TOP=wT,R.TabNavigateCursor=Cp,R.Theme=rs,R.ThemeManager=Hp,R.Themes=vu,R.Toolbox=bg,R.ToolboxCategory=Gt,R.ToolboxItem=Cu,R.ToolboxSeparator=Ti,R.Tooltip=Ae,R.Touch=ht,R.TouchGesture=qt,R.Trashcan=Rg,R.UnattachedFieldError=Le,R.VARIABLE_CATEGORY_NAME=$n,R.VARIABLE_DYNAMIC_CATEGORY_NAME=bu,R.VERSION=vT,R.VariableMap=Ru,R.VariableModel=Ur,R.Variables=n.module$build$src$core$variables,R.VariablesDynamic=Go,R.VerticalFlyout=Iu,R.Warning=Np,R.WidgetDiv=Lt,R.Workspace=pi,R.WorkspaceAudio=Vp,R.WorkspaceComment=Kt,R.WorkspaceCommentSvg=Xe,R.WorkspaceDragSurfaceSvg=jp,R.WorkspaceDragger=Mp,R.WorkspaceSvg=Mt,R.Xml=n.module$build$src$core$xml,R.ZoomControls=Wp,R.bindEventWithChecks_=y_,R.bindEvent_=C_,R.blockAnimations=ei,R.blockRendering=ae,R.browserEvents=uo,R.bumpObjects=wn,R.clipboard=ti,R.common=n.module$build$src$core$common,R.config=n.config$$module$build$src$core$config,R.connectionTypes=xT,R.constants=fc,R.copy=R_,R.defineBlocksWithJsonArray=lr,R.dialog=nt,R.duplicate=O_,R.fieldRegistry=n.module$build$src$core$field_registry,R.geras=Qt,R.getMainWorkspace=Y,R.getSelected=_e,R.hideChaff=f_,R.hueToHex=v_,R.inject=qd,R.inputTypes=X,R.isNumber=S_,R.isObservable=rn,R.isVariableBackedParameterModel=Yn,R.minimalist=gi,R.paste=I_,R.procedures=n.module$build$src$core$procedures,R.registry=vt,R.resizeSvgContents=b_,R.serialization=$T,R.setLocale=ic,R.setParentContainer=nr,R.svgResize=Pt,R.thrasos=Ou,R.uiPosition=us,R.unbindEvent_=N_,R.utils=oe,R.zelos=wt,n.module$build$src$core$contextmenu,n.module$build$src$core$events$events,n.module$build$src$core$msg,n.module$build$src$core$common,Object.defineProperties(R,{alert:{set:function(e){we.warn("Blockly.alert","version 9","version 10","Blockly.dialog.setAlert"),nt.setAlert(e)},get:function(){return we.warn("Blockly.alert","version 9","version 10","Blockly.dialog.alert"),nt.alert}},confirm:{set:function(e){we.warn("Blockly.confirm","version 9","version 10","Blockly.dialog.setConfirm"),nt.setConfirm(e)},get:function(){return we.warn("Blockly.confirm","version 9","version 10","Blockly.dialog.confirm"),nt.confirm}},mainWorkspace:{set:function(e){we.warn("Blockly.mainWorkspace","version 9","version 10","Blockly.getMainWorkspace"),n.module$build$src$core$common.setMainWorkspace(e)},get:function(){return we.warn("Blockly.mainWorkspace","version 9","version 10","Blockly.getMainWorkspace"),n.module$build$src$core$common.getMainWorkspace()}},prompt:{set:function(e){we.warn("Blockly.prompt","version 9","version 10","Blockly.dialog.setPrompt"),nt.setPrompt(e)},get:function(){return we.warn("Blockly.prompt","version 9","version 10","Blockly.dialog.prompt"),nt.prompt}},selected:{get:function(){return we.warn("Blockly.selected","version 9","version 10","Blockly.getSelected"),n.module$build$src$core$common.getSelected()},set:function(e){we.warn("Blockly.selected","version 9","version 10","Blockly.getSelected"),n.module$build$src$core$common.setSelected(e)}},HSV_SATURATION:{get:function(){return je.getHsvSaturation()},set:function(e){je.setHsvSaturation(e)}},HSV_VALUE:{get:function(){return je.getHsvValue()},set:function(e){je.setHsvValue(e)}}}),Object.defineProperties(n.module$build$src$core$contextmenu,{currentBlock:{get:function(){return we.warn("Blockly.ContextMenu.currentBlock","September 2021","September 2022","Blockly.Tooltip.getCurrentBlock()"),n.module$build$src$core$contextmenu.getCurrentBlock()},set:function(e){we.warn("Blockly.ContextMenu.currentBlock","September 2021","September 2022","Blockly.Tooltip.setCurrentBlock(block)"),n.module$build$src$core$contextmenu.setCurrentBlock(e)}}}),Object.defineProperties(n.module$build$src$core$events$events,{recordUndo:{get:function(){return we.warn("Blockly.Events.recordUndo","September 2021","September 2022","Blockly.Events.getRecordUndo()"),j.getRecordUndo()},set:function(e){we.warn("Blockly.Events.recordUndo","September 2021","September 2022","Blockly.Events.setRecordUndo()"),j.setRecordUndo(e)}}}),Object.defineProperties(Ae,{visible:{get:function(){return we.warn("Blockly.Tooltip.visible","September 2021","September 2022","Blockly.Tooltip.isVisible()"),Ae.isVisible()}},DIV:{get:function(){return we.warn("Blockly.Tooltip.DIV","September 2021","September 2022","Blockly.Tooltip.getDiv()"),Ae.getDiv()}}}),Object.defineProperties(Lt,{DIV:{get:function(){return we.warn("Blockly.WidgetDiv.DIV","September 2021","September 2022","Blockly.WidgetDiv.getDiv()"),Lt.getDiv()}}}),"Blockly"in globalThis||(globalThis.Blockly={Msg:n.module$build$src$core$msg}),R.__namespace__=n,R})}(Mu)),Mu.exports}var Lg;function HT(){return Lg||(Lg=1,function(q,xe){(function(n,_){q.exports=_($i())})(Ve,function(n){/**
|
|
793
|
+
* @license
|
|
794
|
+
* Copyright 2020 Google LLC
|
|
795
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
796
|
+
*/return n})}(Du)),Du.exports}var kg;function jn(){return kg||(kg=1,function(q,xe){(function(n,_){q.exports=_(HT())})(Ve,function(n){return n})}(ku)),ku.exports}var wu={exports:{}},Dg;function Hg(){return Dg||(Dg=1,function(q,xe){(function(n,_){q.exports=_()})(Ve,function(){var n=n||{Msg:Object.create(null)};return n.Msg.ADD_COMMENT="Add Comment",n.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE="Can't delete the variable '%1' because it's part of the definition of the function '%2'",n.Msg.CHANGE_VALUE_TITLE="Change value:",n.Msg.CLEAN_UP="Clean up Blocks",n.Msg.COLLAPSED_WARNINGS_WARNING="Collapsed blocks contain warnings.",n.Msg.COLLAPSE_ALL="Collapse Blocks",n.Msg.COLLAPSE_BLOCK="Collapse Block",n.Msg.COLOUR_BLEND_COLOUR1="colour 1",n.Msg.COLOUR_BLEND_COLOUR2="colour 2",n.Msg.COLOUR_BLEND_HELPURL="https://meyerweb.com/eric/tools/color-blend/#:::rgbp",n.Msg.COLOUR_BLEND_RATIO="ratio",n.Msg.COLOUR_BLEND_TITLE="blend",n.Msg.COLOUR_BLEND_TOOLTIP="Blends two colours together with a given ratio (0.0 - 1.0).",n.Msg.COLOUR_PICKER_HELPURL="https://en.wikipedia.org/wiki/Color",n.Msg.COLOUR_PICKER_TOOLTIP="Choose a colour from the palette.",n.Msg.COLOUR_RANDOM_HELPURL="http://randomcolour.com",n.Msg.COLOUR_RANDOM_TITLE="random colour",n.Msg.COLOUR_RANDOM_TOOLTIP="Choose a colour at random.",n.Msg.COLOUR_RGB_BLUE="blue",n.Msg.COLOUR_RGB_GREEN="green",n.Msg.COLOUR_RGB_HELPURL="https://www.december.com/html/spec/colorpercompact.html",n.Msg.COLOUR_RGB_RED="red",n.Msg.COLOUR_RGB_TITLE="colour with",n.Msg.COLOUR_RGB_TOOLTIP="Create a colour with the specified amount of red, green, and blue. All values must be between 0 and 100.",n.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL="https://github.com/google/blockly/wiki/Loops#loop-termination-blocks",n.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK="break out of loop",n.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE="continue with next iteration of loop",n.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK="Break out of the containing loop.",n.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE="Skip the rest of this loop, and continue with the next iteration.",n.Msg.CONTROLS_FLOW_STATEMENTS_WARNING="Warning: This block may only be used within a loop.",n.Msg.CONTROLS_FOREACH_HELPURL="https://github.com/google/blockly/wiki/Loops#for-each",n.Msg.CONTROLS_FOREACH_TITLE="for each item %1 in list %2",n.Msg.CONTROLS_FOREACH_TOOLTIP="For each item in a list, set the variable '%1' to the item, and then do some statements.",n.Msg.CONTROLS_FOR_HELPURL="https://github.com/google/blockly/wiki/Loops#count-with",n.Msg.CONTROLS_FOR_TITLE="count with %1 from %2 to %3 by %4",n.Msg.CONTROLS_FOR_TOOLTIP="Have the variable '%1' take on the values from the start number to the end number, counting by the specified interval, and do the specified blocks.",n.Msg.CONTROLS_IF_ELSEIF_TOOLTIP="Add a condition to the if block.",n.Msg.CONTROLS_IF_ELSE_TOOLTIP="Add a final, catch-all condition to the if block.",n.Msg.CONTROLS_IF_HELPURL="https://github.com/google/blockly/wiki/IfElse",n.Msg.CONTROLS_IF_IF_TOOLTIP="Add, remove, or reorder sections to reconfigure this if block.",n.Msg.CONTROLS_IF_MSG_ELSE="else",n.Msg.CONTROLS_IF_MSG_ELSEIF="else if",n.Msg.CONTROLS_IF_MSG_IF="if",n.Msg.CONTROLS_IF_TOOLTIP_1="If a value is true, then do some statements.",n.Msg.CONTROLS_IF_TOOLTIP_2="If a value is true, then do the first block of statements. Otherwise, do the second block of statements.",n.Msg.CONTROLS_IF_TOOLTIP_3="If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements.",n.Msg.CONTROLS_IF_TOOLTIP_4="If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements. If none of the values are true, do the last block of statements.",n.Msg.CONTROLS_REPEAT_HELPURL="https://en.wikipedia.org/wiki/For_loop",n.Msg.CONTROLS_REPEAT_INPUT_DO="do",n.Msg.CONTROLS_REPEAT_TITLE="repeat %1 times",n.Msg.CONTROLS_REPEAT_TOOLTIP="Do some statements several times.",n.Msg.CONTROLS_WHILEUNTIL_HELPURL="https://github.com/google/blockly/wiki/Loops#repeat",n.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL="repeat until",n.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE="repeat while",n.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL="While a value is false, then do some statements.",n.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE="While a value is true, then do some statements.",n.Msg.DELETE_ALL_BLOCKS="Delete all %1 blocks?",n.Msg.DELETE_BLOCK="Delete Block",n.Msg.DELETE_VARIABLE="Delete the '%1' variable",n.Msg.DELETE_VARIABLE_CONFIRMATION="Delete %1 uses of the '%2' variable?",n.Msg.DELETE_X_BLOCKS="Delete %1 Blocks",n.Msg.DIALOG_CANCEL="Cancel",n.Msg.DIALOG_OK="OK",n.Msg.DISABLE_BLOCK="Disable Block",n.Msg.DUPLICATE_BLOCK="Duplicate",n.Msg.DUPLICATE_COMMENT="Duplicate Comment",n.Msg.ENABLE_BLOCK="Enable Block",n.Msg.EXPAND_ALL="Expand Blocks",n.Msg.EXPAND_BLOCK="Expand Block",n.Msg.EXTERNAL_INPUTS="External Inputs",n.Msg.HELP="Help",n.Msg.INLINE_INPUTS="Inline Inputs",n.Msg.LISTS_CREATE_EMPTY_HELPURL="https://github.com/google/blockly/wiki/Lists#create-empty-list",n.Msg.LISTS_CREATE_EMPTY_TITLE="create empty list",n.Msg.LISTS_CREATE_EMPTY_TOOLTIP="Returns a list, of length 0, containing no data records",n.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD="list",n.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP="Add, remove, or reorder sections to reconfigure this list block.",n.Msg.LISTS_CREATE_WITH_HELPURL="https://github.com/google/blockly/wiki/Lists#create-list-with",n.Msg.LISTS_CREATE_WITH_INPUT_WITH="create list with",n.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP="Add an item to the list.",n.Msg.LISTS_CREATE_WITH_TOOLTIP="Create a list with any number of items.",n.Msg.LISTS_GET_INDEX_FIRST="first",n.Msg.LISTS_GET_INDEX_FROM_END="# from end",n.Msg.LISTS_GET_INDEX_FROM_START="#",n.Msg.LISTS_GET_INDEX_GET="get",n.Msg.LISTS_GET_INDEX_GET_REMOVE="get and remove",n.Msg.LISTS_GET_INDEX_LAST="last",n.Msg.LISTS_GET_INDEX_RANDOM="random",n.Msg.LISTS_GET_INDEX_REMOVE="remove",n.Msg.LISTS_GET_INDEX_TAIL="",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST="Returns the first item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM="Returns the item at the specified position in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST="Returns the last item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM="Returns a random item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST="Removes and returns the first item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM="Removes and returns the item at the specified position in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST="Removes and returns the last item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM="Removes and returns a random item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST="Removes the first item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM="Removes the item at the specified position in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST="Removes the last item in a list.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM="Removes a random item in a list.",n.Msg.LISTS_GET_SUBLIST_END_FROM_END="to # from end",n.Msg.LISTS_GET_SUBLIST_END_FROM_START="to #",n.Msg.LISTS_GET_SUBLIST_END_LAST="to last",n.Msg.LISTS_GET_SUBLIST_HELPURL="https://github.com/google/blockly/wiki/Lists#getting-a-sublist",n.Msg.LISTS_GET_SUBLIST_START_FIRST="get sub-list from first",n.Msg.LISTS_GET_SUBLIST_START_FROM_END="get sub-list from # from end",n.Msg.LISTS_GET_SUBLIST_START_FROM_START="get sub-list from #",n.Msg.LISTS_GET_SUBLIST_TAIL="",n.Msg.LISTS_GET_SUBLIST_TOOLTIP="Creates a copy of the specified portion of a list.",n.Msg.LISTS_INDEX_FROM_END_TOOLTIP="%1 is the last item.",n.Msg.LISTS_INDEX_FROM_START_TOOLTIP="%1 is the first item.",n.Msg.LISTS_INDEX_OF_FIRST="find first occurrence of item",n.Msg.LISTS_INDEX_OF_HELPURL="https://github.com/google/blockly/wiki/Lists#getting-items-from-a-list",n.Msg.LISTS_INDEX_OF_LAST="find last occurrence of item",n.Msg.LISTS_INDEX_OF_TOOLTIP="Returns the index of the first/last occurrence of the item in the list. Returns %1 if item is not found.",n.Msg.LISTS_INLIST="in list",n.Msg.LISTS_ISEMPTY_HELPURL="https://github.com/google/blockly/wiki/Lists#is-empty",n.Msg.LISTS_ISEMPTY_TITLE="%1 is empty",n.Msg.LISTS_ISEMPTY_TOOLTIP="Returns true if the list is empty.",n.Msg.LISTS_LENGTH_HELPURL="https://github.com/google/blockly/wiki/Lists#length-of",n.Msg.LISTS_LENGTH_TITLE="length of %1",n.Msg.LISTS_LENGTH_TOOLTIP="Returns the length of a list.",n.Msg.LISTS_REPEAT_HELPURL="https://github.com/google/blockly/wiki/Lists#create-list-with",n.Msg.LISTS_REPEAT_TITLE="create list with item %1 repeated %2 times",n.Msg.LISTS_REPEAT_TOOLTIP="Creates a list consisting of the given value repeated the specified number of times.",n.Msg.LISTS_REVERSE_HELPURL="https://github.com/google/blockly/wiki/Lists#reversing-a-list",n.Msg.LISTS_REVERSE_MESSAGE0="reverse %1",n.Msg.LISTS_REVERSE_TOOLTIP="Reverse a copy of a list.",n.Msg.LISTS_SET_INDEX_HELPURL="https://github.com/google/blockly/wiki/Lists#in-list--set",n.Msg.LISTS_SET_INDEX_INPUT_TO="as",n.Msg.LISTS_SET_INDEX_INSERT="insert at",n.Msg.LISTS_SET_INDEX_SET="set",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST="Inserts the item at the start of a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM="Inserts the item at the specified position in a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST="Append the item to the end of a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM="Inserts the item randomly in a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST="Sets the first item in a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM="Sets the item at the specified position in a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST="Sets the last item in a list.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM="Sets a random item in a list.",n.Msg.LISTS_SORT_HELPURL="https://github.com/google/blockly/wiki/Lists#sorting-a-list",n.Msg.LISTS_SORT_ORDER_ASCENDING="ascending",n.Msg.LISTS_SORT_ORDER_DESCENDING="descending",n.Msg.LISTS_SORT_TITLE="sort %1 %2 %3",n.Msg.LISTS_SORT_TOOLTIP="Sort a copy of a list.",n.Msg.LISTS_SORT_TYPE_IGNORECASE="alphabetic, ignore case",n.Msg.LISTS_SORT_TYPE_NUMERIC="numeric",n.Msg.LISTS_SORT_TYPE_TEXT="alphabetic",n.Msg.LISTS_SPLIT_HELPURL="https://github.com/google/blockly/wiki/Lists#splitting-strings-and-joining-lists",n.Msg.LISTS_SPLIT_LIST_FROM_TEXT="make list from text",n.Msg.LISTS_SPLIT_TEXT_FROM_LIST="make text from list",n.Msg.LISTS_SPLIT_TOOLTIP_JOIN="Join a list of texts into one text, separated by a delimiter.",n.Msg.LISTS_SPLIT_TOOLTIP_SPLIT="Split text into a list of texts, breaking at each delimiter.",n.Msg.LISTS_SPLIT_WITH_DELIMITER="with delimiter",n.Msg.LOGIC_BOOLEAN_FALSE="false",n.Msg.LOGIC_BOOLEAN_HELPURL="https://github.com/google/blockly/wiki/Logic#values",n.Msg.LOGIC_BOOLEAN_TOOLTIP="Returns either true or false.",n.Msg.LOGIC_BOOLEAN_TRUE="true",n.Msg.LOGIC_COMPARE_HELPURL="https://en.wikipedia.org/wiki/Inequality_(mathematics)",n.Msg.LOGIC_COMPARE_TOOLTIP_EQ="Return true if both inputs equal each other.",n.Msg.LOGIC_COMPARE_TOOLTIP_GT="Return true if the first input is greater than the second input.",n.Msg.LOGIC_COMPARE_TOOLTIP_GTE="Return true if the first input is greater than or equal to the second input.",n.Msg.LOGIC_COMPARE_TOOLTIP_LT="Return true if the first input is smaller than the second input.",n.Msg.LOGIC_COMPARE_TOOLTIP_LTE="Return true if the first input is smaller than or equal to the second input.",n.Msg.LOGIC_COMPARE_TOOLTIP_NEQ="Return true if both inputs are not equal to each other.",n.Msg.LOGIC_NEGATE_HELPURL="https://github.com/google/blockly/wiki/Logic#not",n.Msg.LOGIC_NEGATE_TITLE="not %1",n.Msg.LOGIC_NEGATE_TOOLTIP="Returns true if the input is false. Returns false if the input is true.",n.Msg.LOGIC_NULL="null",n.Msg.LOGIC_NULL_HELPURL="https://en.wikipedia.org/wiki/Nullable_type",n.Msg.LOGIC_NULL_TOOLTIP="Returns null.",n.Msg.LOGIC_OPERATION_AND="and",n.Msg.LOGIC_OPERATION_HELPURL="https://github.com/google/blockly/wiki/Logic#logical-operations",n.Msg.LOGIC_OPERATION_OR="or",n.Msg.LOGIC_OPERATION_TOOLTIP_AND="Return true if both inputs are true.",n.Msg.LOGIC_OPERATION_TOOLTIP_OR="Return true if at least one of the inputs is true.",n.Msg.LOGIC_TERNARY_CONDITION="test",n.Msg.LOGIC_TERNARY_HELPURL="https://en.wikipedia.org/wiki/%3F:",n.Msg.LOGIC_TERNARY_IF_FALSE="if false",n.Msg.LOGIC_TERNARY_IF_TRUE="if true",n.Msg.LOGIC_TERNARY_TOOLTIP="Check the condition in 'test'. If the condition is true, returns the 'if true' value; otherwise returns the 'if false' value.",n.Msg.MATH_ADDITION_SYMBOL="+",n.Msg.MATH_ARITHMETIC_HELPURL="https://en.wikipedia.org/wiki/Arithmetic",n.Msg.MATH_ARITHMETIC_TOOLTIP_ADD="Return the sum of the two numbers.",n.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE="Return the quotient of the two numbers.",n.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS="Return the difference of the two numbers.",n.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY="Return the product of the two numbers.",n.Msg.MATH_ARITHMETIC_TOOLTIP_POWER="Return the first number raised to the power of the second number.",n.Msg.MATH_ATAN2_HELPURL="https://en.wikipedia.org/wiki/Atan2",n.Msg.MATH_ATAN2_TITLE="atan2 of X:%1 Y:%2",n.Msg.MATH_ATAN2_TOOLTIP="Return the arctangent of point (X, Y) in degrees from -180 to 180.",n.Msg.MATH_CHANGE_HELPURL="https://en.wikipedia.org/wiki/Programming_idiom#Incrementing_a_counter",n.Msg.MATH_CHANGE_TITLE="change %1 by %2",n.Msg.MATH_CHANGE_TOOLTIP="Add a number to variable '%1'.",n.Msg.MATH_CONSTANT_HELPURL="https://en.wikipedia.org/wiki/Mathematical_constant",n.Msg.MATH_CONSTANT_TOOLTIP="Return one of the common constants: π (3.141…), e (2.718…), φ (1.618…), sqrt(2) (1.414…), sqrt(½) (0.707…), or ∞ (infinity).",n.Msg.MATH_CONSTRAIN_HELPURL="https://en.wikipedia.org/wiki/Clamping_(graphics)",n.Msg.MATH_CONSTRAIN_TITLE="constrain %1 low %2 high %3",n.Msg.MATH_CONSTRAIN_TOOLTIP="Constrain a number to be between the specified limits (inclusive).",n.Msg.MATH_DIVISION_SYMBOL="÷",n.Msg.MATH_IS_DIVISIBLE_BY="is divisible by",n.Msg.MATH_IS_EVEN="is even",n.Msg.MATH_IS_NEGATIVE="is negative",n.Msg.MATH_IS_ODD="is odd",n.Msg.MATH_IS_POSITIVE="is positive",n.Msg.MATH_IS_PRIME="is prime",n.Msg.MATH_IS_TOOLTIP="Check if a number is an even, odd, prime, whole, positive, negative, or if it is divisible by certain number. Returns true or false.",n.Msg.MATH_IS_WHOLE="is whole",n.Msg.MATH_MODULO_HELPURL="https://en.wikipedia.org/wiki/Modulo_operation",n.Msg.MATH_MODULO_TITLE="remainder of %1 ÷ %2",n.Msg.MATH_MODULO_TOOLTIP="Return the remainder from dividing the two numbers.",n.Msg.MATH_MULTIPLICATION_SYMBOL="×",n.Msg.MATH_NUMBER_HELPURL="https://en.wikipedia.org/wiki/Number",n.Msg.MATH_NUMBER_TOOLTIP="A number.",n.Msg.MATH_ONLIST_HELPURL="",n.Msg.MATH_ONLIST_OPERATOR_AVERAGE="average of list",n.Msg.MATH_ONLIST_OPERATOR_MAX="max of list",n.Msg.MATH_ONLIST_OPERATOR_MEDIAN="median of list",n.Msg.MATH_ONLIST_OPERATOR_MIN="min of list",n.Msg.MATH_ONLIST_OPERATOR_MODE="modes of list",n.Msg.MATH_ONLIST_OPERATOR_RANDOM="random item of list",n.Msg.MATH_ONLIST_OPERATOR_STD_DEV="standard deviation of list",n.Msg.MATH_ONLIST_OPERATOR_SUM="sum of list",n.Msg.MATH_ONLIST_TOOLTIP_AVERAGE="Return the average (arithmetic mean) of the numeric values in the list.",n.Msg.MATH_ONLIST_TOOLTIP_MAX="Return the largest number in the list.",n.Msg.MATH_ONLIST_TOOLTIP_MEDIAN="Return the median number in the list.",n.Msg.MATH_ONLIST_TOOLTIP_MIN="Return the smallest number in the list.",n.Msg.MATH_ONLIST_TOOLTIP_MODE="Return a list of the most common item(s) in the list.",n.Msg.MATH_ONLIST_TOOLTIP_RANDOM="Return a random element from the list.",n.Msg.MATH_ONLIST_TOOLTIP_STD_DEV="Return the standard deviation of the list.",n.Msg.MATH_ONLIST_TOOLTIP_SUM="Return the sum of all the numbers in the list.",n.Msg.MATH_POWER_SYMBOL="^",n.Msg.MATH_RANDOM_FLOAT_HELPURL="https://en.wikipedia.org/wiki/Random_number_generation",n.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM="random fraction",n.Msg.MATH_RANDOM_FLOAT_TOOLTIP="Return a random fraction between 0.0 (inclusive) and 1.0 (exclusive).",n.Msg.MATH_RANDOM_INT_HELPURL="https://en.wikipedia.org/wiki/Random_number_generation",n.Msg.MATH_RANDOM_INT_TITLE="random integer from %1 to %2",n.Msg.MATH_RANDOM_INT_TOOLTIP="Return a random integer between the two specified limits, inclusive.",n.Msg.MATH_ROUND_HELPURL="https://en.wikipedia.org/wiki/Rounding",n.Msg.MATH_ROUND_OPERATOR_ROUND="round",n.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN="round down",n.Msg.MATH_ROUND_OPERATOR_ROUNDUP="round up",n.Msg.MATH_ROUND_TOOLTIP="Round a number up or down.",n.Msg.MATH_SINGLE_HELPURL="https://en.wikipedia.org/wiki/Square_root",n.Msg.MATH_SINGLE_OP_ABSOLUTE="absolute",n.Msg.MATH_SINGLE_OP_ROOT="square root",n.Msg.MATH_SINGLE_TOOLTIP_ABS="Return the absolute value of a number.",n.Msg.MATH_SINGLE_TOOLTIP_EXP="Return e to the power of a number.",n.Msg.MATH_SINGLE_TOOLTIP_LN="Return the natural logarithm of a number.",n.Msg.MATH_SINGLE_TOOLTIP_LOG10="Return the base 10 logarithm of a number.",n.Msg.MATH_SINGLE_TOOLTIP_NEG="Return the negation of a number.",n.Msg.MATH_SINGLE_TOOLTIP_POW10="Return 10 to the power of a number.",n.Msg.MATH_SINGLE_TOOLTIP_ROOT="Return the square root of a number.",n.Msg.MATH_SUBTRACTION_SYMBOL="-",n.Msg.MATH_TRIG_ACOS="acos",n.Msg.MATH_TRIG_ASIN="asin",n.Msg.MATH_TRIG_ATAN="atan",n.Msg.MATH_TRIG_COS="cos",n.Msg.MATH_TRIG_HELPURL="https://en.wikipedia.org/wiki/Trigonometric_functions",n.Msg.MATH_TRIG_SIN="sin",n.Msg.MATH_TRIG_TAN="tan",n.Msg.MATH_TRIG_TOOLTIP_ACOS="Return the arccosine of a number.",n.Msg.MATH_TRIG_TOOLTIP_ASIN="Return the arcsine of a number.",n.Msg.MATH_TRIG_TOOLTIP_ATAN="Return the arctangent of a number.",n.Msg.MATH_TRIG_TOOLTIP_COS="Return the cosine of a degree (not radian).",n.Msg.MATH_TRIG_TOOLTIP_SIN="Return the sine of a degree (not radian).",n.Msg.MATH_TRIG_TOOLTIP_TAN="Return the tangent of a degree (not radian).",n.Msg.NEW_COLOUR_VARIABLE="Create colour variable...",n.Msg.NEW_NUMBER_VARIABLE="Create number variable...",n.Msg.NEW_STRING_VARIABLE="Create string variable...",n.Msg.NEW_VARIABLE="Create variable...",n.Msg.NEW_VARIABLE_TITLE="New variable name:",n.Msg.NEW_VARIABLE_TYPE_TITLE="New variable type:",n.Msg.ORDINAL_NUMBER_SUFFIX="",n.Msg.PROCEDURES_ALLOW_STATEMENTS="allow statements",n.Msg.PROCEDURES_BEFORE_PARAMS="with:",n.Msg.PROCEDURES_CALLNORETURN_HELPURL="https://en.wikipedia.org/wiki/Subroutine",n.Msg.PROCEDURES_CALLNORETURN_TOOLTIP="Run the user-defined function '%1'.",n.Msg.PROCEDURES_CALLRETURN_HELPURL="https://en.wikipedia.org/wiki/Subroutine",n.Msg.PROCEDURES_CALLRETURN_TOOLTIP="Run the user-defined function '%1' and use its output.",n.Msg.PROCEDURES_CALL_BEFORE_PARAMS="with:",n.Msg.PROCEDURES_CREATE_DO="Create '%1'",n.Msg.PROCEDURES_DEFNORETURN_COMMENT="Describe this function...",n.Msg.PROCEDURES_DEFNORETURN_DO="",n.Msg.PROCEDURES_DEFNORETURN_HELPURL="https://en.wikipedia.org/wiki/Subroutine",n.Msg.PROCEDURES_DEFNORETURN_PROCEDURE="do something",n.Msg.PROCEDURES_DEFNORETURN_TITLE="to",n.Msg.PROCEDURES_DEFNORETURN_TOOLTIP="Creates a function with no output.",n.Msg.PROCEDURES_DEFRETURN_HELPURL="https://en.wikipedia.org/wiki/Subroutine",n.Msg.PROCEDURES_DEFRETURN_RETURN="return",n.Msg.PROCEDURES_DEFRETURN_TOOLTIP="Creates a function with an output.",n.Msg.PROCEDURES_DEF_DUPLICATE_WARNING="Warning: This function has duplicate parameters.",n.Msg.PROCEDURES_HIGHLIGHT_DEF="Highlight function definition",n.Msg.PROCEDURES_IFRETURN_HELPURL="http://c2.com/cgi/wiki?GuardClause",n.Msg.PROCEDURES_IFRETURN_TOOLTIP="If a value is true, then return a second value.",n.Msg.PROCEDURES_IFRETURN_WARNING="Warning: This block may be used only within a function definition.",n.Msg.PROCEDURES_MUTATORARG_TITLE="input name:",n.Msg.PROCEDURES_MUTATORARG_TOOLTIP="Add an input to the function.",n.Msg.PROCEDURES_MUTATORCONTAINER_TITLE="inputs",n.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP="Add, remove, or reorder inputs to this function.",n.Msg.REDO="Redo",n.Msg.REMOVE_COMMENT="Remove Comment",n.Msg.RENAME_VARIABLE="Rename variable...",n.Msg.RENAME_VARIABLE_TITLE="Rename all '%1' variables to:",n.Msg.TEXT_APPEND_HELPURL="https://github.com/google/blockly/wiki/Text#text-modification",n.Msg.TEXT_APPEND_TITLE="to %1 append text %2",n.Msg.TEXT_APPEND_TOOLTIP="Append some text to variable '%1'.",n.Msg.TEXT_CHANGECASE_HELPURL="https://github.com/google/blockly/wiki/Text#adjusting-text-case",n.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE="to lower case",n.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE="to Title Case",n.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE="to UPPER CASE",n.Msg.TEXT_CHANGECASE_TOOLTIP="Return a copy of the text in a different case.",n.Msg.TEXT_CHARAT_FIRST="get first letter",n.Msg.TEXT_CHARAT_FROM_END="get letter # from end",n.Msg.TEXT_CHARAT_FROM_START="get letter #",n.Msg.TEXT_CHARAT_HELPURL="https://github.com/google/blockly/wiki/Text#extracting-text",n.Msg.TEXT_CHARAT_LAST="get last letter",n.Msg.TEXT_CHARAT_RANDOM="get random letter",n.Msg.TEXT_CHARAT_TAIL="",n.Msg.TEXT_CHARAT_TITLE="in text %1 %2",n.Msg.TEXT_CHARAT_TOOLTIP="Returns the letter at the specified position.",n.Msg.TEXT_COUNT_HELPURL="https://github.com/google/blockly/wiki/Text#counting-substrings",n.Msg.TEXT_COUNT_MESSAGE0="count %1 in %2",n.Msg.TEXT_COUNT_TOOLTIP="Count how many times some text occurs within some other text.",n.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP="Add an item to the text.",n.Msg.TEXT_CREATE_JOIN_TITLE_JOIN="join",n.Msg.TEXT_CREATE_JOIN_TOOLTIP="Add, remove, or reorder sections to reconfigure this text block.",n.Msg.TEXT_GET_SUBSTRING_END_FROM_END="to letter # from end",n.Msg.TEXT_GET_SUBSTRING_END_FROM_START="to letter #",n.Msg.TEXT_GET_SUBSTRING_END_LAST="to last letter",n.Msg.TEXT_GET_SUBSTRING_HELPURL="https://github.com/google/blockly/wiki/Text#extracting-a-region-of-text",n.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT="in text",n.Msg.TEXT_GET_SUBSTRING_START_FIRST="get substring from first letter",n.Msg.TEXT_GET_SUBSTRING_START_FROM_END="get substring from letter # from end",n.Msg.TEXT_GET_SUBSTRING_START_FROM_START="get substring from letter #",n.Msg.TEXT_GET_SUBSTRING_TAIL="",n.Msg.TEXT_GET_SUBSTRING_TOOLTIP="Returns a specified portion of the text.",n.Msg.TEXT_INDEXOF_HELPURL="https://github.com/google/blockly/wiki/Text#finding-text",n.Msg.TEXT_INDEXOF_OPERATOR_FIRST="find first occurrence of text",n.Msg.TEXT_INDEXOF_OPERATOR_LAST="find last occurrence of text",n.Msg.TEXT_INDEXOF_TITLE="in text %1 %2 %3",n.Msg.TEXT_INDEXOF_TOOLTIP="Returns the index of the first/last occurrence of the first text in the second text. Returns %1 if text is not found.",n.Msg.TEXT_ISEMPTY_HELPURL="https://github.com/google/blockly/wiki/Text#checking-for-empty-text",n.Msg.TEXT_ISEMPTY_TITLE="%1 is empty",n.Msg.TEXT_ISEMPTY_TOOLTIP="Returns true if the provided text is empty.",n.Msg.TEXT_JOIN_HELPURL="https://github.com/google/blockly/wiki/Text#text-creation",n.Msg.TEXT_JOIN_TITLE_CREATEWITH="create text with",n.Msg.TEXT_JOIN_TOOLTIP="Create a piece of text by joining together any number of items.",n.Msg.TEXT_LENGTH_HELPURL="https://github.com/google/blockly/wiki/Text#text-modification",n.Msg.TEXT_LENGTH_TITLE="length of %1",n.Msg.TEXT_LENGTH_TOOLTIP="Returns the number of letters (including spaces) in the provided text.",n.Msg.TEXT_PRINT_HELPURL="https://github.com/google/blockly/wiki/Text#printing-text",n.Msg.TEXT_PRINT_TITLE="print %1",n.Msg.TEXT_PRINT_TOOLTIP="Print the specified text, number or other value.",n.Msg.TEXT_PROMPT_HELPURL="https://github.com/google/blockly/wiki/Text#getting-input-from-the-user",n.Msg.TEXT_PROMPT_TOOLTIP_NUMBER="Prompt for user for a number.",n.Msg.TEXT_PROMPT_TOOLTIP_TEXT="Prompt for user for some text.",n.Msg.TEXT_PROMPT_TYPE_NUMBER="prompt for number with message",n.Msg.TEXT_PROMPT_TYPE_TEXT="prompt for text with message",n.Msg.TEXT_REPLACE_HELPURL="https://github.com/google/blockly/wiki/Text#replacing-substrings",n.Msg.TEXT_REPLACE_MESSAGE0="replace %1 with %2 in %3",n.Msg.TEXT_REPLACE_TOOLTIP="Replace all occurances of some text within some other text.",n.Msg.TEXT_REVERSE_HELPURL="https://github.com/google/blockly/wiki/Text#reversing-text",n.Msg.TEXT_REVERSE_MESSAGE0="reverse %1",n.Msg.TEXT_REVERSE_TOOLTIP="Reverses the order of the characters in the text.",n.Msg.TEXT_TEXT_HELPURL="https://en.wikipedia.org/wiki/String_(computer_science)",n.Msg.TEXT_TEXT_TOOLTIP="A letter, word, or line of text.",n.Msg.TEXT_TRIM_HELPURL="https://github.com/google/blockly/wiki/Text#trimming-removing-spaces",n.Msg.TEXT_TRIM_OPERATOR_BOTH="trim spaces from both sides of",n.Msg.TEXT_TRIM_OPERATOR_LEFT="trim spaces from left side of",n.Msg.TEXT_TRIM_OPERATOR_RIGHT="trim spaces from right side of",n.Msg.TEXT_TRIM_TOOLTIP="Return a copy of the text with spaces removed from one or both ends.",n.Msg.TODAY="Today",n.Msg.UNDO="Undo",n.Msg.UNNAMED_KEY="unnamed",n.Msg.VARIABLES_DEFAULT_NAME="item",n.Msg.VARIABLES_GET_CREATE_SET="Create 'set %1'",n.Msg.VARIABLES_GET_HELPURL="https://github.com/google/blockly/wiki/Variables#get",n.Msg.VARIABLES_GET_TOOLTIP="Returns the value of this variable.",n.Msg.VARIABLES_SET="set %1 to %2",n.Msg.VARIABLES_SET_CREATE_GET="Create 'get %1'",n.Msg.VARIABLES_SET_HELPURL="https://github.com/google/blockly/wiki/Variables#set",n.Msg.VARIABLES_SET_TOOLTIP="Sets this variable to be equal to the input.",n.Msg.VARIABLE_ALREADY_EXISTS="A variable named '%1' already exists.",n.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE="A variable named '%1' already exists for another type: '%2'.",n.Msg.WORKSPACE_ARIA_LABEL="Blockly Workspace",n.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT="Say something...",n.Msg.CONTROLS_FOREACH_INPUT_DO=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.CONTROLS_FOR_INPUT_DO=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF=n.Msg.CONTROLS_IF_MSG_ELSEIF,n.Msg.CONTROLS_IF_ELSE_TITLE_ELSE=n.Msg.CONTROLS_IF_MSG_ELSE,n.Msg.CONTROLS_IF_IF_TITLE_IF=n.Msg.CONTROLS_IF_MSG_IF,n.Msg.CONTROLS_IF_MSG_THEN=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.CONTROLS_WHILEUNTIL_INPUT_DO=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.LISTS_CREATE_WITH_ITEM_TITLE=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.LISTS_GET_INDEX_HELPURL=n.Msg.LISTS_INDEX_OF_HELPURL,n.Msg.LISTS_GET_INDEX_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.LISTS_INDEX_OF_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.LISTS_SET_INDEX_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.MATH_CHANGE_TITLE_ITEM=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.PROCEDURES_DEFRETURN_COMMENT=n.Msg.PROCEDURES_DEFNORETURN_COMMENT,n.Msg.PROCEDURES_DEFRETURN_DO=n.Msg.PROCEDURES_DEFNORETURN_DO,n.Msg.PROCEDURES_DEFRETURN_PROCEDURE=n.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,n.Msg.PROCEDURES_DEFRETURN_TITLE=n.Msg.PROCEDURES_DEFNORETURN_TITLE,n.Msg.TEXT_APPEND_VARIABLE=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.MATH_HUE="230",n.Msg.LOOPS_HUE="120",n.Msg.LISTS_HUE="260",n.Msg.LOGIC_HUE="210",n.Msg.VARIABLES_HUE="330",n.Msg.TEXTS_HUE="160",n.Msg.PROCEDURES_HUE="290",n.Msg.COLOUR_HUE="20",n.Msg.VARIABLES_DYNAMIC_HUE="310",n.Msg})}(wu)),wu.exports}var Gu={exports:{}},Pu={exports:{}},Mg;function VT(){return Mg||(Mg=1,function(q,xe){(function(n,_){q.exports=_($i())})(Ve,function(n){var _=n.__namespace__,r=_.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"colour_picker",message0:"%1",args0:[{type:"field_colour",name:"COLOUR",colour:"#ff0000"}],output:"Colour",helpUrl:"%{BKY_COLOUR_PICKER_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_PICKER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"colour_random",message0:"%{BKY_COLOUR_RANDOM_TITLE}",output:"Colour",helpUrl:"%{BKY_COLOUR_RANDOM_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RANDOM_TOOLTIP}"},{type:"colour_rgb",message0:"%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3",args0:[{type:"input_value",name:"RED",check:"Number",align:"RIGHT"},{type:"input_value",name:"GREEN",check:"Number",align:"RIGHT"},{type:"input_value",name:"BLUE",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_RGB_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_RGB_TOOLTIP}"},{type:"colour_blend",message0:"%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3",args0:[{type:"input_value",name:"COLOUR1",check:"Colour",align:"RIGHT"},{type:"input_value",name:"COLOUR2",check:"Colour",align:"RIGHT"},{type:"input_value",name:"RATIO",check:"Number",align:"RIGHT"}],output:"Colour",helpUrl:"%{BKY_COLOUR_BLEND_HELPURL}",style:"colour_blocks",tooltip:"%{BKY_COLOUR_BLEND_TOOLTIP}"}]);_.defineBlocks$$module$build$src$core$common(r);var $e={};$e.blocks=r;var he={};_.module$build$src$core$field_registry,_.module$build$src$core$utils$xml,_.Align$$module$build$src$core$input,_.module$build$src$core$connection_type.ConnectionType;var u=_.module$build$src$core$msg.Msg;_.Mutator$$module$build$src$core$mutator;var c=_.module$build$src$core$common.createBlockDefinitionsFromJsonArray,l=_.module$build$src$core$common.defineBlocks;he.blocks=c([{type:"lists_create_empty",message0:"%{BKY_LISTS_CREATE_EMPTY_TITLE}",output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_CREATE_EMPTY_HELPURL}"},{type:"lists_repeat",message0:"%{BKY_LISTS_REPEAT_TITLE}",args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_LISTS_REPEAT_HELPURL}"},{type:"lists_reverse",message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]),he.blocks.lists_create_with={init:function(){this.setHelpUrl(u.LISTS_CREATE_WITH_HELPURL),this.setStyle("list_blocks"),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new _.Mutator$$module$build$src$core$mutator(["lists_create_with_item"],this)),this.setTooltip(u.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");return h.setAttribute("items",this.itemCount_),h},domToMutation:function(h){this.itemCount_=parseInt(h.getAttribute("items"),10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(h){this.itemCount_=h.itemCount,this.updateShape_()},decompose:function(h){const T=h.newBlock("lists_create_with_container");T.initSvg();let m=T.getInput("STACK").connection;for(let O=0;O<this.itemCount_;O++){const S=h.newBlock("lists_create_with_item");S.initSvg(),m.connect(S.previousConnection),m=S.nextConnection}return T},compose:function(h){var T=h.getInputTargetBlock("STACK");for(h=[];T;)T.isInsertionMarker()||h.push(T.valueConnection_),T=T.getNextBlock();for(T=0;T<this.itemCount_;T++){const m=this.getInput("ADD"+T).connection.targetConnection;m&&h.indexOf(m)===-1&&m.disconnect()}for(this.itemCount_=h.length,this.updateShape_(),T=0;T<this.itemCount_;T++)_.Mutator$$module$build$src$core$mutator.reconnect(h[T],this,"ADD"+T)},saveConnections:function(h){h=h.getInputTargetBlock("STACK");let T=0;for(;h;){if(h.isInsertionMarker()){h=h.getNextBlock();continue}const m=this.getInput("ADD"+T);h.valueConnection_=m&&m.connection.targetConnection,h=h.getNextBlock(),T++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(u.LISTS_CREATE_EMPTY_TITLE);for(var h=0;h<this.itemCount_;h++)if(!this.getInput("ADD"+h)){const T=this.appendValueInput("ADD"+h).setAlign(_.Align$$module$build$src$core$input.RIGHT);h===0&&T.appendField(u.LISTS_CREATE_WITH_INPUT_WITH)}for(h=this.itemCount_;this.getInput("ADD"+h);h++)this.removeInput("ADD"+h)}},he.blocks.lists_create_with_container={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(u.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(u.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},he.blocks.lists_create_with_item={init:function(){this.setStyle("list_blocks"),this.appendDummyInput().appendField(u.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(u.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},he.blocks.lists_indexOf={init:function(){var h=[[u.LISTS_INDEX_OF_FIRST,"FIRST"],[u.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(u.LISTS_INDEX_OF_HELPURL),this.setStyle("list_blocks"),this.setOutput(!0,"Number"),this.appendValueInput("VALUE").setCheck("Array").appendField(u.LISTS_INDEX_OF_INPUT_IN_LIST),h=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),this.appendValueInput("FIND").appendField(h,"END"),this.setInputsInline(!0);const T=this;this.setTooltip(function(){return u.LISTS_INDEX_OF_TOOLTIP.replace("%1",T.workspace.options.oneBasedIndex?"0":"-1")})}},he.blocks.lists_getIndex={init:function(){var h=[[u.LISTS_GET_INDEX_GET,"GET"],[u.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[u.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[u.LISTS_GET_INDEX_FROM_START,"FROM_START"],[u.LISTS_GET_INDEX_FROM_END,"FROM_END"],[u.LISTS_GET_INDEX_FIRST,"FIRST"],[u.LISTS_GET_INDEX_LAST,"LAST"],[u.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(u.LISTS_GET_INDEX_HELPURL),this.setStyle("list_blocks"),h=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),h.setValidator(function(m){m=m==="REMOVE",this.getSourceBlock().updateStatement_(m)}),this.appendValueInput("VALUE").setCheck("Array").appendField(u.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(h,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),u.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(u.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0);const T=this;this.setTooltip(function(){const m=T.getFieldValue("MODE"),O=T.getFieldValue("WHERE");let S="";switch(m+" "+O){case"GET FROM_START":case"GET FROM_END":S=u.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case"GET FIRST":S=u.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case"GET LAST":S=u.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case"GET RANDOM":S=u.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case"GET_REMOVE FROM_START":case"GET_REMOVE FROM_END":S=u.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case"GET_REMOVE FIRST":S=u.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case"GET_REMOVE LAST":S=u.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case"GET_REMOVE RANDOM":S=u.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case"REMOVE FROM_START":case"REMOVE FROM_END":S=u.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case"REMOVE FIRST":S=u.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case"REMOVE LAST":S=u.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case"REMOVE RANDOM":S=u.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}return(O==="FROM_START"||O==="FROM_END")&&(S+=" "+(O==="FROM_START"?u.LISTS_INDEX_FROM_START_TOOLTIP:u.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",T.workspace.options.oneBasedIndex?"#1":"#0")),S})},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");h.setAttribute("statement",!this.outputConnection);const T=this.getInput("AT").type===_.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;return h.setAttribute("at",T),h},domToMutation:function(h){const T=h.getAttribute("statement")==="true";this.updateStatement_(T),h=h.getAttribute("at")!=="false",this.updateAt_(h)},saveExtraState:function(){return this.outputConnection?null:{isStatement:!0}},loadExtraState:function(h){h.isStatement?this.updateStatement_(!0):typeof h=="string"&&this.domToMutation(_.module$build$src$core$utils$xml.textToDom(h))},updateStatement_:function(h){h!==!this.outputConnection&&(this.unplug(!0,!0),h?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(h){this.removeInput("AT"),this.removeInput("ORDINAL",!0),h?(this.appendValueInput("AT").setCheck("Number"),u.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(u.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const T=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:this.WHERE_OPTIONS});T.setValidator(function(m){const O=m==="FROM_START"||m==="FROM_END";if(O!==h){const S=this.getSourceBlock();return S.updateAt_(O),S.setFieldValue(m,"WHERE"),null}}),this.getInput("AT").appendField(T,"WHERE"),u.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}},he.blocks.lists_setIndex={init:function(){var h=[[u.LISTS_SET_INDEX_SET,"SET"],[u.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[u.LISTS_GET_INDEX_FROM_START,"FROM_START"],[u.LISTS_GET_INDEX_FROM_END,"FROM_END"],[u.LISTS_GET_INDEX_FIRST,"FIRST"],[u.LISTS_GET_INDEX_LAST,"LAST"],[u.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(u.LISTS_SET_INDEX_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(u.LISTS_SET_INDEX_INPUT_IN_LIST),h=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),this.appendDummyInput().appendField(h,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(u.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(u.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0);const T=this;this.setTooltip(function(){const m=T.getFieldValue("MODE"),O=T.getFieldValue("WHERE");let S="";switch(m+" "+O){case"SET FROM_START":case"SET FROM_END":S=u.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case"SET FIRST":S=u.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case"SET LAST":S=u.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case"SET RANDOM":S=u.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case"INSERT FROM_START":case"INSERT FROM_END":S=u.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case"INSERT FIRST":S=u.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case"INSERT LAST":S=u.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;break;case"INSERT RANDOM":S=u.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}return(O==="FROM_START"||O==="FROM_END")&&(S+=" "+u.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",T.workspace.options.oneBasedIndex?"#1":"#0")),S})},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation"),T=this.getInput("AT").type===_.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;return h.setAttribute("at",T),h},domToMutation:function(h){h=h.getAttribute("at")!=="false",this.updateAt_(h)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(h){this.removeInput("AT"),this.removeInput("ORDINAL",!0),h?(this.appendValueInput("AT").setCheck("Number"),u.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(u.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");const T=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:this.WHERE_OPTIONS});T.setValidator(function(m){const O=m==="FROM_START"||m==="FROM_END";if(O!==h){const S=this.getSourceBlock();return S.updateAt_(O),S.setFieldValue(m,"WHERE"),null}}),this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO"),this.getInput("AT").appendField(T,"WHERE")}},he.blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[u.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[u.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[u.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[u.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[u.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[u.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(u.LISTS_GET_SUBLIST_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("LIST").setCheck("Array").appendField(u.LISTS_GET_SUBLIST_INPUT_IN_LIST),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),u.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(u.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(u.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");var T=this.getInput("AT1").type===_.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;return h.setAttribute("at1",T),T=this.getInput("AT2").type===_.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE,h.setAttribute("at2",T),h},domToMutation:function(h){const T=h.getAttribute("at1")==="true";h=h.getAttribute("at2")==="true",this.updateAt_(1,T),this.updateAt_(2,h)},saveExtraState:function(){return null},loadExtraState:function(){},updateAt_:function(h,T){this.removeInput("AT"+h),this.removeInput("ORDINAL"+h,!0),T?(this.appendValueInput("AT"+h).setCheck("Number"),u.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+h).appendField(u.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+h);const m=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:this["WHERE_OPTIONS_"+h]});m.setValidator(function(O){const S=O==="FROM_START"||O==="FROM_END";if(S!==T){const te=this.getSourceBlock();return te.updateAt_(h,S),te.setFieldValue(O,"WHERE"+h),null}}),this.getInput("AT"+h).appendField(m,"WHERE"+h),h===1&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2")),u.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}},he.blocks.lists_sort={init:function(){this.jsonInit({message0:"%{BKY_LISTS_SORT_TITLE}",args0:[{type:"field_dropdown",name:"TYPE",options:[["%{BKY_LISTS_SORT_TYPE_NUMERIC}","NUMERIC"],["%{BKY_LISTS_SORT_TYPE_TEXT}","TEXT"],["%{BKY_LISTS_SORT_TYPE_IGNORECASE}","IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[["%{BKY_LISTS_SORT_ORDER_ASCENDING}","1"],["%{BKY_LISTS_SORT_ORDER_DESCENDING}","-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",tooltip:"%{BKY_LISTS_SORT_TOOLTIP}",helpUrl:"%{BKY_LISTS_SORT_HELPURL}"})}},he.blocks.lists_split={init:function(){const h=this,T=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:[[u.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[u.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]]});T.setValidator(function(m){h.updateType_(m)}),this.setHelpUrl(u.LISTS_SPLIT_HELPURL),this.setStyle("list_blocks"),this.appendValueInput("INPUT").setCheck("String").appendField(T,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(u.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip(function(){const m=h.getFieldValue("MODE");if(m==="SPLIT")return u.LISTS_SPLIT_TOOLTIP_SPLIT;if(m==="JOIN")return u.LISTS_SPLIT_TOOLTIP_JOIN;throw Error("Unknown mode: "+m)})},updateType_:function(h){if(this.getFieldValue("MODE")!==h){const T=this.getInput("INPUT").connection;T.setShadowDom(null);const m=T.targetBlock();m&&(T.disconnect(),m.isShadow()?m.dispose():this.bumpNeighbours())}h==="SPLIT"?(this.outputConnection.setCheck("Array"),this.getInput("INPUT").setCheck("String")):(this.outputConnection.setCheck("String"),this.getInput("INPUT").setCheck("Array"))},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");return h.setAttribute("mode",this.getFieldValue("MODE")),h},domToMutation:function(h){this.updateType_(h.getAttribute("mode"))},saveExtraState:function(){return null},loadExtraState:function(){}},l(he.blocks);var d={};_.module$build$src$core$events$events,_.module$build$src$core$extensions,_.module$build$src$core$utils$xml;var g=_.module$build$src$core$msg.Msg;_.Mutator$$module$build$src$core$mutator;var b=_.module$build$src$core$common.createBlockDefinitionsFromJsonArray,N=_.module$build$src$core$common.defineBlocks;d.blocks=b([{type:"logic_boolean",message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[["%{BKY_LOGIC_BOOLEAN_TRUE}","TRUE"],["%{BKY_LOGIC_BOOLEAN_FALSE}","FALSE"]]}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_BOOLEAN_TOOLTIP}",helpUrl:"%{BKY_LOGIC_BOOLEAN_HELPURL}"},{type:"controls_if",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],previousStatement:null,nextStatement:null,style:"logic_blocks",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,mutator:"controls_if_mutator",extensions:["controls_if_tooltip"]},{type:"controls_ifelse",message0:"%{BKY_CONTROLS_IF_MSG_IF} %1",args0:[{type:"input_value",name:"IF0",check:"Boolean"}],message1:"%{BKY_CONTROLS_IF_MSG_THEN} %1",args1:[{type:"input_statement",name:"DO0"}],message2:"%{BKY_CONTROLS_IF_MSG_ELSE} %1",args2:[{type:"input_statement",name:"ELSE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:"%{BKYCONTROLS_IF_TOOLTIP_2}",helpUrl:"%{BKY_CONTROLS_IF_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_if_tooltip"]},{type:"logic_compare",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A"},{type:"field_dropdown",name:"OP",options:[["=","EQ"],["≠","NEQ"],["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]]},{type:"input_value",name:"B"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_COMPARE_HELPURL}",extensions:["logic_compare","logic_op_tooltip"]},{type:"logic_operation",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Boolean"},{type:"field_dropdown",name:"OP",options:[["%{BKY_LOGIC_OPERATION_AND}","AND"],["%{BKY_LOGIC_OPERATION_OR}","OR"]]},{type:"input_value",name:"B",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",helpUrl:"%{BKY_LOGIC_OPERATION_HELPURL}",extensions:["logic_op_tooltip"]},{type:"logic_negate",message0:"%{BKY_LOGIC_NEGATE_TITLE}",args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",style:"logic_blocks",tooltip:"%{BKY_LOGIC_NEGATE_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NEGATE_HELPURL}"},{type:"logic_null",message0:"%{BKY_LOGIC_NULL}",output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_NULL_TOOLTIP}",helpUrl:"%{BKY_LOGIC_NULL_HELPURL}"},{type:"logic_ternary",message0:"%{BKY_LOGIC_TERNARY_CONDITION} %1",args0:[{type:"input_value",name:"IF",check:"Boolean"}],message1:"%{BKY_LOGIC_TERNARY_IF_TRUE} %1",args1:[{type:"input_value",name:"THEN"}],message2:"%{BKY_LOGIC_TERNARY_IF_FALSE} %1",args2:[{type:"input_value",name:"ELSE"}],output:null,style:"logic_blocks",tooltip:"%{BKY_LOGIC_TERNARY_TOOLTIP}",helpUrl:"%{BKY_LOGIC_TERNARY_HELPURL}",extensions:["logic_ternary"]},{type:"controls_if_if",message0:"%{BKY_CONTROLS_IF_IF_TITLE_IF}",nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_IF_TOOLTIP}"},{type:"controls_if_elseif",message0:"%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}",previousStatement:null,nextStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}"},{type:"controls_if_else",message0:"%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}",previousStatement:null,enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);var G={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"};_.module$build$src$core$extensions.register("logic_op_tooltip",_.module$build$src$core$extensions.buildTooltipForDropdown("OP",G));var Q={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const h=_.module$build$src$core$utils$xml.createElement("mutation");return this.elseifCount_&&h.setAttribute("elseif",this.elseifCount_),this.elseCount_&&h.setAttribute("else",1),h},domToMutation:function(h){this.elseifCount_=parseInt(h.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(h.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const h=Object.create(null);return this.elseifCount_&&(h.elseIfCount=this.elseifCount_),this.elseCount_&&(h.hasElse=!0),h},loadExtraState:function(h){this.elseifCount_=h.elseIfCount||0,this.elseCount_=h.hasElse?1:0,this.updateShape_()},decompose:function(h){const T=h.newBlock("controls_if_if");T.initSvg();let m=T.nextConnection;for(let O=1;O<=this.elseifCount_;O++){const S=h.newBlock("controls_if_elseif");S.initSvg(),m.connect(S.previousConnection),m=S.nextConnection}return this.elseCount_&&(h=h.newBlock("controls_if_else"),h.initSvg(),m.connect(h.previousConnection)),T},compose:function(h){h=h.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const T=[null],m=[null];let O=null;for(;h;){if(!h.isInsertionMarker())switch(h.type){case"controls_if_elseif":this.elseifCount_++,T.push(h.valueConnection_),m.push(h.statementConnection_);break;case"controls_if_else":this.elseCount_++,O=h.statementConnection_;break;default:throw TypeError("Unknown block type: "+h.type)}h=h.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(T,m,O)},saveConnections:function(h){h=h.nextConnection.targetBlock();let T=1;for(;h;){if(!h.isInsertionMarker())switch(h.type){case"controls_if_elseif":var m=this.getInput("IF"+T);const O=this.getInput("DO"+T);h.valueConnection_=m&&m.connection.targetConnection,h.statementConnection_=O&&O.connection.targetConnection,T++;break;case"controls_if_else":m=this.getInput("ELSE"),h.statementConnection_=m&&m.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+h.type)}h=h.getNextBlock()}},rebuildShape_:function(){const h=[null],T=[null];let m=null;this.getInput("ELSE")&&(m=this.getInput("ELSE").connection.targetConnection);for(let O=1;this.getInput("IF"+O);O++){const S=this.getInput("IF"+O),te=this.getInput("DO"+O);h.push(S.connection.targetConnection),T.push(te.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(h,T,m)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var h=1;this.getInput("IF"+h);h++)this.removeInput("IF"+h),this.removeInput("DO"+h);for(h=1;h<=this.elseifCount_;h++)this.appendValueInput("IF"+h).setCheck("Boolean").appendField(g.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+h).appendField(g.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(g.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(h,T,m){for(let O=1;O<=this.elseifCount_;O++)_.Mutator$$module$build$src$core$mutator.reconnect(h[O],this,"IF"+O),_.Mutator$$module$build$src$core$mutator.reconnect(T[O],this,"DO"+O);_.Mutator$$module$build$src$core$mutator.reconnect(m,this,"ELSE")}};_.module$build$src$core$extensions.registerMutator("controls_if_mutator",Q,null,["controls_if_elseif","controls_if_else"]);var de=function(){this.setTooltip((function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return g.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return g.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return g.CONTROLS_IF_TOOLTIP_4}else return g.CONTROLS_IF_TOOLTIP_1;return""}).bind(this))};_.module$build$src$core$extensions.register("controls_if_tooltip",de);var Y={onchange:function(h){this.prevBlocks_||(this.prevBlocks_=[null,null]);var T=this.getInputTargetBlock("A");const m=this.getInputTargetBlock("B");T&&m&&!this.workspace.connectionChecker.doTypeChecks(T.outputConnection,m.outputConnection)&&(_.module$build$src$core$events$events.setGroup(h.group),h=this.prevBlocks_[0],h!==T&&(T.unplug(),!h||h.isDisposed()||h.isShadow()||this.getInput("A").connection.connect(h.outputConnection)),T=this.prevBlocks_[1],T!==m&&(m.unplug(),!T||T.isDisposed()||T.isShadow()||this.getInput("B").connection.connect(T.outputConnection)),this.bumpNeighbours(),_.module$build$src$core$events$events.setGroup(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}},Re=function(){this.mixin(Y)};_.module$build$src$core$extensions.register("logic_compare",Re);var _e={prevParentConnection_:null,onchange:function(h){const T=this.getInputTargetBlock("THEN"),m=this.getInputTargetBlock("ELSE"),O=this.outputConnection.targetConnection;if((T||m)&&O)for(let S=0;2>S;S++){const te=S===1?T:m;te&&!te.workspace.connectionChecker.doTypeChecks(te.outputConnection,O)&&(_.module$build$src$core$events$events.setGroup(h.group),O===this.prevParentConnection_?(this.unplug(),O.getSourceBlock().bumpNeighbours()):(te.unplug(),te.bumpNeighbours()),_.module$build$src$core$events$events.setGroup(!1))}this.prevParentConnection_=O}};_.module$build$src$core$extensions.registerMixin("logic_ternary",_e),N(d.blocks);var et={};_.module$build$src$core$contextmenu,_.module$build$src$core$events$events,_.module$build$src$core$extensions,_.module$build$src$core$variables,_.module$build$src$core$utils$xml;var $o=_.module$build$src$core$msg.Msg,nr=_.module$build$src$core$common.createBlockDefinitionsFromJsonArray,Pt=_.module$build$src$core$common.defineBlocks;et.blocks=nr([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:["Number","int"]}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",name:"TIMES",value:10,min:0,precision:1}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}","UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:["Number","int"],align:"RIGHT"},{type:"input_value",name:"TO",check:["Number","int"],align:"RIGHT"},{type:"input_value",name:"BY",check:["Number","int"],align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_for_tooltip"]},{type:"controls_for_chuck",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"input_value",name:"VAR",check:["Number","int"]},{type:"input_value",name:"FROM",check:["Number","int"],align:"RIGHT"},{type:"input_value",name:"TO",check:["Number","int"],align:"RIGHT"},{type:"input_value",name:"BY",check:["Number","int"],align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOR_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_for_tooltip"]},{type:"controls_forEach",message0:"%{BKY_CONTROLS_FOREACH_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"LIST",check:"Array"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",suppressPrefixSuffix:!0,extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]);var Eo={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};_.module$build$src$core$extensions.register("controls_whileUntil_tooltip",_.module$build$src$core$extensions.buildTooltipForDropdown("MODE",Eo));var Ei={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};_.module$build$src$core$extensions.register("controls_flow_tooltip",_.module$build$src$core$extensions.buildTooltipForDropdown("FLOW",Ei));var lr={customContextMenu:function(h){if(!this.isInFlyout){var T=this.getField("VAR").getVariable(),m=T.name;if(!this.isCollapsed()&&m!==null){const O={enabled:!0};O.text=$o.VARIABLES_SET_CREATE_GET.replace("%1",m),T=_.module$build$src$core$variables.generateVariableFieldDom(T),m=_.module$build$src$core$utils$xml.createElement("block"),m.setAttribute("type","variables_get"),m.appendChild(T),O.callback=_.module$build$src$core$contextmenu.callbackFactory(this,m),h.push(O)}}}};_.module$build$src$core$extensions.registerMixin("contextMenu_newGetVariableBlock",lr),_.module$build$src$core$extensions.register("controls_for_tooltip",_.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR")),_.module$build$src$core$extensions.register("controls_forEach_tooltip",_.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR")),et.loopTypes=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);var mi={getSurroundLoop:function(){let h=this;do{if(et.loopTypes.has(h.type))return h;h=h.getSurroundParent()}while(h);return null},onchange:function(h){if(this.workspace.isDragging&&!this.workspace.isDragging()&&h.type===_.module$build$src$core$events$events.BLOCK_MOVE){var T=this.getSurroundLoop(this);if(this.setWarningText(T?null:$o.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout){const m=_.module$build$src$core$events$events.getGroup();_.module$build$src$core$events$events.setGroup(h.group),this.setEnabled(T),_.module$build$src$core$events$events.setGroup(m)}}}};_.module$build$src$core$extensions.registerMixin("controls_flow_in_loop_check",mi),Pt(et.blocks);var oo=_.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:["Number","int","float"],helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:["Number","int","float"]},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}","MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:["Number","int","float"]}],inputsInline:!0,output:["Number","int","float"],style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}","ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_TRIG_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_constant",message0:"%1",args0:[{type:"field_dropdown",name:"CONSTANT",options:[["π","PI"],["e","E"],["φ","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(½)","SQRT1_2"],["∞","INFINITY"]]}],output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTANT_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTANT_HELPURL}"},{type:"math_number_property",message0:"%1 %2",args0:[{type:"input_value",name:"NUMBER_TO_CHECK",check:"Number"},{type:"field_dropdown",name:"PROPERTY",options:[["%{BKY_MATH_IS_EVEN}","EVEN"],["%{BKY_MATH_IS_ODD}","ODD"],["%{BKY_MATH_IS_PRIME}","PRIME"],["%{BKY_MATH_IS_WHOLE}","WHOLE"],["%{BKY_MATH_IS_POSITIVE}","POSITIVE"],["%{BKY_MATH_IS_NEGATIVE}","NEGATIVE"],["%{BKY_MATH_IS_DIVISIBLE_BY}","DIVISIBLE_BY"]]}],inputsInline:!0,output:"Boolean",style:"math_blocks",tooltip:"%{BKY_MATH_IS_TOOLTIP}",mutator:"math_is_divisibleby_mutator"},{type:"math_change",message0:"%{BKY_MATH_CHANGE_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_MATH_CHANGE_TITLE_ITEM}"},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,style:"variable_blocks",helpUrl:"%{BKY_MATH_CHANGE_HELPURL}",extensions:["math_change_tooltip"]},{type:"math_round",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ROUND_OPERATOR_ROUND}","ROUND"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}","ROUNDUP"],["%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}","ROUNDDOWN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ROUND_HELPURL}",tooltip:"%{BKY_MATH_ROUND_TOOLTIP}"},{type:"math_on_list",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ONLIST_OPERATOR_SUM}","SUM"],["%{BKY_MATH_ONLIST_OPERATOR_MIN}","MIN"],["%{BKY_MATH_ONLIST_OPERATOR_MAX}","MAX"],["%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}","AVERAGE"],["%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}","MEDIAN"],["%{BKY_MATH_ONLIST_OPERATOR_MODE}","MODE"],["%{BKY_MATH_ONLIST_OPERATOR_STD_DEV}","STD_DEV"],["%{BKY_MATH_ONLIST_OPERATOR_RANDOM}","RANDOM"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ONLIST_HELPURL}",mutator:"math_modes_of_list_mutator",extensions:["math_op_tooltip"]},{type:"math_modulo",message0:"%{BKY_MATH_MODULO_TITLE}",args0:[{type:"input_value",name:"DIVIDEND",check:"Number"},{type:"input_value",name:"DIVISOR",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_MODULO_TOOLTIP}",helpUrl:"%{BKY_MATH_MODULO_HELPURL}"},{type:"math_constrain",message0:"%{BKY_MATH_CONSTRAIN_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"Number"},{type:"input_value",name:"LOW",check:"Number"},{type:"input_value",name:"HIGH",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_CONSTRAIN_TOOLTIP}",helpUrl:"%{BKY_MATH_CONSTRAIN_HELPURL}"},{type:"math_random_int",message0:"%{BKY_MATH_RANDOM_INT_TITLE}",args0:[{type:"input_value",name:"FROM",check:"Number"},{type:"input_value",name:"TO",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_INT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_INT_HELPURL}"},{type:"math_random_float",message0:"%{BKY_MATH_RANDOM_FLOAT_TITLE_RANDOM}",output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}",helpUrl:"%{BKY_MATH_RANDOM_FLOAT_HELPURL}"},{type:"math_atan2",message0:"%{BKY_MATH_ATAN2_TITLE}",args0:[{type:"input_value",name:"X",check:"Number"},{type:"input_value",name:"Y",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",tooltip:"%{BKY_MATH_ATAN2_TOOLTIP}",helpUrl:"%{BKY_MATH_ATAN2_HELPURL}"}]),ft={ADD:"%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}",MINUS:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}",MULTIPLY:"%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}",DIVIDE:"%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}",POWER:"%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}",ROOT:"%{BKY_MATH_SINGLE_TOOLTIP_ROOT}",ABS:"%{BKY_MATH_SINGLE_TOOLTIP_ABS}",NEG:"%{BKY_MATH_SINGLE_TOOLTIP_NEG}",LN:"%{BKY_MATH_SINGLE_TOOLTIP_LN}",LOG10:"%{BKY_MATH_SINGLE_TOOLTIP_LOG10}",EXP:"%{BKY_MATH_SINGLE_TOOLTIP_EXP}",POW10:"%{BKY_MATH_SINGLE_TOOLTIP_POW10}",SIN:"%{BKY_MATH_TRIG_TOOLTIP_SIN}",COS:"%{BKY_MATH_TRIG_TOOLTIP_COS}",TAN:"%{BKY_MATH_TRIG_TOOLTIP_TAN}",ASIN:"%{BKY_MATH_TRIG_TOOLTIP_ASIN}",ACOS:"%{BKY_MATH_TRIG_TOOLTIP_ACOS}",ATAN:"%{BKY_MATH_TRIG_TOOLTIP_ATAN}",SUM:"%{BKY_MATH_ONLIST_TOOLTIP_SUM}",MIN:"%{BKY_MATH_ONLIST_TOOLTIP_MIN}",MAX:"%{BKY_MATH_ONLIST_TOOLTIP_MAX}",AVERAGE:"%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}",MEDIAN:"%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}",MODE:"%{BKY_MATH_ONLIST_TOOLTIP_MODE}",STD_DEV:"%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}",RANDOM:"%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}"};_.register$$module$build$src$core$extensions("math_op_tooltip",_.buildTooltipForDropdown$$module$build$src$core$extensions("OP",ft));var We={mutationToDom:function(){const h=_.createElement$$module$build$src$core$utils$xml("mutation"),T=this.getFieldValue("PROPERTY")==="DIVISIBLE_BY";return h.setAttribute("divisor_input",String(T)),h},domToMutation:function(h){h=h.getAttribute("divisor_input")==="true",this.updateShape_(h)},updateShape_:function(h){const T=this.getInput("DIVISOR");h?T||this.appendValueInput("DIVISOR").setCheck("Number"):T&&this.removeInput("DIVISOR")}},tt=function(){this.getField("PROPERTY").setValidator(function(h){h=h==="DIVISIBLE_BY",this.getSourceBlock().updateShape_(h)})};_.registerMutator$$module$build$src$core$extensions("math_is_divisibleby_mutator",We,tt),_.register$$module$build$src$core$extensions("math_change_tooltip",_.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));var x={updateType_:function(h){h==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){const h=_.createElement$$module$build$src$core$utils$xml("mutation");return h.setAttribute("op",this.getFieldValue("OP")),h},domToMutation:function(h){if(h=h.getAttribute("op"),h===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(h)}},fi=function(){this.getField("OP").setValidator((function(h){this.updateType_(h)}).bind(this))};_.registerMutator$$module$build$src$core$extensions("math_modes_of_list_mutator",x,fi),_.defineBlocks$$module$build$src$core$common(oo);var mo={};mo.blocks=oo;var Fe={};_.module$build$src$core$contextmenu,_.module$build$src$core$events$events,_.module$build$src$core$procedures,_.module$build$src$core$variables,_.module$build$src$core$xml,_.module$build$src$core$field_registry,_.module$build$src$core$utils$xml,_.Align$$module$build$src$core$input,_.config$$module$build$src$core$config;var Z=_.module$build$src$core$msg.Msg;_.Mutator$$module$build$src$core$mutator,_.module$build$src$core$names.Names;var ve=_.module$build$src$core$common.defineBlocks;Fe.blocks={};var Ie={setStatements_:function(h){this.hasStatements_!==h&&(h?(this.appendStatementInput("STACK").appendField(Z.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=h)},updateParams_:function(){let h="";this.arguments_.length&&(h=Z.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),_.module$build$src$core$events$events.disable();try{this.setFieldValue(h,"PARAMS")}finally{_.module$build$src$core$events$events.enable()}},mutationToDom:function(h){const T=_.module$build$src$core$utils$xml.createElement("mutation");h&&T.setAttribute("name",this.getFieldValue("NAME"));for(let m=0;m<this.argumentVarModels_.length;m++){const O=_.module$build$src$core$utils$xml.createElement("arg"),S=this.argumentVarModels_[m];O.setAttribute("name",S.name),O.setAttribute("varid",S.getId()),h&&this.paramIds_&&O.setAttribute("paramId",this.paramIds_[m]),T.appendChild(O)}return this.hasStatements_||T.setAttribute("statements","false"),T},domToMutation:function(h){this.arguments_=[],this.argumentVarModels_=[];for(let m=0,O;O=h.childNodes[m];m++)if(O.nodeName.toLowerCase()==="arg"){const S=O.getAttribute("name");var T=O.getAttribute("varid")||O.getAttribute("varId");this.arguments_.push(S),T=_.module$build$src$core$variables.getOrCreateVariablePackage(this.workspace,T,S,""),T!==null?this.argumentVarModels_.push(T):console.log(`Failed to create a variable named "${S}", ignoring.`)}this.updateParams_(),_.module$build$src$core$procedures.mutateCallers(this),this.setStatements_(h.getAttribute("statements")!=="false")},saveExtraState:function(){if(!this.argumentVarModels_.length&&this.hasStatements_)return null;const h=Object.create(null);if(this.argumentVarModels_.length){h.params=[];for(let T=0;T<this.argumentVarModels_.length;T++)h.params.push({name:this.argumentVarModels_[T].name,id:this.argumentVarModels_[T].getId()})}return this.hasStatements_||(h.hasStatements=!1),h},loadExtraState:function(h){if(this.arguments_=[],this.argumentVarModels_=[],h.params)for(let m=0;m<h.params.length;m++){var T=h.params[m];T=_.module$build$src$core$variables.getOrCreateVariablePackage(this.workspace,T.id,T.name,""),this.arguments_.push(T.name),this.argumentVarModels_.push(T)}this.updateParams_(),_.module$build$src$core$procedures.mutateCallers(this),this.setStatements_(h.hasStatements!==!1)},decompose:function(h){const T=_.module$build$src$core$utils$xml.createElement("block");T.setAttribute("type","procedures_mutatorcontainer");var m=_.module$build$src$core$utils$xml.createElement("statement");m.setAttribute("name","STACK"),T.appendChild(m);for(let S=0;S<this.arguments_.length;S++){const te=_.module$build$src$core$utils$xml.createElement("block");te.setAttribute("type","procedures_mutatorarg");var O=_.module$build$src$core$utils$xml.createElement("field");O.setAttribute("name","NAME");const Uo=_.module$build$src$core$utils$xml.createTextNode(this.arguments_[S]);O.appendChild(Uo),te.appendChild(O),O=_.module$build$src$core$utils$xml.createElement("next"),te.appendChild(O),m.appendChild(te),m=O}return h=_.module$build$src$core$xml.domToBlock(T,h),this.type==="procedures_defreturn"?h.setFieldValue(this.hasStatements_,"STATEMENTS"):h.removeInput("STATEMENT_INPUT"),_.module$build$src$core$procedures.mutateCallers(this),h},compose:function(h){this.arguments_=[],this.paramIds_=[],this.argumentVarModels_=[];let T=h.getInputTargetBlock("STACK");for(;T&&!T.isInsertionMarker();){var m=T.getFieldValue("NAME");this.arguments_.push(m),m=this.workspace.getVariable(m,""),this.argumentVarModels_.push(m),this.paramIds_.push(T.id),T=T.nextConnection&&T.nextConnection.targetBlock()}this.updateParams_(),_.module$build$src$core$procedures.mutateCallers(this),h=h.getFieldValue("STATEMENTS"),h!==null&&(h=h==="TRUE",this.hasStatements_!==h)&&(h?(this.setStatements_(!0),_.Mutator$$module$build$src$core$mutator.reconnect(this.statementConnection_,this,"STACK"),this.statementConnection_=null):(h=this.getInput("STACK").connection,(this.statementConnection_=h.targetConnection)&&(h=h.targetBlock(),h.unplug(),h.bumpNeighbours()),this.setStatements_(!1)))},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(h,T){var m=this.workspace.getVariableById(h);if(m.type===""){m=m.name,T=this.workspace.getVariableById(T);var O=!1;for(let S=0;S<this.argumentVarModels_.length;S++)this.argumentVarModels_[S].getId()===h&&(this.arguments_[S]=T.name,this.argumentVarModels_[S]=T,O=!0);O&&(this.displayRenamedVar_(m,T.name),_.module$build$src$core$procedures.mutateCallers(this))}},updateVarName:function(h){const T=h.name;let m=!1,O;for(let S=0;S<this.argumentVarModels_.length;S++)this.argumentVarModels_[S].getId()===h.getId()&&(O=this.arguments_[S],this.arguments_[S]=T,m=!0);m&&(this.displayRenamedVar_(O,T),_.module$build$src$core$procedures.mutateCallers(this))},displayRenamedVar_:function(h,T){if(this.updateParams_(),this.mutator&&this.mutator.isVisible()){const m=this.mutator.workspace_.getAllBlocks(!1);for(let O=0,S;S=m[O];O++)S.type==="procedures_mutatorarg"&&_.module$build$src$core$names.Names.equals(h,S.getFieldValue("NAME"))&&S.setFieldValue(T,"NAME")}},customContextMenu:function(h){if(!this.isInFlyout){var T={enabled:!0},m=this.getFieldValue("NAME");T.text=Z.PROCEDURES_CREATE_DO.replace("%1",m);var O=_.module$build$src$core$utils$xml.createElement("mutation");for(O.setAttribute("name",m),m=0;m<this.arguments_.length;m++){var S=_.module$build$src$core$utils$xml.createElement("arg");S.setAttribute("name",this.arguments_[m]),O.appendChild(S)}if(m=_.module$build$src$core$utils$xml.createElement("block"),m.setAttribute("type",this.callType_),m.appendChild(O),T.callback=_.module$build$src$core$contextmenu.callbackFactory(this,m),h.push(T),!this.isCollapsed())for(T=0;T<this.argumentVarModels_.length;T++)O={enabled:!0},m=this.argumentVarModels_[T],O.text=Z.VARIABLES_SET_CREATE_GET.replace("%1",m.name),m=_.module$build$src$core$variables.generateVariableFieldDom(m),S=_.module$build$src$core$utils$xml.createElement("block"),S.setAttribute("type","variables_get"),S.appendChild(m),O.callback=_.module$build$src$core$contextmenu.callbackFactory(this,S),h.push(O)}}};Fe.blocks.procedures_defnoreturn=Object.assign({},Ie,{init:function(){var h=_.module$build$src$core$procedures.findLegalName("",this);h=_.module$build$src$core$field_registry.fromJson({type:"field_input",text:h}),h.setValidator(_.module$build$src$core$procedures.rename),h.setSpellcheck(!1),this.appendDummyInput().appendField(Z.PROCEDURES_DEFNORETURN_TITLE).appendField(h,"NAME").appendField("","PARAMS"),this.setMutator(new _.Mutator$$module$build$src$core$mutator(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Z.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Z.PROCEDURES_DEFNORETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(Z.PROCEDURES_DEFNORETURN_TOOLTIP),this.setHelpUrl(Z.PROCEDURES_DEFNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},callType_:"procedures_callnoreturn"}),Fe.blocks.procedures_defreturn=Object.assign({},Ie,{init:function(){var h=_.module$build$src$core$procedures.findLegalName("",this);h=_.module$build$src$core$field_registry.fromJson({type:"field_input",text:h}),h.setValidator(_.module$build$src$core$procedures.rename),h.setSpellcheck(!1),this.appendDummyInput().appendField(Z.PROCEDURES_DEFRETURN_TITLE).appendField(h,"NAME").appendField("","PARAMS"),this.appendValueInput("RETURN").setAlign(_.Align$$module$build$src$core$input.RIGHT).appendField(Z.PROCEDURES_DEFRETURN_RETURN),this.setMutator(new _.Mutator$$module$build$src$core$mutator(["procedures_mutatorarg"],this)),(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Z.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText(Z.PROCEDURES_DEFRETURN_COMMENT),this.setStyle("procedure_blocks"),this.setTooltip(Z.PROCEDURES_DEFRETURN_TOOLTIP),this.setHelpUrl(Z.PROCEDURES_DEFRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.setStatements_(!0),this.statementConnection_=null},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},callType_:"procedures_callreturn"}),Fe.blocks.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField(Z.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.appendDummyInput("STATEMENT_INPUT").appendField(Z.PROCEDURES_ALLOW_STATEMENTS).appendField(_.module$build$src$core$field_registry.fromJson({type:"field_checkbox",checked:!0}),"STATEMENTS"),this.setStyle("procedure_blocks"),this.setTooltip(Z.PROCEDURES_MUTATORCONTAINER_TOOLTIP),this.contextMenu=!1}},Fe.blocks.procedures_mutatorarg={init:function(){const h=_.module$build$src$core$field_registry.fromJson({type:"field_input",text:_.module$build$src$core$procedures.DEFAULT_ARG});h.setValidator(this.validator_),h.oldShowEditorFn_=h.showEditor_,h.showEditor_=function(){this.createdVariables_=[],this.oldShowEditorFn_()},this.appendDummyInput().appendField(Z.PROCEDURES_MUTATORARG_TITLE).appendField(h,"NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(Z.PROCEDURES_MUTATORARG_TOOLTIP),this.contextMenu=!1,h.onFinishEditing_=this.deleteIntermediateVars_,h.createdVariables_=[],h.onFinishEditing_("x")},validator_:function(h){var T=this.getSourceBlock();const m=_.Mutator$$module$build$src$core$mutator.findParentWs(T.workspace);if(h=h.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""),!h)return null;const O=(T.workspace.targetWorkspace||T.workspace).getAllBlocks(!1),S=h.toLowerCase();for(let te=0;te<O.length;te++){if(O[te].id===this.getSourceBlock().id)continue;const Uo=O[te].getFieldValue("NAME");if(Uo&&Uo.toLowerCase()===S)return null}return T.isInFlyout||((T=m.getVariable(h,""))&&T.name!==h&&m.renameVariableById(T.getId(),h),T||(T=m.createVariable(h,""))&&this.createdVariables_&&this.createdVariables_.push(T)),h},deleteIntermediateVars_:function(h){const T=_.Mutator$$module$build$src$core$mutator.findParentWs(this.getSourceBlock().workspace);if(T)for(let m=0;m<this.createdVariables_.length;m++){const O=this.createdVariables_[m];O.name!==h&&T.deleteVariableById(O.getId())}}};var Oe={getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(h,T){_.module$build$src$core$names.Names.equals(h,this.getProcedureCall())&&(this.setFieldValue(T,"NAME"),this.setTooltip((this.outputConnection?Z.PROCEDURES_CALLRETURN_TOOLTIP:Z.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",T)))},setProcedureParameters_:function(h,T){var m=_.module$build$src$core$procedures.getDefinition(this.getProcedureCall(),this.workspace),O=m&&m.mutator&&m.mutator.isVisible();if(O?this.setCollapsed(!1):(this.quarkConnections_={},this.quarkIds_=null),h.join(`
|
|
797
|
+
`)===this.arguments_.join(`
|
|
798
|
+
`))this.quarkIds_=T;else{if(T.length!==h.length)throw RangeError("paramNames and paramIds must be the same length.");this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]),m=this.rendered,this.rendered=!1;for(let te=0;te<this.arguments_.length;te++){var S=this.getInput("ARG"+te);S&&(S=S.connection.targetConnection,this.quarkConnections_[this.quarkIds_[te]]=S,O&&S&&T.indexOf(this.quarkIds_[te])===-1&&(S.disconnect(),S.getSourceBlock().bumpNeighbours()))}for(this.arguments_=[].concat(h),this.argumentVarModels_=[],h=0;h<this.arguments_.length;h++)O=_.module$build$src$core$variables.getOrCreateVariablePackage(this.workspace,null,this.arguments_[h],""),this.argumentVarModels_.push(O);if(this.updateShape_(),this.quarkIds_=T)for(T=0;T<this.arguments_.length;T++)h=this.quarkIds_[T],h in this.quarkConnections_&&(_.Mutator$$module$build$src$core$mutator.reconnect(this.quarkConnections_[h],this,"ARG"+T)||delete this.quarkConnections_[h]);(this.rendered=m)&&this.render()}},updateShape_:function(){for(var h=0;h<this.arguments_.length;h++){var T=this.getField("ARGNAME"+h);if(T){_.module$build$src$core$events$events.disable();try{T.setValue(this.arguments_[h])}finally{_.module$build$src$core$events$events.enable()}}else T=_.module$build$src$core$field_registry.fromJson({type:"field_label",text:this.arguments_[h]}),this.appendValueInput("ARG"+h).setAlign(_.Align$$module$build$src$core$input.RIGHT).appendField(T,"ARGNAME"+h).init()}for(h=this.arguments_.length;this.getInput("ARG"+h);h++)this.removeInput("ARG"+h);(h=this.getInput("TOPROW"))&&(this.arguments_.length?this.getField("WITH")||(h.appendField(Z.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),h.init()):this.getField("WITH")&&h.removeField("WITH"))},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");h.setAttribute("name",this.getProcedureCall());for(let T=0;T<this.arguments_.length;T++){const m=_.module$build$src$core$utils$xml.createElement("arg");m.setAttribute("name",this.arguments_[T]),h.appendChild(m)}return h},domToMutation:function(h){var T=h.getAttribute("name");this.renameProcedure(this.getProcedureCall(),T),T=[];const m=[];for(let O=0,S;S=h.childNodes[O];O++)S.nodeName.toLowerCase()==="arg"&&(T.push(S.getAttribute("name")),m.push(S.getAttribute("paramId")));this.setProcedureParameters_(T,m)},saveExtraState:function(){const h=Object.create(null);return h.name=this.getProcedureCall(),this.arguments_.length&&(h.params=this.arguments_),h},loadExtraState:function(h){if(this.renameProcedure(this.getProcedureCall(),h.name),h=h.params){const T=[];T.length=h.length,T.fill(null),this.setProcedureParameters_(h,T)}},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},onchange:function(h){if(this.workspace&&!this.workspace.isFlyout&&h.recordUndo)if(h.type===_.module$build$src$core$events$events.BLOCK_CREATE&&h.ids.indexOf(this.id)!==-1){var T=this.getProcedureCall();if(T=_.module$build$src$core$procedures.getDefinition(T,this.workspace),!T||T.type===this.defType_&&JSON.stringify(T.getVars())===JSON.stringify(this.arguments_)||(T=null),!T){_.module$build$src$core$events$events.setGroup(h.group),h=_.module$build$src$core$utils$xml.createElement("xml"),T=_.module$build$src$core$utils$xml.createElement("block"),T.setAttribute("type",this.defType_);var m=this.getRelativeToSurfaceXY(),O=m.y+2*_.config$$module$build$src$core$config.snapRadius;T.setAttribute("x",m.x+_.config$$module$build$src$core$config.snapRadius*(this.RTL?-1:1)),T.setAttribute("y",O),m=this.mutationToDom(),T.appendChild(m),m=_.module$build$src$core$utils$xml.createElement("field"),m.setAttribute("name","NAME"),O=this.getProcedureCall();const S=_.module$build$src$core$procedures.findLegalName(O,this);O!==S&&this.renameProcedure(O,S),m.appendChild(_.module$build$src$core$utils$xml.createTextNode(O)),T.appendChild(m),h.appendChild(T),_.module$build$src$core$xml.domToWorkspace(h,this.workspace),_.module$build$src$core$events$events.setGroup(!1)}}else h.type===_.module$build$src$core$events$events.BLOCK_DELETE?(T=this.getProcedureCall(),_.module$build$src$core$procedures.getDefinition(T,this.workspace)||(_.module$build$src$core$events$events.setGroup(h.group),this.dispose(!0),_.module$build$src$core$events$events.setGroup(!1))):h.type===_.module$build$src$core$events$events.CHANGE&&h.element==="disabled"&&(T=this.getProcedureCall(),(T=_.module$build$src$core$procedures.getDefinition(T,this.workspace))&&T.id===h.blockId&&((T=_.module$build$src$core$events$events.getGroup())&&console.log("Saw an existing group while responding to a definition change"),_.module$build$src$core$events$events.setGroup(h.group),h.newValue?(this.previousEnabledState_=this.isEnabled(),this.setEnabled(!1)):this.setEnabled(this.previousEnabledState_),_.module$build$src$core$events$events.setGroup(T)))},customContextMenu:function(h){if(this.workspace.isMovable()){var T={enabled:!0};T.text=Z.PROCEDURES_HIGHLIGHT_DEF;var m=this.getProcedureCall(),O=this.workspace;T.callback=function(){const S=_.module$build$src$core$procedures.getDefinition(m,O);S&&(O.centerOnBlock(S.id),S.select())},h.push(T)}}};Fe.blocks.procedures_callnoreturn=Object.assign({},Oe,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(Z.PROCEDURES_CALLNORETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null,this.previousEnabledState_=!0},defType_:"procedures_defnoreturn"}),Fe.blocks.procedures_callreturn=Object.assign({},Oe,{init:function(){this.appendDummyInput("TOPROW").appendField("","NAME"),this.setOutput(!0),this.setStyle("procedure_blocks"),this.setHelpUrl(Z.PROCEDURES_CALLRETURN_HELPURL),this.arguments_=[],this.argumentVarModels_=[],this.quarkConnections_={},this.quarkIds_=null,this.previousEnabledState_=!0},defType_:"procedures_defreturn"}),Fe.blocks.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Z.CONTROLS_IF_MSG_IF),this.appendValueInput("VALUE").appendField(Z.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setStyle("procedure_blocks"),this.setTooltip(Z.PROCEDURES_IFRETURN_TOOLTIP),this.setHelpUrl(Z.PROCEDURES_IFRETURN_HELPURL),this.hasReturnValue_=!0},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");return h.setAttribute("value",Number(this.hasReturnValue_)),h},domToMutation:function(h){this.hasReturnValue_=h.getAttribute("value")==="1",this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Z.PROCEDURES_DEFRETURN_RETURN))},onchange:function(h){if(!(this.workspace.isDragging&&this.workspace.isDragging()||h.type!==_.module$build$src$core$events$events.BLOCK_MOVE)){var T=!1,m=this;do{if(this.FUNCTION_TYPES.indexOf(m.type)!==-1){T=!0;break}m=m.getSurroundParent()}while(m);T?(m.type==="procedures_defnoreturn"&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Z.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):m.type!=="procedures_defreturn"||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(Z.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(Z.PROCEDURES_IFRETURN_WARNING),this.isInFlyout||(m=_.module$build$src$core$events$events.getGroup(),_.module$build$src$core$events$events.setGroup(h.group),this.setEnabled(T),_.module$build$src$core$events$events.setGroup(m))}},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]},ve(Fe.blocks);var K={};_.module$build$src$core$extensions;var C=_.module$build$src$core$msg.Msg;_.module$build$src$core$field_registry,_.module$build$src$core$utils$xml,_.Align$$module$build$src$core$input,_.module$build$src$core$connection_type.ConnectionType,_.Mutator$$module$build$src$core$mutator;var bi=_.module$build$src$core$common.createBlockDefinitionsFromJsonArray,Bo=_.module$build$src$core$common.defineBlocks;K.blocks=bi([{type:"text",message0:"%1",args0:[{type:"field_input",name:"TEXT",text:""}],output:["String","string"],style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["text_quotes","parent_tooltip_when_inline"]},{type:"text_multiline",message0:"%1 %2",args0:[{type:"field_image",src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAARCAYAAADpPU2iAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAdhgAAHYYBXaITgQAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMS42/U4J6AAAAP1JREFUOE+Vks0KQUEYhjmRIja4ABtZ2dm5A3t3Ia6AUm7CylYuQRaUhZSlLZJiQbFAyRnPN33y01HOW08z8873zpwzM4F3GWOCruvGIE4/rLaV+Nq1hVGMBqzhqlxgCys4wJA65xnogMHsQ5lujnYHTejBBCK2mE4abjCgMGhNxHgDFWjDSG07kdfVa2pZMf4ZyMAdWmpZMfYOsLiDMYMjlMB+K613QISRhTnITnsYg5yUd0DETmEoMlkFOeIT/A58iyK5E18BuTBfgYXfwNJv4P9/oEBerLylOnRhygmGdPpTTBZAPkde61lbQe4moWUvYUZYLfUNftIY4zwA5X2Z9AYnQrEAAAAASUVORK5CYII=",width:12,height:17,alt:"¶"},{type:"field_multilinetext",name:"TEXT",text:""}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_TEXT_HELPURL}",tooltip:"%{BKY_TEXT_TEXT_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"text_join",message0:"",output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_JOIN_HELPURL}",tooltip:"%{BKY_TEXT_JOIN_TOOLTIP}",mutator:"text_join_mutator"},{type:"text_create_join_container",message0:"%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2",args0:[{type:"input_dummy"},{type:"input_statement",name:"STACK"}],style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_TOOLTIP}",enableContextMenu:!1},{type:"text_create_join_item",message0:"%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}",previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:"%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}",enableContextMenu:!1},{type:"text_append",message0:"%{BKY_TEXT_APPEND_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_TEXT_APPEND_VARIABLE}"},{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",extensions:["text_append_tooltip"]},{type:"text_length",message0:"%{BKY_TEXT_LENGTH_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"text_blocks",tooltip:"%{BKY_TEXT_LENGTH_TOOLTIP}",helpUrl:"%{BKY_TEXT_LENGTH_HELPURL}"},{type:"text_isEmpty",message0:"%{BKY_TEXT_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"text_blocks",tooltip:"%{BKY_TEXT_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_TEXT_ISEMPTY_HELPURL}"},{type:"text_indexOf",message0:"%{BKY_TEXT_INDEXOF_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"END",options:[["%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}","FIRST"],["%{BKY_TEXT_INDEXOF_OPERATOR_LAST}","LAST"]]},{type:"input_value",name:"FIND",check:"String"}],output:"Number",style:"text_blocks",helpUrl:"%{BKY_TEXT_INDEXOF_HELPURL}",inputsInline:!0,extensions:["text_indexOf_tooltip"]},{type:"text_charAt",message0:"%{BKY_TEXT_CHARAT_TITLE}",args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",name:"WHERE",options:[["%{BKY_TEXT_CHARAT_FROM_START}","FROM_START"],["%{BKY_TEXT_CHARAT_FROM_END}","FROM_END"],["%{BKY_TEXT_CHARAT_FIRST}","FIRST"],["%{BKY_TEXT_CHARAT_LAST}","LAST"],["%{BKY_TEXT_CHARAT_RANDOM}","RANDOM"]]}],output:"String",style:"text_blocks",helpUrl:"%{BKY_TEXT_CHARAT_HELPURL}",inputsInline:!0,mutator:"text_charAt_mutator"}]),K.blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[C.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[C.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[C.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[C.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[C.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[C.TEXT_GET_SUBSTRING_END_LAST,"LAST"]],this.setHelpUrl(C.TEXT_GET_SUBSTRING_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("STRING").setCheck("String").appendField(C.TEXT_GET_SUBSTRING_INPUT_IN_TEXT),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),C.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(C.TEXT_GET_SUBSTRING_TAIL),this.setInputsInline(!0),this.setOutput(!0,"String"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(C.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");var T=this.getInput("AT1").type===_.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE;return h.setAttribute("at1",T),T=this.getInput("AT2").type===_.module$build$src$core$connection_type.ConnectionType.INPUT_VALUE,h.setAttribute("at2",T),h},domToMutation:function(h){const T=h.getAttribute("at1")==="true";h=h.getAttribute("at2")==="true",this.updateAt_(1,T),this.updateAt_(2,h)},updateAt_:function(h,T){this.removeInput("AT"+h),this.removeInput("ORDINAL"+h,!0),T?(this.appendValueInput("AT"+h).setCheck("Number"),C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+h).appendField(C.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+h),h===2&&C.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(C.TEXT_GET_SUBSTRING_TAIL));const m=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:this["WHERE_OPTIONS_"+h]});m.setValidator(function(O){const S=O==="FROM_START"||O==="FROM_END";if(S!==T){const te=this.getSourceBlock();return te.updateAt_(h,S),te.setFieldValue(O,"WHERE"+h),null}}),this.getInput("AT"+h).appendField(m,"WHERE"+h),h===1&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"))}},K.blocks.text_changeCase={init:function(){const h=[[C.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[C.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[C.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(C.TEXT_CHANGECASE_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("TEXT").setCheck("String").appendField(_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),"CASE"),this.setOutput(!0,"String"),this.setTooltip(C.TEXT_CHANGECASE_TOOLTIP)}},K.blocks.text_trim={init:function(){const h=[[C.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[C.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[C.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(C.TEXT_TRIM_HELPURL),this.setStyle("text_blocks"),this.appendValueInput("TEXT").setCheck("String").appendField(_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),"MODE"),this.setOutput(!0,"String"),this.setTooltip(C.TEXT_TRIM_TOOLTIP)}},K.blocks.text_print={init:function(){this.jsonInit({message0:C.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:C.TEXT_PRINT_TOOLTIP,helpUrl:C.TEXT_PRINT_HELPURL})}};var hs={updateType_:function(h){this.outputConnection.setCheck(h==="NUMBER"?"Number":"String")},mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");return h.setAttribute("type",this.getFieldValue("TYPE")),h},domToMutation:function(h){this.updateType_(h.getAttribute("type"))}};K.blocks.text_prompt_ext=Object.assign({},hs,{init:function(){var h=[[C.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[C.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(C.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks");const T=this;h=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),h.setValidator(function(m){T.updateType_(m)}),this.appendValueInput("TEXT").appendField(h,"TYPE"),this.setOutput(!0,"String"),this.setTooltip(function(){return T.getFieldValue("TYPE")==="TEXT"?C.TEXT_PROMPT_TOOLTIP_TEXT:C.TEXT_PROMPT_TOOLTIP_NUMBER})}}),K.blocks.text_prompt=Object.assign({},hs,{init:function(){this.mixin(ds);var h=[[C.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[C.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];const T=this;this.setHelpUrl(C.TEXT_PROMPT_HELPURL),this.setStyle("text_blocks"),h=_.module$build$src$core$field_registry.fromJson({type:"field_dropdown",options:h}),h.setValidator(function(m){T.updateType_(m)}),this.appendDummyInput().appendField(h,"TYPE").appendField(this.newQuote_(!0)).appendField(_.module$build$src$core$field_registry.fromJson({type:"field_input",text:""}),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),this.setTooltip(function(){return T.getFieldValue("TYPE")==="TEXT"?C.TEXT_PROMPT_TOOLTIP_TEXT:C.TEXT_PROMPT_TOOLTIP_NUMBER})}}),K.blocks.text_count={init:function(){this.jsonInit({message0:C.TEXT_COUNT_MESSAGE0,args0:[{type:"input_value",name:"SUB",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"Number",inputsInline:!0,style:"text_blocks",tooltip:C.TEXT_COUNT_TOOLTIP,helpUrl:C.TEXT_COUNT_HELPURL})}},K.blocks.text_replace={init:function(){this.jsonInit({message0:C.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:C.TEXT_REPLACE_TOOLTIP,helpUrl:C.TEXT_REPLACE_HELPURL})}},K.blocks.text_reverse={init:function(){this.jsonInit({message0:C.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:C.TEXT_REVERSE_TOOLTIP,helpUrl:C.TEXT_REVERSE_HELPURL})}};var ds={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(h){for(let T=0,m;m=this.inputList[T];T++)for(let O=0,S;S=m.fieldRow[O];O++)if(h===S.name){m.insertFieldAt(O,this.newQuote_(!0)),m.insertFieldAt(O+2,this.newQuote_(!1));return}console.warn('field named "'+h+'" not found in '+this.toDevString())},newQuote_:function(h){return h=this.RTL?!h:h,_.module$build$src$core$field_registry.fromJson({type:"field_image",src:h?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,width:this.QUOTE_IMAGE_WIDTH,height:this.QUOTE_IMAGE_HEIGHT,alt:h?"“":"”"})}},F=function(){this.mixin(ds),this.quoteField_("TEXT")},_s={mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");return h.setAttribute("items",this.itemCount_),h},domToMutation:function(h){this.itemCount_=parseInt(h.getAttribute("items"),10),this.updateShape_()},saveExtraState:function(){return{itemCount:this.itemCount_}},loadExtraState:function(h){this.itemCount_=h.itemCount,this.updateShape_()},decompose:function(h){const T=h.newBlock("text_create_join_container");T.initSvg();let m=T.getInput("STACK").connection;for(let O=0;O<this.itemCount_;O++){const S=h.newBlock("text_create_join_item");S.initSvg(),m.connect(S.previousConnection),m=S.nextConnection}return T},compose:function(h){var T=h.getInputTargetBlock("STACK");for(h=[];T;)T.isInsertionMarker()||h.push(T.valueConnection_),T=T.getNextBlock();for(T=0;T<this.itemCount_;T++){const m=this.getInput("ADD"+T).connection.targetConnection;m&&h.indexOf(m)===-1&&m.disconnect()}for(this.itemCount_=h.length,this.updateShape_(),T=0;T<this.itemCount_;T++)_.Mutator$$module$build$src$core$mutator.reconnect(h[T],this,"ADD"+T)},saveConnections:function(h){h=h.getInputTargetBlock("STACK");let T=0;for(;h;){if(h.isInsertionMarker()){h=h.getNextBlock();continue}const m=this.getInput("ADD"+T);h.valueConnection_=m&&m.connection.targetConnection,h=h.getNextBlock(),T++}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var h=0;h<this.itemCount_;h++)if(!this.getInput("ADD"+h)){const T=this.appendValueInput("ADD"+h).setAlign(_.Align$$module$build$src$core$input.RIGHT);h===0&&T.appendField(C.TEXT_JOIN_TITLE_CREATEWITH)}for(h=this.itemCount_;this.getInput("ADD"+h);h++)this.removeInput("ADD"+h)}},Ri=function(){this.mixin(ds),this.itemCount_=2,this.updateShape_(),this.setMutator(new _.Mutator$$module$build$src$core$mutator(["text_create_join_item"],this))};_.module$build$src$core$extensions.register("text_append_tooltip",_.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));var Ii=function(){const h=this;this.setTooltip(function(){return C.TEXT_INDEXOF_TOOLTIP.replace("%1",h.workspace.options.oneBasedIndex?"0":"-1")})},Oi={mutationToDom:function(){const h=_.module$build$src$core$utils$xml.createElement("mutation");return h.setAttribute("at",!!this.isAt_),h},domToMutation:function(h){h=h.getAttribute("at")!=="false",this.updateAt_(h)},updateAt_:function(h){this.removeInput("AT",!0),this.removeInput("ORDINAL",!0),h&&(this.appendValueInput("AT").setCheck("Number"),C.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(C.ORDINAL_NUMBER_SUFFIX)),C.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(C.TEXT_CHARAT_TAIL)),this.isAt_=h}},bt=function(){this.getField("WHERE").setValidator(function(T){T=T==="FROM_START"||T==="FROM_END",T!==this.isAt_&&this.getSourceBlock().updateAt_(T)}),this.updateAt_(!0);const h=this;this.setTooltip(function(){var T=h.getFieldValue("WHERE");let m=C.TEXT_CHARAT_TOOLTIP;return(T==="FROM_START"||T==="FROM_END")&&(T=T==="FROM_START"?C.LISTS_INDEX_FROM_START_TOOLTIP:C.LISTS_INDEX_FROM_END_TOOLTIP)&&(m+=" "+T.replace("%1",h.workspace.options.oneBasedIndex?"#1":"#0")),m})};_.module$build$src$core$extensions.register("text_indexOf_tooltip",Ii),_.module$build$src$core$extensions.register("text_quotes",F),_.module$build$src$core$extensions.registerMutator("text_join_mutator",_s,Ri),_.module$build$src$core$extensions.registerMutator("text_charAt_mutator",Oi,bt),Bo(K.blocks);var Ce={};_.module$build$src$core$contextmenu,_.module$build$src$core$extensions,_.module$build$src$core$variables,_.module$build$src$core$utils$xml;var fo=_.module$build$src$core$msg.Msg,bo=_.module$build$src$core$common.createBlockDefinitionsFromJsonArray,I=_.module$build$src$core$common.defineBlocks;Ce.blocks=bo([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]);var U={customContextMenu:function(h){if(this.isInFlyout)(this.type==="variables_get"||this.type==="variables_get_reporter")&&(T={text:fo.RENAME_VARIABLE,enabled:!0,callback:ps(this)},O=this.getField("VAR").getText(),O={text:fo.DELETE_VARIABLE.replace("%1",O),enabled:!0,callback:se(this)},h.unshift(T),h.unshift(O));else{if(this.type==="variables_get")var T="variables_set",m=fo.VARIABLES_GET_CREATE_SET;else T="variables_get",m=fo.VARIABLES_SET_CREATE_GET;var O={enabled:0<this.workspace.remainingCapacity()},S=this.getField("VAR").getText();O.text=m.replace("%1",S),m=_.module$build$src$core$utils$xml.createElement("field"),m.setAttribute("name","VAR"),m.appendChild(_.module$build$src$core$utils$xml.createTextNode(S)),S=_.module$build$src$core$utils$xml.createElement("block"),S.setAttribute("type",T),S.appendChild(m),O.callback=_.module$build$src$core$contextmenu.callbackFactory(this,S),h.push(O)}}},ps=function(h){return function(){const T=h.workspace,m=h.getField("VAR").getVariable();_.module$build$src$core$variables.renameVariable(T,m)}},se=function(h){return function(){const T=h.workspace,m=h.getField("VAR").getVariable();T.deleteVariableById(m.getId()),T.refreshToolboxSelection()}};_.module$build$src$core$extensions.registerMixin("contextMenu_variableSetterGetter",U),I(Ce.blocks);var xo={};_.module$build$src$core$contextmenu,_.module$build$src$core$extensions,_.module$build$src$core$variables,_.module$build$src$core$utils$xml;var re=_.module$build$src$core$msg.Msg,Rt=_.module$build$src$core$common.createBlockDefinitionsFromJsonArray,Fo=_.module$build$src$core$common.defineBlocks;xo.blocks=Rt([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_dynamic_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableDynamicSetterGetter"]}]);var so={customContextMenu:function(h){if(this.isInFlyout)(this.type==="variables_get_dynamic"||this.type==="variables_get_reporter_dynamic")&&(T={text:re.RENAME_VARIABLE,enabled:!0,callback:Bt(this)},S=this.getField("VAR").getText(),S={text:re.DELETE_VARIABLE.replace("%1",S),enabled:!0,callback:xt(this)},h.unshift(T),h.unshift(S));else{var T=this.getFieldValue("VAR"),m=this.workspace.getVariableById(T).type;if(this.type==="variables_get_dynamic"){T="variables_set_dynamic";var O=re.VARIABLES_GET_CREATE_SET}else T="variables_get_dynamic",O=re.VARIABLES_SET_CREATE_GET;var S={enabled:0<this.workspace.remainingCapacity()};const te=this.getField("VAR").getText();S.text=O.replace("%1",te),O=_.module$build$src$core$utils$xml.createElement("field"),O.setAttribute("name","VAR"),O.setAttribute("variabletype",m),O.appendChild(_.module$build$src$core$utils$xml.createTextNode(te)),m=_.module$build$src$core$utils$xml.createElement("block"),m.setAttribute("type",T),m.appendChild(O),S.callback=_.module$build$src$core$contextmenu.callbackFactory(this,m),h.push(S)}},onchange:function(h){h=this.getFieldValue("VAR"),h=_.module$build$src$core$variables.getVariable(this.workspace,h),this.type==="variables_get_dynamic"?this.outputConnection.setCheck(h.type):this.getInput("VALUE").connection.setCheck(h.type)}},Bt=function(h){return function(){const T=h.workspace,m=h.getField("VAR").getVariable();_.module$build$src$core$variables.renameVariable(T,m)}},xt=function(h){return function(){const T=h.workspace,m=h.getField("VAR").getVariable();T.deleteVariableById(m.getId()),T.refreshToolboxSelection()}};_.module$build$src$core$extensions.registerMixin("contextMenu_variableDynamicSetterGetter",so),Fo(xo.blocks);var ct={colour:$e,math:mo};return ct.lists=he,ct.logic=d,ct.loops=et,ct.procedures=Fe,ct.texts=K,ct.variables=Ce,ct.variablesDynamic=xo,ct.blocks=Object.assign({},$e.blocks,he.blocks,d.blocks,et.blocks,mo.blocks,Fe.blocks,Ce.blocks,xo.blocks),ct.__namespace__=_,ct})}(Pu)),Pu.exports}var wg;function WT(){return wg||(wg=1,function(q,xe){(function(n,_){q.exports=_(VT())})(Ve,function(n){/**
|
|
799
|
+
* @license
|
|
800
|
+
* Copyright 2020 Google LLC
|
|
801
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
802
|
+
*/return n})}(Gu)),Gu.exports}var Bu={exports:{}},xu={exports:{}},Gg;function XT(){return Gg||(Gg=1,function(q,xe){(function(n,_){q.exports=_($i())})(Ve,function(n){var _=n.__namespace__,r={};_.module$build$src$core$variables,_.module$build$src$core$utils$string,_.CodeGenerator$$module$build$src$core$generator,_.module$build$src$core$input_types.inputTypes,_.module$build$src$core$names.Names,_.NameType$$module$build$src$core$names,r.javascriptGenerator=new _.CodeGenerator$$module$build$src$core$generator("JavaScript"),r.javascriptGenerator.addReservedWords("break,case,catch,class,const,continue,debugger,default,delete,do,else,export,extends,finally,for,function,if,import,in,instanceof,new,return,super,switch,this,throw,try,typeof,var,void,while,with,yield,enum,implements,interface,let,package,private,protected,public,static,await,null,true,false,arguments,"+Object.getOwnPropertyNames(globalThis).join(",")),r.javascriptGenerator.ORDER_ATOMIC=0,r.javascriptGenerator.ORDER_NEW=1.1,r.javascriptGenerator.ORDER_MEMBER=1.2,r.javascriptGenerator.ORDER_FUNCTION_CALL=2,r.javascriptGenerator.ORDER_INCREMENT=3,r.javascriptGenerator.ORDER_DECREMENT=3,r.javascriptGenerator.ORDER_BITWISE_NOT=4.1,r.javascriptGenerator.ORDER_UNARY_PLUS=4.2,r.javascriptGenerator.ORDER_UNARY_NEGATION=4.3,r.javascriptGenerator.ORDER_LOGICAL_NOT=4.4,r.javascriptGenerator.ORDER_TYPEOF=4.5,r.javascriptGenerator.ORDER_VOID=4.6,r.javascriptGenerator.ORDER_DELETE=4.7,r.javascriptGenerator.ORDER_AWAIT=4.8,r.javascriptGenerator.ORDER_EXPONENTIATION=5,r.javascriptGenerator.ORDER_MULTIPLICATION=5.1,r.javascriptGenerator.ORDER_DIVISION=5.2,r.javascriptGenerator.ORDER_MODULUS=5.3,r.javascriptGenerator.ORDER_SUBTRACTION=6.1,r.javascriptGenerator.ORDER_ADDITION=6.2,r.javascriptGenerator.ORDER_BITWISE_SHIFT=7,r.javascriptGenerator.ORDER_RELATIONAL=8,r.javascriptGenerator.ORDER_IN=8,r.javascriptGenerator.ORDER_INSTANCEOF=8,r.javascriptGenerator.ORDER_EQUALITY=9,r.javascriptGenerator.ORDER_BITWISE_AND=10,r.javascriptGenerator.ORDER_BITWISE_XOR=11,r.javascriptGenerator.ORDER_BITWISE_OR=12,r.javascriptGenerator.ORDER_LOGICAL_AND=13,r.javascriptGenerator.ORDER_LOGICAL_OR=14,r.javascriptGenerator.ORDER_CONDITIONAL=15,r.javascriptGenerator.ORDER_ASSIGNMENT=16,r.javascriptGenerator.ORDER_YIELD=17,r.javascriptGenerator.ORDER_COMMA=18,r.javascriptGenerator.ORDER_NONE=99,r.javascriptGenerator.ORDER_OVERRIDES=[[r.javascriptGenerator.ORDER_FUNCTION_CALL,r.javascriptGenerator.ORDER_MEMBER],[r.javascriptGenerator.ORDER_FUNCTION_CALL,r.javascriptGenerator.ORDER_FUNCTION_CALL],[r.javascriptGenerator.ORDER_MEMBER,r.javascriptGenerator.ORDER_MEMBER],[r.javascriptGenerator.ORDER_MEMBER,r.javascriptGenerator.ORDER_FUNCTION_CALL],[r.javascriptGenerator.ORDER_LOGICAL_NOT,r.javascriptGenerator.ORDER_LOGICAL_NOT],[r.javascriptGenerator.ORDER_MULTIPLICATION,r.javascriptGenerator.ORDER_MULTIPLICATION],[r.javascriptGenerator.ORDER_ADDITION,r.javascriptGenerator.ORDER_ADDITION],[r.javascriptGenerator.ORDER_LOGICAL_AND,r.javascriptGenerator.ORDER_LOGICAL_AND],[r.javascriptGenerator.ORDER_LOGICAL_OR,r.javascriptGenerator.ORDER_LOGICAL_OR]],r.javascriptGenerator.isInitialized=!1,r.javascriptGenerator.init=function(l){Object.getPrototypeOf(this).init.call(this),this.nameDB_?this.nameDB_.reset():this.nameDB_=new _.module$build$src$core$names.Names(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(l.getVariableMap()),this.nameDB_.populateVariables(l),this.nameDB_.populateProcedures(l);const d=[];var g=_.module$build$src$core$variables.allDeveloperVariables(l);for(let b=0;b<g.length;b++)d.push(this.nameDB_.getName(g[b],_.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));for(l=_.module$build$src$core$variables.allUsedVarModels(l),g=0;g<l.length;g++)d.push(this.nameDB_.getName(l[g].getId(),_.NameType$$module$build$src$core$names.VARIABLE));d.length&&(this.definitions_.variables="var "+d.join(", ")+";"),this.isInitialized=!0},r.javascriptGenerator.finish=function(l){const d=Object.values(this.definitions_);return l=Object.getPrototypeOf(this).finish.call(this,l),this.isInitialized=!1,this.nameDB_.reset(),d.join(`
|
|
803
|
+
|
|
804
|
+
`)+`
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
`+l},r.javascriptGenerator.scrubNakedValue=function(l){return l+`;
|
|
808
|
+
`},r.javascriptGenerator.quote_=function(l){return l=l.replace(/\\/g,"\\\\").replace(/\n/g,`\\
|
|
809
|
+
`).replace(/'/g,"\\'"),"'"+l+"'"},r.javascriptGenerator.multiline_quote_=function(l){return l.split(/\n/g).map(this.quote_).join(` + '\\n' +
|
|
810
|
+
`)},r.javascriptGenerator.scrub_=function(l,d,g){let b="";if(!l.outputConnection||!l.outputConnection.targetConnection){var N=l.getCommentText();N&&(N=_.module$build$src$core$utils$string.wrap(N,this.COMMENT_WRAP-3),b+=this.prefixLines(N+`
|
|
811
|
+
`,"// "));for(let G=0;G<l.inputList.length;G++)l.inputList[G].type===_.module$build$src$core$input_types.inputTypes.VALUE&&(N=l.inputList[G].connection.targetBlock())&&(N=this.allNestedComments(N))&&(b+=this.prefixLines(N,"// "))}return l=l.nextConnection&&l.nextConnection.targetBlock(),g=g?"":this.blockToCode(l),b+d+g},r.javascriptGenerator.getAdjusted=function(l,d,g,b,N){g=g||0,N=N||this.ORDER_NONE,l.workspace.options.oneBasedIndex&&g--;const G=l.workspace.options.oneBasedIndex?"1":"0";let Q,de=N;return 0<g?Q=de=this.ORDER_ADDITION:0>g?Q=de=this.ORDER_SUBTRACTION:b&&(Q=de=this.ORDER_UNARY_NEGATION),l=this.valueToCode(l,d,de)||G,_.module$build$src$core$utils$string.isNumber(l)?(l=Number(l)+g,b&&(l=-l)):(0<g?l=l+" + "+g:0>g&&(l=l+" - "+-g),b&&(l=g?"-("+l+")":"-"+l),Q=Math.floor(Q),N=Math.floor(N),Q&&N>=Q&&(l="("+l+")")),l},r.javascriptGenerator.colour_picker=function(l){return[r.javascriptGenerator.quote_(l.getFieldValue("COLOUR")),r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.colour_random=function(l){return[r.javascriptGenerator.provideFunction_("colourRandom",`
|
|
812
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}() {
|
|
813
|
+
var num = Math.floor(Math.random() * Math.pow(2, 24));
|
|
814
|
+
return '#' + ('00000' + num.toString(16)).substr(-6);
|
|
815
|
+
}
|
|
816
|
+
`)+"()",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.colour_rgb=function(l){const d=r.javascriptGenerator.valueToCode(l,"RED",r.javascriptGenerator.ORDER_NONE)||0,g=r.javascriptGenerator.valueToCode(l,"GREEN",r.javascriptGenerator.ORDER_NONE)||0;return l=r.javascriptGenerator.valueToCode(l,"BLUE",r.javascriptGenerator.ORDER_NONE)||0,[r.javascriptGenerator.provideFunction_("colourRgb",`
|
|
817
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) {
|
|
818
|
+
r = Math.max(Math.min(Number(r), 100), 0) * 2.55;
|
|
819
|
+
g = Math.max(Math.min(Number(g), 100), 0) * 2.55;
|
|
820
|
+
b = Math.max(Math.min(Number(b), 100), 0) * 2.55;
|
|
821
|
+
r = ('0' + (Math.round(r) || 0).toString(16)).slice(-2);
|
|
822
|
+
g = ('0' + (Math.round(g) || 0).toString(16)).slice(-2);
|
|
823
|
+
b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2);
|
|
824
|
+
return '#' + r + g + b;
|
|
825
|
+
}
|
|
826
|
+
`)+"("+d+", "+g+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.colour_blend=function(l){const d=r.javascriptGenerator.valueToCode(l,"COLOUR1",r.javascriptGenerator.ORDER_NONE)||"'#000000'",g=r.javascriptGenerator.valueToCode(l,"COLOUR2",r.javascriptGenerator.ORDER_NONE)||"'#000000'";return l=r.javascriptGenerator.valueToCode(l,"RATIO",r.javascriptGenerator.ORDER_NONE)||.5,[r.javascriptGenerator.provideFunction_("colourBlend",`
|
|
827
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) {
|
|
828
|
+
ratio = Math.max(Math.min(Number(ratio), 1), 0);
|
|
829
|
+
var r1 = parseInt(c1.substring(1, 3), 16);
|
|
830
|
+
var g1 = parseInt(c1.substring(3, 5), 16);
|
|
831
|
+
var b1 = parseInt(c1.substring(5, 7), 16);
|
|
832
|
+
var r2 = parseInt(c2.substring(1, 3), 16);
|
|
833
|
+
var g2 = parseInt(c2.substring(3, 5), 16);
|
|
834
|
+
var b2 = parseInt(c2.substring(5, 7), 16);
|
|
835
|
+
var r = Math.round(r1 * (1 - ratio) + r2 * ratio);
|
|
836
|
+
var g = Math.round(g1 * (1 - ratio) + g2 * ratio);
|
|
837
|
+
var b = Math.round(b1 * (1 - ratio) + b2 * ratio);
|
|
838
|
+
r = ('0' + (r || 0).toString(16)).slice(-2);
|
|
839
|
+
g = ('0' + (g || 0).toString(16)).slice(-2);
|
|
840
|
+
b = ('0' + (b || 0).toString(16)).slice(-2);
|
|
841
|
+
return '#' + r + g + b;
|
|
842
|
+
}
|
|
843
|
+
`)+"("+d+", "+g+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},_.NameType$$module$build$src$core$names,r.javascriptGenerator.lists_create_empty=function(l){return["[]",r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.lists_create_with=function(l){const d=Array(l.itemCount_);for(let g=0;g<l.itemCount_;g++)d[g]=r.javascriptGenerator.valueToCode(l,"ADD"+g,r.javascriptGenerator.ORDER_NONE)||"null";return["["+d.join(", ")+"]",r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.lists_repeat=function(l){const d=r.javascriptGenerator.provideFunction_("listsRepeat",`
|
|
844
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(value, n) {
|
|
845
|
+
var array = [];
|
|
846
|
+
for (var i = 0; i < n; i++) {
|
|
847
|
+
array[i] = value;
|
|
848
|
+
}
|
|
849
|
+
return array;
|
|
850
|
+
}
|
|
851
|
+
`),g=r.javascriptGenerator.valueToCode(l,"ITEM",r.javascriptGenerator.ORDER_NONE)||"null";return l=r.javascriptGenerator.valueToCode(l,"NUM",r.javascriptGenerator.ORDER_NONE)||"0",[d+"("+g+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.lists_length=function(l){return[(r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_MEMBER)||"[]")+".length",r.javascriptGenerator.ORDER_MEMBER]},r.javascriptGenerator.lists_isEmpty=function(l){return["!"+(r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_MEMBER)||"[]")+".length",r.javascriptGenerator.ORDER_LOGICAL_NOT]},r.javascriptGenerator.lists_indexOf=function(l){var d=l.getFieldValue("END")==="FIRST"?"indexOf":"lastIndexOf";const g=r.javascriptGenerator.valueToCode(l,"FIND",r.javascriptGenerator.ORDER_NONE)||"''";return d=(r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_MEMBER)||"[]")+"."+d+"("+g+")",l.workspace.options.oneBasedIndex?[d+" + 1",r.javascriptGenerator.ORDER_ADDITION]:[d,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.lists_getIndex=function(l){const d=l.getFieldValue("MODE")||"GET",g=l.getFieldValue("WHERE")||"FROM_START";var b=r.javascriptGenerator.valueToCode(l,"VALUE",g==="RANDOM"?r.javascriptGenerator.ORDER_NONE:r.javascriptGenerator.ORDER_MEMBER)||"[]";switch(g){case"FIRST":if(d==="GET")return[b+"[0]",r.javascriptGenerator.ORDER_MEMBER];if(d==="GET_REMOVE")return[b+".shift()",r.javascriptGenerator.ORDER_MEMBER];if(d==="REMOVE")return b+`.shift();
|
|
852
|
+
`;break;case"LAST":if(d==="GET")return[b+".slice(-1)[0]",r.javascriptGenerator.ORDER_MEMBER];if(d==="GET_REMOVE")return[b+".pop()",r.javascriptGenerator.ORDER_MEMBER];if(d==="REMOVE")return b+`.pop();
|
|
853
|
+
`;break;case"FROM_START":if(l=r.javascriptGenerator.getAdjusted(l,"AT"),d==="GET")return[b+"["+l+"]",r.javascriptGenerator.ORDER_MEMBER];if(d==="GET_REMOVE")return[b+".splice("+l+", 1)[0]",r.javascriptGenerator.ORDER_FUNCTION_CALL];if(d==="REMOVE")return b+".splice("+l+`, 1);
|
|
854
|
+
`;break;case"FROM_END":if(l=r.javascriptGenerator.getAdjusted(l,"AT",1,!0),d==="GET")return[b+".slice("+l+")[0]",r.javascriptGenerator.ORDER_FUNCTION_CALL];if(d==="GET_REMOVE")return[b+".splice("+l+", 1)[0]",r.javascriptGenerator.ORDER_FUNCTION_CALL];if(d==="REMOVE")return b+".splice("+l+", 1);";break;case"RANDOM":if(b=r.javascriptGenerator.provideFunction_("listsGetRandomItem",`
|
|
855
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, remove) {
|
|
856
|
+
var x = Math.floor(Math.random() * list.length);
|
|
857
|
+
if (remove) {
|
|
858
|
+
return list.splice(x, 1)[0];
|
|
859
|
+
} else {
|
|
860
|
+
return list[x];
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
`)+"("+b+", "+(d!=="GET")+")",d==="GET"||d==="GET_REMOVE")return[b,r.javascriptGenerator.ORDER_FUNCTION_CALL];if(d==="REMOVE")return b+`;
|
|
864
|
+
`}throw Error("Unhandled combination (lists_getIndex).")},r.javascriptGenerator.lists_setIndex=function(l){function d(){if(g.match(/^\w+$/))return"";const Q=r.javascriptGenerator.nameDB_.getDistinctName("tmpList",_.NameType$$module$build$src$core$names.VARIABLE),de="var "+Q+" = "+g+`;
|
|
865
|
+
`;return g=Q,de}let g=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_MEMBER)||"[]";const b=l.getFieldValue("MODE")||"GET";var N=l.getFieldValue("WHERE")||"FROM_START";const G=r.javascriptGenerator.valueToCode(l,"TO",r.javascriptGenerator.ORDER_ASSIGNMENT)||"null";switch(N){case"FIRST":if(b==="SET")return g+"[0] = "+G+`;
|
|
866
|
+
`;if(b==="INSERT")return g+".unshift("+G+`);
|
|
867
|
+
`;break;case"LAST":if(b==="SET")return d()+(g+"["+g+".length - 1] = "+G+`;
|
|
868
|
+
`);if(b==="INSERT")return g+".push("+G+`);
|
|
869
|
+
`;break;case"FROM_START":if(l=r.javascriptGenerator.getAdjusted(l,"AT"),b==="SET")return g+"["+l+"] = "+G+`;
|
|
870
|
+
`;if(b==="INSERT")return g+".splice("+l+", 0, "+G+`);
|
|
871
|
+
`;break;case"FROM_END":if(l=r.javascriptGenerator.getAdjusted(l,"AT",1,!1,r.javascriptGenerator.ORDER_SUBTRACTION),N=d(),b==="SET")return N+(g+"["+g+".length - "+l+"] = "+G+`;
|
|
872
|
+
`);if(b==="INSERT")return N+(g+".splice("+g+".length - "+l+", 0, "+G+`);
|
|
873
|
+
`);break;case"RANDOM":if(l=d(),N=r.javascriptGenerator.nameDB_.getDistinctName("tmpX",_.NameType$$module$build$src$core$names.VARIABLE),l+="var "+N+" = Math.floor(Math.random() * "+g+`.length);
|
|
874
|
+
`,b==="SET")return l+(g+"["+N+"] = "+G+`;
|
|
875
|
+
`);if(b==="INSERT")return l+(g+".splice("+N+", 0, "+G+`);
|
|
876
|
+
`)}throw Error("Unhandled combination (lists_setIndex).")};var $e=function(l,d,g){return d==="FIRST"?"0":d==="FROM_END"?l+".length - 1 - "+g:d==="LAST"?l+".length - 1":g};r.javascriptGenerator.lists_getSublist=function(l){var d=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_MEMBER)||"[]",g=l.getFieldValue("WHERE1"),b=l.getFieldValue("WHERE2");if(g==="FIRST"&&b==="LAST")d+=".slice(0)";else if(d.match(/^\w+$/)||g!=="FROM_END"&&b==="FROM_START"){switch(g){case"FROM_START":g=r.javascriptGenerator.getAdjusted(l,"AT1");break;case"FROM_END":g=r.javascriptGenerator.getAdjusted(l,"AT1",1,!1,r.javascriptGenerator.ORDER_SUBTRACTION),g=d+".length - "+g;break;case"FIRST":g="0";break;default:throw Error("Unhandled option (lists_getSublist).")}switch(b){case"FROM_START":b=r.javascriptGenerator.getAdjusted(l,"AT2",1);break;case"FROM_END":b=r.javascriptGenerator.getAdjusted(l,"AT2",0,!1,r.javascriptGenerator.ORDER_SUBTRACTION),b=d+".length - "+b;break;case"LAST":b=d+".length";break;default:throw Error("Unhandled option (lists_getSublist).")}d=d+".slice("+g+", "+b+")"}else{const N=r.javascriptGenerator.getAdjusted(l,"AT1");l=r.javascriptGenerator.getAdjusted(l,"AT2");const G={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};d=r.javascriptGenerator.provideFunction_("subsequence"+G[g]+G[b],`
|
|
877
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${g==="FROM_END"||g==="FROM_START"?", at1":""}${b==="FROM_END"||b==="FROM_START"?", at2":""}) {
|
|
878
|
+
var start = ${$e("sequence",g,"at1")};
|
|
879
|
+
var end = ${$e("sequence",b,"at2")} + 1;
|
|
880
|
+
return sequence.slice(start, end);
|
|
881
|
+
}
|
|
882
|
+
`)+"("+d+(g==="FROM_END"||g==="FROM_START"?", "+N:"")+(b==="FROM_END"||b==="FROM_START"?", "+l:"")+")"}return[d,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.lists_sort=function(l){const d=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]",g=l.getFieldValue("DIRECTION")==="1"?1:-1;l=l.getFieldValue("TYPE");const b=r.javascriptGenerator.provideFunction_("listsGetSortCompare",`
|
|
883
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(type, direction) {
|
|
884
|
+
var compareFuncs = {
|
|
885
|
+
'NUMERIC': function(a, b) {
|
|
886
|
+
return Number(a) - Number(b); },
|
|
887
|
+
'TEXT': function(a, b) {
|
|
888
|
+
return String(a) > String(b) ? 1 : -1; },
|
|
889
|
+
'IGNORE_CASE': function(a, b) {
|
|
890
|
+
return String(a).toLowerCase() > String(b).toLowerCase() ? 1 : -1; },
|
|
891
|
+
};
|
|
892
|
+
var compare = compareFuncs[type];
|
|
893
|
+
return function(a, b) { return compare(a, b) * direction; };
|
|
894
|
+
}
|
|
895
|
+
`);return[d+".slice().sort("+b+'("'+l+'", '+g+"))",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.lists_split=function(l){let d=r.javascriptGenerator.valueToCode(l,"INPUT",r.javascriptGenerator.ORDER_MEMBER);const g=r.javascriptGenerator.valueToCode(l,"DELIM",r.javascriptGenerator.ORDER_NONE)||"''";if(l=l.getFieldValue("MODE"),l==="SPLIT")d||(d="''"),l="split";else if(l==="JOIN")d||(d="[]"),l="join";else throw Error("Unknown mode: "+l);return[d+"."+l+"("+g+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.lists_reverse=function(l){return[(r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]")+".slice().reverse()",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.controls_if=function(l){var d=0;let g="";r.javascriptGenerator.STATEMENT_PREFIX&&(g+=r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_PREFIX,l));do{const b=r.javascriptGenerator.valueToCode(l,"IF"+d,r.javascriptGenerator.ORDER_NONE)||"false";let N=r.javascriptGenerator.statementToCode(l,"DO"+d);r.javascriptGenerator.STATEMENT_SUFFIX&&(N=r.javascriptGenerator.prefixLines(r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_SUFFIX,l),r.javascriptGenerator.INDENT)+N),g+=(0<d?" else ":"")+"if ("+b+`) {
|
|
896
|
+
`+N+"}",d++}while(l.getInput("IF"+d));return(l.getInput("ELSE")||r.javascriptGenerator.STATEMENT_SUFFIX)&&(d=r.javascriptGenerator.statementToCode(l,"ELSE"),r.javascriptGenerator.STATEMENT_SUFFIX&&(d=r.javascriptGenerator.prefixLines(r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_SUFFIX,l),r.javascriptGenerator.INDENT)+d),g+=` else {
|
|
897
|
+
`+d+"}"),g+`
|
|
898
|
+
`},r.javascriptGenerator.controls_ifelse=r.javascriptGenerator.controls_if,r.javascriptGenerator.logic_compare=function(l){const d={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[l.getFieldValue("OP")],g=d==="=="||d==="!="?r.javascriptGenerator.ORDER_EQUALITY:r.javascriptGenerator.ORDER_RELATIONAL,b=r.javascriptGenerator.valueToCode(l,"A",g)||"0";return l=r.javascriptGenerator.valueToCode(l,"B",g)||"0",[b+" "+d+" "+l,g]},r.javascriptGenerator.logic_operation=function(l){const d=l.getFieldValue("OP")==="AND"?"&&":"||",g=d==="&&"?r.javascriptGenerator.ORDER_LOGICAL_AND:r.javascriptGenerator.ORDER_LOGICAL_OR;let b=r.javascriptGenerator.valueToCode(l,"A",g);if(l=r.javascriptGenerator.valueToCode(l,"B",g),b||l){const N=d==="&&"?"true":"false";b||(b=N),l||(l=N)}else l=b="false";return[b+" "+d+" "+l,g]},r.javascriptGenerator.logic_negate=function(l){const d=r.javascriptGenerator.ORDER_LOGICAL_NOT;return["!"+(r.javascriptGenerator.valueToCode(l,"BOOL",d)||"true"),d]},r.javascriptGenerator.logic_boolean=function(l){return[l.getFieldValue("BOOL")==="TRUE"?"true":"false",r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.logic_null=function(l){return["null",r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.logic_ternary=function(l){const d=r.javascriptGenerator.valueToCode(l,"IF",r.javascriptGenerator.ORDER_CONDITIONAL)||"false",g=r.javascriptGenerator.valueToCode(l,"THEN",r.javascriptGenerator.ORDER_CONDITIONAL)||"null";return l=r.javascriptGenerator.valueToCode(l,"ELSE",r.javascriptGenerator.ORDER_CONDITIONAL)||"null",[d+" ? "+g+" : "+l,r.javascriptGenerator.ORDER_CONDITIONAL]},_.module$build$src$core$utils$string,_.NameType$$module$build$src$core$names,r.javascriptGenerator.controls_repeat_ext=function(l){let d;d=l.getField("TIMES")?String(Number(l.getFieldValue("TIMES"))):r.javascriptGenerator.valueToCode(l,"TIMES",r.javascriptGenerator.ORDER_ASSIGNMENT)||"0";let g=r.javascriptGenerator.statementToCode(l,"DO");g=r.javascriptGenerator.addLoopTrap(g,l),l="";const b=r.javascriptGenerator.nameDB_.getDistinctName("count",_.NameType$$module$build$src$core$names.VARIABLE);let N=d;return d.match(/^\w+$/)||_.module$build$src$core$utils$string.isNumber(d)||(N=r.javascriptGenerator.nameDB_.getDistinctName("repeat_end",_.NameType$$module$build$src$core$names.VARIABLE),l+="var "+N+" = "+d+`;
|
|
899
|
+
`),l+("for (var "+b+" = 0; "+b+" < "+N+"; "+b+`++) {
|
|
900
|
+
`+g+`}
|
|
901
|
+
`)},r.javascriptGenerator.controls_repeat=r.javascriptGenerator.controls_repeat_ext,r.javascriptGenerator.controls_whileUntil=function(l){const d=l.getFieldValue("MODE")==="UNTIL";let g=r.javascriptGenerator.valueToCode(l,"BOOL",d?r.javascriptGenerator.ORDER_LOGICAL_NOT:r.javascriptGenerator.ORDER_NONE)||"false",b=r.javascriptGenerator.statementToCode(l,"DO");return b=r.javascriptGenerator.addLoopTrap(b,l),d&&(g="!"+g),"while ("+g+`) {
|
|
902
|
+
`+b+`}
|
|
903
|
+
`},r.javascriptGenerator.controls_for=function(l){var d=r.javascriptGenerator.nameDB_.getName(l.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),g=r.javascriptGenerator.valueToCode(l,"FROM",r.javascriptGenerator.ORDER_ASSIGNMENT)||"0",b=r.javascriptGenerator.valueToCode(l,"TO",r.javascriptGenerator.ORDER_ASSIGNMENT)||"0";const N=r.javascriptGenerator.valueToCode(l,"BY",r.javascriptGenerator.ORDER_ASSIGNMENT)||"1";let G=r.javascriptGenerator.statementToCode(l,"DO");if(G=r.javascriptGenerator.addLoopTrap(G,l),_.module$build$src$core$utils$string.isNumber(g)&&_.module$build$src$core$utils$string.isNumber(b)&&_.module$build$src$core$utils$string.isNumber(N)){var Q=Number(g)<=Number(b);l="for ("+d+" = "+g+"; "+d+(Q?" <= ":" >= ")+b+"; "+d,d=Math.abs(Number(N)),l=d===1?l+(Q?"++":"--"):l+((Q?" += ":" -= ")+d),l+=`) {
|
|
904
|
+
`+G+`}
|
|
905
|
+
`}else l="",Q=g,g.match(/^\w+$/)||_.module$build$src$core$utils$string.isNumber(g)||(Q=r.javascriptGenerator.nameDB_.getDistinctName(d+"_start",_.NameType$$module$build$src$core$names.VARIABLE),l+="var "+Q+" = "+g+`;
|
|
906
|
+
`),g=b,b.match(/^\w+$/)||_.module$build$src$core$utils$string.isNumber(b)||(g=r.javascriptGenerator.nameDB_.getDistinctName(d+"_end",_.NameType$$module$build$src$core$names.VARIABLE),l+="var "+g+" = "+b+`;
|
|
907
|
+
`),b=r.javascriptGenerator.nameDB_.getDistinctName(d+"_inc",_.NameType$$module$build$src$core$names.VARIABLE),l+="var "+b+" = ",l=_.module$build$src$core$utils$string.isNumber(N)?l+(Math.abs(N)+`;
|
|
908
|
+
`):l+("Math.abs("+N+`);
|
|
909
|
+
`),l+="if ("+Q+" > "+g+`) {
|
|
910
|
+
`,l+=r.javascriptGenerator.INDENT+b+" = -"+b+`;
|
|
911
|
+
`,l=l+`}
|
|
912
|
+
for (`+(d+" = "+Q+"; "+b+" >= 0 ? "+d+" <= "+g+" : "+d+" >= "+g+"; "+d+" += "+b+`) {
|
|
913
|
+
`+G+`}
|
|
914
|
+
`);return l},r.javascriptGenerator.controls_forEach=function(l){const d=r.javascriptGenerator.nameDB_.getName(l.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE);var g=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_ASSIGNMENT)||"[]";let b=r.javascriptGenerator.statementToCode(l,"DO");b=r.javascriptGenerator.addLoopTrap(b,l),l="";let N=g;return g.match(/^\w+$/)||(N=r.javascriptGenerator.nameDB_.getDistinctName(d+"_list",_.NameType$$module$build$src$core$names.VARIABLE),l+="var "+N+" = "+g+`;
|
|
915
|
+
`),g=r.javascriptGenerator.nameDB_.getDistinctName(d+"_index",_.NameType$$module$build$src$core$names.VARIABLE),b=r.javascriptGenerator.INDENT+d+" = "+N+"["+g+`];
|
|
916
|
+
`+b,l+("for (var "+g+" in "+N+`) {
|
|
917
|
+
`+b+`}
|
|
918
|
+
`)},r.javascriptGenerator.controls_flow_statements=function(l){let d="";if(r.javascriptGenerator.STATEMENT_PREFIX&&(d+=r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_PREFIX,l)),r.javascriptGenerator.STATEMENT_SUFFIX&&(d+=r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_SUFFIX,l)),r.javascriptGenerator.STATEMENT_PREFIX){const g=l.getSurroundLoop();g&&!g.suppressPrefixSuffix&&(d+=r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_PREFIX,g))}switch(l.getFieldValue("FLOW")){case"BREAK":return d+`break;
|
|
919
|
+
`;case"CONTINUE":return d+`continue;
|
|
920
|
+
`}throw Error("Unknown flow statement.")},_.NameType$$module$build$src$core$names,r.javascriptGenerator.math_number=function(l){return l=Number(l.getFieldValue("NUM")),[l,0<=l?r.javascriptGenerator.ORDER_ATOMIC:r.javascriptGenerator.ORDER_UNARY_NEGATION]},r.javascriptGenerator.math_arithmetic=function(l){var d={ADD:[" + ",r.javascriptGenerator.ORDER_ADDITION],MINUS:[" - ",r.javascriptGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",r.javascriptGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",r.javascriptGenerator.ORDER_DIVISION],POWER:[null,r.javascriptGenerator.ORDER_NONE]}[l.getFieldValue("OP")];const g=d[0];d=d[1];const b=r.javascriptGenerator.valueToCode(l,"A",d)||"0";return l=r.javascriptGenerator.valueToCode(l,"B",d)||"0",g?[b+g+l,d]:["Math.pow("+b+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.math_single=function(l){const d=l.getFieldValue("OP");let g;if(d==="NEG")return l=r.javascriptGenerator.valueToCode(l,"NUM",r.javascriptGenerator.ORDER_UNARY_NEGATION)||"0",l[0]==="-"&&(l=" "+l),["-"+l,r.javascriptGenerator.ORDER_UNARY_NEGATION];switch(l=d==="SIN"||d==="COS"||d==="TAN"?r.javascriptGenerator.valueToCode(l,"NUM",r.javascriptGenerator.ORDER_DIVISION)||"0":r.javascriptGenerator.valueToCode(l,"NUM",r.javascriptGenerator.ORDER_NONE)||"0",d){case"ABS":g="Math.abs("+l+")";break;case"ROOT":g="Math.sqrt("+l+")";break;case"LN":g="Math.log("+l+")";break;case"EXP":g="Math.exp("+l+")";break;case"POW10":g="Math.pow(10,"+l+")";break;case"ROUND":g="Math.round("+l+")";break;case"ROUNDUP":g="Math.ceil("+l+")";break;case"ROUNDDOWN":g="Math.floor("+l+")";break;case"SIN":g="Math.sin("+l+" / 180 * Math.PI)";break;case"COS":g="Math.cos("+l+" / 180 * Math.PI)";break;case"TAN":g="Math.tan("+l+" / 180 * Math.PI)"}if(g)return[g,r.javascriptGenerator.ORDER_FUNCTION_CALL];switch(d){case"LOG10":g="Math.log("+l+") / Math.log(10)";break;case"ASIN":g="Math.asin("+l+") / Math.PI * 180";break;case"ACOS":g="Math.acos("+l+") / Math.PI * 180";break;case"ATAN":g="Math.atan("+l+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+d)}return[g,r.javascriptGenerator.ORDER_DIVISION]},r.javascriptGenerator.math_constant=function(l){return{PI:["Math.PI",r.javascriptGenerator.ORDER_MEMBER],E:["Math.E",r.javascriptGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",r.javascriptGenerator.ORDER_DIVISION],SQRT2:["Math.SQRT2",r.javascriptGenerator.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",r.javascriptGenerator.ORDER_MEMBER],INFINITY:["Infinity",r.javascriptGenerator.ORDER_ATOMIC]}[l.getFieldValue("CONSTANT")]},r.javascriptGenerator.math_number_property=function(l){var d={EVEN:[" % 2 === 0",r.javascriptGenerator.ORDER_MODULUS,r.javascriptGenerator.ORDER_EQUALITY],ODD:[" % 2 === 1",r.javascriptGenerator.ORDER_MODULUS,r.javascriptGenerator.ORDER_EQUALITY],WHOLE:[" % 1 === 0",r.javascriptGenerator.ORDER_MODULUS,r.javascriptGenerator.ORDER_EQUALITY],POSITIVE:[" > 0",r.javascriptGenerator.ORDER_RELATIONAL,r.javascriptGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",r.javascriptGenerator.ORDER_RELATIONAL,r.javascriptGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,r.javascriptGenerator.ORDER_MODULUS,r.javascriptGenerator.ORDER_EQUALITY],PRIME:[null,r.javascriptGenerator.ORDER_NONE,r.javascriptGenerator.ORDER_FUNCTION_CALL]};const g=l.getFieldValue("PROPERTY"),[b,N,G]=d[g];return d=r.javascriptGenerator.valueToCode(l,"NUMBER_TO_CHECK",N)||"0",g==="PRIME"?l=r.javascriptGenerator.provideFunction_("mathIsPrime",`
|
|
921
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) {
|
|
922
|
+
// https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
923
|
+
if (n == 2 || n == 3) {
|
|
924
|
+
return true;
|
|
925
|
+
}
|
|
926
|
+
// False if n is NaN, negative, is 1, or not whole.
|
|
927
|
+
// And false if n is divisible by 2 or 3.
|
|
928
|
+
if (isNaN(n) || n <= 1 || n % 1 !== 0 || n % 2 === 0 || n % 3 === 0) {
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
// Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
932
|
+
for (var x = 6; x <= Math.sqrt(n) + 1; x += 6) {
|
|
933
|
+
if (n % (x - 1) === 0 || n % (x + 1) === 0) {
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
939
|
+
`)+"("+d+")":g==="DIVISIBLE_BY"?(l=r.javascriptGenerator.valueToCode(l,"DIVISOR",r.javascriptGenerator.ORDER_MODULUS)||"0",l=d+" % "+l+" === 0"):l=d+b,[l,G]},r.javascriptGenerator.math_change=function(l){const d=r.javascriptGenerator.valueToCode(l,"DELTA",r.javascriptGenerator.ORDER_ADDITION)||"0";return l=r.javascriptGenerator.nameDB_.getName(l.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),l+" = (typeof "+l+" === 'number' ? "+l+" : 0) + "+d+`;
|
|
940
|
+
`},r.javascriptGenerator.math_round=r.javascriptGenerator.math_single,r.javascriptGenerator.math_trig=r.javascriptGenerator.math_single,r.javascriptGenerator.math_on_list=function(l){var d=l.getFieldValue("OP");switch(d){case"SUM":l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_MEMBER)||"[]",l+=".reduce(function(x, y) {return x + y;}, 0)";break;case"MIN":l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l="Math.min.apply(null, "+l+")";break;case"MAX":l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l="Math.max.apply(null, "+l+")";break;case"AVERAGE":d=r.javascriptGenerator.provideFunction_("mathMean",`
|
|
941
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
942
|
+
return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length;
|
|
943
|
+
}
|
|
944
|
+
`),l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l=d+"("+l+")";break;case"MEDIAN":d=r.javascriptGenerator.provideFunction_("mathMedian",`
|
|
945
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) {
|
|
946
|
+
var localList = myList.filter(function (x) {return typeof x === 'number';});
|
|
947
|
+
if (!localList.length) return null;
|
|
948
|
+
localList.sort(function(a, b) {return b - a;});
|
|
949
|
+
if (localList.length % 2 === 0) {
|
|
950
|
+
return (localList[localList.length / 2 - 1] + localList[localList.length / 2]) / 2;
|
|
951
|
+
} else {
|
|
952
|
+
return localList[(localList.length - 1) / 2];
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
`),l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l=d+"("+l+")";break;case"MODE":d=r.javascriptGenerator.provideFunction_("mathModes",`
|
|
956
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(values) {
|
|
957
|
+
var modes = [];
|
|
958
|
+
var counts = [];
|
|
959
|
+
var maxCount = 0;
|
|
960
|
+
for (var i = 0; i < values.length; i++) {
|
|
961
|
+
var value = values[i];
|
|
962
|
+
var found = false;
|
|
963
|
+
var thisCount;
|
|
964
|
+
for (var j = 0; j < counts.length; j++) {
|
|
965
|
+
if (counts[j][0] === value) {
|
|
966
|
+
thisCount = ++counts[j][1];
|
|
967
|
+
found = true;
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (!found) {
|
|
972
|
+
counts.push([value, 1]);
|
|
973
|
+
thisCount = 1;
|
|
974
|
+
}
|
|
975
|
+
maxCount = Math.max(thisCount, maxCount);
|
|
976
|
+
}
|
|
977
|
+
for (var j = 0; j < counts.length; j++) {
|
|
978
|
+
if (counts[j][1] === maxCount) {
|
|
979
|
+
modes.push(counts[j][0]);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return modes;
|
|
983
|
+
}
|
|
984
|
+
`),l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l=d+"("+l+")";break;case"STD_DEV":d=r.javascriptGenerator.provideFunction_("mathStandardDeviation",`
|
|
985
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers) {
|
|
986
|
+
var n = numbers.length;
|
|
987
|
+
if (!n) return null;
|
|
988
|
+
var mean = numbers.reduce(function(x, y) {return x + y;}) / n;
|
|
989
|
+
var variance = 0;
|
|
990
|
+
for (var j = 0; j < n; j++) {
|
|
991
|
+
variance += Math.pow(numbers[j] - mean, 2);
|
|
992
|
+
}
|
|
993
|
+
variance = variance / n;
|
|
994
|
+
return Math.sqrt(variance);
|
|
995
|
+
}
|
|
996
|
+
`),l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l=d+"("+l+")";break;case"RANDOM":d=r.javascriptGenerator.provideFunction_("mathRandomList",`
|
|
997
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list) {
|
|
998
|
+
var x = Math.floor(Math.random() * list.length);
|
|
999
|
+
return list[x];
|
|
1000
|
+
}
|
|
1001
|
+
`),l=r.javascriptGenerator.valueToCode(l,"LIST",r.javascriptGenerator.ORDER_NONE)||"[]",l=d+"("+l+")";break;default:throw Error("Unknown operator: "+d)}return[l,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.math_modulo=function(l){const d=r.javascriptGenerator.valueToCode(l,"DIVIDEND",r.javascriptGenerator.ORDER_MODULUS)||"0";return l=r.javascriptGenerator.valueToCode(l,"DIVISOR",r.javascriptGenerator.ORDER_MODULUS)||"0",[d+" % "+l,r.javascriptGenerator.ORDER_MODULUS]},r.javascriptGenerator.math_constrain=function(l){const d=r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_NONE)||"0",g=r.javascriptGenerator.valueToCode(l,"LOW",r.javascriptGenerator.ORDER_NONE)||"0";return l=r.javascriptGenerator.valueToCode(l,"HIGH",r.javascriptGenerator.ORDER_NONE)||"Infinity",["Math.min(Math.max("+d+", "+g+"), "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.math_random_int=function(l){const d=r.javascriptGenerator.valueToCode(l,"FROM",r.javascriptGenerator.ORDER_NONE)||"0";return l=r.javascriptGenerator.valueToCode(l,"TO",r.javascriptGenerator.ORDER_NONE)||"0",[r.javascriptGenerator.provideFunction_("mathRandomInt",`
|
|
1002
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(a, b) {
|
|
1003
|
+
if (a > b) {
|
|
1004
|
+
// Swap a and b to ensure a is smaller.
|
|
1005
|
+
var c = a;
|
|
1006
|
+
a = b;
|
|
1007
|
+
b = c;
|
|
1008
|
+
}
|
|
1009
|
+
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
1010
|
+
}
|
|
1011
|
+
`)+"("+d+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.math_random_float=function(l){return["Math.random()",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.math_atan2=function(l){const d=r.javascriptGenerator.valueToCode(l,"X",r.javascriptGenerator.ORDER_NONE)||"0";return["Math.atan2("+(r.javascriptGenerator.valueToCode(l,"Y",r.javascriptGenerator.ORDER_NONE)||"0")+", "+d+") / Math.PI * 180",r.javascriptGenerator.ORDER_DIVISION]},_.NameType$$module$build$src$core$names,r.javascriptGenerator.procedures_defreturn=function(l){const d=r.javascriptGenerator.nameDB_.getName(l.getFieldValue("NAME"),_.NameType$$module$build$src$core$names.PROCEDURE);var g="";r.javascriptGenerator.STATEMENT_PREFIX&&(g+=r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_PREFIX,l)),r.javascriptGenerator.STATEMENT_SUFFIX&&(g+=r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_SUFFIX,l)),g&&(g=r.javascriptGenerator.prefixLines(g,r.javascriptGenerator.INDENT));let b="";r.javascriptGenerator.INFINITE_LOOP_TRAP&&(b=r.javascriptGenerator.prefixLines(r.javascriptGenerator.injectId(r.javascriptGenerator.INFINITE_LOOP_TRAP,l),r.javascriptGenerator.INDENT));const N=r.javascriptGenerator.statementToCode(l,"STACK");let G=r.javascriptGenerator.valueToCode(l,"RETURN",r.javascriptGenerator.ORDER_NONE)||"",Q="";N&&G&&(Q=g),G&&(G=r.javascriptGenerator.INDENT+"return "+G+`;
|
|
1012
|
+
`);const de=[],Y=l.getVars();for(let Re=0;Re<Y.length;Re++)de[Re]=r.javascriptGenerator.nameDB_.getName(Y[Re],_.NameType$$module$build$src$core$names.VARIABLE);return g="function "+d+"("+de.join(", ")+`) {
|
|
1013
|
+
`+g+b+N+Q+G+"}",g=r.javascriptGenerator.scrub_(l,g),r.javascriptGenerator.definitions_["%"+d]=g,null},r.javascriptGenerator.procedures_defnoreturn=r.javascriptGenerator.procedures_defreturn,r.javascriptGenerator.procedures_callreturn=function(l){const d=r.javascriptGenerator.nameDB_.getName(l.getFieldValue("NAME"),_.NameType$$module$build$src$core$names.PROCEDURE),g=[],b=l.getVars();for(let N=0;N<b.length;N++)g[N]=r.javascriptGenerator.valueToCode(l,"ARG"+N,r.javascriptGenerator.ORDER_NONE)||"null";return[d+"("+g.join(", ")+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.procedures_callnoreturn=function(l){return r.javascriptGenerator.procedures_callreturn(l)[0]+`;
|
|
1014
|
+
`},r.javascriptGenerator.procedures_ifreturn=function(l){let d="if ("+(r.javascriptGenerator.valueToCode(l,"CONDITION",r.javascriptGenerator.ORDER_NONE)||"false")+`) {
|
|
1015
|
+
`;return r.javascriptGenerator.STATEMENT_SUFFIX&&(d+=r.javascriptGenerator.prefixLines(r.javascriptGenerator.injectId(r.javascriptGenerator.STATEMENT_SUFFIX,l),r.javascriptGenerator.INDENT)),l.hasReturnValue_?(l=r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_NONE)||"null",d+=r.javascriptGenerator.INDENT+"return "+l+`;
|
|
1016
|
+
`):d+=r.javascriptGenerator.INDENT+`return;
|
|
1017
|
+
`,d+`}
|
|
1018
|
+
`},_.NameType$$module$build$src$core$names;var he=/^\s*'([^']|\\')*'\s*$/,u=function(l){return he.test(l)?[l,r.javascriptGenerator.ORDER_ATOMIC]:["String("+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},c=function(l,d,g){return d==="FIRST"?"0":d==="FROM_END"?l+".length - 1 - "+g:d==="LAST"?l+".length - 1":g};return r.javascriptGenerator.text=function(l){return[r.javascriptGenerator.quote_(l.getFieldValue("TEXT")),r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.text_multiline=function(l){l=r.javascriptGenerator.multiline_quote_(l.getFieldValue("TEXT"));const d=l.indexOf("+")!==-1?r.javascriptGenerator.ORDER_ADDITION:r.javascriptGenerator.ORDER_ATOMIC;return[l,d]},r.javascriptGenerator.text_join=function(l){switch(l.itemCount_){case 0:return["''",r.javascriptGenerator.ORDER_ATOMIC];case 1:return l=r.javascriptGenerator.valueToCode(l,"ADD0",r.javascriptGenerator.ORDER_NONE)||"''",u(l);case 2:var d=r.javascriptGenerator.valueToCode(l,"ADD0",r.javascriptGenerator.ORDER_NONE)||"''";return l=r.javascriptGenerator.valueToCode(l,"ADD1",r.javascriptGenerator.ORDER_NONE)||"''",[u(d)[0]+" + "+u(l)[0],r.javascriptGenerator.ORDER_ADDITION];default:d=Array(l.itemCount_);for(let g=0;g<l.itemCount_;g++)d[g]=r.javascriptGenerator.valueToCode(l,"ADD"+g,r.javascriptGenerator.ORDER_NONE)||"''";return["["+d.join(",")+"].join('')",r.javascriptGenerator.ORDER_FUNCTION_CALL]}},r.javascriptGenerator.text_append=function(l){const d=r.javascriptGenerator.nameDB_.getName(l.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE);return l=r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_NONE)||"''",d+" += "+u(l)[0]+`;
|
|
1019
|
+
`},r.javascriptGenerator.text_length=function(l){return[(r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_MEMBER)||"''")+".length",r.javascriptGenerator.ORDER_MEMBER]},r.javascriptGenerator.text_isEmpty=function(l){return["!"+(r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_MEMBER)||"''")+".length",r.javascriptGenerator.ORDER_LOGICAL_NOT]},r.javascriptGenerator.text_indexOf=function(l){var d=l.getFieldValue("END")==="FIRST"?"indexOf":"lastIndexOf";const g=r.javascriptGenerator.valueToCode(l,"FIND",r.javascriptGenerator.ORDER_NONE)||"''";return d=(r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_MEMBER)||"''")+"."+d+"("+g+")",l.workspace.options.oneBasedIndex?[d+" + 1",r.javascriptGenerator.ORDER_ADDITION]:[d,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_charAt=function(l){const d=l.getFieldValue("WHERE")||"FROM_START",g=r.javascriptGenerator.valueToCode(l,"VALUE",d==="RANDOM"?r.javascriptGenerator.ORDER_NONE:r.javascriptGenerator.ORDER_MEMBER)||"''";switch(d){case"FIRST":return[g+".charAt(0)",r.javascriptGenerator.ORDER_FUNCTION_CALL];case"LAST":return[g+".slice(-1)",r.javascriptGenerator.ORDER_FUNCTION_CALL];case"FROM_START":return l=r.javascriptGenerator.getAdjusted(l,"AT"),[g+".charAt("+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL];case"FROM_END":return l=r.javascriptGenerator.getAdjusted(l,"AT",1,!0),[g+".slice("+l+").charAt(0)",r.javascriptGenerator.ORDER_FUNCTION_CALL];case"RANDOM":return[r.javascriptGenerator.provideFunction_("textRandomLetter",`
|
|
1020
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(text) {
|
|
1021
|
+
var x = Math.floor(Math.random() * text.length);
|
|
1022
|
+
return text[x];
|
|
1023
|
+
}
|
|
1024
|
+
`)+"("+g+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).")},r.javascriptGenerator.text_getSubstring=function(l){var d=l.getFieldValue("WHERE1"),g=l.getFieldValue("WHERE2"),b=d!=="FROM_END"&&d!=="LAST"&&g!=="FROM_END"&&g!=="LAST",N=r.javascriptGenerator.valueToCode(l,"STRING",b?r.javascriptGenerator.ORDER_MEMBER:r.javascriptGenerator.ORDER_NONE)||"''";if(d==="FIRST"&&g==="LAST")return[N,r.javascriptGenerator.ORDER_NONE];if(N.match(/^'?\w+'?$/)||b){switch(d){case"FROM_START":d=r.javascriptGenerator.getAdjusted(l,"AT1");break;case"FROM_END":d=r.javascriptGenerator.getAdjusted(l,"AT1",1,!1,r.javascriptGenerator.ORDER_SUBTRACTION),d=N+".length - "+d;break;case"FIRST":d="0";break;default:throw Error("Unhandled option (text_getSubstring).")}switch(g){case"FROM_START":g=r.javascriptGenerator.getAdjusted(l,"AT2",1);break;case"FROM_END":g=r.javascriptGenerator.getAdjusted(l,"AT2",0,!1,r.javascriptGenerator.ORDER_SUBTRACTION),g=N+".length - "+g;break;case"LAST":g=N+".length";break;default:throw Error("Unhandled option (text_getSubstring).")}N=N+".slice("+d+", "+g+")"}else{b=r.javascriptGenerator.getAdjusted(l,"AT1"),l=r.javascriptGenerator.getAdjusted(l,"AT2");const G={FIRST:"First",LAST:"Last",FROM_START:"FromStart",FROM_END:"FromEnd"};N=r.javascriptGenerator.provideFunction_("subsequence"+G[d]+G[g],`
|
|
1025
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(sequence${d==="FROM_END"||d==="FROM_START"?", at1":""}${g==="FROM_END"||g==="FROM_START"?", at2":""}) {
|
|
1026
|
+
var start = ${c("sequence",d,"at1")};
|
|
1027
|
+
var end = ${c("sequence",g,"at2")} + 1;
|
|
1028
|
+
return sequence.slice(start, end);
|
|
1029
|
+
}
|
|
1030
|
+
`)+"("+N+(d==="FROM_END"||d==="FROM_START"?", "+b:"")+(g==="FROM_END"||g==="FROM_START"?", "+l:"")+")"}return[N,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_changeCase=function(l){const d={UPPERCASE:".toUpperCase()",LOWERCASE:".toLowerCase()",TITLECASE:null}[l.getFieldValue("CASE")];return l=r.javascriptGenerator.valueToCode(l,"TEXT",d?r.javascriptGenerator.ORDER_MEMBER:r.javascriptGenerator.ORDER_NONE)||"''",[d?l+d:r.javascriptGenerator.provideFunction_("textToTitleCase",`
|
|
1031
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(str) {
|
|
1032
|
+
return str.replace(/\\S+/g,
|
|
1033
|
+
function(txt) {return txt[0].toUpperCase() + txt.substring(1).toLowerCase();});
|
|
1034
|
+
}
|
|
1035
|
+
`)+"("+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_trim=function(l){const d={LEFT:".replace(/^[\\s\\xa0]+/, '')",RIGHT:".replace(/[\\s\\xa0]+$/, '')",BOTH:".trim()"}[l.getFieldValue("MODE")];return[(r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_MEMBER)||"''")+d,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_print=function(l){return"window.alert("+(r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_NONE)||"''")+`);
|
|
1036
|
+
`},r.javascriptGenerator.text_prompt_ext=function(l){let d="window.prompt("+(l.getField("TEXT")?r.javascriptGenerator.quote_(l.getFieldValue("TEXT")):r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_NONE)||"''")+")";return l.getFieldValue("TYPE")==="NUMBER"&&(d="Number("+d+")"),[d,r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_prompt=r.javascriptGenerator.text_prompt_ext,r.javascriptGenerator.text_count=function(l){const d=r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_NONE)||"''";return l=r.javascriptGenerator.valueToCode(l,"SUB",r.javascriptGenerator.ORDER_NONE)||"''",[r.javascriptGenerator.provideFunction_("textCount",`
|
|
1037
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle) {
|
|
1038
|
+
if (needle.length === 0) {
|
|
1039
|
+
return haystack.length + 1;
|
|
1040
|
+
} else {
|
|
1041
|
+
return haystack.split(needle).length - 1;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
`)+"("+d+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_replace=function(l){const d=r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_NONE)||"''",g=r.javascriptGenerator.valueToCode(l,"FROM",r.javascriptGenerator.ORDER_NONE)||"''";return l=r.javascriptGenerator.valueToCode(l,"TO",r.javascriptGenerator.ORDER_NONE)||"''",[r.javascriptGenerator.provideFunction_("textReplace",`
|
|
1045
|
+
function ${r.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement) {
|
|
1046
|
+
needle = needle.replace(/([-()\\[\\]{}+?*.$\\^|,:#<!\\\\])/g, '\\\\$1')
|
|
1047
|
+
.replace(/\\x08/g, '\\\\x08');
|
|
1048
|
+
return haystack.replace(new RegExp(needle, 'g'), replacement);
|
|
1049
|
+
}
|
|
1050
|
+
`)+"("+d+", "+g+", "+l+")",r.javascriptGenerator.ORDER_FUNCTION_CALL]},r.javascriptGenerator.text_reverse=function(l){return[(r.javascriptGenerator.valueToCode(l,"TEXT",r.javascriptGenerator.ORDER_MEMBER)||"''")+".split('').reverse().join('')",r.javascriptGenerator.ORDER_FUNCTION_CALL]},_.NameType$$module$build$src$core$names,r.javascriptGenerator.variables_get=function(l){return[r.javascriptGenerator.nameDB_.getName(l.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),r.javascriptGenerator.ORDER_ATOMIC]},r.javascriptGenerator.variables_set=function(l){const d=r.javascriptGenerator.valueToCode(l,"VALUE",r.javascriptGenerator.ORDER_ASSIGNMENT)||"0";return r.javascriptGenerator.nameDB_.getName(l.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE)+" = "+d+`;
|
|
1051
|
+
`},r.javascriptGenerator.variables_get_dynamic=r.javascriptGenerator.variables_get,r.javascriptGenerator.variables_set_dynamic=r.javascriptGenerator.variables_set,r.__namespace__=_,r})}(xu)),xu.exports}var Pg;function jT(){return Pg||(Pg=1,function(q,xe){(function(n,_){q.exports=_(jn(),XT())})(Ve,function(n,_){/**
|
|
1052
|
+
* @license
|
|
1053
|
+
* Copyright 2020 Google LLC
|
|
1054
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1055
|
+
*/return _})}(Bu)),Bu.exports}var Bg;function YT(){return Bg||(Bg=1,function(q,xe){(function(n,_){q.exports=_(jn(),Hg(),WT(),jT())})(Ve,function(n,_,r,$e){return n.setLocale(_),n})}(Lu)),Lu.exports}(function(q,xe){(function(n,_){q.exports=_(YT())})(Ve,function(n){/**
|
|
1056
|
+
* @license
|
|
1057
|
+
* Copyright 2019 Google LLC
|
|
1058
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1059
|
+
*/return n})})(Ug);var Vg=Ug.exports;const KT=Vu(Vg),QT=Hu({__proto__:null,default:KT},[Vg]);var Wg={exports:{}};(function(q,xe){(function(n,_){q.exports=_()})(Ve,function(){var n=n||{Msg:Object.create(null)};return n.Msg.ADD_COMMENT="Añadir comentario",n.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE="No se puede eliminar la variable '%1' porque es parte de la definición de la función '%2'",n.Msg.CHANGE_VALUE_TITLE="Cambiar el valor:",n.Msg.CLEAN_UP="Limpiar los bloques",n.Msg.COLLAPSED_WARNINGS_WARNING="Bloques colapsados contienen advertencias.",n.Msg.COLLAPSE_ALL="Contraer bloques",n.Msg.COLLAPSE_BLOCK="Contraer bloque",n.Msg.COLOUR_BLEND_COLOUR1="color 1",n.Msg.COLOUR_BLEND_COLOUR2="color 2",n.Msg.COLOUR_BLEND_HELPURL="https://meyerweb.com/eric/tools/color-blend/#:::rgbp",n.Msg.COLOUR_BLEND_RATIO="proporción",n.Msg.COLOUR_BLEND_TITLE="combinar",n.Msg.COLOUR_BLEND_TOOLTIP="Combina dos colores con una proporción determinada (0,0 - 1,0).",n.Msg.COLOUR_PICKER_HELPURL="https://es.wikipedia.org/wiki/Color",n.Msg.COLOUR_PICKER_TOOLTIP="Elige un color de la paleta.",n.Msg.COLOUR_RANDOM_HELPURL="http://randomcolour.com",n.Msg.COLOUR_RANDOM_TITLE="color aleatorio",n.Msg.COLOUR_RANDOM_TOOLTIP="Elige un color al azar.",n.Msg.COLOUR_RGB_BLUE="azul",n.Msg.COLOUR_RGB_GREEN="verde",n.Msg.COLOUR_RGB_HELPURL="https://www.december.com/html/spec/colorpercompact.html",n.Msg.COLOUR_RGB_RED="rojo",n.Msg.COLOUR_RGB_TITLE="colorear con",n.Msg.COLOUR_RGB_TOOLTIP="Crea un color con cantidades específicas de rojo, verde y azul. Todos los valores deben encontrarse entre 0 y 100.",n.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL="https://github.com/google/blockly/wiki/Loops#loop-termination-blocks",n.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK="romper el bucle",n.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE="continuar con la siguiente iteración del bucle",n.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK="Romper el bucle que lo contiene.",n.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE="Saltar el resto de este bucle, y continuar con la siguiente iteración.",n.Msg.CONTROLS_FLOW_STATEMENTS_WARNING="Atención: este bloque puede usarse solamente dentro de un bucle.",n.Msg.CONTROLS_FOREACH_HELPURL="https://es.wikipedia.org/wiki/Foreach",n.Msg.CONTROLS_FOREACH_TITLE="para cada elemento %1 en la lista %2",n.Msg.CONTROLS_FOREACH_TOOLTIP="Para cada elemento en una lista, establecer la variable '%1' al elemento y luego hacer algunas declaraciones.",n.Msg.CONTROLS_FOR_HELPURL="https://github.com/google/blockly/wiki/Loops#count-with",n.Msg.CONTROLS_FOR_TITLE="contar con %1 desde %2 hasta %3 de a %4",n.Msg.CONTROLS_FOR_TOOLTIP='Hacer que la variable "%1" tome los valores desde el número de inicio hasta el número final, contando con el intervalo especificado, y hacer los bloques especificados.',n.Msg.CONTROLS_IF_ELSEIF_TOOLTIP="Agregar una condición a este bloque.",n.Msg.CONTROLS_IF_ELSE_TOOLTIP="Agregar una condición general final a este bloque.",n.Msg.CONTROLS_IF_HELPURL="https://github.com/google/blockly/wiki/IfElse",n.Msg.CONTROLS_IF_IF_TOOLTIP="Agregar, eliminar o reordenar las secciones para reconfigurar este bloque.",n.Msg.CONTROLS_IF_MSG_ELSE="sino",n.Msg.CONTROLS_IF_MSG_ELSEIF="sino si",n.Msg.CONTROLS_IF_MSG_IF="si",n.Msg.CONTROLS_IF_TOOLTIP_1="Si un valor es verdadero, entonces hacer algunas declaraciones.",n.Msg.CONTROLS_IF_TOOLTIP_2="Si un valor es verdadero, entonces hacer el primer bloque de declaraciones. De lo contrario, hacer el segundo bloque de declaraciones.",n.Msg.CONTROLS_IF_TOOLTIP_3="Si el primer valor es verdadero, entonces hacer el primer bloque de declaraciones. De lo contrario, si el segundo valor es verdadero, hacer el segundo bloque de declaraciones.",n.Msg.CONTROLS_IF_TOOLTIP_4="Si el primer valor es verdadero, entonces hacer el primer bloque de declaraciones. De lo contrario, si el segundo valor es verdadero, hacer el segundo bloque de declaraciones. Si ninguno de los valores son verdaderos, hacer el último bloque de declaraciones.",n.Msg.CONTROLS_REPEAT_HELPURL="https://es.wikipedia.org/wiki/Bucle_for",n.Msg.CONTROLS_REPEAT_INPUT_DO="hacer",n.Msg.CONTROLS_REPEAT_TITLE="repetir %1 veces",n.Msg.CONTROLS_REPEAT_TOOLTIP="Hacer algunas declaraciones varias veces.",n.Msg.CONTROLS_WHILEUNTIL_HELPURL="https://github.com/google/blockly/wiki/Loops#repeat",n.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL="repetir hasta",n.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE="repetir mientras",n.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL="Mientras un valor sea falso, entonces hacer algunas declaraciones.",n.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE="Mientras un valor sea verdadero, entonces hacer algunas declaraciones.",n.Msg.DELETE_ALL_BLOCKS="¿Eliminar todos los %1 bloques?",n.Msg.DELETE_BLOCK="Eliminar bloque",n.Msg.DELETE_VARIABLE="Borrar la variable '%1'",n.Msg.DELETE_VARIABLE_CONFIRMATION="¿Borrar %1 usos de la variable '%2'?",n.Msg.DELETE_X_BLOCKS="Eliminar %1 bloques",n.Msg.DIALOG_CANCEL="Cancelar",n.Msg.DIALOG_OK="Aceptar",n.Msg.DISABLE_BLOCK="Desactivar bloque",n.Msg.DUPLICATE_BLOCK="Duplicar",n.Msg.DUPLICATE_COMMENT="Duplicar comentario",n.Msg.ENABLE_BLOCK="Activar bloque",n.Msg.EXPAND_ALL="Expandir bloques",n.Msg.EXPAND_BLOCK="Expandir bloque",n.Msg.EXTERNAL_INPUTS="Entradas externas",n.Msg.HELP="Ayuda",n.Msg.INLINE_INPUTS="Entradas en línea",n.Msg.LISTS_CREATE_EMPTY_HELPURL="https://github.com/google/blockly/wiki/Lists#create-empty-list",n.Msg.LISTS_CREATE_EMPTY_TITLE="crear lista vacía",n.Msg.LISTS_CREATE_EMPTY_TOOLTIP="Devuelve una lista, de longitud 0, sin ningún dato",n.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD="lista",n.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP="Agregar, eliminar o reorganizar las secciones para reconfigurar este bloque de lista.",n.Msg.LISTS_CREATE_WITH_HELPURL="https://github.com/google/blockly/wiki/Lists#create-list-with",n.Msg.LISTS_CREATE_WITH_INPUT_WITH="crear lista con",n.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP="Agregar un elemento a la lista.",n.Msg.LISTS_CREATE_WITH_TOOLTIP="Crear una lista con cualquier número de elementos.",n.Msg.LISTS_GET_INDEX_FIRST="primero",n.Msg.LISTS_GET_INDEX_FROM_END="# del final",n.Msg.LISTS_GET_INDEX_FROM_START="#",n.Msg.LISTS_GET_INDEX_GET="obtener",n.Msg.LISTS_GET_INDEX_GET_REMOVE="obtener y eliminar",n.Msg.LISTS_GET_INDEX_LAST="último",n.Msg.LISTS_GET_INDEX_RANDOM="aleatorio",n.Msg.LISTS_GET_INDEX_REMOVE="eliminar",n.Msg.LISTS_GET_INDEX_TAIL="",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST="Devuelve el primer elemento de una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM="Devuelve el elemento en la posición especificada en una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST="Devuelve el último elemento de una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM="Devuelve un elemento aleatorio en una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST="Elimina y devuelve el primer elemento de una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM="Elimina y devuelve el elemento en la posición especificada en una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST="Elimina y devuelve el último elemento de una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM="Elimina y devuelve un elemento aleatorio en una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST="Elimina el primer elemento de una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM="Elimina el elemento en la posición especificada en una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST="Elimina el último elemento de una lista.",n.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM="Elimina un elemento aleatorio en una lista.",n.Msg.LISTS_GET_SUBLIST_END_FROM_END="hasta # del final",n.Msg.LISTS_GET_SUBLIST_END_FROM_START="hasta #",n.Msg.LISTS_GET_SUBLIST_END_LAST="hasta el último",n.Msg.LISTS_GET_SUBLIST_HELPURL="https://github.com/google/blockly/wiki/Lists#getting-a-sublist",n.Msg.LISTS_GET_SUBLIST_START_FIRST="obtener sublista desde el primero",n.Msg.LISTS_GET_SUBLIST_START_FROM_END="obtener sublista desde # del final",n.Msg.LISTS_GET_SUBLIST_START_FROM_START="obtener sublista desde #",n.Msg.LISTS_GET_SUBLIST_TAIL="",n.Msg.LISTS_GET_SUBLIST_TOOLTIP="Crea una copia de la parte especificada de una lista.",n.Msg.LISTS_INDEX_FROM_END_TOOLTIP="%1 es el último elemento.",n.Msg.LISTS_INDEX_FROM_START_TOOLTIP="%1 es el primer elemento.",n.Msg.LISTS_INDEX_OF_FIRST="encontrar la primera aparición del elemento",n.Msg.LISTS_INDEX_OF_HELPURL="https://github.com/google/blockly/wiki/Lists#getting-items-from-a-list",n.Msg.LISTS_INDEX_OF_LAST="encontrar la última aparición del elemento",n.Msg.LISTS_INDEX_OF_TOOLTIP="Devuelve el índice de la primera/última aparición del elemento en la lista. Devuelve %1 si el elemento no se encuentra.",n.Msg.LISTS_INLIST="en la lista",n.Msg.LISTS_ISEMPTY_HELPURL="https://github.com/google/blockly/wiki/Lists#is-empty",n.Msg.LISTS_ISEMPTY_TITLE="%1 está vacía",n.Msg.LISTS_ISEMPTY_TOOLTIP="Devuelve verdadero si la lista está vacía.",n.Msg.LISTS_LENGTH_HELPURL="https://github.com/google/blockly/wiki/Lists#length-of",n.Msg.LISTS_LENGTH_TITLE="longitud de %1",n.Msg.LISTS_LENGTH_TOOLTIP="Devuelve la longitud de una lista.",n.Msg.LISTS_REPEAT_HELPURL="https://github.com/google/blockly/wiki/Lists#create-list-with",n.Msg.LISTS_REPEAT_TITLE="crear lista con el elemento %1 repetido %2 veces",n.Msg.LISTS_REPEAT_TOOLTIP="Crea una lista que consta de un valor dado repetido el número de veces especificado.",n.Msg.LISTS_REVERSE_HELPURL="https://github.com/google/blockly/wiki/Lists#reversing-a-list",n.Msg.LISTS_REVERSE_MESSAGE0="invertir %1",n.Msg.LISTS_REVERSE_TOOLTIP="Invertir una copia de una lista.",n.Msg.LISTS_SET_INDEX_HELPURL="https://github.com/google/blockly/wiki/Lists#in-list--set",n.Msg.LISTS_SET_INDEX_INPUT_TO="como",n.Msg.LISTS_SET_INDEX_INSERT="insertar en",n.Msg.LISTS_SET_INDEX_SET="establecer",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST="Inserta el elemento al inicio de una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM="Inserta el elemento en la posición especificada en una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST="Añade el elemento al final de una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM="Inserta el elemento aleatoriamente en una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST="Establece el primer elemento de una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM="Establece el elemento en la posición especificada en una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST="Establece el último elemento de una lista.",n.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM="Establece un elemento aleatorio en una lista.",n.Msg.LISTS_SORT_HELPURL="https://github.com/google/blockly/wiki/Lists#sorting-a-list",n.Msg.LISTS_SORT_ORDER_ASCENDING="ascendente",n.Msg.LISTS_SORT_ORDER_DESCENDING="descendente",n.Msg.LISTS_SORT_TITLE="orden %1 %2 %3",n.Msg.LISTS_SORT_TOOLTIP="Ordenar una copia de una lista.",n.Msg.LISTS_SORT_TYPE_IGNORECASE="alfabético, ignorar mayúscula/minúscula",n.Msg.LISTS_SORT_TYPE_NUMERIC="numérico",n.Msg.LISTS_SORT_TYPE_TEXT="alfabético",n.Msg.LISTS_SPLIT_HELPURL="https://github.com/google/blockly/wiki/Lists#splitting-strings-and-joining-lists",n.Msg.LISTS_SPLIT_LIST_FROM_TEXT="hacer lista a partir de texto",n.Msg.LISTS_SPLIT_TEXT_FROM_LIST="hacer texto a partir de lista",n.Msg.LISTS_SPLIT_TOOLTIP_JOIN="Unir una lista de textos en un solo texto, separado por un delimitador.",n.Msg.LISTS_SPLIT_TOOLTIP_SPLIT="Dividir el texto en una lista de textos, separando en cada delimitador.",n.Msg.LISTS_SPLIT_WITH_DELIMITER="con delimitador",n.Msg.LOGIC_BOOLEAN_FALSE="falso",n.Msg.LOGIC_BOOLEAN_HELPURL="https://github.com/google/blockly/wiki/Logic#values",n.Msg.LOGIC_BOOLEAN_TOOLTIP="Devuelve verdadero o falso.",n.Msg.LOGIC_BOOLEAN_TRUE="verdadero",n.Msg.LOGIC_COMPARE_HELPURL="https://es.wikipedia.org/wiki/Desigualdad_matemática",n.Msg.LOGIC_COMPARE_TOOLTIP_EQ="Devuelve verdadero si ambas entradas son iguales.",n.Msg.LOGIC_COMPARE_TOOLTIP_GT="Devuelve verdadero si la primera entrada es mayor que la segunda entrada.",n.Msg.LOGIC_COMPARE_TOOLTIP_GTE="Devuelve verdadero si la primera entrada es mayor o igual a la segunda entrada.",n.Msg.LOGIC_COMPARE_TOOLTIP_LT="Devuelve verdadero si la primera entrada es menor que la segunda entrada.",n.Msg.LOGIC_COMPARE_TOOLTIP_LTE="Devuelve verdadero si la primera entrada es menor que o igual a la segunda entrada.",n.Msg.LOGIC_COMPARE_TOOLTIP_NEQ="Devuelve verdadero si ambas entradas son distintas.",n.Msg.LOGIC_NEGATE_HELPURL="https://github.com/google/blockly/wiki/Logic#not",n.Msg.LOGIC_NEGATE_TITLE="no %1",n.Msg.LOGIC_NEGATE_TOOLTIP="Devuelve verdadero si la entrada es falsa. Devuelve falso si la entrada es verdadera.",n.Msg.LOGIC_NULL="nulo",n.Msg.LOGIC_NULL_HELPURL="https://en.wikipedia.org/wiki/Nullable_type",n.Msg.LOGIC_NULL_TOOLTIP="Devuelve nulo.",n.Msg.LOGIC_OPERATION_AND="y",n.Msg.LOGIC_OPERATION_HELPURL="https://github.com/google/blockly/wiki/Logic#logical-operations",n.Msg.LOGIC_OPERATION_OR="o",n.Msg.LOGIC_OPERATION_TOOLTIP_AND="Devuelve verdadero si ambas entradas son verdaderas.",n.Msg.LOGIC_OPERATION_TOOLTIP_OR="Devuelve verdadero si al menos una de las entradas es verdadera.",n.Msg.LOGIC_TERNARY_CONDITION="prueba",n.Msg.LOGIC_TERNARY_HELPURL="https://en.wikipedia.org/wiki/%3F:",n.Msg.LOGIC_TERNARY_IF_FALSE="si es falso",n.Msg.LOGIC_TERNARY_IF_TRUE="si es verdadero",n.Msg.LOGIC_TERNARY_TOOLTIP='Comprueba la condición en "prueba". Si la condición es verdadera, devuelve el valor "si es verdadero"; de lo contrario, devuelve el valor "si es falso".',n.Msg.MATH_ADDITION_SYMBOL="+",n.Msg.MATH_ARITHMETIC_HELPURL="https://es.wikipedia.org/wiki/Aritmética",n.Msg.MATH_ARITHMETIC_TOOLTIP_ADD="Devuelve la suma de ambos números.",n.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE="Devuelve el cociente de ambos números.",n.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS="Devuelve la diferencia de ambos números.",n.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY="Devuelve el producto de ambos números.",n.Msg.MATH_ARITHMETIC_TOOLTIP_POWER="Devuelve el primer número elevado a la potencia del segundo.",n.Msg.MATH_ATAN2_HELPURL="https://es.wikipedia.org/wiki/Arcotangente_de_dos_par%C3%A1metros",n.Msg.MATH_ATAN2_TITLE="Arcotangente de X:%1 Y:%2",n.Msg.MATH_ATAN2_TOOLTIP="Regresar el arcotangente del punto (X,Y) en grados de -180 a 180.",n.Msg.MATH_CHANGE_HELPURL="https://en.wikipedia.org/wiki/Programming_idiom#Incrementing_a_counter",n.Msg.MATH_CHANGE_TITLE="añadir %2 a %1",n.Msg.MATH_CHANGE_TOOLTIP="Añadir un número a la variable «%1».",n.Msg.MATH_CONSTANT_HELPURL="https://es.wikipedia.org/wiki/Anexo:Constantes_matemáticas",n.Msg.MATH_CONSTANT_TOOLTIP="Devuelve una de las constantes comunes: π (3.141…), e (2.718…), φ (1.618…), sqrt(2) (1.414…), sqrt(½) (0.707…) o ∞ (infinito).",n.Msg.MATH_CONSTRAIN_HELPURL="https://en.wikipedia.org/wiki/Clamping_(graphics)",n.Msg.MATH_CONSTRAIN_TITLE="limitar %1 entre %2 y %3",n.Msg.MATH_CONSTRAIN_TOOLTIP="Limitar un número entre los límites especificados (inclusive).",n.Msg.MATH_DIVISION_SYMBOL="÷",n.Msg.MATH_IS_DIVISIBLE_BY="es divisible por",n.Msg.MATH_IS_EVEN="es par",n.Msg.MATH_IS_NEGATIVE="es negativo",n.Msg.MATH_IS_ODD="es impar",n.Msg.MATH_IS_POSITIVE="es positivo",n.Msg.MATH_IS_PRIME="es primo",n.Msg.MATH_IS_TOOLTIP="Comprueba si un número es par, impar, primo, entero, positivo, negativo, o si es divisible por un número determinado. Devuelve verdadero o falso.",n.Msg.MATH_IS_WHOLE="es entero",n.Msg.MATH_MODULO_HELPURL="https://en.wikipedia.org/wiki/Modulo_operation",n.Msg.MATH_MODULO_TITLE="resto de %1 ÷ %2",n.Msg.MATH_MODULO_TOOLTIP="Devuelve el resto al dividir los dos números.",n.Msg.MATH_MULTIPLICATION_SYMBOL="×",n.Msg.MATH_NUMBER_HELPURL="https://es.wikipedia.org/wiki/Número",n.Msg.MATH_NUMBER_TOOLTIP="Un número.",n.Msg.MATH_ONLIST_HELPURL="",n.Msg.MATH_ONLIST_OPERATOR_AVERAGE="promedio de la lista",n.Msg.MATH_ONLIST_OPERATOR_MAX="máximo de la lista",n.Msg.MATH_ONLIST_OPERATOR_MEDIAN="mediana de la lista",n.Msg.MATH_ONLIST_OPERATOR_MIN="mínimo de la lista",n.Msg.MATH_ONLIST_OPERATOR_MODE="modas de la lista",n.Msg.MATH_ONLIST_OPERATOR_RANDOM="elemento aleatorio de la lista",n.Msg.MATH_ONLIST_OPERATOR_STD_DEV="desviación estándar de la lista",n.Msg.MATH_ONLIST_OPERATOR_SUM="suma de la lista",n.Msg.MATH_ONLIST_TOOLTIP_AVERAGE="Devuelve el promedio (media aritmética) de los valores numéricos en la lista.",n.Msg.MATH_ONLIST_TOOLTIP_MAX="Devuelve el número más grande en la lista.",n.Msg.MATH_ONLIST_TOOLTIP_MEDIAN="Devuelve la mediana en la lista.",n.Msg.MATH_ONLIST_TOOLTIP_MIN="Devuelve el número más pequeño en la lista.",n.Msg.MATH_ONLIST_TOOLTIP_MODE="Devuelve una lista de los elementos más comunes en la lista.",n.Msg.MATH_ONLIST_TOOLTIP_RANDOM="Devuelve un elemento aleatorio de la lista.",n.Msg.MATH_ONLIST_TOOLTIP_STD_DEV="Devuelve la desviación estándar de la lista.",n.Msg.MATH_ONLIST_TOOLTIP_SUM="Devuelve la suma de todos los números en la lista.",n.Msg.MATH_POWER_SYMBOL="^",n.Msg.MATH_RANDOM_FLOAT_HELPURL="https://es.wikipedia.org/wiki/Generador_de_números_aleatorios",n.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM="fracción aleatoria",n.Msg.MATH_RANDOM_FLOAT_TOOLTIP="Devuelve una fracción aleatoria entre 0,0 (ambos inclusive) y 1.0 (exclusivo).",n.Msg.MATH_RANDOM_INT_HELPURL="https://es.wikipedia.org/wiki/Generador_de_números_aleatorios",n.Msg.MATH_RANDOM_INT_TITLE="entero aleatorio de %1 a %2",n.Msg.MATH_RANDOM_INT_TOOLTIP="Devuelve un entero aleatorio entre los dos límites especificados, inclusive.",n.Msg.MATH_ROUND_HELPURL="https://es.wikipedia.org/wiki/Redondeo",n.Msg.MATH_ROUND_OPERATOR_ROUND="redondear",n.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN="redondear a la baja",n.Msg.MATH_ROUND_OPERATOR_ROUNDUP="redondear al alza",n.Msg.MATH_ROUND_TOOLTIP="Redondear un número al alza o a la baja.",n.Msg.MATH_SINGLE_HELPURL="https://es.wikipedia.org/wiki/Ra%C3%ADz_cuadrada",n.Msg.MATH_SINGLE_OP_ABSOLUTE="absoluto",n.Msg.MATH_SINGLE_OP_ROOT="raíz cuadrada",n.Msg.MATH_SINGLE_TOOLTIP_ABS="Devuelve el valor absoluto de un número.",n.Msg.MATH_SINGLE_TOOLTIP_EXP="Devuelve e a la potencia de un número.",n.Msg.MATH_SINGLE_TOOLTIP_LN="Devuelve el logaritmo natural de un número.",n.Msg.MATH_SINGLE_TOOLTIP_LOG10="Devuelve el logaritmo base 10 de un número.",n.Msg.MATH_SINGLE_TOOLTIP_NEG="Devuelve la negación de un número.",n.Msg.MATH_SINGLE_TOOLTIP_POW10="Devuelve 10 a la potencia de un número.",n.Msg.MATH_SINGLE_TOOLTIP_ROOT="Devuelve la raíz cuadrada de un número.",n.Msg.MATH_SUBTRACTION_SYMBOL="-",n.Msg.MATH_TRIG_ACOS="acos",n.Msg.MATH_TRIG_ASIN="asin",n.Msg.MATH_TRIG_ATAN="atan",n.Msg.MATH_TRIG_COS="cos",n.Msg.MATH_TRIG_HELPURL="https://es.wikipedia.org/wiki/Función_trigonométrica",n.Msg.MATH_TRIG_SIN="sin",n.Msg.MATH_TRIG_TAN="tan",n.Msg.MATH_TRIG_TOOLTIP_ACOS="Devuelve el arcocoseno de un número.",n.Msg.MATH_TRIG_TOOLTIP_ASIN="Devuelve el arcoseno de un número.",n.Msg.MATH_TRIG_TOOLTIP_ATAN="Devuelve el arcotangente de un número.",n.Msg.MATH_TRIG_TOOLTIP_COS="Devuelve el coseno de un grado (no radián).",n.Msg.MATH_TRIG_TOOLTIP_SIN="Devuelve el seno de un grado (no radián).",n.Msg.MATH_TRIG_TOOLTIP_TAN="Devuelve la tangente de un grado (no radián).",n.Msg.NEW_COLOUR_VARIABLE="Crear una variable de color...",n.Msg.NEW_NUMBER_VARIABLE="Crear una variable de número...",n.Msg.NEW_STRING_VARIABLE="Crear una variable de cadena...",n.Msg.NEW_VARIABLE="Crear variable...",n.Msg.NEW_VARIABLE_TITLE="Nombre de variable nueva:",n.Msg.NEW_VARIABLE_TYPE_TITLE="Nuevo tipo de variable:",n.Msg.ORDINAL_NUMBER_SUFFIX="",n.Msg.PROCEDURES_ALLOW_STATEMENTS="permitir declaraciones",n.Msg.PROCEDURES_BEFORE_PARAMS="con:",n.Msg.PROCEDURES_CALLNORETURN_HELPURL="https://es.wikipedia.org/wiki/Subrutina",n.Msg.PROCEDURES_CALLNORETURN_TOOLTIP="Ejecuta la función definida por el usuario '%1'.",n.Msg.PROCEDURES_CALLRETURN_HELPURL="https://es.wikipedia.org/wiki/Subrutina",n.Msg.PROCEDURES_CALLRETURN_TOOLTIP="Ejecuta la función definida por el usuario '%1' y usa su salida.",n.Msg.PROCEDURES_CALL_BEFORE_PARAMS="con:",n.Msg.PROCEDURES_CREATE_DO="Crear '%1'",n.Msg.PROCEDURES_DEFNORETURN_COMMENT="Describe esta función...",n.Msg.PROCEDURES_DEFNORETURN_DO="",n.Msg.PROCEDURES_DEFNORETURN_HELPURL="https://en.wikipedia.org/wiki/Subroutine",n.Msg.PROCEDURES_DEFNORETURN_PROCEDURE="hacer algo",n.Msg.PROCEDURES_DEFNORETURN_TITLE="para",n.Msg.PROCEDURES_DEFNORETURN_TOOLTIP="Crea una función sin salida.",n.Msg.PROCEDURES_DEFRETURN_HELPURL="https://en.wikipedia.org/wiki/Subroutine",n.Msg.PROCEDURES_DEFRETURN_RETURN="devuelve",n.Msg.PROCEDURES_DEFRETURN_TOOLTIP="Crea una función con una salida.",n.Msg.PROCEDURES_DEF_DUPLICATE_WARNING="Advertencia: Esta función tiene parámetros duplicados.",n.Msg.PROCEDURES_HIGHLIGHT_DEF="Destacar definición de la función",n.Msg.PROCEDURES_IFRETURN_HELPURL="http://c2.com/cgi/wiki?GuardClause",n.Msg.PROCEDURES_IFRETURN_TOOLTIP="Si un valor es verdadero, entonces devuelve un segundo valor.",n.Msg.PROCEDURES_IFRETURN_WARNING="Advertencia: Este bloque solo puede ser utilizado dentro de la definición de una función.",n.Msg.PROCEDURES_MUTATORARG_TITLE="nombre de entrada:",n.Msg.PROCEDURES_MUTATORARG_TOOLTIP="Añadir una entrada a la función.",n.Msg.PROCEDURES_MUTATORCONTAINER_TITLE="entradas",n.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP="Añadir, eliminar o reordenar entradas para esta función.",n.Msg.REDO="Rehacer",n.Msg.REMOVE_COMMENT="Eliminar comentario",n.Msg.RENAME_VARIABLE="Renombrar variable...",n.Msg.RENAME_VARIABLE_TITLE="Renombrar todas las variables '%1' a:",n.Msg.TEXT_APPEND_HELPURL="https://github.com/google/blockly/wiki/Text#text-modification",n.Msg.TEXT_APPEND_TITLE="a %1 añade el texto %2",n.Msg.TEXT_APPEND_TOOLTIP="Añadir texto a la variable '%1'.",n.Msg.TEXT_CHANGECASE_HELPURL="https://github.com/google/blockly/wiki/Text#adjusting-text-case",n.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE="a minúsculas",n.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE="a Mayúsculas Cada Palabra",n.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE="a MAYÚSCULAS",n.Msg.TEXT_CHANGECASE_TOOLTIP="Devuelve una copia del texto en un tamaño diferente.",n.Msg.TEXT_CHARAT_FIRST="obtener la primera letra",n.Msg.TEXT_CHARAT_FROM_END="obtener la letra # del final",n.Msg.TEXT_CHARAT_FROM_START="obtener la letra #",n.Msg.TEXT_CHARAT_HELPURL="https://github.com/google/blockly/wiki/Text#extracting-text",n.Msg.TEXT_CHARAT_LAST="obtener la última letra",n.Msg.TEXT_CHARAT_RANDOM="obtener letra aleatoria",n.Msg.TEXT_CHARAT_TAIL="",n.Msg.TEXT_CHARAT_TITLE="en el texto %1 %2",n.Msg.TEXT_CHARAT_TOOLTIP="Devuelve la letra en la posición especificada.",n.Msg.TEXT_COUNT_HELPURL="https://github.com/google/blockly/wiki/Text#counting-substrings",n.Msg.TEXT_COUNT_MESSAGE0="contar %1 en %2",n.Msg.TEXT_COUNT_TOOLTIP="Cuantas veces aparece un texto dentro de otro texto.",n.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP="Agregar un elemento al texto.",n.Msg.TEXT_CREATE_JOIN_TITLE_JOIN="unir",n.Msg.TEXT_CREATE_JOIN_TOOLTIP="Agregar, eliminar o reordenar las secciones para reconfigurar este bloque de texto.",n.Msg.TEXT_GET_SUBSTRING_END_FROM_END="hasta la letra # del final",n.Msg.TEXT_GET_SUBSTRING_END_FROM_START="hasta la letra #",n.Msg.TEXT_GET_SUBSTRING_END_LAST="hasta la última letra",n.Msg.TEXT_GET_SUBSTRING_HELPURL="https://github.com/google/blockly/wiki/Text#extracting-a-region-of-text",n.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT="en el texto",n.Msg.TEXT_GET_SUBSTRING_START_FIRST="obtener subcadena desde la primera letra",n.Msg.TEXT_GET_SUBSTRING_START_FROM_END="obtener subcadena desde la letra # del final",n.Msg.TEXT_GET_SUBSTRING_START_FROM_START="obtener subcadena desde la letra #",n.Msg.TEXT_GET_SUBSTRING_TAIL="",n.Msg.TEXT_GET_SUBSTRING_TOOLTIP="Devuelve una porción determinada del texto.",n.Msg.TEXT_INDEXOF_HELPURL="https://github.com/google/blockly/wiki/Text#finding-text",n.Msg.TEXT_INDEXOF_OPERATOR_FIRST="encontrar la primera aparición del texto",n.Msg.TEXT_INDEXOF_OPERATOR_LAST="encontrar la última aparición del texto",n.Msg.TEXT_INDEXOF_TITLE="en el texto %1 %2 %3",n.Msg.TEXT_INDEXOF_TOOLTIP="Devuelve el índice de la primera/última aparición del primer texto en el segundo texto. Devuelve %1 si el texto no se encuentra.",n.Msg.TEXT_ISEMPTY_HELPURL="https://github.com/google/blockly/wiki/Text#checking-for-empty-text",n.Msg.TEXT_ISEMPTY_TITLE="%1 está vacío",n.Msg.TEXT_ISEMPTY_TOOLTIP="Devuelve verdadero si el texto proporcionado está vacío.",n.Msg.TEXT_JOIN_HELPURL="https://github.com/google/blockly/wiki/Text#text-creation",n.Msg.TEXT_JOIN_TITLE_CREATEWITH="crear texto con",n.Msg.TEXT_JOIN_TOOLTIP="Crear un fragmento de texto al unir cualquier número de elementos.",n.Msg.TEXT_LENGTH_HELPURL="https://github.com/google/blockly/wiki/Text#text-modification",n.Msg.TEXT_LENGTH_TITLE="longitud de %1",n.Msg.TEXT_LENGTH_TOOLTIP="Devuelve el número de letras (espacios incluidos) del texto proporcionado.",n.Msg.TEXT_PRINT_HELPURL="https://github.com/google/blockly/wiki/Text#printing-text",n.Msg.TEXT_PRINT_TITLE="imprimir %1",n.Msg.TEXT_PRINT_TOOLTIP="Imprimir el texto, número u otro valor especificado.",n.Msg.TEXT_PROMPT_HELPURL="https://github.com/google/blockly/wiki/Text#getting-input-from-the-user",n.Msg.TEXT_PROMPT_TOOLTIP_NUMBER="Solicitar al usuario un número.",n.Msg.TEXT_PROMPT_TOOLTIP_TEXT="Solicitar al usuario un texto.",n.Msg.TEXT_PROMPT_TYPE_NUMBER="solicitar número con el mensaje",n.Msg.TEXT_PROMPT_TYPE_TEXT="solicitar texto con el mensaje",n.Msg.TEXT_REPLACE_HELPURL="https://github.com/google/blockly/wiki/Text#replacing-substrings",n.Msg.TEXT_REPLACE_MESSAGE0="reemplazar %1 con %2 en %3",n.Msg.TEXT_REPLACE_TOOLTIP="Reemplazar todas las veces que un texto dentro de otro texto.",n.Msg.TEXT_REVERSE_HELPURL="https://github.com/google/blockly/wiki/Text#reversing-text",n.Msg.TEXT_REVERSE_MESSAGE0="invertir %1",n.Msg.TEXT_REVERSE_TOOLTIP="Invierte el orden de los caracteres en el texto.",n.Msg.TEXT_TEXT_HELPURL="https://es.wikipedia.org/wiki/Cadena_de_caracteres",n.Msg.TEXT_TEXT_TOOLTIP="Una letra, palabra o línea de texto.",n.Msg.TEXT_TRIM_HELPURL="https://github.com/google/blockly/wiki/Text#trimming-removing-spaces",n.Msg.TEXT_TRIM_OPERATOR_BOTH="quitar espacios de ambos lados de",n.Msg.TEXT_TRIM_OPERATOR_LEFT="quitar espacios iniciales de",n.Msg.TEXT_TRIM_OPERATOR_RIGHT="quitar espacios finales de",n.Msg.TEXT_TRIM_TOOLTIP="Devuelve una copia del texto sin los espacios de uno o ambos extremos.",n.Msg.TODAY="Hoy",n.Msg.UNDO="Deshacer",n.Msg.UNNAMED_KEY="sin nombre",n.Msg.VARIABLES_DEFAULT_NAME="elemento",n.Msg.VARIABLES_GET_CREATE_SET="Crear 'establecer %1'",n.Msg.VARIABLES_GET_HELPURL="https://github.com/google/blockly/wiki/Variables#get",n.Msg.VARIABLES_GET_TOOLTIP="Devuelve el valor de esta variable.",n.Msg.VARIABLES_SET="establecer %1 a %2",n.Msg.VARIABLES_SET_CREATE_GET="Crear 'obtener %1'",n.Msg.VARIABLES_SET_HELPURL="https://github.com/google/blockly/wiki/Variables#set",n.Msg.VARIABLES_SET_TOOLTIP="Establece esta variable para que sea igual a la entrada.",n.Msg.VARIABLE_ALREADY_EXISTS="Ya existe una variable nombrada '%1'.",n.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE="Ya existe una variable nombrada '%1' para otra variable del tipo: '%2'.",n.Msg.WORKSPACE_ARIA_LABEL="Espacio de trabajo de Blockly",n.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT="Di algo…",n.Msg.CONTROLS_FOREACH_INPUT_DO=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.CONTROLS_FOR_INPUT_DO=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF=n.Msg.CONTROLS_IF_MSG_ELSEIF,n.Msg.CONTROLS_IF_ELSE_TITLE_ELSE=n.Msg.CONTROLS_IF_MSG_ELSE,n.Msg.CONTROLS_IF_IF_TITLE_IF=n.Msg.CONTROLS_IF_MSG_IF,n.Msg.CONTROLS_IF_MSG_THEN=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.CONTROLS_WHILEUNTIL_INPUT_DO=n.Msg.CONTROLS_REPEAT_INPUT_DO,n.Msg.LISTS_CREATE_WITH_ITEM_TITLE=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.LISTS_GET_INDEX_HELPURL=n.Msg.LISTS_INDEX_OF_HELPURL,n.Msg.LISTS_GET_INDEX_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.LISTS_INDEX_OF_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.LISTS_SET_INDEX_INPUT_IN_LIST=n.Msg.LISTS_INLIST,n.Msg.MATH_CHANGE_TITLE_ITEM=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.PROCEDURES_DEFRETURN_COMMENT=n.Msg.PROCEDURES_DEFNORETURN_COMMENT,n.Msg.PROCEDURES_DEFRETURN_DO=n.Msg.PROCEDURES_DEFNORETURN_DO,n.Msg.PROCEDURES_DEFRETURN_PROCEDURE=n.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,n.Msg.PROCEDURES_DEFRETURN_TITLE=n.Msg.PROCEDURES_DEFNORETURN_TITLE,n.Msg.TEXT_APPEND_VARIABLE=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM=n.Msg.VARIABLES_DEFAULT_NAME,n.Msg.MATH_HUE="230",n.Msg.LOOPS_HUE="120",n.Msg.LISTS_HUE="260",n.Msg.LOGIC_HUE="210",n.Msg.VARIABLES_HUE="330",n.Msg.TEXTS_HUE="160",n.Msg.PROCEDURES_HUE="290",n.Msg.COLOUR_HUE="20",n.Msg.VARIABLES_DYNAMIC_HUE="310",n.Msg})})(Wg);var Xg=Wg.exports;const zT=Vu(Xg),e$=Hu({__proto__:null,default:zT},[Xg]);var jg=Hg();const JT=Vu(jg),t$=Hu({__proto__:null,default:JT},[jg]);var Yg={exports:{}},Fu={exports:{}},xg;function qT(){return xg||(xg=1,function(q,xe){(function(n,_){q.exports=_($i())})(Ve,function(n){var _=n.__namespace__,r={};_.module$build$src$core$utils$string,_.CodeGenerator$$module$build$src$core$generator,_.module$build$src$core$input_types.inputTypes,_.module$build$src$core$names.Names,r.luaGenerator=new _.CodeGenerator$$module$build$src$core$generator("Lua"),r.luaGenerator.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug"),r.luaGenerator.ORDER_ATOMIC=0,r.luaGenerator.ORDER_HIGH=1,r.luaGenerator.ORDER_EXPONENTIATION=2,r.luaGenerator.ORDER_UNARY=3,r.luaGenerator.ORDER_MULTIPLICATIVE=4,r.luaGenerator.ORDER_ADDITIVE=5,r.luaGenerator.ORDER_CONCATENATION=6,r.luaGenerator.ORDER_RELATIONAL=7,r.luaGenerator.ORDER_AND=8,r.luaGenerator.ORDER_OR=9,r.luaGenerator.ORDER_NONE=99,r.luaGenerator.isInitialized=!1,r.luaGenerator.init=function(c){Object.getPrototypeOf(this).init.call(this),this.nameDB_?this.nameDB_.reset():this.nameDB_=new _.module$build$src$core$names.Names(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(c.getVariableMap()),this.nameDB_.populateVariables(c),this.nameDB_.populateProcedures(c),this.isInitialized=!0},r.luaGenerator.finish=function(c){const l=Object.values(this.definitions_);return c=Object.getPrototypeOf(this).finish.call(this,c),this.isInitialized=!1,this.nameDB_.reset(),l.join(`
|
|
1060
|
+
|
|
1061
|
+
`)+`
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
`+c},r.luaGenerator.scrubNakedValue=function(c){return"local _ = "+c+`
|
|
1065
|
+
`},r.luaGenerator.quote_=function(c){return c=c.replace(/\\/g,"\\\\").replace(/\n/g,`\\
|
|
1066
|
+
`).replace(/'/g,"\\'"),"'"+c+"'"},r.luaGenerator.multiline_quote_=function(c){return c.split(/\n/g).map(this.quote_).join(` .. '\\n' ..
|
|
1067
|
+
`)},r.luaGenerator.scrub_=function(c,l,d){let g="";if(!c.outputConnection||!c.outputConnection.targetConnection){var b=c.getCommentText();b&&(b=_.module$build$src$core$utils$string.wrap(b,this.COMMENT_WRAP-3),g+=this.prefixLines(b,"-- ")+`
|
|
1068
|
+
`);for(let N=0;N<c.inputList.length;N++)c.inputList[N].type===_.module$build$src$core$input_types.inputTypes.VALUE&&(b=c.inputList[N].connection.targetBlock())&&(b=this.allNestedComments(b))&&(g+=this.prefixLines(b,"-- "))}return c=c.nextConnection&&c.nextConnection.targetBlock(),d=d?"":this.blockToCode(c),g+l+d},r.luaGenerator.colour_picker=function(c){return[r.luaGenerator.quote_(c.getFieldValue("COLOUR")),r.luaGenerator.ORDER_ATOMIC]},r.luaGenerator.colour_random=function(c){return['string.format("#%06x", math.random(0, 2^24 - 1))',r.luaGenerator.ORDER_HIGH]},r.luaGenerator.colour_rgb=function(c){const l=r.luaGenerator.provideFunction_("colour_rgb",`
|
|
1069
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b)
|
|
1070
|
+
r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)
|
|
1071
|
+
g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)
|
|
1072
|
+
b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)
|
|
1073
|
+
return string.format("#%02x%02x%02x", r, g, b)
|
|
1074
|
+
end
|
|
1075
|
+
`),d=r.luaGenerator.valueToCode(c,"RED",r.luaGenerator.ORDER_NONE)||0,g=r.luaGenerator.valueToCode(c,"GREEN",r.luaGenerator.ORDER_NONE)||0;return c=r.luaGenerator.valueToCode(c,"BLUE",r.luaGenerator.ORDER_NONE)||0,[l+"("+d+", "+g+", "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.colour_blend=function(c){const l=r.luaGenerator.provideFunction_("colour_blend",`
|
|
1076
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio)
|
|
1077
|
+
local r1 = tonumber(string.sub(colour1, 2, 3), 16)
|
|
1078
|
+
local r2 = tonumber(string.sub(colour2, 2, 3), 16)
|
|
1079
|
+
local g1 = tonumber(string.sub(colour1, 4, 5), 16)
|
|
1080
|
+
local g2 = tonumber(string.sub(colour2, 4, 5), 16)
|
|
1081
|
+
local b1 = tonumber(string.sub(colour1, 6, 7), 16)
|
|
1082
|
+
local b2 = tonumber(string.sub(colour2, 6, 7), 16)
|
|
1083
|
+
local ratio = math.min(1, math.max(0, ratio))
|
|
1084
|
+
local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)
|
|
1085
|
+
local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)
|
|
1086
|
+
local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)
|
|
1087
|
+
return string.format("#%02x%02x%02x", r, g, b)
|
|
1088
|
+
end
|
|
1089
|
+
`),d=r.luaGenerator.valueToCode(c,"COLOUR1",r.luaGenerator.ORDER_NONE)||"'#000000'",g=r.luaGenerator.valueToCode(c,"COLOUR2",r.luaGenerator.ORDER_NONE)||"'#000000'";return c=r.luaGenerator.valueToCode(c,"RATIO",r.luaGenerator.ORDER_NONE)||0,[l+"("+d+", "+g+", "+c+")",r.luaGenerator.ORDER_HIGH]},_.NameType$$module$build$src$core$names,r.luaGenerator.lists_create_empty=function(c){return["{}",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.lists_create_with=function(c){const l=Array(c.itemCount_);for(let d=0;d<c.itemCount_;d++)l[d]=r.luaGenerator.valueToCode(c,"ADD"+d,r.luaGenerator.ORDER_NONE)||"None";return["{"+l.join(", ")+"}",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.lists_repeat=function(c){const l=r.luaGenerator.provideFunction_("create_list_repeated",`
|
|
1090
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(item, count)
|
|
1091
|
+
local t = {}
|
|
1092
|
+
for i = 1, count do
|
|
1093
|
+
table.insert(t, item)
|
|
1094
|
+
end
|
|
1095
|
+
return t
|
|
1096
|
+
end
|
|
1097
|
+
`),d=r.luaGenerator.valueToCode(c,"ITEM",r.luaGenerator.ORDER_NONE)||"None";return c=r.luaGenerator.valueToCode(c,"NUM",r.luaGenerator.ORDER_NONE)||"0",[l+"("+d+", "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.lists_length=function(c){return["#"+(r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_UNARY)||"{}"),r.luaGenerator.ORDER_UNARY]},r.luaGenerator.lists_isEmpty=function(c){return["#"+(r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_UNARY)||"{}")+" == 0",r.luaGenerator.ORDER_RELATIONAL]},r.luaGenerator.lists_indexOf=function(c){const l=r.luaGenerator.valueToCode(c,"FIND",r.luaGenerator.ORDER_NONE)||"''",d=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_NONE)||"{}";return[(c.getFieldValue("END")==="FIRST"?r.luaGenerator.provideFunction_("first_index",`
|
|
1098
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
1099
|
+
for k, v in ipairs(t) do
|
|
1100
|
+
if v == elem then
|
|
1101
|
+
return k
|
|
1102
|
+
end
|
|
1103
|
+
end
|
|
1104
|
+
return 0
|
|
1105
|
+
end
|
|
1106
|
+
`):r.luaGenerator.provideFunction_("last_index",`
|
|
1107
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t, elem)
|
|
1108
|
+
for i = #t, 1, -1 do
|
|
1109
|
+
if t[i] == elem then
|
|
1110
|
+
return i
|
|
1111
|
+
end
|
|
1112
|
+
end
|
|
1113
|
+
return 0
|
|
1114
|
+
end
|
|
1115
|
+
`))+"("+d+", "+l+")",r.luaGenerator.ORDER_HIGH]};var $e=function(c,l,d){return l==="FIRST"?"1":l==="FROM_END"?"#"+c+" + 1 - "+d:l==="LAST"?"#"+c:l==="RANDOM"?"math.random(#"+c+")":d};r.luaGenerator.lists_getIndex=function(c){var l=c.getFieldValue("MODE")||"GET",d=c.getFieldValue("WHERE")||"FROM_START";const g=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_HIGH)||"({})";return d!=="LAST"&&d!=="FROM_END"&&d!=="RANDOM"||g.match(/^\w+$/)?(c=r.luaGenerator.valueToCode(c,"AT",l==="GET"&&d==="FROM_END"?r.luaGenerator.ORDER_ADDITIVE:r.luaGenerator.ORDER_NONE)||"1",c=$e(g,d,c),l==="GET"?[g+"["+c+"]",r.luaGenerator.ORDER_HIGH]:(d="table.remove("+g+", "+c+")",l==="GET_REMOVE"?[d,r.luaGenerator.ORDER_HIGH]:d+`
|
|
1116
|
+
`)):l==="REMOVE"?(l=r.luaGenerator.valueToCode(c,"AT",d==="FROM_END"?r.luaGenerator.ORDER_ADDITIVE:r.luaGenerator.ORDER_NONE)||"1",c=r.luaGenerator.nameDB_.getDistinctName("tmp_list",_.NameType$$module$build$src$core$names.VARIABLE),l=$e(c,d,l),c+" = "+g+`
|
|
1117
|
+
table.remove(`+c+", "+l+`)
|
|
1118
|
+
`):(c=r.luaGenerator.valueToCode(c,"AT",r.luaGenerator.ORDER_NONE)||"1",[(l==="GET"?r.luaGenerator.provideFunction_("list_get_"+d.toLowerCase(),["function "+r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_+"(t"+(d==="FROM_END"||d==="FROM_START"?", at)":")")," return t["+$e("t",d,"at")+"]","end"]):r.luaGenerator.provideFunction_("list_remove_"+d.toLowerCase(),["function "+r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_+"(t"+(d==="FROM_END"||d==="FROM_START"?", at)":")")," return table.remove(t, "+$e("t",d,"at")+")","end"]))+"("+g+(d==="FROM_END"||d==="FROM_START"?", "+c:"")+")",r.luaGenerator.ORDER_HIGH])},r.luaGenerator.lists_setIndex=function(c){let l=r.luaGenerator.valueToCode(c,"LIST",r.luaGenerator.ORDER_HIGH)||"{}";const d=c.getFieldValue("MODE")||"SET",g=c.getFieldValue("WHERE")||"FROM_START",b=r.luaGenerator.valueToCode(c,"AT",r.luaGenerator.ORDER_ADDITIVE)||"1";c=r.luaGenerator.valueToCode(c,"TO",r.luaGenerator.ORDER_NONE)||"None";let N="";if((g==="LAST"||g==="FROM_END"||g==="RANDOM")&&!l.match(/^\w+$/)){const G=r.luaGenerator.nameDB_.getDistinctName("tmp_list",_.NameType$$module$build$src$core$names.VARIABLE);N=G+" = "+l+`
|
|
1119
|
+
`,l=G}return N=d==="SET"?N+(l+"["+$e(l,g,b)+"] = "+c):N+("table.insert("+l+", "+($e(l,g,b)+(g==="LAST"?" + 1":""))+", "+c+")"),N+`
|
|
1120
|
+
`},r.luaGenerator.lists_getSublist=function(c){const l=r.luaGenerator.valueToCode(c,"LIST",r.luaGenerator.ORDER_NONE)||"{}",d=c.getFieldValue("WHERE1"),g=c.getFieldValue("WHERE2"),b=r.luaGenerator.valueToCode(c,"AT1",r.luaGenerator.ORDER_NONE)||"1";c=r.luaGenerator.valueToCode(c,"AT2",r.luaGenerator.ORDER_NONE)||"1";const N=d==="FROM_END"||d==="FROM_START"?", at1":"",G=g==="FROM_END"||g==="FROM_START"?", at2":"";return[r.luaGenerator.provideFunction_("list_sublist_"+d.toLowerCase()+"_"+g.toLowerCase(),`
|
|
1121
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(source${N}${G})
|
|
1122
|
+
local t = {}
|
|
1123
|
+
local start = ${$e("source",d,"at1")}
|
|
1124
|
+
local finish = ${$e("source",g,"at2")}
|
|
1125
|
+
for i = start, finish do
|
|
1126
|
+
table.insert(t, source[i])
|
|
1127
|
+
end
|
|
1128
|
+
return t
|
|
1129
|
+
end
|
|
1130
|
+
`)+"("+l+(d==="FROM_END"||d==="FROM_START"?", "+b:"")+(g==="FROM_END"||g==="FROM_START"?", "+c:"")+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.lists_sort=function(c){const l=r.luaGenerator.valueToCode(c,"LIST",r.luaGenerator.ORDER_NONE)||"{}",d=c.getFieldValue("DIRECTION")==="1"?1:-1;return c=c.getFieldValue("TYPE"),[r.luaGenerator.provideFunction_("list_sort",`
|
|
1131
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(list, typev, direction)
|
|
1132
|
+
local t = {}
|
|
1133
|
+
for n,v in pairs(list) do table.insert(t, v) end
|
|
1134
|
+
local compareFuncs = {
|
|
1135
|
+
NUMERIC = function(a, b)
|
|
1136
|
+
return (tonumber(tostring(a)) or 0)
|
|
1137
|
+
< (tonumber(tostring(b)) or 0) end,
|
|
1138
|
+
TEXT = function(a, b)
|
|
1139
|
+
return tostring(a) < tostring(b) end,
|
|
1140
|
+
IGNORE_CASE = function(a, b)
|
|
1141
|
+
return string.lower(tostring(a)) < string.lower(tostring(b)) end
|
|
1142
|
+
}
|
|
1143
|
+
local compareTemp = compareFuncs[typev]
|
|
1144
|
+
local compare = compareTemp
|
|
1145
|
+
if direction == -1
|
|
1146
|
+
then compare = function(a, b) return compareTemp(b, a) end
|
|
1147
|
+
end
|
|
1148
|
+
table.sort(t, compare)
|
|
1149
|
+
return t
|
|
1150
|
+
end
|
|
1151
|
+
`)+"("+l+',"'+c+'", '+d+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.lists_split=function(c){let l=r.luaGenerator.valueToCode(c,"INPUT",r.luaGenerator.ORDER_NONE);const d=r.luaGenerator.valueToCode(c,"DELIM",r.luaGenerator.ORDER_NONE)||"''";if(c=c.getFieldValue("MODE"),c==="SPLIT")l||(l="''"),c=r.luaGenerator.provideFunction_("list_string_split",`
|
|
1152
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input, delim)
|
|
1153
|
+
local t = {}
|
|
1154
|
+
local pos = 1
|
|
1155
|
+
while true do
|
|
1156
|
+
next_delim = string.find(input, delim, pos)
|
|
1157
|
+
if next_delim == nil then
|
|
1158
|
+
table.insert(t, string.sub(input, pos))
|
|
1159
|
+
break
|
|
1160
|
+
else
|
|
1161
|
+
table.insert(t, string.sub(input, pos, next_delim-1))
|
|
1162
|
+
pos = next_delim + #delim
|
|
1163
|
+
end
|
|
1164
|
+
end
|
|
1165
|
+
return t
|
|
1166
|
+
end
|
|
1167
|
+
`);else if(c==="JOIN")l||(l="{}"),c="table.concat";else throw Error("Unknown mode: "+c);return[c+"("+l+", "+d+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.lists_reverse=function(c){return c=r.luaGenerator.valueToCode(c,"LIST",r.luaGenerator.ORDER_NONE)||"{}",[r.luaGenerator.provideFunction_("list_reverse",`
|
|
1168
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(input)
|
|
1169
|
+
local reversed = {}
|
|
1170
|
+
for i = #input, 1, -1 do
|
|
1171
|
+
table.insert(reversed, input[i])
|
|
1172
|
+
end
|
|
1173
|
+
return reversed
|
|
1174
|
+
end
|
|
1175
|
+
`)+"("+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.controls_if=function(c){var l=0;let d="";r.luaGenerator.STATEMENT_PREFIX&&(d+=r.luaGenerator.injectId(r.luaGenerator.STATEMENT_PREFIX,c));do{const g=r.luaGenerator.valueToCode(c,"IF"+l,r.luaGenerator.ORDER_NONE)||"false";let b=r.luaGenerator.statementToCode(c,"DO"+l);r.luaGenerator.STATEMENT_SUFFIX&&(b=r.luaGenerator.prefixLines(r.luaGenerator.injectId(r.luaGenerator.STATEMENT_SUFFIX,c),r.luaGenerator.INDENT)+b),d+=(0<l?"else":"")+"if "+g+` then
|
|
1176
|
+
`+b,l++}while(c.getInput("IF"+l));return(c.getInput("ELSE")||r.luaGenerator.STATEMENT_SUFFIX)&&(l=r.luaGenerator.statementToCode(c,"ELSE"),r.luaGenerator.STATEMENT_SUFFIX&&(l=r.luaGenerator.prefixLines(r.luaGenerator.injectId(r.luaGenerator.STATEMENT_SUFFIX,c),r.luaGenerator.INDENT)+l),d+=`else
|
|
1177
|
+
`+l),d+`end
|
|
1178
|
+
`},r.luaGenerator.controls_ifelse=r.luaGenerator.controls_if,r.luaGenerator.logic_compare=function(c){const l={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[c.getFieldValue("OP")],d=r.luaGenerator.valueToCode(c,"A",r.luaGenerator.ORDER_RELATIONAL)||"0";return c=r.luaGenerator.valueToCode(c,"B",r.luaGenerator.ORDER_RELATIONAL)||"0",[d+" "+l+" "+c,r.luaGenerator.ORDER_RELATIONAL]},r.luaGenerator.logic_operation=function(c){const l=c.getFieldValue("OP")==="AND"?"and":"or",d=l==="and"?r.luaGenerator.ORDER_AND:r.luaGenerator.ORDER_OR;let g=r.luaGenerator.valueToCode(c,"A",d);if(c=r.luaGenerator.valueToCode(c,"B",d),g||c){const b=l==="and"?"true":"false";g||(g=b),c||(c=b)}else c=g="false";return[g+" "+l+" "+c,d]},r.luaGenerator.logic_negate=function(c){return["not "+(r.luaGenerator.valueToCode(c,"BOOL",r.luaGenerator.ORDER_UNARY)||"true"),r.luaGenerator.ORDER_UNARY]},r.luaGenerator.logic_boolean=function(c){return[c.getFieldValue("BOOL")==="TRUE"?"true":"false",r.luaGenerator.ORDER_ATOMIC]},r.luaGenerator.logic_null=function(c){return["nil",r.luaGenerator.ORDER_ATOMIC]},r.luaGenerator.logic_ternary=function(c){const l=r.luaGenerator.valueToCode(c,"IF",r.luaGenerator.ORDER_AND)||"false",d=r.luaGenerator.valueToCode(c,"THEN",r.luaGenerator.ORDER_AND)||"nil";return c=r.luaGenerator.valueToCode(c,"ELSE",r.luaGenerator.ORDER_OR)||"nil",[l+" and "+d+" or "+c,r.luaGenerator.ORDER_OR]},_.module$build$src$core$utils$string,_.NameType$$module$build$src$core$names;var he=`goto continue
|
|
1179
|
+
`,u=function(c){return c.indexOf(he)!==-1?c+r.luaGenerator.INDENT+`::continue::
|
|
1180
|
+
`:c};return r.luaGenerator.controls_repeat_ext=function(c){let l;l=c.getField("TIMES")?String(Number(c.getFieldValue("TIMES"))):r.luaGenerator.valueToCode(c,"TIMES",r.luaGenerator.ORDER_NONE)||"0",l=_.module$build$src$core$utils$string.isNumber(l)?parseInt(l,10):"math.floor("+l+")";let d=r.luaGenerator.statementToCode(c,"DO");return d=r.luaGenerator.addLoopTrap(d,c),d=u(d),"for "+r.luaGenerator.nameDB_.getDistinctName("count",_.NameType$$module$build$src$core$names.VARIABLE)+" = 1, "+l+` do
|
|
1181
|
+
`+d+`end
|
|
1182
|
+
`},r.luaGenerator.controls_repeat=r.luaGenerator.controls_repeat_ext,r.luaGenerator.controls_whileUntil=function(c){const l=c.getFieldValue("MODE")==="UNTIL";let d=r.luaGenerator.valueToCode(c,"BOOL",l?r.luaGenerator.ORDER_UNARY:r.luaGenerator.ORDER_NONE)||"false",g=r.luaGenerator.statementToCode(c,"DO");return g=r.luaGenerator.addLoopTrap(g,c),g=u(g),l&&(d="not "+d),"while "+d+` do
|
|
1183
|
+
`+g+`end
|
|
1184
|
+
`},r.luaGenerator.controls_for=function(c){const l=r.luaGenerator.nameDB_.getName(c.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),d=r.luaGenerator.valueToCode(c,"FROM",r.luaGenerator.ORDER_NONE)||"0",g=r.luaGenerator.valueToCode(c,"TO",r.luaGenerator.ORDER_NONE)||"0",b=r.luaGenerator.valueToCode(c,"BY",r.luaGenerator.ORDER_NONE)||"1";let N=r.luaGenerator.statementToCode(c,"DO");N=r.luaGenerator.addLoopTrap(N,c),N=u(N),c="";let G;return _.module$build$src$core$utils$string.isNumber(d)&&_.module$build$src$core$utils$string.isNumber(g)&&_.module$build$src$core$utils$string.isNumber(b)?G=(Number(d)<=Number(g)?"":"-")+Math.abs(Number(b)):(c="",G=r.luaGenerator.nameDB_.getDistinctName(l+"_inc",_.NameType$$module$build$src$core$names.VARIABLE),c+=G+" = ",c=_.module$build$src$core$utils$string.isNumber(b)?c+(Math.abs(b)+`
|
|
1185
|
+
`):c+("math.abs("+b+`)
|
|
1186
|
+
`),c=c+("if ("+d+") > ("+g+`) then
|
|
1187
|
+
`)+(r.luaGenerator.INDENT+G+" = -"+G+`
|
|
1188
|
+
`),c+=`end
|
|
1189
|
+
`),c+("for "+l+" = "+d+", "+g+", "+G)+(` do
|
|
1190
|
+
`+N+`end
|
|
1191
|
+
`)},r.luaGenerator.controls_forEach=function(c){const l=r.luaGenerator.nameDB_.getName(c.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),d=r.luaGenerator.valueToCode(c,"LIST",r.luaGenerator.ORDER_NONE)||"{}";let g=r.luaGenerator.statementToCode(c,"DO");return g=r.luaGenerator.addLoopTrap(g,c),g=u(g),"for _, "+l+" in ipairs("+d+`) do
|
|
1192
|
+
`+g+`end
|
|
1193
|
+
`},r.luaGenerator.controls_flow_statements=function(c){let l="";if(r.luaGenerator.STATEMENT_PREFIX&&(l+=r.luaGenerator.injectId(r.luaGenerator.STATEMENT_PREFIX,c)),r.luaGenerator.STATEMENT_SUFFIX&&(l+=r.luaGenerator.injectId(r.luaGenerator.STATEMENT_SUFFIX,c)),r.luaGenerator.STATEMENT_PREFIX){const d=c.getSurroundLoop();d&&!d.suppressPrefixSuffix&&(l+=r.luaGenerator.injectId(r.luaGenerator.STATEMENT_PREFIX,d))}switch(c.getFieldValue("FLOW")){case"BREAK":return l+`break
|
|
1194
|
+
`;case"CONTINUE":return l+he}throw Error("Unknown flow statement.")},_.NameType$$module$build$src$core$names,r.luaGenerator.math_number=function(c){return c=Number(c.getFieldValue("NUM")),[c,0>c?r.luaGenerator.ORDER_UNARY:r.luaGenerator.ORDER_ATOMIC]},r.luaGenerator.math_arithmetic=function(c){var l={ADD:[" + ",r.luaGenerator.ORDER_ADDITIVE],MINUS:[" - ",r.luaGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",r.luaGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",r.luaGenerator.ORDER_MULTIPLICATIVE],POWER:[" ^ ",r.luaGenerator.ORDER_EXPONENTIATION]}[c.getFieldValue("OP")];const d=l[0];l=l[1];const g=r.luaGenerator.valueToCode(c,"A",l)||"0";return c=r.luaGenerator.valueToCode(c,"B",l)||"0",[g+d+c,l]},r.luaGenerator.math_single=function(c){var l=c.getFieldValue("OP");if(l==="NEG")return c=r.luaGenerator.valueToCode(c,"NUM",r.luaGenerator.ORDER_UNARY)||"0",["-"+c,r.luaGenerator.ORDER_UNARY];if(l==="POW10")return c=r.luaGenerator.valueToCode(c,"NUM",r.luaGenerator.ORDER_EXPONENTIATION)||"0",["10 ^ "+c,r.luaGenerator.ORDER_EXPONENTIATION];switch(c=l==="ROUND"?r.luaGenerator.valueToCode(c,"NUM",r.luaGenerator.ORDER_ADDITIVE)||"0":r.luaGenerator.valueToCode(c,"NUM",r.luaGenerator.ORDER_NONE)||"0",l){case"ABS":l="math.abs("+c+")";break;case"ROOT":l="math.sqrt("+c+")";break;case"LN":l="math.log("+c+")";break;case"LOG10":l="math.log("+c+", 10)";break;case"EXP":l="math.exp("+c+")";break;case"ROUND":l="math.floor("+c+" + .5)";break;case"ROUNDUP":l="math.ceil("+c+")";break;case"ROUNDDOWN":l="math.floor("+c+")";break;case"SIN":l="math.sin(math.rad("+c+"))";break;case"COS":l="math.cos(math.rad("+c+"))";break;case"TAN":l="math.tan(math.rad("+c+"))";break;case"ASIN":l="math.deg(math.asin("+c+"))";break;case"ACOS":l="math.deg(math.acos("+c+"))";break;case"ATAN":l="math.deg(math.atan("+c+"))";break;default:throw Error("Unknown math operator: "+l)}return[l,r.luaGenerator.ORDER_HIGH]},r.luaGenerator.math_constant=function(c){return{PI:["math.pi",r.luaGenerator.ORDER_HIGH],E:["math.exp(1)",r.luaGenerator.ORDER_HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",r.luaGenerator.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",r.luaGenerator.ORDER_HIGH],SQRT1_2:["math.sqrt(1 / 2)",r.luaGenerator.ORDER_HIGH],INFINITY:["math.huge",r.luaGenerator.ORDER_HIGH]}[c.getFieldValue("CONSTANT")]},r.luaGenerator.math_number_property=function(c){var l={EVEN:[" % 2 == 0",r.luaGenerator.ORDER_MULTIPLICATIVE,r.luaGenerator.ORDER_RELATIONAL],ODD:[" % 2 == 1",r.luaGenerator.ORDER_MULTIPLICATIVE,r.luaGenerator.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",r.luaGenerator.ORDER_MULTIPLICATIVE,r.luaGenerator.ORDER_RELATIONAL],POSITIVE:[" > 0",r.luaGenerator.ORDER_RELATIONAL,r.luaGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",r.luaGenerator.ORDER_RELATIONAL,r.luaGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,r.luaGenerator.ORDER_MULTIPLICATIVE,r.luaGenerator.ORDER_RELATIONAL],PRIME:[null,r.luaGenerator.ORDER_NONE,r.luaGenerator.ORDER_HIGH]};const d=c.getFieldValue("PROPERTY"),[g,b,N]=l[d];if(l=r.luaGenerator.valueToCode(c,"NUMBER_TO_CHECK",b)||"0",d==="PRIME")c=r.luaGenerator.provideFunction_("math_isPrime",`
|
|
1195
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(n)
|
|
1196
|
+
-- https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
1197
|
+
if n == 2 or n == 3 then
|
|
1198
|
+
return true
|
|
1199
|
+
end
|
|
1200
|
+
-- False if n is NaN, negative, is 1, or not whole.
|
|
1201
|
+
-- And false if n is divisible by 2 or 3.
|
|
1202
|
+
if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then
|
|
1203
|
+
return false
|
|
1204
|
+
end
|
|
1205
|
+
-- Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
1206
|
+
for x = 6, math.sqrt(n) + 1.5, 6 do
|
|
1207
|
+
if n % (x - 1) == 0 or n % (x + 1) == 0 then
|
|
1208
|
+
return false
|
|
1209
|
+
end
|
|
1210
|
+
end
|
|
1211
|
+
return true
|
|
1212
|
+
end
|
|
1213
|
+
`)+"("+l+")";else if(d==="DIVISIBLE_BY"){if(c=r.luaGenerator.valueToCode(c,"DIVISOR",r.luaGenerator.ORDER_MULTIPLICATIVE)||"0",c==="0")return["nil",r.luaGenerator.ORDER_ATOMIC];c=l+" % "+c+" == 0"}else c=l+g;return[c,N]},r.luaGenerator.math_change=function(c){const l=r.luaGenerator.valueToCode(c,"DELTA",r.luaGenerator.ORDER_ADDITIVE)||"0";return c=r.luaGenerator.nameDB_.getName(c.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),c+" = "+c+" + "+l+`
|
|
1214
|
+
`},r.luaGenerator.math_round=r.luaGenerator.math_single,r.luaGenerator.math_trig=r.luaGenerator.math_single,r.luaGenerator.math_on_list=function(c){function l(){return r.luaGenerator.provideFunction_("math_sum",`
|
|
1215
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1216
|
+
local result = 0
|
|
1217
|
+
for _, v in ipairs(t) do
|
|
1218
|
+
result = result + v
|
|
1219
|
+
end
|
|
1220
|
+
return result
|
|
1221
|
+
end
|
|
1222
|
+
`)}var d=c.getFieldValue("OP");switch(c=r.luaGenerator.valueToCode(c,"LIST",r.luaGenerator.ORDER_NONE)||"{}",d){case"SUM":d=l();break;case"MIN":d=r.luaGenerator.provideFunction_("math_min",`
|
|
1223
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1224
|
+
if #t == 0 then
|
|
1225
|
+
return 0
|
|
1226
|
+
end
|
|
1227
|
+
local result = math.huge
|
|
1228
|
+
for _, v in ipairs(t) do
|
|
1229
|
+
if v < result then
|
|
1230
|
+
result = v
|
|
1231
|
+
end
|
|
1232
|
+
end
|
|
1233
|
+
return result
|
|
1234
|
+
end
|
|
1235
|
+
`);break;case"AVERAGE":d=r.luaGenerator.provideFunction_("math_average",`
|
|
1236
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1237
|
+
if #t == 0 then
|
|
1238
|
+
return 0
|
|
1239
|
+
end
|
|
1240
|
+
return ${l()}(t) / #t
|
|
1241
|
+
end
|
|
1242
|
+
`);break;case"MAX":d=r.luaGenerator.provideFunction_("math_max",`
|
|
1243
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1244
|
+
if #t == 0 then
|
|
1245
|
+
return 0
|
|
1246
|
+
end
|
|
1247
|
+
local result = -math.huge
|
|
1248
|
+
for _, v in ipairs(t) do
|
|
1249
|
+
if v > result then
|
|
1250
|
+
result = v
|
|
1251
|
+
end
|
|
1252
|
+
end
|
|
1253
|
+
return result
|
|
1254
|
+
end
|
|
1255
|
+
`);break;case"MEDIAN":d=r.luaGenerator.provideFunction_("math_median",`
|
|
1256
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1257
|
+
-- Source: http://lua-users.org/wiki/SimpleStats
|
|
1258
|
+
if #t == 0 then
|
|
1259
|
+
return 0
|
|
1260
|
+
end
|
|
1261
|
+
local temp = {}
|
|
1262
|
+
for _, v in ipairs(t) do
|
|
1263
|
+
if type(v) == 'number' then
|
|
1264
|
+
table.insert(temp, v)
|
|
1265
|
+
end
|
|
1266
|
+
end
|
|
1267
|
+
table.sort(temp)
|
|
1268
|
+
if #temp % 2 == 0 then
|
|
1269
|
+
return (temp[#temp / 2] + temp[(#temp / 2) + 1]) / 2
|
|
1270
|
+
else
|
|
1271
|
+
return temp[math.ceil(#temp / 2)]
|
|
1272
|
+
end
|
|
1273
|
+
end
|
|
1274
|
+
`);break;case"MODE":d=r.luaGenerator.provideFunction_("math_modes",`
|
|
1275
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1276
|
+
-- Source: http://lua-users.org/wiki/SimpleStats
|
|
1277
|
+
local counts = {}
|
|
1278
|
+
for _, v in ipairs(t) do
|
|
1279
|
+
if counts[v] == nil then
|
|
1280
|
+
counts[v] = 1
|
|
1281
|
+
else
|
|
1282
|
+
counts[v] = counts[v] + 1
|
|
1283
|
+
end
|
|
1284
|
+
end
|
|
1285
|
+
local biggestCount = 0
|
|
1286
|
+
for _, v in pairs(counts) do
|
|
1287
|
+
if v > biggestCount then
|
|
1288
|
+
biggestCount = v
|
|
1289
|
+
end
|
|
1290
|
+
end
|
|
1291
|
+
local temp = {}
|
|
1292
|
+
for k, v in pairs(counts) do
|
|
1293
|
+
if v == biggestCount then
|
|
1294
|
+
table.insert(temp, k)
|
|
1295
|
+
end
|
|
1296
|
+
end
|
|
1297
|
+
return temp
|
|
1298
|
+
end
|
|
1299
|
+
`);break;case"STD_DEV":d=r.luaGenerator.provideFunction_("math_standard_deviation",`
|
|
1300
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1301
|
+
local m
|
|
1302
|
+
local vm
|
|
1303
|
+
local total = 0
|
|
1304
|
+
local count = 0
|
|
1305
|
+
local result
|
|
1306
|
+
m = #t == 0 and 0 or ${l()}(t) / #t
|
|
1307
|
+
for _, v in ipairs(t) do
|
|
1308
|
+
if type(v) == 'number' then
|
|
1309
|
+
vm = v - m
|
|
1310
|
+
total = total + (vm * vm)
|
|
1311
|
+
count = count + 1
|
|
1312
|
+
end
|
|
1313
|
+
end
|
|
1314
|
+
result = math.sqrt(total / (count-1))
|
|
1315
|
+
return result
|
|
1316
|
+
end
|
|
1317
|
+
`);break;case"RANDOM":d=r.luaGenerator.provideFunction_("math_random_list",`
|
|
1318
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(t)
|
|
1319
|
+
if #t == 0 then
|
|
1320
|
+
return nil
|
|
1321
|
+
end
|
|
1322
|
+
return t[math.random(#t)]
|
|
1323
|
+
end
|
|
1324
|
+
`);break;default:throw Error("Unknown operator: "+d)}return[d+"("+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.math_modulo=function(c){const l=r.luaGenerator.valueToCode(c,"DIVIDEND",r.luaGenerator.ORDER_MULTIPLICATIVE)||"0";return c=r.luaGenerator.valueToCode(c,"DIVISOR",r.luaGenerator.ORDER_MULTIPLICATIVE)||"0",[l+" % "+c,r.luaGenerator.ORDER_MULTIPLICATIVE]},r.luaGenerator.math_constrain=function(c){const l=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_NONE)||"0",d=r.luaGenerator.valueToCode(c,"LOW",r.luaGenerator.ORDER_NONE)||"-math.huge";return c=r.luaGenerator.valueToCode(c,"HIGH",r.luaGenerator.ORDER_NONE)||"math.huge",["math.min(math.max("+l+", "+d+"), "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.math_random_int=function(c){const l=r.luaGenerator.valueToCode(c,"FROM",r.luaGenerator.ORDER_NONE)||"0";return c=r.luaGenerator.valueToCode(c,"TO",r.luaGenerator.ORDER_NONE)||"0",["math.random("+l+", "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.math_random_float=function(c){return["math.random()",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.math_atan2=function(c){const l=r.luaGenerator.valueToCode(c,"X",r.luaGenerator.ORDER_NONE)||"0";return["math.deg(math.atan2("+(r.luaGenerator.valueToCode(c,"Y",r.luaGenerator.ORDER_NONE)||"0")+", "+l+"))",r.luaGenerator.ORDER_HIGH]},_.NameType$$module$build$src$core$names,r.luaGenerator.procedures_defreturn=function(c){const l=r.luaGenerator.nameDB_.getName(c.getFieldValue("NAME"),_.NameType$$module$build$src$core$names.PROCEDURE);var d="";r.luaGenerator.STATEMENT_PREFIX&&(d+=r.luaGenerator.injectId(r.luaGenerator.STATEMENT_PREFIX,c)),r.luaGenerator.STATEMENT_SUFFIX&&(d+=r.luaGenerator.injectId(r.luaGenerator.STATEMENT_SUFFIX,c)),d&&(d=r.luaGenerator.prefixLines(d,r.luaGenerator.INDENT));let g="";r.luaGenerator.INFINITE_LOOP_TRAP&&(g=r.luaGenerator.prefixLines(r.luaGenerator.injectId(r.luaGenerator.INFINITE_LOOP_TRAP,c),r.luaGenerator.INDENT));let b=r.luaGenerator.statementToCode(c,"STACK"),N=r.luaGenerator.valueToCode(c,"RETURN",r.luaGenerator.ORDER_NONE)||"",G="";b&&N&&(G=d),N?N=r.luaGenerator.INDENT+"return "+N+`
|
|
1325
|
+
`:b||(b="");const Q=[],de=c.getVars();for(let Y=0;Y<de.length;Y++)Q[Y]=r.luaGenerator.nameDB_.getName(de[Y],_.NameType$$module$build$src$core$names.VARIABLE);return d="function "+l+"("+Q.join(", ")+`)
|
|
1326
|
+
`+d+g+b+G+N+`end
|
|
1327
|
+
`,d=r.luaGenerator.scrub_(c,d),r.luaGenerator.definitions_["%"+l]=d,null},r.luaGenerator.procedures_defnoreturn=r.luaGenerator.procedures_defreturn,r.luaGenerator.procedures_callreturn=function(c){const l=r.luaGenerator.nameDB_.getName(c.getFieldValue("NAME"),_.NameType$$module$build$src$core$names.PROCEDURE),d=[],g=c.getVars();for(let b=0;b<g.length;b++)d[b]=r.luaGenerator.valueToCode(c,"ARG"+b,r.luaGenerator.ORDER_NONE)||"nil";return[l+"("+d.join(", ")+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.procedures_callnoreturn=function(c){return r.luaGenerator.procedures_callreturn(c)[0]+`
|
|
1328
|
+
`},r.luaGenerator.procedures_ifreturn=function(c){let l="if "+(r.luaGenerator.valueToCode(c,"CONDITION",r.luaGenerator.ORDER_NONE)||"false")+` then
|
|
1329
|
+
`;return r.luaGenerator.STATEMENT_SUFFIX&&(l+=r.luaGenerator.prefixLines(r.luaGenerator.injectId(r.luaGenerator.STATEMENT_SUFFIX,c),r.luaGenerator.INDENT)),c.hasReturnValue_?(c=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_NONE)||"nil",l+=r.luaGenerator.INDENT+"return "+c+`
|
|
1330
|
+
`):l+=r.luaGenerator.INDENT+`return
|
|
1331
|
+
`,l+`end
|
|
1332
|
+
`},_.NameType$$module$build$src$core$names,r.luaGenerator.text=function(c){return[r.luaGenerator.quote_(c.getFieldValue("TEXT")),r.luaGenerator.ORDER_ATOMIC]},r.luaGenerator.text_multiline=function(c){c=r.luaGenerator.multiline_quote_(c.getFieldValue("TEXT"));const l=c.indexOf("..")!==-1?r.luaGenerator.ORDER_CONCATENATION:r.luaGenerator.ORDER_ATOMIC;return[c,l]},r.luaGenerator.text_join=function(c){if(c.itemCount_===0)return["''",r.luaGenerator.ORDER_ATOMIC];if(c.itemCount_===1)return["tostring("+(r.luaGenerator.valueToCode(c,"ADD0",r.luaGenerator.ORDER_NONE)||"''")+")",r.luaGenerator.ORDER_HIGH];if(c.itemCount_===2){var l=r.luaGenerator.valueToCode(c,"ADD0",r.luaGenerator.ORDER_CONCATENATION)||"''";return c=r.luaGenerator.valueToCode(c,"ADD1",r.luaGenerator.ORDER_CONCATENATION)||"''",[l+" .. "+c,r.luaGenerator.ORDER_CONCATENATION]}l=[];for(let d=0;d<c.itemCount_;d++)l[d]=r.luaGenerator.valueToCode(c,"ADD"+d,r.luaGenerator.ORDER_NONE)||"''";return["table.concat({"+l.join(", ")+"})",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_append=function(c){const l=r.luaGenerator.nameDB_.getName(c.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE);return c=r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_CONCATENATION)||"''",l+" = "+l+" .. "+c+`
|
|
1333
|
+
`},r.luaGenerator.text_length=function(c){return["#"+(r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_UNARY)||"''"),r.luaGenerator.ORDER_UNARY]},r.luaGenerator.text_isEmpty=function(c){return["#"+(r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_UNARY)||"''")+" == 0",r.luaGenerator.ORDER_RELATIONAL]},r.luaGenerator.text_indexOf=function(c){const l=r.luaGenerator.valueToCode(c,"FIND",r.luaGenerator.ORDER_NONE)||"''",d=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_NONE)||"''";return[(c.getFieldValue("END")==="FIRST"?r.luaGenerator.provideFunction_("firstIndexOf",`
|
|
1334
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
1335
|
+
local i = string.find(str, substr, 1, true)
|
|
1336
|
+
if i == nil then
|
|
1337
|
+
return 0
|
|
1338
|
+
end
|
|
1339
|
+
return i
|
|
1340
|
+
end
|
|
1341
|
+
`):r.luaGenerator.provideFunction_("lastIndexOf",`
|
|
1342
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, substr)
|
|
1343
|
+
local i = string.find(string.reverse(str), string.reverse(substr), 1, true)
|
|
1344
|
+
if i then
|
|
1345
|
+
return #str + 2 - i - #substr
|
|
1346
|
+
end
|
|
1347
|
+
return 0
|
|
1348
|
+
end
|
|
1349
|
+
`))+"("+d+", "+l+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_charAt=function(c){var l=c.getFieldValue("WHERE")||"FROM_START";const d=r.luaGenerator.valueToCode(c,"AT",l==="FROM_END"?r.luaGenerator.ORDER_UNARY:r.luaGenerator.ORDER_NONE)||"1";if(c=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_NONE)||"''",l==="RANDOM")l=r.luaGenerator.provideFunction_("text_random_letter",`
|
|
1350
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
1351
|
+
local index = math.random(string.len(str))
|
|
1352
|
+
return string.sub(str, index, index)
|
|
1353
|
+
end
|
|
1354
|
+
`)+"("+c+")";else{if(l==="FIRST")l="1";else if(l==="LAST")l="-1";else if(l==="FROM_START")l=d;else if(l==="FROM_END")l="-"+d;else throw Error("Unhandled option (text_charAt).");l=l.match(/^-?\w*$/)?"string.sub("+c+", "+l+", "+l+")":r.luaGenerator.provideFunction_("text_char_at",`
|
|
1355
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str, index)
|
|
1356
|
+
return string.sub(str, index, index)
|
|
1357
|
+
end
|
|
1358
|
+
`)+"("+c+", "+l+")"}return[l,r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_getSubstring=function(c){const l=r.luaGenerator.valueToCode(c,"STRING",r.luaGenerator.ORDER_NONE)||"''";var d=c.getFieldValue("WHERE1"),g=r.luaGenerator.valueToCode(c,"AT1",d==="FROM_END"?r.luaGenerator.ORDER_UNARY:r.luaGenerator.ORDER_NONE)||"1";if(d==="FIRST")d=1;else if(d==="FROM_START")d=g;else if(d==="FROM_END")d="-"+g;else throw Error("Unhandled option (text_getSubstring)");if(g=c.getFieldValue("WHERE2"),c=r.luaGenerator.valueToCode(c,"AT2",g==="FROM_END"?r.luaGenerator.ORDER_UNARY:r.luaGenerator.ORDER_NONE)||"1",g==="LAST")c=-1;else if(g!=="FROM_START")if(g==="FROM_END")c="-"+c;else throw Error("Unhandled option (text_getSubstring)");return["string.sub("+l+", "+d+", "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_changeCase=function(c){const l=c.getFieldValue("CASE");c=r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''";let d;return l==="UPPERCASE"?d="string.upper":l==="LOWERCASE"?d="string.lower":l==="TITLECASE"&&(d=r.luaGenerator.provideFunction_("text_titlecase",`
|
|
1359
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(str)
|
|
1360
|
+
local buf = {}
|
|
1361
|
+
local inWord = false
|
|
1362
|
+
for i = 1, #str do
|
|
1363
|
+
local c = string.sub(str, i, i)
|
|
1364
|
+
if inWord then
|
|
1365
|
+
table.insert(buf, string.lower(c))
|
|
1366
|
+
if string.find(c, "%s") then
|
|
1367
|
+
inWord = false
|
|
1368
|
+
end
|
|
1369
|
+
else
|
|
1370
|
+
table.insert(buf, string.upper(c))
|
|
1371
|
+
inWord = true
|
|
1372
|
+
end
|
|
1373
|
+
end
|
|
1374
|
+
return table.concat(buf)
|
|
1375
|
+
end
|
|
1376
|
+
`)),[d+"("+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_trim=function(c){const l={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[c.getFieldValue("MODE")];return["string.gsub("+(r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''")+', "'+l+'", "%1")',r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_print=function(c){return"print("+(r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''")+`)
|
|
1377
|
+
`},r.luaGenerator.text_prompt_ext=function(c){var l=c.getField("TEXT")?r.luaGenerator.quote_(c.getFieldValue("TEXT")):r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''";return l=r.luaGenerator.provideFunction_("text_prompt",`
|
|
1378
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg)
|
|
1379
|
+
io.write(msg)
|
|
1380
|
+
io.flush()
|
|
1381
|
+
return io.read()
|
|
1382
|
+
end
|
|
1383
|
+
`)+"("+l+")",c.getFieldValue("TYPE")==="NUMBER"&&(l="tonumber("+l+", 10)"),[l,r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_prompt=r.luaGenerator.text_prompt_ext,r.luaGenerator.text_count=function(c){const l=r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''";return c=r.luaGenerator.valueToCode(c,"SUB",r.luaGenerator.ORDER_NONE)||"''",[r.luaGenerator.provideFunction_("text_count",`
|
|
1384
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle)
|
|
1385
|
+
if #needle == 0 then
|
|
1386
|
+
return #haystack + 1
|
|
1387
|
+
end
|
|
1388
|
+
local i = 1
|
|
1389
|
+
local count = 0
|
|
1390
|
+
while true do
|
|
1391
|
+
i = string.find(haystack, needle, i, true)
|
|
1392
|
+
if i == nil then
|
|
1393
|
+
break
|
|
1394
|
+
end
|
|
1395
|
+
count = count + 1
|
|
1396
|
+
i = i + #needle
|
|
1397
|
+
end
|
|
1398
|
+
return count
|
|
1399
|
+
end
|
|
1400
|
+
`)+"("+l+", "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_replace=function(c){const l=r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''",d=r.luaGenerator.valueToCode(c,"FROM",r.luaGenerator.ORDER_NONE)||"''";return c=r.luaGenerator.valueToCode(c,"TO",r.luaGenerator.ORDER_NONE)||"''",[r.luaGenerator.provideFunction_("text_replace",`
|
|
1401
|
+
function ${r.luaGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, replacement)
|
|
1402
|
+
local buf = {}
|
|
1403
|
+
local i = 1
|
|
1404
|
+
while i <= #haystack do
|
|
1405
|
+
if string.sub(haystack, i, i + #needle - 1) == needle then
|
|
1406
|
+
for j = 1, #replacement do
|
|
1407
|
+
table.insert(buf, string.sub(replacement, j, j))
|
|
1408
|
+
end
|
|
1409
|
+
i = i + #needle
|
|
1410
|
+
else
|
|
1411
|
+
table.insert(buf, string.sub(haystack, i, i))
|
|
1412
|
+
i = i + 1
|
|
1413
|
+
end
|
|
1414
|
+
end
|
|
1415
|
+
return table.concat(buf)
|
|
1416
|
+
end
|
|
1417
|
+
`)+"("+l+", "+d+", "+c+")",r.luaGenerator.ORDER_HIGH]},r.luaGenerator.text_reverse=function(c){return["string.reverse("+(r.luaGenerator.valueToCode(c,"TEXT",r.luaGenerator.ORDER_NONE)||"''")+")",r.luaGenerator.ORDER_HIGH]},_.NameType$$module$build$src$core$names,r.luaGenerator.variables_get=function(c){return[r.luaGenerator.nameDB_.getName(c.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),r.luaGenerator.ORDER_ATOMIC]},r.luaGenerator.variables_set=function(c){const l=r.luaGenerator.valueToCode(c,"VALUE",r.luaGenerator.ORDER_NONE)||"0";return r.luaGenerator.nameDB_.getName(c.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE)+" = "+l+`
|
|
1418
|
+
`},r.luaGenerator.variables_get_dynamic=r.luaGenerator.variables_get,r.luaGenerator.variables_set_dynamic=r.luaGenerator.variables_set,r.__namespace__=_,r})}(Fu)),Fu.exports}(function(q,xe){(function(n,_){q.exports=_(jn(),qT())})(Ve,function(n,_){/**
|
|
1419
|
+
* @license
|
|
1420
|
+
* Copyright 2020 Google LLC
|
|
1421
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1422
|
+
*/return _})})(Yg);var o$=Yg.exports,Kg={exports:{}},Uu={exports:{}},Fg;function ZT(){return Fg||(Fg=1,function(q,xe){(function(n,_){q.exports=_($i())})(Ve,function(n){var _=n.__namespace__,r={};_.module$build$src$core$utils$string,_.module$build$src$core$variables,_.CodeGenerator$$module$build$src$core$generator,_.module$build$src$core$input_types.inputTypes,_.module$build$src$core$names.Names,_.NameType$$module$build$src$core$names,r.pythonGenerator=new _.CodeGenerator$$module$build$src$core$generator("Python"),r.pythonGenerator.addReservedWords("False,None,True,and,as,assert,break,class,continue,def,del,elif,else,except,exec,finally,for,from,global,if,import,in,is,lambda,nonlocal,not,or,pass,print,raise,return,try,while,with,yield,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,license,credits,ArithmeticError,AssertionError,AttributeError,BaseException,BlockingIOError,BrokenPipeError,BufferError,BytesWarning,ChildProcessError,ConnectionAbortedError,ConnectionError,ConnectionRefusedError,ConnectionResetError,DeprecationWarning,EOFError,Ellipsis,EnvironmentError,Exception,FileExistsError,FileNotFoundError,FloatingPointError,FutureWarning,GeneratorExit,IOError,ImportError,ImportWarning,IndentationError,IndexError,InterruptedError,IsADirectoryError,KeyError,KeyboardInterrupt,LookupError,MemoryError,ModuleNotFoundError,NameError,NotADirectoryError,NotImplemented,NotImplementedError,OSError,OverflowError,PendingDeprecationWarning,PermissionError,ProcessLookupError,RecursionError,ReferenceError,ResourceWarning,RuntimeError,RuntimeWarning,StandardError,StopAsyncIteration,StopIteration,SyntaxError,SyntaxWarning,SystemError,SystemExit,TabError,TimeoutError,TypeError,UnboundLocalError,UnicodeDecodeError,UnicodeEncodeError,UnicodeError,UnicodeTranslateError,UnicodeWarning,UserWarning,ValueError,Warning,ZeroDivisionError,_,__build_class__,__debug__,__doc__,__import__,__loader__,__name__,__package__,__spec__,abs,all,any,apply,ascii,basestring,bin,bool,buffer,bytearray,bytes,callable,chr,classmethod,cmp,coerce,compile,complex,copyright,credits,delattr,dict,dir,divmod,enumerate,eval,exec,execfile,exit,file,filter,float,format,frozenset,getattr,globals,hasattr,hash,help,hex,id,input,int,intern,isinstance,issubclass,iter,len,license,list,locals,long,map,max,memoryview,min,next,object,oct,open,ord,pow,print,property,quit,range,raw_input,reduce,reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod,str,sum,super,tuple,type,unichr,unicode,vars,xrange,zip"),r.pythonGenerator.ORDER_ATOMIC=0,r.pythonGenerator.ORDER_COLLECTION=1,r.pythonGenerator.ORDER_STRING_CONVERSION=1,r.pythonGenerator.ORDER_MEMBER=2.1,r.pythonGenerator.ORDER_FUNCTION_CALL=2.2,r.pythonGenerator.ORDER_EXPONENTIATION=3,r.pythonGenerator.ORDER_UNARY_SIGN=4,r.pythonGenerator.ORDER_BITWISE_NOT=4,r.pythonGenerator.ORDER_MULTIPLICATIVE=5,r.pythonGenerator.ORDER_ADDITIVE=6,r.pythonGenerator.ORDER_BITWISE_SHIFT=7,r.pythonGenerator.ORDER_BITWISE_AND=8,r.pythonGenerator.ORDER_BITWISE_XOR=9,r.pythonGenerator.ORDER_BITWISE_OR=10,r.pythonGenerator.ORDER_RELATIONAL=11,r.pythonGenerator.ORDER_LOGICAL_NOT=12,r.pythonGenerator.ORDER_LOGICAL_AND=13,r.pythonGenerator.ORDER_LOGICAL_OR=14,r.pythonGenerator.ORDER_CONDITIONAL=15,r.pythonGenerator.ORDER_LAMBDA=16,r.pythonGenerator.ORDER_NONE=99,r.pythonGenerator.ORDER_OVERRIDES=[[r.pythonGenerator.ORDER_FUNCTION_CALL,r.pythonGenerator.ORDER_MEMBER],[r.pythonGenerator.ORDER_FUNCTION_CALL,r.pythonGenerator.ORDER_FUNCTION_CALL],[r.pythonGenerator.ORDER_MEMBER,r.pythonGenerator.ORDER_MEMBER],[r.pythonGenerator.ORDER_MEMBER,r.pythonGenerator.ORDER_FUNCTION_CALL],[r.pythonGenerator.ORDER_LOGICAL_NOT,r.pythonGenerator.ORDER_LOGICAL_NOT],[r.pythonGenerator.ORDER_LOGICAL_AND,r.pythonGenerator.ORDER_LOGICAL_AND],[r.pythonGenerator.ORDER_LOGICAL_OR,r.pythonGenerator.ORDER_LOGICAL_OR]],r.pythonGenerator.isInitialized=!1,r.pythonGenerator.init=function(u){Object.getPrototypeOf(this).init.call(this),this.PASS=this.INDENT+`pass
|
|
1423
|
+
`,this.nameDB_?this.nameDB_.reset():this.nameDB_=new _.module$build$src$core$names.Names(this.RESERVED_WORDS_),this.nameDB_.setVariableMap(u.getVariableMap()),this.nameDB_.populateVariables(u),this.nameDB_.populateProcedures(u);const c=[];var l=_.module$build$src$core$variables.allDeveloperVariables(u);for(let d=0;d<l.length;d++)c.push(this.nameDB_.getName(l[d],_.module$build$src$core$names.Names.DEVELOPER_VARIABLE_TYPE)+" = None");for(u=_.module$build$src$core$variables.allUsedVarModels(u),l=0;l<u.length;l++)c.push(this.nameDB_.getName(u[l].getId(),_.NameType$$module$build$src$core$names.VARIABLE)+" = None");this.definitions_.variables=c.join(`
|
|
1424
|
+
`),this.isInitialized=!0},r.pythonGenerator.finish=function(u){const c=[],l=[];for(let d in this.definitions_){const g=this.definitions_[d];g.match(/^(from\s+\S+\s+)?import\s+\S+/)?c.push(g):l.push(g)}return u=Object.getPrototypeOf(this).finish.call(this,u),this.isInitialized=!1,this.nameDB_.reset(),(c.join(`
|
|
1425
|
+
`)+`
|
|
1426
|
+
|
|
1427
|
+
`+l.join(`
|
|
1428
|
+
|
|
1429
|
+
`)).replace(/\n\n+/g,`
|
|
1430
|
+
|
|
1431
|
+
`).replace(/\n*$/,`
|
|
1432
|
+
|
|
1433
|
+
|
|
1434
|
+
`)+u},r.pythonGenerator.scrubNakedValue=function(u){return u+`
|
|
1435
|
+
`},r.pythonGenerator.quote_=function(u){u=u.replace(/\\/g,"\\\\").replace(/\n/g,`\\
|
|
1436
|
+
`);let c="'";return u.indexOf("'")!==-1&&(u.indexOf('"')===-1?c='"':u=u.replace(/'/g,"\\'")),c+u+c},r.pythonGenerator.multiline_quote_=function(u){return u.split(/\n/g).map(this.quote_).join(` + '\\n' +
|
|
1437
|
+
`)},r.pythonGenerator.scrub_=function(u,c,l){let d="";if(!u.outputConnection||!u.outputConnection.targetConnection){var g=u.getCommentText();g&&(g=_.module$build$src$core$utils$string.wrap(g,this.COMMENT_WRAP-3),d+=this.prefixLines(g+`
|
|
1438
|
+
`,"# "));for(let b=0;b<u.inputList.length;b++)u.inputList[b].type===_.module$build$src$core$input_types.inputTypes.VALUE&&(g=u.inputList[b].connection.targetBlock())&&(g=this.allNestedComments(g))&&(d+=this.prefixLines(g,"# "))}return u=u.nextConnection&&u.nextConnection.targetBlock(),l=l?"":this.blockToCode(u),d+c+l},r.pythonGenerator.getAdjustedInt=function(u,c,l,d){l=l||0,u.workspace.options.oneBasedIndex&&l--;const g=u.workspace.options.oneBasedIndex?"1":"0";return u=this.valueToCode(u,c,l?this.ORDER_ADDITIVE:this.ORDER_NONE)||g,_.module$build$src$core$utils$string.isNumber(u)?(u=parseInt(u,10)+l,d&&(u=-u)):(u=0<l?"int("+u+" + "+l+")":0>l?"int("+u+" - "+-l+")":"int("+u+")",d&&(u="-"+u)),u},r.pythonGenerator.colour_picker=function(u){return[r.pythonGenerator.quote_(u.getFieldValue("COLOUR")),r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.colour_random=function(u){return r.pythonGenerator.definitions_.import_random="import random",["'#%06x' % random.randint(0, 2**24 - 1)",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.colour_rgb=function(u){const c=r.pythonGenerator.provideFunction_("colour_rgb",`
|
|
1439
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b):
|
|
1440
|
+
r = round(min(100, max(0, r)) * 2.55)
|
|
1441
|
+
g = round(min(100, max(0, g)) * 2.55)
|
|
1442
|
+
b = round(min(100, max(0, b)) * 2.55)
|
|
1443
|
+
return '#%02x%02x%02x' % (r, g, b)
|
|
1444
|
+
`),l=r.pythonGenerator.valueToCode(u,"RED",r.pythonGenerator.ORDER_NONE)||0,d=r.pythonGenerator.valueToCode(u,"GREEN",r.pythonGenerator.ORDER_NONE)||0;return u=r.pythonGenerator.valueToCode(u,"BLUE",r.pythonGenerator.ORDER_NONE)||0,[c+"("+l+", "+d+", "+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.colour_blend=function(u){const c=r.pythonGenerator.provideFunction_("colour_blend",`
|
|
1445
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(colour1, colour2, ratio):
|
|
1446
|
+
r1, r2 = int(colour1[1:3], 16), int(colour2[1:3], 16)
|
|
1447
|
+
g1, g2 = int(colour1[3:5], 16), int(colour2[3:5], 16)
|
|
1448
|
+
b1, b2 = int(colour1[5:7], 16), int(colour2[5:7], 16)
|
|
1449
|
+
ratio = min(1, max(0, ratio))
|
|
1450
|
+
r = round(r1 * (1 - ratio) + r2 * ratio)
|
|
1451
|
+
g = round(g1 * (1 - ratio) + g2 * ratio)
|
|
1452
|
+
b = round(b1 * (1 - ratio) + b2 * ratio)
|
|
1453
|
+
return '#%02x%02x%02x' % (r, g, b)
|
|
1454
|
+
`),l=r.pythonGenerator.valueToCode(u,"COLOUR1",r.pythonGenerator.ORDER_NONE)||"'#000000'",d=r.pythonGenerator.valueToCode(u,"COLOUR2",r.pythonGenerator.ORDER_NONE)||"'#000000'";return u=r.pythonGenerator.valueToCode(u,"RATIO",r.pythonGenerator.ORDER_NONE)||0,[c+"("+l+", "+d+", "+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},_.module$build$src$core$utils$string,_.NameType$$module$build$src$core$names,r.pythonGenerator.lists_create_empty=function(u){return["[]",r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.lists_create_with=function(u){const c=Array(u.itemCount_);for(let l=0;l<u.itemCount_;l++)c[l]=r.pythonGenerator.valueToCode(u,"ADD"+l,r.pythonGenerator.ORDER_NONE)||"None";return["["+c.join(", ")+"]",r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.lists_repeat=function(u){const c=r.pythonGenerator.valueToCode(u,"ITEM",r.pythonGenerator.ORDER_NONE)||"None";return u=r.pythonGenerator.valueToCode(u,"NUM",r.pythonGenerator.ORDER_MULTIPLICATIVE)||"0",["["+c+"] * "+u,r.pythonGenerator.ORDER_MULTIPLICATIVE]},r.pythonGenerator.lists_length=function(u){return["len("+(r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"[]")+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.lists_isEmpty=function(u){return["not len("+(r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"[]")+")",r.pythonGenerator.ORDER_LOGICAL_NOT]},r.pythonGenerator.lists_indexOf=function(u){const c=r.pythonGenerator.valueToCode(u,"FIND",r.pythonGenerator.ORDER_NONE)||"[]",l=r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"''";let d=" -1",g="",b=" - 1";return u.workspace.options.oneBasedIndex&&(d=" 0",g=" + 1",b=""),[(u.getFieldValue("END")==="FIRST"?r.pythonGenerator.provideFunction_("first_index",`
|
|
1455
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
|
1456
|
+
try: index = my_list.index(elem)${g}
|
|
1457
|
+
except: index =${d}
|
|
1458
|
+
return index
|
|
1459
|
+
`):r.pythonGenerator.provideFunction_("last_index",`
|
|
1460
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, elem):
|
|
1461
|
+
try: index = len(my_list) - my_list[::-1].index(elem)${b}
|
|
1462
|
+
except: index =${d}
|
|
1463
|
+
return index
|
|
1464
|
+
`))+"("+l+", "+c+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.lists_getIndex=function(u){const c=u.getFieldValue("MODE")||"GET",l=u.getFieldValue("WHERE")||"FROM_START";var d=r.pythonGenerator.valueToCode(u,"VALUE",l==="RANDOM"?r.pythonGenerator.ORDER_NONE:r.pythonGenerator.ORDER_MEMBER)||"[]";switch(l){case"FIRST":if(c==="GET")return[d+"[0]",r.pythonGenerator.ORDER_MEMBER];if(c==="GET_REMOVE")return[d+".pop(0)",r.pythonGenerator.ORDER_FUNCTION_CALL];if(c==="REMOVE")return d+`.pop(0)
|
|
1465
|
+
`;break;case"LAST":if(c==="GET")return[d+"[-1]",r.pythonGenerator.ORDER_MEMBER];if(c==="GET_REMOVE")return[d+".pop()",r.pythonGenerator.ORDER_FUNCTION_CALL];if(c==="REMOVE")return d+`.pop()
|
|
1466
|
+
`;break;case"FROM_START":if(u=r.pythonGenerator.getAdjustedInt(u,"AT"),c==="GET")return[d+"["+u+"]",r.pythonGenerator.ORDER_MEMBER];if(c==="GET_REMOVE")return[d+".pop("+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL];if(c==="REMOVE")return d+".pop("+u+`)
|
|
1467
|
+
`;break;case"FROM_END":if(u=r.pythonGenerator.getAdjustedInt(u,"AT",1,!0),c==="GET")return[d+"["+u+"]",r.pythonGenerator.ORDER_MEMBER];if(c==="GET_REMOVE")return[d+".pop("+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL];if(c==="REMOVE")return d+".pop("+u+`)
|
|
1468
|
+
`;break;case"RANDOM":if(r.pythonGenerator.definitions_.import_random="import random",c==="GET")return["random.choice("+d+")",r.pythonGenerator.ORDER_FUNCTION_CALL];if(d=r.pythonGenerator.provideFunction_("lists_remove_random_item",`
|
|
1469
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
1470
|
+
x = int(random.random() * len(myList))
|
|
1471
|
+
return myList.pop(x)
|
|
1472
|
+
`)+"("+d+")",c==="GET_REMOVE")return[d,r.pythonGenerator.ORDER_FUNCTION_CALL];if(c==="REMOVE")return d+`
|
|
1473
|
+
`}throw Error("Unhandled combination (lists_getIndex).")},r.pythonGenerator.lists_setIndex=function(u){let c=r.pythonGenerator.valueToCode(u,"LIST",r.pythonGenerator.ORDER_MEMBER)||"[]";const l=u.getFieldValue("MODE")||"GET";var d=u.getFieldValue("WHERE")||"FROM_START";const g=r.pythonGenerator.valueToCode(u,"TO",r.pythonGenerator.ORDER_NONE)||"None";switch(d){case"FIRST":if(l==="SET")return c+"[0] = "+g+`
|
|
1474
|
+
`;if(l==="INSERT")return c+".insert(0, "+g+`)
|
|
1475
|
+
`;break;case"LAST":if(l==="SET")return c+"[-1] = "+g+`
|
|
1476
|
+
`;if(l==="INSERT")return c+".append("+g+`)
|
|
1477
|
+
`;break;case"FROM_START":if(u=r.pythonGenerator.getAdjustedInt(u,"AT"),l==="SET")return c+"["+u+"] = "+g+`
|
|
1478
|
+
`;if(l==="INSERT")return c+".insert("+u+", "+g+`)
|
|
1479
|
+
`;break;case"FROM_END":if(u=r.pythonGenerator.getAdjustedInt(u,"AT",1,!0),l==="SET")return c+"["+u+"] = "+g+`
|
|
1480
|
+
`;if(l==="INSERT")return c+".insert("+u+", "+g+`)
|
|
1481
|
+
`;break;case"RANDOM":if(r.pythonGenerator.definitions_.import_random="import random",c.match(/^\w+$/)?u="":(u=r.pythonGenerator.nameDB_.getDistinctName("tmp_list",_.NameType$$module$build$src$core$names.VARIABLE),d=u+" = "+c+`
|
|
1482
|
+
`,c=u,u=d),d=r.pythonGenerator.nameDB_.getDistinctName("tmp_x",_.NameType$$module$build$src$core$names.VARIABLE),u+=d+" = int(random.random() * len("+c+`))
|
|
1483
|
+
`,l==="SET")return u+(c+"["+d+"] = "+g+`
|
|
1484
|
+
`);if(l==="INSERT")return u+(c+".insert("+d+", "+g+`)
|
|
1485
|
+
`)}throw Error("Unhandled combination (lists_setIndex).")},r.pythonGenerator.lists_getSublist=function(u){const c=r.pythonGenerator.valueToCode(u,"LIST",r.pythonGenerator.ORDER_MEMBER)||"[]";var l=u.getFieldValue("WHERE1");const d=u.getFieldValue("WHERE2");switch(l){case"FROM_START":l=r.pythonGenerator.getAdjustedInt(u,"AT1"),l===0&&(l="");break;case"FROM_END":l=r.pythonGenerator.getAdjustedInt(u,"AT1",1,!0);break;case"FIRST":l="";break;default:throw Error("Unhandled option (lists_getSublist)")}switch(d){case"FROM_START":u=r.pythonGenerator.getAdjustedInt(u,"AT2",1);break;case"FROM_END":u=r.pythonGenerator.getAdjustedInt(u,"AT2",0,!0),_.module$build$src$core$utils$string.isNumber(String(u))?u===0&&(u=""):(r.pythonGenerator.definitions_.import_sys="import sys",u+=" or sys.maxsize");break;case"LAST":u="";break;default:throw Error("Unhandled option (lists_getSublist)")}return[c+"["+l+" : "+u+"]",r.pythonGenerator.ORDER_MEMBER]},r.pythonGenerator.lists_sort=function(u){const c=r.pythonGenerator.valueToCode(u,"LIST",r.pythonGenerator.ORDER_NONE)||"[]",l=u.getFieldValue("TYPE");return u=u.getFieldValue("DIRECTION")==="1"?"False":"True",[r.pythonGenerator.provideFunction_("lists_sort",`
|
|
1486
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(my_list, type, reverse):
|
|
1487
|
+
def try_float(s):
|
|
1488
|
+
try:
|
|
1489
|
+
return float(s)
|
|
1490
|
+
except:
|
|
1491
|
+
return 0
|
|
1492
|
+
key_funcs = {
|
|
1493
|
+
"NUMERIC": try_float,
|
|
1494
|
+
"TEXT": str,
|
|
1495
|
+
"IGNORE_CASE": lambda s: str(s).lower()
|
|
1496
|
+
}
|
|
1497
|
+
key_func = key_funcs[type]
|
|
1498
|
+
list_cpy = list(my_list)
|
|
1499
|
+
return sorted(list_cpy, key=key_func, reverse=reverse)
|
|
1500
|
+
`)+"("+c+', "'+l+'", '+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.lists_split=function(u){var c=u.getFieldValue("MODE");if(c==="SPLIT")c=r.pythonGenerator.valueToCode(u,"INPUT",r.pythonGenerator.ORDER_MEMBER)||"''",u=r.pythonGenerator.valueToCode(u,"DELIM",r.pythonGenerator.ORDER_NONE),u=c+".split("+u+")";else if(c==="JOIN")c=r.pythonGenerator.valueToCode(u,"INPUT",r.pythonGenerator.ORDER_NONE)||"[]",u=(r.pythonGenerator.valueToCode(u,"DELIM",r.pythonGenerator.ORDER_MEMBER)||"''")+".join("+c+")";else throw Error("Unknown mode: "+c);return[u,r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.lists_reverse=function(u){return["list(reversed("+(r.pythonGenerator.valueToCode(u,"LIST",r.pythonGenerator.ORDER_NONE)||"[]")+"))",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.controls_if=function(u){let c=0,l="",d,g;r.pythonGenerator.STATEMENT_PREFIX&&(l+=r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_PREFIX,u));do g=r.pythonGenerator.valueToCode(u,"IF"+c,r.pythonGenerator.ORDER_NONE)||"False",d=r.pythonGenerator.statementToCode(u,"DO"+c)||r.pythonGenerator.PASS,r.pythonGenerator.STATEMENT_SUFFIX&&(d=r.pythonGenerator.prefixLines(r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_SUFFIX,u),r.pythonGenerator.INDENT)+d),l+=(c===0?"if ":"elif ")+g+`:
|
|
1501
|
+
`+d,c++;while(u.getInput("IF"+c));return(u.getInput("ELSE")||r.pythonGenerator.STATEMENT_SUFFIX)&&(d=r.pythonGenerator.statementToCode(u,"ELSE")||r.pythonGenerator.PASS,r.pythonGenerator.STATEMENT_SUFFIX&&(d=r.pythonGenerator.prefixLines(r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_SUFFIX,u),r.pythonGenerator.INDENT)+d),l+=`else:
|
|
1502
|
+
`+d),l},r.pythonGenerator.controls_ifelse=r.pythonGenerator.controls_if,r.pythonGenerator.logic_compare=function(u){const c={EQ:"==",NEQ:"!=",LT:"<",LTE:"<=",GT:">",GTE:">="}[u.getFieldValue("OP")],l=r.pythonGenerator.ORDER_RELATIONAL,d=r.pythonGenerator.valueToCode(u,"A",l)||"0";return u=r.pythonGenerator.valueToCode(u,"B",l)||"0",[d+" "+c+" "+u,l]},r.pythonGenerator.logic_operation=function(u){const c=u.getFieldValue("OP")==="AND"?"and":"or",l=c==="and"?r.pythonGenerator.ORDER_LOGICAL_AND:r.pythonGenerator.ORDER_LOGICAL_OR;let d=r.pythonGenerator.valueToCode(u,"A",l);if(u=r.pythonGenerator.valueToCode(u,"B",l),d||u){const g=c==="and"?"True":"False";d||(d=g),u||(u=g)}else u=d="False";return[d+" "+c+" "+u,l]},r.pythonGenerator.logic_negate=function(u){return["not "+(r.pythonGenerator.valueToCode(u,"BOOL",r.pythonGenerator.ORDER_LOGICAL_NOT)||"True"),r.pythonGenerator.ORDER_LOGICAL_NOT]},r.pythonGenerator.logic_boolean=function(u){return[u.getFieldValue("BOOL")==="TRUE"?"True":"False",r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.logic_null=function(u){return["None",r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.logic_ternary=function(u){const c=r.pythonGenerator.valueToCode(u,"IF",r.pythonGenerator.ORDER_CONDITIONAL)||"False",l=r.pythonGenerator.valueToCode(u,"THEN",r.pythonGenerator.ORDER_CONDITIONAL)||"None";return u=r.pythonGenerator.valueToCode(u,"ELSE",r.pythonGenerator.ORDER_CONDITIONAL)||"None",[l+" if "+c+" else "+u,r.pythonGenerator.ORDER_CONDITIONAL]},_.module$build$src$core$utils$string,_.NameType$$module$build$src$core$names,r.pythonGenerator.controls_repeat_ext=function(u){let c;c=u.getField("TIMES")?String(parseInt(u.getFieldValue("TIMES"),10)):r.pythonGenerator.valueToCode(u,"TIMES",r.pythonGenerator.ORDER_NONE)||"0",c=_.module$build$src$core$utils$string.isNumber(c)?parseInt(c,10):"int("+c+")";let l=r.pythonGenerator.statementToCode(u,"DO");return l=r.pythonGenerator.addLoopTrap(l,u)||r.pythonGenerator.PASS,"for "+r.pythonGenerator.nameDB_.getDistinctName("count",_.NameType$$module$build$src$core$names.VARIABLE)+" in range("+c+`):
|
|
1503
|
+
`+l},r.pythonGenerator.controls_repeat=r.pythonGenerator.controls_repeat_ext,r.pythonGenerator.controls_whileUntil=function(u){const c=u.getFieldValue("MODE")==="UNTIL";let l=r.pythonGenerator.valueToCode(u,"BOOL",c?r.pythonGenerator.ORDER_LOGICAL_NOT:r.pythonGenerator.ORDER_NONE)||"False",d=r.pythonGenerator.statementToCode(u,"DO");return d=r.pythonGenerator.addLoopTrap(d,u)||r.pythonGenerator.PASS,c&&(l="not "+l),"while "+l+`:
|
|
1504
|
+
`+d},r.pythonGenerator.controls_for=function(u){const c=r.pythonGenerator.nameDB_.getName(u.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE);var l=r.pythonGenerator.valueToCode(u,"FROM",r.pythonGenerator.ORDER_NONE)||"0",d=r.pythonGenerator.valueToCode(u,"TO",r.pythonGenerator.ORDER_NONE)||"0",g=r.pythonGenerator.valueToCode(u,"BY",r.pythonGenerator.ORDER_NONE)||"1";let b=r.pythonGenerator.statementToCode(u,"DO");b=r.pythonGenerator.addLoopTrap(b,u)||r.pythonGenerator.PASS;let N="";const G=function(){return r.pythonGenerator.provideFunction_("upRange",`
|
|
1505
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
|
1506
|
+
while start <= stop:
|
|
1507
|
+
yield start
|
|
1508
|
+
start += abs(step)
|
|
1509
|
+
`)},Q=function(){return r.pythonGenerator.provideFunction_("downRange",`
|
|
1510
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(start, stop, step):
|
|
1511
|
+
while start >= stop:
|
|
1512
|
+
yield start
|
|
1513
|
+
start -= abs(step)
|
|
1514
|
+
`)};if(u=function(de,Y,Re){return"("+de+" <= "+Y+") and "+G()+"("+de+", "+Y+", "+Re+") or "+Q()+"("+de+", "+Y+", "+Re+")"},_.module$build$src$core$utils$string.isNumber(l)&&_.module$build$src$core$utils$string.isNumber(d)&&_.module$build$src$core$utils$string.isNumber(g))l=Number(l),d=Number(d),g=Math.abs(Number(g)),l%1===0&&d%1===0&&g%1===0?(l<=d?(d++,u=l===0&&g===1?d:l+", "+d,g!==1&&(u+=", "+g)):(d--,u=l+", "+d+", -"+g),u="range("+u+")"):(u=l<d?G():Q(),u+="("+l+", "+d+", "+g+")");else{const de=function(Y,Re){return _.module$build$src$core$utils$string.isNumber(Y)?Y=Number(Y):Y.match(/^\w+$/)||(Re=r.pythonGenerator.nameDB_.getDistinctName(c+Re,_.NameType$$module$build$src$core$names.VARIABLE),N+=Re+" = "+Y+`
|
|
1515
|
+
`,Y=Re),Y};l=de(l,"_start"),d=de(d,"_end"),g=de(g,"_inc"),typeof l=="number"&&typeof d=="number"?(u=l<d?G():Q(),u+="("+l+", "+d+", "+g+")"):u=u(l,d,g)}return N+="for "+c+" in "+u+`:
|
|
1516
|
+
`+b},r.pythonGenerator.controls_forEach=function(u){const c=r.pythonGenerator.nameDB_.getName(u.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),l=r.pythonGenerator.valueToCode(u,"LIST",r.pythonGenerator.ORDER_RELATIONAL)||"[]";let d=r.pythonGenerator.statementToCode(u,"DO");return d=r.pythonGenerator.addLoopTrap(d,u)||r.pythonGenerator.PASS,"for "+c+" in "+l+`:
|
|
1517
|
+
`+d},r.pythonGenerator.controls_flow_statements=function(u){let c="";if(r.pythonGenerator.STATEMENT_PREFIX&&(c+=r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_PREFIX,u)),r.pythonGenerator.STATEMENT_SUFFIX&&(c+=r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_SUFFIX,u)),r.pythonGenerator.STATEMENT_PREFIX){const l=u.getSurroundLoop();l&&!l.suppressPrefixSuffix&&(c+=r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_PREFIX,l))}switch(u.getFieldValue("FLOW")){case"BREAK":return c+`break
|
|
1518
|
+
`;case"CONTINUE":return c+`continue
|
|
1519
|
+
`}throw Error("Unknown flow statement.")},_.NameType$$module$build$src$core$names,r.pythonGenerator.addReservedWords("math,random,Number"),r.pythonGenerator.math_number=function(u){u=Number(u.getFieldValue("NUM"));let c;return u===1/0?(u='float("inf")',c=r.pythonGenerator.ORDER_FUNCTION_CALL):u===-1/0?(u='-float("inf")',c=r.pythonGenerator.ORDER_UNARY_SIGN):c=0>u?r.pythonGenerator.ORDER_UNARY_SIGN:r.pythonGenerator.ORDER_ATOMIC,[u,c]},r.pythonGenerator.math_arithmetic=function(u){var c={ADD:[" + ",r.pythonGenerator.ORDER_ADDITIVE],MINUS:[" - ",r.pythonGenerator.ORDER_ADDITIVE],MULTIPLY:[" * ",r.pythonGenerator.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",r.pythonGenerator.ORDER_MULTIPLICATIVE],POWER:[" ** ",r.pythonGenerator.ORDER_EXPONENTIATION]}[u.getFieldValue("OP")];const l=c[0];c=c[1];const d=r.pythonGenerator.valueToCode(u,"A",c)||"0";return u=r.pythonGenerator.valueToCode(u,"B",c)||"0",[d+l+u,c]},r.pythonGenerator.math_single=function(u){const c=u.getFieldValue("OP");let l;if(c==="NEG")return l=r.pythonGenerator.valueToCode(u,"NUM",r.pythonGenerator.ORDER_UNARY_SIGN)||"0",["-"+l,r.pythonGenerator.ORDER_UNARY_SIGN];switch(r.pythonGenerator.definitions_.import_math="import math",u=c==="SIN"||c==="COS"||c==="TAN"?r.pythonGenerator.valueToCode(u,"NUM",r.pythonGenerator.ORDER_MULTIPLICATIVE)||"0":r.pythonGenerator.valueToCode(u,"NUM",r.pythonGenerator.ORDER_NONE)||"0",c){case"ABS":l="math.fabs("+u+")";break;case"ROOT":l="math.sqrt("+u+")";break;case"LN":l="math.log("+u+")";break;case"LOG10":l="math.log10("+u+")";break;case"EXP":l="math.exp("+u+")";break;case"POW10":l="math.pow(10,"+u+")";break;case"ROUND":l="round("+u+")";break;case"ROUNDUP":l="math.ceil("+u+")";break;case"ROUNDDOWN":l="math.floor("+u+")";break;case"SIN":l="math.sin("+u+" / 180.0 * math.pi)";break;case"COS":l="math.cos("+u+" / 180.0 * math.pi)";break;case"TAN":l="math.tan("+u+" / 180.0 * math.pi)"}if(l)return[l,r.pythonGenerator.ORDER_FUNCTION_CALL];switch(c){case"ASIN":l="math.asin("+u+") / math.pi * 180";break;case"ACOS":l="math.acos("+u+") / math.pi * 180";break;case"ATAN":l="math.atan("+u+") / math.pi * 180";break;default:throw Error("Unknown math operator: "+c)}return[l,r.pythonGenerator.ORDER_MULTIPLICATIVE]},r.pythonGenerator.math_constant=function(u){const c={PI:["math.pi",r.pythonGenerator.ORDER_MEMBER],E:["math.e",r.pythonGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",r.pythonGenerator.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",r.pythonGenerator.ORDER_MEMBER],SQRT1_2:["math.sqrt(1.0 / 2)",r.pythonGenerator.ORDER_MEMBER],INFINITY:["float('inf')",r.pythonGenerator.ORDER_ATOMIC]};return u=u.getFieldValue("CONSTANT"),u!=="INFINITY"&&(r.pythonGenerator.definitions_.import_math="import math"),c[u]},r.pythonGenerator.math_number_property=function(u){var c={EVEN:[" % 2 == 0",r.pythonGenerator.ORDER_MULTIPLICATIVE,r.pythonGenerator.ORDER_RELATIONAL],ODD:[" % 2 == 1",r.pythonGenerator.ORDER_MULTIPLICATIVE,r.pythonGenerator.ORDER_RELATIONAL],WHOLE:[" % 1 == 0",r.pythonGenerator.ORDER_MULTIPLICATIVE,r.pythonGenerator.ORDER_RELATIONAL],POSITIVE:[" > 0",r.pythonGenerator.ORDER_RELATIONAL,r.pythonGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",r.pythonGenerator.ORDER_RELATIONAL,r.pythonGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,r.pythonGenerator.ORDER_MULTIPLICATIVE,r.pythonGenerator.ORDER_RELATIONAL],PRIME:[null,r.pythonGenerator.ORDER_NONE,r.pythonGenerator.ORDER_FUNCTION_CALL]};const l=u.getFieldValue("PROPERTY"),[d,g,b]=c[l];if(c=r.pythonGenerator.valueToCode(u,"NUMBER_TO_CHECK",g)||"0",l==="PRIME")r.pythonGenerator.definitions_.import_math="import math",r.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number",u=r.pythonGenerator.provideFunction_("math_isPrime",`
|
|
1520
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(n):
|
|
1521
|
+
# https://en.wikipedia.org/wiki/Primality_test#Naive_methods
|
|
1522
|
+
# If n is not a number but a string, try parsing it.
|
|
1523
|
+
if not isinstance(n, Number):
|
|
1524
|
+
try:
|
|
1525
|
+
n = float(n)
|
|
1526
|
+
except:
|
|
1527
|
+
return False
|
|
1528
|
+
if n == 2 or n == 3:
|
|
1529
|
+
return True
|
|
1530
|
+
# False if n is negative, is 1, or not whole, or if n is divisible by 2 or 3.
|
|
1531
|
+
if n <= 1 or n % 1 != 0 or n % 2 == 0 or n % 3 == 0:
|
|
1532
|
+
return False
|
|
1533
|
+
# Check all the numbers of form 6k +/- 1, up to sqrt(n).
|
|
1534
|
+
for x in range(6, int(math.sqrt(n)) + 2, 6):
|
|
1535
|
+
if n % (x - 1) == 0 or n % (x + 1) == 0:
|
|
1536
|
+
return False
|
|
1537
|
+
return True
|
|
1538
|
+
`)+"("+c+")";else if(l==="DIVISIBLE_BY"){if(u=r.pythonGenerator.valueToCode(u,"DIVISOR",r.pythonGenerator.ORDER_MULTIPLICATIVE)||"0",u==="0")return["False",r.pythonGenerator.ORDER_ATOMIC];u=c+" % "+u+" == 0"}else u=c+d;return[u,b]},r.pythonGenerator.math_change=function(u){r.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number";const c=r.pythonGenerator.valueToCode(u,"DELTA",r.pythonGenerator.ORDER_ADDITIVE)||"0";return u=r.pythonGenerator.nameDB_.getName(u.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),u+" = ("+u+" if isinstance("+u+", Number) else 0) + "+c+`
|
|
1539
|
+
`},r.pythonGenerator.math_round=r.pythonGenerator.math_single,r.pythonGenerator.math_trig=r.pythonGenerator.math_single,r.pythonGenerator.math_on_list=function(u){var c=u.getFieldValue("OP");switch(u=r.pythonGenerator.valueToCode(u,"LIST",r.pythonGenerator.ORDER_NONE)||"[]",c){case"SUM":c="sum("+u+")";break;case"MIN":c="min("+u+")";break;case"MAX":c="max("+u+")";break;case"AVERAGE":r.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number",c=r.pythonGenerator.provideFunction_("math_mean",`
|
|
1540
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
1541
|
+
localList = [e for e in myList if isinstance(e, Number)]
|
|
1542
|
+
if not localList: return
|
|
1543
|
+
return float(sum(localList)) / len(localList)
|
|
1544
|
+
`)+"("+u+")";break;case"MEDIAN":r.pythonGenerator.definitions_.from_numbers_import_Number="from numbers import Number",c=r.pythonGenerator.provideFunction_("math_median",`
|
|
1545
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList):
|
|
1546
|
+
localList = sorted([e for e in myList if isinstance(e, Number)])
|
|
1547
|
+
if not localList: return
|
|
1548
|
+
if len(localList) % 2 == 0:
|
|
1549
|
+
return (localList[len(localList) // 2 - 1] + localList[len(localList) // 2]) / 2.0
|
|
1550
|
+
else:
|
|
1551
|
+
return localList[(len(localList) - 1) // 2]
|
|
1552
|
+
`)+"("+u+")";break;case"MODE":c=r.pythonGenerator.provideFunction_("math_modes",`
|
|
1553
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(some_list):
|
|
1554
|
+
modes = []
|
|
1555
|
+
# Using a lists of [item, count] to keep count rather than dict
|
|
1556
|
+
# to avoid "unhashable" errors when the counted item is itself a list or dict.
|
|
1557
|
+
counts = []
|
|
1558
|
+
maxCount = 1
|
|
1559
|
+
for item in some_list:
|
|
1560
|
+
found = False
|
|
1561
|
+
for count in counts:
|
|
1562
|
+
if count[0] == item:
|
|
1563
|
+
count[1] += 1
|
|
1564
|
+
maxCount = max(maxCount, count[1])
|
|
1565
|
+
found = True
|
|
1566
|
+
if not found:
|
|
1567
|
+
counts.append([item, 1])
|
|
1568
|
+
for counted_item, item_count in counts:
|
|
1569
|
+
if item_count == maxCount:
|
|
1570
|
+
modes.append(counted_item)
|
|
1571
|
+
return modes
|
|
1572
|
+
`)+"("+u+")";break;case"STD_DEV":r.pythonGenerator.definitions_.import_math="import math",c=r.pythonGenerator.provideFunction_("math_standard_deviation",`
|
|
1573
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers):
|
|
1574
|
+
n = len(numbers)
|
|
1575
|
+
if n == 0: return
|
|
1576
|
+
mean = float(sum(numbers)) / n
|
|
1577
|
+
variance = sum((x - mean) ** 2 for x in numbers) / n
|
|
1578
|
+
return math.sqrt(variance)
|
|
1579
|
+
`)+"("+u+")";break;case"RANDOM":r.pythonGenerator.definitions_.import_random="import random",c="random.choice("+u+")";break;default:throw Error("Unknown operator: "+c)}return[c,r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.math_modulo=function(u){const c=r.pythonGenerator.valueToCode(u,"DIVIDEND",r.pythonGenerator.ORDER_MULTIPLICATIVE)||"0";return u=r.pythonGenerator.valueToCode(u,"DIVISOR",r.pythonGenerator.ORDER_MULTIPLICATIVE)||"0",[c+" % "+u,r.pythonGenerator.ORDER_MULTIPLICATIVE]},r.pythonGenerator.math_constrain=function(u){const c=r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"0",l=r.pythonGenerator.valueToCode(u,"LOW",r.pythonGenerator.ORDER_NONE)||"0";return u=r.pythonGenerator.valueToCode(u,"HIGH",r.pythonGenerator.ORDER_NONE)||"float('inf')",["min(max("+c+", "+l+"), "+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.math_random_int=function(u){r.pythonGenerator.definitions_.import_random="import random";const c=r.pythonGenerator.valueToCode(u,"FROM",r.pythonGenerator.ORDER_NONE)||"0";return u=r.pythonGenerator.valueToCode(u,"TO",r.pythonGenerator.ORDER_NONE)||"0",["random.randint("+c+", "+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.math_random_float=function(u){return r.pythonGenerator.definitions_.import_random="import random",["random.random()",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.math_atan2=function(u){r.pythonGenerator.definitions_.import_math="import math";const c=r.pythonGenerator.valueToCode(u,"X",r.pythonGenerator.ORDER_NONE)||"0";return["math.atan2("+(r.pythonGenerator.valueToCode(u,"Y",r.pythonGenerator.ORDER_NONE)||"0")+", "+c+") / math.pi * 180",r.pythonGenerator.ORDER_MULTIPLICATIVE]},_.module$build$src$core$variables,_.NameType$$module$build$src$core$names,r.pythonGenerator.procedures_defreturn=function(u){var c=[],l=u.workspace,d=_.module$build$src$core$variables.allUsedVarModels(l)||[];for(let Y=0,Re;Re=d[Y];Y++){var g=Re.name;u.getVars().indexOf(g)===-1&&c.push(r.pythonGenerator.nameDB_.getName(g,_.NameType$$module$build$src$core$names.VARIABLE))}for(l=_.module$build$src$core$variables.allDeveloperVariables(l),d=0;d<l.length;d++)c.push(r.pythonGenerator.nameDB_.getName(l[d],_.NameType$$module$build$src$core$names.DEVELOPER_VARIABLE));l=c.length?r.pythonGenerator.INDENT+"global "+c.join(", ")+`
|
|
1580
|
+
`:"",c=r.pythonGenerator.nameDB_.getName(u.getFieldValue("NAME"),_.NameType$$module$build$src$core$names.PROCEDURE),d="",r.pythonGenerator.STATEMENT_PREFIX&&(d+=r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_PREFIX,u)),r.pythonGenerator.STATEMENT_SUFFIX&&(d+=r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_SUFFIX,u)),d&&(d=r.pythonGenerator.prefixLines(d,r.pythonGenerator.INDENT)),g="",r.pythonGenerator.INFINITE_LOOP_TRAP&&(g=r.pythonGenerator.prefixLines(r.pythonGenerator.injectId(r.pythonGenerator.INFINITE_LOOP_TRAP,u),r.pythonGenerator.INDENT));let b=r.pythonGenerator.statementToCode(u,"STACK"),N=r.pythonGenerator.valueToCode(u,"RETURN",r.pythonGenerator.ORDER_NONE)||"",G="";b&&N&&(G=d),N?N=r.pythonGenerator.INDENT+"return "+N+`
|
|
1581
|
+
`:b||(b=r.pythonGenerator.PASS);const Q=[],de=u.getVars();for(let Y=0;Y<de.length;Y++)Q[Y]=r.pythonGenerator.nameDB_.getName(de[Y],_.NameType$$module$build$src$core$names.VARIABLE);return l="def "+c+"("+Q.join(", ")+`):
|
|
1582
|
+
`+l+d+g+b+G+N,l=r.pythonGenerator.scrub_(u,l),r.pythonGenerator.definitions_["%"+c]=l,null},r.pythonGenerator.procedures_defnoreturn=r.pythonGenerator.procedures_defreturn,r.pythonGenerator.procedures_callreturn=function(u){const c=r.pythonGenerator.nameDB_.getName(u.getFieldValue("NAME"),_.NameType$$module$build$src$core$names.PROCEDURE),l=[],d=u.getVars();for(let g=0;g<d.length;g++)l[g]=r.pythonGenerator.valueToCode(u,"ARG"+g,r.pythonGenerator.ORDER_NONE)||"None";return[c+"("+l.join(", ")+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.procedures_callnoreturn=function(u){return r.pythonGenerator.procedures_callreturn(u)[0]+`
|
|
1583
|
+
`},r.pythonGenerator.procedures_ifreturn=function(u){let c="if "+(r.pythonGenerator.valueToCode(u,"CONDITION",r.pythonGenerator.ORDER_NONE)||"False")+`:
|
|
1584
|
+
`;return r.pythonGenerator.STATEMENT_SUFFIX&&(c+=r.pythonGenerator.prefixLines(r.pythonGenerator.injectId(r.pythonGenerator.STATEMENT_SUFFIX,u),r.pythonGenerator.INDENT)),u.hasReturnValue_?(u=r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"None",c+=r.pythonGenerator.INDENT+"return "+u+`
|
|
1585
|
+
`):c+=r.pythonGenerator.INDENT+`return
|
|
1586
|
+
`,c},_.module$build$src$core$utils$string,_.NameType$$module$build$src$core$names,r.pythonGenerator.text=function(u){return[r.pythonGenerator.quote_(u.getFieldValue("TEXT")),r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.text_multiline=function(u){u=r.pythonGenerator.multiline_quote_(u.getFieldValue("TEXT"));const c=u.indexOf("+")!==-1?r.pythonGenerator.ORDER_ADDITIVE:r.pythonGenerator.ORDER_ATOMIC;return[u,c]};var $e=/^\s*'([^']|\\')*'\s*$/,he=function(u){return $e.test(u)?[u,r.pythonGenerator.ORDER_ATOMIC]:["str("+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]};return r.pythonGenerator.text_join=function(u){switch(u.itemCount_){case 0:return["''",r.pythonGenerator.ORDER_ATOMIC];case 1:return u=r.pythonGenerator.valueToCode(u,"ADD0",r.pythonGenerator.ORDER_NONE)||"''",he(u);case 2:var c=r.pythonGenerator.valueToCode(u,"ADD0",r.pythonGenerator.ORDER_NONE)||"''";return u=r.pythonGenerator.valueToCode(u,"ADD1",r.pythonGenerator.ORDER_NONE)||"''",[he(c)[0]+" + "+he(u)[0],r.pythonGenerator.ORDER_ADDITIVE];default:c=[];for(let l=0;l<u.itemCount_;l++)c[l]=r.pythonGenerator.valueToCode(u,"ADD"+l,r.pythonGenerator.ORDER_NONE)||"''";return u=r.pythonGenerator.nameDB_.getDistinctName("x",_.NameType$$module$build$src$core$names.VARIABLE),["''.join([str("+u+") for "+u+" in ["+c.join(", ")+"]])",r.pythonGenerator.ORDER_FUNCTION_CALL]}},r.pythonGenerator.text_append=function(u){const c=r.pythonGenerator.nameDB_.getName(u.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE);return u=r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_NONE)||"''",c+" = str("+c+") + "+he(u)[0]+`
|
|
1587
|
+
`},r.pythonGenerator.text_length=function(u){return["len("+(r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"''")+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.text_isEmpty=function(u){return["not len("+(r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"''")+")",r.pythonGenerator.ORDER_LOGICAL_NOT]},r.pythonGenerator.text_indexOf=function(u){var c=u.getFieldValue("END")==="FIRST"?"find":"rfind";const l=r.pythonGenerator.valueToCode(u,"FIND",r.pythonGenerator.ORDER_NONE)||"''";return c=(r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_MEMBER)||"''")+"."+c+"("+l+")",u.workspace.options.oneBasedIndex?[c+" + 1",r.pythonGenerator.ORDER_ADDITIVE]:[c,r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.text_charAt=function(u){const c=u.getFieldValue("WHERE")||"FROM_START",l=r.pythonGenerator.valueToCode(u,"VALUE",c==="RANDOM"?r.pythonGenerator.ORDER_NONE:r.pythonGenerator.ORDER_MEMBER)||"''";switch(c){case"FIRST":return[l+"[0]",r.pythonGenerator.ORDER_MEMBER];case"LAST":return[l+"[-1]",r.pythonGenerator.ORDER_MEMBER];case"FROM_START":return u=r.pythonGenerator.getAdjustedInt(u,"AT"),[l+"["+u+"]",r.pythonGenerator.ORDER_MEMBER];case"FROM_END":return u=r.pythonGenerator.getAdjustedInt(u,"AT",1,!0),[l+"["+u+"]",r.pythonGenerator.ORDER_MEMBER];case"RANDOM":return r.pythonGenerator.definitions_.import_random="import random",[r.pythonGenerator.provideFunction_("text_random_letter",`
|
|
1588
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(text):
|
|
1589
|
+
x = int(random.random() * len(text))
|
|
1590
|
+
return text[x]
|
|
1591
|
+
`)+"("+l+")",r.pythonGenerator.ORDER_FUNCTION_CALL]}throw Error("Unhandled option (text_charAt).")},r.pythonGenerator.text_getSubstring=function(u){var c=u.getFieldValue("WHERE1");const l=u.getFieldValue("WHERE2"),d=r.pythonGenerator.valueToCode(u,"STRING",r.pythonGenerator.ORDER_MEMBER)||"''";switch(c){case"FROM_START":c=r.pythonGenerator.getAdjustedInt(u,"AT1"),c===0&&(c="");break;case"FROM_END":c=r.pythonGenerator.getAdjustedInt(u,"AT1",1,!0);break;case"FIRST":c="";break;default:throw Error("Unhandled option (text_getSubstring)")}switch(l){case"FROM_START":u=r.pythonGenerator.getAdjustedInt(u,"AT2",1);break;case"FROM_END":u=r.pythonGenerator.getAdjustedInt(u,"AT2",0,!0),_.module$build$src$core$utils$string.isNumber(String(u))?u===0&&(u=""):(r.pythonGenerator.definitions_.import_sys="import sys",u+=" or sys.maxsize");break;case"LAST":u="";break;default:throw Error("Unhandled option (text_getSubstring)")}return[d+"["+c+" : "+u+"]",r.pythonGenerator.ORDER_MEMBER]},r.pythonGenerator.text_changeCase=function(u){const c={UPPERCASE:".upper()",LOWERCASE:".lower()",TITLECASE:".title()"}[u.getFieldValue("CASE")];return[(r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_MEMBER)||"''")+c,r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.text_trim=function(u){const c={LEFT:".lstrip()",RIGHT:".rstrip()",BOTH:".strip()"}[u.getFieldValue("MODE")];return[(r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_MEMBER)||"''")+c,r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.text_print=function(u){return"print("+(r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_NONE)||"''")+`)
|
|
1592
|
+
`},r.pythonGenerator.text_prompt_ext=function(u){var c=r.pythonGenerator.provideFunction_("text_prompt",`
|
|
1593
|
+
def ${r.pythonGenerator.FUNCTION_NAME_PLACEHOLDER_}(msg):
|
|
1594
|
+
try:
|
|
1595
|
+
return raw_input(msg)
|
|
1596
|
+
except NameError:
|
|
1597
|
+
return input(msg)
|
|
1598
|
+
`);let l;return l=u.getField("TEXT")?r.pythonGenerator.quote_(u.getFieldValue("TEXT")):r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_NONE)||"''",c=c+"("+l+")",u.getFieldValue("TYPE")==="NUMBER"&&(c="float("+c+")"),[c,r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.text_prompt=r.pythonGenerator.text_prompt_ext,r.pythonGenerator.text_count=function(u){const c=r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_MEMBER)||"''";return u=r.pythonGenerator.valueToCode(u,"SUB",r.pythonGenerator.ORDER_NONE)||"''",[c+".count("+u+")",r.pythonGenerator.ORDER_FUNCTION_CALL]},r.pythonGenerator.text_replace=function(u){const c=r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_MEMBER)||"''",l=r.pythonGenerator.valueToCode(u,"FROM",r.pythonGenerator.ORDER_NONE)||"''";return u=r.pythonGenerator.valueToCode(u,"TO",r.pythonGenerator.ORDER_NONE)||"''",[c+".replace("+l+", "+u+")",r.pythonGenerator.ORDER_MEMBER]},r.pythonGenerator.text_reverse=function(u){return[(r.pythonGenerator.valueToCode(u,"TEXT",r.pythonGenerator.ORDER_MEMBER)||"''")+"[::-1]",r.pythonGenerator.ORDER_MEMBER]},_.NameType$$module$build$src$core$names,r.pythonGenerator.variables_get=function(u){return[r.pythonGenerator.nameDB_.getName(u.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE),r.pythonGenerator.ORDER_ATOMIC]},r.pythonGenerator.variables_set=function(u){const c=r.pythonGenerator.valueToCode(u,"VALUE",r.pythonGenerator.ORDER_NONE)||"0";return r.pythonGenerator.nameDB_.getName(u.getFieldValue("VAR"),_.NameType$$module$build$src$core$names.VARIABLE)+" = "+c+`
|
|
1599
|
+
`},r.pythonGenerator.variables_get_dynamic=r.pythonGenerator.variables_get,r.pythonGenerator.variables_set_dynamic=r.pythonGenerator.variables_set,r.__namespace__=_,r})}(Uu)),Uu.exports}(function(q,xe){(function(n,_){q.exports=_(jn(),ZT())})(Ve,function(n,_){/**
|
|
1600
|
+
* @license
|
|
1601
|
+
* Copyright 2020 Google LLC
|
|
1602
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1603
|
+
*/return _})})(Kg);var s$=Kg.exports;export{QT as B,e$ as E,t$ as a,Vg as b,o$ as l,s$ as p};
|